diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / tools / js2c . py <nl> ppp b / tools / js2c . py <nl> def CompressScript ( lines ) : <nl> # Note that we could easily compress the scripts mode but don ' t <nl> # since we want it to remain readable . <nl> lines = re . sub ( ' / / . * \ n ' , ' \ n ' , lines ) # end - of - line comments <nl> + lines = re . sub ( re . compile ( r ' / \ * . * ? \ * / ' , re . DOTALL ) , ' ' , lines ) # comments . <nl> lines = re . sub ( ' \ s + \ n + ' , ' \ n ' , lines ) # trailing whitespace <nl> return lines <nl> <nl>
Strip / * * / style comments in js2c . Saves ~ 17k of binary size .
v8/v8
89bf4d56345a54967f6280af7a02489de840d1d4
2009-01-27T13:08:06Z
mmm a / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> ppp b / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> <nl> 2905FA6F18CF08D100240AA3 / * UIRichText . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2905FA0418CF08D000240AA3 / * UIRichText . cpp * / ; } ; <nl> 2905FA7018CF08D100240AA3 / * UIRichText . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA0518CF08D000240AA3 / * UIRichText . h * / ; } ; <nl> 2905FA7118CF08D100240AA3 / * UIRichText . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA0518CF08D000240AA3 / * UIRichText . h * / ; } ; <nl> + 2905FA7218CF08D100240AA3 / * UIScrollInterface . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA0618CF08D000240AA3 / * UIScrollInterface . h * / ; } ; <nl> + 2905FA7318CF08D100240AA3 / * UIScrollInterface . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA0618CF08D000240AA3 / * UIScrollInterface . h * / ; } ; <nl> 2905FA7418CF08D100240AA3 / * UIScrollView . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2905FA0718CF08D000240AA3 / * UIScrollView . cpp * / ; } ; <nl> 2905FA7518CF08D100240AA3 / * UIScrollView . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2905FA0718CF08D000240AA3 / * UIScrollView . cpp * / ; } ; <nl> 2905FA7618CF08D100240AA3 / * UIScrollView . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA0818CF08D000240AA3 / * UIScrollView . h * / ; } ; <nl> <nl> 2905FA8E18CF08D100240AA3 / * UIWidget . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA1418CF08D100240AA3 / * UIWidget . h * / ; } ; <nl> 2905FA8F18CF08D100240AA3 / * UIWidget . h in Headers * / = { isa = PBXBuildFile ; fileRef = 2905FA1418CF08D100240AA3 / * UIWidget . h * / ; } ; <nl> 2986667F18B1B246000E39CA / * CCTweenFunction . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2986667818B1B079000E39CA / * CCTweenFunction . cpp * / ; } ; <nl> - 29CB8F4C1929D1BB00C841D6 / * UILayoutExecutant . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 29CB8F4A1929D1BB00C841D6 / * UILayoutExecutant . cpp * / ; } ; <nl> - 29CB8F4D1929D1BB00C841D6 / * UILayoutExecutant . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 29CB8F4A1929D1BB00C841D6 / * UILayoutExecutant . cpp * / ; } ; <nl> - 29CB8F4E1929D1BB00C841D6 / * UILayoutExecutant . h in Headers * / = { isa = PBXBuildFile ; fileRef = 29CB8F4B1929D1BB00C841D6 / * UILayoutExecutant . h * / ; } ; <nl> - 29CB8F4F1929D1BB00C841D6 / * UILayoutExecutant . h in Headers * / = { isa = PBXBuildFile ; fileRef = 29CB8F4B1929D1BB00C841D6 / * UILayoutExecutant . h * / ; } ; <nl> - 29CB8F551929D7A900C841D6 / * UIScrollInterface . h in Headers * / = { isa = PBXBuildFile ; fileRef = 29CB8F541929D7A900C841D6 / * UIScrollInterface . h * / ; } ; <nl> - 29CB8F561929D7A900C841D6 / * UIScrollInterface . h in Headers * / = { isa = PBXBuildFile ; fileRef = 29CB8F541929D7A900C841D6 / * UIScrollInterface . h * / ; } ; <nl> 2AC795DB1862870F005EC8E1 / * SkeletonBounds . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2AC795D918628689005EC8E1 / * SkeletonBounds . cpp * / ; } ; <nl> 2AC795DC1862870F005EC8E1 / * Event . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2AC795D51862867D005EC8E1 / * Event . cpp * / ; } ; <nl> 2AC795DD1862870F005EC8E1 / * EventData . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 2AC795D71862867D005EC8E1 / * EventData . cpp * / ; } ; <nl> <nl> 2905FA0318CF08D000240AA3 / * UIPageView . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UIPageView . h ; sourceTree = " < group > " ; } ; <nl> 2905FA0418CF08D000240AA3 / * UIRichText . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = UIRichText . cpp ; sourceTree = " < group > " ; } ; <nl> 2905FA0518CF08D000240AA3 / * UIRichText . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UIRichText . h ; sourceTree = " < group > " ; } ; <nl> + 2905FA0618CF08D000240AA3 / * UIScrollInterface . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UIScrollInterface . h ; sourceTree = " < group > " ; } ; <nl> 2905FA0718CF08D000240AA3 / * UIScrollView . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = UIScrollView . cpp ; sourceTree = " < group > " ; } ; <nl> 2905FA0818CF08D000240AA3 / * UIScrollView . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UIScrollView . h ; sourceTree = " < group > " ; } ; <nl> 2905FA0918CF08D000240AA3 / * UISlider . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = UISlider . cpp ; sourceTree = " < group > " ; } ; <nl> <nl> 29080DEB191B82CE0066F8DF / * UIDeprecated . h * / = { isa = PBXFileReference ; lastKnownFileType = sourcecode . c . h ; path = UIDeprecated . h ; sourceTree = " < group > " ; } ; <nl> 2986667818B1B079000E39CA / * CCTweenFunction . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCTweenFunction . cpp ; sourceTree = " < group > " ; } ; <nl> 2986667918B1B079000E39CA / * CCTweenFunction . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCTweenFunction . h ; sourceTree = " < group > " ; } ; <nl> - 29CB8F4A1929D1BB00C841D6 / * UILayoutExecutant . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = UILayoutExecutant . cpp ; sourceTree = " < group > " ; } ; <nl> - 29CB8F4B1929D1BB00C841D6 / * UILayoutExecutant . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UILayoutExecutant . h ; sourceTree = " < group > " ; } ; <nl> - 29CB8F541929D7A900C841D6 / * UIScrollInterface . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = UIScrollInterface . h ; sourceTree = " < group > " ; } ; <nl> 2AC795D318628672005EC8E1 / * BoundingBoxAttachment . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = BoundingBoxAttachment . cpp ; sourceTree = " < group > " ; } ; <nl> 2AC795D418628672005EC8E1 / * BoundingBoxAttachment . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = BoundingBoxAttachment . h ; sourceTree = " < group > " ; } ; <nl> 2AC795D51862867D005EC8E1 / * Event . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = Event . cpp ; sourceTree = " < group > " ; } ; <nl> <nl> 2905F9E618CF08D000240AA3 / * ui * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> - 29CB8F531929D67D00C841D6 / * widgets * / , <nl> - 29CB8F521929D65500C841D6 / * experimental * / , <nl> - 29CB8F511929D64500C841D6 / * base * / , <nl> - 29CB8F501929D63600C841D6 / * layout * / , <nl> + 3EA0FB69191C841D00B170C8 / * UIVideoPlayer . h * / , <nl> + 3EA0FB6A191C841D00B170C8 / * UIVideoPlayerIOS . mm * / , <nl> 2905F9E918CF08D000240AA3 / * CocosGUI . cpp * / , <nl> 2905F9EA18CF08D000240AA3 / * CocosGUI . h * / , <nl> - ) ; <nl> - name = ui ; <nl> - path = . . / cocos / ui ; <nl> - sourceTree = " < group > " ; <nl> - } ; <nl> - 29CB8F501929D63600C841D6 / * layout * / = { <nl> - isa = PBXGroup ; <nl> - children = ( <nl> - 50E6D32E18E174130051CA34 / * UIHBox . cpp * / , <nl> - 50E6D32F18E174130051CA34 / * UIHBox . h * / , <nl> - 50E6D33018E174130051CA34 / * UIRelativeBox . cpp * / , <nl> - 50E6D33118E174130051CA34 / * UIRelativeBox . h * / , <nl> - 50E6D33218E174130051CA34 / * UIVBox . cpp * / , <nl> - 50E6D33318E174130051CA34 / * UIVBox . h * / , <nl> + 2905F9EB18CF08D000240AA3 / * GUIDefine . h * / , <nl> + 2905F9F018CF08D000240AA3 / * UIButton . cpp * / , <nl> + 2905F9F118CF08D000240AA3 / * UIButton . h * / , <nl> + 2905F9F218CF08D000240AA3 / * UICheckBox . cpp * / , <nl> + 2905F9F318CF08D000240AA3 / * UICheckBox . h * / , <nl> + 2905F9F418CF08D000240AA3 / * UIHelper . cpp * / , <nl> + 2905F9F518CF08D000240AA3 / * UIHelper . h * / , <nl> + 2905F9F618CF08D000240AA3 / * UIImageView . cpp * / , <nl> + 2905F9F718CF08D000240AA3 / * UIImageView . h * / , <nl> 2905F9F818CF08D000240AA3 / * UILayout . cpp * / , <nl> 2905F9F918CF08D000240AA3 / * UILayout . h * / , <nl> 2905F9FC18CF08D000240AA3 / * UILayoutParameter . cpp * / , <nl> 2905F9FD18CF08D000240AA3 / * UILayoutParameter . h * / , <nl> - 29CB8F4A1929D1BB00C841D6 / * UILayoutExecutant . cpp * / , <nl> - 29CB8F4B1929D1BB00C841D6 / * UILayoutExecutant . h * / , <nl> - ) ; <nl> - name = layout ; <nl> - sourceTree = " < group > " ; <nl> - } ; <nl> - 29CB8F511929D64500C841D6 / * base * / = { <nl> - isa = PBXGroup ; <nl> - children = ( <nl> - 29080DEB191B82CE0066F8DF / * UIDeprecated . h * / , <nl> - 2905FA1318CF08D100240AA3 / * UIWidget . cpp * / , <nl> - 2905FA1418CF08D100240AA3 / * UIWidget . h * / , <nl> - 50E6D30C18DADB5D0051CA34 / * CCProtectedNode . cpp * / , <nl> - 50E6D30D18DADB5D0051CA34 / * CCProtectedNode . h * / , <nl> - 2905F9F418CF08D000240AA3 / * UIHelper . cpp * / , <nl> - 2905F9F518CF08D000240AA3 / * UIHelper . h * / , <nl> - 2905F9EB18CF08D000240AA3 / * GUIDefine . h * / , <nl> - ) ; <nl> - name = base ; <nl> - sourceTree = " < group > " ; <nl> - } ; <nl> - 29CB8F521929D65500C841D6 / * experimental * / = { <nl> - isa = PBXGroup ; <nl> - children = ( <nl> - 3EA0FB69191C841D00B170C8 / * UIVideoPlayer . h * / , <nl> - 3EA0FB6A191C841D00B170C8 / * UIVideoPlayerIOS . mm * / , <nl> - ) ; <nl> - name = experimental ; <nl> - sourceTree = " < group > " ; <nl> - } ; <nl> - 29CB8F531929D67D00C841D6 / * widgets * / = { <nl> - isa = PBXGroup ; <nl> - children = ( <nl> 2905F9FE18CF08D000240AA3 / * UIListView . cpp * / , <nl> 2905F9FF18CF08D000240AA3 / * UIListView . h * / , <nl> 2905FA0018CF08D000240AA3 / * UILoadingBar . cpp * / , <nl> <nl> 2905FA0318CF08D000240AA3 / * UIPageView . h * / , <nl> 2905FA0418CF08D000240AA3 / * UIRichText . cpp * / , <nl> 2905FA0518CF08D000240AA3 / * UIRichText . h * / , <nl> + 2905FA0618CF08D000240AA3 / * UIScrollInterface . h * / , <nl> 2905FA0718CF08D000240AA3 / * UIScrollView . cpp * / , <nl> 2905FA0818CF08D000240AA3 / * UIScrollView . h * / , <nl> - 29CB8F541929D7A900C841D6 / * UIScrollInterface . h * / , <nl> 2905FA0918CF08D000240AA3 / * UISlider . cpp * / , <nl> 2905FA0A18CF08D100240AA3 / * UISlider . h * / , <nl> 2905FA0B18CF08D100240AA3 / * UIText . cpp * / , <nl> <nl> 2905FA1018CF08D100240AA3 / * UITextBMFont . h * / , <nl> 2905FA1118CF08D100240AA3 / * UITextField . cpp * / , <nl> 2905FA1218CF08D100240AA3 / * UITextField . h * / , <nl> - 2905F9F018CF08D000240AA3 / * UIButton . cpp * / , <nl> - 2905F9F118CF08D000240AA3 / * UIButton . h * / , <nl> - 2905F9F218CF08D000240AA3 / * UICheckBox . cpp * / , <nl> - 2905F9F318CF08D000240AA3 / * UICheckBox . h * / , <nl> - 2905F9F618CF08D000240AA3 / * UIImageView . cpp * / , <nl> - 2905F9F718CF08D000240AA3 / * UIImageView . h * / , <nl> + 2905FA1318CF08D100240AA3 / * UIWidget . cpp * / , <nl> + 2905FA1418CF08D100240AA3 / * UIWidget . h * / , <nl> + 50E6D30C18DADB5D0051CA34 / * CCProtectedNode . cpp * / , <nl> + 50E6D30D18DADB5D0051CA34 / * CCProtectedNode . h * / , <nl> + 50E6D32E18E174130051CA34 / * UIHBox . cpp * / , <nl> + 50E6D32F18E174130051CA34 / * UIHBox . h * / , <nl> + 50E6D33018E174130051CA34 / * UIRelativeBox . cpp * / , <nl> + 50E6D33118E174130051CA34 / * UIRelativeBox . h * / , <nl> + 50E6D33218E174130051CA34 / * UIVBox . cpp * / , <nl> + 50E6D33318E174130051CA34 / * UIVBox . h * / , <nl> + 29080DEB191B82CE0066F8DF / * UIDeprecated . h * / , <nl> ) ; <nl> - name = widgets ; <nl> + name = ui ; <nl> + path = . . / cocos / ui ; <nl> sourceTree = " < group > " ; <nl> } ; <nl> 37936A361869B76800E974DD / * internal * / = { <nl> <nl> 5034CA39191D591100CE6051 / * ccShader_PositionColorLengthTexture . frag in Headers * / , <nl> 2AC795DF18628723005EC8E1 / * SkeletonBounds . h in Headers * / , <nl> 50ABBE891925AB6F00A911A9 / * CCMap . h in Headers * / , <nl> - 29CB8F4E1929D1BB00C841D6 / * UILayoutExecutant . h in Headers * / , <nl> 2AC795E018628723005EC8E1 / * Event . h in Headers * / , <nl> 2AC795E118628723005EC8E1 / * EventData . h in Headers * / , <nl> 50E6D33618E174130051CA34 / * UIHBox . h in Headers * / , <nl> <nl> 1AD71DED180E26E600808F54 / * CCMenuLoader . h in Headers * / , <nl> 50ABBE8F1925AB6F00A911A9 / * CCPlatformConfig . h in Headers * / , <nl> 1AD71DF1180E26E600808F54 / * CCNode + CCBRelativePositioning . h in Headers * / , <nl> + 2905FA7218CF08D100240AA3 / * UIScrollInterface . h in Headers * / , <nl> 1AD71DF5180E26E600808F54 / * CCNodeLoader . h in Headers * / , <nl> 1AD71DF9180E26E600808F54 / * CCNodeLoaderLibrary . h in Headers * / , <nl> 50ABBE291925AB6F00A911A9 / * CCAutoreleasePool . h in Headers * / , <nl> <nl> 50ABBD9D1925AB4100A911A9 / * ccGLStateCache . h in Headers * / , <nl> 50ABBEB91925AB6F00A911A9 / * ccUTF8 . h in Headers * / , <nl> 1AAF536E180E3374000584C8 / * HttpRequest . h in Headers * / , <nl> - 29CB8F551929D7A900C841D6 / * UIScrollInterface . h in Headers * / , <nl> 1AAF5370180E3374000584C8 / * HttpResponse . h in Headers * / , <nl> 50ABBE671925AB6F00A911A9 / * CCEventListenerCustom . h in Headers * / , <nl> 1AAF5374180E3374000584C8 / * SocketIO . h in Headers * / , <nl> <nl> 503DD8E41926736A00CD74DD / * CCDirectorCaller . h in Headers * / , <nl> 50ABBD8A1925AB4100A911A9 / * CCCustomCommand . h in Headers * / , <nl> 2905FA6D18CF08D100240AA3 / * UIPageView . h in Headers * / , <nl> + 2905FA7318CF08D100240AA3 / * UIScrollInterface . h in Headers * / , <nl> 50ABBE881925AB6F00A911A9 / * ccMacros . h in Headers * / , <nl> 50ABC0101926664800A911A9 / * CCFileUtils . h in Headers * / , <nl> 2905FA4318CF08D100240AA3 / * CocosGUI . h in Headers * / , <nl> <nl> 50ABBD921925AB4100A911A9 / * CCGLProgramCache . h in Headers * / , <nl> 1AD71E0E180E26E600808F54 / * CocosBuilder . h in Headers * / , <nl> B29594C91926D61F003EEF37 / * CCObjLoader . h in Headers * / , <nl> - 29CB8F561929D7A900C841D6 / * UIScrollInterface . h in Headers * / , <nl> 1AD71E98180E26E600808F54 / * Animation . h in Headers * / , <nl> 1AD71E9C180E26E600808F54 / * AnimationState . h in Headers * / , <nl> 50ABBE961925AB6F00A911A9 / * CCProfiling . h in Headers * / , <nl> <nl> 1A8C59E2180E930E00EF57C3 / * CCInputDelegate . h in Headers * / , <nl> 503DD8EA1926736A00CD74DD / * CCESRenderer . h in Headers * / , <nl> 1A8C59E6180E930E00EF57C3 / * CCProcessBase . h in Headers * / , <nl> - 29CB8F4F1929D1BB00C841D6 / * UILayoutExecutant . h in Headers * / , <nl> 50ABBE581925AB6F00A911A9 / * CCEventFocus . h in Headers * / , <nl> 50ABC00A1926664800A911A9 / * CCCommon . h in Headers * / , <nl> 2905FA5918CF08D100240AA3 / * UILayout . h in Headers * / , <nl> <nl> 2905FA4018CF08D100240AA3 / * CocosGUI . cpp in Sources * / , <nl> 1AD71EC1180E26E600808F54 / * extension . cpp in Sources * / , <nl> 50ABBE511925AB6F00A911A9 / * CCEventDispatcher . cpp in Sources * / , <nl> - 29CB8F4C1929D1BB00C841D6 / * UILayoutExecutant . cpp in Sources * / , <nl> 50ABC0051926664800A911A9 / * CCThread . mm in Sources * / , <nl> 1AD71EC5180E26E600808F54 / * Json . cpp in Sources * / , <nl> 50E6D33C18E174130051CA34 / * UIVBox . cpp in Sources * / , <nl> <nl> 50FCEBAC18C72017004AD434 / * PageViewReader . cpp in Sources * / , <nl> 1A8C598C180E930E00EF57C3 / * CCActionFrame . cpp in Sources * / , <nl> 1A8C5990180E930E00EF57C3 / * CCActionFrameEasing . cpp in Sources * / , <nl> - 29CB8F4D1929D1BB00C841D6 / * UILayoutExecutant . cpp in Sources * / , <nl> 50FCEBA418C72017004AD434 / * ListViewReader . cpp in Sources * / , <nl> 1A8C5994180E930E00EF57C3 / * CCActionManagerEx . cpp in Sources * / , <nl> 50ABBEBC1925AB6F00A911A9 / * ccUtils . cpp in Sources * / , <nl> mmm a / cocos / ui / Android . mk <nl> ppp b / cocos / ui / Android . mk <nl> LOCAL_SRC_FILES : = \ <nl> UIWidget . cpp \ <nl> UILayout . cpp \ <nl> UILayoutParameter . cpp \ <nl> - UILayoutExecutant . cpp \ <nl> CocosGUI . cpp \ <nl> UIHelper . cpp \ <nl> UIListView . cpp \ <nl> mmm a / cocos / ui / CMakeLists . txt <nl> ppp b / cocos / ui / CMakeLists . txt <nl> set ( COCOS_UI_SRC <nl> ui / UIImageView . cpp <nl> ui / UILayout . cpp <nl> ui / UILayoutParameter . cpp <nl> - ui / UILayoutExecutant . cpp <nl> ui / UIListView . cpp <nl> ui / UILoadingBar . cpp <nl> ui / UIPageView . cpp <nl> mmm a / cocos / ui / UILayout . cpp <nl> ppp b / cocos / ui / UILayout . cpp <nl> THE SOFTWARE . <nl> # include " renderer / CCRenderer . h " <nl> # include " renderer / CCGroupCommand . h " <nl> # include " renderer / CCCustomCommand . h " <nl> - # include " ui / UILayoutExecutant . h " <nl> <nl> NS_CC_BEGIN <nl> <nl> namespace ui { <nl> <nl> + class LayoutExecutant : public Ref <nl> + { <nl> + public : <nl> + LayoutExecutant ( ) { } ; <nl> + virtual ~ LayoutExecutant ( ) { } ; <nl> + static LayoutExecutant * create ( ) ; <nl> + virtual void doLayout ( const Size & layoutSize , Vector < Node * > container ) { } ; <nl> + } ; <nl> + <nl> + class LinearVerticalLayoutExecutant : public LayoutExecutant <nl> + { <nl> + public : <nl> + LinearVerticalLayoutExecutant ( ) { } ; <nl> + virtual ~ LinearVerticalLayoutExecutant ( ) { } ; <nl> + static LinearVerticalLayoutExecutant * create ( ) ; <nl> + virtual void doLayout ( const Size & layoutSize , Vector < Node * > container ) ; <nl> + } ; <nl> + <nl> + class LinearHorizontalLayoutExecutant : public LayoutExecutant <nl> + { <nl> + public : <nl> + LinearHorizontalLayoutExecutant ( ) { } ; <nl> + virtual ~ LinearHorizontalLayoutExecutant ( ) { } ; <nl> + static LinearHorizontalLayoutExecutant * create ( ) ; <nl> + virtual void doLayout ( const Size & layoutSize , Vector < Node * > container ) ; <nl> + } ; <nl> + <nl> + class RelativeLayoutExecutant : public LayoutExecutant <nl> + { <nl> + public : <nl> + RelativeLayoutExecutant ( ) { } ; <nl> + virtual ~ RelativeLayoutExecutant ( ) { } ; <nl> + static RelativeLayoutExecutant * create ( ) ; <nl> + virtual void doLayout ( const Size & layoutSize , Vector < Node * > container ) ; <nl> + } ; <nl> + <nl> + LayoutExecutant * LayoutExecutant : : create ( ) <nl> + { <nl> + LayoutExecutant * exe = new LayoutExecutant ( ) ; <nl> + if ( exe ) <nl> + { <nl> + exe - > autorelease ( ) ; <nl> + return exe ; <nl> + } <nl> + CC_SAFE_DELETE ( exe ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + LinearVerticalLayoutExecutant * LinearVerticalLayoutExecutant : : create ( ) <nl> + { <nl> + LinearVerticalLayoutExecutant * exe = new LinearVerticalLayoutExecutant ( ) ; <nl> + if ( exe ) <nl> + { <nl> + exe - > autorelease ( ) ; <nl> + return exe ; <nl> + } <nl> + CC_SAFE_DELETE ( exe ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + LinearHorizontalLayoutExecutant * LinearHorizontalLayoutExecutant : : create ( ) <nl> + { <nl> + LinearHorizontalLayoutExecutant * exe = new LinearHorizontalLayoutExecutant ( ) ; <nl> + if ( exe ) <nl> + { <nl> + exe - > autorelease ( ) ; <nl> + return exe ; <nl> + } <nl> + CC_SAFE_DELETE ( exe ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + RelativeLayoutExecutant * RelativeLayoutExecutant : : create ( ) <nl> + { <nl> + RelativeLayoutExecutant * exe = new RelativeLayoutExecutant ( ) ; <nl> + if ( exe ) <nl> + { <nl> + exe - > autorelease ( ) ; <nl> + return exe ; <nl> + } <nl> + CC_SAFE_DELETE ( exe ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + void LinearVerticalLayoutExecutant : : doLayout ( const cocos2d : : Size & layoutSize , Vector < cocos2d : : Node * > container ) <nl> + { <nl> + float topBoundary = layoutSize . height ; <nl> + <nl> + for ( auto & subWidget : container ) <nl> + { <nl> + Widget * child = dynamic_cast < Widget * > ( subWidget ) ; <nl> + if ( child ) <nl> + { <nl> + LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( LayoutParameter : : Type : : LINEAR ) ) ; <nl> + <nl> + if ( layoutParameter ) <nl> + { <nl> + LinearLayoutParameter : : LinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> + Vec2 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> + { <nl> + case LinearLayoutParameter : : LinearGravity : : NONE : <nl> + case LinearLayoutParameter : : LinearGravity : : LEFT : <nl> + break ; <nl> + case LinearLayoutParameter : : LinearGravity : : RIGHT : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + break ; <nl> + case LinearLayoutParameter : : LinearGravity : : CENTER_HORIZONTAL : <nl> + finalPosX = layoutSize . width / 2 . 0f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + Margin mg = layoutParameter - > getMargin ( ) ; <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + child - > setPosition ( Vec2 ( finalPosX , finalPosY ) ) ; <nl> + topBoundary = child - > getBottomInParent ( ) - mg . bottom ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + void LinearHorizontalLayoutExecutant : : doLayout ( const cocos2d : : Size & layoutSize , Vector < cocos2d : : Node * > container ) <nl> + { <nl> + float leftBoundary = 0 . 0f ; <nl> + for ( auto & subWidget : container ) <nl> + { <nl> + Widget * child = dynamic_cast < Widget * > ( subWidget ) ; <nl> + if ( child ) <nl> + { <nl> + LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( LayoutParameter : : Type : : LINEAR ) ) ; <nl> + if ( layoutParameter ) <nl> + { <nl> + LinearLayoutParameter : : LinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> + Vec2 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> + { <nl> + case LinearLayoutParameter : : LinearGravity : : NONE : <nl> + case LinearLayoutParameter : : LinearGravity : : TOP : <nl> + break ; <nl> + case LinearLayoutParameter : : LinearGravity : : BOTTOM : <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + case LinearLayoutParameter : : LinearGravity : : CENTER_VERTICAL : <nl> + finalPosY = layoutSize . height / 2 . 0f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + Margin mg = layoutParameter - > getMargin ( ) ; <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + child - > setPosition ( Vec2 ( finalPosX , finalPosY ) ) ; <nl> + leftBoundary = child - > getRightInParent ( ) + mg . right ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + void RelativeLayoutExecutant : : doLayout ( const cocos2d : : Size & layoutSize , Vector < cocos2d : : Node * > container ) <nl> + { <nl> + ssize_t unlayoutChildCount = 0 ; <nl> + Vector < Widget * > widgetChildren ; <nl> + for ( auto & subWidget : container ) <nl> + { <nl> + Widget * child = dynamic_cast < Widget * > ( subWidget ) ; <nl> + if ( child ) <nl> + { <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LayoutParameter : : Type : : RELATIVE ) ) ; <nl> + layoutParameter - > _put = false ; <nl> + unlayoutChildCount + + ; <nl> + widgetChildren . pushBack ( child ) ; <nl> + } <nl> + } <nl> + while ( unlayoutChildCount > 0 ) <nl> + { <nl> + for ( auto & subWidget : widgetChildren ) <nl> + { <nl> + Widget * child = static_cast < Widget * > ( subWidget ) ; <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LayoutParameter : : Type : : RELATIVE ) ) ; <nl> + <nl> + if ( layoutParameter ) <nl> + { <nl> + if ( layoutParameter - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + Vec2 ap = child - > getAnchorPoint ( ) ; <nl> + Size cs = child - > getSize ( ) ; <nl> + RelativeLayoutParameter : : RelativeAlign align = layoutParameter - > getAlign ( ) ; <nl> + const std : : string relativeName = layoutParameter - > getRelativeToWidgetName ( ) ; <nl> + Widget * relativeWidget = nullptr ; <nl> + RelativeLayoutParameter * relativeWidgetLP = nullptr ; <nl> + float finalPosX = 0 . 0f ; <nl> + float finalPosY = 0 . 0f ; <nl> + if ( ! relativeName . empty ( ) ) <nl> + { <nl> + for ( auto & sWidget : widgetChildren ) <nl> + { <nl> + if ( sWidget ) <nl> + { <nl> + RelativeLayoutParameter * rlayoutParameter = dynamic_cast < RelativeLayoutParameter * > ( sWidget - > getLayoutParameter ( LayoutParameter : : Type : : RELATIVE ) ) ; <nl> + if ( rlayoutParameter & & rlayoutParameter - > getRelativeName ( ) = = relativeName ) <nl> + { <nl> + relativeWidget = sWidget ; <nl> + relativeWidgetLP = rlayoutParameter ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + switch ( align ) <nl> + { <nl> + case RelativeLayoutParameter : : RelativeAlign : : NONE : <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_LEFT : <nl> + finalPosX = ap . x * cs . width ; <nl> + finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_CENTER_HORIZONTAL : <nl> + finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_RIGHT : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_CENTER_VERTICAL : <nl> + finalPosX = ap . x * cs . width ; <nl> + finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : CENTER_IN_PARENT : <nl> + finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_CENTER_VERTICAL : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_BOTTOM : <nl> + finalPosX = ap . x * cs . width ; <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_BOTTOM_CENTER_HORIZONTAL : <nl> + finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_BOTTOM : <nl> + finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> + finalPosY = ap . y * cs . height ; <nl> + break ; <nl> + <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_LEFTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> + <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = relativeWidget - > getLeftInParent ( ) + rbs . width * 0 . 5f + ap . x * cs . width - cs . width * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_RIGHTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getTopInParent ( ) ; <nl> + float locationRight = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_TOPALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getTopInParent ( ) ; <nl> + float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + <nl> + finalPosY = relativeWidget - > getBottomInParent ( ) + rbs . height * 0 . 5f + ap . y * cs . height - cs . height * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_BOTTOMALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationRight = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_TOPALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getTopInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + <nl> + finalPosY = relativeWidget - > getBottomInParent ( ) + rbs . height * 0 . 5f + ap . y * cs . height - cs . height * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationBottom = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationBottom + ap . y * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_LEFTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationLeft = relativeWidget - > getLeftInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationLeft + ap . x * cs . width ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_CENTER : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + Size rbs = relativeWidget - > getSize ( ) ; <nl> + float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> + <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = relativeWidget - > getLeftInParent ( ) + rbs . width * 0 . 5f + ap . x * cs . width - cs . width * 0 . 5f ; <nl> + } <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_RIGHTALIGN : <nl> + if ( relativeWidget ) <nl> + { <nl> + if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> + { <nl> + continue ; <nl> + } <nl> + float locationTop = relativeWidget - > getBottomInParent ( ) ; <nl> + float locationRight = relativeWidget - > getRightInParent ( ) ; <nl> + finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> + finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> + } <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + Margin relativeWidgetMargin ; <nl> + Margin mg = layoutParameter - > getMargin ( ) ; <nl> + if ( relativeWidgetLP ) <nl> + { <nl> + relativeWidgetMargin = relativeWidgetLP - > getMargin ( ) ; <nl> + } <nl> + / / handle margin <nl> + switch ( align ) <nl> + { <nl> + case RelativeLayoutParameter : : RelativeAlign : : NONE : <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_LEFT : <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_CENTER_HORIZONTAL : <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_RIGHT : <nl> + finalPosX - = mg . right ; <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_CENTER_VERTICAL : <nl> + finalPosX + = mg . left ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : CENTER_IN_PARENT : <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_CENTER_VERTICAL : <nl> + finalPosX - = mg . right ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_BOTTOM : <nl> + finalPosX + = mg . left ; <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_BOTTOM_CENTER_HORIZONTAL : <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_BOTTOM : <nl> + finalPosX - = mg . right ; <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_LEFTALIGN : <nl> + finalPosY + = mg . bottom ; <nl> + finalPosX + = mg . left ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_RIGHTALIGN : <nl> + finalPosY + = mg . bottom ; <nl> + finalPosX - = mg . right ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_CENTER : <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_TOPALIGN : <nl> + finalPosX - = mg . right ; <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_BOTTOMALIGN : <nl> + finalPosX - = mg . right ; <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_CENTER : <nl> + finalPosX - = mg . right ; <nl> + break ; <nl> + <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_TOPALIGN : <nl> + finalPosX + = mg . left ; <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> + finalPosX + = mg . left ; <nl> + finalPosY + = mg . bottom ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_CENTER : <nl> + finalPosX + = mg . left ; <nl> + break ; <nl> + <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_LEFTALIGN : <nl> + finalPosY - = mg . top ; <nl> + finalPosX + = mg . left ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_RIGHTALIGN : <nl> + finalPosY - = mg . top ; <nl> + finalPosX - = mg . right ; <nl> + break ; <nl> + case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_CENTER : <nl> + finalPosY - = mg . top ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + child - > setPosition ( Vec2 ( finalPosX , finalPosY ) ) ; <nl> + layoutParameter - > _put = true ; <nl> + unlayoutChildCount - - ; <nl> + } <nl> + } <nl> + } <nl> + widgetChildren . clear ( ) ; <nl> + } <nl> + <nl> static const int BACKGROUNDIMAGE_Z = ( - 1 ) ; <nl> static const int BCAKGROUNDCOLORRENDERER_Z = ( - 2 ) ; <nl> <nl> _currentAlphaTestFunc ( GL_ALWAYS ) , <nl> _currentAlphaTestRef ( 1 ) , <nl> _backGroundImageColor ( Color3B : : WHITE ) , <nl> _backGroundImageOpacity ( 255 ) , <nl> + _curLayoutExecutant ( nullptr ) , <nl> _passFocusToChild ( true ) , <nl> _loopFocus ( false ) <nl> { <nl> _loopFocus ( false ) <nl> Layout : : ~ Layout ( ) <nl> { <nl> CC_SAFE_RELEASE ( _clippingStencil ) ; <nl> + CC_SAFE_RELEASE ( _curLayoutExecutant ) ; <nl> } <nl> <nl> void Layout : : onEnter ( ) <nl> void Layout : : supplyTheLayoutParameterLackToChild ( Widget * child ) <nl> case Type : : HORIZONTAL : <nl> case Type : : VERTICAL : <nl> { <nl> - LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> + LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( LayoutParameter : : Type : : LINEAR ) ) ; <nl> if ( ! layoutParameter ) <nl> { <nl> child - > setLayoutParameter ( LinearLayoutParameter : : create ( ) ) ; <nl> void Layout : : supplyTheLayoutParameterLackToChild ( Widget * child ) <nl> } <nl> case Type : : RELATIVE : <nl> { <nl> - RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> + RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( LayoutParameter : : Type : : RELATIVE ) ) ; <nl> if ( ! layoutParameter ) <nl> { <nl> child - > setLayoutParameter ( RelativeLayoutParameter : : create ( ) ) ; <nl> const Size & Layout : : getBackGroundImageTextureSize ( ) const <nl> void Layout : : setLayoutType ( Type type ) <nl> { <nl> _layoutType = type ; <nl> - <nl> + CC_SAFE_RELEASE_NULL ( _curLayoutExecutant ) ; <nl> + _curLayoutExecutant = createCurrentLayoutExecutant ( ) ; <nl> + CC_SAFE_RETAIN ( _curLayoutExecutant ) ; <nl> for ( auto & child : _children ) <nl> { <nl> Widget * widgetChild = dynamic_cast < Widget * > ( child ) ; <nl> void Layout : : setLayoutType ( Type type ) <nl> _doLayoutDirty = true ; <nl> } <nl> <nl> - <nl> - <nl> - Layout : : Type Layout : : getLayoutType ( ) const <nl> - { <nl> - return _layoutType ; <nl> - } <nl> - <nl> - void Layout : : requestDoLayout ( ) <nl> - { <nl> - _doLayoutDirty = true ; <nl> - } <nl> - <nl> - const Size Layout : : getLayoutContentSize ( ) <nl> - { <nl> - return this - > getSize ( ) ; <nl> - } <nl> - <nl> - const Vector < Node * > & Layout : : getLayoutElements ( ) <nl> - { <nl> - return this - > getChildren ( ) ; <nl> - } <nl> - <nl> - LayoutExecutant * Layout : : createLayoutExecutant ( ) <nl> + LayoutExecutant * Layout : : createCurrentLayoutExecutant ( ) <nl> { <nl> LayoutExecutant * exe = nullptr ; <nl> switch ( _layoutType ) <nl> LayoutExecutant * Layout : : createLayoutExecutant ( ) <nl> break ; <nl> } <nl> return exe ; <nl> + } <nl> <nl> + Layout : : Type Layout : : getLayoutType ( ) const <nl> + { <nl> + return _layoutType ; <nl> + } <nl> + <nl> + void Layout : : requestDoLayout ( ) <nl> + { <nl> + _doLayoutDirty = true ; <nl> } <nl> <nl> void Layout : : doLayout ( ) <nl> void Layout : : doLayout ( ) <nl> { <nl> return ; <nl> } <nl> - LayoutExecutant * executant = this - > createLayoutExecutant ( ) ; <nl> - <nl> - if ( executant ) <nl> + if ( _curLayoutExecutant ) <nl> { <nl> - executant - > doLayout ( this ) ; <nl> + _curLayoutExecutant - > doLayout ( getSize ( ) , getChildren ( ) ) ; <nl> } <nl> - <nl> _doLayoutDirty = false ; <nl> } <nl> <nl> bool Layout : : isPassFocusToChild ( ) <nl> return _passFocusToChild ; <nl> } <nl> <nl> - Size Layout : : getLayoutAccumulatedSize ( ) const <nl> + Size Layout : : getLayoutContentSize ( ) const <nl> { <nl> const auto & children = this - > getChildren ( ) ; <nl> Size layoutSize = Size : : ZERO ; <nl> Size Layout : : getLayoutAccumulatedSize ( ) const <nl> Layout * layout = dynamic_cast < Layout * > ( widget ) ; <nl> if ( nullptr ! = layout ) <nl> { <nl> - layoutSize = layoutSize + layout - > getLayoutAccumulatedSize ( ) ; <nl> + layoutSize = layoutSize + layout - > getLayoutContentSize ( ) ; <nl> } <nl> else <nl> { <nl> Size Layout : : getLayoutAccumulatedSize ( ) const <nl> if ( w ) <nl> { <nl> widgetCount + + ; <nl> - Margin m = w - > getLayoutParameter ( ) - > getMargin ( ) ; <nl> + Margin m = w - > getLayoutParameter ( LayoutParameter : : Type : : LINEAR ) - > getMargin ( ) ; <nl> layoutSize = layoutSize + w - > getSize ( ) + Size ( m . right + m . left , m . top + m . bottom ) * 0 . 5 ; <nl> } <nl> } <nl> Vec2 Layout : : getWorldCenterPoint ( Widget * widget ) <nl> { <nl> Layout * layout = dynamic_cast < Layout * > ( widget ) ; <nl> / / FIXEDME : we don ' t need to calculate the content size of layout anymore <nl> - Size widgetSize = layout ? layout - > getLayoutAccumulatedSize ( ) : widget - > getSize ( ) ; <nl> + Size widgetSize = layout ? layout - > getLayoutContentSize ( ) : widget - > getSize ( ) ; <nl> / / CCLOG ( " contnet size : width = % f , height = % f " , widgetSize . width , widgetSize . height ) ; <nl> return widget - > convertToWorldSpace ( Vec2 ( widgetSize . width / 2 , widgetSize . height / 2 ) ) ; <nl> } <nl> mmm a / cocos / ui / UILayout . h <nl> ppp b / cocos / ui / UILayout . h <nl> THE SOFTWARE . <nl> NS_CC_BEGIN <nl> <nl> namespace ui { <nl> - <nl> - class LayoutExecutant ; <nl> - <nl> - class LayoutProtocol <nl> - { <nl> - public : <nl> - LayoutProtocol ( ) { } <nl> - virtual ~ LayoutProtocol ( ) { } <nl> - <nl> - virtual LayoutExecutant * createLayoutExecutant ( ) = 0 ; <nl> - virtual const Size getLayoutContentSize ( ) = 0 ; <nl> - virtual const Vector < Node * > & getLayoutElements ( ) = 0 ; <nl> - virtual void doLayout ( ) = 0 ; <nl> - } ; <nl> <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> + class LayoutExecutant ; <nl> <nl> - class Layout : public Widget , public LayoutProtocol <nl> + class Layout : public Widget <nl> { <nl> <nl> DECLARE_CLASS_GUI_INFO <nl> class Layout : public Widget , public LayoutProtocol <nl> <nl> void setStencilClippingSize ( const Size & size ) ; <nl> const Rect & getClippingRect ( ) ; <nl> - <nl> - virtual void doLayout ( ) override ; <nl> - virtual LayoutExecutant * createLayoutExecutant ( ) override ; <nl> - virtual const Size getLayoutContentSize ( ) override ; <nl> - virtual const Vector < Node * > & getLayoutElements ( ) override ; <nl> + virtual void doLayout ( ) ; <nl> <nl> / / clipping <nl> void onBeforeVisitStencil ( ) ; <nl> class Layout : public Widget , public LayoutProtocol <nl> void updateBackGroundImageColor ( ) ; <nl> void updateBackGroundImageOpacity ( ) ; <nl> void updateBackGroundImageRGBA ( ) ; <nl> + LayoutExecutant * createCurrentLayoutExecutant ( ) ; <nl> <nl> / * * <nl> * get the content size of the layout , it will accumulate all its children ' s content size <nl> * / <nl> - Size getLayoutAccumulatedSize ( ) const ; <nl> + Size getLayoutContentSize ( ) const ; <nl> <nl> / * * <nl> * When the layout get focused , it the layout pass the focus to its child , it will use this method to determine which child <nl> class Layout : public Widget , public LayoutProtocol <nl> Color3B _backGroundImageColor ; <nl> GLubyte _backGroundImageOpacity ; <nl> <nl> + LayoutExecutant * _curLayoutExecutant ; <nl> + <nl> GLint _mask_layer_le ; <nl> GroupCommand _groupCommand ; <nl> CustomCommand _beforeVisitCmdStencil ; <nl> deleted file mode 100644 <nl> index 30ac2f2e0b5d . . 000000000000 <nl> mmm a / cocos / ui / UILayoutExecutant . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 - 2014 Chukong Technologies Inc . <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 " UILayoutExecutant . h " <nl> - # include " UILayout . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - namespace ui { <nl> - <nl> - LinearVerticalLayoutExecutant * LinearVerticalLayoutExecutant : : create ( ) <nl> - { <nl> - LinearVerticalLayoutExecutant * exe = new LinearVerticalLayoutExecutant ( ) ; <nl> - if ( exe ) <nl> - { <nl> - exe - > autorelease ( ) ; <nl> - return exe ; <nl> - } <nl> - CC_SAFE_DELETE ( exe ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - LinearHorizontalLayoutExecutant * LinearHorizontalLayoutExecutant : : create ( ) <nl> - { <nl> - LinearHorizontalLayoutExecutant * exe = new LinearHorizontalLayoutExecutant ( ) ; <nl> - if ( exe ) <nl> - { <nl> - exe - > autorelease ( ) ; <nl> - return exe ; <nl> - } <nl> - CC_SAFE_DELETE ( exe ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - RelativeLayoutExecutant * RelativeLayoutExecutant : : create ( ) <nl> - { <nl> - RelativeLayoutExecutant * exe = new RelativeLayoutExecutant ( ) ; <nl> - if ( exe ) <nl> - { <nl> - exe - > autorelease ( ) ; <nl> - return exe ; <nl> - } <nl> - CC_SAFE_DELETE ( exe ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - void LinearVerticalLayoutExecutant : : doLayout ( LayoutProtocol * layout ) <nl> - { <nl> - Size layoutSize = layout - > getLayoutContentSize ( ) ; <nl> - Vector < Node * > container = layout - > getLayoutElements ( ) ; <nl> - float topBoundary = layoutSize . height ; <nl> - <nl> - for ( auto & subWidget : container ) <nl> - { <nl> - LayoutParameterProtocol * child = dynamic_cast < LayoutParameterProtocol * > ( subWidget ) ; <nl> - if ( child ) <nl> - { <nl> - LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - <nl> - if ( layoutParameter ) <nl> - { <nl> - LinearLayoutParameter : : LinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> - Vec2 ap = subWidget - > getAnchorPoint ( ) ; <nl> - Size cs = subWidget - > getContentSize ( ) ; <nl> - float finalPosX = ap . x * cs . width ; <nl> - float finalPosY = topBoundary - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> - switch ( childGravity ) <nl> - { <nl> - case LinearLayoutParameter : : LinearGravity : : NONE : <nl> - case LinearLayoutParameter : : LinearGravity : : LEFT : <nl> - break ; <nl> - case LinearLayoutParameter : : LinearGravity : : RIGHT : <nl> - finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> - break ; <nl> - case LinearLayoutParameter : : LinearGravity : : CENTER_HORIZONTAL : <nl> - finalPosX = layoutSize . width / 2 . 0f - cs . width * ( 0 . 5f - ap . x ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - Margin mg = layoutParameter - > getMargin ( ) ; <nl> - finalPosX + = mg . left ; <nl> - finalPosY - = mg . top ; <nl> - subWidget - > setPosition ( Vec2 ( finalPosX , finalPosY ) ) ; <nl> - topBoundary = subWidget - > getPosition ( ) . y - subWidget - > getAnchorPoint ( ) . y * subWidget - > getContentSize ( ) . height - mg . bottom ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void LinearHorizontalLayoutExecutant : : doLayout ( LayoutProtocol * layout ) <nl> - { <nl> - Size layoutSize = layout - > getLayoutContentSize ( ) ; <nl> - Vector < Node * > container = layout - > getLayoutElements ( ) ; <nl> - float leftBoundary = 0 . 0f ; <nl> - for ( auto & subWidget : container ) <nl> - { <nl> - Widget * child = dynamic_cast < Widget * > ( subWidget ) ; <nl> - if ( child ) <nl> - { <nl> - LinearLayoutParameter * layoutParameter = dynamic_cast < LinearLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - if ( layoutParameter ) <nl> - { <nl> - LinearLayoutParameter : : LinearGravity childGravity = layoutParameter - > getGravity ( ) ; <nl> - Vec2 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> - { <nl> - case LinearLayoutParameter : : LinearGravity : : NONE : <nl> - case LinearLayoutParameter : : LinearGravity : : TOP : <nl> - break ; <nl> - case LinearLayoutParameter : : LinearGravity : : BOTTOM : <nl> - finalPosY = ap . y * cs . height ; <nl> - break ; <nl> - case LinearLayoutParameter : : LinearGravity : : CENTER_VERTICAL : <nl> - finalPosY = layoutSize . height / 2 . 0f - cs . height * ( 0 . 5f - ap . y ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - Margin mg = layoutParameter - > getMargin ( ) ; <nl> - finalPosX + = mg . left ; <nl> - finalPosY - = mg . top ; <nl> - child - > setPosition ( Vec2 ( finalPosX , finalPosY ) ) ; <nl> - leftBoundary = child - > getRightBoundary ( ) + mg . right ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - void RelativeLayoutExecutant : : doLayout ( LayoutProtocol * layout ) <nl> - { <nl> - Size layoutSize = layout - > getLayoutContentSize ( ) ; <nl> - Vector < Node * > container = layout - > getLayoutElements ( ) ; <nl> - ssize_t unlayoutChildCount = 0 ; <nl> - Vector < Widget * > widgetChildren ; <nl> - for ( auto & subWidget : container ) <nl> - { <nl> - Widget * child = dynamic_cast < Widget * > ( subWidget ) ; <nl> - if ( child ) <nl> - { <nl> - RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - layoutParameter - > _put = false ; <nl> - unlayoutChildCount + + ; <nl> - widgetChildren . pushBack ( child ) ; <nl> - } <nl> - } <nl> - while ( unlayoutChildCount > 0 ) <nl> - { <nl> - for ( auto & subWidget : widgetChildren ) <nl> - { <nl> - Widget * child = static_cast < Widget * > ( subWidget ) ; <nl> - RelativeLayoutParameter * layoutParameter = dynamic_cast < RelativeLayoutParameter * > ( child - > getLayoutParameter ( ) ) ; <nl> - <nl> - if ( layoutParameter ) <nl> - { <nl> - if ( layoutParameter - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - Vec2 ap = child - > getAnchorPoint ( ) ; <nl> - Size cs = child - > getSize ( ) ; <nl> - RelativeLayoutParameter : : RelativeAlign align = layoutParameter - > getAlign ( ) ; <nl> - const std : : string relativeName = layoutParameter - > getRelativeToWidgetName ( ) ; <nl> - Widget * relativeWidget = nullptr ; <nl> - RelativeLayoutParameter * relativeWidgetLP = nullptr ; <nl> - float finalPosX = 0 . 0f ; <nl> - float finalPosY = 0 . 0f ; <nl> - if ( ! relativeName . empty ( ) ) <nl> - { <nl> - for ( auto & sWidget : widgetChildren ) <nl> - { <nl> - if ( sWidget ) <nl> - { <nl> - RelativeLayoutParameter * rlayoutParameter = dynamic_cast < RelativeLayoutParameter * > ( sWidget - > getLayoutParameter ( ) ) ; <nl> - if ( rlayoutParameter & & rlayoutParameter - > getRelativeName ( ) = = relativeName ) <nl> - { <nl> - relativeWidget = sWidget ; <nl> - relativeWidgetLP = rlayoutParameter ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - switch ( align ) <nl> - { <nl> - case RelativeLayoutParameter : : RelativeAlign : : NONE : <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_LEFT : <nl> - finalPosX = ap . x * cs . width ; <nl> - finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_CENTER_HORIZONTAL : <nl> - finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> - finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_RIGHT : <nl> - finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> - finalPosY = layoutSize . height - ( ( 1 . 0f - ap . y ) * cs . height ) ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_CENTER_VERTICAL : <nl> - finalPosX = ap . x * cs . width ; <nl> - finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : CENTER_IN_PARENT : <nl> - finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> - finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_CENTER_VERTICAL : <nl> - finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> - finalPosY = layoutSize . height * 0 . 5f - cs . height * ( 0 . 5f - ap . y ) ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_BOTTOM : <nl> - finalPosX = ap . x * cs . width ; <nl> - finalPosY = ap . y * cs . height ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_BOTTOM_CENTER_HORIZONTAL : <nl> - finalPosX = layoutSize . width * 0 . 5f - cs . width * ( 0 . 5f - ap . x ) ; <nl> - finalPosY = ap . y * cs . height ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_BOTTOM : <nl> - finalPosX = layoutSize . width - ( ( 1 . 0f - ap . x ) * cs . width ) ; <nl> - finalPosY = ap . y * cs . height ; <nl> - break ; <nl> - <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_LEFTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationTop = relativeWidget - > getTopBoundary ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftBoundary ( ) ; <nl> - finalPosY = locationTop + ap . y * cs . height ; <nl> - finalPosX = locationLeft + ap . x * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_CENTER : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - Size rbs = relativeWidget - > getSize ( ) ; <nl> - float locationTop = relativeWidget - > getTopBoundary ( ) ; <nl> - <nl> - finalPosY = locationTop + ap . y * cs . height ; <nl> - finalPosX = relativeWidget - > getLeftBoundary ( ) + rbs . width * 0 . 5f + ap . x * cs . width - cs . width * 0 . 5f ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_RIGHTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationTop = relativeWidget - > getTopBoundary ( ) ; <nl> - float locationRight = relativeWidget - > getRightBoundary ( ) ; <nl> - finalPosY = locationTop + ap . y * cs . height ; <nl> - finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_TOPALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationTop = relativeWidget - > getTopBoundary ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftBoundary ( ) ; <nl> - finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> - finalPosX = locationLeft - ( 1 . 0f - ap . x ) * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_CENTER : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - Size rbs = relativeWidget - > getSize ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftBoundary ( ) ; <nl> - finalPosX = locationLeft - ( 1 . 0f - ap . x ) * cs . width ; <nl> - <nl> - finalPosY = relativeWidget - > getBottomBoundary ( ) + rbs . height * 0 . 5f + ap . y * cs . height - cs . height * 0 . 5f ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_BOTTOMALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationBottom = relativeWidget - > getBottomBoundary ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftBoundary ( ) ; <nl> - finalPosY = locationBottom + ap . y * cs . height ; <nl> - finalPosX = locationLeft - ( 1 . 0f - ap . x ) * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_TOPALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationTop = relativeWidget - > getTopBoundary ( ) ; <nl> - float locationRight = relativeWidget - > getRightBoundary ( ) ; <nl> - finalPosY = locationTop - ( 1 . 0f - ap . y ) * cs . height ; <nl> - finalPosX = locationRight + ap . x * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_CENTER : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - Size rbs = relativeWidget - > getSize ( ) ; <nl> - float locationRight = relativeWidget - > getRightBoundary ( ) ; <nl> - finalPosX = locationRight + ap . x * cs . width ; <nl> - <nl> - finalPosY = relativeWidget - > getBottomBoundary ( ) + rbs . height * 0 . 5f + ap . y * cs . height - cs . height * 0 . 5f ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationBottom = relativeWidget - > getBottomBoundary ( ) ; <nl> - float locationRight = relativeWidget - > getRightBoundary ( ) ; <nl> - finalPosY = locationBottom + ap . y * cs . height ; <nl> - finalPosX = locationRight + ap . x * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_LEFTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationBottom = relativeWidget - > getBottomBoundary ( ) ; <nl> - float locationLeft = relativeWidget - > getLeftBoundary ( ) ; <nl> - finalPosY = locationBottom - ( 1 . 0f - ap . y ) * cs . height ; <nl> - finalPosX = locationLeft + ap . x * cs . width ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_CENTER : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - Size rbs = relativeWidget - > getSize ( ) ; <nl> - float locationBottom = relativeWidget - > getBottomBoundary ( ) ; <nl> - <nl> - finalPosY = locationBottom - ( 1 . 0f - ap . y ) * cs . height ; <nl> - finalPosX = relativeWidget - > getLeftBoundary ( ) + rbs . width * 0 . 5f + ap . x * cs . width - cs . width * 0 . 5f ; <nl> - } <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_RIGHTALIGN : <nl> - if ( relativeWidget ) <nl> - { <nl> - if ( relativeWidgetLP & & ! relativeWidgetLP - > _put ) <nl> - { <nl> - continue ; <nl> - } <nl> - float locationBottom = relativeWidget - > getBottomBoundary ( ) ; <nl> - float locationRight = relativeWidget - > getRightBoundary ( ) ; <nl> - finalPosY = locationBottom - ( 1 . 0f - ap . y ) * cs . height ; <nl> - finalPosX = locationRight - ( 1 . 0f - ap . x ) * cs . width ; <nl> - } <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - Margin relativeWidgetMargin ; <nl> - Margin mg = layoutParameter - > getMargin ( ) ; <nl> - if ( relativeWidgetLP ) <nl> - { <nl> - relativeWidgetMargin = relativeWidgetLP - > getMargin ( ) ; <nl> - } <nl> - / / handle margin <nl> - switch ( align ) <nl> - { <nl> - case RelativeLayoutParameter : : RelativeAlign : : NONE : <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_LEFT : <nl> - finalPosX + = mg . left ; <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_CENTER_HORIZONTAL : <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_TOP_RIGHT : <nl> - finalPosX - = mg . right ; <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_CENTER_VERTICAL : <nl> - finalPosX + = mg . left ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : CENTER_IN_PARENT : <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_CENTER_VERTICAL : <nl> - finalPosX - = mg . right ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_LEFT_BOTTOM : <nl> - finalPosX + = mg . left ; <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_BOTTOM_CENTER_HORIZONTAL : <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : PARENT_RIGHT_BOTTOM : <nl> - finalPosX - = mg . right ; <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_LEFTALIGN : <nl> - finalPosY + = mg . bottom ; <nl> - finalPosX + = mg . left ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_RIGHTALIGN : <nl> - finalPosY + = mg . bottom ; <nl> - finalPosX - = mg . right ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_ABOVE_CENTER : <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_TOPALIGN : <nl> - finalPosX - = mg . right ; <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_BOTTOMALIGN : <nl> - finalPosX - = mg . right ; <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_LEFT_OF_CENTER : <nl> - finalPosX - = mg . right ; <nl> - break ; <nl> - <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_TOPALIGN : <nl> - finalPosX + = mg . left ; <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_BOTTOMALIGN : <nl> - finalPosX + = mg . left ; <nl> - finalPosY + = mg . bottom ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_RIGHT_OF_CENTER : <nl> - finalPosX + = mg . left ; <nl> - break ; <nl> - <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_LEFTALIGN : <nl> - finalPosY - = mg . top ; <nl> - finalPosX + = mg . left ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_RIGHTALIGN : <nl> - finalPosY - = mg . top ; <nl> - finalPosX - = mg . right ; <nl> - break ; <nl> - case RelativeLayoutParameter : : RelativeAlign : : LOCATION_BELOW_CENTER : <nl> - finalPosY - = mg . top ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - child - > setPosition ( Vec2 ( finalPosX , finalPosY ) ) ; <nl> - layoutParameter - > _put = true ; <nl> - unlayoutChildCount - - ; <nl> - } <nl> - } <nl> - } <nl> - widgetChildren . clear ( ) ; <nl> - } <nl> - <nl> - } <nl> - <nl> - NS_CC_END <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index a8deffd2f036 . . 000000000000 <nl> mmm a / cocos / ui / UILayoutExecutant . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2013 - 2014 Chukong Technologies Inc . <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 __cocos2d_libs__CCLayoutExecutant__ <nl> - # define __cocos2d_libs__CCLayoutExecutant__ <nl> - <nl> - # include " base / CCRef . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - namespace ui { <nl> - <nl> - class LayoutProtocol ; <nl> - <nl> - class LayoutExecutant : public Ref <nl> - { <nl> - public : <nl> - LayoutExecutant ( ) { } ; <nl> - virtual ~ LayoutExecutant ( ) { } ; <nl> - <nl> - virtual void doLayout ( LayoutProtocol * layout ) = 0 ; <nl> - } ; <nl> - <nl> - class LinearVerticalLayoutExecutant : public LayoutExecutant <nl> - { <nl> - public : <nl> - LinearVerticalLayoutExecutant ( ) { } ; <nl> - virtual ~ LinearVerticalLayoutExecutant ( ) { } ; <nl> - static LinearVerticalLayoutExecutant * create ( ) ; <nl> - virtual void doLayout ( LayoutProtocol * layout ) override ; <nl> - } ; <nl> - <nl> - class LinearHorizontalLayoutExecutant : public LayoutExecutant <nl> - { <nl> - public : <nl> - LinearHorizontalLayoutExecutant ( ) { } ; <nl> - virtual ~ LinearHorizontalLayoutExecutant ( ) { } ; <nl> - static LinearHorizontalLayoutExecutant * create ( ) ; <nl> - virtual void doLayout ( LayoutProtocol * layout ) override ; <nl> - } ; <nl> - <nl> - class RelativeLayoutExecutant : public LayoutExecutant <nl> - { <nl> - public : <nl> - RelativeLayoutExecutant ( ) { } ; <nl> - virtual ~ RelativeLayoutExecutant ( ) { } ; <nl> - static RelativeLayoutExecutant * create ( ) ; <nl> - virtual void doLayout ( LayoutProtocol * layout ) override ; <nl> - } ; <nl> - <nl> - } <nl> - <nl> - NS_CC_END <nl> - # endif / * defined ( __cocos2d_libs__CCLayoutExecutant__ ) * / <nl> mmm a / cocos / ui / UILayoutParameter . h <nl> ppp b / cocos / ui / UILayoutParameter . h <nl> class LayoutParameter : public Ref <nl> Margin _margin ; <nl> Type _layoutParameterType ; <nl> } ; <nl> - <nl> - class LayoutParameterProtocol <nl> - { <nl> - public : <nl> - LayoutParameterProtocol ( ) { } <nl> - virtual ~ LayoutParameterProtocol ( ) { } <nl> - <nl> - virtual LayoutParameter * getLayoutParameter ( ) = 0 ; <nl> - } ; <nl> <nl> <nl> / * * <nl> mmm a / cocos / ui / UIListView . cpp <nl> ppp b / cocos / ui / UIListView . cpp <nl> void ListView : : remedyLayoutParameter ( Widget * item ) <nl> switch ( _direction ) { <nl> case Direction : : VERTICAL : <nl> { <nl> - LinearLayoutParameter * llp = ( LinearLayoutParameter * ) ( item - > getLayoutParameter ( ) ) ; <nl> + LinearLayoutParameter * llp = ( LinearLayoutParameter * ) ( item - > getLayoutParameter ( LayoutParameter : : Type : : LINEAR ) ) ; <nl> if ( ! llp ) <nl> { <nl> LinearLayoutParameter * defaultLp = LinearLayoutParameter : : create ( ) ; <nl> void ListView : : remedyLayoutParameter ( Widget * item ) <nl> } <nl> case Direction : : HORIZONTAL : <nl> { <nl> - LinearLayoutParameter * llp = ( LinearLayoutParameter * ) ( item - > getLayoutParameter ( ) ) ; <nl> + LinearLayoutParameter * llp = ( LinearLayoutParameter * ) ( item - > getLayoutParameter ( LayoutParameter : : Type : : LINEAR ) ) ; <nl> if ( ! llp ) <nl> { <nl> LinearLayoutParameter * defaultLp = LinearLayoutParameter : : create ( ) ; <nl> mmm a / cocos / ui / UIPageView . cpp <nl> ppp b / cocos / ui / UIPageView . cpp <nl> bool PageView : : scrollPages ( float touchOffset ) <nl> switch ( _touchMoveDir ) <nl> { <nl> case TouchDirection : : LEFT : / / left <nl> - if ( _rightChild - > getRightBoundary ( ) + touchOffset < = _rightBoundary ) <nl> + if ( _rightChild - > getRightInParent ( ) + touchOffset < = _rightBoundary ) <nl> { <nl> - realOffset = _rightBoundary - _rightChild - > getRightBoundary ( ) ; <nl> + realOffset = _rightBoundary - _rightChild - > getRightInParent ( ) ; <nl> movePages ( realOffset ) ; <nl> return false ; <nl> } <nl> break ; <nl> <nl> case TouchDirection : : RIGHT : / / right <nl> - if ( _leftChild - > getLeftBoundary ( ) + touchOffset > = _leftBoundary ) <nl> + if ( _leftChild - > getLeftInParent ( ) + touchOffset > = _leftBoundary ) <nl> { <nl> - realOffset = _leftBoundary - _leftChild - > getLeftBoundary ( ) ; <nl> + realOffset = _leftBoundary - _leftChild - > getLeftInParent ( ) ; <nl> movePages ( realOffset ) ; <nl> return false ; <nl> } <nl> mmm a / cocos / ui / UIScrollView . cpp <nl> ppp b / cocos / ui / UIScrollView . cpp <nl> ScrollInnerContainer * ScrollInnerContainer : : create ( ) <nl> CC_SAFE_DELETE ( widget ) ; <nl> return nullptr ; <nl> } <nl> - <nl> + <nl> const Size & ScrollInnerContainer : : getLayoutSize ( ) <nl> { <nl> Widget * parent = getWidgetParent ( ) ; <nl> void ScrollView : : setInnerContainerSize ( const Size & size ) <nl> } <nl> case Direction : : HORIZONTAL : <nl> { <nl> - if ( _innerContainer - > getRightBoundary ( ) < = _size . width ) <nl> + if ( _innerContainer - > getRightInParent ( ) < = _size . width ) <nl> { <nl> Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> float offset = originalInnerSize . width - newInnerSize . width ; <nl> void ScrollView : : setInnerContainerSize ( const Size & size ) <nl> Size newInnerSize = _innerContainer - > getSize ( ) ; <nl> float offsetY = originalInnerSize . height - newInnerSize . height ; <nl> float offsetX = 0 . 0f ; <nl> - if ( _innerContainer - > getRightBoundary ( ) < = _size . width ) <nl> + if ( _innerContainer - > getRightInParent ( ) < = _size . width ) <nl> { <nl> offsetX = originalInnerSize . width - newInnerSize . width ; <nl> } <nl> void ScrollView : : setInnerContainerSize ( const Size & size ) <nl> default : <nl> break ; <nl> } <nl> - if ( _innerContainer - > getLeftBoundary ( ) > 0 . 0f ) <nl> + if ( _innerContainer - > getLeftInParent ( ) > 0 . 0f ) <nl> { <nl> _innerContainer - > setPosition ( Vec2 ( _innerContainer - > getAnchorPoint ( ) . x * _innerContainer - > getSize ( ) . width , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> - if ( _innerContainer - > getRightBoundary ( ) < _size . width ) <nl> + if ( _innerContainer - > getRightInParent ( ) < _size . width ) <nl> { <nl> _innerContainer - > setPosition ( Vec2 ( _size . width - ( ( 1 . 0f - _innerContainer - > getAnchorPoint ( ) . x ) * _innerContainer - > getSize ( ) . width ) , _innerContainer - > getPosition ( ) . y ) ) ; <nl> } <nl> void ScrollView : : setInnerContainerSize ( const Size & size ) <nl> { <nl> _innerContainer - > setPosition ( Vec2 ( _innerContainer - > getPosition ( ) . x , _innerContainer - > getAnchorPoint ( ) . y * _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> - if ( _innerContainer - > getTopBoundary ( ) < _size . height ) <nl> + if ( _innerContainer - > getTopInParent ( ) < _size . height ) <nl> { <nl> _innerContainer - > setPosition ( Vec2 ( _innerContainer - > getPosition ( ) . x , _size . height - ( 1 . 0f - _innerContainer - > getAnchorPoint ( ) . y ) * _innerContainer - > getSize ( ) . height ) ) ; <nl> } <nl> bool ScrollView : : checkNeedBounce ( ) <nl> { <nl> if ( _topBounceNeeded & & _leftBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 ( 0 . 0f , _size . height ) - Vec2 ( _innerContainer - > getLeftBoundary ( ) , _innerContainer - > getTopBoundary ( ) ) ; <nl> + Vec2 scrollVector = Vec2 ( 0 . 0f , _size . height ) - Vec2 ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _topBounceNeeded & & _rightBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 ( _size . width , _size . height ) - Vec2 ( _innerContainer - > getRightBoundary ( ) , _innerContainer - > getTopBoundary ( ) ) ; <nl> + Vec2 scrollVector = Vec2 ( _size . width , _size . height ) - Vec2 ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getTopInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _bottomBounceNeeded & & _leftBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 : : ZERO - Vec2 ( _innerContainer - > getLeftBoundary ( ) , _innerContainer - > getBottomBoundary ( ) ) ; <nl> + Vec2 scrollVector = Vec2 : : ZERO - Vec2 ( _innerContainer - > getLeftInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _bottomBounceNeeded & & _rightBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 ( _size . width , 0 . 0f ) - Vec2 ( _innerContainer - > getRightBoundary ( ) , _innerContainer - > getBottomBoundary ( ) ) ; <nl> + Vec2 scrollVector = Vec2 ( _size . width , 0 . 0f ) - Vec2 ( _innerContainer - > getRightInParent ( ) , _innerContainer - > getBottomInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _topBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 ( 0 . 0f , _size . height ) - Vec2 ( 0 . 0f , _innerContainer - > getTopBoundary ( ) ) ; <nl> + Vec2 scrollVector = Vec2 ( 0 . 0f , _size . height ) - Vec2 ( 0 . 0f , _innerContainer - > getTopInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _bottomBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 : : ZERO - Vec2 ( 0 . 0f , _innerContainer - > getBottomBoundary ( ) ) ; <nl> + Vec2 scrollVector = Vec2 : : ZERO - Vec2 ( 0 . 0f , _innerContainer - > getBottomInParent ( ) ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _leftBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 : : ZERO - Vec2 ( _innerContainer - > getLeftBoundary ( ) , 0 . 0f ) ; <nl> + Vec2 scrollVector = Vec2 : : ZERO - Vec2 ( _innerContainer - > getLeftInParent ( ) , 0 . 0f ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> } <nl> else if ( _rightBounceNeeded ) <nl> { <nl> - Vec2 scrollVector = Vec2 ( _size . width , 0 . 0f ) - Vec2 ( _innerContainer - > getRightBoundary ( ) , 0 . 0f ) ; <nl> + Vec2 scrollVector = Vec2 ( _size . width , 0 . 0f ) - Vec2 ( _innerContainer - > getRightInParent ( ) , 0 . 0f ) ; <nl> float orSpeed = scrollVector . getLength ( ) / ( 0 . 2f ) ; <nl> _bounceDir = scrollVector . getNormalized ( ) ; <nl> startBounceChildren ( orSpeed ) ; <nl> bool ScrollView : : checkNeedBounce ( ) <nl> <nl> void ScrollView : : checkBounceBoundary ( ) <nl> { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos > _bottomBoundary ) <nl> { <nl> scrollToBottomEvent ( ) ; <nl> void ScrollView : : checkBounceBoundary ( ) <nl> { <nl> _bottomBounceNeeded = false ; <nl> } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos < _topBoundary ) <nl> { <nl> scrollToTopEvent ( ) ; <nl> void ScrollView : : checkBounceBoundary ( ) <nl> { <nl> _topBounceNeeded = false ; <nl> } <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos < _rightBoundary ) <nl> { <nl> scrollToRightEvent ( ) ; <nl> void ScrollView : : checkBounceBoundary ( ) <nl> { <nl> _rightBounceNeeded = false ; <nl> } <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos > _leftBoundary ) <nl> { <nl> scrollToLeftEvent ( ) ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> float realOffsetX = touchOffsetX ; <nl> float realOffsetY = touchOffsetY ; <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos + realOffsetX > = _rightBoundary ) <nl> { <nl> realOffsetX = _rightBoundary - icRightPos ; <nl> bounceRightEvent ( ) ; <nl> scrollenabled = false ; <nl> } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos + touchOffsetY > = _topBoundary ) <nl> { <nl> realOffsetY = _topBoundary - icTopPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> float realOffsetX = touchOffsetX ; <nl> float realOffsetY = touchOffsetY ; <nl> - float icLefrPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLefrPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLefrPos + realOffsetX < = _leftBoundary ) <nl> { <nl> realOffsetX = _leftBoundary - icLefrPos ; <nl> bounceLeftEvent ( ) ; <nl> scrollenabled = false ; <nl> } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos + touchOffsetY > = _topBoundary ) <nl> { <nl> realOffsetY = _topBoundary - icTopPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> float realOffsetX = touchOffsetX ; <nl> float realOffsetY = touchOffsetY ; <nl> - float icLefrPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLefrPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLefrPos + realOffsetX < = _leftBoundary ) <nl> { <nl> realOffsetX = _leftBoundary - icLefrPos ; <nl> bounceLeftEvent ( ) ; <nl> scrollenabled = false ; <nl> } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + touchOffsetY < = _bottomBoundary ) <nl> { <nl> realOffsetY = _bottomBoundary - icBottomPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> float realOffsetX = touchOffsetX ; <nl> float realOffsetY = touchOffsetY ; <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos + realOffsetX > = _rightBoundary ) <nl> { <nl> realOffsetX = _rightBoundary - icRightPos ; <nl> bounceRightEvent ( ) ; <nl> scrollenabled = false ; <nl> } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + touchOffsetY < = _bottomBoundary ) <nl> { <nl> realOffsetY = _bottomBoundary - icBottomPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / bounce to top <nl> { <nl> float realOffsetY = touchOffsetY ; <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos + touchOffsetY > = _topBoundary ) <nl> { <nl> realOffsetY = _topBoundary - icTopPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / bounce to bottom <nl> { <nl> float realOffsetY = touchOffsetY ; <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + touchOffsetY < = _bottomBoundary ) <nl> { <nl> realOffsetY = _bottomBoundary - icBottomPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / bounce to right <nl> { <nl> float realOffsetX = touchOffsetX ; <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos + realOffsetX > = _rightBoundary ) <nl> { <nl> realOffsetX = _rightBoundary - icRightPos ; <nl> bool ScrollView : : bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / bounce to left <nl> { <nl> float realOffsetX = touchOffsetX ; <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos + realOffsetX < = _leftBoundary ) <nl> { <nl> realOffsetX = _leftBoundary - icLeftPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> { <nl> if ( _autoScrollDir . y > 0 ) <nl> { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else <nl> { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> { <nl> if ( _autoScrollDir . x > 0 ) <nl> { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else <nl> { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> { <nl> if ( * touchOffsetX > 0 . 0f & & * touchOffsetY > 0 . 0f ) / / up right <nl> { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> scrollenabled = false ; <nl> } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX < 0 . 0f & & * touchOffsetY > 0 . 0f ) / / up left <nl> { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icRightPos ; <nl> scrollenabled = false ; <nl> } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX < 0 . 0f & & * touchOffsetY < 0 . 0f ) / / down left <nl> { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icRightPos ; <nl> scrollenabled = false ; <nl> } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icTopPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX > 0 . 0f & & * touchOffsetY < 0 . 0f ) / / down right <nl> { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> scrollenabled = false ; <nl> } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icTopPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX = = 0 . 0f & & * touchOffsetY > 0 . 0f ) / / up <nl> { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> if ( icBottomPos + * touchOffsetY > = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icBottomPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX < 0 . 0f & & * touchOffsetY = = 0 . 0f ) / / left <nl> { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> if ( icRightPos + * touchOffsetX < = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icRightPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX = = 0 . 0f & & * touchOffsetY < 0 . 0f ) / / down <nl> { <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> if ( icTopPos + * touchOffsetY < = _autoScrollDestination . y ) <nl> { <nl> * touchOffsetY = _autoScrollDestination . y - icTopPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> else if ( * touchOffsetX > 0 . 0f & & * touchOffsetY = = 0 . 0f ) / / right <nl> { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> if ( icLeftPos + * touchOffsetX > = _autoScrollDestination . x ) <nl> { <nl> * touchOffsetX = _autoScrollDestination . x - icLeftPos ; <nl> bool ScrollView : : checkCustomScrollDestination ( float * touchOffsetX , float * touchO <nl> } <nl> return scrollenabled ; <nl> } <nl> - <nl> - bool ScrollView : : scrollChilderVertical ( float touchOffsetX , float touchOffsetY ) <nl> - { <nl> - bool scrollenabled = true ; <nl> <nl> - float realOffset = touchOffsetY ; <nl> - if ( _bounceEnabled ) <nl> - { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> - { <nl> - realOffset = _bounceBottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> - { <nl> - realOffset = _bounceTopBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> - { <nl> - realOffset = _bottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> - { <nl> - realOffset = _topBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - moveChildren ( 0 . 0f , realOffset ) ; <nl> - <nl> - return scrollenabled ; <nl> - } <nl> - <nl> - bool ScrollView : : scrollChilderHorizontal ( float touchOffsetX , float touchOffsetY ) <nl> - { <nl> - bool scrollenabled = true ; <nl> - <nl> - float realOffset = touchOffsetX ; <nl> - if ( _bounceEnabled ) <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> - { <nl> - realOffset = _bounceRightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> - { <nl> - realOffset = _bounceLeftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> - { <nl> - realOffset = _rightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> - { <nl> - realOffset = _leftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - moveChildren ( realOffset , 0 . 0f ) ; <nl> - <nl> - return scrollenabled ; <nl> - } <nl> - <nl> - bool ScrollView : : scrollChilderBoth ( float touchOffsetX , float touchOffsetY ) <nl> + bool ScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> { <nl> bool scrollenabled = true ; <nl> - float realOffsetX = touchOffsetX ; <nl> - float realOffsetY = touchOffsetY ; <nl> - if ( _bounceEnabled ) <nl> - { <nl> - if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / up right <nl> - { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> - { <nl> - realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> - { <nl> - realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / up left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> - { <nl> - realOffsetX = _bounceRightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> - { <nl> - realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / down left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> - { <nl> - realOffsetX = _bounceRightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> - { <nl> - realOffsetY = _bounceTopBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / down right <nl> - { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> - { <nl> - realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> - { <nl> - realOffsetY = _bounceTopBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / up <nl> - { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> - { <nl> - realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> - { <nl> - realOffsetX = _bounceRightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / down <nl> - { <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> - { <nl> - realOffsetY = _bounceTopBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / right <nl> - { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> - { <nl> - realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> + scrollingEvent ( ) ; <nl> + switch ( _direction ) <nl> { <nl> - if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / up right <nl> - { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> - { <nl> - realOffsetX = _leftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> - { <nl> - realOffsetY = _bottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / up left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> - { <nl> - realOffsetX = _rightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> - { <nl> - realOffsetY = _bottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / down left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> - { <nl> - realOffsetX = _rightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> - { <nl> - realOffsetY = _topBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> - } <nl> - } <nl> - else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / down right <nl> + case Direction : : VERTICAL : / / vertical <nl> { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + float realOffset = touchOffsetY ; <nl> + if ( _bounceEnabled ) <nl> { <nl> - realOffsetX = _leftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffset = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffset = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> } <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + else <nl> { <nl> - realOffsetY = _topBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffset = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffset = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> } <nl> + moveChildren ( 0 . 0f , realOffset ) ; <nl> + break ; <nl> } <nl> - else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / up <nl> + case Direction : : HORIZONTAL : / / horizontal <nl> { <nl> - float icBottomPos = _innerContainer - > getBottomBoundary ( ) ; <nl> - if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + float realOffset = touchOffsetX ; <nl> + if ( _bounceEnabled ) <nl> { <nl> - realOffsetY = _bottomBoundary - icBottomPos ; <nl> - scrollToBottomEvent ( ) ; <nl> - scrollenabled = false ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffset = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffset = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> } <nl> - } <nl> - else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / left <nl> - { <nl> - float icRightPos = _innerContainer - > getRightBoundary ( ) ; <nl> - if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + else <nl> { <nl> - realOffsetX = _rightBoundary - icRightPos ; <nl> - scrollToRightEvent ( ) ; <nl> - scrollenabled = false ; <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffset = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffset = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> } <nl> + moveChildren ( realOffset , 0 . 0f ) ; <nl> + break ; <nl> } <nl> - else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / down <nl> + case Direction : : BOTH : <nl> { <nl> - float icTopPos = _innerContainer - > getTopBoundary ( ) ; <nl> - if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + float realOffsetX = touchOffsetX ; <nl> + float realOffsetY = touchOffsetY ; <nl> + if ( _bounceEnabled ) <nl> { <nl> - realOffsetY = _topBoundary - icTopPos ; <nl> - scrollToTopEvent ( ) ; <nl> - scrollenabled = false ; <nl> + if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / up right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / up left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffsetX = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / down left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffsetX = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffsetY = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / down right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffsetY = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / up <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bounceBottomBoundary ) <nl> + { <nl> + realOffsetY = _bounceBottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _bounceRightBoundary ) <nl> + { <nl> + realOffsetX = _bounceRightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / down <nl> + { <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _bounceTopBoundary ) <nl> + { <nl> + realOffsetY = _bounceTopBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _bounceLeftBoundary ) <nl> + { <nl> + realOffsetX = _bounceLeftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> } <nl> - } <nl> - else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / right <nl> - { <nl> - float icLeftPos = _innerContainer - > getLeftBoundary ( ) ; <nl> - if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + else <nl> { <nl> - realOffsetX = _leftBoundary - icLeftPos ; <nl> - scrollToLeftEvent ( ) ; <nl> - scrollenabled = false ; <nl> + if ( touchOffsetX > 0 . 0f & & touchOffsetY > 0 . 0f ) / / up right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY > 0 . 0f ) / / up left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY < 0 . 0f ) / / down left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY < 0 . 0f ) / / down right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY > 0 . 0f ) / / up <nl> + { <nl> + float icBottomPos = _innerContainer - > getBottomInParent ( ) ; <nl> + if ( icBottomPos + touchOffsetY > = _bottomBoundary ) <nl> + { <nl> + realOffsetY = _bottomBoundary - icBottomPos ; <nl> + scrollToBottomEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX < 0 . 0f & & touchOffsetY = = 0 . 0f ) / / left <nl> + { <nl> + float icRightPos = _innerContainer - > getRightInParent ( ) ; <nl> + if ( icRightPos + touchOffsetX < = _rightBoundary ) <nl> + { <nl> + realOffsetX = _rightBoundary - icRightPos ; <nl> + scrollToRightEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX = = 0 . 0f & & touchOffsetY < 0 . 0f ) / / down <nl> + { <nl> + float icTopPos = _innerContainer - > getTopInParent ( ) ; <nl> + if ( icTopPos + touchOffsetY < = _topBoundary ) <nl> + { <nl> + realOffsetY = _topBoundary - icTopPos ; <nl> + scrollToTopEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> + else if ( touchOffsetX > 0 . 0f & & touchOffsetY = = 0 . 0f ) / / right <nl> + { <nl> + float icLeftPos = _innerContainer - > getLeftInParent ( ) ; <nl> + if ( icLeftPos + touchOffsetX > = _leftBoundary ) <nl> + { <nl> + realOffsetX = _leftBoundary - icLeftPos ; <nl> + scrollToLeftEvent ( ) ; <nl> + scrollenabled = false ; <nl> + } <nl> + } <nl> } <nl> - } <nl> - } <nl> - moveChildren ( realOffsetX , realOffsetY ) ; <nl> - return scrollenabled ; <nl> - } <nl> - <nl> - bool ScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> - { <nl> - bool scrollenabled = true ; <nl> - scrollingEvent ( ) ; <nl> - <nl> - switch ( _direction ) <nl> - { <nl> - case Direction : : VERTICAL : / / vertical <nl> - { <nl> - scrollenabled = this - > scrollChilderVertical ( touchOffsetX , touchOffsetY ) ; <nl> - break ; <nl> - } <nl> - case Direction : : HORIZONTAL : / / horizontal <nl> - { <nl> - scrollenabled = this - > scrollChilderHorizontal ( touchOffsetX , touchOffsetY ) ; <nl> - break ; <nl> - } <nl> - case Direction : : BOTH : <nl> - { <nl> - scrollenabled = this - > scrollChilderBoth ( touchOffsetX , touchOffsetY ) ; <nl> + moveChildren ( realOffsetX , realOffsetY ) ; <nl> break ; <nl> } <nl> default : <nl> mmm a / cocos / ui / UIScrollView . h <nl> ppp b / cocos / ui / UIScrollView . h <nl> class ScrollView : public Layout , public UIScrollInterface <nl> void startBounceChildren ( float v ) ; <nl> void stopBounceChildren ( ) ; <nl> bool checkCustomScrollDestination ( float * touchOffsetX , float * touchOffsetY ) ; <nl> - <nl> virtual bool scrollChildren ( float touchOffsetX , float touchOffsetY ) ; <nl> - virtual bool scrollChilderHorizontal ( float touchOffsetX , float touchOffsetY ) ; <nl> - virtual bool scrollChilderVertical ( float touchOffsetX , float touchOffsetY ) ; <nl> - virtual bool scrollChilderBoth ( float touchOffsetX , float touchOffsetY ) ; <nl> - <nl> - <nl> bool bounceScrollChildren ( float touchOffsetX , float touchOffsetY ) ; <nl> void startRecordSlidAction ( ) ; <nl> virtual void endRecordSlidAction ( ) ; <nl> mmm a / cocos / ui / UIWidget . cpp <nl> ppp b / cocos / ui / UIWidget . cpp <nl> _opacity ( 255 ) , <nl> _flippedX ( false ) , <nl> _flippedY ( false ) , <nl> _focused ( false ) , <nl> - _focusEnabled ( true ) , <nl> - _layoutParameterType ( LayoutParameter : : Type : : NONE ) <nl> + _focusEnabled ( true ) <nl> { <nl> onFocusChanged = CC_CALLBACK_2 ( Widget : : onFocusChange , this ) ; <nl> onNextFocusedWidget = nullptr ; <nl> bool Widget : : isEnabled ( ) const <nl> return _enabled ; <nl> } <nl> <nl> - float Widget : : getLeftBoundary ( ) const <nl> + float Widget : : getLeftInParent ( ) <nl> { <nl> - return getPosition ( ) . x - getAnchorPoint ( ) . x * _size . width ; <nl> + return getPosition ( ) . x - getAnchorPoint ( ) . x * _size . width ; ; <nl> } <nl> <nl> - float Widget : : getBottomBoundary ( ) const <nl> + float Widget : : getBottomInParent ( ) <nl> { <nl> - return getPosition ( ) . y - getAnchorPoint ( ) . y * _size . height ; <nl> + return getPosition ( ) . y - getAnchorPoint ( ) . y * _size . height ; ; <nl> } <nl> <nl> - float Widget : : getRightBoundary ( ) const <nl> + float Widget : : getRightInParent ( ) <nl> { <nl> - return getLeftBoundary ( ) + _size . width ; <nl> + return getLeftInParent ( ) + _size . width ; <nl> } <nl> <nl> - float Widget : : getTopBoundary ( ) const <nl> + float Widget : : getTopInParent ( ) <nl> { <nl> - return getBottomBoundary ( ) + _size . height ; <nl> + return getBottomInParent ( ) + _size . height ; <nl> } <nl> <nl> const Vec2 & Widget : : getTouchStartPos ( ) <nl> void Widget : : setLayoutParameter ( LayoutParameter * parameter ) <nl> return ; <nl> } <nl> _layoutParameterDictionary . insert ( ( int ) parameter - > getLayoutType ( ) , parameter ) ; <nl> - _layoutParameterType = parameter - > getLayoutType ( ) ; <nl> } <nl> <nl> - LayoutParameter * Widget : : getLayoutParameter ( ) <nl> - { <nl> - return dynamic_cast < LayoutParameter * > ( _layoutParameterDictionary . at ( ( int ) _layoutParameterType ) ) ; <nl> - } <nl> - <nl> LayoutParameter * Widget : : getLayoutParameter ( LayoutParameter : : Type type ) <nl> { <nl> return dynamic_cast < LayoutParameter * > ( _layoutParameterDictionary . at ( ( int ) type ) ) ; <nl> mmm a / cocos / ui / UIWidget . h <nl> ppp b / cocos / ui / UIWidget . h <nl> THE SOFTWARE . <nl> # include " ui / CCProtectedNode . h " <nl> # include " ui / UILayoutParameter . h " <nl> # include " ui / GUIDefine . h " <nl> - # include " ui / UILayoutParameter . h " <nl> <nl> NS_CC_BEGIN <nl> <nl> CC_DEPRECATED_ATTRIBUTE typedef void ( Ref : : * SEL_TouchEvent ) ( Ref * , TouchEventType ) <nl> # endif <nl> <nl> <nl> - class Widget : public ProtectedNode , public LayoutParameterProtocol <nl> + class Widget : public ProtectedNode <nl> { <nl> public : <nl> enum class FocusDirection <nl> class Widget : public ProtectedNode , public LayoutParameterProtocol <nl> * <nl> * @ return The left boundary position of this widget . <nl> * / <nl> - CC_DEPRECATED_ATTRIBUTE float getLeftInParent ( ) { return this - > getLeftBoundary ( ) ; } <nl> - float getLeftBoundary ( ) const ; <nl> + float getLeftInParent ( ) ; <nl> <nl> / * * <nl> * Gets the bottom boundary position of this widget . <nl> * <nl> * @ return The bottom boundary position of this widget . <nl> * / <nl> - CC_DEPRECATED_ATTRIBUTE float getBottomInParent ( ) { return this - > getBottomBoundary ( ) ; } <nl> - float getBottomBoundary ( ) const ; <nl> + float getBottomInParent ( ) ; <nl> <nl> / * * <nl> * Gets the right boundary position of this widget . <nl> * <nl> * @ return The right boundary position of this widget . <nl> * / <nl> - CC_DEPRECATED_ATTRIBUTE float getRightInParent ( ) { return this - > getRightBoundary ( ) ; } <nl> - float getRightBoundary ( ) const ; <nl> + float getRightInParent ( ) ; <nl> <nl> / * * <nl> * Gets the top boundary position of this widget . <nl> * <nl> * @ return The top boundary position of this widget . <nl> * / <nl> - CC_DEPRECATED_ATTRIBUTE float getTopInParent ( ) { return this - > getTopBoundary ( ) ; } <nl> - float getTopBoundary ( ) const ; <nl> + float getTopInParent ( ) ; <nl> <nl> / * * <nl> * Gets a child from the container with its name <nl> class Widget : public ProtectedNode , public LayoutParameterProtocol <nl> * <nl> * @ return LayoutParameter <nl> * / <nl> - LayoutParameter * getLayoutParameter ( ) override ; <nl> - CC_DEPRECATED_ATTRIBUTE LayoutParameter * getLayoutParameter ( LayoutParameter : : Type type ) ; <nl> - <nl> + LayoutParameter * getLayoutParameter ( LayoutParameter : : Type type ) ; <nl> <nl> / * * <nl> * Ignore the widget size <nl> class Widget : public ProtectedNode , public LayoutParameterProtocol <nl> Size _size ; <nl> Size _customSize ; <nl> bool _ignoreSize ; <nl> - <nl> + bool _affectByClipping ; <nl> SizeType _sizeType ; <nl> Vec2 _sizePercent ; <nl> - <nl> - bool _affectByClipping ; <nl> - <nl> PositionType _positionType ; <nl> Vec2 _positionPercent ; <nl> bool _reorderWidgetChildDirty ; <nl> class Widget : public ProtectedNode , public LayoutParameterProtocol <nl> GLubyte _opacity ; <nl> bool _flippedX ; <nl> bool _flippedY ; <nl> - / / use map to enble switch back and forth for user layout parameters <nl> - Map < int , LayoutParameter * > _layoutParameterDictionary ; <nl> - LayoutParameter : : Type _layoutParameterType ; <nl> - <nl> + Map < int , LayoutParameter * > _layoutParameterDictionary ; <nl> + <nl> bool _focused ; <nl> bool _focusEnabled ; <nl> <nl> mmm a / cocos / ui / proj . win32 / libGUI . vcxproj <nl> ppp b / cocos / ui / proj . win32 / libGUI . vcxproj <nl> <nl> < ClInclude Include = " . . \ UIHelper . h " / > <nl> < ClInclude Include = " . . \ UIImageView . h " / > <nl> < ClInclude Include = " . . \ UILayout . h " / > <nl> - < ClInclude Include = " . . \ UILayoutExecutant . h " / > <nl> < ClInclude Include = " . . \ UILayoutParameter . h " / > <nl> < ClInclude Include = " . . \ UIListView . h " / > <nl> < ClInclude Include = " . . \ UILoadingBar . h " / > <nl> <nl> < ClCompile Include = " . . \ UIHelper . cpp " / > <nl> < ClCompile Include = " . . \ UIImageView . cpp " / > <nl> < ClCompile Include = " . . \ UILayout . cpp " / > <nl> - < ClCompile Include = " . . \ UILayoutExecutant . cpp " / > <nl> < ClCompile Include = " . . \ UILayoutParameter . cpp " / > <nl> < ClCompile Include = " . . \ UIListView . cpp " / > <nl> < ClCompile Include = " . . \ UILoadingBar . cpp " / > <nl> mmm a / cocos / ui / proj . win32 / libGUI . vcxproj . filters <nl> ppp b / cocos / ui / proj . win32 / libGUI . vcxproj . filters <nl> <nl> < ClInclude Include = " . . \ UIVBox . h " > <nl> < Filter > Layouts < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " . . \ UILayoutExecutant . h " > <nl> - < Filter > Layouts < / Filter > <nl> - < / ClInclude > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClCompile Include = " . . \ UIScrollView . cpp " > <nl> <nl> < ClCompile Include = " . . \ UIVBox . cpp " > <nl> < Filter > Layouts < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ UILayoutExecutant . cpp " > <nl> - < Filter > Layouts < / Filter > <nl> - < / ClCompile > <nl> < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl> mmm a / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> ppp b / tests / cpp - tests / Classes / UITest / CocoStudioGUITest / UIScrollViewTest / UIScrollViewTest . cpp <nl> bool UIScrollViewTest_Vertical : : init ( ) <nl> <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> - titleButton - > setPosition ( Vec2 ( innerWidth / 2 . 0f , button - > getBottomBoundary ( ) - button - > getSize ( ) . height ) ) ; <nl> + titleButton - > setPosition ( Vec2 ( innerWidth / 2 . 0f , button - > getBottomInParent ( ) - button - > getSize ( ) . height ) ) ; <nl> scrollView - > addChild ( titleButton ) ; <nl> <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Vec2 ( innerWidth / 2 . 0f , titleButton - > getBottomBoundary ( ) - titleButton - > getSize ( ) . height ) ) ; <nl> + button_scale9 - > setPosition ( Vec2 ( innerWidth / 2 . 0f , titleButton - > getBottomInParent ( ) - titleButton - > getSize ( ) . height ) ) ; <nl> scrollView - > addChild ( button_scale9 ) ; <nl> <nl> imageView - > setPosition ( Vec2 ( innerWidth / 2 . 0f , imageView - > getSize ( ) . height / 2 . 0f ) ) ; <nl> bool UIScrollViewTest_Horizontal : : init ( ) <nl> <nl> Button * titleButton = Button : : create ( " cocosui / backtotopnormal . png " , " cocosui / backtotoppressed . png " ) ; <nl> titleButton - > setTitleText ( " Title Button " ) ; <nl> - titleButton - > setPosition ( Vec2 ( button - > getRightBoundary ( ) + button - > getSize ( ) . width / 2 . 0f , <nl> - button - > getBottomBoundary ( ) - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + titleButton - > setPosition ( Vec2 ( button - > getRightInParent ( ) + button - > getSize ( ) . width / 2 . 0f , <nl> + button - > getBottomInParent ( ) - button - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( titleButton ) ; <nl> <nl> Button * button_scale9 = Button : : create ( " cocosui / button . png " , " cocosui / buttonHighlighted . png " ) ; <nl> button_scale9 - > setScale9Enabled ( true ) ; <nl> button_scale9 - > setSize ( Size ( 100 . 0f , button_scale9 - > getVirtualRendererSize ( ) . height ) ) ; <nl> - button_scale9 - > setPosition ( Vec2 ( titleButton - > getRightBoundary ( ) + titleButton - > getSize ( ) . width / 2 . 0f , <nl> - titleButton - > getBottomBoundary ( ) - titleButton - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + button_scale9 - > setPosition ( Vec2 ( titleButton - > getRightInParent ( ) + titleButton - > getSize ( ) . width / 2 . 0f , <nl> + titleButton - > getBottomInParent ( ) - titleButton - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( button_scale9 ) ; <nl> <nl> imageView - > setPosition ( Vec2 ( innerWidth - imageView - > getSize ( ) . width / 2 . 0f , <nl> - button_scale9 - > getBottomBoundary ( ) - button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> + button_scale9 - > getBottomInParent ( ) - button_scale9 - > getSize ( ) . height / 2 . 0f ) ) ; <nl> scrollView - > addChild ( imageView ) ; <nl> <nl> return true ; <nl>
Revert " Merge pull request from andyque / refactorLayout "
cocos2d/cocos2d-x
1ed9b9749ea80ca56d13538613673144b09a8c2f
2014-05-20T06:36:29Z
mmm a / lib / SILOptimizer / Utils / ConstExpr . cpp <nl> ppp b / lib / SILOptimizer / Utils / ConstExpr . cpp <nl> SymbolicValue ConstExprFunctionState : : computeConstantValue ( SILValue value ) { <nl> if ( auto * bai = dyn_cast < BeginAccessInst > ( value ) ) <nl> return getConstantValue ( bai - > getOperand ( ) ) ; <nl> <nl> + / / Look through copy_value and begin_borrow since the interpreter doesn ' t <nl> + / / model these memory management instructions . <nl> + if ( isa < CopyValueInst > ( value ) | | isa < BeginBorrowInst > ( value ) ) <nl> + return getConstantValue ( cast < SingleValueInstruction > ( value ) - > getOperand ( 0 ) ) ; <nl> + <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " ConstExpr Unknown simple : " < < * value < < " \ n " ) ; <nl> <nl> / / Otherwise , we don ' t know how to handle this . <nl> ConstExprFunctionState : : evaluateFlowSensitive ( SILInstruction * inst ) { <nl> / / skip them . <nl> isa < DestroyAddrInst > ( inst ) | | isa < RetainValueInst > ( inst ) | | <nl> isa < ReleaseValueInst > ( inst ) | | isa < StrongRetainInst > ( inst ) | | <nl> - isa < StrongReleaseInst > ( inst ) ) <nl> + isa < StrongReleaseInst > ( inst ) | | isa < DestroyValueInst > ( inst ) | | <nl> + isa < EndBorrowInst > ( inst ) ) <nl> return None ; <nl> <nl> / / If this is a special flow - sensitive instruction like a stack allocation , <nl> ConstExprFunctionState : : evaluateFlowSensitive ( SILInstruction * inst ) { <nl> return None ; <nl> } <nl> <nl> + / / Make sure that our copy_value , begin_borrow form constants . Otherwise , <nl> + / / return why . <nl> + if ( isa < CopyValueInst > ( inst ) | | isa < BeginBorrowInst > ( inst ) ) { <nl> + auto result = getConstantValue ( inst - > getOperand ( 0 ) ) ; <nl> + if ( ! result . isConstant ( ) ) <nl> + return result ; <nl> + return None ; <nl> + } <nl> + <nl> / / If this is a deallocation of a memory object that we are tracking , then <nl> / / don ' t do anything . The memory is allocated in a BumpPtrAllocator so there <nl> / / is no useful way to free it . <nl>
Merge remote - tracking branch ' origin / master ' into master - next
apple/swift
fef9eeab4a8f64f91ece7261fd3f4a629e2abd5b
2019-05-20T19:29: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> - c3b97117ff38c9347b34f01a67fd7206af29194d <nl> \ No newline at end of file <nl> + 42f742346aec806886a8fd399aa42f689cafa71c <nl> \ No newline at end of file <nl> mmm a / extensions / Android . mk <nl> ppp b / extensions / Android . mk <nl> GUI / CCEditBox / CCEditBoxImplNone . cpp \ <nl> GUI / CCEditBox / CCEditBoxImplTizen . cpp \ <nl> GUI / CCEditBox / CCEditBoxImplWin . cpp \ <nl> GUI / CCScrollView / CCScrollView . cpp \ <nl> - GUI / CCScrollView / CCSorting . cpp \ <nl> GUI / CCScrollView / CCTableView . cpp \ <nl> GUI / CCScrollView / CCTableViewCell . cpp \ <nl> physics - nodes / CCPhysicsDebugNode . cpp \ <nl> mmm a / extensions / CMakeLists . txt <nl> ppp b / extensions / CMakeLists . txt <nl> set ( EXTENSIONS_SRC <nl> GUI / CCEditBox / CCEditBoxImplTizen . cpp <nl> GUI / CCEditBox / CCEditBoxImplWin . cpp <nl> GUI / CCScrollView / CCScrollView . cpp <nl> - GUI / CCScrollView / CCSorting . cpp <nl> GUI / CCScrollView / CCTableView . cpp <nl> GUI / CCScrollView / CCTableViewCell . cpp <nl> physics - nodes / CCPhysicsDebugNode . cpp <nl> mmm a / extensions / proj . win32 / libExtensions . vcxproj <nl> ppp b / extensions / proj . win32 / libExtensions . vcxproj <nl> <nl> < ClCompile Include = " . . \ GUI \ CCEditBox \ CCEditBox . cpp " / > <nl> < ClCompile Include = " . . \ GUI \ CCEditBox \ CCEditBoxImplWin . cpp " / > <nl> < ClCompile Include = " . . \ GUI \ CCScrollView \ CCScrollView . cpp " / > <nl> - < ClCompile Include = " . . \ GUI \ CCScrollView \ CCSorting . cpp " / > <nl> < ClCompile Include = " . . \ GUI \ CCScrollView \ CCTableView . cpp " / > <nl> < ClCompile Include = " . . \ GUI \ CCScrollView \ CCTableViewCell . cpp " / > <nl> < ClCompile Include = " . . \ physics - nodes \ CCPhysicsDebugNode . cpp " / > <nl> <nl> < ClInclude Include = " . . \ GUI \ CCScrollView \ CCScrollView . h " / > <nl> < ClInclude Include = " . . \ cocos - ext . h " / > <nl> < ClInclude Include = " . . \ ExtensionMacros . h " / > <nl> - < ClInclude Include = " . . \ GUI \ CCScrollView \ CCSorting . h " / > <nl> < ClInclude Include = " . . \ GUI \ CCScrollView \ CCTableView . h " / > <nl> < ClInclude Include = " . . \ GUI \ CCScrollView \ CCTableViewCell . h " / > <nl> < ClInclude Include = " . . \ physics - nodes \ CCPhysicsDebugNode . h " / > <nl> mmm a / extensions / proj . win32 / libExtensions . vcxproj . filters <nl> ppp b / extensions / proj . win32 / libExtensions . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ GUI \ CCScrollView \ CCScrollView . cpp " > <nl> < Filter > GUI \ CCScrollView < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ GUI \ CCScrollView \ CCSorting . cpp " > <nl> - < Filter > GUI \ CCScrollView < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ GUI \ CCScrollView \ CCTableView . cpp " > <nl> < Filter > GUI \ CCScrollView < / Filter > <nl> < / ClCompile > <nl> <nl> < / ClInclude > <nl> < ClInclude Include = " . . \ cocos - ext . h " / > <nl> < ClInclude Include = " . . \ ExtensionMacros . h " / > <nl> - < ClInclude Include = " . . \ GUI \ CCScrollView \ CCSorting . h " > <nl> - < Filter > GUI \ CCScrollView < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " . . \ GUI \ CCScrollView \ CCTableView . h " > <nl> < Filter > GUI \ CCScrollView < / Filter > <nl> < / ClInclude > <nl>
issue : Removes CCSort . h / . cpp from projects .
cocos2d/cocos2d-x
d8061477c129ec89db59ba2705eccd241b252806
2013-12-07T06:21:01Z
new file mode 100644 <nl> index 00000000000 . . 9553ed116a3 <nl> mmm / dev / null <nl> ppp b / Telegram / SourceFiles / base / match_method . h <nl> <nl> + / * <nl> + This file is part of Telegram Desktop , <nl> + the official desktop application for the Telegram messaging service . <nl> + <nl> + For license and copyright information please follow this link : <nl> + https : / / github . com / telegramdesktop / tdesktop / blob / master / LEGAL <nl> + * / <nl> + # pragma once <nl> + <nl> + # include < rpl / details / callable . h > <nl> + <nl> + namespace base { <nl> + <nl> + template < typename Data , typename Method , typename . . . Methods > <nl> + inline decltype ( auto ) match_method ( <nl> + Data & & data , <nl> + Method & & method , <nl> + Methods & & . . . methods ) { <nl> + if constexpr ( rpl : : details : : is_callable_plain_v < Method , Data & & > ) { <nl> + return std : : forward < Method > ( method ) ( std : : forward < Data > ( data ) ) ; <nl> + } else { <nl> + return match_method ( <nl> + std : : forward < Data > ( data ) , <nl> + std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + } <nl> + <nl> + } / / namespace base <nl> mmm a / Telegram / SourceFiles / base / optional . h <nl> ppp b / Telegram / SourceFiles / base / optional . h <nl> class optional_variant { <nl> return _impl . template get_unchecked < T > ( ) ; <nl> } <nl> <nl> + template < typename . . . Methods > <nl> + decltype ( auto ) match ( Methods & & . . . methods ) { <nl> + return base : : match ( _impl , std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + template < typename . . . Methods > <nl> + decltype ( auto ) match ( Methods & & . . . methods ) const { <nl> + return base : : match ( _impl , std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + <nl> private : <nl> variant < none_type , Types . . . > _impl ; <nl> <nl> inline const T * get_if ( const optional_variant < Types . . . > * v ) { <nl> return ( v & & v - > template is < T > ( ) ) ? & v - > template get_unchecked < T > ( ) : nullptr ; <nl> } <nl> <nl> + template < typename . . . Types , typename . . . Methods > <nl> + inline decltype ( auto ) match ( <nl> + optional_variant < Types . . . > & value , <nl> + Methods & & . . . methods ) { <nl> + return value . match ( std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + <nl> + template < typename . . . Types , typename . . . Methods > <nl> + inline decltype ( auto ) match ( <nl> + const optional_variant < Types . . . > & value , <nl> + Methods & & . . . methods ) { <nl> + return value . match ( std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + <nl> template < typename Type > <nl> class optional ; <nl> <nl> mmm a / Telegram / SourceFiles / base / variant . h <nl> ppp b / Telegram / SourceFiles / base / variant . h <nl> For license and copyright information please follow this link : <nl> # pragma once <nl> <nl> # include < mapbox / variant . hpp > <nl> + # include < rpl / details / type_list . h > <nl> + # include " base / match_method . h " <nl> + # include " base / assertion . h " <nl> <nl> / / We use base : : variant < > alias and base : : get_if ( ) helper while we don ' t have std : : variant < > . <nl> namespace base { <nl> inline const T * get_if ( const variant < Types . . . > * v ) { <nl> return ( v & & v - > template is < T > ( ) ) ? & v - > template get_unchecked < T > ( ) : nullptr ; <nl> } <nl> <nl> - / / Simplified visit <nl> - template < typename Method , typename . . . Types > <nl> - inline auto visit ( Method & & method , const variant < Types . . . > & value ) { <nl> - return value . match ( std : : forward < Method > ( method ) ) ; <nl> - } <nl> + namespace type_list = rpl : : details : : type_list ; <nl> + <nl> + template < typename . . . Types > <nl> + struct normalized_variant { <nl> + using list = type_list : : list < Types . . . > ; <nl> + using distinct = type_list : : distinct_t < list > ; <nl> + using type = std : : conditional_t < <nl> + type_list : : size_v < distinct > = = 1 , <nl> + type_list : : get_t < 0 , distinct > , <nl> + type_list : : extract_to_t < distinct , base : : variant > > ; <nl> + } ; <nl> + <nl> + template < typename . . . Types > <nl> + using normalized_variant_t <nl> + = typename normalized_variant < Types . . . > : : type ; <nl> + <nl> + template < typename TypeList , typename Variant , typename . . . Methods > <nl> + struct match_helper ; <nl> + <nl> + template < <nl> + typename Type , <nl> + typename . . . Types , <nl> + typename Variant , <nl> + typename . . . Methods > <nl> + struct match_helper < type_list : : list < Type , Types . . . > , Variant , Methods . . . > { <nl> + static decltype ( auto ) call ( Variant & value , Methods & & . . . methods ) { <nl> + if ( const auto v = get_if < Type > ( & value ) ) { <nl> + return match_method ( <nl> + * v , <nl> + std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + return match_helper < <nl> + type_list : : list < Types . . . > , <nl> + Variant , <nl> + Methods . . . > : : call ( <nl> + value , <nl> + std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + } ; <nl> + <nl> + template < <nl> + typename Type , <nl> + typename Variant , <nl> + typename . . . Methods > <nl> + struct match_helper < type_list : : list < Type > , Variant , Methods . . . > { <nl> + static decltype ( auto ) call ( Variant & value , Methods & & . . . methods ) { <nl> + if ( const auto v = get_if < Type > ( & value ) ) { <nl> + return match_method ( <nl> + * v , <nl> + std : : forward < Methods > ( methods ) . . . ) ; <nl> + } <nl> + Unexpected ( " Valueless variant in base : : match ( ) . " ) ; <nl> + } <nl> + } ; <nl> <nl> - template < typename Method , typename . . . Types > <nl> - inline auto visit ( Method & & method , variant < Types . . . > & value ) { <nl> - return value . match ( std : : forward < Method > ( method ) ) ; <nl> + template < typename . . . Types , typename . . . Methods > <nl> + inline decltype ( auto ) match ( <nl> + variant < Types . . . > & value , <nl> + Methods & & . . . methods ) { <nl> + return match_helper < <nl> + type_list : : list < Types . . . > , <nl> + variant < Types . . . > , <nl> + Methods . . . > : : call ( value , std : : forward < Methods > ( methods ) . . . ) ; <nl> } <nl> <nl> - template < typename Method , typename . . . Types > <nl> - inline auto visit ( Method & & method , variant < Types . . . > & & value ) { <nl> - return value . match ( std : : forward < Method > ( method ) ) ; <nl> + template < typename . . . Types , typename . . . Methods > <nl> + inline decltype ( auto ) match ( <nl> + const variant < Types . . . > & value , <nl> + Methods & & . . . methods ) { <nl> + return match_helper < <nl> + type_list : : list < Types . . . > , <nl> + const variant < Types . . . > , <nl> + Methods . . . > : : call ( value , std : : forward < Methods > ( methods ) . . . ) ; <nl> } <nl> <nl> } / / namespace base <nl> mmm a / Telegram / SourceFiles / codegen / scheme / codegen_scheme . py <nl> ppp b / Telegram / SourceFiles / codegen / scheme / codegen_scheme . py <nl> def addTextSerializeInit ( lst , dct ) : <nl> <nl> switchLines + = ' \ tcase mtpc_ ' + name + ' : ' ; # for by - type - id type constructor <nl> getters + = ' \ tconst MTPD ' + name + ' & c_ ' + name + ' ( ) const ; \ n ' ; # const getter <nl> - visitor + = ' \ tcase mtpc_ ' + name + ' : return VisitData ( c_ ' + name + ' ( ) , std : : forward < Callback > ( callback ) , std : : forward < Callbacks > ( callbacks ) . . . ) ; \ n ' ; <nl> + visitor + = ' \ tcase mtpc_ ' + name + ' : return base : : match_method ( c_ ' + name + ' ( ) , std : : forward < Method > ( method ) , std : : forward < Methods > ( methods ) . . . ) ; \ n ' ; <nl> <nl> forwards + = ' class MTPD ' + name + ' ; \ n ' ; # data class forward declaration <nl> if ( len ( prms ) > len ( trivialConditions ) ) : <nl> def addTextSerializeInit ( lst , dct ) : <nl> typesText + = getters ; <nl> if ( withType ) : <nl> typesText + = ' \ n ' ; <nl> - typesText + = ' \ ttemplate < typename Callback , typename . . . Callbacks > \ n ' ; <nl> - typesText + = ' \ tdecltype ( auto ) visit ( Callback & & callback , Callbacks & & . . . callbacks ) const ; \ n ' ; <nl> - visitorMethods + = ' template < typename Callback , typename . . . Callbacks > \ n ' ; <nl> - visitorMethods + = ' decltype ( auto ) MTP ' + restype + ' : : visit ( Callback & & callback , Callbacks & & . . . callbacks ) const { \ n ' ; <nl> + typesText + = ' \ ttemplate < typename Method , typename . . . Methods > \ n ' ; <nl> + typesText + = ' \ tdecltype ( auto ) match ( Method & & method , Methods & & . . . methods ) const ; \ n ' ; <nl> + visitorMethods + = ' template < typename Method , typename . . . Methods > \ n ' ; <nl> + visitorMethods + = ' decltype ( auto ) MTP ' + restype + ' : : match ( Method & & method , Methods & & . . . methods ) const { \ n ' ; <nl> visitorMethods + = ' \ tswitch ( _type ) { \ n ' ; <nl> visitorMethods + = visitor ; <nl> visitorMethods + = ' \ t } \ n ' ; <nl> - visitorMethods + = ' \ tUnexpected ( " Type in MTP ' + restype + ' : : visit . " ) ; \ n ' ; <nl> + visitorMethods + = ' \ tUnexpected ( " Type in MTP ' + restype + ' : : match . " ) ; \ n ' ; <nl> visitorMethods + = ' } \ n \ n ' ; <nl> <nl> typesText + = ' \ n \ tuint32 innerLength ( ) const ; \ n ' ; # size method <nl> mmm a / Telegram / SourceFiles / export / data / export_data_types . cpp <nl> ppp b / Telegram / SourceFiles / export / data / export_data_types . cpp <nl> For license and copyright information please follow this link : <nl> * / <nl> # include " export / data / export_data_types . h " <nl> <nl> + # include " core / mime_type . h " <nl> + <nl> # include < QtCore / QDateTime > <nl> + # include < QtCore / QRegularExpression > <nl> <nl> namespace App { / / Hackish . . <nl> QString formatPhone ( QString phone ) ; <nl> constexpr auto kChatPeerIdShift = ( 2ULL < < 32 ) ; <nl> <nl> } / / namespace <nl> <nl> + QString PreparePhotoFileName ( TimeId date ) { <nl> + return " Photo_ " <nl> + + QString : : fromUtf8 ( FormatDateTime ( date , ' _ ' , ' _ ' , ' _ ' ) ) <nl> + + " . jpg " ; <nl> + } <nl> + <nl> PeerId UserPeerId ( int32 userId ) { <nl> return kUserPeerIdShift | uint32 ( userId ) ; <nl> } <nl> int32 BarePeerId ( PeerId peerId ) { <nl> } <nl> <nl> PeerId ParsePeerId ( const MTPPeer & data ) { <nl> - return data . visit ( [ ] ( const MTPDpeerUser & data ) { <nl> + return data . match ( [ ] ( const MTPDpeerUser & data ) { <nl> return UserPeerId ( data . vuser_id . v ) ; <nl> } , [ ] ( const MTPDpeerChat & data ) { <nl> return ChatPeerId ( data . vchat_id . v ) ; <nl> Utf8String FillLeft ( const Utf8String & data , int length , char filler ) { <nl> } <nl> <nl> FileLocation ParseLocation ( const MTPFileLocation & data ) { <nl> - return data . visit ( [ ] ( const MTPDfileLocation & data ) { <nl> + return data . match ( [ ] ( const MTPDfileLocation & data ) { <nl> return FileLocation { <nl> data . vdc_id . v , <nl> MTP_inputFileLocation ( <nl> FileLocation ParseLocation ( const MTPFileLocation & data ) { <nl> } ) ; <nl> } <nl> <nl> - File ParseMaxImage ( <nl> + Image ParseMaxImage ( <nl> const MTPVector < MTPPhotoSize > & data , <nl> const QString & suggestedPath ) { <nl> - auto result = File ( ) ; <nl> - result . suggestedPath = suggestedPath ; <nl> + auto result = Image ( ) ; <nl> + result . file . suggestedPath = suggestedPath ; <nl> <nl> auto maxArea = int64 ( 0 ) ; <nl> for ( const auto & size : data . v ) { <nl> - size . visit ( [ & ] ( const MTPDphotoSize & data ) { <nl> - const auto area = data . vw . v * int64 ( data . vh . v ) ; <nl> - if ( area > maxArea ) { <nl> - result . location = ParseLocation ( data . vlocation ) ; <nl> - result . size = data . vsize . v ; <nl> - result . content = QByteArray ( ) ; <nl> - maxArea = area ; <nl> - } <nl> - } , [ & ] ( const MTPDphotoCachedSize & data ) { <nl> + size . match ( [ ] ( const MTPDphotoSizeEmpty & ) { <nl> + } , [ & ] ( const auto & data ) { <nl> const auto area = data . vw . v * int64 ( data . vh . v ) ; <nl> if ( area > maxArea ) { <nl> - result . location = ParseLocation ( data . vlocation ) ; <nl> - result . size = data . vbytes . v . size ( ) ; <nl> - result . content = data . vbytes . v ; <nl> + result . width = data . vw . v ; <nl> + result . height = data . vh . v ; <nl> + result . file . location = ParseLocation ( data . vlocation ) ; <nl> + if constexpr ( MTPDphotoCachedSize : : Is < decltype ( data ) > ( ) ) { <nl> + result . file . content = data . vbytes . v ; <nl> + result . file . size = result . file . content . size ( ) ; <nl> + } else { <nl> + result . file . content = QByteArray ( ) ; <nl> + result . file . size = data . vsize . v ; <nl> + } <nl> maxArea = area ; <nl> } <nl> - } , [ ] ( const MTPDphotoSizeEmpty & ) { } ) ; <nl> + } ) ; <nl> } <nl> return result ; <nl> } <nl> <nl> Photo ParsePhoto ( const MTPPhoto & data , const QString & suggestedPath ) { <nl> auto result = Photo ( ) ; <nl> - data . visit ( [ & ] ( const MTPDphoto & data ) { <nl> + data . match ( [ & ] ( const MTPDphoto & data ) { <nl> result . id = data . vid . v ; <nl> result . date = data . vdate . v ; <nl> result . image = ParseMaxImage ( data . vsizes , suggestedPath ) ; <nl> Photo ParsePhoto ( const MTPPhoto & data , const QString & suggestedPath ) { <nl> return result ; <nl> } <nl> <nl> + void ParseAttributes ( <nl> + Document & result , <nl> + const MTPVector < MTPDocumentAttribute > & attributes ) { <nl> + for ( const auto & value : attributes . v ) { <nl> + value . match ( [ & ] ( const MTPDdocumentAttributeImageSize & data ) { <nl> + result . width = data . vw . v ; <nl> + result . height = data . vh . v ; <nl> + } , [ & ] ( const MTPDdocumentAttributeAnimated & data ) { <nl> + result . isAnimated = true ; <nl> + } , [ & ] ( const MTPDdocumentAttributeSticker & data ) { <nl> + result . stickerEmoji = ParseString ( data . valt ) ; <nl> + } , [ & ] ( const MTPDdocumentAttributeVideo & data ) { <nl> + if ( data . is_round_message ( ) ) { <nl> + result . isVideoMessage = true ; <nl> + } else { <nl> + result . isVideoFile = true ; <nl> + } <nl> + result . width = data . vw . v ; <nl> + result . height = data . vh . v ; <nl> + result . duration = data . vduration . v ; <nl> + } , [ & ] ( const MTPDdocumentAttributeAudio & data ) { <nl> + if ( data . is_voice ( ) ) { <nl> + result . isVoiceMessage = true ; <nl> + } else { <nl> + result . isAudioFile = true ; <nl> + } <nl> + result . songPerformer = ParseString ( data . vperformer ) ; <nl> + result . songTitle = ParseString ( data . vtitle ) ; <nl> + result . duration = data . vduration . v ; <nl> + } , [ & ] ( const MTPDdocumentAttributeFilename & data ) { <nl> + result . name = ParseString ( data . vfile_name ) ; <nl> + } , [ & ] ( const MTPDdocumentAttributeHasStickers & data ) { <nl> + } ) ; <nl> + } <nl> + } <nl> + <nl> + QString ComputeDocumentName ( const Document & data , TimeId date ) { <nl> + if ( ! data . name . isEmpty ( ) ) { <nl> + return QString : : fromUtf8 ( data . name ) ; <nl> + } <nl> + const auto mimeString = QString : : fromUtf8 ( data . mime ) ; <nl> + const auto mimeType = Core : : MimeTypeForName ( mimeString ) ; <nl> + const auto hasMimeType = [ & ] ( QLatin1String mime ) { <nl> + return ! mimeString . compare ( mime , Qt : : CaseInsensitive ) ; <nl> + } ; <nl> + const auto patterns = mimeType . globPatterns ( ) ; <nl> + auto pattern = patterns . isEmpty ( ) ? QString ( ) : patterns . front ( ) ; <nl> + auto extension = QString ( ) ; <nl> + auto prefix = QString ( ) ; <nl> + if ( data . isVoiceMessage ) { <nl> + const auto isMP3 = hasMimeType ( qstr ( " audio / mp3 " ) ) ; <nl> + extension = isMP3 ? qsl ( " . mp3 " ) : qsl ( " . ogg " ) ; <nl> + prefix = qsl ( " Audio_ " ) ; <nl> + } else if ( data . isVideoFile ) { <nl> + extension = pattern . isEmpty ( ) <nl> + ? qsl ( " . mov " ) <nl> + : QString ( pattern ) . replace ( ' * ' , QString ( ) ) ; <nl> + prefix = qsl ( " Video_ " ) ; <nl> + } else { <nl> + extension = pattern . isEmpty ( ) <nl> + ? qsl ( " . unknown " ) <nl> + : pattern . replace ( ' * ' , QString ( ) ) ; <nl> + prefix = qsl ( " File_ " ) ; <nl> + } <nl> + return prefix <nl> + + QString : : fromUtf8 ( FormatDateTime ( date , ' _ ' , ' _ ' , ' _ ' ) ) <nl> + + extension ; <nl> + } <nl> + <nl> + QString CleanDocumentName ( QString name ) { <nl> + / / We don ' t want LTR / RTL mark / embedding / override / isolate chars <nl> + / / in filenames , because they introduce a security issue , when <nl> + / / an executable " Fil [ x ] gepj . exe " may look like " Filexe . jpeg " . <nl> + QChar controls [ ] = { <nl> + 0x200E , / / LTR Mark <nl> + 0x200F , / / RTL Mark <nl> + 0x202A , / / LTR Embedding <nl> + 0x202B , / / RTL Embedding <nl> + 0x202D , / / LTR Override <nl> + 0x202E , / / RTL Override <nl> + 0x2066 , / / LTR Isolate <nl> + 0x2067 , / / RTL Isolate <nl> + # ifdef Q_OS_WIN <nl> + ' \ \ ' , <nl> + ' / ' , <nl> + ' : ' , <nl> + ' * ' , <nl> + ' ? ' , <nl> + ' " ' , <nl> + ' < ' , <nl> + ' > ' , <nl> + ' | ' , <nl> + # elif defined Q_OS_MAC / / Q_OS_WIN <nl> + ' : ' , <nl> + # elif defined Q_OS_LINUX / / Q_OS_WIN | | Q_OS_MAC <nl> + ' / ' , <nl> + # endif / / Q_OS_WIN | | Q_OS_MAC | | Q_OS_LINUX <nl> + } ; <nl> + for ( const auto ch : controls ) { <nl> + name = std : : move ( name ) . replace ( ch , ' _ ' ) ; <nl> + } <nl> + <nl> + # ifdef Q_OS_WIN <nl> + const auto lower = name . trimmed ( ) . toLower ( ) ; <nl> + const auto kBadExtensions = { qstr ( " . lnk " ) , qstr ( " . scf " ) } ; <nl> + const auto kMaskExtension = qsl ( " . download " ) ; <nl> + for ( const auto extension : kBadExtensions ) { <nl> + if ( lower . endsWith ( extension ) ) { <nl> + return name + kMaskExtension ; <nl> + } <nl> + } <nl> + # endif / / Q_OS_WIN <nl> + <nl> + return name ; <nl> + } <nl> + <nl> + Document ParseDocument ( <nl> + const MTPDocument & data , <nl> + const QString & suggestedFolder , <nl> + TimeId date ) { <nl> + auto result = Document ( ) ; <nl> + data . match ( [ & ] ( const MTPDdocument & data ) { <nl> + result . id = data . vid . v ; <nl> + result . date = data . vdate . v ; <nl> + result . file . size = data . vsize . v ; <nl> + result . file . location . dcId = data . vdc_id . v ; <nl> + result . file . location . data = MTP_inputDocumentFileLocation ( <nl> + data . vid , <nl> + data . vaccess_hash , <nl> + data . vversion ) ; <nl> + result . mime = ParseString ( data . vmime_type ) ; <nl> + ParseAttributes ( result , data . vattributes ) ; <nl> + result . file . suggestedPath = suggestedFolder <nl> + + CleanDocumentName ( <nl> + ComputeDocumentName ( result , date ? date : result . date ) ) ; <nl> + } , [ & ] ( const MTPDdocumentEmpty & data ) { <nl> + result . id = data . vid . v ; <nl> + } ) ; <nl> + return result ; <nl> + } <nl> + <nl> Utf8String FormatDateTime ( <nl> TimeId date , <nl> QChar dateSeparator , <nl> UserpicsSlice ParseUserpicsSlice ( const MTPVector < MTPPhoto > & data ) { <nl> auto result = UserpicsSlice ( ) ; <nl> result . list . reserve ( list . size ( ) ) ; <nl> for ( const auto & photo : list ) { <nl> - const auto suggestedPath = " PersonalPhotos / Photo_ " <nl> + const auto suggestedPath = " PersonalPhotos / " <nl> + ( photo . type ( ) = = mtpc_photo <nl> - ? QString : : fromUtf8 ( <nl> - FormatDateTime ( photo . c_photo ( ) . vdate . v , ' _ ' , ' _ ' , ' _ ' ) ) <nl> - : " Empty " ) <nl> - + " . jpg " ; <nl> + ? PreparePhotoFileName ( photo . c_photo ( ) . vdate . v ) <nl> + : " Photo_Empty . jpg " ) ; <nl> result . list . push_back ( ParsePhoto ( photo , suggestedPath ) ) ; <nl> } <nl> return result ; <nl> UserpicsSlice ParseUserpicsSlice ( const MTPVector < MTPPhoto > & data ) { <nl> <nl> User ParseUser ( const MTPUser & data ) { <nl> auto result = User ( ) ; <nl> - data . visit ( [ & ] ( const MTPDuser & data ) { <nl> + data . match ( [ & ] ( const MTPDuser & data ) { <nl> result . id = data . vid . v ; <nl> if ( data . has_first_name ( ) ) { <nl> result . firstName = ParseString ( data . vfirst_name ) ; <nl> std : : map < int32 , User > ParseUsersList ( const MTPVector < MTPUser > & data ) { <nl> <nl> Chat ParseChat ( const MTPChat & data ) { <nl> auto result = Chat ( ) ; <nl> - data . visit ( [ & ] ( const MTPDchat & data ) { <nl> + data . match ( [ & ] ( const MTPDchat & data ) { <nl> result . id = data . vid . v ; <nl> result . title = ParseString ( data . vtitle ) ; <nl> result . input = MTP_inputPeerChat ( MTP_int ( result . id ) ) ; <nl> std : : map < PeerId , Peer > ParsePeersLists ( <nl> return result ; <nl> } <nl> <nl> - Message ParseMessage ( const MTPMessage & data ) { <nl> + File & Media : : file ( ) { <nl> + return content . match ( [ ] ( Photo & data ) - > File & { <nl> + return data . image . file ; <nl> + } , [ ] ( Document & data ) - > File & { <nl> + return data . file ; <nl> + } , [ ] ( base : : none_type & ) - > File & { <nl> + static File result ; <nl> + return result ; <nl> + } ) ; <nl> + } <nl> + <nl> + const File & Media : : file ( ) const { <nl> + return content . match ( [ ] ( const Photo & data ) - > const File & { <nl> + return data . image . file ; <nl> + } , [ ] ( const Document & data ) - > const File & { <nl> + return data . file ; <nl> + } , [ ] ( const base : : none_type & ) - > const File & { <nl> + static const File result ; <nl> + return result ; <nl> + } ) ; <nl> + } <nl> + <nl> + Media ParseMedia ( <nl> + const MTPMessageMedia & data , <nl> + const QString & folder , <nl> + TimeId date ) { <nl> + Expects ( folder . isEmpty ( ) | | folder . endsWith ( QChar ( ' / ' ) ) ) ; <nl> + <nl> + auto result = Media ( ) ; <nl> + data . match ( [ & ] ( const MTPDmessageMediaPhoto & data ) { <nl> + result . content = data . has_photo ( ) <nl> + ? ParsePhoto ( <nl> + data . vphoto , <nl> + folder + " Photos / " + PreparePhotoFileName ( date ) ) <nl> + : Photo ( ) ; <nl> + if ( data . has_ttl_seconds ( ) ) { <nl> + result . ttl = data . vttl_seconds . v ; <nl> + } <nl> + } , [ & ] ( const MTPDmessageMediaGeo & data ) { <nl> + } , [ & ] ( const MTPDmessageMediaContact & data ) { <nl> + } , [ & ] ( const MTPDmessageMediaUnsupported & data ) { <nl> + } , [ & ] ( const MTPDmessageMediaDocument & data ) { <nl> + result . content = data . has_document ( ) <nl> + ? ParseDocument ( <nl> + data . vdocument , <nl> + folder + " Files / " , <nl> + date ) <nl> + : Document ( ) ; <nl> + } , [ & ] ( const MTPDmessageMediaWebPage & data ) { <nl> + / / Ignore web pages . <nl> + } , [ & ] ( const MTPDmessageMediaVenue & data ) { <nl> + } , [ & ] ( const MTPDmessageMediaGame & data ) { <nl> + } , [ & ] ( const MTPDmessageMediaInvoice & data ) { <nl> + } , [ & ] ( const MTPDmessageMediaGeoLive & data ) { <nl> + } , [ ] ( const MTPDmessageMediaEmpty & data ) { } ) ; <nl> + return result ; <nl> + } <nl> + <nl> + ServiceAction ParseServiceAction ( <nl> + const MTPMessageAction & data , <nl> + const QString & mediaFolder , <nl> + TimeId date ) { <nl> + auto result = ServiceAction ( ) ; <nl> + data . match ( [ & ] ( const MTPDmessageActionChatCreate & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatEditTitle & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatEditPhoto & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatDeletePhoto & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatAddUser & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatDeleteUser & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatJoinedByLink & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChannelCreate & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChatMigrateTo & data ) { <nl> + } , [ & ] ( const MTPDmessageActionChannelMigrateFrom & data ) { <nl> + } , [ & ] ( const MTPDmessageActionPinMessage & data ) { <nl> + } , [ & ] ( const MTPDmessageActionHistoryClear & data ) { <nl> + } , [ & ] ( const MTPDmessageActionGameScore & data ) { <nl> + } , [ & ] ( const MTPDmessageActionPaymentSentMe & data ) { <nl> + } , [ & ] ( const MTPDmessageActionPaymentSent & data ) { <nl> + } , [ & ] ( const MTPDmessageActionPhoneCall & data ) { <nl> + } , [ & ] ( const MTPDmessageActionScreenshotTaken & data ) { <nl> + } , [ & ] ( const MTPDmessageActionCustomAction & data ) { <nl> + } , [ & ] ( const MTPDmessageActionBotAllowed & data ) { <nl> + } , [ & ] ( const MTPDmessageActionSecureValuesSentMe & data ) { <nl> + } , [ & ] ( const MTPDmessageActionSecureValuesSent & data ) { <nl> + } , [ ] ( const MTPDmessageActionEmpty & data ) { } ) ; <nl> + return result ; <nl> + } <nl> + <nl> + Message ParseMessage ( const MTPMessage & data , const QString & mediaFolder ) { <nl> auto result = Message ( ) ; <nl> - data . visit ( [ & ] ( const MTPDmessage & data ) { <nl> + data . match ( [ & ] ( const MTPDmessage & data ) { <nl> result . id = data . vid . v ; <nl> - result . date = data . vdate . v ; <nl> + const auto date = result . date = data . vdate . v ; <nl> + if ( data . has_edit_date ( ) ) { <nl> + result . edited = data . vedit_date . v ; <nl> + } <nl> + if ( data . has_from_id ( ) ) { <nl> + result . fromId = data . vfrom_id . v ; <nl> + } <nl> + if ( data . has_reply_to_msg_id ( ) ) { <nl> + result . replyToMsgId = data . vreply_to_msg_id . v ; <nl> + } <nl> + if ( data . has_via_bot_id ( ) ) { <nl> + result . viaBotId = data . vvia_bot_id . v ; <nl> + } <nl> + if ( data . has_media ( ) ) { <nl> + result . media = ParseMedia ( data . vmedia , mediaFolder , date ) ; <nl> + } <nl> result . text = ParseString ( data . vmessage ) ; <nl> } , [ & ] ( const MTPDmessageService & data ) { <nl> result . id = data . vid . v ; <nl> - result . date = data . vdate . v ; <nl> + const auto date = result . date = data . vdate . v ; <nl> + result . action = ParseServiceAction ( data . vaction , mediaFolder , date ) ; <nl> + if ( data . has_from_id ( ) ) { <nl> + result . fromId = data . vfrom_id . v ; <nl> + } <nl> + if ( data . has_reply_to_msg_id ( ) ) { <nl> + result . replyToMsgId = data . vreply_to_msg_id . v ; <nl> + } <nl> } , [ & ] ( const MTPDmessageEmpty & data ) { <nl> result . id = data . vid . v ; <nl> } ) ; <nl> Message ParseMessage ( const MTPMessage & data ) { <nl> } <nl> <nl> std : : map < int32 , Message > ParseMessagesList ( <nl> - const MTPVector < MTPMessage > & data ) { <nl> + const MTPVector < MTPMessage > & data , <nl> + const QString & mediaFolder ) { <nl> auto result = std : : map < int32 , Message > ( ) ; <nl> for ( const auto & message : data . v ) { <nl> - auto parsed = ParseMessage ( message ) ; <nl> + auto parsed = ParseMessage ( message , mediaFolder ) ; <nl> result . emplace ( parsed . id , std : : move ( parsed ) ) ; <nl> } <nl> return result ; <nl> SessionsList ParseSessionsList ( const MTPaccount_Authorizations & data ) { <nl> <nl> DialogsInfo ParseDialogsInfo ( const MTPmessages_Dialogs & data ) { <nl> auto result = DialogsInfo ( ) ; <nl> - data . visit ( [ & ] ( const auto & data ) { / / MTPDmessages_dialogs & data ) { <nl> + const auto folder = QString ( ) ; <nl> + data . match ( [ & ] ( const auto & data ) { / / MTPDmessages_dialogs & data ) { <nl> const auto peers = ParsePeersLists ( data . vusers , data . vchats ) ; <nl> - const auto messages = ParseMessagesList ( data . vmessages ) ; <nl> + const auto messages = ParseMessagesList ( data . vmessages , folder ) ; <nl> result . list . reserve ( result . list . size ( ) + data . vdialogs . v . size ( ) ) ; <nl> for ( const auto & dialog : data . vdialogs . v ) { <nl> if ( dialog . type ( ) ! = mtpc_dialog ) { <nl> DialogsInfo ParseDialogsInfo ( const MTPmessages_Dialogs & data ) { <nl> MessagesSlice ParseMessagesSlice ( <nl> const MTPVector < MTPMessage > & data , <nl> const MTPVector < MTPUser > & users , <nl> - const MTPVector < MTPChat > & chats ) { <nl> + const MTPVector < MTPChat > & chats , <nl> + const QString & mediaFolder ) { <nl> const auto & list = data . v ; <nl> auto result = MessagesSlice ( ) ; <nl> result . list . reserve ( list . size ( ) ) ; <nl> for ( const auto & message : list ) { <nl> - result . list . push_back ( ParseMessage ( message ) ) ; <nl> + result . list . push_back ( ParseMessage ( message , mediaFolder ) ) ; <nl> } <nl> ranges : : reverse ( result . list ) ; <nl> result . peers = ParsePeersLists ( users , chats ) ; <nl> mmm a / Telegram / SourceFiles / export / data / export_data_types . h <nl> ppp b / Telegram / SourceFiles / export / data / export_data_types . h <nl> struct File { <nl> QString relativePath ; <nl> } ; <nl> <nl> + struct Image { <nl> + int width = 0 ; <nl> + int height = 0 ; <nl> + File file ; <nl> + } ; <nl> + <nl> struct Photo { <nl> uint64 id = 0 ; <nl> TimeId date = 0 ; <nl> <nl> + Image image ; <nl> + } ; <nl> + <nl> + struct Document { <nl> + uint64 id = 0 ; <nl> + TimeId date = 0 ; <nl> + <nl> + File file ; <nl> + <nl> + Utf8String name ; <nl> + Utf8String mime ; <nl> int width = 0 ; <nl> int height = 0 ; <nl> - File image ; <nl> + <nl> + Utf8String stickerEmoji ; <nl> + Utf8String songPerformer ; <nl> + Utf8String songTitle ; <nl> + int duration = 0 ; <nl> + <nl> + bool isAnimated = false ; <nl> + bool isVideoMessage = false ; <nl> + bool isVoiceMessage = false ; <nl> + bool isVideoFile = false ; <nl> + bool isAudioFile = false ; <nl> } ; <nl> <nl> struct UserpicsSlice { <nl> struct SessionsList { <nl> <nl> SessionsList ParseSessionsList ( const MTPaccount_Authorizations & data ) ; <nl> <nl> + struct Media { <nl> + base : : optional_variant < Photo , Document > content ; <nl> + TimeId ttl = 0 ; <nl> + <nl> + File & file ( ) ; <nl> + const File & file ( ) const ; <nl> + } ; <nl> + <nl> + Media ParseMedia ( <nl> + const MTPMessageMedia & data , <nl> + const QString & folder , <nl> + TimeId date ) ; <nl> + <nl> + struct ServiceAction { <nl> + base : : optional_variant < > data ; <nl> + } ; <nl> + <nl> + ServiceAction ParseServiceAction ( <nl> + const MTPMessageAction & data , <nl> + const QString & mediaFolder , <nl> + TimeId date ) ; <nl> + <nl> struct Message { <nl> int32 id = 0 ; <nl> TimeId date = 0 ; <nl> - <nl> + TimeId edited = 0 ; <nl> + int32 fromId = 0 ; <nl> + int32 viaBotId = 0 ; <nl> + int32 replyToMsgId = 0 ; <nl> Utf8String text ; <nl> - File mediaFile ; <nl> + Media media ; <nl> + ServiceAction action ; <nl> <nl> } ; <nl> <nl> - Message ParseMessage ( const MTPMessage & data ) ; <nl> + Message ParseMessage ( const MTPMessage & data , const QString & mediaFolder ) ; <nl> std : : map < int32 , Message > ParseMessagesList ( <nl> - const MTPVector < MTPMessage > & data ) ; <nl> + const MTPVector < MTPMessage > & data , <nl> + const QString & mediaFolder ) ; <nl> <nl> struct DialogInfo { <nl> enum class Type { <nl> struct DialogInfo { <nl> MTPInputPeer input ; <nl> int32 topMessageId = 0 ; <nl> TimeId topMessageDate = 0 ; <nl> + <nl> + QString relativePath ; <nl> + <nl> } ; <nl> <nl> struct DialogsInfo { <nl> struct MessagesSlice { <nl> MessagesSlice ParseMessagesSlice ( <nl> const MTPVector < MTPMessage > & data , <nl> const MTPVector < MTPUser > & users , <nl> - const MTPVector < MTPChat > & chats ) ; <nl> + const MTPVector < MTPChat > & chats , <nl> + const QString & mediaFolder ) ; <nl> <nl> Utf8String FormatPhoneNumber ( const Utf8String & phoneNumber ) ; <nl> <nl> mmm a / Telegram / SourceFiles / export / export_api_wrap . cpp <nl> ppp b / Telegram / SourceFiles / export / export_api_wrap . cpp <nl> constexpr auto kFileNextRequestDelay = TimeMs ( 20 ) ; <nl> constexpr auto kChatsSliceLimit = 100 ; <nl> constexpr auto kMessagesSliceLimit = 100 ; <nl> <nl> + bool WillLoadFile ( const Data : : File & file ) { <nl> + return file . relativePath . isEmpty ( ) <nl> + & & ( ! file . content . isEmpty ( ) | | file . location . dcId ! = 0 ) ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> struct ApiWrap : : UserpicsProcess { <nl> struct ApiWrap : : DialogsProcess { <nl> struct ApiWrap : : DialogsProcess : : Single { <nl> Single ( const Data : : DialogInfo & info ) ; <nl> <nl> - MTPInputPeer peer ; <nl> + Data : : DialogInfo info ; <nl> int32 offsetId = 1 ; <nl> <nl> base : : optional < Data : : MessagesSlice > slice ; <nl> ApiWrap : : FileProcess : : FileProcess ( const QString & path ) : file ( path ) { <nl> } <nl> <nl> ApiWrap : : DialogsProcess : : Single : : Single ( const Data : : DialogInfo & info ) <nl> - : peer ( info . input ) { <nl> + : info ( info ) { <nl> } <nl> <nl> template < typename Request > <nl> void ApiWrap : : requestUserpics ( <nl> <nl> _userpicsProcess - > start ( [ & ] { <nl> auto info = Data : : UserpicsInfo ( ) ; <nl> - result . visit ( [ & ] ( const MTPDphotos_photos & data ) { <nl> + result . match ( [ & ] ( const MTPDphotos_photos & data ) { <nl> info . count = data . vphotos . v . size ( ) ; <nl> } , [ & ] ( const MTPDphotos_photosSlice & data ) { <nl> info . count = data . vcount . v ; <nl> void ApiWrap : : requestUserpics ( <nl> void ApiWrap : : handleUserpicsSlice ( const MTPphotos_Photos & result ) { <nl> Expects ( _userpicsProcess ! = nullptr ) ; <nl> <nl> - result . visit ( [ & ] ( const auto & data ) { <nl> + result . match ( [ & ] ( const auto & data ) { <nl> if constexpr ( MTPDphotos_photos : : Is < decltype ( data ) > ( ) ) { <nl> _userpicsProcess - > lastSlice = true ; <nl> } <nl> void ApiWrap : : loadNextUserpic ( ) { <nl> Expects ( _userpicsProcess - > slice . has_value ( ) ) ; <nl> <nl> const auto & list = _userpicsProcess - > slice - > list ; <nl> - + + _userpicsProcess - > fileIndex ; <nl> - if ( _userpicsProcess - > fileIndex < list . size ( ) ) { <nl> - loadFile ( <nl> - list [ _userpicsProcess - > fileIndex ] . image , <nl> - [ = ] ( const QString & path ) { loadUserpicDone ( path ) ; } ) ; <nl> - return ; <nl> + while ( true ) { <nl> + const auto index = + + _userpicsProcess - > fileIndex ; <nl> + if ( index > = list . size ( ) ) { <nl> + break ; <nl> + } <nl> + const auto & file = list [ index ] . image . file ; <nl> + if ( WillLoadFile ( file ) ) { <nl> + loadFile ( <nl> + file , <nl> + [ = ] ( const QString & path ) { loadUserpicDone ( path ) ; } ) ; <nl> + return ; <nl> + } <nl> } <nl> const auto lastUserpicId = list . empty ( ) <nl> ? base : : none <nl> void ApiWrap : : loadUserpicDone ( const QString & relativePath ) { <nl> < _userpicsProcess - > slice - > list . size ( ) ) ) ; <nl> <nl> const auto index = _userpicsProcess - > fileIndex ; <nl> - _userpicsProcess - > slice - > list [ index ] . image . relativePath = relativePath ; <nl> + auto & file = _userpicsProcess - > slice - > list [ index ] . image . file ; <nl> + file . relativePath = relativePath ; <nl> loadNextUserpic ( ) ; <nl> } <nl> <nl> void ApiWrap : : finishDialogsList ( ) { <nl> Expects ( _dialogsProcess ! = nullptr ) ; <nl> <nl> ranges : : reverse ( _dialogsProcess - > info . list ) ; <nl> + fillDialogsPaths ( ) ; <nl> + <nl> _dialogsProcess - > start ( _dialogsProcess - > info ) ; <nl> requestNextDialog ( ) ; <nl> } <nl> <nl> + void ApiWrap : : fillDialogsPaths ( ) { <nl> + Expects ( _dialogsProcess ! = nullptr ) ; <nl> + <nl> + auto & list = _dialogsProcess - > info . list ; <nl> + const auto digits = Data : : NumberToString ( list . size ( ) - 1 ) . size ( ) ; <nl> + auto index = 0 ; <nl> + for ( auto & dialog : list ) { <nl> + const auto number = Data : : NumberToString ( + + index , digits , ' 0 ' ) ; <nl> + dialog . relativePath = " Chats / chat_ " + number + ' / ' ; <nl> + } <nl> + } <nl> + <nl> void ApiWrap : : requestNextDialog ( ) { <nl> Expects ( _dialogsProcess ! = nullptr ) ; <nl> Expects ( _dialogsProcess - > single = = nullptr ) ; <nl> <nl> const auto index = + + _dialogsProcess - > singleIndex ; <nl> - if ( index < 3 ) { / / _dialogsProcess - > info . list . size ( ) ) { <nl> + if ( index < 11 ) { / / _dialogsProcess - > info . list . size ( ) ) { <nl> const auto & one = _dialogsProcess - > info . list [ index ] ; <nl> _dialogsProcess - > single = std : : make_unique < DialogsProcess : : Single > ( one ) ; <nl> _dialogsProcess - > startOne ( one ) ; <nl> void ApiWrap : : requestMessagesSlice ( ) { <nl> <nl> const auto process = _dialogsProcess - > single . get ( ) ; <nl> mainRequest ( MTPmessages_GetHistory ( <nl> - process - > peer , <nl> + process - > info . input , <nl> MTP_int ( process - > offsetId ) , <nl> MTP_int ( 0 ) , / / offset_date <nl> MTP_int ( - kMessagesSliceLimit ) , <nl> void ApiWrap : : requestMessagesSlice ( ) { <nl> Expects ( _dialogsProcess - > single ! = nullptr ) ; <nl> <nl> const auto process = _dialogsProcess - > single . get ( ) ; <nl> - result . visit ( [ & ] ( const MTPDmessages_messagesNotModified & data ) { <nl> + result . match ( [ & ] ( const MTPDmessages_messagesNotModified & data ) { <nl> error ( " Unexpected messagesNotModified received . " ) ; <nl> } , [ & ] ( const auto & data ) { <nl> if constexpr ( MTPDmessages_messages : : Is < decltype ( data ) > ( ) ) { <nl> void ApiWrap : : requestMessagesSlice ( ) { <nl> loadMessagesFiles ( Data : : ParseMessagesSlice ( <nl> data . vmessages , <nl> data . vusers , <nl> - data . vchats ) ) ; <nl> + data . vchats , <nl> + process - > info . relativePath ) ) ; <nl> } ) ; <nl> } ) . send ( ) ; <nl> } <nl> void ApiWrap : : loadNextMessageFile ( ) { <nl> <nl> const auto process = _dialogsProcess - > single . get ( ) ; <nl> const auto & list = process - > slice - > list ; <nl> - + + process - > fileIndex ; <nl> - if ( process - > fileIndex < list . size ( ) ) { <nl> - loadFile ( <nl> - list [ process - > fileIndex ] . mediaFile , <nl> - [ = ] ( const QString & path ) { loadMessageFileDone ( path ) ; } ) ; <nl> - return ; <nl> + while ( true ) { <nl> + const auto index = + + process - > fileIndex ; <nl> + if ( index > = list . size ( ) ) { <nl> + break ; <nl> + } <nl> + const auto & file = list [ index ] . media . file ( ) ; <nl> + if ( WillLoadFile ( file ) ) { <nl> + loadFile ( <nl> + file , <nl> + [ = ] ( const QString & path ) { loadMessageFileDone ( path ) ; } ) ; <nl> + return ; <nl> + } <nl> } <nl> <nl> _dialogsProcess - > sliceOne ( * base : : take ( process - > slice ) ) ; <nl> void ApiWrap : : loadMessageFileDone ( const QString & relativePath ) { <nl> <nl> const auto process = _dialogsProcess - > single . get ( ) ; <nl> const auto index = process - > fileIndex ; <nl> - process - > slice - > list [ index ] . mediaFile . relativePath = relativePath ; <nl> + process - > slice - > list [ index ] . media . file ( ) . relativePath = relativePath ; <nl> loadNextMessageFile ( ) ; <nl> } <nl> <nl> void ApiWrap : : finishDialogs ( ) { <nl> void ApiWrap : : loadFile ( const Data : : File & file , FnMut < void ( QString ) > done ) { <nl> Expects ( _fileProcess = = nullptr ) ; <nl> Expects ( _settings ! = nullptr ) ; <nl> - <nl> - if ( ! file . relativePath . isEmpty ( ) ) { <nl> - done ( file . relativePath ) ; <nl> - return ; <nl> - } else if ( file . content . isEmpty ( ) & & ! file . location . dcId ) { <nl> - done ( QString ( ) ) ; <nl> - return ; <nl> - } <nl> + Expects ( WillLoadFile ( file ) ) ; <nl> <nl> using namespace Output ; <nl> const auto relativePath = File : : PrepareRelativePath ( <nl> mmm a / Telegram / SourceFiles / export / export_api_wrap . h <nl> ppp b / Telegram / SourceFiles / export / export_api_wrap . h <nl> class ApiWrap { <nl> void requestDialogsSlice ( ) ; <nl> void appendDialogsSlice ( Data : : DialogsInfo & & info ) ; <nl> void finishDialogsList ( ) ; <nl> + void fillDialogsPaths ( ) ; <nl> <nl> void requestNextDialog ( ) ; <nl> void requestMessagesSlice ( ) ; <nl> mmm a / Telegram / SourceFiles / export / output / export_output_text . cpp <nl> ppp b / Telegram / SourceFiles / export / output / export_output_text . cpp <nl> bool TextWriter : : writeUserpicsSlice ( const Data : : UserpicsSlice & data ) { <nl> lines . append ( " ( deleted photo ) " ) ; <nl> } else { <nl> lines . append ( Data : : FormatDateTime ( userpic . date ) ) . append ( " - " ) ; <nl> - if ( userpic . image . relativePath . isEmpty ( ) ) { <nl> + if ( userpic . image . file . relativePath . isEmpty ( ) ) { <nl> lines . append ( " ( file unavailable ) " ) ; <nl> } else { <nl> - lines . append ( userpic . image . relativePath . toUtf8 ( ) ) ; <nl> + lines . append ( userpic . image . file . relativePath . toUtf8 ( ) ) ; <nl> } <nl> } <nl> lines . append ( kLineBreak ) ; <nl> bool TextWriter : : writeDialogsStart ( const Data : : DialogsInfo & data ) { <nl> } <nl> Unexpected ( " Dialog type in TypeString . " ) ; <nl> } ; <nl> - const auto digits = Data : : NumberToString ( data . list . size ( ) - 1 ) . size ( ) ; <nl> const auto file = fileWithRelativePath ( " chats . txt " ) ; <nl> auto list = std : : vector < QByteArray > ( ) ; <nl> list . reserve ( data . list . size ( ) ) ; <nl> auto index = 0 ; <nl> for ( const auto & dialog : data . list ) { <nl> - const auto number = Data : : NumberToString ( + + index , digits , ' 0 ' ) ; <nl> - const auto path = " Chats / chat_ " + number + " . txt " ; <nl> + const auto path = dialog . relativePath + " messages . txt " ; <nl> list . push_back ( SerializeKeyValue ( { <nl> { " Name " , NameString ( dialog . name , dialog . type ) } , <nl> { " Type " , TypeString ( dialog . type ) } , <nl> - { " Content " , path } <nl> + { " Content " , path . toUtf8 ( ) } <nl> } ) ) ; <nl> } <nl> const auto full = JoinList ( kLineBreak , list ) ; <nl> bool TextWriter : : writeDialogStart ( const Data : : DialogInfo & data ) { <nl> <nl> const auto digits = Data : : NumberToString ( _dialogsCount - 1 ) . size ( ) ; <nl> const auto number = Data : : NumberToString ( + + _dialogIndex , digits , ' 0 ' ) ; <nl> - _dialog = fileWithRelativePath ( " Chats / chat_ " + number + " . txt " ) ; <nl> + _dialog = fileWithRelativePath ( data . relativePath + " messages . txt " ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / mtproto / core_types . h <nl> ppp b / Telegram / SourceFiles / mtproto / core_types . h <nl> For license and copyright information please follow this link : <nl> # include < QtCore / QByteArray > <nl> # include < rpl / details / callable . h > <nl> # include " core / basic_types . h " <nl> + # include " base / match_method . h " <nl> # include " base / flags . h " <nl> # include " base / bytes . h " <nl> # include " base / algorithm . h " <nl> class TypeDataOwner { <nl> template < typename DataType > <nl> const DataType & queryData ( ) const { <nl> Expects ( _data ! = nullptr ) ; <nl> - return static_cast < const DataType & > ( * _data ) ; <nl> - } <nl> <nl> - template < typename Data , typename Callback , typename . . . Callbacks > <nl> - static decltype ( auto ) VisitData ( <nl> - const Data & data , <nl> - Callback & & callback , <nl> - Callbacks & & . . . callbacks ) { <nl> - if constexpr ( rpl : : details : : is_callable_plain_v < Callback , Data > ) { <nl> - return std : : forward < Callback > ( callback ) ( data ) ; <nl> - } else { <nl> - return VisitData ( data , std : : forward < Callbacks > ( callbacks ) . . . ) ; <nl> - } <nl> + return static_cast < const DataType & > ( * _data ) ; <nl> } <nl> <nl> private : <nl> mmm a / Telegram / SourceFiles / rpl / combine . h <nl> ppp b / Telegram / SourceFiles / rpl / combine . h <nl> For license and copyright information please follow this link : <nl> # pragma once <nl> <nl> # include " base / optional . h " <nl> + # include " base / variant . h " <nl> # include < rpl / map . h > <nl> # include < rpl / producer . h > <nl> # include < rpl / details / type_list . h > <nl> template < <nl> class combine_implementation_helper < producer < Values , Errors , Generators > . . . > { <nl> public : <nl> using CombinedValue = std : : tuple < Values . . . > ; <nl> - using CombinedError = normalized_variant_t < Errors . . . > ; <nl> + using CombinedError = base : : normalized_variant_t < Errors . . . > ; <nl> <nl> combine_implementation_helper ( <nl> producer < Values , Errors , Generators > & & . . . producers ) <nl> template < <nl> inline auto combine_implementation ( <nl> producer < Values , Errors , Generators > & & . . . producers ) { <nl> using CombinedValue = std : : tuple < Values . . . > ; <nl> - using CombinedError = normalized_variant_t < Errors . . . > ; <nl> + using CombinedError = base : : normalized_variant_t < Errors . . . > ; <nl> <nl> return make_producer < CombinedValue , CombinedError > ( <nl> make_combine_implementation_helper ( std : : move ( producers ) . . . ) ) ; <nl> mmm a / Telegram / SourceFiles / rpl / details / type_list . h <nl> ppp b / Telegram / SourceFiles / rpl / details / type_list . h <nl> For license and copyright information please follow this link : <nl> # pragma once <nl> <nl> # include < type_traits > <nl> - # include " base / variant . h " <nl> <nl> namespace rpl { <nl> namespace details { <nl> struct extract_to < list < Types . . . > , To > { <nl> } ; <nl> <nl> } / / namespace type_list <nl> - <nl> - template < typename . . . Types > <nl> - struct normalized_variant { <nl> - using list = type_list : : list < Types . . . > ; <nl> - using distinct = type_list : : distinct_t < list > ; <nl> - using type = std : : conditional_t < <nl> - type_list : : size_v < distinct > = = 1 , <nl> - type_list : : get_t < 0 , distinct > , <nl> - type_list : : extract_to_t < distinct , base : : variant > > ; <nl> - } ; <nl> - <nl> - template < typename . . . Types > <nl> - using normalized_variant_t <nl> - = typename normalized_variant < Types . . . > : : type ; <nl> - <nl> } / / namespace details <nl> } / / namespace rpl <nl> mmm a / Telegram / gyp / telegram_sources . txt <nl> ppp b / Telegram / gyp / telegram_sources . txt <nl> <nl> < ( src_loc ) / base / flat_set . h <nl> < ( src_loc ) / base / functors . h <nl> < ( src_loc ) / base / index_based_iterator . h <nl> + < ( src_loc ) / base / match_method . h <nl> < ( src_loc ) / base / observer . cpp <nl> < ( src_loc ) / base / observer . h <nl> < ( src_loc ) / base / ordered_set . h <nl>
Export chat messages photos and documents .
telegramdesktop/tdesktop
83786ddeaf2d52aa4f2cfd38b31d3df9304d63a6
2018-06-13T22:09:48Z
mmm a / PowerEditor / installer / themes / Bespin . xml <nl> ppp b / PowerEditor / installer / themes / Bespin . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " FFAA00 " bgColor = " 2A211C " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 1E9AE0 " bgColor = " 2A211C " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 1E9AE0 " bgColor = " 2A211C " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 1E9AE0 " bgColor = " 2A211C " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " BDAE9D " bgColor = " 2A211C " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> diff - - git a / PowerEditor / installer / themes / Black board . xml b / PowerEditor / installer / themes / Black board . xml <nl> mmm a / PowerEditor / installer / themes / Black board . xml <nl> ppp b / PowerEditor / installer / themes / Black board . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " FBDE2D " bgColor = " 0C1021 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " AEAEAE " bgColor = " 0C1021 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " AEAEAE " bgColor = " 0C1021 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " AEAEAE " bgColor = " 0C1021 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " F8F8F8 " bgColor = " 0C1021 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> mmm a / PowerEditor / installer / themes / Choco . xml <nl> ppp b / PowerEditor / installer / themes / Choco . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " B3935C " bgColor = " 1A0F0B " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 679D47 " bgColor = " 1A0F0B " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 679D47 " bgColor = " 1A0F0B " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 679D47 " bgColor = " 1A0F0B " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " C3BE98 " bgColor = " 1A0F0B " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> diff - - git a / PowerEditor / installer / themes / Deep Black . xml b / PowerEditor / installer / themes / Deep Black . xml <nl> mmm a / PowerEditor / installer / themes / Deep Black . xml <nl> ppp b / PowerEditor / installer / themes / Deep Black . xml <nl> http : / / sourceforge . net / donate / index . php ? group_id = 95717 <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " FF8000 " bgColor = " 000000 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 00FF00 " bgColor = " 000000 " fontName = " " fontStyle = " 2 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 00FF00 " bgColor = " 000000 " fontName = " " fontStyle = " 2 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 00FF00 " bgColor = " 000000 " fontName = " " fontStyle = " 2 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " FFFFFF " bgColor = " 000000 " fontName = " " fontStyle = " 1 " fontSize = " " / > <nl> diff - - git a / PowerEditor / installer / themes / Hello Kitty . xml b / PowerEditor / installer / themes / Hello Kitty . xml <nl> mmm a / PowerEditor / installer / themes / Hello Kitty . xml <nl> ppp b / PowerEditor / installer / themes / Hello Kitty . xml <nl> so your enhanced file can be included in Notepad + + future release . <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " 000080 " bgColor = " FFB0FF " fontName = " " fontStyle = " 1 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 008000 " bgColor = " FFB0FF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 008000 " bgColor = " FFB0FF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 008000 " bgColor = " FFB0FF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " tcl " desc = " TCL " ext = " " > <nl> < WordsStyle name = " PREPROCESSOR " styleID = " 9 " fgColor = " 804000 " bgColor = " FFB0FF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> diff - - git a / PowerEditor / installer / themes / Mono Industrial . xml b / PowerEditor / installer / themes / Mono Industrial . xml <nl> mmm a / PowerEditor / installer / themes / Mono Industrial . xml <nl> ppp b / PowerEditor / installer / themes / Mono Industrial . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " A8B3AB " bgColor = " 222C28 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 666C68 " bgColor = " 222C28 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 666C68 " bgColor = " 222C28 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 666C68 " bgColor = " 222C28 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " FFFFFF " bgColor = " 222C28 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> mmm a / PowerEditor / installer / themes / Monokai . xml <nl> ppp b / PowerEditor / installer / themes / Monokai . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " F92672 " bgColor = " 272822 " fontName = " " fontStyle = " " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 75715E " bgColor = " 272822 " fontName = " " fontStyle = " " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 75715E " bgColor = " 272822 " fontName = " " fontStyle = " " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 75715E " bgColor = " 272822 " fontName = " " fontStyle = " " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " F8F8F2 " bgColor = " 272822 " fontName = " " fontStyle = " " fontSize = " 10 " / > <nl> mmm a / PowerEditor / installer / themes / Obsidian . xml <nl> ppp b / PowerEditor / installer / themes / Obsidian . xml <nl> Notepad + + Custom Style <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " E8E2B7 " bgColor = " 293134 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 66747B " bgColor = " 293134 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 66747B " bgColor = " 293134 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 66747B " bgColor = " 293134 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " tcl " desc = " TCL " ext = " " > <nl> < WordsStyle name = " PREPROCESSOR " styleID = " 9 " fgColor = " A082BD " bgColor = " 293134 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> diff - - git a / PowerEditor / installer / themes / Plastic Code Wrap . xml b / PowerEditor / installer / themes / Plastic Code Wrap . xml <nl> mmm a / PowerEditor / installer / themes / Plastic Code Wrap . xml <nl> ppp b / PowerEditor / installer / themes / Plastic Code Wrap . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " FFAA00 " bgColor = " 0B161D " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 1E9AE0 " bgColor = " 0B161D " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 1E9AE0 " bgColor = " 0B161D " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 1E9AE0 " bgColor = " 0B161D " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " F8F8F8 " bgColor = " 0B161D " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> diff - - git a / PowerEditor / installer / themes / Ruby Blue . xml b / PowerEditor / installer / themes / Ruby Blue . xml <nl> mmm a / PowerEditor / installer / themes / Ruby Blue . xml <nl> ppp b / PowerEditor / installer / themes / Ruby Blue . xml <nl> http : / / sourceforge . net / donate / index . php ? group_id = 95717 <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " F08047 " bgColor = " 112435 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 3A8BDA " bgColor = " 112435 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 3A8BDA " bgColor = " 112435 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 3A8BDA " bgColor = " 112435 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " FFFFFF " bgColor = " 112435 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> mmm a / PowerEditor / installer / themes / Twilight . xml <nl> ppp b / PowerEditor / installer / themes / Twilight . xml <nl> Credits : <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " CDA869 " bgColor = " 141414 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 5F5A60 " bgColor = " 141414 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 5F5A60 " bgColor = " 141414 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 5F5A60 " bgColor = " 141414 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " F8F8F8 " bgColor = " 141414 " fontName = " " fontStyle = " 0 " fontSize = " 10 " / > <nl> diff - - git a / PowerEditor / installer / themes / Vibrant Ink . xml b / PowerEditor / installer / themes / Vibrant Ink . xml <nl> mmm a / PowerEditor / installer / themes / Vibrant Ink . xml <nl> ppp b / PowerEditor / installer / themes / Vibrant Ink . xml <nl> http : / / sourceforge . net / donate / index . php ? group_id = 95717 <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " FFCC00 " bgColor = " 000000 " fontName = " " fontStyle = " 1 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 9933CC " bgColor = " 000000 " fontName = " " fontStyle = " 0 " fontSize = " 8 " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 9933CC " bgColor = " 000000 " fontName = " " fontStyle = " 0 " fontSize = " 8 " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 9933CC " bgColor = " 000000 " fontName = " " fontStyle = " 0 " fontSize = " 8 " / > <nl> < / LexerType > <nl> < LexerType name = " html " desc = " HTML " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " FFFFFF " bgColor = " 000000 " fontName = " " fontStyle = " 1 " fontSize = " " / > <nl> mmm a / PowerEditor / installer / themes / Zenburn . xml <nl> ppp b / PowerEditor / installer / themes / Zenburn . xml <nl> License : Feel free to modify this style and re - release it . This styl <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " 9F9D6D " bgColor = " 3F3F3F " fontName = " " fontStyle = " 1 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 7F9F7F " bgColor = " 3F3F3F " fontName = " " fontStyle = " 3 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 7F9F7F " bgColor = " 3F3F3F " fontName = " " fontStyle = " 3 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 7F9F7F " bgColor = " 3F3F3F " fontName = " " fontStyle = " 3 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " tcl " desc = " TCL " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " DCDCCC " bgColor = " 3F3F3F " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> diff - - git a / PowerEditor / installer / themes / vim Dark Blue . xml b / PowerEditor / installer / themes / vim Dark Blue . xml <nl> mmm a / PowerEditor / installer / themes / vim Dark Blue . xml <nl> ppp b / PowerEditor / installer / themes / vim Dark Blue . xml <nl> <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " FFFFFF " bgColor = " 000040 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 80A0FF " bgColor = " 000040 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 80A0FF " bgColor = " 000040 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 80A0FF " bgColor = " 000040 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " tcl " desc = " TCL " ext = " " > <nl> < WordsStyle name = " PREPROCESSOR " styleID = " 9 " fgColor = " 804000 " bgColor = " 000040 " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> mmm a / PowerEditor / src / stylers . model . xml <nl> ppp b / PowerEditor / src / stylers . model . xml <nl> <nl> < WordsStyle name = " OPERATOR " styleID = " 10 " fgColor = " 000080 " bgColor = " FFFFFF " fontName = " " fontStyle = " 1 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT " styleID = " 1 " fgColor = " 008000 " bgColor = " FFFFFF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < WordsStyle name = " COMMENT LINE " styleID = " 2 " fgColor = " 008000 " bgColor = " FFFFFF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> + < WordsStyle name = " COMMENT DOC " styleID = " 3 " fgColor = " 008000 " bgColor = " FFFFFF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl> < / LexerType > <nl> < LexerType name = " srec " desc = " S - Record " ext = " " > <nl> < WordsStyle name = " DEFAULT " styleID = " 0 " fgColor = " 000000 " bgColor = " FFFFFF " fontName = " " fontStyle = " 0 " fontSize = " " / > <nl>
Add comment doc style to SQL lexer
notepad-plus-plus/notepad-plus-plus
c9e5b0b1e36acabf46479b58854c996acf9a15ff
2019-05-24T15:59:52Z
mmm a / tensorflow / contrib / __init__ . py <nl> ppp b / tensorflow / contrib / __init__ . py <nl> <nl> # Add projects here , they will show up under tf . contrib . <nl> from tensorflow . contrib import bayesflow <nl> from tensorflow . contrib import cloud <nl> + from tensorflow . contrib import cluster_resolver <nl> from tensorflow . contrib import compiler <nl> from tensorflow . contrib import copy_graph <nl> from tensorflow . contrib import crf <nl>
This adds the cluster_resolver module to contrib / __init__ . py so that it is actually visible to open source TensorFlow users .
tensorflow/tensorflow
e17650b69853d2f5706a51ac775375100408abb3
2017-07-30T22:43:18Z
mmm a / lib / IDE / Formatting . cpp <nl> ppp b / lib / IDE / Formatting . cpp <nl> class ListAligner { <nl> SourceLoc AlignLoc ; <nl> SourceLoc LastEndLoc ; <nl> bool HasOutdent = false ; <nl> + bool BreakAlignment = false ; <nl> <nl> public : <nl> <nl> + / / / Don ' t column - align if any element starts on the same line as IntroducerLoc <nl> + / / / but ends on a later line . <nl> + bool BreakAlignmentIfSpanning = false ; <nl> + <nl> / / / Constructs a new \ c ListAligner for a list bounded by separate opening and <nl> / / / closing tokens , e . g . tuples , array literals , parameter lists , etc . <nl> / / / <nl> class ListAligner { <nl> assert ( Range . isValid ( ) ) ; <nl> LastEndLoc = Range . End ; <nl> <nl> - HasOutdent | = isOnSameLine ( SM , IntroducerLoc , Range . Start ) & & <nl> - OutdentChecker : : hasOutdent ( SM , Range , WalkableParent ) ; <nl> + if ( isOnSameLine ( SM , IntroducerLoc , Range . Start ) ) { <nl> + HasOutdent | = OutdentChecker : : hasOutdent ( SM , Range , WalkableParent ) ; <nl> + if ( BreakAlignmentIfSpanning ) <nl> + BreakAlignment | = ! isOnSameLine ( SM , IntroducerLoc , Range . End ) ; <nl> + } <nl> <nl> if ( HasOutdent | | ! SM . isBeforeInBuffer ( Range . Start , TargetLoc ) ) <nl> return ; <nl> class ListAligner { <nl> } <nl> <nl> bool ShouldIndent = shouldIndent ( HasTrailingComma , TargetIsTrailing ) ; <nl> - if ( ShouldIndent & & AlignLoc . isValid ( ) ) { <nl> + if ( ShouldIndent & & ! BreakAlignment & & AlignLoc . isValid ( ) ) { <nl> setAlignmentIfNeeded ( Override ) ; <nl> return IndentContext { AlignLoc , false , IndentContext : : Exact } ; <nl> } <nl> class ListAligner { <nl> / / / This should be called before returning an \ c IndentContext for a subrange <nl> / / / of the list . <nl> void setAlignmentIfNeeded ( ContextOverride & Override ) { <nl> - if ( HasOutdent | | AlignLoc . isInvalid ( ) ) <nl> + if ( HasOutdent | | BreakAlignment | | AlignLoc . isInvalid ( ) ) <nl> return ; <nl> Override . setExact ( SM , AlignLoc ) ; <nl> } <nl> class FormatWalker : public ASTWalker { <nl> SourceLoc ContextLoc = PBD - > getStartLoc ( ) , IntroducerLoc = PBD - > getLoc ( ) ; <nl> <nl> ListAligner Aligner ( SM , TargetLocation , ContextLoc , IntroducerLoc ) ; <nl> + <nl> + / / Don ' t column align PBD entries if any entry spans from the same line as <nl> + / / the IntroducerLoc ( var / let ) to another line . E . g . <nl> + / / <nl> + / / let foo = someItem <nl> + / / . getValue ( ) , / / Column - alignment looks ok here , but . . . <nl> + / / bar = otherItem <nl> + / / . getValue ( ) <nl> + / / <nl> + / / getAThing ( ) <nl> + / / . andDoStuffWithIt ( ) <nl> + / / let foo = someItem <nl> + / / . getValue ( ) / / looks over - indented here , which is more common . . . <nl> + / / getOtherThing ( ) <nl> + / / . andDoStuffWithIt ( ) <nl> + / / <nl> + / / getAThing ( ) <nl> + / / . andDoStuffWithIt ( ) <nl> + / / let foo = someItem <nl> + / / . getValue ( ) / / so break column alignment in this case . . . <nl> + / / doOtherThing ( ) <nl> + / / <nl> + / / let foo = someItem . getValue ( ) , <nl> + / / bar = otherItem . getValue ( ) / / but not in this case . <nl> + / / <nl> + / / Using this rule , rather than handling single and multi - entry PBDs <nl> + / / differently , ensures that the as - typed - out indentation matches the <nl> + / / re - indented indentation for multi - entry PBDs . <nl> + Aligner . BreakAlignmentIfSpanning = true ; <nl> + <nl> for ( auto I : range ( PBD - > getNumPatternEntries ( ) ) ) { <nl> SourceRange EntryRange = PBD - > getEqualLoc ( I ) ; <nl> VarDecl * SingleVar = nullptr ; <nl> mmm a / test / SourceKit / CodeFormat / indent - multiline - string . swift <nl> ppp b / test / SourceKit / CodeFormat / indent - multiline - string . swift <nl> this is line1 , <nl> / / CHECK : key . sourcetext : " this is line1 , " <nl> / / CHECK : key . sourcetext : " this is line2 , " <nl> / / CHECK : key . sourcetext : " \ " \ " \ " " <nl> - / / CHECK : key . sourcetext : " \ " content \ " " <nl> + / / CHECK : key . sourcetext : " \ " content \ " " <nl> mmm a / test / SourceKit / CodeFormat / rdar_32789463 . swift <nl> ppp b / test / SourceKit / CodeFormat / rdar_32789463 . swift <nl> $ <nl> <nl> / / CHECK : key . sourcetext : " struct $ { " <nl> / / CHECK : key . sourcetext : " let $ : < # Type # > " <nl> - / / CHECK : key . sourcetext : " = foo ( \ " foo \ \ ( $ ) bar \ " ) { " <nl> + / / CHECK : key . sourcetext : " = foo ( \ " foo \ \ ( $ ) bar \ " ) { " <nl> / / CHECK : key . sourcetext : " $ " <nl> mmm a / test / swift - indent / basic . swift <nl> ppp b / test / swift - indent / basic . swift <nl> test ( arg1 : 1 , <nl> } <nl> <nl> let x = [ 1 , 2 , 3 ] <nl> - . filter { $ 0 < $ 1 } <nl> - . filter { $ 0 < $ 1 } <nl> - . filter { $ 0 < $ 1 } <nl> + . filter { $ 0 < $ 1 } <nl> + . filter { $ 0 < $ 1 } <nl> + . filter { $ 0 < $ 1 } <nl> <nl> bax ( 34949494949 ) <nl> . foo ( a : Int , <nl> if # available ( <nl> / / do the same . <nl> / / <nl> let _ = [ ] <nl> - . map { <nl> - f { <nl> - print ( ) <nl> - } ? ? 0 <nl> - } <nl> + . map { <nl> + f { <nl> + print ( ) <nl> + } ? ? 0 <nl> + } <nl> <nl> basename <nl> . foo ( a : Int , <nl> let arrayC = [ 2 ] <nl> let arrayD = [ 3 ] <nl> <nl> let array1 = <nl> - arrayA + <nl> - arrayB + <nl> - arrayC + <nl> - arrayD <nl> + arrayA + <nl> + arrayB + <nl> + arrayC + <nl> + arrayD <nl> <nl> array1 = <nl> arrayA + <nl> arrayC + <nl> arrayD <nl> <nl> let array2 = arrayA + <nl> - arrayB + <nl> - arrayC + <nl> - arrayD <nl> + arrayB + <nl> + arrayC + <nl> + arrayD <nl> <nl> <nl> / / Comments should not break exact alignment , and leading comments should be aligned , rather than the label . <nl> func foo ( <nl> ) { } <nl> <nl> var ( d , e ) : <nl> - ( Int , Int ) = ( 1 , 3 ) , <nl> + ( Int , Int ) = ( 1 , 3 ) , <nl> ( f , g ) : ( <nl> Int , <nl> Int <nl> catch MyErr . a ( let code , let message ) , <nl> { <nl> print ( " ahhh ! " ) <nl> } <nl> + <nl> + / / Pattern binding decls should only column - align if no element spans from the first line to beyond it . <nl> + <nl> + public let x = 10 , <nl> + y = 20 <nl> + <nl> + private var firstThing = 20 , <nl> + secondThing = item <nl> + . filter { } , <nl> + thirdThing = 42 <nl> + <nl> + public let myVar = itemWithALongName <nl> + . filter { $ 0 > = $ 1 & & $ 0 - $ 1 < 50 } <nl> + <nl> + public let first = 45 , second = itemWithALongName <nl> + . filter { $ 0 > = $ 1 & & $ 0 - $ 1 < 50 } <nl> + <nl> + private var secondThing = item <nl> + . filter { } , <nl> + firstThing = 20 , <nl> + thirdThing = 56 <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftEditor . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftEditor . cpp <nl> class PlaceholderExpansionScanner { <nl> <nl> struct ParamClosureInfo { <nl> Optional < ClosureInfo > placeholderClosure ; <nl> - bool isNonPlacholderClosure = false ; <nl> + bool isNonPlaceholderClosure = false ; <nl> bool isWrappedWithBraces = false ; <nl> } ; <nl> <nl> / / / Scan the given TupleExpr collecting parameter closure information and <nl> / / / returning the index of the given target placeholder ( if found ) . <nl> - Optional < unsigned > scanTupleExpr ( TupleExpr * TE , SourceLoc targetPlacholderLoc , <nl> + Optional < unsigned > scanTupleExpr ( TupleExpr * TE , SourceLoc targetPlaceholderLoc , <nl> std : : vector < ParamClosureInfo > & outParams ) { <nl> if ( TE - > getElements ( ) . empty ( ) ) <nl> return llvm : : None ; <nl> class PlaceholderExpansionScanner { <nl> outParams . clear ( ) ; <nl> outParams . reserve ( TE - > getNumElements ( ) ) ; <nl> <nl> - Optional < unsigned > targetPlacholderIndex ; <nl> + Optional < unsigned > targetPlaceholderIndex ; <nl> <nl> for ( Expr * E : TE - > getElements ( ) ) { <nl> outParams . emplace_back ( ) ; <nl> class PlaceholderExpansionScanner { <nl> if ( auto CE = dyn_cast < ClosureExpr > ( E ) ) { <nl> if ( CE - > hasSingleExpressionBody ( ) & & <nl> CE - > getSingleExpressionBody ( ) - > getStartLoc ( ) = = <nl> - targetPlacholderLoc ) { <nl> - targetPlacholderIndex = outParams . size ( ) - 1 ; <nl> + targetPlaceholderLoc ) { <nl> + targetPlaceholderIndex = outParams . size ( ) - 1 ; <nl> if ( auto * PHE = dyn_cast < EditorPlaceholderExpr > ( <nl> CE - > getSingleExpressionBody ( ) ) ) { <nl> outParam . isWrappedWithBraces = true ; <nl> class PlaceholderExpansionScanner { <nl> } <nl> } <nl> / / else . . . <nl> - outParam . isNonPlacholderClosure = true ; <nl> + outParam . isNonPlaceholderClosure = true ; <nl> continue ; <nl> } <nl> <nl> class PlaceholderExpansionScanner { <nl> if ( scanClosureType ( PHE , info ) ) <nl> outParam . placeholderClosure = info ; <nl> } else if ( containClosure ( E ) ) { <nl> - outParam . isNonPlacholderClosure = true ; <nl> + outParam . isNonPlaceholderClosure = true ; <nl> } <nl> <nl> - if ( E - > getStartLoc ( ) = = targetPlacholderLoc ) { <nl> - targetPlacholderIndex = outParams . size ( ) - 1 ; <nl> + if ( E - > getStartLoc ( ) = = targetPlaceholderLoc ) { <nl> + targetPlaceholderIndex = outParams . size ( ) - 1 ; <nl> } <nl> } <nl> <nl> - return targetPlacholderIndex ; <nl> + return targetPlaceholderIndex ; <nl> } <nl> <nl> public : <nl> class PlaceholderExpansionScanner { <nl> / / and if the call parens can be removed in that case . <nl> / / We ' ll first find the enclosing CallExpr , and then do further analysis . <nl> std : : vector < ParamClosureInfo > params ; <nl> - Optional < unsigned > targetPlacholderIndex ; <nl> + Optional < unsigned > targetPlaceholderIndex ; <nl> auto ECE = enclosingCallExprArg ( SF , PlaceholderStartLoc ) ; <nl> Expr * Args = ECE . first ; <nl> if ( Args & & ECE . second ) { <nl> if ( isa < ParenExpr > ( Args ) ) { <nl> params . emplace_back ( ) ; <nl> params . back ( ) . placeholderClosure = TargetClosureInfo ; <nl> - targetPlacholderIndex = 0 ; <nl> + targetPlaceholderIndex = 0 ; <nl> } else if ( auto * TE = dyn_cast < TupleExpr > ( Args ) ) { <nl> - targetPlacholderIndex = scanTupleExpr ( TE , PlaceholderStartLoc , params ) ; <nl> + targetPlaceholderIndex = scanTupleExpr ( TE , PlaceholderStartLoc , params ) ; <nl> } <nl> } <nl> <nl> / / If there was no appropriate parent call expression , it ' s non - trailing . <nl> - if ( ! targetPlacholderIndex . hasValue ( ) ) { <nl> + if ( ! targetPlaceholderIndex . hasValue ( ) ) { <nl> OneClosureCallback ( Args , / * useTrailingClosure = * / false , <nl> / * isWrappedWithBraces = * / false , TargetClosureInfo ) ; <nl> return true ; <nl> class PlaceholderExpansionScanner { <nl> / / Find the first parameter eligible to be trailing . <nl> while ( firstTrailingIndex ! = 0 ) { <nl> unsigned i = firstTrailingIndex - 1 ; <nl> - if ( params [ i ] . isNonPlacholderClosure | | <nl> + if ( params [ i ] . isNonPlaceholderClosure | | <nl> ! params [ i ] . placeholderClosure . hasValue ( ) ) <nl> break ; <nl> firstTrailingIndex = i ; <nl> } <nl> <nl> - if ( firstTrailingIndex > targetPlacholderIndex ) { <nl> + if ( firstTrailingIndex > targetPlaceholderIndex ) { <nl> / / Target comes before the eligible trailing closures . <nl> OneClosureCallback ( Args , / * isTrailing = * / false , <nl> - params [ * targetPlacholderIndex ] . isWrappedWithBraces , <nl> + params [ * targetPlaceholderIndex ] . isWrappedWithBraces , <nl> TargetClosureInfo ) ; <nl> return true ; <nl> - } else if ( targetPlacholderIndex = = end - 1 & & <nl> + } else if ( targetPlaceholderIndex = = end - 1 & & <nl> firstTrailingIndex = = end - 1 ) { <nl> / / Target is the only eligible trailing closure . <nl> OneClosureCallback ( Args , / * isTrailing = * / true , <nl> - params [ * targetPlacholderIndex ] . isWrappedWithBraces , <nl> + params [ * targetPlaceholderIndex ] . isWrappedWithBraces , <nl> TargetClosureInfo ) ; <nl> return true ; <nl> } <nl>
Merge remote - tracking branch ' origin / master ' into master - next
apple/swift
5d16b82996761ebd8e0d564b7ee24d69cf4bfea7
2020-05-22T00:59:18Z
mmm a / hphp / runtime / vm / jit / hhbctranslator . cpp <nl> ppp b / hphp / runtime / vm / jit / hhbctranslator . cpp <nl> void HhbcTranslator : : assertString ( const Location & loc , const StringData * str ) { <nl> * / <nl> RuntimeType HhbcTranslator : : rttFromLocation ( const Location & loc ) { <nl> Type t ; <nl> - SSATmp * val ; <nl> + SSATmp * val = nullptr ; <nl> switch ( loc . space ) { <nl> case Location : : Stack : { <nl> auto i = loc . offset ; <nl>
fix potentially uninitialized warning on other platforms
facebook/hhvm
779904e538d6dcb9156f9dc0fbea20260b691944
2013-06-27T17:49:59Z
mmm a / test / core / channel / channel_tracer_test . cc <nl> ppp b / test / core / channel / channel_tracer_test . cc <nl> static void validate_tracer_data_matches_uuid_lookup ( <nl> char * tracer_json_str = tracer - > RenderTrace ( true ) ; <nl> char * uuid_lookup_json_str = <nl> ChannelTracer : : GetChannelTraceFromUuid ( uuid , true ) ; <nl> - strcmp ( tracer_json_str , uuid_lookup_json_str ) ; <nl> + GPR_ASSERT ( strcmp ( tracer_json_str , uuid_lookup_json_str ) = = 0 ) ; <nl> gpr_free ( tracer_json_str ) ; <nl> gpr_free ( uuid_lookup_json_str ) ; <nl> } <nl>
Fix test compile
grpc/grpc
765cc955526092dc835dd7dce2cd9cb3d61746ad
2018-01-23T20:08:56Z
mmm a / modules / planning / common / planning_context . h <nl> ppp b / modules / planning / common / planning_context . h <nl> class PlanningContext { <nl> / / all traffic lights ahead , with signal info <nl> std : : unordered_map < std : : string , const apollo : : perception : : TrafficLight * > <nl> traffic_lights ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / scenario specific info , set up by ScenarioManager : : ScenarioDispatch ( ) <nl> - / / current traffic light ( vector ) <nl> - std : : vector < apollo : : hdmap : : PathOverlap > current_traffic_light_overlaps ; <nl> - <nl> - / / still in the scenario for this overlap , but stop already done <nl> - / / = > no stop fence from decider_rule_based_stop task <nl> - std : : vector < std : : string > stop_done_overlap_ids ; <nl> } ; <nl> <nl> / / @ brief a container logging the data required for non - scenario side pass <nl> mmm a / modules / planning / scenarios / scenario_manager . cc <nl> ppp b / modules / planning / scenarios / scenario_manager . cc <nl> void ScenarioManager : : UpdatePlanningContextStopSignScenario ( <nl> return ; <nl> } <nl> <nl> - / / set to first_encountered stop sign <nl> + / / set to first_encountered stop_sign <nl> const auto map_itr = <nl> first_encountered_overlap_map_ . find ( ReferenceLineInfo : : STOP_SIGN ) ; <nl> if ( map_itr ! = first_encountered_overlap_map_ . end ( ) ) { <nl> PlanningContext : : MutablePlanningStatus ( ) - > mutable_stop_sign ( ) <nl> - > set_current_stop_sign_overlap_id ( map_itr - > second . object_id ) ; <nl> - AERROR < < " Update PlanningContext with first_encountered stop sign [ " <nl> + ADEBUG < < " Update PlanningContext with first_encountered stop sign [ " <nl> < < map_itr - > second . object_id < < " ] start_s [ " <nl> < < map_itr - > second . start_s < < " ] " ; <nl> } <nl> void ScenarioManager : : UpdatePlanningContextStopSignScenario ( <nl> / / update : traffic_light ( s ) status in PlanningContext <nl> void ScenarioManager : : UpdatePlanningContextTrafficLightScenario ( <nl> const Frame & frame , const ScenarioConfig : : ScenarioType & scenario_type ) { <nl> - const auto & reference_line_info = frame . reference_line_info ( ) . front ( ) ; <nl> + if ( scenario_type = = current_scenario_ - > scenario_type ( ) ) { <nl> + return ; <nl> + } <nl> <nl> + / / get first_encountered traffic_light <nl> std : : string current_traffic_light_overlap_id ; <nl> - if ( scenario_type ! = current_scenario_ - > scenario_type ( ) ) { <nl> - const auto map_itr = <nl> - first_encountered_overlap_map_ . find ( ReferenceLineInfo : : SIGNAL ) ; <nl> - if ( map_itr ! = first_encountered_overlap_map_ . end ( ) ) { <nl> - current_traffic_light_overlap_id = map_itr - > second . object_id ; <nl> - } <nl> - } else { <nl> - / / refresh with current_traffic_light_overlaps <nl> - if ( ! PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . empty ( ) ) { <nl> - current_traffic_light_overlap_id = PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps [ 0 ] <nl> - . object_id ; <nl> - } <nl> + const auto map_itr = <nl> + first_encountered_overlap_map_ . find ( ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( map_itr ! = first_encountered_overlap_map_ . end ( ) ) { <nl> + current_traffic_light_overlap_id = map_itr - > second . object_id ; <nl> } <nl> <nl> if ( current_traffic_light_overlap_id . empty ( ) ) { <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps . clear ( ) ; <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) - > Clear ( ) ; <nl> return ; <nl> } <nl> <nl> / / find all the traffic light at / within the same location / group <nl> - / / and refresh the overlap info <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps . clear ( ) ; <nl> - <nl> + const auto & reference_line_info = frame . reference_line_info ( ) . front ( ) ; <nl> const std : : vector < PathOverlap > & traffic_light_overlaps = <nl> reference_line_info . reference_line ( ) . map_path ( ) . signal_overlaps ( ) ; <nl> auto traffic_light_overlap_itr = std : : find_if ( <nl> void ScenarioManager : : UpdatePlanningContextTrafficLightScenario ( <nl> [ & current_traffic_light_overlap_id ] ( const hdmap : : PathOverlap & overlap ) { <nl> return overlap . object_id = = current_traffic_light_overlap_id ; <nl> } ) ; <nl> - double current_traffic_light_overlap_start_s ; <nl> - if ( traffic_light_overlap_itr ! = traffic_light_overlaps . end ( ) ) { <nl> - current_traffic_light_overlap_start_s = traffic_light_overlap_itr - > start_s ; <nl> + if ( traffic_light_overlap_itr = = traffic_light_overlaps . end ( ) ) { <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) - > Clear ( ) ; <nl> + return ; <nl> } <nl> <nl> constexpr double kTrafficLightGroupingMaxDist = 2 . 0 ; / / unit : m <nl> + const double current_traffic_light_overlap_start_s = <nl> + traffic_light_overlap_itr - > start_s ; <nl> for ( const auto & traffic_light_overlap : traffic_light_overlaps ) { <nl> const double dist = <nl> traffic_light_overlap . start_s - current_traffic_light_overlap_start_s ; <nl> if ( fabs ( dist ) < = kTrafficLightGroupingMaxDist ) { <nl> - PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . push_back ( traffic_light_overlap ) ; <nl> - ADEBUG < < " traffic_light [ " < < traffic_light_overlap . object_id <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) <nl> + - > add_current_traffic_light_overlap_id ( <nl> + traffic_light_overlap . object_id ) ; <nl> + ADEBUG < < " Update PlanningContext with first_encountered traffic_light [ " <nl> + < < traffic_light_overlap . object_id <nl> < < " ] start_s [ " < < traffic_light_overlap . start_s < < " ] " ; <nl> } <nl> } <nl> mmm a / modules / planning / scenarios / traffic_light / protected / stage_approach . cc <nl> ppp b / modules / planning / scenarios / traffic_light / protected / stage_approach . cc <nl> <nl> # include " modules / planning / scenarios / traffic_light / protected / stage_approach . h " <nl> <nl> # include " cyber / common / log . h " <nl> + # include " modules / map / pnc_map / path . h " <nl> # include " modules / planning / common / frame . h " <nl> # include " modules / planning / common / planning_context . h " <nl> # include " modules / planning / common / util / util . h " <nl> namespace scenario { <nl> namespace traffic_light { <nl> <nl> using common : : TrajectoryPoint ; <nl> + using hdmap : : PathOverlap ; <nl> using perception : : TrafficLight ; <nl> <nl> Stage : : StageStatus TrafficLightProtectedStageApproach : : Process ( <nl> Stage : : StageStatus TrafficLightProtectedStageApproach : : Process ( <nl> AERROR < < " TrafficLightProtectedStop planning error " ; <nl> } <nl> <nl> + if ( GetContext ( ) - > current_traffic_light_overlap_ids . size ( ) = = 0 ) { <nl> + return FinishScenario ( ) ; <nl> + } <nl> + <nl> const auto & reference_line_info = frame - > reference_line_info ( ) . front ( ) ; <nl> <nl> bool traffic_light_all_done = true ; <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> + for ( const auto & traffic_light_overlap_id : <nl> + GetContext ( ) - > current_traffic_light_overlap_ids ) { <nl> / / check if the traffic_light is still along reference_line <nl> if ( planning : : util : : CheckTrafficLightOnReferenceLine ( <nl> - reference_line_info , traffic_light_overlap . object_id ) ) { <nl> + reference_line_info , traffic_light_overlap_id ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + / / refresh overlap along reference line <nl> + PathOverlap * current_traffic_light_overlap = <nl> + scenario : : util : : RefreshOverlapOnReferenceLine ( <nl> + reference_line_info , <nl> + traffic_light_overlap_id , <nl> + ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( ! current_traffic_light_overlap ) { <nl> continue ; <nl> } <nl> <nl> / / set right_of_way_status <nl> - reference_line_info . SetJunctionRightOfWay ( traffic_light_overlap . start_s , <nl> - false ) ; <nl> + reference_line_info . SetJunctionRightOfWay ( <nl> + current_traffic_light_overlap - > start_s , false ) ; <nl> <nl> const double adc_front_edge_s = reference_line_info . AdcSlBoundary ( ) . end_s ( ) ; <nl> const double distance_adc_to_stop_line = <nl> - traffic_light_overlap . start_s - adc_front_edge_s ; <nl> + current_traffic_light_overlap - > start_s - adc_front_edge_s ; <nl> auto signal_color = <nl> - scenario : : util : : GetSignal ( traffic_light_overlap . object_id ) . color ( ) ; <nl> - ADEBUG < < " traffic_light_overlap_id [ " < < traffic_light_overlap . object_id <nl> - < < " ] start_s [ " < < traffic_light_overlap . start_s <nl> + scenario : : util : : GetSignal ( traffic_light_overlap_id ) . color ( ) ; <nl> + ADEBUG < < " traffic_light_overlap_id [ " < < traffic_light_overlap_id <nl> + < < " ] start_s [ " < < current_traffic_light_overlap - > start_s <nl> < < " ] distance_adc_to_stop_line [ " < < distance_adc_to_stop_line <nl> < < " ] color [ " < < signal_color < < " ] " ; <nl> <nl> Stage : : StageStatus TrafficLightProtectedStageApproach : : Process ( <nl> } <nl> <nl> Stage : : StageStatus TrafficLightProtectedStageApproach : : FinishScenario ( ) { <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids . clear ( ) ; <nl> + PlanningContext : : MutablePlanningStatus ( ) - > clear_traffic_light ( ) ; <nl> <nl> next_stage_ = ScenarioConfig : : NO_STAGE ; <nl> return Stage : : FINISHED ; <nl> } <nl> <nl> Stage : : StageStatus TrafficLightProtectedStageApproach : : FinishStage ( ) { <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids . clear ( ) ; <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids . push_back ( <nl> - traffic_light_overlap . object_id ) ; <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) <nl> + - > mutable_done_traffic_light_overlap_id ( ) - > Clear ( ) ; <nl> + for ( const auto & traffic_light_overlap_id : <nl> + GetContext ( ) - > current_traffic_light_overlap_ids ) { <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) <nl> + - > add_done_traffic_light_overlap_id ( traffic_light_overlap_id ) ; <nl> } <nl> <nl> next_stage_ = ScenarioConfig : : TRAFFIC_LIGHT_PROTECTED_INTERSECTION_CRUISE ; <nl> mmm a / modules / planning / scenarios / traffic_light / protected / stage_intersection_cruise . cc <nl> ppp b / modules / planning / scenarios / traffic_light / protected / stage_intersection_cruise . cc <nl> <nl> # include " modules / planning / common / frame . h " <nl> # include " modules / planning / common / planning_context . h " <nl> # include " modules / planning / common / util / util . h " <nl> + # include " modules / planning / scenarios / util / util . h " <nl> <nl> namespace apollo { <nl> namespace planning { <nl> Stage : : StageStatus TrafficLightProtectedStageIntersectionCruise : : Process ( <nl> AERROR < < " TrafficLightProtectedStageIntersectionCruise plan error " ; <nl> } <nl> <nl> + if ( GetContext ( ) - > current_traffic_light_overlap_ids . size ( ) < = 0 ) { <nl> + return FinishStage ( ) ; <nl> + } <nl> + <nl> const auto & reference_line_info = frame - > reference_line_info ( ) . front ( ) ; <nl> <nl> - / / set right_of_way_status <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . size ( ) > 0 ) { <nl> - const double traffic_light_start_s = PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps [ 0 ] <nl> - . start_s ; <nl> - reference_line_info . SetJunctionRightOfWay ( traffic_light_start_s , true ) ; <nl> + / / refresh overlap along reference line <nl> + PathOverlap * current_traffic_light_overlap = <nl> + scenario : : util : : RefreshOverlapOnReferenceLine ( <nl> + reference_line_info , <nl> + GetContext ( ) - > current_traffic_light_overlap_ids [ 0 ] , <nl> + ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( ! current_traffic_light_overlap ) { <nl> + return FinishStage ( ) ; <nl> } <nl> <nl> + / / set right_of_way_status <nl> + reference_line_info . SetJunctionRightOfWay ( <nl> + current_traffic_light_overlap - > start_s , true ) ; <nl> + <nl> / / check pass pnc_junction <nl> / / TODO ( all ) : remove when pnc_junction completely available on map <nl> const auto & pnc_junction_overlaps = <nl> reference_line_info . reference_line ( ) . map_path ( ) . pnc_junction_overlaps ( ) ; <nl> if ( pnc_junction_overlaps . empty ( ) ) { <nl> / / pnc_junction not exist on map , use current traffic_light ' s end_s <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . empty ( ) ) { <nl> - return FinishStage ( ) ; <nl> - } <nl> - <nl> constexpr double kIntersectionPassDist = 20 . 0 ; / / unit : m <nl> const double adc_back_edge_s = <nl> reference_line_info . AdcSlBoundary ( ) . start_s ( ) ; <nl> - const double traffic_light_end_s = PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps [ 0 ] <nl> - . end_s ; <nl> const double distance_adc_pass_traffic_light = <nl> - adc_back_edge_s - traffic_light_end_s ; <nl> + adc_back_edge_s - current_traffic_light_overlap - > end_s ; <nl> ADEBUG < < " distance_adc_pass_traffic_light [ " <nl> < < distance_adc_pass_traffic_light < < " ] traffic_light_end_s [ " <nl> - < < traffic_light_end_s < < " ] " ; <nl> + < < current_traffic_light_overlap - > end_s < < " ] " ; <nl> <nl> if ( distance_adc_pass_traffic_light > = kIntersectionPassDist ) { <nl> return FinishStage ( ) ; <nl> Stage : : StageStatus TrafficLightProtectedStageIntersectionCruise : : Process ( <nl> } <nl> } <nl> <nl> - if ( ! util : : CheckInsidePnCJunction ( reference_line_info ) ) { <nl> + if ( ! planning : : util : : CheckInsidePnCJunction ( reference_line_info ) ) { <nl> return FinishStage ( ) ; <nl> } <nl> <nl> mmm a / modules / planning / scenarios / traffic_light / protected / traffic_light_protected_scenario . cc <nl> ppp b / modules / planning / scenarios / traffic_light / protected / traffic_light_protected_scenario . cc <nl> void TrafficLightProtectedScenario : : Init ( ) { <nl> return ; <nl> } <nl> <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . empty ( ) ) { <nl> + const auto & traffic_light_status = <nl> + PlanningContext : : Planningstatus ( ) . traffic_light ( ) ; <nl> + <nl> + if ( traffic_light_status . current_traffic_light_overlap_id_size ( ) = = 0 ) { <nl> AERROR < < " Could not find traffic - light ( s ) " ; <nl> return ; <nl> } <nl> <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> + context_ . current_traffic_light_overlap_ids . clear ( ) ; <nl> + for ( int i = 0 ; <nl> + i < traffic_light_status . current_traffic_light_overlap_id_size ( ) ; i + + ) { <nl> const std : : string traffic_light_overlap_id = <nl> - traffic_light_overlap . object_id ; <nl> + traffic_light_status . current_traffic_light_overlap_id ( i ) ; <nl> hdmap : : SignalInfoConstPtr traffic_light = <nl> HDMapUtil : : BaseMap ( ) . GetSignalById ( <nl> hdmap : : MakeMapId ( traffic_light_overlap_id ) ) ; <nl> if ( ! traffic_light ) { <nl> AERROR < < " Could not find traffic light : " < < traffic_light_overlap_id ; <nl> } <nl> + <nl> + context_ . current_traffic_light_overlap_ids . push_back ( <nl> + traffic_light_overlap_id ) ; <nl> } <nl> <nl> init_ = true ; <nl> mmm a / modules / planning / scenarios / traffic_light / protected / traffic_light_protected_scenario . h <nl> ppp b / modules / planning / scenarios / traffic_light / protected / traffic_light_protected_scenario . h <nl> <nl> <nl> # include < memory > <nl> # include < string > <nl> + # include < vector > <nl> <nl> # include " modules / planning / proto / planning . pb . h " <nl> <nl> namespace traffic_light { <nl> / / stage context <nl> struct TrafficLightProtectedContext { <nl> ScenarioTrafficLightProtectedConfig scenario_config ; <nl> + std : : vector < std : : string > current_traffic_light_overlap_ids ; <nl> } ; <nl> <nl> class TrafficLightProtectedScenario : public Scenario { <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_left_turn / traffic_light_unprotected_left_turn_scenario . cc <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_left_turn / traffic_light_unprotected_left_turn_scenario . cc <nl> void TrafficLightUnprotectedLeftTurnScenario : : Init ( ) { <nl> return ; <nl> } <nl> <nl> - / * TODO ( all ) : to be fixed <nl> - const std : : string traffic_light_overlap_id = <nl> - PlanningContext : : GetScenarioInfo ( ) - > next_traffic_light_overlap . object_id ; <nl> - if ( traffic_light_overlap_id . empty ( ) ) { <nl> + const auto & traffic_light_status = <nl> + PlanningContext : : Planningstatus ( ) . traffic_light ( ) ; <nl> + <nl> + if ( traffic_light_status . current_traffic_light_overlap_id_size ( ) = = 0 ) { <nl> + AERROR < < " Could not find traffic - light ( s ) " ; <nl> return ; <nl> } <nl> <nl> - hdmap : : SignalInfoConstPtr traffic_light = HDMapUtil : : BaseMap ( ) . GetSignalById ( <nl> - hdmap : : MakeMapId ( traffic_light_overlap_id ) ) ; <nl> - if ( ! traffic_light ) { <nl> - AERROR < < " Could not find traffic light : " < < traffic_light_overlap_id ; <nl> - return ; <nl> + context_ . current_traffic_light_overlap_ids . clear ( ) ; <nl> + for ( int i = 0 ; <nl> + i < traffic_light_status . current_traffic_light_overlap_id_size ( ) ; i + + ) { <nl> + const std : : string traffic_light_overlap_id = <nl> + traffic_light_status . current_traffic_light_overlap_id ( i ) ; <nl> + hdmap : : SignalInfoConstPtr traffic_light = <nl> + HDMapUtil : : BaseMap ( ) . GetSignalById ( <nl> + hdmap : : MakeMapId ( traffic_light_overlap_id ) ) ; <nl> + if ( ! traffic_light ) { <nl> + AERROR < < " Could not find traffic light : " < < traffic_light_overlap_id ; <nl> + } <nl> + <nl> + context_ . current_traffic_light_overlap_ids . push_back ( <nl> + traffic_light_overlap_id ) ; <nl> } <nl> - * / <nl> <nl> init_ = true ; <nl> } <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_left_turn / traffic_light_unprotected_left_turn_scenario . h <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_left_turn / traffic_light_unprotected_left_turn_scenario . h <nl> <nl> <nl> # include < memory > <nl> # include < string > <nl> + # include < vector > <nl> <nl> # include " modules / planning / proto / planning . pb . h " <nl> <nl> namespace traffic_light { <nl> / / stage context <nl> struct TrafficLightUnprotectedLeftTurnContext { <nl> ScenarioTrafficLightUnprotectedLeftTurnConfig scenario_config ; <nl> + std : : vector < std : : string > current_traffic_light_overlap_ids ; <nl> double stop_start_time = 0 . 0 ; <nl> double creep_start_time ; <nl> } ; <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_creep . cc <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_creep . cc <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageCreep : : Process ( <nl> AERROR < < " TrafficLightUnprotectedRightTurnStageCreep planning error " ; <nl> } <nl> <nl> - const auto & reference_line_info = frame - > reference_line_info ( ) . front ( ) ; <nl> - <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . empty ( ) ) { <nl> - return FinishStage ( ) ; <nl> + if ( GetContext ( ) - > current_traffic_light_overlap_ids . size ( ) = = 0 ) { <nl> + return FinishScenario ( ) ; <nl> } <nl> <nl> - PathOverlap traffic_light ; <nl> + const auto & reference_line_info = frame - > reference_line_info ( ) . front ( ) ; <nl> + <nl> + PathOverlap * traffic_light = nullptr ; <nl> bool traffic_light_all_green = true ; <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> + for ( const auto & traffic_light_overlap_id : <nl> + GetContext ( ) - > current_traffic_light_overlap_ids ) { <nl> / / check if the traffic_light is still along reference_line <nl> if ( planning : : util : : CheckTrafficLightOnReferenceLine ( <nl> - reference_line_info , traffic_light_overlap . object_id ) ) { <nl> + reference_line_info , traffic_light_overlap_id ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + / / refresh overlap along reference line <nl> + PathOverlap * current_traffic_light_overlap = <nl> + scenario : : util : : RefreshOverlapOnReferenceLine ( <nl> + reference_line_info , <nl> + traffic_light_overlap_id , <nl> + ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( ! current_traffic_light_overlap ) { <nl> continue ; <nl> } <nl> <nl> / / set right_of_way_status <nl> - reference_line_info . SetJunctionRightOfWay ( traffic_light_overlap . start_s , <nl> - false ) ; <nl> + reference_line_info . SetJunctionRightOfWay ( <nl> + current_traffic_light_overlap - > start_s , false ) ; <nl> <nl> auto signal_color = <nl> - scenario : : util : : GetSignal ( traffic_light_overlap . object_id ) . color ( ) ; <nl> - ADEBUG < < " traffic_light_overlap_id [ " < < traffic_light_overlap . object_id <nl> - < < " ] start_s [ " < < traffic_light_overlap . start_s < < " ] color [ " <nl> - < < signal_color < < " ] " ; <nl> + scenario : : util : : GetSignal ( traffic_light_overlap_id ) . color ( ) ; <nl> + ADEBUG < < " traffic_light_overlap_id [ " < < traffic_light_overlap_id <nl> + < < " ] start_s [ " < < current_traffic_light_overlap - > start_s <nl> + < < " ] color [ " < < signal_color < < " ] " ; <nl> <nl> / / check on traffic light color <nl> if ( signal_color ! = TrafficLight : : GREEN ) { <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageCreep : : Process ( <nl> break ; <nl> } <nl> <nl> - traffic_light = traffic_light_overlap ; <nl> + traffic_light = current_traffic_light_overlap ; <nl> } <nl> <nl> if ( traffic_light_all_green ) { <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageCreep : : Process ( <nl> const double timeout_sec = scenario_config_ . creep_timeout_sec ( ) ; <nl> auto * task = dynamic_cast < DeciderCreep * > ( FindTask ( TaskConfig : : DECIDER_CREEP ) ) ; <nl> if ( task & & <nl> - task - > CheckCreepDone ( * frame , reference_line_info , traffic_light . end_s , <nl> + task - > CheckCreepDone ( * frame , reference_line_info , traffic_light - > end_s , <nl> wait_time , timeout_sec ) ) { <nl> return FinishStage ( ) ; <nl> } <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageCreep : : Process ( <nl> return Stage : : RUNNING ; <nl> } <nl> <nl> + Stage : : StageStatus <nl> + TrafficLightUnprotectedRightTurnStageCreep : : FinishScenario ( ) { <nl> + PlanningContext : : MutablePlanningStatus ( ) - > clear_traffic_light ( ) ; <nl> + <nl> + next_stage_ = ScenarioConfig : : NO_STAGE ; <nl> + return Stage : : FINISHED ; <nl> + } <nl> + <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageCreep : : FinishStage ( ) { <nl> next_stage_ = <nl> ScenarioConfig : : TRAFFIC_LIGHT_UNPROTECTED_RIGHT_TURN_INTERSECTION_CRUISE ; <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_creep . h <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_creep . h <nl> class TrafficLightUnprotectedRightTurnStageCreep : public Stage { <nl> } <nl> <nl> private : <nl> + Stage : : StageStatus FinishScenario ( ) override ; <nl> Stage : : StageStatus FinishStage ( ) ; <nl> <nl> private : <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_intersection_cruise . cc <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_intersection_cruise . cc <nl> <nl> # include " modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_intersection_cruise . h " <nl> <nl> # include " cyber / common / log . h " <nl> + # include " modules / map / pnc_map / path . h " <nl> # include " modules / planning / common / frame . h " <nl> # include " modules / planning / common / planning_context . h " <nl> # include " modules / planning / common / util / util . h " <nl> + # include " modules / planning / scenarios / util / util . h " <nl> <nl> namespace apollo { <nl> namespace planning { <nl> namespace scenario { <nl> namespace traffic_light { <nl> <nl> using common : : TrajectoryPoint ; <nl> + using hdmap : : PathOverlap ; <nl> <nl> Stage : : StageStatus <nl> TrafficLightUnprotectedRightTurnStageIntersectionCruise : : Process ( <nl> TrafficLightUnprotectedRightTurnStageIntersectionCruise : : Process ( <nl> < < " plan error " ; <nl> } <nl> <nl> + if ( GetContext ( ) - > current_traffic_light_overlap_ids . size ( ) < = 0 ) { <nl> + return FinishStage ( ) ; <nl> + } <nl> + <nl> const auto & reference_line_info = frame - > reference_line_info ( ) . front ( ) ; <nl> <nl> - / / set right_of_way_status <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . size ( ) > 0 ) { <nl> - const double traffic_light_start_s = PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps [ 0 ] <nl> - . start_s ; <nl> - reference_line_info . SetJunctionRightOfWay ( traffic_light_start_s , true ) ; <nl> + / / refresh overlap along reference line <nl> + PathOverlap * current_traffic_light_overlap = <nl> + scenario : : util : : RefreshOverlapOnReferenceLine ( <nl> + reference_line_info , <nl> + GetContext ( ) - > current_traffic_light_overlap_ids [ 0 ] , <nl> + ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( ! current_traffic_light_overlap ) { <nl> + return FinishStage ( ) ; <nl> } <nl> <nl> + / / set right_of_way_status <nl> + reference_line_info . SetJunctionRightOfWay ( <nl> + current_traffic_light_overlap - > start_s , true ) ; <nl> + <nl> / / check pass pnc_junction <nl> / / TODO ( all ) : remove when pnc_junction completely available on map <nl> const auto & pnc_junction_overlaps = <nl> reference_line_info . reference_line ( ) . map_path ( ) . pnc_junction_overlaps ( ) ; <nl> if ( pnc_junction_overlaps . empty ( ) ) { <nl> / / pnc_junction not exist on map , use current traffic_light ' s end_s <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . empty ( ) ) { <nl> - return FinishStage ( ) ; <nl> - } <nl> - <nl> constexpr double kIntersectionPassDist = 20 . 0 ; / / unit : m <nl> const double adc_back_edge_s = <nl> reference_line_info . AdcSlBoundary ( ) . start_s ( ) ; <nl> - const double traffic_light_end_s = PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps [ 0 ] <nl> - . end_s ; <nl> const double distance_adc_pass_traffic_light = <nl> - adc_back_edge_s - traffic_light_end_s ; <nl> + adc_back_edge_s - current_traffic_light_overlap - > end_s ; <nl> ADEBUG < < " distance_adc_pass_traffic_light [ " <nl> < < distance_adc_pass_traffic_light < < " ] traffic_light_end_s [ " <nl> - < < traffic_light_end_s < < " ] " ; <nl> + < < current_traffic_light_overlap - > end_s < < " ] " ; <nl> <nl> if ( distance_adc_pass_traffic_light > = kIntersectionPassDist ) { <nl> return FinishStage ( ) ; <nl> TrafficLightUnprotectedRightTurnStageIntersectionCruise : : Process ( <nl> } <nl> } <nl> <nl> - if ( ! util : : CheckInsidePnCJunction ( reference_line_info ) ) { <nl> + if ( ! planning : : util : : CheckInsidePnCJunction ( reference_line_info ) ) { <nl> return FinishStage ( ) ; <nl> } <nl> <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_stop . cc <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_right_turn / stage_stop . cc <nl> <nl> <nl> # include " cyber / common / log . h " <nl> # include " modules / common / time / time . h " <nl> + # include " modules / map / pnc_map / path . h " <nl> # include " modules / planning / common / frame . h " <nl> # include " modules / planning / common / planning_context . h " <nl> # include " modules / planning / common / util / util . h " <nl> namespace traffic_light { <nl> <nl> using common : : TrajectoryPoint ; <nl> using common : : time : : Clock ; <nl> + using hdmap : : PathOverlap ; <nl> using perception : : TrafficLight ; <nl> <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageStop : : Process ( <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageStop : : Process ( <nl> AERROR < < " TrafficLightRightTurnUnprotectedStop planning error " ; <nl> } <nl> <nl> + if ( GetContext ( ) - > current_traffic_light_overlap_ids . size ( ) = = 0 ) { <nl> + return FinishScenario ( ) ; <nl> + } <nl> + <nl> const auto & reference_line_info = frame - > reference_line_info ( ) . front ( ) ; <nl> <nl> bool traffic_light_all_stop = true ; <nl> bool traffic_light_all_green = true ; <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> + <nl> + for ( const auto & traffic_light_overlap_id : <nl> + GetContext ( ) - > current_traffic_light_overlap_ids ) { <nl> / / check if the traffic_light is still along reference_line <nl> if ( planning : : util : : CheckTrafficLightOnReferenceLine ( <nl> - reference_line_info , traffic_light_overlap . object_id ) ) { <nl> + reference_line_info , traffic_light_overlap_id ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + / / refresh overlap along reference line <nl> + PathOverlap * current_traffic_light_overlap = <nl> + scenario : : util : : RefreshOverlapOnReferenceLine ( <nl> + reference_line_info , <nl> + traffic_light_overlap_id , <nl> + ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( ! current_traffic_light_overlap ) { <nl> continue ; <nl> } <nl> <nl> / / set right_of_way_status <nl> - reference_line_info . SetJunctionRightOfWay ( traffic_light_overlap . start_s , <nl> - false ) ; <nl> + reference_line_info . SetJunctionRightOfWay ( <nl> + current_traffic_light_overlap - > start_s , false ) ; <nl> <nl> const double adc_front_edge_s = reference_line_info . AdcSlBoundary ( ) . end_s ( ) ; <nl> const double distance_adc_to_stop_line = <nl> - traffic_light_overlap . start_s - adc_front_edge_s ; <nl> + current_traffic_light_overlap - > start_s - adc_front_edge_s ; <nl> auto signal_color = <nl> - scenario : : util : : GetSignal ( traffic_light_overlap . object_id ) . color ( ) ; <nl> - ADEBUG < < " traffic_light_overlap_id [ " < < traffic_light_overlap . object_id <nl> - < < " ] start_s [ " < < traffic_light_overlap . start_s <nl> + scenario : : util : : GetSignal ( traffic_light_overlap_id ) . color ( ) ; <nl> + ADEBUG < < " traffic_light_overlap_id [ " < < traffic_light_overlap_id <nl> + < < " ] start_s [ " < < current_traffic_light_overlap - > start_s <nl> < < " ] distance_adc_to_stop_line [ " < < distance_adc_to_stop_line <nl> < < " ] color [ " < < signal_color < < " ] " ; <nl> <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageStop : : Process ( <nl> } <nl> <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageStop : : FinishScenario ( ) { <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids . clear ( ) ; <nl> + PlanningContext : : MutablePlanningStatus ( ) - > clear_traffic_light ( ) ; <nl> <nl> next_stage_ = ScenarioConfig : : NO_STAGE ; <nl> return Stage : : FINISHED ; <nl> Stage : : StageStatus TrafficLightUnprotectedRightTurnStageStop : : FinishStage ( <nl> } else { <nl> / / creep <nl> / / update PlanningContext <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids . clear ( ) ; <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids . push_back ( <nl> - traffic_light_overlap . object_id ) ; <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) <nl> + - > mutable_done_traffic_light_overlap_id ( ) - > Clear ( ) ; <nl> + for ( const auto & traffic_light_overlap_id : <nl> + GetContext ( ) - > current_traffic_light_overlap_ids ) { <nl> + PlanningContext : : MutablePlanningStatus ( ) - > mutable_traffic_light ( ) <nl> + - > add_done_traffic_light_overlap_id ( traffic_light_overlap_id ) ; <nl> } <nl> <nl> GetContext ( ) - > creep_start_time = Clock : : NowInSeconds ( ) ; <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_right_turn / traffic_light_unprotected_right_turn_scenario . cc <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_right_turn / traffic_light_unprotected_right_turn_scenario . cc <nl> void TrafficLightUnprotectedRightTurnScenario : : Init ( ) { <nl> return ; <nl> } <nl> <nl> - if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . empty ( ) ) { <nl> + const auto & traffic_light_status = <nl> + PlanningContext : : Planningstatus ( ) . traffic_light ( ) ; <nl> + <nl> + if ( traffic_light_status . current_traffic_light_overlap_id_size ( ) = = 0 ) { <nl> AERROR < < " Could not find traffic - light ( s ) " ; <nl> return ; <nl> } <nl> <nl> - for ( const auto & traffic_light_overlap : <nl> - PlanningContext : : GetScenarioInfo ( ) - > current_traffic_light_overlaps ) { <nl> + context_ . current_traffic_light_overlap_ids . clear ( ) ; <nl> + for ( int i = 0 ; <nl> + i < traffic_light_status . current_traffic_light_overlap_id_size ( ) ; i + + ) { <nl> const std : : string traffic_light_overlap_id = <nl> - traffic_light_overlap . object_id ; <nl> + traffic_light_status . current_traffic_light_overlap_id ( i ) ; <nl> hdmap : : SignalInfoConstPtr traffic_light = <nl> HDMapUtil : : BaseMap ( ) . GetSignalById ( <nl> hdmap : : MakeMapId ( traffic_light_overlap_id ) ) ; <nl> if ( ! traffic_light ) { <nl> AERROR < < " Could not find traffic light : " < < traffic_light_overlap_id ; <nl> } <nl> + <nl> + context_ . current_traffic_light_overlap_ids . push_back ( <nl> + traffic_light_overlap_id ) ; <nl> } <nl> <nl> init_ = true ; <nl> mmm a / modules / planning / scenarios / traffic_light / unprotected_right_turn / traffic_light_unprotected_right_turn_scenario . h <nl> ppp b / modules / planning / scenarios / traffic_light / unprotected_right_turn / traffic_light_unprotected_right_turn_scenario . h <nl> <nl> <nl> # include < memory > <nl> # include < string > <nl> + # include < vector > <nl> <nl> # include " modules / planning / proto / planning . pb . h " <nl> <nl> namespace traffic_light { <nl> / / stage context <nl> struct TrafficLightUnprotectedRightTurnContext { <nl> ScenarioTrafficLightUnprotectedRightTurnConfig scenario_config ; <nl> + std : : vector < std : : string > current_traffic_light_overlap_ids ; <nl> double stop_start_time = 0 . 0 ; <nl> double creep_start_time = 0 . 0 ; <nl> } ; <nl> mmm a / modules / planning / tasks / deciders / decider_creep . cc <nl> ppp b / modules / planning / tasks / deciders / decider_creep . cc <nl> Status DeciderCreep : : Process ( Frame * frame , <nl> CHECK_NOTNULL ( reference_line_info ) ; <nl> <nl> double stop_line_s = 0 . 0 ; <nl> - std : : string stop_sign_overlap_id = <nl> + const std : : string stop_sign_overlap_id = <nl> PlanningContext : : Planningstatus ( ) . stop_sign ( ) <nl> . current_stop_sign_overlap_id ( ) ; <nl> if ( ! stop_sign_overlap_id . empty ( ) ) { <nl> Status DeciderCreep : : Process ( Frame * frame , <nl> if ( current_stop_sign_overlap ) { <nl> stop_line_s = current_stop_sign_overlap - > end_s ; <nl> } <nl> - } else if ( PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps . size ( ) > 0 ) { <nl> - stop_line_s = PlanningContext : : GetScenarioInfo ( ) <nl> - - > current_traffic_light_overlaps [ 0 ] <nl> - . end_s ; <nl> + } else if ( PlanningContext : : Planningstatus ( ) . traffic_light ( ) <nl> + . current_traffic_light_overlap_id_size ( ) > 0 ) { <nl> + / / refresh overlap along reference line <nl> + const std : : string current_traffic_light_overlap_id = <nl> + PlanningContext : : Planningstatus ( ) . traffic_light ( ) <nl> + . current_traffic_light_overlap_id ( 0 ) ; <nl> + PathOverlap * current_traffic_light_overlap = <nl> + scenario : : util : : RefreshOverlapOnReferenceLine ( <nl> + * reference_line_info , <nl> + current_traffic_light_overlap_id , <nl> + ReferenceLineInfo : : SIGNAL ) ; <nl> + if ( current_traffic_light_overlap ) { <nl> + stop_line_s = current_traffic_light_overlap - > end_s ; <nl> + } <nl> } <nl> if ( stop_line_s > 0 . 0 ) { <nl> BuildStopDecision ( stop_line_s , frame , reference_line_info ) ; <nl> mmm a / modules / planning / traffic_rules / traffic_light . cc <nl> ppp b / modules / planning / traffic_rules / traffic_light . cc <nl> void TrafficLight : : MakeDecisions ( Frame * const frame , <nl> return ; <nl> } <nl> <nl> - const double adc_front_edge_s = reference_line_info - > AdcSlBoundary ( ) . end_s ( ) ; <nl> - const double adc_back_edge_s = reference_line_info - > AdcSlBoundary ( ) . start_s ( ) ; <nl> + const auto & traffic_light_status = <nl> + PlanningContext : : Planningstatus ( ) . traffic_light ( ) ; <nl> + <nl> + const double adc_front_edge_s = <nl> + reference_line_info - > AdcSlBoundary ( ) . end_s ( ) ; <nl> + const double adc_back_edge_s = <nl> + reference_line_info - > AdcSlBoundary ( ) . start_s ( ) ; <nl> <nl> / / debug info <nl> planning_internal : : SignalLightDebug * signal_light_debug = <nl> void TrafficLight : : MakeDecisions ( Frame * const frame , <nl> continue ; <nl> } <nl> <nl> - const auto & stop_done_overlap_ids = <nl> - PlanningContext : : GetScenarioInfo ( ) - > stop_done_overlap_ids ; <nl> - if ( stop_done_overlap_ids . end ( ) ! = <nl> - std : : find ( stop_done_overlap_ids . begin ( ) , stop_done_overlap_ids . end ( ) , <nl> - traffic_light_overlap . object_id ) ) { <nl> + / / check if traffic - light - stop already finished , set by scenario / stage <nl> + bool traffic_light_done = false ; <nl> + for ( int i = 0 ; <nl> + i < traffic_light_status . done_traffic_light_overlap_id_size ( ) ; i + + ) { <nl> + if ( traffic_light_overlap . object_id = = <nl> + traffic_light_status . done_traffic_light_overlap_id ( i ) ) { <nl> + traffic_light_done = true ; <nl> + break ; <nl> + } <nl> + } <nl> + if ( traffic_light_done ) { <nl> continue ; <nl> } <nl> <nl>
planning : move traffic - light related status in PlanningContext into PlanningContext - > PlanningStatus ( ) - > traffic_light ( )
ApolloAuto/apollo
0fcb4d6dc50d9212dfb3ace0d606c4dd8d2bbf1a
2019-03-29T02:56:42Z
mmm a / include / swift / AST / TypeNodes . def <nl> ppp b / include / swift / AST / TypeNodes . def <nl> ABSTRACT_TYPE ( ReferenceStorage , Type ) <nl> ARTIFICIAL_TYPE ( UnmanagedStorage , ReferenceStorageType ) <nl> ARTIFICIAL_TYPE ( WeakStorage , ReferenceStorageType ) <nl> TYPE_RANGE ( ReferenceStorage , UnownedStorage , WeakStorage ) <nl> - ABSTRACT_TYPE ( Nominal , Type ) <nl> - TYPE ( Enum , NominalType ) <nl> - TYPE ( Struct , NominalType ) <nl> - TYPE ( Class , NominalType ) <nl> - TYPE ( Protocol , NominalType ) <nl> - TYPE_RANGE ( Nominal , Enum , Protocol ) <nl> + ABSTRACT_TYPE ( AnyGeneric , Type ) <nl> + ABSTRACT_TYPE ( NominalOrBoundGenericNominal , Type ) <nl> + ABSTRACT_TYPE ( Nominal , Type ) <nl> + TYPE ( Enum , NominalType ) <nl> + TYPE ( Struct , NominalType ) <nl> + TYPE ( Class , NominalType ) <nl> + TYPE ( Protocol , NominalType ) <nl> + TYPE_RANGE ( Nominal , Enum , Protocol ) <nl> + ABSTRACT_TYPE ( BoundGeneric , Type ) <nl> + TYPE ( BoundGenericClass , BoundGenericType ) <nl> + TYPE ( BoundGenericEnum , BoundGenericType ) <nl> + TYPE ( BoundGenericStruct , BoundGenericType ) <nl> + TYPE_RANGE ( BoundGeneric , BoundGenericClass , BoundGenericStruct ) <nl> + TYPE_RANGE ( NominalOrBoundGenericNominal , Enum , BoundGenericStruct ) <nl> + UNCHECKED_TYPE ( UnboundGeneric , Type ) <nl> + TYPE_RANGE ( AnyGeneric , Enum , UnboundGeneric ) <nl> ABSTRACT_TYPE ( AnyMetatype , Type ) <nl> TYPE ( Metatype , AnyMetatypeType ) <nl> TYPE ( ExistentialMetatype , AnyMetatypeType ) <nl> SUGARED_TYPE ( Dictionary , Type ) <nl> TYPE ( ProtocolComposition , Type ) <nl> TYPE ( LValue , Type ) <nl> TYPE ( InOut , Type ) <nl> - UNCHECKED_TYPE ( UnboundGeneric , Type ) <nl> - ABSTRACT_TYPE ( BoundGeneric , Type ) <nl> - TYPE ( BoundGenericClass , BoundGenericType ) <nl> - TYPE ( BoundGenericEnum , BoundGenericType ) <nl> - TYPE ( BoundGenericStruct , BoundGenericType ) <nl> - TYPE_RANGE ( BoundGeneric , BoundGenericClass , BoundGenericStruct ) <nl> UNCHECKED_TYPE ( TypeVariable , Type ) <nl> LAST_TYPE ( TypeVariable ) <nl> <nl> mmm a / include / swift / AST / Types . h <nl> ppp b / include / swift / AST / Types . h <nl> class alignas ( 1 < < TypeAlignInBits ) TypeBase { <nl> void * operator new ( size_t Bytes , void * Mem ) throw ( ) { return Mem ; } <nl> } ; <nl> <nl> + / / / AnyGenericType - This abstract class helps types ensure that fields <nl> + / / / exist at the same offset in memory to improve code generation of the <nl> + / / / compiler itself . <nl> + class AnyGenericType : public TypeBase { <nl> + friend class NominalOrBoundGenericNominalType ; <nl> + <nl> + / / / TheDecl - This is the TypeDecl which declares the given type . It <nl> + / / / specifies the name and other useful information about this type . <nl> + union { <nl> + GenericTypeDecl * GenDecl ; <nl> + NominalTypeDecl * NomDecl ; <nl> + } ; <nl> + <nl> + / / / \ brief The type of the parent , in which this type is nested . <nl> + Type Parent ; <nl> + <nl> + template < typename . . . Args > <nl> + AnyGenericType ( NominalTypeDecl * TheDecl , Type Parent , Args & & . . . args ) <nl> + : TypeBase ( std : : forward < Args > ( args ) . . . ) , NomDecl ( TheDecl ) , Parent ( Parent ) { } <nl> + <nl> + protected : <nl> + template < typename . . . Args > <nl> + AnyGenericType ( GenericTypeDecl * TheDecl , Type Parent , Args & & . . . args ) <nl> + : TypeBase ( std : : forward < Args > ( args ) . . . ) , GenDecl ( TheDecl ) , Parent ( Parent ) { } <nl> + <nl> + public : <nl> + <nl> + / / / \ brief Returns the declaration that declares this type . <nl> + GenericTypeDecl * getDecl ( ) const { return GenDecl ; } <nl> + <nl> + / / / \ brief Returns the type of the parent of this type . This will <nl> + / / / be null for top - level types or local types , and for non - generic types <nl> + / / / will simply be the same as the declared type of the declaration context <nl> + / / / of TheDecl . For types nested within generic types , however , this will <nl> + / / / involve \ c BoundGenericType nodes that provide context for the nested <nl> + / / / type , e . g . , the type Dictionary < String , Int > . ItemRange would be <nl> + / / / represented as a NominalType with Dictionary < String , Int > as its parent <nl> + / / / type . <nl> + Type getParent ( ) const { return Parent ; } <nl> + <nl> + / / Implement isa / cast / dyncast / etc . <nl> + static bool classof ( const TypeBase * T ) { <nl> + return T - > getKind ( ) > = TypeKind : : First_AnyGenericType & & <nl> + T - > getKind ( ) < = TypeKind : : Last_AnyGenericType ; <nl> + } <nl> + } ; <nl> + BEGIN_CAN_TYPE_WRAPPER ( AnyGenericType , Type ) <nl> + PROXY_CAN_TYPE_SIMPLE_GETTER ( getParent ) <nl> + END_CAN_TYPE_WRAPPER ( AnyGenericType , Type ) <nl> + <nl> + / / / NominalOrBoundGenericNominal - This abstract class helps types ensure that <nl> + / / / fields exist at the same offset in memory to improve code generation of the <nl> + / / / compiler itself . <nl> + class NominalOrBoundGenericNominalType : public AnyGenericType { <nl> + public : <nl> + template < typename . . . Args > <nl> + NominalOrBoundGenericNominalType ( Args & & . . . args ) <nl> + : AnyGenericType ( std : : forward < Args > ( args ) . . . ) { } <nl> + <nl> + / / / \ brief Returns the declaration that declares this type . <nl> + NominalTypeDecl * getDecl ( ) const { return NomDecl ; } <nl> + <nl> + / / Implement isa / cast / dyncast / etc . <nl> + static bool classof ( const TypeBase * T ) { <nl> + return T - > getKind ( ) > = TypeKind : : First_NominalOrBoundGenericNominalType & & <nl> + T - > getKind ( ) < = TypeKind : : Last_NominalOrBoundGenericNominalType ; <nl> + } <nl> + } ; <nl> + DEFINE_EMPTY_CAN_TYPE_WRAPPER ( NominalOrBoundGenericNominalType , AnyGenericType ) <nl> + <nl> / / / ErrorType - This represents a type that was erroneously constructed . This <nl> / / / is produced when parsing types and when name binding type aliases , and is <nl> / / / installed in declaration that use these erroneous types . All uses of a <nl> END_CAN_TYPE_WRAPPER ( TupleType , Type ) <nl> <nl> / / / UnboundGenericType - Represents a generic type where the type arguments have <nl> / / / not yet been resolved . <nl> - class UnboundGenericType : public TypeBase , public llvm : : FoldingSetNode { <nl> - GenericTypeDecl * TheDecl ; <nl> - <nl> - / / / \ brief The type of the parent , in which this type is nested . <nl> - Type Parent ; <nl> - <nl> + class UnboundGenericType : public AnyGenericType , <nl> + public llvm : : FoldingSetNode { <nl> private : <nl> UnboundGenericType ( GenericTypeDecl * TheDecl , Type Parent , const ASTContext & C , <nl> RecursiveTypeProperties properties ) <nl> - : TypeBase ( TypeKind : : UnboundGeneric , <nl> - ( ! Parent | | Parent - > isCanonical ( ) ) ? & C : nullptr , <nl> - properties | RecursiveTypeProperties : : HasUnboundGeneric ) , <nl> - TheDecl ( TheDecl ) , Parent ( Parent ) { } <nl> + : AnyGenericType ( TheDecl , Parent , TypeKind : : UnboundGeneric , <nl> + ( ! Parent | | Parent - > isCanonical ( ) ) ? & C : nullptr , <nl> + properties | RecursiveTypeProperties : : HasUnboundGeneric ) { } <nl> <nl> public : <nl> static UnboundGenericType * get ( GenericTypeDecl * TheDecl , Type Parent , <nl> const ASTContext & C ) ; <nl> <nl> - / / / \ brief Returns the declaration that declares this type . <nl> - GenericTypeDecl * getDecl ( ) const { return TheDecl ; } <nl> - <nl> - / / / \ brief Returns the type of the parent of this type . This will <nl> - / / / be null for top - level types or local types , and for non - generic types <nl> - / / / will simply be the same as the declared type of the declaration context <nl> - / / / of TheDecl . For types nested within generic types , however , this will <nl> - / / / involve \ c BoundGenericType nodes that provide context for the nested <nl> - / / / type , e . g . , the bound type Dictionary < String , Int > . Inner would be <nl> - / / / represented as an UnboundGenericType with Dictionary < String , Int > as its <nl> - / / / parent type . <nl> - Type getParent ( ) const { return Parent ; } <nl> - <nl> void Profile ( llvm : : FoldingSetNodeID & ID ) { <nl> Profile ( ID , getDecl ( ) , getParent ( ) ) ; <nl> } <nl> class UnboundGenericType : public TypeBase , public llvm : : FoldingSetNode { <nl> return T - > getKind ( ) = = TypeKind : : UnboundGeneric ; <nl> } <nl> } ; <nl> - BEGIN_CAN_TYPE_WRAPPER ( UnboundGenericType , Type ) <nl> - PROXY_CAN_TYPE_SIMPLE_GETTER ( getParent ) <nl> - END_CAN_TYPE_WRAPPER ( UnboundGenericType , Type ) <nl> + DEFINE_EMPTY_CAN_TYPE_WRAPPER ( UnboundGenericType , AnyGenericType ) <nl> <nl> inline CanType getAsCanType ( const Type & type ) { return CanType ( type ) ; } <nl> typedef ArrayRefView < Type , CanType , getAsCanType > CanTypeArrayRef ; <nl> <nl> / / / BoundGenericType - An abstract class for applying a generic type to the <nl> / / / given type arguments . <nl> - class BoundGenericType : public TypeBase , public llvm : : FoldingSetNode { <nl> - NominalTypeDecl * TheDecl ; <nl> - <nl> - / / / \ brief The type of the parent , in which this type is nested . <nl> - Type Parent ; <nl> + class BoundGenericType : public NominalOrBoundGenericNominalType , <nl> + public llvm : : FoldingSetNode { <nl> <nl> / / / Retrieve the intrusive pointer storage from the subtype <nl> const Type * getTrailingObjectsPointer ( ) const ; <nl> class BoundGenericType : public TypeBase , public llvm : : FoldingSetNode { <nl> static BoundGenericType * get ( NominalTypeDecl * TheDecl , Type Parent , <nl> ArrayRef < Type > GenericArgs ) ; <nl> <nl> - / / / \ brief Returns the declaration that declares this type . <nl> - NominalTypeDecl * getDecl ( ) const { return TheDecl ; } <nl> - <nl> - / / / \ brief Returns the type of the parent of this type . This will <nl> - / / / be null for top - level types or local types , and for non - generic types <nl> - / / / will simply be the same as the declared type of the declaration context <nl> - / / / of TheDecl . For types nested within generic types , however , this will <nl> - / / / involve \ c BoundGenericType nodes that provide context for the nested <nl> - / / / type , e . g . , the bound type Dictionary < String , Int > . Inner < Int > would be <nl> - / / / represented as a BoundGenericType with Dictionary < String , Int > as its <nl> - / / / parent type . <nl> - Type getParent ( ) const { return Parent ; } <nl> - <nl> / / / Retrieve the set of generic arguments provided at this level . <nl> ArrayRef < Type > getGenericArgs ( ) const { <nl> return { getTrailingObjectsPointer ( ) , Bits . BoundGenericType . GenericArgCount } ; <nl> } <nl> <nl> void Profile ( llvm : : FoldingSetNodeID & ID ) { <nl> - Profile ( ID , TheDecl , Parent , getGenericArgs ( ) ) ; <nl> + Profile ( ID , getDecl ( ) , getParent ( ) , getGenericArgs ( ) ) ; <nl> } <nl> static void Profile ( llvm : : FoldingSetNodeID & ID , NominalTypeDecl * TheDecl , <nl> Type Parent , ArrayRef < Type > GenericArgs ) ; <nl> class BoundGenericType : public TypeBase , public llvm : : FoldingSetNode { <nl> T - > getKind ( ) < = TypeKind : : Last_BoundGenericType ; <nl> } <nl> } ; <nl> - BEGIN_CAN_TYPE_WRAPPER ( BoundGenericType , Type ) <nl> - PROXY_CAN_TYPE_SIMPLE_GETTER ( getParent ) <nl> + BEGIN_CAN_TYPE_WRAPPER ( BoundGenericType , NominalOrBoundGenericNominalType ) <nl> CanTypeArrayRef getGenericArgs ( ) const { <nl> return CanTypeArrayRef ( getPointer ( ) - > getGenericArgs ( ) ) ; <nl> } <nl> - END_CAN_TYPE_WRAPPER ( BoundGenericType , Type ) <nl> + END_CAN_TYPE_WRAPPER ( BoundGenericType , NominalOrBoundGenericNominalType ) <nl> <nl> <nl> / / / BoundGenericClassType - A subclass of BoundGenericType for the case <nl> DEFINE_EMPTY_CAN_TYPE_WRAPPER ( BoundGenericStructType , BoundGenericType ) <nl> / / / NominalType - Represents a type with a name that is significant , such that <nl> / / / the name distinguishes it from other structurally - similar types that have <nl> / / / different names . Nominal types are always canonical . <nl> - class NominalType : public TypeBase { <nl> - / / / TheDecl - This is the TypeDecl which declares the given type . It <nl> - / / / specifies the name and other useful information about this type . <nl> - NominalTypeDecl * const TheDecl ; <nl> - <nl> - / / / \ brief The type of the parent , in which this type is nested . <nl> - Type Parent ; <nl> + class NominalType : public NominalOrBoundGenericNominalType { <nl> <nl> protected : <nl> NominalType ( TypeKind K , const ASTContext * C , NominalTypeDecl * TheDecl , <nl> Type Parent , RecursiveTypeProperties properties ) <nl> - : TypeBase ( K , ( ! Parent | | Parent - > isCanonical ( ) ) ? C : nullptr , <nl> - properties ) , <nl> - TheDecl ( TheDecl ) , Parent ( Parent ) { } <nl> + : NominalOrBoundGenericNominalType ( TheDecl , Parent , K , <nl> + ( ! Parent | | Parent - > isCanonical ( ) ) ? C : nullptr , properties ) { } <nl> <nl> public : <nl> static NominalType * get ( NominalTypeDecl * D , Type Parent , const ASTContext & C ) ; <nl> <nl> - / / / \ brief Returns the declaration that declares this type . <nl> - NominalTypeDecl * getDecl ( ) const { return TheDecl ; } <nl> - <nl> - / / / \ brief Returns the type of the parent of this type . This will <nl> - / / / be null for top - level types or local types , and for non - generic types <nl> - / / / will simply be the same as the declared type of the declaration context <nl> - / / / of TheDecl . For types nested within generic types , however , this will <nl> - / / / involve \ c BoundGenericType nodes that provide context for the nested <nl> - / / / type , e . g . , the type Dictionary < String , Int > . ItemRange would be <nl> - / / / represented as a NominalType with Dictionary < String , Int > as its parent <nl> - / / / type . <nl> - Type getParent ( ) const { return Parent ; } <nl> - <nl> / / Implement isa / cast / dyncast / etc . <nl> static bool classof ( const TypeBase * T ) { <nl> return T - > getKind ( ) > = TypeKind : : First_NominalType & & <nl> T - > getKind ( ) < = TypeKind : : Last_NominalType ; <nl> } <nl> } ; <nl> - BEGIN_CAN_TYPE_WRAPPER ( NominalType , Type ) <nl> - PROXY_CAN_TYPE_SIMPLE_GETTER ( getParent ) <nl> - END_CAN_TYPE_WRAPPER ( NominalType , Type ) <nl> + DEFINE_EMPTY_CAN_TYPE_WRAPPER ( NominalType , NominalOrBoundGenericNominalType ) <nl> <nl> / / / EnumType - This represents the type declared by an EnumDecl . <nl> class EnumType : public NominalType , public llvm : : FoldingSetNode { <nl> inline NominalTypeDecl * TypeBase : : getNominalOrBoundGenericNominal ( ) { <nl> } <nl> <nl> inline NominalTypeDecl * CanType : : getNominalOrBoundGenericNominal ( ) const { <nl> - if ( auto nomTy = dyn_cast < NominalType > ( * this ) ) <nl> - return nomTy - > getDecl ( ) ; <nl> - <nl> - if ( auto boundTy = dyn_cast < BoundGenericType > ( * this ) ) <nl> - return boundTy - > getDecl ( ) ; <nl> - <nl> + if ( auto Ty = dyn_cast < NominalOrBoundGenericNominalType > ( * this ) ) <nl> + return Ty - > getDecl ( ) ; <nl> return nullptr ; <nl> } <nl> <nl> inline NominalTypeDecl * TypeBase : : getAnyNominal ( ) { <nl> } <nl> <nl> inline Type TypeBase : : getNominalParent ( ) { <nl> - if ( auto classType = getAs < NominalType > ( ) ) { <nl> - return classType - > getParent ( ) ; <nl> - } else if ( auto unboundType = getAs < UnboundGenericType > ( ) ) { <nl> - return unboundType - > getParent ( ) ; <nl> - } else { <nl> - return castTo < BoundGenericType > ( ) - > getParent ( ) ; <nl> - } <nl> + return castTo < AnyGenericType > ( ) - > getParent ( ) ; <nl> } <nl> <nl> inline GenericTypeDecl * TypeBase : : getAnyGeneric ( ) { <nl> inline CanType CanType : : getWithoutSpecifierTypeImpl ( CanType type ) { <nl> } <nl> <nl> inline CanType CanType : : getNominalParent ( ) const { <nl> - if ( auto classType = dyn_cast < NominalType > ( * this ) ) { <nl> - return classType . getParent ( ) ; <nl> - } else { <nl> - return cast < BoundGenericType > ( * this ) . getParent ( ) ; <nl> - } <nl> + return cast < NominalOrBoundGenericNominalType > ( * this ) . getParent ( ) ; <nl> } <nl> <nl> inline Type TupleTypeElt : : getVarargBaseTy ( ) const { <nl> mmm a / lib / AST / ASTContext . cpp <nl> ppp b / lib / AST / ASTContext . cpp <nl> BoundGenericType : : BoundGenericType ( TypeKind theKind , <nl> ArrayRef < Type > genericArgs , <nl> const ASTContext * context , <nl> RecursiveTypeProperties properties ) <nl> - : TypeBase ( theKind , context , properties ) , <nl> - TheDecl ( theDecl ) , Parent ( parent ) <nl> - { <nl> + : NominalOrBoundGenericNominalType ( theDecl , parent , theKind , context , <nl> + properties ) { <nl> Bits . BoundGenericType . GenericArgCount = genericArgs . size ( ) ; <nl> / / Subtypes are required to provide storage for the generic arguments <nl> std : : uninitialized_copy ( genericArgs . begin ( ) , genericArgs . end ( ) , <nl> mmm a / lib / AST / Type . cpp <nl> ppp b / lib / AST / Type . cpp <nl> NominalTypeDecl * CanType : : getAnyNominal ( ) const { <nl> } <nl> <nl> GenericTypeDecl * CanType : : getAnyGeneric ( ) const { <nl> - if ( auto nominalTy = dyn_cast < NominalType > ( * this ) ) <nl> - return ( GenericTypeDecl * ) nominalTy - > getDecl ( ) ; <nl> - <nl> - if ( auto boundTy = dyn_cast < BoundGenericType > ( * this ) ) <nl> - return ( GenericTypeDecl * ) boundTy - > getDecl ( ) ; <nl> - <nl> - if ( auto unboundTy = dyn_cast < UnboundGenericType > ( * this ) ) <nl> - return unboundTy - > getDecl ( ) ; <nl> + if ( auto Ty = dyn_cast < AnyGenericType > ( * this ) ) <nl> + return Ty - > getDecl ( ) ; <nl> return nullptr ; <nl> } <nl> <nl> - <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / Various Type Methods . <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl>
Merge pull request from davezarzycki / nfc_refactor_typenode_hierarchy
apple/swift
07f5029df6a728b680751a235541b175761b824d
2018-01-02T17:27:36Z
mmm a / xbmc / network / upnp / UPnPServer . cpp <nl> ppp b / xbmc / network / upnp / UPnPServer . cpp <nl> CUPnPServer : : BuildResponse ( PLT_ActionReference & action , <nl> / / this isn ' t pretty but needed to properly hide the addons node from clients <nl> if ( StringUtils : : StartsWith ( items . GetPath ( ) , " library " ) ) { <nl> for ( int i = 0 ; i < items . Size ( ) ; i + + ) { <nl> - if ( StringUtils : : StartsWith ( items [ i ] - > GetPath ( ) , " addons " ) ) <nl> + if ( StringUtils : : StartsWith ( items [ i ] - > GetPath ( ) , " addons " ) | | <nl> + StringUtils : : EndsWith ( items [ i ] - > GetPath ( ) , " / addons . xml / " ) ) <nl> items . Remove ( i ) ; <nl> } <nl> } <nl>
[ upnp ] properly hide the addons node
xbmc/xbmc
e46a8f9b50eed246f741b69d501bae729a9f42dd
2014-05-17T23:52:06Z
mmm a / src / compiler / backend / instruction . cc <nl> ppp b / src / compiler / backend / instruction . cc <nl> std : : ostream & operator < < ( std : : ostream & os , <nl> const InstructionSequence * code = printable_block . code_ ; <nl> <nl> os < < " B " < < block - > rpo_number ( ) ; <nl> - os < < " : AO # " < < block - > ao_number ( ) ; <nl> + if ( block - > ao_number ( ) . IsValid ( ) ) { <nl> + os < < " : AO # " < < block - > ao_number ( ) ; <nl> + } else { <nl> + os < < " : AO # ? " ; <nl> + } <nl> if ( block - > IsDeferred ( ) ) os < < " ( deferred ) " ; <nl> if ( ! block - > needs_frame ( ) ) os < < " ( no frame ) " ; <nl> if ( block - > must_construct_frame ( ) ) os < < " ( construct frame ) " ; <nl> mmm a / src / compiler / backend / register - allocator . cc <nl> ppp b / src / compiler / backend / register - allocator . cc <nl> bool LiveRange : : ShouldBeAllocatedBefore ( const LiveRange * other ) const { <nl> return true ; <nl> } <nl> / / The other has a smaller hint . <nl> - if ( other - > controlflow_hint ( ) ! = kUnassignedRegister ) { <nl> + if ( controlflow_hint ( ) > other - > controlflow_hint ( ) ) { <nl> return false ; <nl> } <nl> - / / No hint , use first use position . <nl> + / / Both have the same hint or no hint at all . Use first use position . <nl> UsePosition * pos = first_pos ( ) ; <nl> UsePosition * other_pos = other - > first_pos ( ) ; <nl> / / To make the order total , handle the case where both positions are null . <nl> RegisterAllocationData : : RegisterAllocationData ( <nl> live_out_sets_ ( code - > InstructionBlockCount ( ) , nullptr , allocation_zone ( ) ) , <nl> live_ranges_ ( code - > VirtualRegisterCount ( ) * 2 , nullptr , <nl> allocation_zone ( ) ) , <nl> - fixed_live_ranges_ ( this - > config ( ) - > num_general_registers ( ) , nullptr , <nl> - allocation_zone ( ) ) , <nl> + fixed_live_ranges_ ( kNumberOfFixedRangesPerRegister * <nl> + this - > config ( ) - > num_general_registers ( ) , <nl> + nullptr , allocation_zone ( ) ) , <nl> fixed_float_live_ranges_ ( allocation_zone ( ) ) , <nl> - fixed_double_live_ranges_ ( this - > config ( ) - > num_double_registers ( ) , nullptr , <nl> - allocation_zone ( ) ) , <nl> + fixed_double_live_ranges_ ( kNumberOfFixedRangesPerRegister * <nl> + this - > config ( ) - > num_double_registers ( ) , <nl> + nullptr , allocation_zone ( ) ) , <nl> fixed_simd128_live_ranges_ ( allocation_zone ( ) ) , <nl> spill_ranges_ ( code - > VirtualRegisterCount ( ) , nullptr , allocation_zone ( ) ) , <nl> delayed_references_ ( allocation_zone ( ) ) , <nl> RegisterAllocationData : : RegisterAllocationData ( <nl> spill_state_ ( code - > InstructionBlockCount ( ) , ZoneVector < LiveRange * > ( zone ) , <nl> zone ) { <nl> if ( ! kSimpleFPAliasing ) { <nl> - fixed_float_live_ranges_ . resize ( this - > config ( ) - > num_float_registers ( ) , <nl> - nullptr ) ; <nl> - fixed_simd128_live_ranges_ . resize ( this - > config ( ) - > num_simd128_registers ( ) , <nl> - nullptr ) ; <nl> + fixed_float_live_ranges_ . resize ( <nl> + kNumberOfFixedRangesPerRegister * this - > config ( ) - > num_float_registers ( ) , <nl> + nullptr ) ; <nl> + fixed_simd128_live_ranges_ . resize ( <nl> + kNumberOfFixedRangesPerRegister * <nl> + this - > config ( ) - > num_simd128_registers ( ) , <nl> + nullptr ) ; <nl> } <nl> <nl> assigned_registers_ = new ( code_zone ( ) ) <nl> int LiveRangeBuilder : : FixedFPLiveRangeID ( int index , MachineRepresentation rep ) { <nl> int result = - index - 1 ; <nl> switch ( rep ) { <nl> case MachineRepresentation : : kSimd128 : <nl> - result - = config ( ) - > num_float_registers ( ) ; <nl> + result - = <nl> + kNumberOfFixedRangesPerRegister * config ( ) - > num_float_registers ( ) ; <nl> V8_FALLTHROUGH ; <nl> case MachineRepresentation : : kFloat32 : <nl> - result - = config ( ) - > num_double_registers ( ) ; <nl> + result - = <nl> + kNumberOfFixedRangesPerRegister * config ( ) - > num_double_registers ( ) ; <nl> V8_FALLTHROUGH ; <nl> case MachineRepresentation : : kFloat64 : <nl> - result - = config ( ) - > num_general_registers ( ) ; <nl> + result - = <nl> + kNumberOfFixedRangesPerRegister * config ( ) - > num_general_registers ( ) ; <nl> break ; <nl> default : <nl> UNREACHABLE ( ) ; <nl> int LiveRangeBuilder : : FixedFPLiveRangeID ( int index , MachineRepresentation rep ) { <nl> return result ; <nl> } <nl> <nl> - TopLevelLiveRange * LiveRangeBuilder : : FixedLiveRangeFor ( int index ) { <nl> + TopLevelLiveRange * LiveRangeBuilder : : FixedLiveRangeFor ( int index , <nl> + SpillMode spill_mode ) { <nl> + int offset = spill_mode = = SpillMode : : kSpillAtDefinition <nl> + ? 0 <nl> + : config ( ) - > num_general_registers ( ) ; <nl> DCHECK ( index < config ( ) - > num_general_registers ( ) ) ; <nl> - TopLevelLiveRange * result = data ( ) - > fixed_live_ranges ( ) [ index ] ; <nl> + TopLevelLiveRange * result = data ( ) - > fixed_live_ranges ( ) [ offset + index ] ; <nl> if ( result = = nullptr ) { <nl> MachineRepresentation rep = InstructionSequence : : DefaultRepresentation ( ) ; <nl> - result = data ( ) - > NewLiveRange ( FixedLiveRangeID ( index ) , rep ) ; <nl> + result = data ( ) - > NewLiveRange ( FixedLiveRangeID ( offset + index ) , rep ) ; <nl> DCHECK ( result - > IsFixed ( ) ) ; <nl> result - > set_assigned_register ( index ) ; <nl> data ( ) - > MarkAllocated ( rep , index ) ; <nl> - data ( ) - > fixed_live_ranges ( ) [ index ] = result ; <nl> + if ( spill_mode = = SpillMode : : kSpillDeferred ) { <nl> + result - > set_deferred_fixed ( ) ; <nl> + } <nl> + data ( ) - > fixed_live_ranges ( ) [ offset + index ] = result ; <nl> } <nl> return result ; <nl> } <nl> <nl> TopLevelLiveRange * LiveRangeBuilder : : FixedFPLiveRangeFor ( <nl> - int index , MachineRepresentation rep ) { <nl> + int index , MachineRepresentation rep , SpillMode spill_mode ) { <nl> int num_regs = config ( ) - > num_double_registers ( ) ; <nl> ZoneVector < TopLevelLiveRange * > * live_ranges = <nl> & data ( ) - > fixed_double_live_ranges ( ) ; <nl> TopLevelLiveRange * LiveRangeBuilder : : FixedFPLiveRangeFor ( <nl> } <nl> } <nl> <nl> + int offset = spill_mode = = SpillMode : : kSpillAtDefinition ? 0 : num_regs ; <nl> + <nl> DCHECK ( index < num_regs ) ; <nl> USE ( num_regs ) ; <nl> - TopLevelLiveRange * result = ( * live_ranges ) [ index ] ; <nl> + TopLevelLiveRange * result = ( * live_ranges ) [ offset + index ] ; <nl> if ( result = = nullptr ) { <nl> - result = data ( ) - > NewLiveRange ( FixedFPLiveRangeID ( index , rep ) , rep ) ; <nl> + result = data ( ) - > NewLiveRange ( FixedFPLiveRangeID ( offset + index , rep ) , rep ) ; <nl> DCHECK ( result - > IsFixed ( ) ) ; <nl> result - > set_assigned_register ( index ) ; <nl> data ( ) - > MarkAllocated ( rep , index ) ; <nl> - ( * live_ranges ) [ index ] = result ; <nl> + if ( spill_mode = = SpillMode : : kSpillDeferred ) { <nl> + result - > set_deferred_fixed ( ) ; <nl> + } <nl> + ( * live_ranges ) [ offset + index ] = result ; <nl> } <nl> return result ; <nl> } <nl> <nl> - TopLevelLiveRange * LiveRangeBuilder : : LiveRangeFor ( InstructionOperand * operand ) { <nl> + TopLevelLiveRange * LiveRangeBuilder : : LiveRangeFor ( InstructionOperand * operand , <nl> + SpillMode spill_mode ) { <nl> if ( operand - > IsUnallocated ( ) ) { <nl> return data ( ) - > GetOrCreateLiveRangeFor ( <nl> UnallocatedOperand : : cast ( operand ) - > virtual_register ( ) ) ; <nl> TopLevelLiveRange * LiveRangeBuilder : : LiveRangeFor ( InstructionOperand * operand ) { <nl> ConstantOperand : : cast ( operand ) - > virtual_register ( ) ) ; <nl> } else if ( operand - > IsRegister ( ) ) { <nl> return FixedLiveRangeFor ( <nl> - LocationOperand : : cast ( operand ) - > GetRegister ( ) . code ( ) ) ; <nl> + LocationOperand : : cast ( operand ) - > GetRegister ( ) . code ( ) , spill_mode ) ; <nl> } else if ( operand - > IsFPRegister ( ) ) { <nl> LocationOperand * op = LocationOperand : : cast ( operand ) ; <nl> - return FixedFPLiveRangeFor ( op - > register_code ( ) , op - > representation ( ) ) ; <nl> + return FixedFPLiveRangeFor ( op - > register_code ( ) , op - > representation ( ) , <nl> + spill_mode ) ; <nl> } else { <nl> return nullptr ; <nl> } <nl> UsePosition * LiveRangeBuilder : : NewUsePosition ( LifetimePosition pos , <nl> <nl> UsePosition * LiveRangeBuilder : : Define ( LifetimePosition position , <nl> InstructionOperand * operand , void * hint , <nl> - UsePositionHintType hint_type ) { <nl> - TopLevelLiveRange * range = LiveRangeFor ( operand ) ; <nl> + UsePositionHintType hint_type , <nl> + SpillMode spill_mode ) { <nl> + TopLevelLiveRange * range = LiveRangeFor ( operand , spill_mode ) ; <nl> if ( range = = nullptr ) return nullptr ; <nl> <nl> if ( range - > IsEmpty ( ) | | range - > Start ( ) > position ) { <nl> UsePosition * LiveRangeBuilder : : Define ( LifetimePosition position , <nl> UsePosition * LiveRangeBuilder : : Use ( LifetimePosition block_start , <nl> LifetimePosition position , <nl> InstructionOperand * operand , void * hint , <nl> - UsePositionHintType hint_type ) { <nl> - TopLevelLiveRange * range = LiveRangeFor ( operand ) ; <nl> + UsePositionHintType hint_type , <nl> + SpillMode spill_mode ) { <nl> + TopLevelLiveRange * range = LiveRangeFor ( operand , spill_mode ) ; <nl> if ( range = = nullptr ) return nullptr ; <nl> UsePosition * use_pos = nullptr ; <nl> if ( operand - > IsUnallocated ( ) ) { <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> fixed_float_live_ranges = ( mask & kFloat32Bit ) ! = 0 ; <nl> fixed_simd128_live_ranges = ( mask & kSimd128Bit ) ! = 0 ; <nl> } <nl> + SpillMode spill_mode = SpillModeForBlock ( block ) ; <nl> <nl> for ( int index = block - > last_instruction_index ( ) ; index > = block_start ; <nl> index - - ) { <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> / / exception value . <nl> / / TODO ( mtrofin ) : should we explore an explicit opcode for <nl> / / the first instruction in the handler ? <nl> - Define ( LifetimePosition : : GapFromInstructionIndex ( index ) , output ) ; <nl> + Define ( LifetimePosition : : GapFromInstructionIndex ( index ) , output , <nl> + spill_mode ) ; <nl> } else { <nl> - Define ( curr_position , output ) ; <nl> + Define ( curr_position , output , spill_mode ) ; <nl> } <nl> } <nl> <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> / / is OK because AddUseInterval will just merge it with the existing <nl> / / one at the end of the range . <nl> int code = config ( ) - > GetAllocatableGeneralCode ( i ) ; <nl> - TopLevelLiveRange * range = FixedLiveRangeFor ( code ) ; <nl> + TopLevelLiveRange * range = FixedLiveRangeFor ( code , spill_mode ) ; <nl> range - > AddUseInterval ( curr_position , curr_position . End ( ) , <nl> allocation_zone ( ) ) ; <nl> } <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> / / Add a UseInterval for all DoubleRegisters . See comment above for <nl> / / general registers . <nl> int code = config ( ) - > GetAllocatableDoubleCode ( i ) ; <nl> - TopLevelLiveRange * range = <nl> - FixedFPLiveRangeFor ( code , MachineRepresentation : : kFloat64 ) ; <nl> + TopLevelLiveRange * range = FixedFPLiveRangeFor ( <nl> + code , MachineRepresentation : : kFloat64 , spill_mode ) ; <nl> range - > AddUseInterval ( curr_position , curr_position . End ( ) , <nl> allocation_zone ( ) ) ; <nl> } <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> / / Add a UseInterval for all FloatRegisters . See comment above for <nl> / / general registers . <nl> int code = config ( ) - > GetAllocatableFloatCode ( i ) ; <nl> - TopLevelLiveRange * range = <nl> - FixedFPLiveRangeFor ( code , MachineRepresentation : : kFloat32 ) ; <nl> + TopLevelLiveRange * range = FixedFPLiveRangeFor ( <nl> + code , MachineRepresentation : : kFloat32 , spill_mode ) ; <nl> range - > AddUseInterval ( curr_position , curr_position . End ( ) , <nl> allocation_zone ( ) ) ; <nl> } <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> for ( int i = 0 ; i < config ( ) - > num_allocatable_simd128_registers ( ) ; <nl> + + i ) { <nl> int code = config ( ) - > GetAllocatableSimd128Code ( i ) ; <nl> - TopLevelLiveRange * range = <nl> - FixedFPLiveRangeFor ( code , MachineRepresentation : : kSimd128 ) ; <nl> + TopLevelLiveRange * range = FixedFPLiveRangeFor ( <nl> + code , MachineRepresentation : : kSimd128 , spill_mode ) ; <nl> range - > AddUseInterval ( curr_position , curr_position . End ( ) , <nl> allocation_zone ( ) ) ; <nl> } <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> } <nl> } <nl> } <nl> - Use ( block_start_position , use_pos , input ) ; <nl> + Use ( block_start_position , use_pos , input , spill_mode ) ; <nl> } <nl> <nl> for ( size_t i = 0 ; i < instr - > TempCount ( ) ; i + + ) { <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> } <nl> } <nl> } <nl> - Use ( block_start_position , curr_position . End ( ) , temp ) ; <nl> - Define ( curr_position , temp ) ; <nl> + Use ( block_start_position , curr_position . End ( ) , temp , spill_mode ) ; <nl> + Define ( curr_position , temp , spill_mode ) ; <nl> } <nl> <nl> / / Process the moves of the instruction ' s gaps , making their sources live . <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> } <nl> } else { <nl> if ( live - > Contains ( to_vreg ) ) { <nl> - to_use = Define ( curr_position , & to , & from , <nl> - UsePosition : : HintTypeForOperand ( from ) ) ; <nl> + to_use = <nl> + Define ( curr_position , & to , & from , <nl> + UsePosition : : HintTypeForOperand ( from ) , spill_mode ) ; <nl> live - > Remove ( to_vreg ) ; <nl> } else { <nl> cur - > Eliminate ( ) ; <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> } <nl> } <nl> } else { <nl> - Define ( curr_position , & to ) ; <nl> + Define ( curr_position , & to , spill_mode ) ; <nl> } <nl> - UsePosition * from_use = <nl> - Use ( block_start_position , curr_position , & from , hint , hint_type ) ; <nl> + UsePosition * from_use = Use ( block_start_position , curr_position , & from , <nl> + hint , hint_type , spill_mode ) ; <nl> / / Mark range live . <nl> if ( from . IsUnallocated ( ) ) { <nl> live - > Add ( UnallocatedOperand : : cast ( from ) . virtual_register ( ) ) ; <nl> void LiveRangeBuilder : : ProcessPhis ( const InstructionBlock * block , <nl> LifetimePosition block_start = LifetimePosition : : GapFromInstructionIndex ( <nl> block - > first_instruction_index ( ) ) ; <nl> UsePosition * use_pos = Define ( block_start , & phi - > output ( ) , hint , <nl> - UsePosition : : HintTypeForOperand ( * hint ) ) ; <nl> + UsePosition : : HintTypeForOperand ( * hint ) , <nl> + SpillModeForBlock ( block ) ) ; <nl> MapPhiHint ( hint , use_pos ) ; <nl> } <nl> } <nl> bool LinearScanAllocator : : ConsiderBlockForControlFlow ( <nl> ! code ( ) - > InstructionBlockAt ( predecessor ) - > IsDeferred ( ) ) ; <nl> } <nl> <nl> + void LinearScanAllocator : : UpdateDeferredFixedRanges ( SpillMode spill_mode , <nl> + InstructionBlock * block ) { <nl> + if ( spill_mode = = SpillMode : : kSpillDeferred ) { <nl> + LifetimePosition max = LifetimePosition : : InstructionFromInstructionIndex ( <nl> + LastDeferredInstructionIndex ( block ) ) ; <nl> + / / Adds range back to inactive , resolving resulting conflicts . <nl> + auto add_to_inactive = [ this , max ] ( LiveRange * range ) { <nl> + AddToInactive ( range ) ; <nl> + / / Splits other if it conflicts with range . Other is placed in unhandled <nl> + / / for later reallocation . <nl> + auto split_conflicting = [ this , max ] ( LiveRange * range , LiveRange * other , <nl> + std : : function < void ( LiveRange * ) > <nl> + update_caches ) { <nl> + if ( other - > TopLevel ( ) - > IsFixed ( ) ) return ; <nl> + int reg = range - > assigned_register ( ) ; <nl> + if ( kSimpleFPAliasing | | ! check_fp_aliasing ( ) ) { <nl> + if ( other - > assigned_register ( ) ! = reg ) { <nl> + return ; <nl> + } <nl> + } else { <nl> + if ( ! data ( ) - > config ( ) - > AreAliases ( range - > representation ( ) , reg , <nl> + other - > representation ( ) , <nl> + other - > assigned_register ( ) ) ) { <nl> + return ; <nl> + } <nl> + } <nl> + / / The inactive range might conflict , so check whether we need to <nl> + / / split and spill . We can look for the first intersection , as there <nl> + / / cannot be any intersections in the past , as those would have been a <nl> + / / conflict then . <nl> + LifetimePosition next_start = range - > FirstIntersection ( other ) ; <nl> + if ( ! next_start . IsValid ( ) | | ( next_start > max ) ) { <nl> + / / There is no conflict or the conflict is outside of the current <nl> + / / stretch of deferred code . In either case we can ignore the <nl> + / / inactive range . <nl> + return ; <nl> + } <nl> + / / They overlap . So we need to split active and reschedule it <nl> + / / for allocation . <nl> + TRACE ( " Resolving conflict of % d with deferred fixed for register % s \ n " , <nl> + other - > TopLevel ( ) - > vreg ( ) , <nl> + RegisterName ( other - > assigned_register ( ) ) ) ; <nl> + LiveRange * split_off = <nl> + other - > SplitAt ( next_start , data ( ) - > allocation_zone ( ) ) ; <nl> + DCHECK_NE ( split_off , other ) ; <nl> + AddToUnhandled ( split_off ) ; <nl> + update_caches ( other ) ; <nl> + } ; <nl> + / / Now check for conflicts in active and inactive ranges . We might have <nl> + / / conflicts in inactive , as we do not do this check on every block <nl> + / / boundary but only on deferred / non - deferred changes but inactive <nl> + / / live ranges might become live on any block boundary . <nl> + for ( auto active : active_live_ranges ( ) ) { <nl> + split_conflicting ( range , active , [ this ] ( LiveRange * updated ) { <nl> + next_active_ranges_change_ = <nl> + Min ( updated - > End ( ) , next_active_ranges_change_ ) ; <nl> + } ) ; <nl> + } <nl> + for ( auto inactive : inactive_live_ranges ( ) ) { <nl> + split_conflicting ( range , inactive , [ this ] ( LiveRange * updated ) { <nl> + next_inactive_ranges_change_ = <nl> + Min ( updated - > End ( ) , next_inactive_ranges_change_ ) ; <nl> + } ) ; <nl> + } <nl> + } ; <nl> + if ( mode ( ) = = GENERAL_REGISTERS ) { <nl> + for ( TopLevelLiveRange * current : data ( ) - > fixed_live_ranges ( ) ) { <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) { <nl> + add_to_inactive ( current ) ; <nl> + } <nl> + } <nl> + } <nl> + } else { <nl> + for ( TopLevelLiveRange * current : data ( ) - > fixed_double_live_ranges ( ) ) { <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) { <nl> + add_to_inactive ( current ) ; <nl> + } <nl> + } <nl> + } <nl> + if ( ! kSimpleFPAliasing & & check_fp_aliasing ( ) ) { <nl> + for ( TopLevelLiveRange * current : data ( ) - > fixed_float_live_ranges ( ) ) { <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) { <nl> + add_to_inactive ( current ) ; <nl> + } <nl> + } <nl> + } <nl> + for ( TopLevelLiveRange * current : data ( ) - > fixed_simd128_live_ranges ( ) ) { <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) { <nl> + add_to_inactive ( current ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } else { <nl> + / / Remove all ranges . <nl> + for ( auto it = inactive_live_ranges ( ) . begin ( ) ; <nl> + it ! = inactive_live_ranges ( ) . end ( ) ; ) { <nl> + if ( ( * it ) - > TopLevel ( ) - > IsDeferredFixed ( ) ) { <nl> + it = inactive_live_ranges ( ) . erase ( it ) ; <nl> + } else { <nl> + + + it ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> bool LinearScanAllocator : : BlockIsDeferredOrImmediatePredecessorIsNotDeferred ( <nl> const InstructionBlock * block ) { <nl> if ( block - > IsDeferred ( ) ) return true ; <nl> bool LinearScanAllocator : : BlockIsDeferredOrImmediatePredecessorIsNotDeferred ( <nl> return ! pred_is_deferred ; <nl> } <nl> <nl> + bool LinearScanAllocator : : HasNonDeferredPredecessor ( InstructionBlock * block ) { <nl> + for ( auto pred : block - > predecessors ( ) ) { <nl> + InstructionBlock * pred_block = code ( ) - > InstructionBlockAt ( pred ) ; <nl> + if ( ! pred_block - > IsDeferred ( ) ) return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> void LinearScanAllocator : : AllocateRegisters ( ) { <nl> DCHECK ( unhandled_live_ranges ( ) . empty ( ) ) ; <nl> DCHECK ( active_live_ranges ( ) . empty ( ) ) ; <nl> void LinearScanAllocator : : AllocateRegisters ( ) { <nl> <nl> if ( mode ( ) = = GENERAL_REGISTERS ) { <nl> for ( TopLevelLiveRange * current : data ( ) - > fixed_live_ranges ( ) ) { <nl> - if ( current ! = nullptr ) AddToInactive ( current ) ; <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) continue ; <nl> + AddToInactive ( current ) ; <nl> + } <nl> } <nl> } else { <nl> for ( TopLevelLiveRange * current : data ( ) - > fixed_double_live_ranges ( ) ) { <nl> - if ( current ! = nullptr ) AddToInactive ( current ) ; <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) continue ; <nl> + AddToInactive ( current ) ; <nl> + } <nl> } <nl> if ( ! kSimpleFPAliasing & & check_fp_aliasing ( ) ) { <nl> for ( TopLevelLiveRange * current : data ( ) - > fixed_float_live_ranges ( ) ) { <nl> - if ( current ! = nullptr ) AddToInactive ( current ) ; <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) continue ; <nl> + AddToInactive ( current ) ; <nl> + } <nl> } <nl> for ( TopLevelLiveRange * current : data ( ) - > fixed_simd128_live_ranges ( ) ) { <nl> - if ( current ! = nullptr ) AddToInactive ( current ) ; <nl> + if ( current ! = nullptr ) { <nl> + if ( current - > IsDeferredFixed ( ) ) continue ; <nl> + AddToInactive ( current ) ; <nl> + } <nl> } <nl> } <nl> } <nl> void LinearScanAllocator : : AllocateRegisters ( ) { <nl> current_block - > predecessors ( ) [ 0 ] . IsNext ( <nl> current_block - > rpo_number ( ) ) ; <nl> <nl> - spill_mode = current_block - > IsDeferred ( ) <nl> - ? SpillMode : : kSpillDeferred <nl> - : SpillMode : : kSpillAtDefinition ; <nl> + / / When crossing a deferred / non - deferred boundary , we have to load or <nl> + / / remove the deferred fixed ranges from inactive . <nl> + if ( ( spill_mode = = SpillMode : : kSpillDeferred ) ! = <nl> + current_block - > IsDeferred ( ) ) { <nl> + / / Update spill mode . <nl> + spill_mode = current_block - > IsDeferred ( ) <nl> + ? SpillMode : : kSpillDeferred <nl> + : SpillMode : : kSpillAtDefinition ; <nl> + <nl> + ForwardStateTo ( next_block_boundary ) ; <nl> + <nl> + # ifdef DEBUG <nl> + / / Allow allocation at current position . <nl> + allocation_finger_ = next_block_boundary ; <nl> + # endif <nl> + UpdateDeferredFixedRanges ( spill_mode , current_block ) ; <nl> + } <nl> + <nl> + / / Allocation relies on the fact that each non - deferred block has at <nl> + / / least one non - deferred predecessor . Check this invariant here . <nl> + DCHECK_IMPLIES ( ! current_block - > IsDeferred ( ) , <nl> + HasNonDeferredPredecessor ( current_block ) ) ; <nl> <nl> if ( ! fallthrough ) { <nl> # ifdef DEBUG <nl> void LinearScanAllocator : : AllocateBlockedReg ( LiveRange * current , <nl> new_end = block_pos [ reg ] . Start ( ) ; <nl> } <nl> <nl> + / / If there is no register available at all , we can only spill this range . <nl> + / / Happens for instance on entry to deferred code where registers might <nl> + / / become blocked yet we aim to reload ranges . <nl> + if ( new_end = = current - > Start ( ) ) { <nl> + SpillBetween ( current , new_end , register_use - > pos ( ) , spill_mode ) ; <nl> + return ; <nl> + } <nl> + <nl> / / Split at the new end if we found one . <nl> if ( new_end ! = current - > End ( ) ) { <nl> LiveRange * tail = SplitBetween ( current , current - > Start ( ) , new_end ) ; <nl> mmm a / src / compiler / backend / register - allocator . h <nl> ppp b / src / compiler / backend / register - allocator . h <nl> class V8_EXPORT_PRIVATE LiveRange : public NON_EXPORTED_BASE ( ZoneObject ) { <nl> void VerifyIntervals ( ) const ; <nl> <nl> typedef BitField < bool , 0 , 1 > SpilledField ; <nl> - / / Bits ( 1 , 7 ] are used by TopLevelLiveRange . <nl> + / / Bits ( 1 , 7 [ are used by TopLevelLiveRange . <nl> typedef BitField < int32_t , 7 , 6 > AssignedRegisterField ; <nl> typedef BitField < MachineRepresentation , 13 , 8 > RepresentationField ; <nl> typedef BitField < bool , 21 , 1 > RecombineField ; <nl> typedef BitField < uint8_t , 22 , 6 > ControlFlowRegisterHint ; <nl> + / / Bit 28 is used by TopLevelLiveRange . <nl> <nl> / / Unique among children and splinters of the same virtual register . <nl> int relative_id_ ; <nl> class V8_EXPORT_PRIVATE TopLevelLiveRange final : public LiveRange { <nl> <nl> bool IsFixed ( ) const { return vreg_ < 0 ; } <nl> <nl> + bool IsDeferredFixed ( ) const { return DeferredFixedField : : decode ( bits_ ) ; } <nl> + void set_deferred_fixed ( ) { bits_ = DeferredFixedField : : update ( bits_ , true ) ; } <nl> bool is_phi ( ) const { return IsPhiField : : decode ( bits_ ) ; } <nl> void set_is_phi ( bool value ) { bits_ = IsPhiField : : update ( bits_ , value ) ; } <nl> <nl> class V8_EXPORT_PRIVATE TopLevelLiveRange final : public LiveRange { <nl> typedef BitField < bool , 3 , 1 > IsPhiField ; <nl> typedef BitField < bool , 4 , 1 > IsNonLoopPhiField ; <nl> typedef BitField < SpillType , 5 , 2 > SpillTypeField ; <nl> + typedef BitField < bool , 28 , 1 > DeferredFixedField ; <nl> <nl> int vreg_ ; <nl> int last_child_id_ ; <nl> class RegisterAllocationData final : public ZoneObject { <nl> / / Encodes whether a spill happens in deferred code ( kSpillDeferred ) or <nl> / / regular code ( kSpillAtDefinition ) . <nl> enum SpillMode { kSpillAtDefinition , kSpillDeferred } ; <nl> + static constexpr int kNumberOfFixedRangesPerRegister = 2 ; <nl> + <nl> class PhiMapValue : public ZoneObject { <nl> public : <nl> PhiMapValue ( PhiInstruction * phi , const InstructionBlock * block , Zone * zone ) ; <nl> class LiveRangeBuilder final : public ZoneObject { <nl> <nl> private : <nl> using SpillMode = RegisterAllocationData : : SpillMode ; <nl> + static constexpr int kNumberOfFixedRangesPerRegister = <nl> + RegisterAllocationData : : kNumberOfFixedRangesPerRegister ; <nl> <nl> RegisterAllocationData * data ( ) const { return data_ ; } <nl> InstructionSequence * code ( ) const { return data ( ) - > code ( ) ; } <nl> class LiveRangeBuilder final : public ZoneObject { <nl> <nl> static int FixedLiveRangeID ( int index ) { return - index - 1 ; } <nl> int FixedFPLiveRangeID ( int index , MachineRepresentation rep ) ; <nl> - TopLevelLiveRange * FixedLiveRangeFor ( int index ) ; <nl> - TopLevelLiveRange * FixedFPLiveRangeFor ( int index , MachineRepresentation rep ) ; <nl> + TopLevelLiveRange * FixedLiveRangeFor ( int index , SpillMode spill_mode ) ; <nl> + TopLevelLiveRange * FixedFPLiveRangeFor ( int index , MachineRepresentation rep , <nl> + SpillMode spill_mode ) ; <nl> <nl> void MapPhiHint ( InstructionOperand * operand , UsePosition * use_pos ) ; <nl> void ResolvePhiHint ( InstructionOperand * operand , UsePosition * use_pos ) ; <nl> class LiveRangeBuilder final : public ZoneObject { <nl> UsePosition * NewUsePosition ( LifetimePosition pos ) { <nl> return NewUsePosition ( pos , nullptr , nullptr , UsePositionHintType : : kNone ) ; <nl> } <nl> - TopLevelLiveRange * LiveRangeFor ( InstructionOperand * operand ) ; <nl> + TopLevelLiveRange * LiveRangeFor ( InstructionOperand * operand , <nl> + SpillMode spill_mode ) ; <nl> / / Helper methods for building intervals . <nl> UsePosition * Define ( LifetimePosition position , InstructionOperand * operand , <nl> - void * hint , UsePositionHintType hint_type ) ; <nl> - void Define ( LifetimePosition position , InstructionOperand * operand ) { <nl> - Define ( position , operand , nullptr , UsePositionHintType : : kNone ) ; <nl> + void * hint , UsePositionHintType hint_type , <nl> + SpillMode spill_mode ) ; <nl> + void Define ( LifetimePosition position , InstructionOperand * operand , <nl> + SpillMode spill_mode ) { <nl> + Define ( position , operand , nullptr , UsePositionHintType : : kNone , spill_mode ) ; <nl> } <nl> UsePosition * Use ( LifetimePosition block_start , LifetimePosition position , <nl> InstructionOperand * operand , void * hint , <nl> - UsePositionHintType hint_type ) ; <nl> + UsePositionHintType hint_type , SpillMode spill_mode ) ; <nl> void Use ( LifetimePosition block_start , LifetimePosition position , <nl> - InstructionOperand * operand ) { <nl> - Use ( block_start , position , operand , nullptr , UsePositionHintType : : kNone ) ; <nl> + InstructionOperand * operand , SpillMode spill_mode ) { <nl> + Use ( block_start , position , operand , nullptr , UsePositionHintType : : kNone , <nl> + spill_mode ) ; <nl> + } <nl> + SpillMode SpillModeForBlock ( const InstructionBlock * block ) const { <nl> + if ( FLAG_turbo_control_flow_aware_allocation ) { <nl> + return block - > IsDeferred ( ) ? SpillMode : : kSpillDeferred <nl> + : SpillMode : : kSpillAtDefinition ; <nl> + } <nl> + return SpillMode : : kSpillAtDefinition ; <nl> } <nl> RegisterAllocationData * const data_ ; <nl> ZoneMap < InstructionOperand * , UsePosition * > phi_hints_ ; <nl> class LinearScanAllocator final : public RegisterAllocator { <nl> void ReloadLiveRanges ( RangeWithRegisterSet & to_be_live , <nl> LifetimePosition position ) ; <nl> <nl> + void UpdateDeferredFixedRanges ( SpillMode spill_mode , InstructionBlock * block ) ; <nl> bool BlockIsDeferredOrImmediatePredecessorIsNotDeferred ( <nl> const InstructionBlock * block ) ; <nl> + bool HasNonDeferredPredecessor ( InstructionBlock * block ) ; <nl> <nl> struct LiveRangeOrdering { <nl> bool operator ( ) ( const LiveRange * a , const LiveRange * b ) const { <nl> mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> DEFINE_BOOL ( print_deopt_stress , false , " print number of possible deopt points " ) <nl> / / Flags for TurboFan . <nl> DEFINE_BOOL ( turbo_sp_frame_access , false , <nl> " use stack pointer - relative access to frame wherever possible " ) <nl> - DEFINE_BOOL ( turbo_preprocess_ranges , true , <nl> + DEFINE_BOOL ( turbo_preprocess_ranges , false , <nl> " run pre - register allocation heuristics " ) <nl> - DEFINE_BOOL ( turbo_control_flow_aware_allocation , false , <nl> + DEFINE_BOOL ( turbo_control_flow_aware_allocation , true , <nl> " consider control flow while allocating registers " ) <nl> DEFINE_NEG_IMPLICATION ( turbo_control_flow_aware_allocation , <nl> turbo_preprocess_ranges ) <nl> mmm a / test / unittests / compiler / regalloc / register - allocator - unittest . cc <nl> ppp b / test / unittests / compiler / regalloc / register - allocator - unittest . cc <nl> TEST_F ( RegisterAllocatorTest , SimpleLoop ) { <nl> / / while ( true ) { i + + } <nl> StartBlock ( ) ; <nl> auto i_reg = DefineConstant ( ) ; <nl> + / / Add a branch around the loop to ensure the end - block <nl> + / / is connected . <nl> + EndBlock ( Branch ( Reg ( DefineConstant ( ) ) , 3 , 1 ) ) ; <nl> + <nl> + StartBlock ( ) ; <nl> EndBlock ( ) ; <nl> <nl> { <nl> TEST_F ( RegisterAllocatorTest , SimpleLoop ) { <nl> EndLoop ( ) ; <nl> } <nl> <nl> + StartBlock ( ) ; <nl> + EndBlock ( ) ; <nl> + <nl> Allocate ( ) ; <nl> } <nl> <nl> TEST_F ( RegisterAllocatorTest , SingleDeferredBlockSpill ) { <nl> <nl> const int var_def_index = 1 ; <nl> const int call_index = 3 ; <nl> - int expect_no_moves = <nl> - FLAG_turbo_preprocess_ranges ? var_def_index : call_index ; <nl> - int expect_spill_move = <nl> - FLAG_turbo_preprocess_ranges ? call_index : var_def_index ; <nl> + const bool spill_in_deferred = <nl> + FLAG_turbo_preprocess_ranges | | FLAG_turbo_control_flow_aware_allocation ; <nl> + int expect_no_moves = spill_in_deferred ? var_def_index : call_index ; <nl> + int expect_spill_move = spill_in_deferred ? call_index : var_def_index ; <nl> <nl> / / We should have no parallel moves at the " expect_no_moves " position . <nl> EXPECT_EQ ( <nl> TEST_F ( RegisterAllocatorTest , MultipleDeferredBlockSpills ) { <nl> GetParallelMoveCount ( start_of_b3 , Instruction : : START , sequence ( ) ) ) ; <nl> } <nl> <nl> + TEST_F ( RegisterAllocatorTest , ValidMultipleDeferredBlockSpills ) { <nl> + if ( ! FLAG_turbo_control_flow_aware_allocation ) return ; <nl> + <nl> + StartBlock ( ) ; / / B0 <nl> + auto var1 = EmitOI ( Reg ( 0 ) ) ; <nl> + auto var2 = EmitOI ( Reg ( 1 ) ) ; <nl> + auto var3 = EmitOI ( Reg ( 2 ) ) ; <nl> + EndBlock ( Branch ( Reg ( var1 , 0 ) , 1 , 2 ) ) ; <nl> + <nl> + StartBlock ( true ) ; / / B1 <nl> + EmitCall ( Slot ( - 2 ) , Slot ( var1 ) ) ; <nl> + EndBlock ( Jump ( 5 ) ) ; <nl> + <nl> + StartBlock ( ) ; / / B2 <nl> + EmitNop ( ) ; <nl> + EndBlock ( ) ; <nl> + <nl> + StartBlock ( ) ; / / B3 <nl> + EmitNop ( ) ; <nl> + EndBlock ( Branch ( Reg ( var2 , 0 ) , 1 , 2 ) ) ; <nl> + <nl> + StartBlock ( true ) ; / / B4 <nl> + EmitCall ( Slot ( - 1 ) , Slot ( var2 ) ) ; <nl> + EndBlock ( Jump ( 2 ) ) ; <nl> + <nl> + StartBlock ( ) ; / / B5 <nl> + EmitNop ( ) ; <nl> + EndBlock ( ) ; <nl> + <nl> + StartBlock ( ) ; / / B6 <nl> + Return ( Reg ( var3 , 2 ) ) ; <nl> + EndBlock ( ) ; <nl> + <nl> + const int def_of_v2 = 2 ; <nl> + const int call_in_b1 = 4 ; <nl> + const int call_in_b4 = 10 ; <nl> + const int end_of_b1 = 5 ; <nl> + const int end_of_b4 = 11 ; <nl> + const int start_of_b6 = 14 ; <nl> + <nl> + Allocate ( ) ; <nl> + <nl> + const int var3_reg = 2 ; <nl> + const int var3_slot = 2 ; <nl> + <nl> + EXPECT_FALSE ( IsParallelMovePresent ( def_of_v2 , Instruction : : START , sequence ( ) , <nl> + Reg ( var3_reg ) , Slot ( ) ) ) ; <nl> + EXPECT_TRUE ( IsParallelMovePresent ( call_in_b1 , Instruction : : START , sequence ( ) , <nl> + Reg ( var3_reg ) , Slot ( var3_slot ) ) ) ; <nl> + EXPECT_TRUE ( IsParallelMovePresent ( end_of_b1 , Instruction : : START , sequence ( ) , <nl> + Slot ( var3_slot ) , Reg ( ) ) ) ; <nl> + <nl> + EXPECT_TRUE ( IsParallelMovePresent ( call_in_b4 , Instruction : : START , sequence ( ) , <nl> + Reg ( var3_reg ) , Slot ( var3_slot ) ) ) ; <nl> + EXPECT_TRUE ( IsParallelMovePresent ( end_of_b4 , Instruction : : START , sequence ( ) , <nl> + Slot ( var3_slot ) , Reg ( ) ) ) ; <nl> + <nl> + EXPECT_EQ ( 0 , <nl> + GetParallelMoveCount ( start_of_b6 , Instruction : : START , sequence ( ) ) ) ; <nl> + } <nl> + <nl> namespace { <nl> <nl> enum class ParameterType { kFixedSlot , kSlot , kRegister , kFixedRegister } ; <nl>
[ regalloc ] Introduce deferred fixed ranges
v8/v8
b176931311c49597e312056109abfa45e31ea4a2
2019-03-19T12:54:41Z
mmm a / test / functional / feature_versionbits_warning . py <nl> ppp b / test / functional / feature_versionbits_warning . py <nl> <nl> Generate chains with block versions that appear to be signalling unknown <nl> soft - forks , and test that warning alerts are generated . <nl> " " " <nl> - <nl> - from test_framework . mininode import * <nl> - from test_framework . test_framework import BitcoinTestFramework <nl> - from test_framework . util import * <nl> + import os <nl> import re <nl> + <nl> from test_framework . blocktools import create_block , create_coinbase <nl> + from test_framework . messages import msg_block <nl> + from test_framework . mininode import P2PInterface , network_thread_start <nl> + from test_framework . test_framework import BitcoinTestFramework <nl> <nl> - VB_PERIOD = 144 # versionbits period length for regtest <nl> - VB_THRESHOLD = 108 # versionbits activation threshold for regtest <nl> + VB_PERIOD = 144 # versionbits period length for regtest <nl> + VB_THRESHOLD = 108 # versionbits activation threshold for regtest <nl> VB_TOP_BITS = 0x20000000 <nl> - VB_UNKNOWN_BIT = 27 # Choose a bit unassigned to any deployment <nl> + VB_UNKNOWN_BIT = 27 # Choose a bit unassigned to any deployment <nl> <nl> WARN_UNKNOWN_RULES_MINED = " Unknown block versions being mined ! It ' s possible unknown rules are in effect " <nl> WARN_UNKNOWN_RULES_ACTIVE = " unknown new rules activated ( versionbit { } ) " . format ( VB_UNKNOWN_BIT ) <nl> def set_test_params ( self ) : <nl> def setup_network ( self ) : <nl> self . alert_filename = os . path . join ( self . options . tmpdir , " alert . txt " ) <nl> # Open and close to create zero - length file <nl> - with open ( self . alert_filename , ' w ' , encoding = ' utf8 ' ) as _ : <nl> + with open ( self . alert_filename , ' w ' , encoding = ' utf8 ' ) : <nl> pass <nl> self . extra_args = [ [ " - alertnotify = echo % s > > \ " " + self . alert_filename + " \ " " ] ] <nl> self . setup_nodes ( ) <nl> <nl> - # Send numblocks blocks via peer with nVersionToUse set . <nl> - def send_blocks_with_version ( self , peer , numblocks , nVersionToUse ) : <nl> + # Send numblocks blocks via peer with version set . <nl> + def send_blocks_with_version ( self , peer , numblocks , version ) : <nl> tip = self . nodes [ 0 ] . getbestblockhash ( ) <nl> height = self . nodes [ 0 ] . getblockcount ( ) <nl> - block_time = self . nodes [ 0 ] . getblockheader ( tip ) [ " time " ] + 1 <nl> + block_time = self . nodes [ 0 ] . getblockheader ( tip ) [ " time " ] + 1 <nl> tip = int ( tip , 16 ) <nl> <nl> for _ in range ( numblocks ) : <nl> - block = create_block ( tip , create_coinbase ( height + 1 ) , block_time ) <nl> - block . nVersion = nVersionToUse <nl> + block = create_block ( tip , create_coinbase ( height + 1 ) , block_time ) <nl> + block . nVersion = version <nl> block . solve ( ) <nl> peer . send_message ( msg_block ( block ) ) <nl> block_time + = 1 <nl> def run_test ( self ) : <nl> <nl> # 2 . Now build one period of blocks on the tip , with < VB_THRESHOLD <nl> # blocks signaling some unknown bit . <nl> - nVersion = VB_TOP_BITS | ( 1 < < VB_UNKNOWN_BIT ) <nl> - self . send_blocks_with_version ( self . nodes [ 0 ] . p2p , VB_THRESHOLD - 1 , nVersion ) <nl> + version = VB_TOP_BITS | ( 1 < < VB_UNKNOWN_BIT ) <nl> + self . send_blocks_with_version ( self . nodes [ 0 ] . p2p , VB_THRESHOLD - 1 , version ) <nl> <nl> # Fill rest of period with regular version blocks <nl> self . nodes [ 0 ] . generate ( VB_PERIOD - VB_THRESHOLD + 1 ) <nl> def run_test ( self ) : <nl> <nl> # 3 . Now build one period of blocks with > = VB_THRESHOLD blocks signaling <nl> # some unknown bit <nl> - self . send_blocks_with_version ( self . nodes [ 0 ] . p2p , VB_THRESHOLD , nVersion ) <nl> + self . send_blocks_with_version ( self . nodes [ 0 ] . p2p , VB_THRESHOLD , version ) <nl> self . nodes [ 0 ] . generate ( VB_PERIOD - VB_THRESHOLD ) <nl> # Might not get a versionbits - related alert yet , as we should <nl> # have gotten a different alert due to more than 51 / 100 blocks <nl> def run_test ( self ) : <nl> self . nodes [ 0 ] . generate ( VB_PERIOD ) <nl> self . stop_nodes ( ) <nl> # Empty out the alert file <nl> - with open ( self . alert_filename , ' w ' , encoding = ' utf8 ' ) as _ : <nl> + with open ( self . alert_filename , ' w ' , encoding = ' utf8 ' ) : <nl> pass <nl> self . start_nodes ( ) <nl> <nl>
Fix flake8 warnings in p2p - versionbits - warning . py
bitcoin/bitcoin
ef2beb2c1300b0725cf06ac9309c35a8046936f3
2018-01-25T12:34:58Z
mmm a / src / arm / codegen - arm . cc <nl> ppp b / src / arm / codegen - arm . cc <nl> void CodeGenerator : : VisitUnaryOperation ( UnaryOperation * node ) { <nl> frame_ - > EmitPush ( r0 ) ; / / r0 has result <nl> <nl> } else { <nl> + bool overwrite = <nl> + ( node - > expression ( ) - > AsBinaryOperation ( ) ! = NULL & & <nl> + node - > expression ( ) - > AsBinaryOperation ( ) - > ResultOverwriteAllowed ( ) ) ; <nl> LoadAndSpill ( node - > expression ( ) ) ; <nl> frame_ - > EmitPop ( r0 ) ; <nl> switch ( op ) { <nl> void CodeGenerator : : VisitUnaryOperation ( UnaryOperation * node ) { <nl> break ; <nl> <nl> case Token : : SUB : { <nl> - bool overwrite = <nl> - ( node - > expression ( ) - > AsBinaryOperation ( ) ! = NULL & & <nl> - node - > expression ( ) - > AsBinaryOperation ( ) - > ResultOverwriteAllowed ( ) ) ; <nl> GenericUnaryOpStub stub ( Token : : SUB , overwrite ) ; <nl> frame_ - > CallStub ( & stub , 0 ) ; <nl> break ; <nl> void CodeGenerator : : VisitUnaryOperation ( UnaryOperation * node ) { <nl> __ tst ( r0 , Operand ( kSmiTagMask ) ) ; <nl> smi_label . Branch ( eq ) ; <nl> <nl> - frame_ - > EmitPush ( r0 ) ; <nl> - frame_ - > InvokeBuiltin ( Builtins : : BIT_NOT , CALL_JS , 1 ) ; <nl> - <nl> + GenericUnaryOpStub stub ( Token : : BIT_NOT , overwrite ) ; <nl> + frame_ - > CallStub ( & stub , 0 ) ; <nl> continue_label . Jump ( ) ; <nl> + <nl> smi_label . Bind ( ) ; <nl> __ mvn ( r0 , Operand ( r0 ) ) ; <nl> __ bic ( r0 , r0 , Operand ( kSmiTagMask ) ) ; / / bit - clear inverted smi - tag <nl> void StackCheckStub : : Generate ( MacroAssembler * masm ) { <nl> <nl> <nl> void GenericUnaryOpStub : : Generate ( MacroAssembler * masm ) { <nl> - ASSERT ( op_ = = Token : : SUB ) ; <nl> - <nl> - Label undo ; <nl> - Label slow ; <nl> - Label not_smi ; <nl> - <nl> - / / Enter runtime system if the value is not a smi . <nl> - __ tst ( r0 , Operand ( kSmiTagMask ) ) ; <nl> - __ b ( ne , & not_smi ) ; <nl> + Label slow , done ; <nl> <nl> - / / Enter runtime system if the value of the expression is zero <nl> - / / to make sure that we switch between 0 and - 0 . <nl> - __ cmp ( r0 , Operand ( 0 ) ) ; <nl> - __ b ( eq , & slow ) ; <nl> + if ( op_ = = Token : : SUB ) { <nl> + / / Check whether the value is a smi . <nl> + Label try_float ; <nl> + __ tst ( r0 , Operand ( kSmiTagMask ) ) ; <nl> + __ b ( ne , & try_float ) ; <nl> + <nl> + / / Go slow case if the value of the expression is zero <nl> + / / to make sure that we switch between 0 and - 0 . <nl> + __ cmp ( r0 , Operand ( 0 ) ) ; <nl> + __ b ( eq , & slow ) ; <nl> + <nl> + / / The value of the expression is a smi that is not zero . Try <nl> + / / optimistic subtraction ' 0 - value ' . <nl> + __ rsb ( r1 , r0 , Operand ( 0 ) , SetCC ) ; <nl> + __ b ( vs , & slow ) ; <nl> + <nl> + __ mov ( r0 , Operand ( r1 ) ) ; / / Set r0 to result . <nl> + __ b ( & done ) ; <nl> + <nl> + __ bind ( & try_float ) ; <nl> + __ CompareObjectType ( r0 , r1 , r1 , HEAP_NUMBER_TYPE ) ; <nl> + __ b ( ne , & slow ) ; <nl> + / / r0 is a heap number . Get a new heap number in r1 . <nl> + if ( overwrite_ ) { <nl> + __ ldr ( r2 , FieldMemOperand ( r0 , HeapNumber : : kExponentOffset ) ) ; <nl> + __ eor ( r2 , r2 , Operand ( HeapNumber : : kSignMask ) ) ; / / Flip sign . <nl> + __ str ( r2 , FieldMemOperand ( r0 , HeapNumber : : kExponentOffset ) ) ; <nl> + } else { <nl> + AllocateHeapNumber ( masm , & slow , r1 , r2 , r3 ) ; <nl> + __ ldr ( r3 , FieldMemOperand ( r0 , HeapNumber : : kMantissaOffset ) ) ; <nl> + __ ldr ( r2 , FieldMemOperand ( r0 , HeapNumber : : kExponentOffset ) ) ; <nl> + __ str ( r3 , FieldMemOperand ( r1 , HeapNumber : : kMantissaOffset ) ) ; <nl> + __ eor ( r2 , r2 , Operand ( HeapNumber : : kSignMask ) ) ; / / Flip sign . <nl> + __ str ( r2 , FieldMemOperand ( r1 , HeapNumber : : kExponentOffset ) ) ; <nl> + __ mov ( r0 , Operand ( r1 ) ) ; <nl> + } <nl> + } else if ( op_ = = Token : : BIT_NOT ) { <nl> + / / Check if the operand is a heap number . <nl> + __ CompareObjectType ( r0 , r1 , r1 , HEAP_NUMBER_TYPE ) ; <nl> + __ b ( ne , & slow ) ; <nl> + <nl> + / / Convert the heap number is r0 to an untagged integer in r1 . <nl> + GetInt32 ( masm , r0 , r1 , r2 , r3 , & slow ) ; <nl> + <nl> + / / Do the bitwise operation ( move negated ) and check if the result <nl> + / / fits in a smi . <nl> + Label try_float ; <nl> + __ mvn ( r1 , Operand ( r1 ) ) ; <nl> + __ add ( r2 , r1 , Operand ( 0x40000000 ) , SetCC ) ; <nl> + __ b ( mi , & try_float ) ; <nl> + __ mov ( r0 , Operand ( r1 , LSL , kSmiTagSize ) ) ; <nl> + __ b ( & done ) ; <nl> + <nl> + __ bind ( & try_float ) ; <nl> + if ( ! overwrite_ ) { <nl> + / / Allocate a fresh heap number , but don ' t overwrite r0 until <nl> + / / we ' re sure we can do it without going through the slow case <nl> + / / that needs the value in r0 . <nl> + AllocateHeapNumber ( masm , & slow , r2 , r3 , r4 ) ; <nl> + __ mov ( r0 , Operand ( r2 ) ) ; <nl> + } <nl> <nl> - / / The value of the expression is a smi that is not zero . Try <nl> - / / optimistic subtraction ' 0 - value ' . <nl> - __ rsb ( r1 , r0 , Operand ( 0 ) , SetCC ) ; <nl> - __ b ( vs , & slow ) ; <nl> + / / WriteInt32ToHeapNumberStub does not trigger GC , so we do not <nl> + / / have to set up a frame . <nl> + WriteInt32ToHeapNumberStub stub ( r1 , r0 , r2 ) ; <nl> + __ push ( lr ) ; <nl> + __ Call ( stub . GetCode ( ) , RelocInfo : : CODE_TARGET ) ; <nl> + __ pop ( lr ) ; <nl> + } else { <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> <nl> - __ mov ( r0 , Operand ( r1 ) ) ; / / Set r0 to result . <nl> + __ bind ( & done ) ; <nl> __ StubReturn ( 1 ) ; <nl> <nl> - / / Enter runtime system . <nl> + / / Handle the slow case by jumping to the JavaScript builtin . <nl> __ bind ( & slow ) ; <nl> __ push ( r0 ) ; <nl> - __ InvokeBuiltin ( Builtins : : UNARY_MINUS , JUMP_JS ) ; <nl> - <nl> - __ bind ( & not_smi ) ; <nl> - __ CompareObjectType ( r0 , r1 , r1 , HEAP_NUMBER_TYPE ) ; <nl> - __ b ( ne , & slow ) ; <nl> - / / r0 is a heap number . Get a new heap number in r1 . <nl> - if ( overwrite_ ) { <nl> - __ ldr ( r2 , FieldMemOperand ( r0 , HeapNumber : : kExponentOffset ) ) ; <nl> - __ eor ( r2 , r2 , Operand ( HeapNumber : : kSignMask ) ) ; / / Flip sign . <nl> - __ str ( r2 , FieldMemOperand ( r0 , HeapNumber : : kExponentOffset ) ) ; <nl> - } else { <nl> - AllocateHeapNumber ( masm , & slow , r1 , r2 , r3 ) ; <nl> - __ ldr ( r3 , FieldMemOperand ( r0 , HeapNumber : : kMantissaOffset ) ) ; <nl> - __ ldr ( r2 , FieldMemOperand ( r0 , HeapNumber : : kExponentOffset ) ) ; <nl> - __ str ( r3 , FieldMemOperand ( r1 , HeapNumber : : kMantissaOffset ) ) ; <nl> - __ eor ( r2 , r2 , Operand ( HeapNumber : : kSignMask ) ) ; / / Flip sign . <nl> - __ str ( r2 , FieldMemOperand ( r1 , HeapNumber : : kExponentOffset ) ) ; <nl> - __ mov ( r0 , Operand ( r1 ) ) ; <nl> + switch ( op_ ) { <nl> + case Token : : SUB : <nl> + __ InvokeBuiltin ( Builtins : : UNARY_MINUS , JUMP_JS ) ; <nl> + break ; <nl> + case Token : : BIT_NOT : <nl> + __ InvokeBuiltin ( Builtins : : BIT_NOT , JUMP_JS ) ; <nl> + break ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> } <nl> - __ StubReturn ( 1 ) ; <nl> } <nl> <nl> <nl>
Port bit not unary op stub to ARM .
v8/v8
ed224fc1dcd10407983014a2f9fd034da62e9f9b
2010-01-28T08:14:19Z
mmm a / xbmc / cores / VideoRenderers / LinuxRenderer . cpp <nl> ppp b / xbmc / cores / VideoRenderers / LinuxRenderer . cpp <nl> void CLinuxRenderer : : ReleaseImage ( int source , bool preserve ) <nl> <nl> / / transform from YUV to RGB <nl> struct SwsContext * context = m_dllSwScale - > sws_getContext ( m_image . width , m_image . height , PIX_FMT_YUV420P , m_backbuffer - > w , m_backbuffer - > h , PIX_FMT_BGRA , SWS_BILINEAR , NULL , NULL , NULL ) ; <nl> - uint8_t * src [ ] = { m_image . plane [ 0 ] , m_image . plane [ 1 ] , m_image . plane [ 2 ] , 0 } ; <nl> - int srcStride [ ] = { m_image . stride [ 0 ] , m_image . stride [ 1 ] , m_image . stride [ 2 ] , 0 } ; <nl> - uint8_t * dst [ ] = { ( uint8_t * ) m_backbuffer - > pixels , 0 , 0 , 0 } ; <nl> - int dstStride [ ] = { m_backbuffer - > pitch , 0 , 0 , 0 } ; <nl> + uint8_t * src [ ] = { m_image . plane [ 0 ] , m_image . plane [ 1 ] , m_image . plane [ 2 ] , 0 } ; <nl> + int srcStride [ ] = { m_image . stride [ 0 ] , m_image . stride [ 1 ] , m_image . stride [ 2 ] , 0 } ; <nl> + uint8_t * dst [ ] = { ( uint8_t * ) m_backbuffer - > pixels , 0 , 0 , 0 } ; <nl> + int dstStride [ ] = { m_backbuffer - > pitch , 0 , 0 , 0 } ; <nl> <nl> m_dllSwScale - > sws_scale ( context , src , srcStride , 0 , m_image . height , dst , dstStride ) ; <nl> <nl> - for ( int n = 0 ; n < 720 * 90 ; n + + ) { <nl> - * ( ( ( uint8_t * ) m_backbuffer - > pixels ) + ( 720 * 10 ) + n ) = 70 ; <nl> - } <nl> + for ( int n = 0 ; n < 720 * 90 ; n + + ) { <nl> + * ( ( ( uint8_t * ) m_backbuffer - > pixels ) + ( 720 * 10 ) + n ) = 70 ; <nl> + } <nl> <nl> m_dllSwScale - > sws_freeContext ( context ) ; <nl> <nl> mmm a / xbmc / cores / VideoRenderers / LinuxRendererGL . cpp <nl> ppp b / xbmc / cores / VideoRenderers / LinuxRendererGL . cpp <nl> void CLinuxRendererGL : : UploadYV12Texture ( int source ) <nl> struct SwsContext * context = m_dllSwScale - > sws_getContext ( im - > width , im - > height , PIX_FMT_YUV420P , <nl> im - > width , im - > height , PIX_FMT_BGRA , <nl> SWS_FAST_BILINEAR , NULL , NULL , NULL ) ; <nl> - uint8_t * src [ ] = { im - > plane [ 0 ] , im - > plane [ 1 ] , im - > plane [ 2 ] , 0 } ; <nl> - int srcStride [ ] = { im - > stride [ 0 ] , im - > stride [ 1 ] , im - > stride [ 2 ] , 0 } ; <nl> - uint8_t * dst [ ] = { m_rgbBuffer , 0 , 0 , 0 } ; <nl> - int dstStride [ ] = { m_sourceWidth * 4 , 0 , 0 , 0 } ; <nl> + uint8_t * src [ ] = { im - > plane [ 0 ] , im - > plane [ 1 ] , im - > plane [ 2 ] , 0 } ; <nl> + int srcStride [ ] = { im - > stride [ 0 ] , im - > stride [ 1 ] , im - > stride [ 2 ] , 0 } ; <nl> + uint8_t * dst [ ] = { m_rgbBuffer , 0 , 0 , 0 } ; <nl> + int dstStride [ ] = { m_sourceWidth * 4 , 0 , 0 , 0 } ; <nl> m_dllSwScale - > sws_scale ( context , src , srcStride , 0 , im - > height , dst , dstStride ) ; <nl> m_dllSwScale - > sws_freeContext ( context ) ; <nl> SetEvent ( m_eventTexturesDone [ source ] ) ; <nl>
cosmetics
xbmc/xbmc
a76b8eaf732038efa064636ee7732c48d01df463
2010-05-11T03:13:53Z
mmm a / dbms / src / TableFunctions / TableFunctionFile . cpp <nl> ppp b / dbms / src / TableFunctions / TableFunctionFile . cpp <nl> namespace DB <nl> <nl> StoragePtr TableFunctionFile : : executeImpl ( const ASTPtr & ast_function , const Context & context ) const <nl> { <nl> + switch ( context . getApplicationType ( ) ) { <nl> + case Context : : ApplicationType : : SERVER : throw Exception ( " ApplicationType : : SERVER " , 9999 ) ; <nl> + case Context : : ApplicationType : : CLIENT : throw Exception ( " ApplicationType : : CLIENT " , 9999 ) ; <nl> + case Context : : ApplicationType : : LOCAL : throw Exception ( " ApplicationType : : LOCAL " , 9999 ) ; <nl> + } <nl> + <nl> / / / Parse args <nl> ASTs & args_func = typeid_cast < ASTFunction & > ( * ast_function ) . children ; <nl> <nl>
table function file - test application context [ # add_table_function_file ]
ClickHouse/ClickHouse
aebc28d44b5f6506c9f7f7b5e9b6506bd170df52
2018-04-05T09:21:01Z
mmm a / stdlib / public / SDK / AVFoundation / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / AVFoundation / CMakeLists . txt <nl> add_swift_library ( swiftAVFoundation $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_ <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreAudio CoreData CoreGraphics CoreImage CoreMedia Dispatch Foundation IOKit ObjectiveC QuartzCore simd XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreAudio CoreGraphics CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreAudio CoreGraphics CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreAudio CoreGraphics CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreAudio CoreGraphics CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd XPC # auto - updated <nl> FRAMEWORK_DEPENDS AVFoundation <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_AVFOUNDATION_OSX } <nl> mmm a / stdlib / public / SDK / AssetsLibrary / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / AssetsLibrary / CMakeLists . txt <nl> add_swift_library ( swiftAssetsLibrary $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS IOS IOS_SIMULATOR <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS AssetsLibrary <nl> <nl> DEPLOYMENT_VERSION_IOS $ { SWIFTLIB_DEPLOYMENT_VERSION_ASSETSLIBRARY_IOS } <nl> mmm a / stdlib / public / SDK / CloudKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / CloudKit / CMakeLists . txt <nl> add_swift_library ( swiftCloudKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_ <nl> # configurations , but it causes no harm to specify it unconditionally . <nl> # The . / utils / find - overlay - dependencies . sh tool only touches the <nl> # OSX | IOS | TVOS | WATCHOS lines , so the standalone " os " lines remain . <nl> - SWIFT_MODULE_DEPENDS_OSX Darwin Contacts CoreGraphics CoreLocation Dispatch Foundation IOKit ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_OSX Darwin Contacts CoreGraphics CoreLocation Dispatch Foundation IOKit ObjectiveC XPC # auto - updated <nl> os <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin Contacts CoreLocation Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin Contacts CoreGraphics CoreLocation Dispatch Foundation ObjectiveC XPC # auto - updated <nl> os <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreLocation Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin Contacts CoreGraphics CoreLocation Dispatch Foundation ObjectiveC XPC # auto - updated <nl> os <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreLocation Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin Contacts CoreGraphics CoreLocation Dispatch Foundation ObjectiveC XPC # auto - updated <nl> os <nl> FRAMEWORK_DEPENDS_WEAK CloudKit <nl> <nl> mmm a / stdlib / public / SDK / Contacts / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / Contacts / CMakeLists . txt <nl> add_swift_library ( swiftContacts $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_ <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin CoreGraphics Dispatch Foundation IOKit ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS_WEAK Contacts <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_CONTACTS_OSX } <nl> mmm a / stdlib / public / SDK / CoreData / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / CoreData / CMakeLists . txt <nl> add_swift_library ( swiftCoreData $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_ <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> SWIFT_MODULE_DEPENDS_OSX Darwin CoreGraphics Dispatch Foundation IOKit ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS CoreData <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_COREDATA_OSX } <nl> mmm a / stdlib / public / SDK / CoreImage / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / CoreImage / CMakeLists . txt <nl> add_swift_library ( swiftCoreImage $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin CoreGraphics Dispatch Foundation IOKit ObjectiveC XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS_OSX QuartzCore <nl> FRAMEWORK_DEPENDS_IOS_TVOS CoreImage <nl> <nl> mmm a / stdlib / public / SDK / CoreLocation / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / CoreLocation / CMakeLists . txt <nl> add_swift_library ( swiftCoreLocation $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_ <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> SWIFT_MODULE_DEPENDS_OSX Darwin CoreGraphics Dispatch Foundation IOKit ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS CoreLocation <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_CORELOCATION_OSX } <nl> mmm a / stdlib / public / SDK / CoreMedia / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / CoreMedia / CMakeLists . txt <nl> add_swift_library ( swiftCoreMedia $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreAudio CoreData CoreGraphics CoreImage Dispatch Foundation IOKit ObjectiveC QuartzCore XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreAudio CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreAudio CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreAudio CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreAudio CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS CoreMedia <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_COREMEDIA_OSX } <nl> mmm a / stdlib / public / SDK / Foundation / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / Foundation / CMakeLists . txt <nl> add_swift_library ( swiftFoundation $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SD <nl> # framework , so we need to add it as a dependency . <nl> # The . / utils / find - overlay - dependencies . sh tool only touches the <nl> # OSX | IOS | TVOS | WATCHOS lines , so the standalone CoreGraphics lines remain . <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch ObjectiveC XPC # auto - updated <nl> CoreGraphics <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch ObjectiveC XPC # auto - updated <nl> CoreGraphics <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch ObjectiveC XPC # auto - updated <nl> CoreGraphics <nl> FRAMEWORK_DEPENDS Foundation <nl> <nl> mmm a / stdlib / public / SDK / GLKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / GLKit / CMakeLists . txt <nl> add_swift_library ( swiftGLKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_OVE <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreData CoreGraphics CoreImage Dispatch Foundation IOKit ObjectiveC QuartzCore simd XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore simd UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore simd UIKit # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC os QuartzCore simd UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore simd UIKit XPC # auto - updated <nl> FRAMEWORK_DEPENDS GLKit <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_GLKIT_OSX } <nl> mmm a / stdlib / public / SDK / GameplayKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / GameplayKit / CMakeLists . txt <nl> add_swift_library ( swiftGameplayKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_S <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreData CoreGraphics CoreImage Dispatch Foundation GLKit IOKit ObjectiveC QuartzCore SceneKit simd SpriteKit XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore SceneKit simd SpriteKit UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore SceneKit simd SpriteKit UIKit # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreAudio CoreGraphics CoreImage CoreMedia Dispatch Foundation GLKit ObjectiveC os QuartzCore SceneKit simd SpriteKit UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore SceneKit simd SpriteKit UIKit XPC # auto - updated <nl> FRAMEWORK_DEPENDS_WEAK GameplayKit <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_GAMEPLAYKIT_OSX } <nl> mmm a / stdlib / public / SDK / HomeKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / HomeKit / CMakeLists . txt <nl> add_swift_library ( swiftHomeKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_O <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC os QuartzCore UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore UIKit XPC # auto - updated <nl> UIKit # required in some configurations but not found by tool <nl> FRAMEWORK_DEPENDS_WEAK HomeKit <nl> <nl> mmm a / stdlib / public / SDK / Intents / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / Intents / CMakeLists . txt <nl> add_swift_library ( swiftIntents $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_O <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin CoreGraphics CoreLocation Dispatch Foundation IOKit ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreLocation Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreLocation Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreLocation Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreLocation Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS_WEAK Intents <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_INTENTS_OSX } <nl> mmm a / stdlib / public / SDK / MapKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / MapKit / CMakeLists . txt <nl> add_swift_library ( swiftMapKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_OV <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreData CoreGraphics CoreImage CoreLocation Dispatch Foundation IOKit ObjectiveC QuartzCore XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation ObjectiveC QuartzCore UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation ObjectiveC QuartzCore UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreLocation Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation ObjectiveC os QuartzCore UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation ObjectiveC QuartzCore UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation ObjectiveC QuartzCore UIKit XPC # auto - updated <nl> UIKit # required in some configurations but not found by tool <nl> FRAMEWORK_DEPENDS MapKit <nl> <nl> mmm a / stdlib / public / SDK / Photos / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / Photos / CMakeLists . txt <nl> add_swift_library ( swiftPhotos $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_OV <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin AVFoundation CoreAudio CoreGraphics CoreImage CoreLocation CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin AVFoundation CoreAudio CoreGraphics CoreImage CoreLocation CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd UIKit # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin AVFoundation CoreAudio CoreData CoreGraphics CoreImage CoreLocation CoreMedia Dispatch Foundation ObjectiveC os QuartzCore simd UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin AVFoundation CoreAudio CoreData CoreGraphics CoreImage CoreLocation CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd UIKit XPC # auto - updated <nl> FRAMEWORK_DEPENDS Photos <nl> <nl> DEPLOYMENT_VERSION_IOS $ { SWIFTLIB_DEPLOYMENT_VERSION_PHOTOS_IOS } <nl> mmm a / stdlib / public / SDK / QuartzCore / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / QuartzCore / CMakeLists . txt <nl> add_swift_library ( swiftQuartzCore $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SD <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin CoreGraphics CoreImage Dispatch Foundation IOKit ObjectiveC XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics Dispatch Foundation ObjectiveC XPC # auto - updated <nl> FRAMEWORK_DEPENDS QuartzCore <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_QUARTZCORE_OSX } <nl> mmm a / stdlib / public / SDK / SceneKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / SceneKit / CMakeLists . txt <nl> add_swift_library ( swiftSceneKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_ <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreData CoreGraphics CoreImage Dispatch Foundation GLKit IOKit ObjectiveC QuartzCore simd XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC simd # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreAudio CoreGraphics CoreImage CoreMedia Dispatch Foundation GLKit ObjectiveC os QuartzCore simd UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore simd UIKit XPC # auto - updated <nl> UIKit # required in some configurations but not found by tool <nl> FRAMEWORK_DEPENDS_WEAK SceneKit <nl> <nl> mmm a / stdlib / public / SDK / SpriteKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / SpriteKit / CMakeLists . txt <nl> add_swift_library ( swiftSpriteKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreData CoreGraphics CoreImage Dispatch Foundation GLKit IOKit ObjectiveC QuartzCore simd XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC simd UIKit # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC os QuartzCore simd UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC QuartzCore simd UIKit XPC # auto - updated <nl> FRAMEWORK_DEPENDS SpriteKit <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_SPRITEKIT_OSX } <nl> mmm a / stdlib / public / SDK / UIKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / UIKit / CMakeLists . txt <nl> add_swift_library ( swiftUIKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_OVE <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore # auto - updated <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics Dispatch Foundation ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC os QuartzCore XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreImage Dispatch Foundation ObjectiveC QuartzCore XPC # auto - updated <nl> SWIFT_COMPILE_FLAGS_WATCHOS - Xfrontend - disable - autolink - framework - Xfrontend CoreText <nl> FRAMEWORK_DEPENDS UIKit <nl> <nl> mmm a / stdlib / public / SDK / WatchKit / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / WatchKit / CMakeLists . txt <nl> add_swift_library ( swiftWatchKit $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_ <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> TARGET_SDKS IOS IOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation MapKit ObjectiveC QuartzCore UIKit # auto - updated <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreLocation Dispatch Foundation HomeKit MapKit ObjectiveC SceneKit simd UIKit # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation MapKit ObjectiveC os QuartzCore UIKit XPC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreGraphics CoreImage CoreLocation Dispatch Foundation HomeKit MapKit ObjectiveC QuartzCore SceneKit simd UIKit XPC # auto - updated <nl> FRAMEWORK_DEPENDS_WEAK WatchKit <nl> SWIFT_COMPILE_FLAGS_WATCHOS - Xfrontend - disable - autolink - framework - Xfrontend CoreText <nl> <nl> mmm a / stdlib / public / SDK / os / CMakeLists . txt <nl> ppp b / stdlib / public / SDK / os / CMakeLists . txt <nl> add_swift_library ( swiftos $ { SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES } IS_SDK_OVERLA <nl> SWIFT_COMPILE_FLAGS " $ { SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS } " <nl> LINK_FLAGS " $ { SWIFT_RUNTIME_SWIFT_LINK_FLAGS } " <nl> SWIFT_MODULE_DEPENDS_OSX Darwin Dispatch ObjectiveC XPC # auto - updated <nl> - SWIFT_MODULE_DEPENDS_IOS Darwin ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch ObjectiveC XPC # auto - updated <nl> Dispatch # required in some configurations but not found by tool <nl> - SWIFT_MODULE_DEPENDS_TVOS Darwin ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch ObjectiveC XPC # auto - updated <nl> Dispatch # required in some configurations but not found by tool <nl> - SWIFT_MODULE_DEPENDS_WATCHOS Darwin ObjectiveC # auto - updated <nl> + SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch ObjectiveC XPC # auto - updated <nl> Dispatch # required in some configurations but not found by tool <nl> <nl> DEPLOYMENT_VERSION_OSX $ { SWIFTLIB_DEPLOYMENT_VERSION_OS_OSX } <nl> mmm a / utils / find - overlay - dependencies . sh <nl> ppp b / utils / find - overlay - dependencies . sh <nl> CMAKE_DEPENDS_NAME [ watchos ] = " SWIFT_MODULE_DEPENDS_WATCHOS " <nl> echo $ 1 <nl> for sdk in $ { ( k ) SDKS } ; do <nl> arch = $ SDKS [ $ sdk ] <nl> - printf " % s : \ n \ t " " $ sdk " <nl> - deps = $ ( echo " @ import $ 1 ; " | xcrun - sdk $ sdk clang - arch $ arch - x objective - c - - M - fmodules 2 > / dev / null ) <nl> + sdkfull = " $ sdk $ SUFFIX " <nl> + printf " % s : \ n \ t " " $ sdkfull " <nl> + deps = $ ( echo " @ import $ 1 ; " | xcrun - sdk " $ { sdkfull } " clang - arch $ arch - x objective - c - F $ ( xcrun - show - sdk - path - sdk " $ { sdkfull } " ) / System / Library / PrivateFrameworks - - M - fmodules 2 > / dev / null ) <nl> if [ [ $ ? ! = 0 ] ] ; then <nl> # Clear the cmake file of this unsupported platform and loop <nl> echo " unsupported " <nl>
overlays : Update dependencies and amend the script to add headers .
apple/swift
9a289310010196a97f248c1d226c947fc08ccf5d
2017-04-27T01:27:44Z
new file mode 100644 <nl> index 00000000000 . . 184d0808d08 <nl> mmm / dev / null <nl> ppp b / Documentation / Examples / foxx - doc - comment <nl> <nl> + / * * Get all foxxes <nl> + * <nl> + * If you want to get all foxxes , please use this <nl> + * method to do that . <nl> + * / <nl> + app . get ( " / foxxes " , function ( ) { <nl> + / / . . . <nl> + } ) ; <nl> mmm a / Documentation / Manual / NewFeatures13 . md <nl> ppp b / Documentation / Manual / NewFeatures13 . md <nl> another : <nl> db . accounts . update ( account1 , { amount : account1 . amount - amount } ) ; <nl> db . accounts . update ( account2 , { amount : account2 . amount + amount } ) ; <nl> <nl> - / * will commit the transaction and return the value true * / <nl> + / / will commit the transaction and return the value true <nl> return true ; <nl> } <nl> } ) ; <nl> mmm a / Documentation / Scripts / generateTOC . py <nl> ppp b / Documentation / Scripts / generateTOC . py <nl> <nl> <nl> DEBUG = False <nl> <nl> + print ' # Auto - generated aliases ' <nl> + print ' ' <nl> + <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # # # @ brief parse file <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> mmm a / Documentation / UserManual / AqlExamples . md <nl> ppp b / Documentation / UserManual / AqlExamples . md <nl> For example , to get the 3 ` ageGroup ` s with the most users in them : <nl> FILTER u . active = = true <nl> COLLECT ageGroup = FLOOR ( u . age / 5 ) * 5 INTO group <nl> LET numUsers = LENGTH ( group ) <nl> - FILTER numUsers > 2 / * group must contain at least 3 users in order to qualify * / <nl> + FILTER numUsers > 2 / / group must contain at least 3 users in order to qualify <nl> SORT numUsers DESC <nl> LIMIT 0 , 3 <nl> RETURN { <nl> mmm a / Documentation / UserManual / Arangosh . md <nl> ppp b / Documentation / UserManual / Arangosh . md <nl> You can use this to define your own extra variables and functions that you need <nl> For example , you could put the following into the ` . arangosh . rc ` file in your home <nl> directory : <nl> <nl> - / * var keyword omitted intentionally , <nl> - otherwise " timed " would not survive the scope of this script * / <nl> + / / var keyword omitted intentionally , <nl> + / / otherwise " timed " would not survive the scope of this script <nl> timed = function ( cb ) { <nl> var internal = require ( " internal " ) ; <nl> var start = internal . time ( ) ; <nl> - <nl> cb ( ) ; <nl> - <nl> internal . print ( " execution took : " , internal . time ( ) - start ) ; <nl> - } <nl> + } ; <nl> <nl> This will make a function named ` timed ` available in _arangosh_ in the global scope . <nl> <nl> mmm a / Documentation / UserManual / Foxx . md <nl> ppp b / Documentation / UserManual / Foxx . md <nl> If you now want to document your route , you can use JSDoc style comments ( a <nl> multiline comment block with the first line starting with ` / * * ` instead <nl> of ` / * ` ) above your routes to do that : <nl> <nl> - / * * Get all Foxes <nl> - * <nl> - * If you want to get all foxes , please use this <nl> - * method to do that . <nl> - * / <nl> - app . get ( " / foxes " , function ( ) { <nl> - / / . . . <nl> - } ) ; <nl> + @ verbinclude foxx - doc - comment <nl> <nl> The first line will be treated as a summary ( For optical reasons in the <nl> produced documentation , the summary is restricted to 60 characters ) . All <nl> mmm a / Documentation / UserManual / Transactions . md <nl> ppp b / Documentation / UserManual / Transactions . md <nl> attribute : <nl> write : " users " <nl> } , <nl> action : function ( ) { <nl> - / * all operations go here * / <nl> + / / all operations go here <nl> } <nl> } ) ; <nl> <nl> of a Javascript function : <nl> collections : { <nl> write : " users " <nl> } , <nl> - action : " function ( ) { / * all operations go here * / } " <nl> + action : " function ( ) { doSomething ( ) ; } " <nl> } ) ; <nl> <nl> Please note that any operations specified in ` action ` will be executed on the <nl> be thrown and not caught inside the transaction : <nl> var db = require ( " internal " ) . db ; <nl> db . users . save ( { _key : " hello " } ) ; <nl> <nl> - / * will abort and roll back the transaction * / <nl> + / / will abort and roll back the transaction <nl> throw " doh ! " ; <nl> } <nl> } ) ; <nl> case , the user can return any legal Javascript value from the function : <nl> var db = require ( " internal " ) . db ; <nl> db . users . save ( { _key : " hello " } ) ; <nl> <nl> - / * will commit the transaction and return the value " hello " * / <nl> + / / will commit the transaction and return the value " hello " <nl> return " hello " ; <nl> } <nl> } ) ; <nl> The ` c1 ` collection needs to be declared in the ` write ` attribute of the <nl> The ` action ` attribute contains the actual transaction code to be executed . <nl> This code contains all data modification operations ( 3 in this example ) . <nl> <nl> - / * setup * / <nl> + / / setup <nl> db . _create ( " c1 " ) ; <nl> <nl> db . _executeTransaction ( { <nl> This code contains all data modification operations ( 3 in this example ) . <nl> } <nl> } ) ; <nl> <nl> - db . c1 . count ( ) ; / * 3 * / <nl> + db . c1 . count ( ) ; / / 3 <nl> <nl> <nl> Aborting the transaction by throwing an exception in the ` action ` function <nl> will revert all changes , so as if the transaction never happened : <nl> <nl> - / * setup * / <nl> + / / setup <nl> db . _create ( " c1 " ) ; <nl> <nl> db . _executeTransaction ( { <nl> will revert all changes , so as if the transaction never happened : <nl> action : function ( ) { <nl> var db = require ( " internal " ) . db ; <nl> db . c1 . save ( { _key : " key1 " } ) ; <nl> - db . c1 . count ( ) ; / * 1 * / <nl> + db . c1 . count ( ) ; / / 1 <nl> <nl> db . c1 . save ( { _key : " key2 " } ) ; <nl> - db . c1 . count ( ) ; / * 2 * / <nl> + db . c1 . count ( ) ; / / 2 <nl> <nl> throw " doh ! " ; <nl> } <nl> } ) ; <nl> <nl> - db . c1 . count ( ) ; / * 0 * / <nl> + db . c1 . count ( ) ; / / 0 <nl> <nl> <nl> The automatic rollback is also executed when an internal exception is thrown <nl> at some point during transaction execution : <nl> <nl> - / * setup * / <nl> + / / setup <nl> db . _create ( " c1 " ) ; <nl> <nl> db . _executeTransaction ( { <nl> at some point during transaction execution : <nl> var db = require ( " internal " ) . db ; <nl> db . c1 . save ( { _key : " key1 " } ) ; <nl> <nl> - / * will throw duplicate a key error , not explicitly requested by the user * / <nl> + / / will throw duplicate a key error , not explicitly requested by the user <nl> db . c1 . save ( { _key : " key1 " } ) ; <nl> <nl> - / * we ' ll never get here . . . * / <nl> + / / we ' ll never get here . . . <nl> } <nl> } ) ; <nl> <nl> - db . c1 . count ( ) ; / * 0 * / <nl> + db . c1 . count ( ) ; / / 0 <nl> <nl> <nl> As required by the * consistency * principle , aborting or rolling back a <nl> transaction will also restore secondary indexes to the state at transaction <nl> start . The following example using a cap constraint should illustrate that : <nl> <nl> - / * setup * / <nl> + / / setup <nl> db . _create ( " c1 " ) ; <nl> <nl> - / * limit the number of documents to 3 * / <nl> + / / limit the number of documents to 3 <nl> db . c1 . ensureCapConstraint ( 3 ) ; <nl> <nl> - / * insert 3 documents * / <nl> + / / insert 3 documents <nl> db . c1 . save ( { _key : " key1 " } ) ; <nl> db . c1 . save ( { _key : " key2 " } ) ; <nl> db . c1 . save ( { _key : " key3 " } ) ; <nl> <nl> - / * this will push out key1 * / <nl> - / * we now have these keys : [ " key1 " , " key2 " , " key3 " ] * / <nl> + / / this will push out key1 <nl> + / / we now have these keys : [ " key1 " , " key2 " , " key3 " ] <nl> db . c1 . save ( { _key : " key4 " } ) ; <nl> <nl> <nl> start . The following example using a cap constraint should illustrate that : <nl> } , <nl> action : function ( ) { <nl> var db = require ( " internal " ) . db ; <nl> - / * this will push out key2 . we now have keys [ " key3 " , " key4 " , " key5 " ] * / <nl> + / / this will push out key2 . we now have keys [ " key3 " , " key4 " , " key5 " ] <nl> db . c1 . save ( { _key : " key5 " } ) ; <nl> <nl> - / * will abort the transaction * / <nl> + / / will abort the transaction <nl> throw " doh ! " <nl> } <nl> } ) ; <nl> <nl> - / * we now have these keys back : [ " key2 " , " key3 " , " key4 " ] * / <nl> + / / we now have these keys back : [ " key2 " , " key3 " , " key4 " ] <nl> <nl> Cross - collection transactions <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> There ' s also the possibility to run a transaction across multiple collections . <nl> In this case , multiple collections need to be declared in the ` collections ` <nl> attribute , e . g . : <nl> <nl> - / * setup * / <nl> + / / setup <nl> db . _create ( " c1 " ) ; <nl> db . _create ( " c2 " ) ; <nl> <nl> attribute , e . g . : <nl> } <nl> } ) ; <nl> <nl> - db . c1 . count ( ) ; / * 1 * / <nl> - db . c2 . count ( ) ; / * 1 * / <nl> + db . c1 . count ( ) ; / / 1 <nl> + db . c2 . count ( ) ; / / 1 <nl> <nl> <nl> Again , throwing an exception from inside the ` action ` function will make the <nl> transaction abort and roll back all changes in all collections : <nl> <nl> - / * setup * / <nl> + / / setup <nl> db . _create ( " c1 " ) ; <nl> db . _create ( " c2 " ) ; <nl> <nl> transaction abort and roll back all changes in all collections : <nl> db . c2 . save ( { _key : " key " + i } ) ; <nl> } <nl> <nl> - db . c1 . count ( ) ; / * 100 * / <nl> - db . c2 . count ( ) ; / * 100 * / <nl> + db . c1 . count ( ) ; / / 100 <nl> + db . c2 . count ( ) ; / / 100 <nl> <nl> - / * abort * / <nl> + / / abort <nl> throw " doh ! " <nl> } <nl> } ) ; <nl> <nl> - db . c1 . count ( ) ; / * 0 * / <nl> - db . c2 . count ( ) ; / * 0 * / <nl> + db . c1 . count ( ) ; / / 0 <nl> + db . c2 . count ( ) ; / / 0 <nl> <nl> Passing parameters to transactions { # TransactionsParameters } <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> Example : <nl> read : " users " <nl> } , <nl> action : function ( ) { <nl> - / * execute an AQL query that traverses a graph starting at a " users " vertex . <nl> - it is yet unknown into which other collections the query will traverse * / <nl> + / / execute an AQL query that traverses a graph starting at a " users " vertex . <nl> + / / it is yet unknown into which other collections the query will traverse <nl> db . _createStatement ( { <nl> query : " FOR t IN TRAVERSAL ( users , connections , " users / 1234 " , " any " , { } ) RETURN t " <nl> } ) . execute ( ) . toArray ( ) . forEach ( function ( d ) { <nl> - / * . . . * / <nl> + / / . . . <nl> } ) ; <nl> } <nl> } ) ; <nl> into one transaction . <nl> Additionally , transactions in ArangoDB cannot be nested , i . e . a transaction <nl> must not call any other transaction . If an attempt is made to call a transaction <nl> from inside a running transaction , the server will throw error ` 1651 ( nested <nl> - transactions detected ` ) . <nl> + transactions detected ) ` . <nl> <nl> It is also disallowed to execute user transaction on some of ArangoDB ' s own system <nl> collections . This shouldn ' t be a problem for regular usage as system collections will <nl> mmm a / Documentation / UserManual / Traversals . md <nl> ppp b / Documentation / UserManual / Traversals . md <nl> To set up the collections and populate them with initial data , the following scr <nl> db . _create ( " v " ) ; <nl> db . _createEdgeCollection ( " e " ) ; <nl> <nl> - / * vertices : root node * / <nl> + / / vertices : root node <nl> db . v . save ( { _key : " world " , name : " World " , type : " root " } ) ; <nl> <nl> - / * vertices : continents * / <nl> + / / vertices : continents <nl> db . v . save ( { _key : " continent - africa " , name : " Africa " , type : " continent " } ) ; <nl> db . v . save ( { _key : " continent - asia " , name : " Asia " , type : " continent " } ) ; <nl> db . v . save ( { _key : " continent - australia " , name : " Australia " , type : " continent " } ) ; <nl> To set up the collections and populate them with initial data , the following scr <nl> db . v . save ( { _key : " continent - north - america " , name : " North America " , type : " continent " } ) ; <nl> db . v . save ( { _key : " continent - south - america " , name : " South America " , type : " continent " } ) ; <nl> <nl> - / * vertices : countries * / <nl> + / / vertices : countries <nl> db . v . save ( { _key : " country - afghanistan " , name : " Afghanistan " , type : " country " , code : " AFG " } ) ; <nl> db . v . save ( { _key : " country - albania " , name : " Albania " , type : " country " , code : " ALB " } ) ; <nl> db . v . save ( { _key : " country - algeria " , name : " Algeria " , type : " country " , code : " DZA " } ) ; <nl> To set up the collections and populate them with initial data , the following scr <nl> db . v . save ( { _key : " country - germany " , name : " Germany " , type : " country " , code : " DEU " } ) ; <nl> db . v . save ( { _key : " country - people - s - republic - of - china " , name : " People ' s Republic of China " , type : " country " , code : " CHN " } ) ; <nl> <nl> - / * vertices : capitals * / <nl> + / / vertices : capitals <nl> db . v . save ( { _key : " capital - algiers " , name : " Algiers " , type : " capital " } ) ; <nl> db . v . save ( { _key : " capital - andorra - la - vella " , name : " Andorra la Vella " , type : " capital " } ) ; <nl> db . v . save ( { _key : " capital - asmara " , name : " Asmara " , type : " capital " } ) ; <nl> To set up the collections and populate them with initial data , the following scr <nl> db . v . save ( { _key : " capital - yaounde " , name : " Yaounde " , type : " capital " } ) ; <nl> db . v . save ( { _key : " capital - zagreb " , name : " Zagreb " , type : " capital " } ) ; <nl> <nl> - / * edges : continent - > world * / <nl> + / / edges : continent - > world <nl> db . e . save ( " v / continent - africa " , " v / world " , { type : " is - in " } ) ; <nl> db . e . save ( " v / continent - asia " , " v / world " , { type : " is - in " } ) ; <nl> db . e . save ( " v / continent - australia " , " v / world " , { type : " is - in " } ) ; <nl> To set up the collections and populate them with initial data , the following scr <nl> db . e . save ( " v / continent - north - america " , " v / world " , { type : " is - in " } ) ; <nl> db . e . save ( " v / continent - south - america " , " v / world " , { type : " is - in " } ) ; <nl> <nl> - / * edges : country - > continent * / <nl> + / / edges : country - > continent <nl> db . e . save ( " v / country - afghanistan " , " v / continent - asia " , { type : " is - in " } ) ; <nl> db . e . save ( " v / country - albania " , " v / continent - europe " , { type : " is - in " } ) ; <nl> db . e . save ( " v / country - algeria " , " v / continent - africa " , { type : " is - in " } ) ; <nl> To set up the collections and populate them with initial data , the following scr <nl> db . e . save ( " v / country - germany " , " v / continent - europe " , { type : " is - in " } ) ; <nl> db . e . save ( " v / country - people - s - republic - of - china " , " v / continent - asia " , { type : " is - in " } ) ; <nl> <nl> - / * edges : capital - > country * / <nl> + / / edges : capital - > country <nl> db . e . save ( " v / capital - algiers " , " v / country - algeria " , { type : " is - in " } ) ; <nl> db . e . save ( " v / capital - andorra - la - vella " , " v / country - andorra " , { type : " is - in " } ) ; <nl> db . e . save ( " v / capital - asmara " , " v / country - eritrea " , { type : " is - in " } ) ; <nl>
fixed documentation errors
arangodb/arangodb
1500318dd40aad9f817aebcab3422ebc122b3fc7
2014-01-27T13:50:17Z
mmm a / README . md <nl> ppp b / README . md <nl> export CMAKE_PREFIX_PATH = " $ ( dirname $ ( which conda ) ) / . . / " # [ anaconda root direct <nl> <nl> # Install basic dependencies <nl> conda install numpy pyyaml mkl mkl - include setuptools cmake cffi typing <nl> - conda install - c intel mkl - dnn <nl> + conda install - c mingfeima mkldnn <nl> <nl> # Add LAPACK support for the GPU <nl> conda install - c pytorch magma - cuda80 # or magma - cuda90 if CUDA 9 <nl>
Use mingfeima ' s mkldnn ( )
pytorch/pytorch
6e1de968d65a95a49aa50e8db4c8e7fe5a8ae0c8
2018-05-31T01:46:39Z
mmm a / include / internal / catch_capture . hpp <nl> ppp b / include / internal / catch_capture . hpp <nl> <nl> <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - # define INTERNAL_CATCH_TEST ( macroName , resultDisposition , expr ) \ <nl> + # define INTERNAL_CATCH_TEST ( macroName , resultDisposition , . . . ) \ <nl> do { \ <nl> - Catch : : ResultBuilder __catchResult ( macroName , CATCH_INTERNAL_LINEINFO , # expr , resultDisposition ) ; \ <nl> + Catch : : ResultBuilder __catchResult ( macroName , CATCH_INTERNAL_LINEINFO , # __VA_ARGS__ , resultDisposition ) ; \ <nl> try { \ <nl> CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ <nl> - ( __catchResult < = expr ) . endExpression ( ) ; \ <nl> + ( __catchResult < = __VA_ARGS__ ) . endExpression ( ) ; \ <nl> CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ <nl> } \ <nl> catch ( . . . ) { \ <nl> __catchResult . useActiveException ( resultDisposition ) ; \ <nl> } \ <nl> INTERNAL_CATCH_REACT ( __catchResult ) \ <nl> - } while ( Catch : : isTrue ( false & & static_cast < bool > ( ! ! ( expr ) ) ) ) / / expr here is never evaluated at runtime but it forces the compiler to give it a look <nl> + } while ( Catch : : isTrue ( false & & static_cast < bool > ( ! ! ( __VA_ARGS__ ) ) ) ) / / the expression here is never evaluated at runtime but it forces the compiler to give it a look <nl> / / The double negation silences MSVC ' s C4800 warning , the static_cast forces short - circuit evaluation if the type has overloaded & & . <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl>
Made INTERNAL_CATCH_TEST variadic so commas in assertions work
catchorg/Catch2
d17d94e45d3223985158ac7cda8b9fead191da4f
2017-04-26T15:10:18Z
mmm a / src / builtins / ia32 / builtins - ia32 . cc <nl> ppp b / src / builtins / ia32 / builtins - ia32 . cc <nl> static void AdvanceBytecodeOffsetOrReturn ( MacroAssembler * masm , <nl> / / The function builds an interpreter frame . See InterpreterFrameConstants in <nl> / / frames . h for its layout . <nl> void Builtins : : Generate_InterpreterEntryTrampoline ( MacroAssembler * masm ) { <nl> + Assembler : : SupportsRootRegisterScope supports_root_register ( masm ) ; <nl> ProfileEntryHookStub : : MaybeCallEntryHook ( masm ) ; <nl> <nl> __ VerifyRootRegister ( ) ; <nl> void Builtins : : Generate_InterpreterEntryTrampoline ( MacroAssembler * masm ) { <nl> static void Generate_InterpreterPushArgs ( MacroAssembler * masm , <nl> Register array_limit , <nl> Register start_address ) { <nl> + Assembler : : SupportsRootRegisterScope supports_root_register ( masm ) ; <nl> / / mmmmmmmmm - - S t a t e mmmmmmmmmmmm - <nl> / / - - start_address : Pointer to the last argument in the args array . <nl> / / - - array_limit : Pointer to one before the first argument in the <nl> static void Generate_InterpreterPushArgs ( MacroAssembler * masm , <nl> void Builtins : : Generate_InterpreterPushArgsThenCallImpl ( <nl> MacroAssembler * masm , ConvertReceiverMode receiver_mode , <nl> InterpreterPushArgsMode mode ) { <nl> + Assembler : : SupportsRootRegisterScope supports_root_register ( masm ) ; <nl> DCHECK ( mode ! = InterpreterPushArgsMode : : kArrayFunction ) ; <nl> / / mmmmmmmmm - - S t a t e mmmmmmmmmmmm - <nl> / / - - eax : the number of arguments ( not including the receiver ) <nl> void Builtins : : Generate_InterpreterPushArgsThenCallImpl ( <nl> / / - - edi : the target to call ( can be any Object ) . <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> - const Register scratch = ebx ; <nl> + const Register scratch = edx ; <nl> const Register argv = ecx ; <nl> <nl> Label stack_overflow ; <nl> + / / Add a stack check before pushing the arguments . <nl> + Generate_StackOverflowCheck ( masm , eax , scratch , & stack_overflow , true ) ; <nl> + <nl> + __ movd ( xmm0 , eax ) ; / / Spill number of arguments . <nl> + <nl> / / Compute the expected number of arguments . <nl> __ mov ( scratch , eax ) ; <nl> __ add ( scratch , Immediate ( 1 ) ) ; / / Add one for receiver . <nl> <nl> - / / Add a stack check before pushing the arguments . We need an extra register <nl> - / / to perform a stack check . So push it onto the stack temporarily . This <nl> - / / might cause stack overflow , but it will be detected by the check . <nl> - __ Push ( edi ) ; <nl> - Generate_StackOverflowCheck ( masm , scratch , edx , & stack_overflow ) ; <nl> - __ Pop ( edi ) ; <nl> - <nl> / / Pop return address to allow tail - call after pushing arguments . <nl> - __ PopReturnAddressTo ( edx ) ; <nl> + __ PopReturnAddressTo ( eax ) ; <nl> <nl> / / Push " undefined " as the receiver arg if we need to . <nl> if ( receiver_mode = = ConvertReceiverMode : : kNullOrUndefined ) { <nl> void Builtins : : Generate_InterpreterPushArgsThenCallImpl ( <nl> <nl> if ( mode = = InterpreterPushArgsMode : : kWithFinalSpread ) { <nl> __ Pop ( ecx ) ; / / Pass the spread in a register <nl> + __ PushReturnAddressFrom ( eax ) ; <nl> + __ movd ( eax , xmm0 ) ; / / Restore number of arguments . <nl> __ sub ( eax , Immediate ( 1 ) ) ; / / Subtract one for spread <nl> - __ PushReturnAddressFrom ( edx ) ; <nl> __ Jump ( BUILTIN_CODE ( masm - > isolate ( ) , CallWithSpread ) , <nl> RelocInfo : : CODE_TARGET ) ; <nl> } else { <nl> - __ PushReturnAddressFrom ( edx ) ; <nl> + __ PushReturnAddressFrom ( eax ) ; <nl> + __ movd ( eax , xmm0 ) ; / / Restore number of arguments . <nl> __ Jump ( masm - > isolate ( ) - > builtins ( ) - > Call ( ConvertReceiverMode : : kAny ) , <nl> RelocInfo : : CODE_TARGET ) ; <nl> } <nl> <nl> __ bind ( & stack_overflow ) ; <nl> { <nl> - / / Pop the temporary registers , so that return address is on top of stack . <nl> - __ Pop ( edi ) ; <nl> - <nl> __ TailCallRuntime ( Runtime : : kThrowStackOverflow ) ; <nl> <nl> / / This should be unreachable . <nl>
[ ia32 , root ] Preserve kRootRegister ( ebx ) in several builtins
v8/v8
d333075033756a3773e9d96a9f57105916b4d41c
2018-09-19T15:42:14Z
mmm a / hphp / runtime / base / runtime - option . cpp <nl> ppp b / hphp / runtime / base / runtime - option . cpp <nl> static inline uint32_t resetProfCountersDefault ( ) { <nl> } <nl> <nl> static inline int retranslateAllRequestDefault ( ) { <nl> - return RuntimeOption : : ServerExecutionMode ( ) & & <nl> - arch ( ) ! = Arch : : ARM ? 3000 : 0 ; <nl> + return RuntimeOption : : ServerExecutionMode ( ) ? 3000 : 0 ; <nl> } <nl> <nl> uint64_t ahotDefault ( ) { <nl> mmm a / hphp / runtime / vm / jit / align - arm . cpp <nl> ppp b / hphp / runtime / vm / jit / align - arm . cpp <nl> struct AlignImpl { <nl> <nl> static void pad ( CodeBlock & cb , AlignContext context , size_t bytes ) { <nl> vixl : : MacroAssembler a { cb } ; <nl> - auto const start = reinterpret_cast < char * > ( cb . frontier ( ) ) ; <nl> + auto const start = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> <nl> switch ( context ) { <nl> - case AlignContext : : Live : <nl> + case AlignContext : : Live : { <nl> assert ( ( ( bytes & 3 ) = = 0 ) & & " alignment must be multiple of 4 " ) ; <nl> for ( ; bytes > 0 ; bytes - = 4 ) { <nl> a . Nop ( ) ; <nl> } <nl> - __builtin___clear_cache ( start , reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> + __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> return ; <nl> - <nl> - case AlignContext : : Dead : <nl> + } <nl> + case AlignContext : : Dead : { <nl> if ( bytes > 4 ) { <nl> a . Brk ( ) ; <nl> bytes - = 4 ; <nl> } <nl> - __builtin___clear_cache ( start , reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> + __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> if ( bytes > 0 ) pad ( cb , AlignContext : : Live , bytes ) ; <nl> return ; <nl> + } <nl> } <nl> not_reached ( ) ; <nl> } <nl> mmm a / hphp / runtime / vm / jit / func - guard - arm . cpp <nl> ppp b / hphp / runtime / vm / jit / func - guard - arm . cpp <nl> void emitFuncGuard ( const Func * func , CodeBlock & cb , CGMeta & fixups ) { <nl> vixl : : MacroAssembler a { cb } ; <nl> vixl : : Label after_data ; <nl> vixl : : Label target_data ; <nl> - auto const start = reinterpret_cast < char * > ( cb . frontier ( ) ) ; <nl> + auto const start = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> <nl> assertx ( arm : : abi ( CodeKind : : CrossTrace ) . gpUnreserved . contains ( vixl : : x0 ) ) ; <nl> <nl> void emitFuncGuard ( const Func * func , CodeBlock & cb , CGMeta & fixups ) { <nl> a . dc64 ( tc : : ustubs ( ) . funcPrologueRedispatch ) ; <nl> a . bind ( & after_data ) ; <nl> <nl> - __builtin___clear_cache ( start , reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> + __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> } <nl> <nl> TCA funcGuardFromPrologue ( TCA prologue , const Func * / * func * / ) { <nl> if ( ! isPrologueStub ( prologue ) ) { <nl> - / / Typically a func guard is a smashable movq followed by an ldr , cmp , b , <nl> - / / br , and a 64 bit target . However , relocation can shorten the sequence , <nl> - / / so search backwards until the smashable movq is found . <nl> - for ( int length = 0 ; length < ( 5 * 4 ) + 8 ; length + = 4 ) { <nl> + / / Typically a func guard is a smashable movq followed by an ldr , cmp , b . eq , <nl> + / / ldr , br , and a 64 bit target . However , relocation can shorten the <nl> + / / sequence , so search backwards until the smashable movq is found . <nl> + for ( int length = 0 ; length < = ( 5 * 4 ) + 8 ; length + = 4 ) { <nl> TCA inst = prologue - ( smashableMovqLen ( ) + length ) ; <nl> if ( isSmashableMovq ( inst ) ) return inst ; <nl> } <nl> mmm a / hphp / runtime / vm / jit / relocation - arm . cpp <nl> ppp b / hphp / runtime / vm / jit / relocation - arm . cpp <nl> struct JmpOutOfRange : std : : exception { } ; <nl> * Maintains various state during relocation . <nl> * / <nl> struct Env { <nl> - explicit Env ( RelocationInfo & rel , CodeBlock & destBlock , <nl> + explicit Env ( RelocationInfo & rel , <nl> + CodeBlock & srcBlock , CodeBlock & destBlock , <nl> TCA start , TCA end , CGMeta & meta , TCA * exitAddr ) <nl> : rel ( rel ) <nl> + , srcBlock ( srcBlock ) <nl> , destBlock ( destBlock ) <nl> , start ( start ) <nl> , end ( end ) <nl> struct Env { <nl> } <nl> <nl> RelocationInfo & rel ; <nl> + CodeBlock & srcBlock ; <nl> CodeBlock & destBlock ; <nl> const TCA start , end ; <nl> const CGMeta & meta ; <nl> InstrSet findLiterals ( Instruction * start , Instruction * end ) { <nl> * destCount , srcCount and rewrites are updated to reflect when an <nl> * instruction ( s ) is rewritten to a different instruction sequence . <nl> * / <nl> - bool relocateSmashable ( Env & env , Instruction * src , Instruction * dest , <nl> + bool relocateSmashable ( Env & env , TCA srcAddr , TCA destAddr , <nl> size_t & srcCount , size_t & destCount ) { <nl> - auto const srcAddr = reinterpret_cast < TCA > ( src ) ; <nl> - auto const destAddr = reinterpret_cast < TCA > ( dest ) ; <nl> + <nl> + auto const srcAddrActual = env . srcBlock . toDestAddress ( srcAddr ) ; <nl> + auto const src = Instruction : : Cast ( srcAddrActual ) ; <nl> <nl> if ( env . far . count ( src ) ) return false ; <nl> <nl> bool relocateSmashable ( Env & env , Instruction * src , Instruction * dest , <nl> * jmp that can be optimized . It ' s important to not simply analyze this <nl> * smashable jmp without first considering if it ' s part of a jcc . <nl> * / <nl> - auto target = smashableJmpTarget ( srcAddr ) ; <nl> + auto target = smashableJmpTarget ( srcAddrActual ) ; <nl> if ( target ) { <nl> - auto sl = getSmashableFromTargetAddr ( srcAddr + kSmashJmpTargetOff ) ; <nl> + / / Look up the smashable ( jmp , jcc , etc ) from the target . Note this is <nl> + / / an actual address , and so we ' ll use the offset with the ( potentially ) <nl> + / / virtual srcAddr when we search through smashableLocation . <nl> + auto slActual = <nl> + getSmashableFromTargetAddr ( srcAddrActual + kSmashJmpTargetOff ) ; <nl> + auto sl = srcAddr + ( slActual - srcAddrActual ) ; <nl> if ( sl & & env . meta . smashableLocations . count ( sl ) ) { <nl> target = nullptr ; <nl> } <nl> bool relocateSmashable ( Env & env , Instruction * src , Instruction * dest , <nl> } <nl> env . updateInternalRefs = true ; <nl> FTRACE ( 3 , <nl> - " Relocated smashable at src 0x { : 08x } " , <nl> - " with target 0x { : 08x } to 0x { : 08x } ( 0x { : 08x } ) \ n " , <nl> - ( uint64_t ) srcAddr , ( uint64_t ) target , <nl> - * ( ( uint32_t * ) destAddr ) , ( uint64_t ) destAddr ) ; <nl> + " Relocated and optimized smashable at src { } with target { } to { } . \ n " , <nl> + srcAddrActual , target , env . destBlock . toDestAddress ( destAddr ) ) ; <nl> <nl> return true ; <nl> } <nl> bool relocateSmashable ( Env & env , Instruction * src , Instruction * dest , <nl> * destCount , srcCount and rewrites are updated to reflect when an <nl> * instruction ( s ) is rewritten to a different instruction sequence . <nl> * / <nl> - bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> + bool relocatePCRelative ( Env & env , TCA srcAddr , TCA destAddr , <nl> size_t & / * srcCount * / , size_t & destCount ) { <nl> - auto const destAddr = reinterpret_cast < TCA > ( dest ) ; <nl> + <nl> + auto const srcFrom = Instruction : : Cast ( srcAddr ) ; <nl> + auto const destFrom = Instruction : : Cast ( destAddr ) ; <nl> + <nl> + auto const srcAddrActual = env . srcBlock . toDestAddress ( srcAddr ) ; <nl> + auto const destAddrActual = env . destBlock . toDestAddress ( destAddr ) ; <nl> + auto const src = Instruction : : Cast ( srcAddrActual ) ; <nl> + auto const dest = Instruction : : Cast ( destAddrActual ) ; <nl> <nl> if ( ! ( src - > IsPCRelAddressing ( ) | | <nl> src - > IsLoadLiteral ( ) | | <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> src - > IsCompareBranch ( ) | | <nl> src - > IsTestBranch ( ) ) ) return false ; <nl> <nl> - auto target = reinterpret_cast < TCA > ( src - > ImmPCOffsetTarget ( ) ) ; <nl> + auto target = reinterpret_cast < TCA > ( src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> <nl> / / If the target is outside of the range of this relocation , <nl> / / then update it . <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> * scope is just a single macroassembler directive , whereas <nl> * the scope of rAsm is an entire vasm instruction . <nl> * / <nl> - int imm = src - > ImmPCOffsetTarget ( ) - dest ; <nl> + int imm = src - > ImmPCOffsetTarget ( srcFrom ) - dest ; <nl> bool isRelative = true ; <nl> if ( src - > IsPCRelAddressing ( ) ) { <nl> if ( ! is_int21 ( imm ) | | env . far . count ( src ) ) { <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> <nl> vixl : : MacroAssembler a { env . destBlock } ; <nl> auto const dst = vixl : : Register ( src - > Rd ( ) , 64 ) ; <nl> - a . Mov ( dst , src - > ImmPCOffsetTarget ( ) ) ; <nl> + a . Mov ( dst , src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> <nl> destCount + = ( env . destBlock . frontier ( ) - destAddr ) / kInstructionSize ; <nl> isRelative = false ; <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> auto const dst = vixl : : Register ( src - > Rd ( ) , 64 ) ; <nl> auto const tmp = dst . Is ( rVixlScratch0 ) <nl> ? rVixlScratch1 : rVixlScratch0 ; <nl> - a . Mov ( tmp , src - > ImmPCOffsetTarget ( ) ) ; <nl> + a . Mov ( tmp , src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> a . Ldr ( dst , vixl : : MemOperand ( tmp ) ) ; <nl> a . SetScratchRegisters ( rVixlScratch0 , rVixlScratch1 ) ; <nl> <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> auto const tmp = rVixlScratch0 ; <nl> a . SetScratchRegisters ( vixl : : NoReg , vixl : : NoReg ) ; <nl> a . B ( & end , vixl : : InvertCondition ( cond ) ) ; <nl> - a . Mov ( tmp , src - > ImmPCOffsetTarget ( ) ) ; <nl> + a . Mov ( tmp , src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> a . Br ( tmp ) ; <nl> a . bind ( & end ) ; <nl> a . SetScratchRegisters ( rVixlScratch0 , rVixlScratch1 ) ; <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> vixl : : MacroAssembler a { env . destBlock } ; <nl> a . SetScratchRegisters ( vixl : : NoReg , vixl : : NoReg ) ; <nl> auto const tmp = rVixlScratch0 ; <nl> - a . Mov ( tmp , src - > ImmPCOffsetTarget ( ) ) ; <nl> + a . Mov ( tmp , src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> a . Br ( tmp ) ; <nl> a . SetScratchRegisters ( rVixlScratch0 , rVixlScratch1 ) ; <nl> <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> } else { <nl> a . Cbz ( rt , & end ) ; <nl> } <nl> - a . Mov ( tmp , src - > ImmPCOffsetTarget ( ) ) ; <nl> + a . Mov ( tmp , src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> a . Br ( tmp ) ; <nl> a . bind ( & end ) ; <nl> a . SetScratchRegisters ( rVixlScratch0 , rVixlScratch1 ) ; <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> } else { <nl> a . Tbz ( rt , bit_pos , & end ) ; <nl> } <nl> - a . Mov ( tmp , src - > ImmPCOffsetTarget ( ) ) ; <nl> + a . Mov ( tmp , src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> a . Br ( tmp ) ; <nl> a . bind ( & end ) ; <nl> a . SetScratchRegisters ( rVixlScratch0 , rVixlScratch1 ) ; <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> <nl> / / Update offset if it was NOT converted from relative to absolute <nl> if ( isRelative ) { <nl> - dest - > SetImmPCOffsetTarget ( src - > ImmPCOffsetTarget ( ) ) ; <nl> + dest - > SetImmPCOffsetTarget ( src - > ImmPCOffsetTarget ( srcFrom ) , destFrom ) ; <nl> } else { <nl> / / Otherwise it was rewritten to absolute , and this <nl> / / internal reference must be updated later . <nl> bool relocatePCRelative ( Env & env , Instruction * src , Instruction * dest , <nl> * destCount , srcCount and rewrites are updated to reflect when an <nl> * instruction ( s ) is rewritten to a different instruction sequence . <nl> * / <nl> - size_t relocateImmediate ( Env & env , Instruction * src , Instruction * dest , <nl> + size_t relocateImmediate ( Env & env , TCA srcAddr , TCA destAddr , <nl> size_t & srcCount , size_t & destCount ) { <nl> - auto const srcAddr = reinterpret_cast < TCA > ( src ) ; <nl> - auto const destAddr = reinterpret_cast < TCA > ( dest ) ; <nl> + <nl> + auto const srcAddrActual = env . srcBlock . toDestAddress ( srcAddr ) ; <nl> + auto const destAddrActual = env . destBlock . toDestAddress ( destAddr ) ; <nl> + auto const src = Instruction : : Cast ( srcAddrActual ) ; <nl> + auto const dest = Instruction : : Cast ( destAddrActual ) ; <nl> <nl> if ( ! src - > IsMovz ( ) ) return false ; <nl> <nl> size_t relocateImpl ( Env & env ) { <nl> * / <nl> try { <nl> / / Find the literals embedded within the range <nl> - InstrSet literals = findLiterals ( Instruction : : Cast ( env . start ) , <nl> - Instruction : : Cast ( env . end ) ) ; <nl> + InstrSet literals = <nl> + findLiterals ( Instruction : : Cast ( env . srcBlock . toDestAddress ( env . start ) ) , <nl> + Instruction : : Cast ( env . srcBlock . toDestAddress ( env . end ) ) ) ; <nl> <nl> / / Relocate each instruction to the destination . <nl> size_t srcCount , destCount ; <nl> - for ( auto src = Instruction : : Cast ( env . start ) ; <nl> - src < Instruction : : Cast ( env . end ) ; <nl> - src + = srcCount * kInstructionSize ) { <nl> - auto const srcAddr = reinterpret_cast < TCA > ( src ) ; <nl> + for ( auto srcAddr = env . start ; <nl> + srcAddr < env . end ; <nl> + srcAddr + = srcCount * kInstructionSize ) { <nl> + auto const src = Instruction : : Cast ( env . srcBlock . toDestAddress ( srcAddr ) ) ; <nl> auto destAddr = env . destBlock . frontier ( ) ; <nl> - auto const dest = Instruction : : Cast ( destAddr ) ; <nl> srcCount = 1 ; <nl> destCount = 1 ; <nl> <nl> / / Initially copy the instruction word <nl> - env . destBlock . bytes ( kInstructionSize , srcAddr ) ; <nl> + env . destBlock . bytes ( kInstructionSize , <nl> + env . srcBlock . toDestAddress ( srcAddr ) ) ; <nl> <nl> / / If it ' s not a literal , then attempt any special relocations <nl> if ( ! literals . count ( src ) & & <nl> - ! relocateSmashable ( env , src , dest , srcCount , destCount ) & & <nl> - ! relocatePCRelative ( env , src , dest , srcCount , destCount ) & & <nl> - ! relocateImmediate ( env , src , dest , srcCount , destCount ) ) { <nl> + ! relocateSmashable ( env , srcAddr , destAddr , srcCount , destCount ) & & <nl> + ! relocatePCRelative ( env , srcAddr , destAddr , srcCount , destCount ) & & <nl> + ! relocateImmediate ( env , srcAddr , destAddr , srcCount , destCount ) ) { <nl> / / Do nothing , as the instruction word was initially copied above <nl> } <nl> <nl> / / If we just copied the first instruction of a smashableMovq , then it may <nl> / / have an internal reference that ' ll need to be adjusted below . <nl> - if ( ! literals . count ( src ) & & isSmashableMovq ( srcAddr ) ) { <nl> + if ( ! literals . count ( src ) & & <nl> + isSmashableMovq ( env . srcBlock . toDestAddress ( srcAddr ) ) ) { <nl> env . updateInternalRefs = true ; <nl> } <nl> <nl> size_t relocateImpl ( Env & env ) { <nl> * / <nl> if ( env . updateInternalRefs ) { <nl> bool ok = true ; <nl> - for ( auto src = Instruction : : Cast ( env . start ) ; <nl> - src < Instruction : : Cast ( env . end ) ; <nl> - src = src - > NextInstruction ( ) ) { <nl> - auto const destAddr = env . rel . adjustedAddressAfter ( <nl> - reinterpret_cast < TCA > ( src ) <nl> - ) ; <nl> - auto const dest = Instruction : : Cast ( destAddr ) ; <nl> + for ( auto srcAddr = env . start ; <nl> + srcAddr < env . end ; <nl> + srcAddr + = kInstructionSize ) { <nl> + auto const srcFrom = Instruction : : Cast ( srcAddr ) ; <nl> + auto const src = Instruction : : Cast ( env . srcBlock . toDestAddress ( srcAddr ) ) ; <nl> <nl> / / Adjust this instruction if A ) it wasn ' t written from a pc relative <nl> / / instruction to an absolute ( or vice - versa ) and B ) it isn ' t a literal . <nl> if ( ! env . rewrites . count ( src ) & & ! literals . count ( src ) ) { <nl> + auto const destAddr = env . rel . adjustedAddressAfter ( srcAddr ) ; <nl> + auto const destFrom = Instruction : : Cast ( destAddr ) ; <nl> + auto const dest = <nl> + Instruction : : Cast ( env . destBlock . toDestAddress ( destAddr ) ) ; <nl> / * <nl> * PC Relative <nl> * ADR / ADRP <nl> size_t relocateImpl ( Env & env ) { <nl> src - > IsUncondBranchImm ( ) | | <nl> src - > IsCompareBranch ( ) | | <nl> src - > IsTestBranch ( ) ) { <nl> - auto old_target = reinterpret_cast < TCA > ( src - > ImmPCOffsetTarget ( ) ) ; <nl> - auto adjusted_target = env . rel . adjustedAddressAfter ( old_target ) ; <nl> - auto new_target = adjusted_target ? adjusted_target : old_target ; <nl> + auto const old_target = <nl> + reinterpret_cast < TCA > ( src - > ImmPCOffsetTarget ( srcFrom ) ) ; <nl> + auto const adjusted_target = <nl> + env . rel . adjustedAddressAfter ( old_target ) ; <nl> + auto const new_target = <nl> + adjusted_target ? adjusted_target : old_target ; <nl> <nl> / * <nl> * Calculate the new offset and update . At this stage , we ' ve already <nl> size_t relocateImpl ( Env & env ) { <nl> env . far . insert ( src ) ; <nl> ok = false ; <nl> } else { <nl> - dest - > SetImmPCOffsetTarget ( Instruction : : Cast ( new_target ) ) ; <nl> + dest - > SetImmPCOffsetTarget ( Instruction : : Cast ( new_target ) , <nl> + destFrom ) ; <nl> } <nl> } <nl> <nl> size_t relocateImpl ( Env & env ) { <nl> env . destBlock . setFrontier ( destStart ) ; <nl> throw ; <nl> } <nl> - __builtin___clear_cache ( reinterpret_cast < char * > ( destStart ) , <nl> - reinterpret_cast < char * > ( env . destBlock . frontier ( ) ) ) ; <nl> + auto const start = env . destBlock . toDestAddress ( destStart ) ; <nl> + auto const end = env . destBlock . toDestAddress ( env . destBlock . frontier ( ) ) ; <nl> + __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> <nl> return asmCount ; <nl> } <nl> void adjustCodeForRelocation ( RelocationInfo & rel , CGMeta & meta ) { <nl> <nl> void adjustMetaDataForRelocation ( RelocationInfo & rel , AsmInfo * / * asmInfo * / , <nl> CGMeta & meta ) { <nl> + for ( auto & li : meta . literals ) { <nl> + if ( auto adjusted = rel . adjustedAddressAfter ( ( TCA ) li . second ) ) { <nl> + li . second = ( uint64_t * ) adjusted ; <nl> + } <nl> + } <nl> + <nl> decltype ( meta . smashableLocations ) updatedSL ; <nl> for ( auto sl : meta . smashableLocations ) { <nl> if ( auto adjusted = rel . adjustedAddressAfter ( sl ) ) { <nl> void adjustMetaDataForRelocation ( RelocationInfo & rel , AsmInfo * / * asmInfo * / , <nl> } <nl> } <nl> updatedSL . swap ( meta . smashableLocations ) ; <nl> + <nl> + decltype ( meta . codePointers ) updatedCP ; <nl> + for ( auto cp : meta . codePointers ) { <nl> + if ( auto adjusted = ( TCA * ) rel . adjustedAddressAfter ( ( TCA ) cp ) ) { <nl> + updatedCP . emplace ( adjusted ) ; <nl> + } else { <nl> + updatedCP . emplace ( cp ) ; <nl> + } <nl> + } <nl> + updatedCP . swap ( meta . codePointers ) ; <nl> } <nl> <nl> void findFixups ( TCA start , TCA end , CGMeta & meta ) { <nl> void findFixups ( TCA start , TCA end , CGMeta & meta ) { <nl> size_t relocate ( RelocationInfo & rel , <nl> CodeBlock & destBlock , <nl> TCA start , TCA end , <nl> - CodeBlock & , <nl> + CodeBlock & srcBlock , <nl> CGMeta & meta , <nl> TCA * exitAddr , <nl> AreaIndex ) { <nl> while ( true ) { <nl> try { <nl> - Env env ( rel , destBlock , start , end , meta , exitAddr ) ; <nl> + Env env ( rel , srcBlock , destBlock , start , end , meta , exitAddr ) ; <nl> return relocateImpl ( env ) ; <nl> } catch ( JmpOutOfRange & j ) { <nl> } <nl> mmm a / hphp / runtime / vm / jit / smashable - instr - arm . cpp <nl> ppp b / hphp / runtime / vm / jit / smashable - instr - arm . cpp <nl> TCA emitSmashableMovq ( CodeBlock & cb , CGMeta & meta , uint64_t imm , <nl> vixl : : Label imm_data ; <nl> vixl : : Label after_data ; <nl> <nl> - auto const start = cb . frontier ( ) ; <nl> - meta . smashableLocations . insert ( start ) ; <nl> + meta . smashableLocations . insert ( cb . frontier ( ) ) ; <nl> + auto const the_start = cb . frontier ( ) ; <nl> <nl> a . Ldr ( x2a ( d ) , & imm_data ) ; <nl> a . B ( & after_data ) ; <nl> TCA emitSmashableMovq ( CodeBlock & cb , CGMeta & meta , uint64_t imm , <nl> a . dc64 ( imm ) ; <nl> a . bind ( & after_data ) ; <nl> <nl> + auto const start = cb . toDestAddress ( the_start ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> - reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> - return start ; <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> + return the_start ; <nl> } <nl> <nl> TCA emitSmashableCmpq ( CodeBlock & / * cb * / , CGMeta & / * meta * / , int32_t / * imm * / , <nl> TCA emitSmashableCall ( CodeBlock & cb , CGMeta & meta , TCA target ) { <nl> vixl : : Label target_data ; <nl> vixl : : Label after_data ; <nl> <nl> - auto const start = cb . frontier ( ) ; <nl> - meta . smashableLocations . insert ( start ) ; <nl> + meta . smashableLocations . insert ( cb . frontier ( ) ) ; <nl> + auto const the_start = cb . frontier ( ) ; <nl> <nl> / / Jump over the data <nl> a . B ( & after_data ) ; <nl> TCA emitSmashableCall ( CodeBlock & cb , CGMeta & meta , TCA target ) { <nl> a . Ldr ( rAsm , & target_data ) ; <nl> a . Blr ( rAsm ) ; <nl> <nl> + auto const start = cb . toDestAddress ( the_start ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> - reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> - return start ; <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> + return the_start ; <nl> } <nl> <nl> TCA emitSmashableJmp ( CodeBlock & cb , CGMeta & meta , TCA target ) { <nl> TCA emitSmashableJmp ( CodeBlock & cb , CGMeta & meta , TCA target ) { <nl> vixl : : MacroAssembler a { cb } ; <nl> vixl : : Label target_data ; <nl> <nl> - auto const start = cb . frontier ( ) ; <nl> - meta . smashableLocations . insert ( start ) ; <nl> + meta . smashableLocations . insert ( cb . frontier ( ) ) ; <nl> + auto const the_start = cb . frontier ( ) ; <nl> <nl> a . Ldr ( rAsm , & target_data ) ; <nl> a . Br ( rAsm ) ; <nl> TCA emitSmashableJmp ( CodeBlock & cb , CGMeta & meta , TCA target ) { <nl> a . bind ( & target_data ) ; <nl> a . dc64 ( target ) ; <nl> <nl> + auto const start = cb . toDestAddress ( the_start ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> - reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> - return start ; <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> + return the_start ; <nl> } <nl> <nl> / / While a b . cc can be overwritten on ARM , if the cc and the target <nl> TCA emitSmashableJcc ( CodeBlock & cb , CGMeta & meta , TCA target , <nl> vixl : : Label target_data ; <nl> vixl : : Label after_data ; <nl> <nl> - auto const start = cb . frontier ( ) ; <nl> - meta . smashableLocations . insert ( start ) ; <nl> + meta . smashableLocations . insert ( cb . frontier ( ) ) ; <nl> + auto const the_start = cb . frontier ( ) ; <nl> <nl> / / Emit the conditional branch <nl> a . B ( & after_data , InvertCondition ( arm : : convertCC ( cc ) ) ) ; <nl> TCA emitSmashableJcc ( CodeBlock & cb , CGMeta & meta , TCA target , <nl> <nl> a . bind ( & after_data ) ; <nl> <nl> + auto const start = cb . toDestAddress ( the_start ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> - reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> - return start ; <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> + return the_start ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool isSmashableMovq ( TCA inst ) { <nl> + using namespace vixl ; <nl> + <nl> + Instruction * ldr = Instruction : : Cast ( inst ) ; <nl> + Instruction * b = ldr - > NextInstruction ( ) ; <nl> + Instruction * target = b - > NextInstruction ( ) ; <nl> + Instruction * after = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> + <nl> + return ( ldr - > IsLoadLiteral ( ) & & <nl> + ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> + ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> + b - > Mask ( UnconditionalBranchMask ) = = B & & <nl> + b - > ImmPCOffsetTarget ( ) = = after ) ; <nl> + } <nl> + <nl> + bool isSmashableCall ( TCA inst ) { <nl> + using namespace vixl ; <nl> + <nl> + Instruction * b = Instruction : : Cast ( inst ) ; <nl> + Instruction * target = b - > NextInstruction ( ) ; <nl> + Instruction * ldr = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> + Instruction * blr = ldr - > NextInstruction ( ) ; <nl> + const auto rd = ldr - > Rd ( ) ; <nl> + <nl> + return ( b - > Mask ( UnconditionalBranchMask ) = = B & & <nl> + b - > ImmPCOffsetTarget ( ) = = ldr & & <nl> + ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> + ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> + blr - > Mask ( UnconditionalBranchToRegisterMask ) = = BLR & & <nl> + blr - > Rn ( ) = = rd ) ; <nl> + } <nl> + <nl> + bool isSmashableJmp ( TCA inst ) { <nl> + using namespace vixl ; <nl> + <nl> + Instruction * ldr = Instruction : : Cast ( inst ) ; <nl> + Instruction * br = ldr - > NextInstruction ( ) ; <nl> + Instruction * target = br - > NextInstruction ( ) ; <nl> + const auto rd = ldr - > Rd ( ) ; <nl> + <nl> + return ( ldr - > IsLoadLiteral ( ) & & <nl> + ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> + ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> + br - > Mask ( UnconditionalBranchToRegisterMask ) = = BR & & <nl> + br - > Rn ( ) = = rd ) ; <nl> + } <nl> + <nl> + bool isSmashableJcc ( TCA inst ) { <nl> + using namespace vixl ; <nl> + <nl> + Instruction * b = Instruction : : Cast ( inst ) ; <nl> + Instruction * ldr = b - > NextInstruction ( ) ; ; <nl> + Instruction * br = ldr - > NextInstruction ( ) ; <nl> + Instruction * target = br - > NextInstruction ( ) ; <nl> + Instruction * after = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> + const auto rd = ldr - > Rd ( ) ; <nl> + <nl> + return ( b - > IsCondBranchImm ( ) & & <nl> + b - > ImmPCOffsetTarget ( ) = = after & & <nl> + ldr - > IsLoadLiteral ( ) & & <nl> + ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> + ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> + br - > Mask ( UnconditionalBranchToRegisterMask ) = = BR & & <nl> + br - > Rn ( ) = = rd ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> static void smashInstr ( TCA inst , T target , size_t sz ) { <nl> } <nl> <nl> void smashMovq ( TCA inst , uint64_t target ) { <nl> + assertx ( isSmashableMovq ( inst ) ) ; <nl> smashInstr ( inst , target , smashableMovqLen ( ) ) ; <nl> } <nl> <nl> void smashCmpq ( TCA / * inst * / , uint32_t / * target * / ) { <nl> } <nl> <nl> void smashCall ( TCA inst , TCA target ) { <nl> + assertx ( isSmashableCall ( inst ) ) ; <nl> smashInstr ( inst , target , ( 1 * 4 ) + 8 ) ; <nl> } <nl> <nl> void smashJmp ( TCA inst , TCA target ) { <nl> + assertx ( isSmashableJmp ( inst ) ) ; <nl> <nl> / / If the target is within the smashable jmp , then set the target to the <nl> / / end . This mirrors logic in x86_64 with the exception that ARM cannot <nl> void smashJmp ( TCA inst , TCA target ) { <nl> } <nl> <nl> void smashJcc ( TCA inst , TCA target ) { <nl> - using namespace vixl ; <nl> + assertx ( isSmashableJcc ( inst ) ) ; <nl> <nl> if ( smashableJccTarget ( inst ) ! = target ) { <nl> smashInstr ( inst , target , smashableJccLen ( ) ) ; <nl> void smashJcc ( TCA inst , TCA target ) { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - bool isSmashableMovq ( TCA inst ) { <nl> - using namespace vixl ; <nl> - <nl> - Instruction * ldr = Instruction : : Cast ( inst ) ; <nl> - Instruction * b = ldr - > NextInstruction ( ) ; <nl> - Instruction * target = b - > NextInstruction ( ) ; <nl> - Instruction * after = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> - <nl> - return ( ldr - > IsLoadLiteral ( ) & & <nl> - ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> - ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> - b - > Mask ( UnconditionalBranchMask ) = = B & & <nl> - b - > ImmPCOffsetTarget ( ) = = after ) ; <nl> - } <nl> - <nl> uint64_t smashableMovqImm ( TCA inst ) { <nl> using namespace vixl ; <nl> <nl> TCA smashableCallTarget ( TCA inst ) { <nl> <nl> Instruction * b = Instruction : : Cast ( inst ) ; <nl> Instruction * target = b - > NextInstruction ( ) ; <nl> - Instruction * ldr = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> - Instruction * blr = ldr - > NextInstruction ( ) ; <nl> - const auto rd = ldr - > Rd ( ) ; <nl> <nl> - if ( b - > Mask ( UnconditionalBranchMask ) = = B & & <nl> - b - > ImmPCOffsetTarget ( ) = = ldr & & <nl> - ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> - ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> - blr - > Mask ( UnconditionalBranchToRegisterMask ) = = BLR & & <nl> - blr - > Rn ( ) = = rd ) { <nl> + if ( isSmashableCall ( inst ) ) { <nl> assertx ( ( reinterpret_cast < uintptr_t > ( target ) & 3 ) = = 0 ) ; <nl> return * reinterpret_cast < TCA * > ( target ) ; <nl> } <nl> TCA smashableJmpTarget ( TCA inst ) { <nl> Instruction * ldr = Instruction : : Cast ( inst ) ; <nl> Instruction * br = ldr - > NextInstruction ( ) ; <nl> Instruction * target = br - > NextInstruction ( ) ; <nl> - const auto rd = ldr - > Rd ( ) ; <nl> <nl> - if ( ldr - > IsLoadLiteral ( ) & & <nl> - ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> - ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> - br - > Mask ( UnconditionalBranchToRegisterMask ) = = BR & & <nl> - br - > Rn ( ) = = rd ) { <nl> + if ( isSmashableJmp ( inst ) ) { <nl> assertx ( ( reinterpret_cast < uintptr_t > ( target ) & 3 ) = = 0 ) ; <nl> return * reinterpret_cast < TCA * > ( target ) ; <nl> } <nl> TCA smashableJccTarget ( TCA inst ) { <nl> Instruction * ldr = b - > NextInstruction ( ) ; ; <nl> Instruction * br = ldr - > NextInstruction ( ) ; <nl> Instruction * target = br - > NextInstruction ( ) ; <nl> - Instruction * after = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> - const auto rd = ldr - > Rd ( ) ; <nl> <nl> - if ( b - > IsCondBranchImm ( ) & & <nl> - b - > ImmPCOffsetTarget ( ) = = after & & <nl> - ldr - > IsLoadLiteral ( ) & & <nl> - ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> - ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> - br - > Mask ( UnconditionalBranchToRegisterMask ) = = BR & & <nl> - br - > Rn ( ) = = rd ) { <nl> + if ( isSmashableJcc ( inst ) ) { <nl> assertx ( ( reinterpret_cast < uintptr_t > ( target ) & 3 ) = = 0 ) ; <nl> return * reinterpret_cast < TCA * > ( target ) ; <nl> } <nl> ConditionCode smashableJccCond ( TCA inst ) { <nl> using namespace vixl ; <nl> <nl> Instruction * b = Instruction : : Cast ( inst ) ; <nl> - Instruction * ldr = b - > NextInstruction ( ) ; ; <nl> - Instruction * br = ldr - > NextInstruction ( ) ; <nl> - Instruction * target = br - > NextInstruction ( ) ; <nl> - DEBUG_ONLY Instruction * after = target - > NextInstruction ( ) - > NextInstruction ( ) ; <nl> - DEBUG_ONLY const auto rd = ldr - > Rd ( ) ; <nl> <nl> - assertx ( b - > IsCondBranchImm ( ) & & <nl> - b - > ImmPCOffsetTarget ( ) = = after & & <nl> - ldr - > IsLoadLiteral ( ) & & <nl> - ldr - > Mask ( LoadLiteralMask ) = = LDR_x_lit & & <nl> - ldr - > ImmPCOffsetTarget ( ) = = target & & <nl> - br - > Mask ( UnconditionalBranchToRegisterMask ) = = BR & & <nl> - br - > Rn ( ) = = rd ) ; <nl> + assertx ( isSmashableJcc ( inst ) ) ; <nl> <nl> return arm : : convertCC ( InvertCondition ( static_cast < Condition > ( b - > Bits ( 3 , 0 ) ) ) ) ; <nl> } <nl> mmm a / hphp / runtime / vm / jit / unique - stubs - arm . cpp <nl> ppp b / hphp / runtime / vm / jit / unique - stubs - arm . cpp <nl> TCA emitCallToExit ( CodeBlock & cb , DataBlock & / * data * / , const UniqueStubs & us ) { <nl> a . bind ( & target_data ) ; <nl> a . dc64 ( us . enterTCExit ) ; <nl> <nl> + auto const end = cb . frontier ( ) ; <nl> __builtin___clear_cache ( reinterpret_cast < char * > ( start ) , <nl> - reinterpret_cast < char * > ( cb . frontier ( ) ) ) ; <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> return start ; <nl> } <nl> <nl> mmm a / hphp / runtime / vm / jit / vasm - arm . cpp <nl> ppp b / hphp / runtime / vm / jit / vasm - arm . cpp <nl> struct Vgen { <nl> , catches ( env . catches ) <nl> { } <nl> ~ Vgen ( ) { <nl> - auto begin = reinterpret_cast < char * > ( base ) ; <nl> - auto end = reinterpret_cast < char * > ( a - > frontier ( ) ) ; <nl> - __builtin___clear_cache ( begin , end ) ; <nl> + auto begin = env . cb - > toDestAddress ( base ) ; <nl> + auto end = env . cb - > toDestAddress ( a - > frontier ( ) ) ; <nl> + __builtin___clear_cache ( reinterpret_cast < char * > ( begin ) , <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> } <nl> <nl> static void patch ( Venv & env ) ; <nl> <nl> static void pad ( CodeBlock & cb ) { <nl> vixl : : MacroAssembler a { cb } ; <nl> - auto const begin = reinterpret_cast < char * > ( cb . frontier ( ) ) ; <nl> + auto const begin = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> while ( cb . available ( ) > = 4 ) a . Brk ( 1 ) ; <nl> assertx ( cb . available ( ) = = 0 ) ; <nl> - auto const end = reinterpret_cast < char * > ( cb . frontier ( ) ) ; <nl> - __builtin___clear_cache ( begin , end ) ; <nl> + auto const end = cb . toDestAddress ( cb . frontier ( ) ) ; <nl> + __builtin___clear_cache ( reinterpret_cast < char * > ( begin ) , <nl> + reinterpret_cast < char * > ( end ) ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> struct Vgen { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> + static CodeAddress toReal ( Venv & env , CodeAddress a ) { <nl> + if ( env . text . main ( ) . code . contains ( a ) ) { <nl> + return env . text . main ( ) . code . toDestAddress ( a ) ; <nl> + } <nl> + if ( env . text . cold ( ) . code . contains ( a ) ) { <nl> + return env . text . cold ( ) . code . toDestAddress ( a ) ; <nl> + } <nl> + if ( env . text . frozen ( ) . code . contains ( a ) ) { <nl> + return env . text . frozen ( ) . code . toDestAddress ( a ) ; <nl> + } <nl> + return a ; <nl> + } <nl> + <nl> void Vgen : : patch ( Venv & env ) { <nl> for ( auto & p : env . jmps ) { <nl> assertx ( env . addrs [ p . target ] ) ; <nl> / / ' jmp ' is 2 instructions , load followed by branch <nl> - auto const begin = reinterpret_cast < char * > ( p . instr + 2 * 4 ) ; <nl> + auto const begin = reinterpret_cast < char * > ( toReal ( env , p . instr + 2 * 4 ) ) ; <nl> auto const end = begin + sizeof ( env . addrs [ p . target ] ) ; <nl> * reinterpret_cast < TCA * > ( begin ) = env . addrs [ p . target ] ; <nl> __builtin___clear_cache ( begin , end ) ; <nl> void Vgen : : patch ( Venv & env ) { <nl> for ( auto & p : env . jccs ) { <nl> assertx ( env . addrs [ p . target ] ) ; <nl> / / ' jcc ' is 3 instructions , b . ! cc + load followed by branch <nl> - auto const begin = reinterpret_cast < char * > ( p . instr + 3 * 4 ) ; <nl> + auto const begin = reinterpret_cast < char * > ( toReal ( env , p . instr + 3 * 4 ) ) ; <nl> auto const end = begin + sizeof ( env . addrs [ p . target ] ) ; <nl> * reinterpret_cast < TCA * > ( begin ) = env . addrs [ p . target ] ; <nl> __builtin___clear_cache ( begin , end ) ; <nl> void Vgen : : emit ( const mcprep & i ) { <nl> * / <nl> auto const mov_addr = emitSmashableMovq ( a - > code ( ) , env . meta , 0 , r64 ( i . d ) ) ; <nl> auto const imm = reinterpret_cast < uint64_t > ( mov_addr ) ; <nl> - smashMovq ( mov_addr , ( imm < < 1 ) | 1 ) ; <nl> + smashMovq ( a - > code ( ) . toDestAddress ( mov_addr ) , ( imm < < 1 ) | 1 ) ; <nl> <nl> env . meta . addressImmediates . insert ( reinterpret_cast < TCA > ( ~ imm ) ) ; <nl> } <nl> void Vgen : : emit ( const jcc & i ) { <nl> a - > Ldr ( rAsm , & data ) ; <nl> a - > Br ( rAsm ) ; <nl> a - > bind ( & data ) ; <nl> - a - > dc64 ( a - > frontier ( ) ) ; <nl> + a - > dc64 ( a - > code ( ) . toDestAddress ( a - > frontier ( ) ) ) ; <nl> a - > bind ( & skip ) ; <nl> } <nl> emit ( jmp { i . targets [ 0 ] } ) ; <nl> void Vgen : : emit ( const jmp & i ) { <nl> a - > Ldr ( rAsm , & data ) ; <nl> a - > Br ( rAsm ) ; <nl> a - > bind ( & data ) ; <nl> - a - > dc64 ( a - > frontier ( ) ) ; <nl> + a - > dc64 ( a - > code ( ) . toDestAddress ( a - > frontier ( ) ) ) ; <nl> } <nl> <nl> void Vgen : : emit ( const jmpi & i ) { <nl> mmm a / hphp / util / hfsort . cpp <nl> ppp b / hphp / util / hfsort . cpp <nl> void TargetGraph : : normalizeArcWeights ( ) { <nl> for ( auto src : func . preds ) { <nl> auto & arc = * arcs . find ( Arc ( src , f ) ) ; <nl> arc . normalizedWeight = arc . weight / func . samples ; <nl> + if ( arc . weight = = 0 ) continue ; <nl> arc . avgCallOffset = arc . avgCallOffset / arc . weight ; <nl> assert ( arc . avgCallOffset < targets [ src ] . size ) ; <nl> } <nl> void freezeClusters ( const TargetGraph & cg , std : : vector < Cluster > & clusters ) { <nl> } <nl> <nl> void mergeInto ( Cluster & into , Cluster & & other , const double / * aw * / = 0 ) { <nl> - into . targets . insert ( into . targets . end ( ) , other . targets . begin ( ) , other . targets . end ( ) ) ; <nl> + into . targets . insert ( into . targets . end ( ) , <nl> + other . targets . begin ( ) , other . targets . end ( ) ) ; <nl> into . size + = other . size ; <nl> into . samples + = other . samples ; <nl> <nl> mmm a / hphp / vixl / a64 / assembler - a64 . cc <nl> ppp b / hphp / vixl / a64 / assembler - a64 . cc <nl> void Assembler : : bind ( Label * label ) { <nl> label - > target_ = cb_ . frontier ( ) ; <nl> while ( label - > IsLinked ( ) ) { <nl> / / Get the address of the following instruction in the chain . <nl> - auto link = Instruction : : Cast ( label - > link_ ) ; <nl> - Instruction * next_link = link - > ImmPCOffsetTarget ( ) ; <nl> + auto const link = Instruction : : Cast ( label - > link_ ) ; <nl> + auto const actual_link = Instruction : : Cast ( cb_ . toDestAddress ( label - > link_ ) ) ; <nl> + auto const next_link = actual_link - > ImmPCOffsetTarget ( link ) ; <nl> / / Update the instruction target . <nl> - link - > SetImmPCOffsetTarget ( Instruction : : Cast ( label - > target_ ) ) ; <nl> + actual_link - > SetImmPCOffsetTarget ( Instruction : : Cast ( label - > target_ ) , link ) ; <nl> / / Update the label ' s link . <nl> / / If the offset of the branch we just updated was 0 ( kEndOfChain ) we are <nl> / / done . <nl> mmm a / hphp / vixl / a64 / assembler - a64 . h <nl> ppp b / hphp / vixl / a64 / assembler - a64 . h <nl> class Label { <nl> private : <nl> / / Indicates if the label has been bound , ie its location is fixed . <nl> bool is_bound_ ; <nl> + <nl> / / Branches instructions branching to this label form a chained list , with <nl> / / their offset indicating where the next instruction is located . <nl> / / link_ points to the latest branch instruction generated branching to this <nl> / / branch . <nl> + <nl> + / / link_ and target_ will hold virtual addresses if the CodeBlock is <nl> + / / configured as such . When binding a Label , the physical instructions will <nl> + / / be updated with targets computed with the virtual address of the linked <nl> + / / instructions and the virtual target_ . This will cause calls to <nl> + / / Instruction : : ImmPCOffsetTarget ( ) for the physical instruction to return <nl> + / / target in the weeds , and so the code in relocation - arm . cpp takes this <nl> + / / into account . Why the madness ? Because translations in high memory of <nl> + / / thread local caches will have branches distances as if they were in <nl> + / / low memory . Ideally , this means we ' re very likely to have an identically - <nl> + / / sized translation once we relocate into the code cache . <nl> + <nl> / / If link_ is not nullptr , the label has been linked to . <nl> HPHP : : CodeAddress link_ ; <nl> / / The label location . <nl> class Assembler { <nl> <nl> / / Emit the instruction at pc_ . <nl> void Emit ( Instr instruction ) { <nl> - assert ( cb_ . canEmit ( sizeof ( instruction ) ) ) ; <nl> assert ( sizeof ( instruction ) = = sizeof ( uint32_t ) ) ; <nl> CheckBufferSpace ( ) ; <nl> <nl> class Assembler { <nl> <nl> / / Emit data inline in the instruction stream . <nl> void EmitData ( void const * data , unsigned size ) { <nl> - assert ( cb_ . canEmit ( size ) ) ; <nl> CheckBufferSpace ( ) ; <nl> <nl> # ifdef DEBUG <nl> class Assembler { <nl> } <nl> <nl> inline void CheckBufferSpace ( ) { <nl> - assert ( cb_ . available ( ) > 0 ) ; <nl> if ( cb_ . frontier ( ) > next_literal_pool_check_ ) { <nl> CheckLiteralPool ( ) ; <nl> } <nl> mmm a / hphp / vixl / a64 / instructions - a64 . cc <nl> ppp b / hphp / vixl / a64 / instructions - a64 . cc <nl> LSDataSize CalcLSPairDataSize ( LoadStorePairOp op ) { <nl> } <nl> <nl> <nl> - Instruction * Instruction : : ImmPCOffsetTarget ( ) { <nl> + Instruction * Instruction : : ImmPCOffsetTarget ( Instruction * from ) { <nl> ptrdiff_t offset ; <nl> if ( IsPCRelAddressing ( ) ) { <nl> / / PC - relative addressing . Only ADR is supported . <nl> Instruction * Instruction : : ImmPCOffsetTarget ( ) { <nl> / / Relative branch offsets are instruction - size - aligned . <nl> offset = ImmBranch ( ) < < kInstructionSizeLog2 ; <nl> } <nl> - return this + offset ; <nl> + return ( ! from ? this : from ) + offset ; <nl> } <nl> <nl> <nl> inline int Instruction : : ImmBranch ( ) const { <nl> } <nl> <nl> <nl> - void Instruction : : SetImmPCOffsetTarget ( Instruction * target ) { <nl> + void Instruction : : SetImmPCOffsetTarget ( Instruction * target , <nl> + Instruction * from ) { <nl> + auto adjusted_target = ! from ? target : target + ( int64_t ) ( this - from ) ; <nl> if ( IsPCRelAddressing ( ) ) { <nl> - SetPCRelImmTarget ( target ) ; <nl> + SetPCRelImmTarget ( adjusted_target ) ; <nl> } else if ( IsLoadOrStore ( ) ) { <nl> - SetPCRelLoadStoreTarget ( target ) ; <nl> + SetPCRelLoadStoreTarget ( adjusted_target ) ; <nl> } else { <nl> - SetBranchImmTarget ( target ) ; <nl> + SetBranchImmTarget ( adjusted_target ) ; <nl> } <nl> } <nl> <nl> mmm a / hphp / vixl / a64 / instructions - a64 . h <nl> ppp b / hphp / vixl / a64 / instructions - a64 . h <nl> class Instruction { <nl> <nl> / / Find the target of this instruction . ' this ' may be a branch or a <nl> / / PC - relative addressing instruction . <nl> - Instruction * ImmPCOffsetTarget ( ) ; <nl> + Instruction * ImmPCOffsetTarget ( Instruction * from = nullptr ) ; <nl> <nl> / / Patch a PC - relative offset to refer to ' target ' . ' this ' may be a branch or <nl> / / a PC - relative addressing instruction . <nl> - void SetImmPCOffsetTarget ( Instruction * target ) ; <nl> + void SetImmPCOffsetTarget ( Instruction * target , Instruction * from = nullptr ) ; <nl> / / Patch a literal load instruction to load from ' source ' . <nl> void SetImmLLiteral ( Instruction * source ) ; <nl> <nl>
Add retranslate all support .
facebook/hhvm
f64c1e590a8adcaf9a67c345647991a970ff68f1
2017-09-01T21:44:26Z
mmm a / folly / io / async / AsyncSSLSocket . cpp <nl> ppp b / folly / io / async / AsyncSSLSocket . cpp <nl> void AsyncSSLSocket : : sslInfoCallback ( const SSL * ssl , int where , int ret ) { <nl> if ( sslSocket - > handshakeComplete_ & & ( where & SSL_CB_HANDSHAKE_START ) ) { <nl> sslSocket - > renegotiateAttempted_ = true ; <nl> } <nl> + if ( sslSocket - > handshakeComplete_ & & ( where & SSL_CB_WRITE_ALERT ) ) { <nl> + const char * desc = SSL_alert_desc_string ( ret ) ; <nl> + if ( desc & & strcmp ( desc , " NR " ) = = 0 ) { <nl> + sslSocket - > renegotiateAttempted_ = true ; <nl> + } <nl> + } <nl> if ( where & SSL_CB_READ_ALERT ) { <nl> const char * type = SSL_alert_type_string ( ret ) ; <nl> if ( type ) { <nl>
Disable renegotiation in OpenSSL 1 . 1 . x
facebook/folly
b1fd4e1a2b8f48388b74e6dadf7ad2afd6763f50
2019-01-18T01:49:17Z
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> bool ImGui : : SliderFloat ( const char * label , float * v , float v_min , float v_max , c <nl> / / Process clicking on the slider <nl> if ( g . ActiveId = = id ) <nl> { <nl> - if ( g . IO . MouseDown [ 0 ] ) <nl> + if ( ! is_unbound & & g . IO . MouseDown [ 0 ] ) <nl> { <nl> - if ( ! is_unbound ) <nl> - { <nl> - const float normalized_pos = ImClamp ( ( g . IO . MousePos . x - slider_effective_x1 ) / slider_effective_w , 0 . 0f , 1 . 0f ) ; <nl> + const float normalized_pos = ImClamp ( ( g . IO . MousePos . x - slider_effective_x1 ) / slider_effective_w , 0 . 0f , 1 . 0f ) ; <nl> <nl> - float new_value ; <nl> - if ( is_logarithmic ) <nl> + float new_value ; <nl> + if ( is_logarithmic ) <nl> + { <nl> + / / Account for logarithmic scale on both sides of the zero <nl> + if ( normalized_pos < linear_zero_pos ) <nl> { <nl> - / / Account for logarithmic scale on both sides of the zero <nl> - if ( normalized_pos < linear_zero_pos ) <nl> - { <nl> - / / Negative : rescale to the negative range before powering <nl> - float a = 1 . 0f - ( normalized_pos / linear_zero_pos ) ; <nl> - a = powf ( a , power ) ; <nl> - new_value = ImLerp ( ImMin ( v_max , 0 . f ) , v_min , a ) ; <nl> - } <nl> - else <nl> - { <nl> - / / Positive : rescale to the positive range before powering <nl> - float a ; <nl> - if ( fabsf ( linear_zero_pos - 1 . 0f ) > 1 . e - 6 ) <nl> - a = ( normalized_pos - linear_zero_pos ) / ( 1 . 0f - linear_zero_pos ) ; <nl> - else <nl> - a = normalized_pos ; <nl> - a = powf ( a , power ) ; <nl> - new_value = ImLerp ( ImMax ( v_min , 0 . 0f ) , v_max , a ) ; <nl> - } <nl> + / / Negative : rescale to the negative range before powering <nl> + float a = 1 . 0f - ( normalized_pos / linear_zero_pos ) ; <nl> + a = powf ( a , power ) ; <nl> + new_value = ImLerp ( ImMin ( v_max , 0 . f ) , v_min , a ) ; <nl> } <nl> else <nl> { <nl> - / / Linear slider <nl> - new_value = ImLerp ( v_min , v_max , normalized_pos ) ; <nl> + / / Positive : rescale to the positive range before powering <nl> + float a ; <nl> + if ( fabsf ( linear_zero_pos - 1 . 0f ) > 1 . e - 6 ) <nl> + a = ( normalized_pos - linear_zero_pos ) / ( 1 . 0f - linear_zero_pos ) ; <nl> + else <nl> + a = normalized_pos ; <nl> + a = powf ( a , power ) ; <nl> + new_value = ImLerp ( ImMax ( v_min , 0 . 0f ) , v_max , a ) ; <nl> } <nl> + } <nl> + else <nl> + { <nl> + / / Linear slider <nl> + new_value = ImLerp ( v_min , v_max , normalized_pos ) ; <nl> + } <nl> <nl> - / / Round past decimal precision <nl> - / / 0 - > 1 , 1 - > 0 . 1 , 2 - > 0 . 01 , etc . <nl> - / / So when our value is 1 . 99999 with a precision of 0 . 001 we ' ll end up rounding to 2 . 0 <nl> - const float min_step = 1 . 0f / powf ( 10 . 0f , ( float ) decimal_precision ) ; <nl> - const float remainder = fmodf ( new_value , min_step ) ; <nl> - if ( remainder < = min_step * 0 . 5f ) <nl> - new_value - = remainder ; <nl> - else <nl> - new_value + = ( min_step - remainder ) ; <nl> + / / Round past decimal precision <nl> + / / 0 - > 1 , 1 - > 0 . 1 , 2 - > 0 . 01 , etc . <nl> + / / So when our value is 1 . 99999 with a precision of 0 . 001 we ' ll end up rounding to 2 . 0 <nl> + const float min_step = 1 . 0f / powf ( 10 . 0f , ( float ) decimal_precision ) ; <nl> + const float remainder = fmodf ( new_value , min_step ) ; <nl> + if ( remainder < = min_step * 0 . 5f ) <nl> + new_value - = remainder ; <nl> + else <nl> + new_value + = ( min_step - remainder ) ; <nl> <nl> - if ( * v ! = new_value ) <nl> - { <nl> - * v = new_value ; <nl> - value_changed = true ; <nl> - } <nl> + if ( * v ! = new_value ) <nl> + { <nl> + * v = new_value ; <nl> + value_changed = true ; <nl> } <nl> } <nl> else <nl> bool ImGui : : SliderFloat ( const char * label , float * v , float v_min , float v_max , c <nl> window - > DrawList - > AddRectFilled ( grab_bb . Min , grab_bb . Max , window - > Color ( g . ActiveId = = id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab ) ) ; <nl> } <nl> <nl> - / / Draw value using user - provided display format so user can add prefix / suffix / decorations to the value . <nl> + / / Display value using user - provided display format so user can add prefix / suffix / decorations to the value . <nl> char value_buf [ 64 ] ; <nl> char * value_buf_end = value_buf + ImFormatString ( value_buf , IM_ARRAYSIZE ( value_buf ) , display_format , * v ) ; <nl> const ImVec2 value_text_size = CalcTextSize ( value_buf , value_buf_end , true ) ; <nl>
Slider code syntax tweaks
ocornut/imgui
72855becabb989146b319fab2e385f8972bdcad6
2015-03-14T09:36:15Z
new file mode 100644 <nl> index 0000000000 . . 78898e28f5 <nl> mmm / dev / null <nl> ppp b / change / react - native - windows - 2020 - 02 - 06 - 10 - 15 - 05 - accessibilityLiveRegionFix . json <nl> <nl> + { <nl> + " type " : " prerelease " , <nl> + " comment " : " Enable screen reader announcements for accessibilityLiveRegion " , <nl> + " packageName " : " react - native - windows " , <nl> + " email " : " jagorrin @ microsoft . com " , <nl> + " commit " : " 4571c3c9445b1e31fbb623393644aef9e9fe6c09 " , <nl> + " dependentChangeType " : " patch " , <nl> + " date " : " 2020 - 02 - 06T18 : 15 : 05 . 072Z " <nl> + } <nl> \ No newline at end of file <nl> mmm a / vnext / ReactUWP / Views / FrameworkElementViewManager . cpp <nl> ppp b / vnext / ReactUWP / Views / FrameworkElementViewManager . cpp <nl> void FrameworkElementViewManager : : TransferProperties ( XamlView oldView , XamlView <nl> <nl> folly : : dynamic FrameworkElementViewManager : : GetNativeProps ( ) const { <nl> folly : : dynamic props = Super : : GetNativeProps ( ) ; <nl> - props . update ( <nl> - folly : : dynamic : : object ( " accessible " , " boolean " ) ( " accessibilityRole " , " string " ) ( " accessibilityStates " , " array " ) ( <nl> - " accessibilityHint " , " string " ) ( " accessibilityLabel " , " string " ) ( " accessibilityPosInSet " , " number " ) ( <nl> - " accessibilitySetSize " , " number " ) ( " testID " , " string " ) ( " tooltip " , " string " ) ( " accessibilityActions " , " array " ) ) ; <nl> + props . update ( folly : : dynamic : : object ( " accessible " , " boolean " ) ( " accessibilityRole " , " string " ) ( <nl> + " accessibilityStates " , " array " ) ( " accessibilityHint " , " string " ) ( " accessibilityLabel " , " string " ) ( <nl> + " accessibilityPosInSet " , " number " ) ( " accessibilitySetSize " , " number " ) ( " testID " , " string " ) ( " tooltip " , " string " ) ( <nl> + " accessibilityActions " , " array " ) ( " accessibilityLiveRegion " , " string " ) ) ; <nl> return props ; <nl> } <nl> <nl>
Enable screen reader announcements for accessibilityLiveRegion ( )
microsoft/react-native-windows
ffaa1051f2f2f154630e710596bae3dea5ae4aa1
2020-02-07T21:28:49Z
mmm a / util / env_posix . cc <nl> ppp b / util / env_posix . cc <nl> <nl> # include " util / posix_logger . h " <nl> # include " util / string_util . h " <nl> # include " util / sync_point . h " <nl> + # include " util / thread_local . h " <nl> # include " util / thread_status_updater . h " <nl> <nl> # if ! defined ( TMPFS_MAGIC ) <nl> std : : string Env : : GenerateUniqueId ( ) { <nl> } <nl> <nl> Env * Env : : Default ( ) { <nl> + / / The following function call initializes the singletons of ThreadLocalPtr <nl> + / / right before the static default_env . This guarantees default_env will <nl> + / / always being destructed before the ThreadLocalPtr singletons get <nl> + / / destructed as C + + guarantees that the destructions of static variables <nl> + / / is in the reverse order of their constructions . <nl> + / / <nl> + / / Since static members are destructed in the reverse order <nl> + / / of their construction , having this call here guarantees that <nl> + / / the destructor of static PosixEnv will go first , then the <nl> + / / the singletons of ThreadLocalPtr . <nl> + ThreadLocalPtr : : InitSingletons ( ) ; <nl> static PosixEnv default_env ; <nl> return & default_env ; <nl> } <nl> mmm a / util / thread_local . cc <nl> ppp b / util / thread_local . cc <nl> <nl> <nl> namespace rocksdb { <nl> <nl> - port : : Mutex ThreadLocalPtr : : StaticMeta : : mutex_ ; <nl> # if ROCKSDB_SUPPORT_THREAD_LOCAL <nl> __thread ThreadLocalPtr : : ThreadData * ThreadLocalPtr : : StaticMeta : : tls_ = nullptr ; <nl> # endif <nl> PIMAGE_TLS_CALLBACK p_thread_callback_on_exit = wintlscleanup : : WinOnThreadExit ; <nl> <nl> # endif / / OS_WIN <nl> <nl> + void ThreadLocalPtr : : InitSingletons ( ) { <nl> + ThreadLocalPtr : : StaticMeta : : InitSingletons ( ) ; <nl> + ThreadLocalPtr : : Instance ( ) ; <nl> + } <nl> + <nl> ThreadLocalPtr : : StaticMeta * ThreadLocalPtr : : Instance ( ) { <nl> + / / Here we prefer function static variable instead of global <nl> + / / static variable as function static variable is initialized <nl> + / / when the function is first call . As a result , we can properly <nl> + / / control their construction order by properly preparing their <nl> + / / first function call . <nl> static ThreadLocalPtr : : StaticMeta inst ; <nl> return & inst ; <nl> } <nl> <nl> + void ThreadLocalPtr : : StaticMeta : : InitSingletons ( ) { Mutex ( ) ; } <nl> + <nl> + port : : Mutex * ThreadLocalPtr : : StaticMeta : : Mutex ( ) { <nl> + / / Here we prefer function static variable instead of global <nl> + / / static variable as function static variable is initialized <nl> + / / when the function is first call . As a result , we can properly <nl> + / / control their construction order by properly preparing their <nl> + / / first function call . <nl> + static port : : Mutex mutex ; <nl> + return & mutex ; <nl> + } <nl> + <nl> void ThreadLocalPtr : : StaticMeta : : OnThreadExit ( void * ptr ) { <nl> auto * tls = static_cast < ThreadData * > ( ptr ) ; <nl> assert ( tls ! = nullptr ) ; <nl> void ThreadLocalPtr : : StaticMeta : : OnThreadExit ( void * ptr ) { <nl> auto * inst = Instance ( ) ; <nl> pthread_setspecific ( inst - > pthread_key_ , nullptr ) ; <nl> <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> inst - > RemoveThreadData ( tls ) ; <nl> / / Unref stored pointers of current thread from all instances <nl> uint32_t id = 0 ; <nl> ThreadLocalPtr : : StaticMeta : : StaticMeta ( ) : next_instance_id_ ( 0 ) { <nl> } <nl> <nl> void ThreadLocalPtr : : StaticMeta : : AddThreadData ( ThreadLocalPtr : : ThreadData * d ) { <nl> - mutex_ . AssertHeld ( ) ; <nl> + Mutex ( ) - > AssertHeld ( ) ; <nl> d - > next = & head_ ; <nl> d - > prev = head_ . prev ; <nl> head_ . prev - > next = d ; <nl> void ThreadLocalPtr : : StaticMeta : : AddThreadData ( ThreadLocalPtr : : ThreadData * d ) { <nl> <nl> void ThreadLocalPtr : : StaticMeta : : RemoveThreadData ( <nl> ThreadLocalPtr : : ThreadData * d ) { <nl> - mutex_ . AssertHeld ( ) ; <nl> + Mutex ( ) - > AssertHeld ( ) ; <nl> d - > next - > prev = d - > prev ; <nl> d - > prev - > next = d - > next ; <nl> d - > next = d - > prev = d ; <nl> ThreadLocalPtr : : ThreadData * ThreadLocalPtr : : StaticMeta : : GetThreadLocal ( ) { <nl> { <nl> / / Register it in the global chain , needs to be done before thread exit <nl> / / handler registration <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> inst - > AddThreadData ( tls_ ) ; <nl> } <nl> / / Even it is not OS_MACOSX , need to register value for pthread_key_ so that <nl> / / its exit handler will be triggered . <nl> if ( pthread_setspecific ( inst - > pthread_key_ , tls_ ) ! = 0 ) { <nl> { <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> inst - > RemoveThreadData ( tls_ ) ; <nl> } <nl> delete tls_ ; <nl> void ThreadLocalPtr : : StaticMeta : : Reset ( uint32_t id , void * ptr ) { <nl> auto * tls = GetThreadLocal ( ) ; <nl> if ( UNLIKELY ( id > = tls - > entries . size ( ) ) ) { <nl> / / Need mutex to protect entries access within ReclaimId <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> tls - > entries . resize ( id + 1 ) ; <nl> } <nl> tls - > entries [ id ] . ptr . store ( ptr , std : : memory_order_release ) ; <nl> void * ThreadLocalPtr : : StaticMeta : : Swap ( uint32_t id , void * ptr ) { <nl> auto * tls = GetThreadLocal ( ) ; <nl> if ( UNLIKELY ( id > = tls - > entries . size ( ) ) ) { <nl> / / Need mutex to protect entries access within ReclaimId <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> tls - > entries . resize ( id + 1 ) ; <nl> } <nl> return tls - > entries [ id ] . ptr . exchange ( ptr , std : : memory_order_acquire ) ; <nl> bool ThreadLocalPtr : : StaticMeta : : CompareAndSwap ( uint32_t id , void * ptr , <nl> auto * tls = GetThreadLocal ( ) ; <nl> if ( UNLIKELY ( id > = tls - > entries . size ( ) ) ) { <nl> / / Need mutex to protect entries access within ReclaimId <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> tls - > entries . resize ( id + 1 ) ; <nl> } <nl> return tls - > entries [ id ] . ptr . compare_exchange_strong ( <nl> bool ThreadLocalPtr : : StaticMeta : : CompareAndSwap ( uint32_t id , void * ptr , <nl> <nl> void ThreadLocalPtr : : StaticMeta : : Scrape ( uint32_t id , autovector < void * > * ptrs , <nl> void * const replacement ) { <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> for ( ThreadData * t = head_ . next ; t ! = & head_ ; t = t - > next ) { <nl> if ( id < t - > entries . size ( ) ) { <nl> void * ptr = <nl> void ThreadLocalPtr : : StaticMeta : : Scrape ( uint32_t id , autovector < void * > * ptrs , <nl> } <nl> <nl> void ThreadLocalPtr : : StaticMeta : : SetHandler ( uint32_t id , UnrefHandler handler ) { <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> handler_map_ [ id ] = handler ; <nl> } <nl> <nl> UnrefHandler ThreadLocalPtr : : StaticMeta : : GetHandler ( uint32_t id ) { <nl> - mutex_ . AssertHeld ( ) ; <nl> + Mutex ( ) - > AssertHeld ( ) ; <nl> auto iter = handler_map_ . find ( id ) ; <nl> if ( iter = = handler_map_ . end ( ) ) { <nl> return nullptr ; <nl> UnrefHandler ThreadLocalPtr : : StaticMeta : : GetHandler ( uint32_t id ) { <nl> } <nl> <nl> uint32_t ThreadLocalPtr : : StaticMeta : : GetId ( ) { <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> if ( free_instance_ids_ . empty ( ) ) { <nl> return next_instance_id_ + + ; <nl> } <nl> uint32_t ThreadLocalPtr : : StaticMeta : : GetId ( ) { <nl> } <nl> <nl> uint32_t ThreadLocalPtr : : StaticMeta : : PeekId ( ) const { <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> if ( ! free_instance_ids_ . empty ( ) ) { <nl> return free_instance_ids_ . back ( ) ; <nl> } <nl> uint32_t ThreadLocalPtr : : StaticMeta : : PeekId ( ) const { <nl> void ThreadLocalPtr : : StaticMeta : : ReclaimId ( uint32_t id ) { <nl> / / This id is not used , go through all thread local data and release <nl> / / corresponding value <nl> - MutexLock l ( & mutex_ ) ; <nl> + MutexLock l ( Mutex ( ) ) ; <nl> auto unref = GetHandler ( id ) ; <nl> for ( ThreadData * t = head_ . next ; t ! = & head_ ; t = t - > next ) { <nl> if ( id < t - > entries . size ( ) ) { <nl> mmm a / util / thread_local . h <nl> ppp b / util / thread_local . h <nl> class ThreadLocalPtr { <nl> / / data for all existing threads <nl> void Scrape ( autovector < void * > * ptrs , void * const replacement ) ; <nl> <nl> + / / Initialize the static singletons of the ThreadLocalPtr . <nl> + / / <nl> + / / If this function is not called , then the singletons will be <nl> + / / automatically initialized when they are used . <nl> + / / <nl> + / / Calling this function twice or after the singletons have been <nl> + / / initialized will be no - op . <nl> + static void InitSingletons ( ) ; <nl> + <nl> protected : <nl> struct Entry { <nl> Entry ( ) : ptr ( nullptr ) { } <nl> class ThreadLocalPtr { <nl> / / Register the UnrefHandler for id <nl> void SetHandler ( uint32_t id , UnrefHandler handler ) ; <nl> <nl> + / / Initialize all the singletons associated with StaticMeta . <nl> + / / <nl> + / / If this function is not called , then the singletons will be <nl> + / / automatically initialized when they are used . <nl> + / / <nl> + / / Calling this function twice or after the singletons have been <nl> + / / initialized will be no - op . <nl> + static void InitSingletons ( ) ; <nl> + <nl> private : <nl> / / Get UnrefHandler for id with acquiring mutex <nl> / / REQUIRES : mutex locked <nl> class ThreadLocalPtr { <nl> <nl> / / protect inst , next_instance_id_ , free_instance_ids_ , head_ , <nl> / / ThreadData . entries <nl> - static port : : Mutex mutex_ ; <nl> + / / <nl> + / / Note that here we prefer function static variable instead of the usual <nl> + / / global static variable . The reason is that c + + destruction order of <nl> + / / static variables in the reverse order of their construction order . <nl> + / / However , C + + does not guarantee any construction order when global <nl> + / / static variables are defined in different files , while the function <nl> + / / static variables are initialized when their function are first called . <nl> + / / As a result , the construction order of the function static variables <nl> + / / can be controlled by properly invoke their first function calls in <nl> + / / the right order . <nl> + / / <nl> + / / For instance , the following function contains a function static <nl> + / / variable . We place a dummy function call of this inside <nl> + / / Env : : Default ( ) to ensure the construction order of the construction <nl> + / / order . <nl> + static port : : Mutex * Mutex ( ) ; <nl> # if ROCKSDB_SUPPORT_THREAD_LOCAL <nl> / / Thread local storage <nl> static __thread ThreadData * tls_ ; <nl>
Ensure the destruction order of PosixEnv and ThreadLocalPtr
facebook/rocksdb
00d6edf6a0080ac3961e56213ae962ec1d570daa
2015-12-11T08:21:58Z
mmm a / include / swift / Sema / IDETypeChecking . h <nl> ppp b / include / swift / Sema / IDETypeChecking . h <nl> namespace swift { <nl> Expr * & parsedExpr , <nl> ConcreteDeclRef & referencedDecl ) ; <nl> <nl> - / / / Typecheck the sequence expression \ p parsedExpr for code completion . <nl> + / / / Resolve type of operator function with \ c opName appending it to \ c LHS . <nl> / / / <nl> - / / / This requires that \ p parsedExpr is a SequenceExpr and that it contains : <nl> - / / / * . . . leading sequence LHS <nl> - / / / * UnresolvedDeclRefExpr operator <nl> - / / / * CodeCompletionExpr RHS <nl> - / / / <nl> - / / / On success , returns false , and replaces parsedExpr with the binary <nl> - / / / expression corresponding to the operator . The type of the operator and <nl> - / / / RHS are also set , but the rest of the expression may not be typed <nl> - / / / <nl> - / / / The LHS should already be type - checked or this will be very slow . <nl> - bool typeCheckCompletionSequence ( DeclContext * DC , Expr * & parsedExpr ) ; <nl> + / / / For \ p refKind , use \ c DeclRefKind : : PostfixOperator for postfix operator , <nl> + / / / or \ c DeclRefKind : : BinaryOperator for infix operator . <nl> + / / / On success , returns resolved function type of the operator . The LHS should <nl> + / / / already be type - checked . This function guarantees LHS not to be modified . <nl> + FunctionType * getTypeOfCompletionOperator ( DeclContext * DC , Expr * LHS , <nl> + Identifier opName , <nl> + DeclRefKind refKind , <nl> + ConcreteDeclRef & referencedDecl ) ; <nl> <nl> / / / Typecheck the given expression . <nl> bool typeCheckExpression ( DeclContext * DC , Expr * & parsedExpr ) ; <nl> mmm a / lib / IDE / CodeCompletion . cpp <nl> ppp b / lib / IDE / CodeCompletion . cpp <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> } <nl> <nl> void tryPostfixOperator ( Expr * expr , PostfixOperatorDecl * op ) { <nl> - auto Ty = expr - > getType ( ) ; <nl> - if ( ! Ty ) <nl> + ConcreteDeclRef referencedDecl ; <nl> + FunctionType * funcTy = getTypeOfCompletionOperator ( <nl> + const_cast < DeclContext * > ( CurrDeclContext ) , expr , op - > getName ( ) , <nl> + DeclRefKind : : PostfixOperator , referencedDecl ) ; <nl> + if ( ! funcTy ) <nl> return ; <nl> <nl> - SWIFT_DEFER { <nl> - / / Restore type . <nl> - / / FIXME : This is workaround for getTypeOfExpressionWithoutApplying ( ) <nl> - / / modifies type of ' expr ' . <nl> - expr - > setType ( Ty ) ; <nl> - prepareForRetypechecking ( expr ) ; <nl> - } ; <nl> - <nl> - / / We allocate these expressions on the stack because we know they can ' t <nl> - / / escape and there isn ' t a better way to allocate scratch Expr nodes . <nl> - UnresolvedDeclRefExpr UDRE ( op - > getName ( ) , DeclRefKind : : PostfixOperator , <nl> - DeclNameLoc ( expr - > getSourceRange ( ) . End ) ) ; <nl> - ParenExpr parenExpr ( expr - > getSourceRange ( ) . Start , expr , <nl> - expr - > getSourceRange ( ) . End , <nl> - / * hasTrailingClosure = * / false ) ; <nl> - PostfixUnaryExpr opExpr ( & UDRE , & parenExpr ) ; <nl> - Expr * tempExpr = & opExpr ; <nl> - ConcreteDeclRef referencedDecl ; <nl> - if ( auto T = getTypeOfCompletionContextExpr ( <nl> - CurrDeclContext - > getASTContext ( ) , <nl> - const_cast < DeclContext * > ( CurrDeclContext ) , <nl> - CompletionTypeCheckKind : : Normal , <nl> - tempExpr , <nl> - referencedDecl ) ) <nl> - addPostfixOperatorCompletion ( op , * T ) ; <nl> + / / TODO : Use referencedDecl ( FuncDecl ) instead of ' op ' ( OperatorDecl ) . <nl> + addPostfixOperatorCompletion ( op , funcTy - > getResult ( ) ) ; <nl> } <nl> <nl> void addAssignmentOperator ( Type RHSType , Type resultType ) { <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> addTypeAnnotation ( builder , resultType ) ; <nl> } <nl> <nl> - void tryInfixOperatorCompletion ( InfixOperatorDecl * op , SequenceExpr * SE ) { <nl> - if ( op - > getName ( ) . str ( ) = = " ~ > " ) <nl> - return ; <nl> - <nl> - MutableArrayRef < Expr * > sequence = SE - > getElements ( ) ; <nl> - assert ( sequence . size ( ) > = 3 & & ! sequence . back ( ) & & <nl> - ! sequence . drop_back ( 1 ) . back ( ) & & " sequence not cleaned up " ) ; <nl> - assert ( ( sequence . size ( ) & 1 ) & & " sequence expr ending with operator " ) ; <nl> - <nl> - / / FIXME : these checks should apply to the LHS of the operator , not the <nl> - / / immediately left expression . Move under the type - checking . <nl> - Expr * LHS = sequence . drop_back ( 2 ) . back ( ) ; <nl> - if ( LHS - > getType ( ) & & ( LHS - > getType ( ) - > is < MetatypeType > ( ) | | <nl> - LHS - > getType ( ) - > is < AnyFunctionType > ( ) ) ) <nl> + void tryInfixOperatorCompletion ( Expr * foldedExpr , InfixOperatorDecl * op ) { <nl> + ConcreteDeclRef referencedDecl ; <nl> + FunctionType * funcTy = getTypeOfCompletionOperator ( <nl> + const_cast < DeclContext * > ( CurrDeclContext ) , foldedExpr , op - > getName ( ) , <nl> + DeclRefKind : : BinaryOperator , referencedDecl ) ; <nl> + if ( ! funcTy ) <nl> return ; <nl> <nl> - / / Preserve LHS type for restoring it . <nl> - Type LHSTy = LHS - > getType ( ) ; <nl> - <nl> - / / We allocate these expressions on the stack because we know they can ' t <nl> - / / escape and there isn ' t a better way to allocate scratch Expr nodes . <nl> - UnresolvedDeclRefExpr UDRE ( op - > getName ( ) , DeclRefKind : : BinaryOperator , <nl> - DeclNameLoc ( LHS - > getEndLoc ( ) ) ) ; <nl> - sequence . drop_back ( 1 ) . back ( ) = & UDRE ; <nl> - CodeCompletionExpr CCE ( LHS - > getSourceRange ( ) ) ; <nl> - sequence . back ( ) = & CCE ; <nl> - <nl> - SWIFT_DEFER { <nl> - / / Reset sequence . <nl> - SE - > setElement ( SE - > getNumElements ( ) - 1 , nullptr ) ; <nl> - SE - > setElement ( SE - > getNumElements ( ) - 2 , nullptr ) ; <nl> - LHS - > setType ( LHSTy ) ; <nl> - prepareForRetypechecking ( SE ) ; <nl> - <nl> - for ( auto & element : sequence . drop_back ( 2 ) ) { <nl> - / / Unfold expressions for re - typechecking sequence . <nl> - if ( auto * assignExpr = dyn_cast_or_null < AssignExpr > ( element ) ) { <nl> - assignExpr - > setSrc ( nullptr ) ; <nl> - assignExpr - > setDest ( nullptr ) ; <nl> - } else if ( auto * ifExpr = dyn_cast_or_null < IfExpr > ( element ) ) { <nl> - ifExpr - > setCondExpr ( nullptr ) ; <nl> - ifExpr - > setElseExpr ( nullptr ) ; <nl> - } <nl> - <nl> - / / Reset any references to operators in types , so they are properly <nl> - / / handled as operators by sequence folding . <nl> - / / <nl> - / / FIXME : Would be better to have some kind of ' OperatorRefExpr ' ? <nl> - if ( auto operatorRef = element - > getMemberOperatorRef ( ) ) { <nl> - operatorRef - > setType ( nullptr ) ; <nl> - element = operatorRef ; <nl> - } <nl> - } <nl> - } ; <nl> + Type lhsTy = funcTy - > getParams ( ) [ 0 ] . getPlainType ( ) ; <nl> + Type rhsTy = funcTy - > getParams ( ) [ 1 ] . getPlainType ( ) ; <nl> + Type resultTy = funcTy - > getResult ( ) ; <nl> <nl> - Expr * expr = SE ; <nl> - if ( ! typeCheckCompletionSequence ( const_cast < DeclContext * > ( CurrDeclContext ) , <nl> - expr ) ) { <nl> - if ( ! LHS - > getType ( ) | | <nl> - ! LHS - > getType ( ) - > getRValueType ( ) - > getOptionalObjectType ( ) ) { <nl> - / / Don ' t complete optional operators on non - optional types . <nl> - / / FIXME : can we get the type - checker to disallow these for us ? <nl> - if ( op - > getName ( ) . str ( ) = = " ? ? " ) <nl> + / / Don ' t complete optional operators on non - optional types . <nl> + if ( ! lhsTy - > getRValueType ( ) - > getOptionalObjectType ( ) ) { <nl> + / / ' T ? ? T ' <nl> + if ( op - > getName ( ) . str ( ) = = " ? ? " ) <nl> + return ; <nl> + / / ' T = = nil ' <nl> + if ( auto NT = rhsTy - > getNominalOrBoundGenericNominal ( ) ) <nl> + if ( NT - > getName ( ) = = <nl> + CurrDeclContext - > getASTContext ( ) . Id_OptionalNilComparisonType ) <nl> return ; <nl> - if ( auto NT = CCE . getType ( ) - > getNominalOrBoundGenericNominal ( ) ) { <nl> - if ( NT - > getName ( ) = = <nl> - CurrDeclContext - > getASTContext ( ) . Id_OptionalNilComparisonType ) <nl> - return ; <nl> - } <nl> - } <nl> + } <nl> <nl> - / / If the right - hand side and result type are both type parameters , we ' re <nl> - / / not providing a useful completion . <nl> - if ( expr - > getType ( ) - > isTypeParameter ( ) & & <nl> - CCE . getType ( ) - > isTypeParameter ( ) ) <nl> - return ; <nl> + / / If the right - hand side and result type are both type parameters , we ' re <nl> + / / not providing a useful completion . <nl> + if ( resultTy - > isTypeParameter ( ) & & rhsTy - > isTypeParameter ( ) ) <nl> + return ; <nl> <nl> - addInfixOperatorCompletion ( op , expr - > getType ( ) , CCE . getType ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - void flattenBinaryExpr ( Expr * expr , SmallVectorImpl < Expr * > & sequence ) { <nl> - if ( auto binExpr = dyn_cast < BinaryExpr > ( expr ) ) { <nl> - flattenBinaryExpr ( binExpr - > getArg ( ) - > getElement ( 0 ) , sequence ) ; <nl> - sequence . push_back ( binExpr - > getFn ( ) ) ; <nl> - flattenBinaryExpr ( binExpr - > getArg ( ) - > getElement ( 1 ) , sequence ) ; <nl> - } else if ( auto assignExpr = dyn_cast < AssignExpr > ( expr ) ) { <nl> - flattenBinaryExpr ( assignExpr - > getDest ( ) , sequence ) ; <nl> - sequence . push_back ( assignExpr ) ; <nl> - flattenBinaryExpr ( assignExpr - > getSrc ( ) , sequence ) ; <nl> - assignExpr - > setDest ( nullptr ) ; <nl> - assignExpr - > setSrc ( nullptr ) ; <nl> - } else if ( auto ifExpr = dyn_cast < IfExpr > ( expr ) ) { <nl> - flattenBinaryExpr ( ifExpr - > getCondExpr ( ) , sequence ) ; <nl> - sequence . push_back ( ifExpr ) ; <nl> - flattenBinaryExpr ( ifExpr - > getElseExpr ( ) , sequence ) ; <nl> - ifExpr - > setCondExpr ( nullptr ) ; <nl> - ifExpr - > setElseExpr ( nullptr ) ; <nl> - } else if ( auto tryExpr = dyn_cast < AnyTryExpr > ( expr ) ) { <nl> - / / Strip out try expression . It doesn ' t affect completion . <nl> - flattenBinaryExpr ( tryExpr - > getSubExpr ( ) , sequence ) ; <nl> - } else if ( auto optEval = dyn_cast < OptionalEvaluationExpr > ( expr ) ) { <nl> - / / Strip out optional evaluation expression . It doesn ' t affect completion . <nl> - flattenBinaryExpr ( optEval - > getSubExpr ( ) , sequence ) ; <nl> - } else { <nl> - sequence . push_back ( expr ) ; <nl> - } <nl> + / / TODO : Use referencedDecl ( FuncDecl ) instead of ' op ' ( OperatorDecl ) . <nl> + addInfixOperatorCompletion ( op , funcTy - > getResult ( ) , <nl> + funcTy - > getParams ( ) [ 1 ] . getPlainType ( ) ) ; <nl> } <nl> <nl> - void typeCheckLeadingSequence ( SmallVectorImpl < Expr * > & sequence ) { <nl> + Expr * typeCheckLeadingSequence ( Expr * LHS , ArrayRef < Expr * > leadingSequence ) { <nl> + if ( leadingSequence . empty ( ) ) <nl> + return LHS ; <nl> <nl> - / / Strip out try and optional evaluation expr because foldSequence ( ) mutates <nl> - / / hierarchy of these expressions . They don ' t affect completion anyway . <nl> - for ( auto & element : sequence ) { <nl> - if ( auto * tryExpr = dyn_cast < AnyTryExpr > ( element ) ) <nl> - element = tryExpr - > getSubExpr ( ) ; <nl> - if ( auto * optEval = dyn_cast < OptionalEvaluationExpr > ( element ) ) <nl> - element = optEval - > getSubExpr ( ) ; <nl> - } <nl> + assert ( leadingSequence . size ( ) % 2 = = 0 ) ; <nl> + SmallVector < Expr * , 3 > sequence ( leadingSequence . begin ( ) , <nl> + leadingSequence . end ( ) ) ; <nl> + sequence . push_back ( LHS ) ; <nl> <nl> Expr * expr = <nl> SequenceExpr : : create ( CurrDeclContext - > getASTContext ( ) , sequence ) ; <nl> prepareForRetypechecking ( expr ) ; <nl> - / / Take advantage of the fact the type - checker leaves the types on the AST . <nl> if ( ! typeCheckExpression ( const_cast < DeclContext * > ( CurrDeclContext ) , <nl> expr ) ) { <nl> - / / Rebuild the sequence from the type - checked version . <nl> - sequence . clear ( ) ; <nl> - flattenBinaryExpr ( expr , sequence ) ; <nl> - return ; <nl> + return expr ; <nl> } <nl> - <nl> - / / Fall back to just using the immediate LHS . <nl> - auto LHS = sequence . back ( ) ; <nl> - sequence . clear ( ) ; <nl> - sequence . push_back ( LHS ) ; <nl> + return LHS ; <nl> } <nl> <nl> void getOperatorCompletions ( Expr * LHS , ArrayRef < Expr * > leadingSequence ) { <nl> - std : : vector < OperatorDecl * > operators = collectOperators ( ) ; <nl> + Expr * foldedExpr = typeCheckLeadingSequence ( LHS , leadingSequence ) ; <nl> <nl> + std : : vector < OperatorDecl * > operators = collectOperators ( ) ; <nl> / / FIXME : this always chooses the first operator with the given name . <nl> llvm : : DenseSet < Identifier > seenPostfixOperators ; <nl> llvm : : DenseSet < Identifier > seenInfixOperators ; <nl> <nl> - SmallVector < Expr * , 3 > sequence ( leadingSequence . begin ( ) , <nl> - leadingSequence . end ( ) ) ; <nl> - sequence . push_back ( LHS ) ; <nl> - assert ( ( sequence . size ( ) & 1 ) & & " sequence expr ending with operator " ) ; <nl> - <nl> - if ( sequence . size ( ) > 1 ) <nl> - typeCheckLeadingSequence ( sequence ) ; <nl> - <nl> - / / Retrieve typechecked LHS . <nl> - LHS = sequence . back ( ) ; <nl> - <nl> - / / Create a single sequence expression , which we will modify for each <nl> - / / operator , filling in the operator and dummy right - hand side . <nl> - sequence . push_back ( nullptr ) ; / / operator <nl> - sequence . push_back ( nullptr ) ; / / RHS <nl> - auto * SE = SequenceExpr : : create ( CurrDeclContext - > getASTContext ( ) , sequence ) ; <nl> - prepareForRetypechecking ( SE ) ; <nl> - <nl> for ( auto op : operators ) { <nl> switch ( op - > getKind ( ) ) { <nl> case DeclKind : : PrefixOperator : <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> break ; <nl> case DeclKind : : InfixOperator : <nl> if ( seenInfixOperators . insert ( op - > getName ( ) ) . second ) <nl> - tryInfixOperatorCompletion ( cast < InfixOperatorDecl > ( op ) , SE ) ; <nl> + tryInfixOperatorCompletion ( foldedExpr , cast < InfixOperatorDecl > ( op ) ) ; <nl> break ; <nl> default : <nl> llvm_unreachable ( " unexpected operator kind " ) ; <nl> mmm a / lib / Sema / CSGen . cpp <nl> ppp b / lib / Sema / CSGen . cpp <nl> namespace { <nl> class LinkedExprCollector : public ASTWalker { <nl> <nl> llvm : : SmallVectorImpl < Expr * > & LinkedExprs ; <nl> + ConstraintSystem & CS ; <nl> <nl> public : <nl> - <nl> - LinkedExprCollector ( llvm : : SmallVectorImpl < Expr * > & linkedExprs ) : <nl> - LinkedExprs ( linkedExprs ) { } <nl> - <nl> + LinkedExprCollector ( llvm : : SmallVectorImpl < Expr * > & linkedExprs , <nl> + ConstraintSystem & cs ) <nl> + : LinkedExprs ( linkedExprs ) , CS ( cs ) { } <nl> + <nl> std : : pair < bool , Expr * > walkToExprPre ( Expr * expr ) override { <nl> - <nl> + <nl> + if ( CS . shouldReusePrecheckedType ( ) & & <nl> + ! CS . getType ( expr ) - > hasTypeVariable ( ) ) { <nl> + return { false , expr } ; <nl> + } <nl> + <nl> / / Store top - level binary exprs for further analysis . <nl> if ( isa < BinaryExpr > ( expr ) | | <nl> <nl> namespace { <nl> LTI ( lti ) , CS ( cs ) { } <nl> <nl> std : : pair < bool , Expr * > walkToExprPre ( Expr * expr ) override { <nl> + <nl> + if ( CS . shouldReusePrecheckedType ( ) & & <nl> + ! CS . getType ( expr ) - > hasTypeVariable ( ) ) { <nl> + return { false , expr } ; <nl> + } <nl> <nl> if ( isa < IntegerLiteralExpr > ( expr ) ) { <nl> LTI . haveIntLiteral = true ; <nl> namespace { <nl> CS ( cs ) { } <nl> <nl> std : : pair < bool , Expr * > walkToExprPre ( Expr * expr ) override { <nl> + <nl> + if ( CS . shouldReusePrecheckedType ( ) & & <nl> + ! CS . getType ( expr ) - > hasTypeVariable ( ) ) { <nl> + return { false , expr } ; <nl> + } <nl> <nl> if ( auto applyExpr = dyn_cast < ApplyExpr > ( expr ) ) { <nl> if ( isa < PrefixUnaryExpr > ( applyExpr ) | | <nl> namespace { <nl> <nl> std : : pair < bool , Expr * > walkToExprPre ( Expr * expr ) override { <nl> while ( true ) { <nl> + <nl> + / / If we should reuse pre - checked types , don ' t sanitize the expression <nl> + / / if it ' s already type - checked . <nl> + if ( CS . shouldReusePrecheckedType ( ) & & expr - > getType ( ) ) <nl> + return { false , expr } ; <nl> + <nl> / / OpenExistentialExpr contains OpaqueValueExpr in its sub expression . <nl> if ( auto OOE = dyn_cast < OpenExistentialExpr > ( expr ) ) { <nl> auto archetypeVal = OOE - > getOpaqueValue ( ) ; <nl> namespace { <nl> ConstraintWalker ( ConstraintGenerator & CG ) : CG ( CG ) { } <nl> <nl> std : : pair < bool , Expr * > walkToExprPre ( Expr * expr ) override { <nl> + <nl> + if ( CG . getConstraintSystem ( ) . shouldReusePrecheckedType ( ) ) { <nl> + if ( expr - > getType ( ) ) { <nl> + assert ( ! expr - > getType ( ) - > hasTypeVariable ( ) ) ; <nl> + CG . getConstraintSystem ( ) . cacheType ( expr ) ; <nl> + return { false , expr } ; <nl> + } <nl> + } <nl> + <nl> / / Note that the subexpression of a # selector expression is <nl> / / unevaluated . <nl> if ( auto sel = dyn_cast < ObjCSelectorExpr > ( expr ) ) { <nl> void ConstraintSystem : : optimizeConstraints ( Expr * e ) { <nl> SmallVector < Expr * , 16 > linkedExprs ; <nl> <nl> / / Collect any linked expressions . <nl> - LinkedExprCollector collector ( linkedExprs ) ; <nl> + LinkedExprCollector collector ( linkedExprs , * this ) ; <nl> e - > walk ( collector ) ; <nl> <nl> / / Favor types , as appropriate . <nl> mmm a / lib / Sema / ConstraintSystem . h <nl> ppp b / lib / Sema / ConstraintSystem . h <nl> enum class ConstraintSystemFlags { <nl> / / / system is not applied to the expression AST , but the ConstraintSystem is <nl> / / / left in - tact . <nl> AllowUnresolvedTypeVariables = 0x10 , <nl> + <nl> + / / / If set , constraint system always reuses type of pre - typechecked <nl> + / / / expression , and doesn ' t dig into its subexpressions . <nl> + ReusePrecheckedType = 0x20 , <nl> } ; <nl> <nl> / / / Options that affect the constraint system as a whole . <nl> class ConstraintSystem { <nl> public : <nl> <nl> / / / \ brief Whether we should attempt to fix problems . <nl> - bool shouldAttemptFixes ( ) { <nl> + bool shouldAttemptFixes ( ) const { <nl> if ( ! ( Options & ConstraintSystemFlags : : AllowFixes ) ) <nl> return false ; <nl> <nl> return ! solverState | | solverState - > recordFixes ; <nl> } <nl> <nl> - bool shouldSuppressDiagnostics ( ) { <nl> + bool shouldSuppressDiagnostics ( ) const { <nl> return Options . contains ( ConstraintSystemFlags : : SuppressDiagnostics ) ; <nl> } <nl> <nl> + bool shouldReusePrecheckedType ( ) const { <nl> + return Options . contains ( ConstraintSystemFlags : : ReusePrecheckedType ) ; <nl> + } <nl> + <nl> / / / \ brief Log and record the application of the fix . Return true iff any <nl> / / / subsequent solution would be worse than the best known solution . <nl> bool recordFix ( ConstraintFix * fix ) ; <nl> mmm a / lib / Sema / TypeCheckConstraints . cpp <nl> ppp b / lib / Sema / TypeCheckConstraints . cpp <nl> void TypeChecker : : getPossibleTypesOfExpressionWithoutApplying ( <nl> } <nl> } <nl> <nl> - bool TypeChecker : : typeCheckCompletionSequence ( Expr * & expr , DeclContext * DC ) { <nl> - FrontendStatsTracer StatsTracer ( Context . Stats , " typecheck - completion - seq " , expr ) ; <nl> - PrettyStackTraceExpr stackTrace ( Context , " type - checking " , expr ) ; <nl> - <nl> - / / Construct a constraint system from this expression . <nl> - ConstraintSystem CS ( * this , DC , ConstraintSystemFlags : : SuppressDiagnostics ) ; <nl> - <nl> - auto * SE = cast < SequenceExpr > ( expr ) ; <nl> - assert ( SE - > getNumElements ( ) > = 3 ) ; <nl> - auto * op = SE - > getElement ( SE - > getNumElements ( ) - 2 ) ; <nl> - auto * CCE = cast < CodeCompletionExpr > ( SE - > getElements ( ) . back ( ) ) ; <nl> - <nl> - / / Resolve the op . <nl> - op = resolveDeclRefExpr ( cast < UnresolvedDeclRefExpr > ( op ) , DC ) ; <nl> - SE - > setElement ( SE - > getNumElements ( ) - 2 , op ) ; <nl> - <nl> - / / Fold the sequence . <nl> - expr = foldSequence ( SE , DC ) ; <nl> - <nl> - / / Find the code - completion expression and operator again . <nl> - Expr * exprAsBinOp = nullptr ; <nl> - while ( true ) { <nl> - Expr * RHS ; <nl> - if ( auto * binExpr = dyn_cast < BinaryExpr > ( expr ) ) <nl> - RHS = binExpr - > getArg ( ) - > getElement ( 1 ) ; <nl> - else if ( auto * assignExpr = dyn_cast < AssignExpr > ( expr ) ) <nl> - RHS = assignExpr - > getSrc ( ) ; <nl> - else if ( auto * ifExpr = dyn_cast < IfExpr > ( expr ) ) <nl> - RHS = ifExpr - > getElseExpr ( ) ; <nl> - else <nl> - break ; <nl> + static FunctionType * <nl> + getTypeOfCompletionOperatorImpl ( TypeChecker & TC , DeclContext * DC , Expr * expr , <nl> + ConcreteDeclRef & referencedDecl ) { <nl> + ASTContext & Context = TC . Context ; <nl> <nl> - if ( RHS = = CCE ) { <nl> - exprAsBinOp = expr ; <nl> - break ; <nl> - } <nl> - expr = RHS ; <nl> - } <nl> - if ( ! exprAsBinOp ) <nl> - return true ; <nl> + FrontendStatsTracer StatsTracer ( Context . Stats , <nl> + " typecheck - completion - operator " , expr ) ; <nl> + PrettyStackTraceExpr stackTrace ( Context , " type - checking " , expr ) ; <nl> <nl> - / / Ensure the output expression is up to date . <nl> - assert ( exprAsBinOp = = expr & & isa < BinaryExpr > ( expr ) & & " found wrong expr ? " ) ; <nl> + ConstraintSystemOptions options ; <nl> + options | = ConstraintSystemFlags : : SuppressDiagnostics ; <nl> + options | = ConstraintSystemFlags : : ReusePrecheckedType ; <nl> <nl> - if ( auto generated = CS . generateConstraints ( expr ) ) { <nl> - expr = generated ; <nl> - } else { <nl> - return true ; <nl> - } <nl> + / / Construct a constraint system from this expression . <nl> + ConstraintSystem CS ( TC , DC , options ) ; <nl> + expr = CS . generateConstraints ( expr ) ; <nl> + if ( ! expr ) <nl> + return nullptr ; <nl> <nl> - if ( getLangOpts ( ) . DebugConstraintSolver ) { <nl> + if ( TC . getLangOpts ( ) . DebugConstraintSolver ) { <nl> auto & log = Context . TypeCheckerDebug - > getStream ( ) ; <nl> log < < " mmmInitial constraints for the given expressionmmm \ n " ; <nl> expr - > dump ( log ) ; <nl> bool TypeChecker : : typeCheckCompletionSequence ( Expr * & expr , DeclContext * DC ) { <nl> / / Attempt to solve the constraint system . <nl> SmallVector < Solution , 4 > viable ; <nl> if ( CS . solve ( expr , viable , FreeTypeVariableBinding : : Disallow ) ) <nl> - return true ; <nl> + return nullptr ; <nl> <nl> auto & solution = viable [ 0 ] ; <nl> - if ( getLangOpts ( ) . DebugConstraintSolver ) { <nl> + if ( TC . getLangOpts ( ) . DebugConstraintSolver ) { <nl> auto & log = Context . TypeCheckerDebug - > getStream ( ) ; <nl> log < < " mmmSolutionmmm \ n " ; <nl> solution . dump ( log ) ; <nl> } <nl> <nl> - auto & solutionCS = solution . getConstraintSystem ( ) ; <nl> - expr - > setType ( solution . simplifyType ( solutionCS . getType ( expr ) ) ) ; <nl> - auto completionType = solution . simplifyType ( solutionCS . getType ( CCE ) ) ; <nl> - CCE - > setType ( completionType ) ; <nl> - return false ; <nl> + / / Fill the results . <nl> + Expr * opExpr = cast < ApplyExpr > ( expr ) - > getFn ( ) ; <nl> + referencedDecl = <nl> + solution . resolveLocatorToDecl ( CS . getConstraintLocator ( opExpr ) ) ; <nl> + <nl> + / / Return ' ( ArgType [ , ArgType ] ) - > ResultType ' as a function type . <nl> + / / We don ' t use the type of the operator expression because we want the types <nl> + / / of the * arguments * instead of the types of the parameters . <nl> + Expr * argsExpr = cast < ApplyExpr > ( expr ) - > getArg ( ) ; <nl> + SmallVector < FunctionType : : Param , 2 > argTypes ; <nl> + if ( auto * PE = dyn_cast < ParenExpr > ( argsExpr ) ) { <nl> + argTypes . emplace_back ( solution . simplifyType ( CS . getType ( PE - > getSubExpr ( ) ) ) ) ; <nl> + } else if ( auto * TE = dyn_cast < TupleExpr > ( argsExpr ) ) { <nl> + for ( auto arg : TE - > getElements ( ) ) <nl> + argTypes . emplace_back ( solution . simplifyType ( CS . getType ( arg ) ) ) ; <nl> + } <nl> + <nl> + return FunctionType : : get ( argTypes , solution . simplifyType ( CS . getType ( expr ) ) ) ; <nl> + } <nl> + <nl> + / / / \ brief Return the type of operator function for specified LHS , or a null <nl> + / / / \ c Type on error . <nl> + FunctionType * <nl> + TypeChecker : : getTypeOfCompletionOperator ( DeclContext * DC , Expr * LHS , <nl> + Identifier opName , DeclRefKind refKind , <nl> + ConcreteDeclRef & referencedDecl ) { <nl> + <nl> + / / For the infix operator , find the actual LHS from pre - folded LHS . <nl> + if ( refKind = = DeclRefKind : : BinaryOperator ) <nl> + LHS = findLHS ( DC , LHS , opName ) ; <nl> + <nl> + if ( ! LHS ) <nl> + return nullptr ; <nl> + <nl> + auto LHSTy = LHS - > getType ( ) ; <nl> + <nl> + / / FIXME : ' UnresolvedType ' still might be typechecked by an operator . <nl> + if ( ! LHSTy | | LHSTy - > is < UnresolvedType > ( ) ) <nl> + return nullptr ; <nl> + <nl> + / / Meta types and function types cannot be a operand of operator expressions . <nl> + if ( LHSTy - > is < MetatypeType > ( ) | | LHSTy - > is < AnyFunctionType > ( ) ) <nl> + return nullptr ; <nl> + <nl> + auto Loc = LHS - > getEndLoc ( ) ; <nl> + <nl> + / / Build temporary expression to typecheck . <nl> + / / We allocate these expressions on the stack because we know they can ' t <nl> + / / escape and there isn ' t a better way to allocate scratch Expr nodes . <nl> + UnresolvedDeclRefExpr UDRE ( opName , refKind , DeclNameLoc ( Loc ) ) ; <nl> + auto * opExpr = resolveDeclRefExpr ( & UDRE , DC ) ; <nl> + <nl> + switch ( refKind ) { <nl> + <nl> + case DeclRefKind : : PostfixOperator : { <nl> + / / ( postfix_unary_expr <nl> + / / ( declref_expr name = < opName > ) <nl> + / / ( paren_expr <nl> + / / ( < LHS > ) ) ) <nl> + ParenExpr Args ( SourceLoc ( ) , LHS , SourceLoc ( ) , <nl> + / * hasTrailingClosure = * / false ) ; <nl> + PostfixUnaryExpr postfixExpr ( opExpr , & Args ) ; <nl> + return getTypeOfCompletionOperatorImpl ( * this , DC , & postfixExpr , <nl> + referencedDecl ) ; <nl> + } <nl> + <nl> + case DeclRefKind : : BinaryOperator : { <nl> + / / ( binary_expr <nl> + / / ( declref_expr name = < opName > ) <nl> + / / ( tuple_expr <nl> + / / ( < LHS > ) <nl> + / / ( code_completion_expr ) ) ) <nl> + CodeCompletionExpr dummyRHS ( Loc ) ; <nl> + auto Args = TupleExpr : : create ( <nl> + Context , SourceLoc ( ) , { LHS , & dummyRHS } , { } , { } , SourceLoc ( ) , <nl> + / * hasTrailingClosure = * / false , / * isImplicit = * / true ) ; <nl> + BinaryExpr binaryExpr ( opExpr , Args , / * isImplicit = * / true ) ; <nl> + <nl> + return getTypeOfCompletionOperatorImpl ( * this , DC , & binaryExpr , <nl> + referencedDecl ) ; <nl> + } <nl> + <nl> + default : <nl> + llvm_unreachable ( " Invalid DeclRefKind for operator completion " ) ; <nl> + } <nl> } <nl> <nl> bool TypeChecker : : typeCheckBinding ( Pattern * & pattern , Expr * & initializer , <nl> mmm a / lib / Sema / TypeCheckExpr . cpp <nl> ppp b / lib / Sema / TypeCheckExpr . cpp <nl> TypeChecker : : lookupPrecedenceGroupForInfixOperator ( DeclContext * DC , Expr * E ) { <nl> return lookupPrecedenceGroupForInfixOperator ( DC , binaryExpr - > getFn ( ) ) ; <nl> } <nl> <nl> + if ( auto * DSCE = dyn_cast < DotSyntaxCallExpr > ( E ) ) { <nl> + return lookupPrecedenceGroupForInfixOperator ( DC , DSCE - > getFn ( ) ) ; <nl> + } <nl> + <nl> + if ( auto * MRE = dyn_cast < MemberRefExpr > ( E ) ) { <nl> + Identifier name = MRE - > getDecl ( ) . getDecl ( ) - > getBaseName ( ) . getIdentifier ( ) ; <nl> + return lookupPrecedenceGroupForOperator ( * this , DC , name , MRE - > getLoc ( ) ) ; <nl> + } <nl> + <nl> / / If E is already an ErrorExpr , then we ' ve diagnosed it as invalid already , <nl> / / otherwise emit an error . <nl> if ( ! isa < ErrorExpr > ( E ) ) <nl> TypeChecker : : lookupPrecedenceGroupForInfixOperator ( DeclContext * DC , Expr * E ) { <nl> return nullptr ; <nl> } <nl> <nl> + / / / Find LHS as if we append binary operator to existing pre - folded expresion . <nl> + / / / Returns found expression , or \ c nullptr if the operator is not applicable . <nl> + / / / <nl> + / / / For example , given ' ( = = R ( * A B ) ) ' : <nl> + / / / ' findLHS ( DC , expr , " + " ) ' returns ' ( * A B ) ' . <nl> + / / / ' findLHS ( DC , expr , " < < " ) ' returns ' B ' . <nl> + / / / ' findLHS ( DC , expr , ' = = ' ) ' returns nullptr . <nl> + Expr * TypeChecker : : findLHS ( DeclContext * DC , Expr * E , Identifier name ) { <nl> + auto right = lookupPrecedenceGroupForOperator ( * this , DC , name , E - > getEndLoc ( ) ) ; <nl> + while ( true ) { <nl> + <nl> + / / Look through implicit conversions . <nl> + if ( auto ICE = dyn_cast < ImplicitConversionExpr > ( E ) ) { <nl> + E = ICE - > getSyntacticSubExpr ( ) ; <nl> + continue ; <nl> + } <nl> + if ( auto ACE = dyn_cast < AutoClosureExpr > ( E ) ) { <nl> + E = ACE - > getSingleExpressionBody ( ) ; <nl> + continue ; <nl> + } <nl> + <nl> + auto left = lookupPrecedenceGroupForInfixOperator ( DC , E ) ; <nl> + if ( ! left ) <nl> + / / LHS is not binary expression . <nl> + return E ; <nl> + switch ( Context . associateInfixOperators ( left , right ) ) { <nl> + case swift : : Associativity : : None : <nl> + return nullptr ; <nl> + case swift : : Associativity : : Left : <nl> + return E ; <nl> + case swift : : Associativity : : Right : <nl> + break ; <nl> + } <nl> + / / Find the RHS of the current binary expr . <nl> + if ( auto * assignExpr = dyn_cast < AssignExpr > ( E ) ) { <nl> + E = assignExpr - > getSrc ( ) ; <nl> + } else if ( auto * ifExpr = dyn_cast < IfExpr > ( E ) ) { <nl> + E = ifExpr - > getElseExpr ( ) ; <nl> + } else if ( auto * binaryExpr = dyn_cast < BinaryExpr > ( E ) ) { <nl> + auto * Args = dyn_cast < TupleExpr > ( binaryExpr - > getArg ( ) ) ; <nl> + if ( ! Args | | Args - > getNumElements ( ) ! = 2 ) <nl> + return nullptr ; <nl> + E = Args - > getElement ( 1 ) ; <nl> + } else { <nl> + / / E . g . ' fn ( ) as Int < < 2 ' . <nl> + / / In this case ' < < ' has higher precedence than ' as ' , but the LHS should <nl> + / / be ' fn ( ) as Int ' instead of ' Int ' . <nl> + return E ; <nl> + } <nl> + } <nl> + } <nl> + <nl> / / The way we compute isEndOfSequence relies on the assumption that <nl> / / the sequence - folding algorithm never recurses with a prefix of the <nl> / / entire sequence . <nl> mmm a / lib / Sema / TypeChecker . cpp <nl> ppp b / lib / Sema / TypeChecker . cpp <nl> Optional < Type > swift : : getTypeOfCompletionContextExpr ( <nl> referencedDecl ) ; <nl> } <nl> <nl> - bool swift : : typeCheckCompletionSequence ( DeclContext * DC , Expr * & parsedExpr ) { <nl> + / / / \ brief Return the type of operator function for specified LHS , or a null <nl> + / / / \ c Type on error . <nl> + FunctionType * <nl> + swift : : getTypeOfCompletionOperator ( DeclContext * DC , Expr * LHS , <nl> + Identifier opName , DeclRefKind refKind , <nl> + ConcreteDeclRef & referencedDecl ) { <nl> auto & ctx = DC - > getASTContext ( ) ; <nl> DiagnosticSuppression suppression ( ctx . Diags ) ; <nl> TypeChecker & TC = createTypeChecker ( ctx ) ; <nl> - return TC . typeCheckCompletionSequence ( parsedExpr , DC ) ; <nl> + return TC . getTypeOfCompletionOperator ( DC , LHS , opName , refKind , <nl> + referencedDecl ) ; <nl> } <nl> <nl> bool swift : : typeCheckExpression ( DeclContext * DC , Expr * & parsedExpr ) { <nl> mmm a / lib / Sema / TypeChecker . h <nl> ppp b / lib / Sema / TypeChecker . h <nl> class TypeChecker final : public LazyResolver { <nl> FreeTypeVariableBinding : : Disallow , <nl> ExprTypeCheckListener * listener = nullptr ) ; <nl> <nl> - bool typeCheckCompletionSequence ( Expr * & expr , DeclContext * DC ) ; <nl> + / / / \ brief Return the type of operator function for specified LHS , or a null <nl> + / / / \ c Type on error . <nl> + FunctionType * getTypeOfCompletionOperator ( DeclContext * DC , Expr * LHS , <nl> + Identifier opName , <nl> + DeclRefKind refKind , <nl> + ConcreteDeclRef & referencedDecl ) ; <nl> <nl> / / / Check the key - path expression . <nl> / / / <nl> class TypeChecker final : public LazyResolver { <nl> PrecedenceGroupDecl * lookupPrecedenceGroup ( DeclContext * dc , Identifier name , <nl> SourceLoc nameLoc ) ; <nl> <nl> + / / / Given an pre - folded expression , find LHS from the expression if a binary <nl> + / / / operator \ c name appended to the expression . <nl> + Expr * findLHS ( DeclContext * DC , Expr * E , Identifier name ) ; <nl> + <nl> / / / \ brief Look up the Bool type in the standard library . <nl> Type lookupBoolType ( const DeclContext * dc ) ; <nl> <nl> mmm a / test / IDE / complete_from_stdlib . swift <nl> ppp b / test / IDE / complete_from_stdlib . swift <nl> func testInfixOperator4 ( _ x : String ) { <nl> } <nl> / / INFIX_EXT_STRING : Begin completions <nl> / / INFIX_EXT_STRING - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : + { # String # } [ # String # ] <nl> - / / INFIX_EXT_STRING - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : = = { # Bool # } [ # Bool # ] <nl> / / INFIX_EXT_STRING - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : | | { # Bool # } [ # Bool # ] <nl> / / INFIX_EXT_STRING - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : & & { # Bool # } [ # Bool # ] <nl> + / / INFIX_EXT_STRING - NOT : = = <nl> / / INFIX_EXT_STRING : End completions <nl> mmm a / test / IDE / complete_operators . swift <nl> ppp b / test / IDE / complete_operators . swift <nl> func testPostfixSpace ( x : inout S ) { <nl> <nl> / / = = = mmm Infix operators <nl> <nl> - struct S2 { } <nl> - infix operator * * { <nl> - associativity left <nl> - precedence 123 <nl> + precedencegroup S2PrecedenceGroup { <nl> + associativity : left <nl> + lowerThan : ComparisonPrecedence <nl> + higherThan : AssignmentPrecedence <nl> } <nl> - infix operator * * = { <nl> - associativity none <nl> - precedence 123 <nl> + precedencegroup S2AssignmentPrecedenceGroup { <nl> + associativity : none <nl> + lowerThan : ComparisonPrecedence <nl> + higherThan : AssignmentPrecedence <nl> } <nl> + <nl> + struct S2 { } <nl> + infix operator * * : S2PrecedenceGroup <nl> + infix operator * * = : S2AssignmentPrecedenceGroup <nl> func + ( x : S2 , y : S2 ) - > S2 { return x } <nl> func * * ( x : S2 , y : Int ) - > S2 { return x } <nl> func * * = ( x : inout S2 , y : Int ) - > Void { return x } <nl> func testExtInfix2 ( x : S4 ) { <nl> x + x = = x + x # ^ EXT_INFIX_2 ^ # <nl> } <nl> / / S4_EXT_INFIX : Begin completions <nl> - / / S4_EXT_INFIX - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : ! = { # Bool # } [ # Bool # ] <nl> / / S4_EXT_INFIX - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : + { # S4 # } [ # S4 # ] <nl> - / / S4_EXT_INFIX - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : = = { # Bool # } [ # Bool # ] <nl> / / S4_EXT_INFIX - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : & & { # Bool # } [ # Bool # ] <nl> / / S4_EXT_INFIX - DAG : Decl [ InfixOperatorFunction ] / OtherModule [ Swift ] : | | { # Bool # } [ # Bool # ] <nl> / / S4_EXT_INFIX : End completions <nl> <nl> + / / S4_EXT_INFIX - NEG - NOT : ! = <nl> + / / S4_EXT_INFIX - NEG - NOT : = = <nl> / / S4_EXT_INFIX_NEG - NOT : ppp <nl> / / S4_EXT_INFIX_NEG - NOT : & & & <nl> <nl> func testAutoclosure ( x : Boolish , y : Boolish ) { <nl> / / INFIX_AUTOCLOSURE_1 - DAG : Decl [ InfixOperatorFunction ] / CurrModule : [ ' ' ] & & & & { # Boolish # } [ # Boolish # ] ; <nl> / / INFIX_AUTOCLOSURE_1 - DAG : Decl [ InfixOperatorFunction ] / CurrModule : [ ' ' ] = = = = { # Boolish # } [ # Boolish # ] ; <nl> / / INFIX_AUTOCLOSURE_1 - DAG : Decl [ InfixOperatorFunction ] / CurrModule : [ ' ' ] | | | | { # Boolish # } [ # Boolish # ] ; <nl> - / / INFIX_AUTOCLOSURE_1 : End completions <nl> \ No newline at end of file <nl> + / / INFIX_AUTOCLOSURE_1 : End completions <nl> new file mode 100644 <nl> index 000000000000 . . 4f9dd01fbb95 <nl> mmm / dev / null <nl> ppp b / validation - test / IDE / slow_fixed / rdar45511835 . swift <nl> <nl> + / / RUN : % target - swift - ide - test - code - completion - code - completion - token = COMPLETE - source - filename = % s | % FileCheck % s <nl> + <nl> + / / This used to take ~ 6 min to complete . <nl> + <nl> + func testing ( ) { <nl> + return ( [ " a " ] + [ 1 ] . map { String ( $ 0 ) } ) <nl> + . map { $ 0 + " b " as String } <nl> + . filter { $ 0 ! = " " } # ^ COMPLETE ^ # <nl> + } <nl> + / / CHECK : Decl [ InfixOperatorFunction ] / { { . * } } : [ ' ' ] + { # [ String ] # } [ # [ String ] # ] ; name = + [ String ] <nl>
[ CodeCompletion ] Rework getOperatorCompletions ( ) ( )
apple/swift
5df5711b673240ccfbd33731242d95578b85b08a
2018-11-22T12:20:51Z
mmm a / contrib / Python / cntk / ops / linear . py <nl> ppp b / contrib / Python / cntk / ops / linear . py <nl> <nl> Linear algebra operations <nl> " " " <nl> <nl> - from cntk . ops . cntk1 import Times , Plus , ElementDivide <nl> + from cntk . ops . cntk1 import Times , Plus , ElementDivide , ElementTimes <nl> <nl> def plus ( left_operand , right_operand , name = None ) : <nl> " " " <nl> def times ( left_operand , right_operand , name = None ) : <nl> <nl> return Times ( left_operand , right_operand , var_name = name ) <nl> <nl> + <nl> + def element_times ( left_operand , right_operand , name = None ) : <nl> + " " " <nl> + element - wise multiplication operation <nl> + <nl> + Args : <nl> + left_operand : Left side tensor <nl> + right_operand : Right side tensor <nl> + name : the name of the node in the network <nl> + Returns : <nl> + : class : ` cntk . graph . ComputationNode ` <nl> + " " " <nl> + <nl> + return ElementDivide ( left_operand , right_operand , var_name = name ) <nl> + <nl> def element_divide ( left_operand , right_operand , name = None ) : <nl> " " " <nl> element - wise division operation <nl>
element times factory
microsoft/CNTK
09d1651ca201d0e9bd43e928df9f8ddaf2e29396
2016-04-11T13:41:13Z
mmm a / caffe2 / operators / sparse_normalize_op . cc <nl> ppp b / caffe2 / operators / sparse_normalize_op . cc <nl> namespace caffe2 { <nl> <nl> template < > <nl> bool SparseNormalizeOp < float , CPUContext > : : RunOnDevice ( ) { <nl> - CAFFE_ENFORCE_EQ ( <nl> - Input ( PARAM ) . size_from_dim ( 1 ) , <nl> - Input ( GRAD ) . size_from_dim ( Input ( INDICES ) . dim ( ) ) ) ; <nl> <nl> return DispatchHelper < TensorTypes < int32_t , int64_t > > : : call ( <nl> this , Input ( INDICES ) ) ; <nl> bool SparseNormalizeOp < float , CPUContext > : : DoRunWithType ( ) { <nl> } <nl> <nl> / / embedding length , e . g . 32 , 64 , 128 <nl> - auto block_size = Input ( GRAD ) . numel ( ) / n ; <nl> + auto block_size = Input ( PARAM ) . size_from_dim ( 1 ) ; <nl> for ( int i = 0 ; i < n ; + + i ) { <nl> auto idx = indices [ i ] ; <nl> auto offsetIdx = idx * block_size ; <nl> bool SparseNormalizeOp < float , CPUContext > : : DoRunWithType ( ) { <nl> <nl> REGISTER_CPU_OPERATOR ( SparseNormalize , SparseNormalizeOp < float , CPUContext > ) ; <nl> OPERATOR_SCHEMA ( SparseNormalize ) <nl> - . NumInputs ( 3 ) <nl> + . NumInputs ( 2 ) <nl> . NumOutputs ( 1 ) <nl> . Input ( 0 , " param " , " Parameters to be normalized " ) <nl> . Input ( 1 , " indices " , " Sparse indices " ) <nl> - . Input ( 2 , " grad " , " Gradient computed " ) <nl> . Output ( 0 , " output_param " , " Normalized parameters " ) <nl> . EnforceOneToOneInplace ( ) <nl> . Arg ( <nl> mmm a / caffe2 / operators / sparse_normalize_op . h <nl> ppp b / caffe2 / operators / sparse_normalize_op . h <nl> class CAFFE2_API SparseNormalizeOp final : public Operator < Context > { <nl> protected : <nl> bool use_max_norm_ ; <nl> float norm_ ; <nl> - INPUT_TAGS ( PARAM , INDICES , GRAD ) ; <nl> + INPUT_TAGS ( PARAM , INDICES ) ; <nl> OUTPUT_TAGS ( OUTPUT_PARAM ) ; <nl> } ; <nl> <nl> mmm a / caffe2 / python / operator_test / sparse_normalize_test . py <nl> ppp b / caffe2 / python / operator_test / sparse_normalize_test . py <nl> def ref_normalize ( param_in , use_max_norm , norm ) : <nl> # Suppress filter_too_much health check . <nl> # Likely caused by ` assume ` call falling through too often . <nl> @ settings ( suppress_health_check = [ HealthCheck . filter_too_much ] ) <nl> - @ given ( inputs = hu . tensors ( n = 2 , min_dim = 2 , max_dim = 2 ) , <nl> + @ given ( inputs = hu . tensors ( n = 1 , min_dim = 2 , max_dim = 2 ) , <nl> use_max_norm = st . booleans ( ) , <nl> norm = st . floats ( min_value = 1 . 0 , max_value = 4 . 0 ) , <nl> data_strategy = st . data ( ) , <nl> * * hu . gcs_cpu_only ) <nl> def test_sparse_normalize ( self , inputs , use_max_norm , norm , <nl> data_strategy , gc , dc ) : <nl> - param , grad = inputs <nl> + param = inputs <nl> param + = 0 . 02 * np . sign ( param ) <nl> param [ param = = 0 . 0 ] + = 0 . 02 <nl> <nl> # Create an indexing array containing values that are lists of indices , <nl> - # which index into grad <nl> + # which index into param <nl> indices = data_strategy . draw ( <nl> hu . tensor ( dtype = np . int64 , min_dim = 1 , max_dim = 1 , <nl> - elements = st . sampled_from ( np . arange ( grad . shape [ 0 ] ) ) ) , <nl> + elements = st . sampled_from ( np . arange ( param . shape [ 0 ] ) ) ) , <nl> ) <nl> hypothesis . note ( ' indices . shape : % s ' % str ( indices . shape ) ) <nl> <nl> def test_sparse_normalize ( self , inputs , use_max_norm , norm , <nl> hypothesis . assume ( np . array_equal ( np . unique ( indices . flatten ( ) ) , <nl> np . sort ( indices . flatten ( ) ) ) ) <nl> <nl> - # Sparsify grad <nl> - grad = grad [ indices ] <nl> - <nl> op = core . CreateOperator ( <nl> " SparseNormalize " , <nl> - [ " param " , " indices " , " grad " ] , <nl> + [ " param " , " indices " ] , <nl> [ " param " ] , <nl> use_max_norm = use_max_norm , <nl> norm = norm , <nl> ) <nl> <nl> - def ref_sparse_normalize ( param , indices , grad ) : <nl> + def ref_sparse_normalize ( param , indices ) : <nl> param_out = np . copy ( param ) <nl> for _ , index in enumerate ( indices ) : <nl> param_out [ index ] = self . ref_normalize ( <nl> def ref_sparse_normalize ( param , indices , grad ) : <nl> ) <nl> return ( param_out , ) <nl> <nl> - # self . assertDeviceChecks ( dc , op , [ param , indices , grad ] , [ 0 ] ) <nl> + # self . assertDeviceChecks ( dc , op , [ param , indices ] , [ 0 ] ) <nl> self . assertReferenceChecks ( <nl> - gc , op , [ param , indices , grad ] , <nl> + gc , op , [ param , indices ] , <nl> ref_sparse_normalize <nl> ) <nl> mmm a / caffe2 / python / regularizer . py <nl> ppp b / caffe2 / python / regularizer . py <nl> def _run_after_optimizer ( self , net , param_init_net , param , grad ) : <nl> assert self . norm > 0 , " norm should be bigger than 0 . " <nl> if isinstance ( grad , core . GradientSlice ) : <nl> net . SparseNormalize ( <nl> - [ param , grad . indices , grad . values ] , <nl> + [ param , grad . indices ] , <nl> [ param ] , <nl> use_max_norm = True , <nl> norm = self . norm , <nl> def _run_after_optimizer ( self , net , param_init_net , param , grad ) : <nl> assert self . norm > 0 , " norm should be bigger than 0 . " <nl> if isinstance ( grad , core . GradientSlice ) : <nl> net . SparseNormalize ( <nl> - [ param , grad . indices , grad . values ] , <nl> + [ param , grad . indices ] , <nl> [ param ] , <nl> use_max_norm = False , <nl> norm = self . norm , <nl>
Remove gradient value as input from SparseNormalize op ( )
pytorch/pytorch
d7c6debc14aa722d8002a19462c38b3b659dbec0
2019-08-19T21:47:09Z
mmm a / db / db . cpp <nl> ppp b / db / db . cpp <nl> struct EmptyObject { <nl> void receivedUpdate ( Message & m ) { <nl> DbMessage d ( m ) ; <nl> const char * ns = d . getns ( ) ; <nl> + setClient ( ns ) ; <nl> int flags = d . pullInt ( ) ; <nl> JSObj query = d . nextJsObj ( ) ; <nl> assert ( d . moreJSObjs ( ) ) ; <nl> JSObj toupdate = d . nextJsObj ( ) ; <nl> updateObjects ( ns , toupdate , query , flags & 1 ) ; <nl> + client = 0 ; <nl> } <nl> <nl> void receivedDelete ( Message & m ) { <nl> DbMessage d ( m ) ; <nl> const char * ns = d . getns ( ) ; <nl> + setClient ( ns ) ; <nl> int flags = d . pullInt ( ) ; <nl> assert ( d . moreJSObjs ( ) ) ; <nl> JSObj pattern = d . nextJsObj ( ) ; <nl> deleteObjects ( ns , pattern , flags & 1 ) ; <nl> + client = 0 ; <nl> } <nl> <nl> void receivedQuery ( MessagingPort & dbMsgPort , Message & m , stringstream & ss ) { <nl> DbMessage d ( m ) ; <nl> const char * ns = d . getns ( ) ; <nl> + setClient ( ns ) ; <nl> int ntoreturn = d . pullInt ( ) ; <nl> JSObj query = d . nextJsObj ( ) ; <nl> auto_ptr < set < string > > fields ; <nl> void receivedQuery ( MessagingPort & dbMsgPort , Message & m , stringstream & ss ) { <nl> Message resp ; <nl> resp . setData ( msgdata , true ) ; <nl> dbMsgPort . reply ( m , resp ) ; <nl> + client = 0 ; <nl> } <nl> <nl> void receivedGetMore ( MessagingPort & dbMsgPort , Message & m ) { <nl> DbMessage d ( m ) ; <nl> const char * ns = d . getns ( ) ; <nl> + setClient ( ns ) ; <nl> int ntoreturn = d . pullInt ( ) ; <nl> long long cursorid = d . pullInt64 ( ) ; <nl> QueryResult * msgdata = getMore ( ns , ntoreturn , cursorid ) ; <nl> Message resp ; <nl> resp . setData ( msgdata , true ) ; <nl> dbMsgPort . reply ( m , resp ) ; <nl> + client = 0 ; <nl> } <nl> <nl> void receivedInsert ( Message & m ) { <nl> void receivedInsert ( Message & m ) { <nl> while ( d . moreJSObjs ( ) ) { <nl> JSObj js = d . nextJsObj ( ) ; <nl> / / cout < < " temp dbinsert : got js object , size = " < < js . objsize ( ) < < " ns : " < < d . getns ( ) < < endl ; <nl> - theDataFileMgr . insert ( d . getns ( ) , ( void * ) js . objdata ( ) , js . objsize ( ) ) ; <nl> + const char * ns = d . getns ( ) ; <nl> + setClient ( ns ) ; <nl> + theDataFileMgr . insert ( ns , ( void * ) js . objdata ( ) , js . objsize ( ) ) ; <nl> } <nl> + client = 0 ; <nl> } <nl> <nl> void testTheDb ( ) { <nl> + setClient ( " sys . unittest . pdfile " ) ; <nl> + <nl> / * this is not validly formatted , if you query this namespace bad things will happen * / <nl> theDataFileMgr . insert ( " sys . unittest . pdfile " , ( void * ) " hello worldx " , 13 ) ; <nl> theDataFileMgr . insert ( " sys . unittest . pdfile " , ( void * ) " hello worldx " , 13 ) ; <nl> void testTheDb ( ) { <nl> auto_ptr < Cursor > c = theDataFileMgr . findAll ( " sys . unittest . pdfile " ) ; <nl> while ( c - > ok ( ) ) { <nl> Record * r = c - > _current ( ) ; <nl> - / / cout < < " gotrec " < < r - > netLength ( ) < < ' ' < < <nl> - / / r - > data < < ' \ n ' ; <nl> c - > advance ( ) ; <nl> } <nl> cout < < endl ; <nl> + <nl> + client = 0 ; <nl> } <nl> <nl> int port = DBPort ; <nl> void msg ( const char * m , int extras = 0 ) { <nl> int main ( int argc , char * argv [ ] , char * envp [ ] ) <nl> { <nl> srand ( curTimeMillis ( ) ) ; <nl> - cout < < curTimeMillis ( ) % 10000 < < endl ; <nl> <nl> if ( argc > = 2 ) { <nl> if ( strcmp ( argv [ 1 ] , " quicktest " ) = = 0 ) { <nl> mmm a / db / db . vcproj <nl> ppp b / db / db . vcproj <nl> <nl> RelativePath = " . \ introspect . cpp " <nl> > <nl> < / File > <nl> - < File <nl> - RelativePath = " . \ jseval . cpp " <nl> - > <nl> - < / File > <nl> < File <nl> RelativePath = " . \ jsobj . cpp " <nl> > <nl> <nl> > <nl> < / File > <nl> < File <nl> - RelativePath = " . \ jseval . h " <nl> + RelativePath = " . \ jsobj . h " <nl> > <nl> < / File > <nl> < File <nl> - RelativePath = " . \ jsobj . h " <nl> + RelativePath = " . . \ util \ lruishmap . h " <nl> > <nl> < / File > <nl> < File <nl> mmm a / db / jsobj . h <nl> ppp b / db / jsobj . h <nl> explicit <nl> bool woEqual ( const JSObj & r ) const { <nl> return _objsize = = r . _objsize & & memcmp ( _objdata , r . _objdata , _objsize ) = = 0 ; <nl> } <nl> + bool operator = = ( const JSObj & r ) const { <nl> + return this - > woEqual ( r ) ; * this = = r ; <nl> + } <nl> <nl> Element firstElement ( ) { <nl> return Element ( objdata ( ) + 4 ) ; <nl> explicit <nl> * / <nl> JSObj copy ( ) const ; <nl> <nl> + int hash ( ) const { <nl> + unsigned x = 0 ; <nl> + const char * p = _objdata ; <nl> + for ( int i = 0 ; i < _objsize ; i + + ) <nl> + x = x * 131 + p [ i ] ; <nl> + return ( x & 0x7fffffff ) | 0x8000000 ; / / must be > 0 <nl> + } <nl> + <nl> bool iFree ; <nl> private : <nl> int _objsize ; <nl> mmm a / db / namespace . h <nl> ppp b / db / namespace . h <nl> class IndexDetails { <nl> DiskLoc head ; / * btree head * / <nl> DiskLoc info ; / * index info object . { name : , ns : , key : } * / <nl> <nl> + / * pull out the relevant key objects from obj , so we <nl> + can index them . Note that the set is multiple elements <nl> + only when it ' s a " multikey " array . <nl> + keys will be left empty if key not found in the object . <nl> + * / <nl> void getKeysFromObject ( JSObj & obj , set < JSObj > & keys ) ; <nl> <nl> + / / returns name of this index ' s storage area <nl> / / client . table . $ index <nl> string indexNamespace ( ) { <nl> JSObj io = info . obj ( ) ; <nl> class NamespaceIndex { <nl> public : <nl> NamespaceIndex ( ) { } <nl> <nl> - void init ( const char * dir ) { <nl> + void init ( const char * dir , const char * client ) { <nl> string path = dir ; <nl> - path + = " namespace . idx " ; <nl> + path + = client ; <nl> + path + = " . ns " ; <nl> const int LEN = 16 * 1024 * 1024 ; <nl> void * p = f . map ( path . c_str ( ) , LEN ) ; <nl> if ( p = = 0 ) { <nl> class NamespaceIndex { <nl> HashTable < Namespace , NamespaceDetails > * ht ; <nl> } ; <nl> <nl> - extern NamespaceIndex namespaceIndex ; <nl> + extern const char * dbpath ; <nl> <nl> - auto_ptr < Cursor > makeNamespaceCursor ( ) ; <nl> + / * <nl> + class NamespaceIndexMgr { <nl> + public : <nl> + NamespaceIndexMgr ( ) { } <nl> + NamespaceIndex * get ( const char * client ) { <nl> + map < string , NamespaceIndex * > : : iterator it = m . find ( client ) ; <nl> + if ( it ! = m . end ( ) ) <nl> + return it - > second ; <nl> + NamespaceIndex * ni = new NamespaceIndex ( ) ; <nl> + ni - > init ( dbpath , client ) ; <nl> + m [ client ] = ni ; <nl> + return ni ; <nl> + } <nl> + private : <nl> + map < string , NamespaceIndex * > m ; <nl> + } ; <nl> + <nl> + extern NamespaceIndexMgr namespaceIndexMgr ; <nl> + * / <nl> + <nl> + / / " client . a . b . c " - > " client " <nl> + inline void nsToClient ( const char * ns , char * client ) { <nl> + const char * p = ns ; <nl> + char * q = client ; <nl> + while ( * p ! = ' . ' ) { <nl> + if ( * p = = 0 ) { <nl> + assert ( false ) ; <nl> + * client = 0 ; <nl> + return ; <nl> + } <nl> + * q + + = * p + + ; <nl> + } <nl> + * q = 0 ; <nl> + assert ( q - client < 256 ) ; <nl> + } <nl> + <nl> + / * <nl> + inline NamespaceIndex * nsindex ( const char * ns ) { <nl> + char client [ 256 ] ; <nl> + nsToClient ( ns , client ) ; <nl> + return namespaceIndexMgr . get ( client ) ; <nl> + } <nl> + <nl> + inline NamespaceDetails * nsdetails ( const char * ns ) { <nl> + return nsindex ( ns ) - > details ( ns ) ; <nl> + } <nl> + * / <nl> + <nl> + / / auto_ptr < Cursor > makeNamespaceCursor ( ) ; <nl> mmm a / db / pdfile . cpp <nl> ppp b / db / pdfile . cpp <nl> _ regex support <nl> const char * dbpath = " / data / db / " ; <nl> <nl> DataFileMgr theDataFileMgr ; <nl> + map < string , Client * > clients ; <nl> + Client * client ; <nl> + <nl> extern int otherTraceLevel ; <nl> <nl> JSObj : : JSObj ( Record * r ) { <nl> int bucketSizes [ ] = { <nl> 0x400000 , 0x800000 <nl> } ; <nl> <nl> - NamespaceIndex namespaceIndex ; <nl> + / / NamespaceIndexMgr namespaceIndexMgr ; <nl> <nl> void NamespaceDetails : : addDeletedRec ( DeletedRecord * d , DiskLoc dloc ) { <nl> int b = bucket ( d - > lengthWithHeaders ) ; <nl> DiskLoc NamespaceDetails : : _alloc ( int len ) { <nl> return bestmatch ; <nl> } <nl> <nl> - <nl> + / * <nl> class NamespaceCursor : public Cursor { <nl> public : <nl> virtual bool ok ( ) { return i > = 0 ; } <nl> class NamespaceCursor : public Cursor { <nl> <nl> auto_ptr < Cursor > makeNamespaceCursor ( ) { <nl> return auto_ptr < Cursor > ( new NamespaceCursor ( ) ) ; <nl> - } <nl> + } * / <nl> <nl> void newNamespace ( const char * ns ) { <nl> cout < < " New namespace : " < < ns < < endl ; <nl> - if ( strcmp ( ns , " system . namespaces " ) ! = 0 ) { <nl> + if ( strstr ( ns , " system . namespaces " ) = = 0 ) { <nl> JSObjBuilder b ; <nl> b . append ( " name " , ns ) ; <nl> JSObj j = b . done ( ) ; <nl> - theDataFileMgr . insert ( " system . namespaces " , j . objdata ( ) , j . objsize ( ) , true ) ; <nl> + char client [ 256 ] ; <nl> + nsToClient ( ns , client ) ; <nl> + string s = client ; <nl> + s + = " . system . namespaces " ; <nl> + theDataFileMgr . insert ( s . c_str ( ) , j . objdata ( ) , j . objsize ( ) , true ) ; <nl> } <nl> } <nl> <nl> / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> <nl> - void PhysicalDataFile : : open ( const char * filename , int length ) { <nl> + void PhysicalDataFile : : open ( int fn , const char * filename ) { <nl> + int length ; <nl> + if ( fn < = 4 ) <nl> + length = ( 64 * 1024 * 1024 ) < < fn ; <nl> + else <nl> + length = 0x7ff00000 ; <nl> + assert ( length > = 64 * 1024 * 1024 & & length % 4096 = = 0 ) ; <nl> + <nl> + assert ( fn = = fileNo ) ; <nl> header = ( PDFHeader * ) mmf . map ( filename , length ) ; <nl> assert ( header ) ; <nl> - header - > init ( length ) ; <nl> + header - > init ( fileNo , length ) ; <nl> } <nl> <nl> / * prev - previous extent for this namespace . null = this is the first one . * / <nl> Extent * PhysicalDataFile : : newExtent ( const char * ns , int approxSize ) { <nl> int ExtentSize = approxSize < = header - > unusedLength ? approxSize : header - > unusedLength ; <nl> DiskLoc loc ; <nl> if ( ExtentSize < = 0 ) { <nl> - cout < < " ERROR : newExtent : no more room for extents . write more code " < < endl ; <nl> - assert ( false ) ; <nl> - exit ( 2 ) ; <nl> + cout < < " INFO : newExtent ( ) : file full , adding a new file " < < ns < < endl ; <nl> + return client - > addAFile ( ) - > newExtent ( ns , approxSize ) ; <nl> } <nl> int offset = header - > unused . getOfs ( ) ; <nl> - header - > unused . setOfs ( offset + ExtentSize ) ; <nl> + header - > unused . setOfs ( fileNo , offset + ExtentSize ) ; <nl> header - > unusedLength - = ExtentSize ; <nl> - loc . setOfs ( offset ) ; <nl> + loc . setOfs ( fileNo , offset ) ; <nl> Extent * e = _getExtent ( loc ) ; <nl> - DiskLoc emptyLoc = e - > init ( ns , ExtentSize , offset ) ; <nl> + DiskLoc emptyLoc = e - > init ( ns , ExtentSize , fileNo , offset ) ; <nl> <nl> DiskLoc oldExtentLoc ; <nl> - NamespaceDetails * details = namespaceIndex . details ( ns ) ; <nl> + NamespaceIndex * ni = nsindex ( ns ) ; <nl> + NamespaceDetails * details = ni - > details ( ns ) ; <nl> if ( details ) { <nl> assert ( ! details - > firstExtent . isNull ( ) ) ; <nl> e - > xprev = details - > lastExtent ; <nl> Extent * PhysicalDataFile : : newExtent ( const char * ns , int approxSize ) { <nl> details - > lastExtent = loc ; <nl> } <nl> else { <nl> - namespaceIndex . add ( ns , loc ) ; <nl> - details = namespaceIndex . details ( ns ) ; <nl> + ni - > add ( ns , loc ) ; <nl> + details = ni - > details ( ns ) ; <nl> } <nl> <nl> details - > lastExtentSize = approxSize ; <nl> Extent * PhysicalDataFile : : newExtent ( const char * ns , int approxSize ) { <nl> / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> <nl> / * assumes already zeroed - - insufficient for block ' reuse ' perhaps * / <nl> - DiskLoc Extent : : init ( const char * nsname , int _length , int _offset ) { <nl> + DiskLoc Extent : : init ( const char * nsname , int _length , int _fileNo , int _offset ) { <nl> magic = 0x41424344 ; <nl> - myLoc . setOfs ( _offset ) ; <nl> + myLoc . setOfs ( _fileNo , _offset ) ; <nl> xnext . Null ( ) ; xprev . Null ( ) ; <nl> ns = nsname ; <nl> length = _length ; <nl> Record * Extent : : newRecord ( int len ) { <nl> <nl> auto_ptr < Cursor > DataFileMgr : : findAll ( const char * ns ) { <nl> DiskLoc loc ; <nl> - bool found = namespaceIndex . find ( ns , loc ) ; <nl> + bool found = nsindex ( ns ) - > find ( ns , loc ) ; <nl> if ( ! found ) { <nl> cout < < " info : findAll ( ) namespace does not exist : " < < ns < < endl ; <nl> return auto_ptr < Cursor > ( new BasicCursor ( DiskLoc ( ) ) ) ; <nl> } <nl> - Extent * e = temp . getExtent ( loc ) ; <nl> + Extent * e = getExtent ( loc ) ; <nl> return auto_ptr < Cursor > ( new BasicCursor ( e - > firstRecord ) ) ; <nl> } <nl> <nl> void aboutToDelete ( const DiskLoc & dl ) ; <nl> <nl> + / * pull out the relevant key objects from obj , so we <nl> + can index them . Note that the set is multiple elements <nl> + only when it ' s a " multikey " array . <nl> + keys will be left empty if key not found in the object . <nl> + * / <nl> void IndexDetails : : getKeysFromObject ( JSObj & obj , set < JSObj > & keys ) { <nl> JSObj keyPattern = info . obj ( ) . getObjectField ( " key " ) ; <nl> JSObjBuilder b ; <nl> void DataFileMgr : : deleteRecord ( const char * ns , Record * todelete , const DiskLoc & <nl> / * check if any cursors point to us . if so , advance them . * / <nl> aboutToDelete ( dl ) ; <nl> <nl> - NamespaceDetails * d = namespaceIndex . details ( ns ) ; <nl> + NamespaceDetails * d = nsdetails ( ns ) ; <nl> unindexRecord ( ns , d , todelete , dl ) ; <nl> <nl> / * remove ourself from the record next / prev chain * / <nl> void DataFileMgr : : deleteRecord ( const char * ns , Record * todelete , const DiskLoc & <nl> / * remove ourself from extent pointers * / <nl> { <nl> Extent * e = todelete - > myExtent ( dl ) ; <nl> - if ( e - > firstRecord = = dl ) <nl> - e - > firstRecord . setOfs ( todelete - > nextOfs ) ; <nl> - if ( e - > lastRecord = = dl ) <nl> - e - > lastRecord . setOfs ( todelete - > prevOfs ) ; <nl> + if ( e - > firstRecord = = dl ) { <nl> + if ( todelete - > nextOfs = = DiskLoc : : NullOfs ) <nl> + e - > firstRecord . Null ( ) ; <nl> + else <nl> + e - > firstRecord . setOfs ( dl . a ( ) , todelete - > nextOfs ) ; <nl> + } <nl> + if ( e - > lastRecord = = dl ) { <nl> + if ( todelete - > prevOfs = = DiskLoc : : NullOfs ) <nl> + e - > lastRecord . Null ( ) ; <nl> + else <nl> + e - > lastRecord . setOfs ( dl . a ( ) , todelete - > prevOfs ) ; <nl> + } <nl> } <nl> <nl> / * add to the free list * / <nl> void DataFileMgr : : update ( <nl> <nl> / * has any index keys changed ? * / <nl> { <nl> - NamespaceDetails * d = namespaceIndex . details ( ns ) ; <nl> + NamespaceDetails * d = nsdetails ( ns ) ; <nl> if ( d - > nIndexes ) { <nl> JSObj newObj ( buf ) ; <nl> JSObj oldObj = dl . obj ( ) ; <nl> DiskLoc DataFileMgr : : insert ( const char * ns , const void * buf , int len , bool god ) <nl> } <nl> <nl> bool addIndex = false ; <nl> - if ( strncmp ( ns , " system . " , 7 ) = = 0 ) { <nl> - if ( strcmp ( ns , " system . indexes " ) = = 0 ) <nl> - addIndex = true ; <nl> - else if ( ! god ) { <nl> - cout < < " ERROR : attempt to insert in system namespace " < < ns < < endl ; <nl> + const char * sys = strstr ( ns , " system . " ) ; <nl> + if ( sys ) { <nl> + if ( sys = = ns ) { <nl> + cout < < " ERROR : attempt to insert for invalid client ' system ' : " < < ns < < endl ; <nl> return DiskLoc ( ) ; <nl> } <nl> + if ( strstr ( ns , " . system . " ) ) { <nl> + if ( strstr ( ns , " . system . indexes " ) ) <nl> + addIndex = true ; <nl> + else if ( ! god ) { <nl> + cout < < " ERROR : attempt to insert in system namespace " < < ns < < endl ; <nl> + return DiskLoc ( ) ; <nl> + } <nl> + } <nl> } <nl> <nl> - NamespaceDetails * d = namespaceIndex . details ( ns ) ; <nl> + NamespaceDetails * d = nsdetails ( ns ) ; <nl> if ( d = = 0 ) { <nl> newNamespace ( ns ) ; <nl> - temp . newExtent ( ns , initialExtentSize ( len ) ) ; <nl> - d = namespaceIndex . details ( ns ) ; <nl> + client - > newestFile ( ) - > newExtent ( ns , initialExtentSize ( len ) ) ; <nl> + d = nsdetails ( ns ) ; <nl> } <nl> <nl> NamespaceDetails * tableToIndex = 0 ; <nl> DiskLoc DataFileMgr : : insert ( const char * ns , const void * buf , int len , bool god ) <nl> ( tabletoidxns ? tabletoidxns : " " ) < < endl ; <nl> return DiskLoc ( ) ; <nl> } <nl> - tableToIndex = namespaceIndex . details ( tabletoidxns ) ; <nl> + tableToIndex = nsdetails ( tabletoidxns ) ; <nl> if ( tableToIndex = = 0 ) { <nl> cout < < " ERROR : bad add index attempt , no such table ( ns ) : " < < tabletoidxns < < endl ; <nl> return DiskLoc ( ) ; <nl> DiskLoc DataFileMgr : : insert ( const char * ns , const void * buf , int len , bool god ) <nl> if ( loc . isNull ( ) ) { <nl> / / out of space <nl> cout < < " allocating new extent for " < < ns < < endl ; <nl> - temp . newExtent ( ns , followupExtentSize ( len , d - > lastExtentSize ) ) ; <nl> + client - > newestFile ( ) - > newExtent ( ns , followupExtentSize ( len , d - > lastExtentSize ) ) ; <nl> loc = d - > alloc ( lenWHdr , extentLoc ) ; <nl> if ( loc . isNull ( ) ) { <nl> cout < < " * * * * * * ERROR : out of space in datafile . write more code . " < < endl ; <nl> DiskLoc DataFileMgr : : insert ( const char * ns , const void * buf , int len , bool god ) <nl> } <nl> <nl> void DataFileMgr : : init ( const char * dir ) { <nl> - string path = dir ; <nl> + / * string path = dir ; <nl> path + = " temp . dat " ; <nl> temp . open ( path . c_str ( ) , 64 * 1024 * 1024 ) ; <nl> + * / <nl> } <nl> <nl> void pdfileInit ( ) { <nl> - namespaceIndex . init ( dbpath ) ; <nl> + / / namespaceIndex . init ( dbpath ) ; <nl> theDataFileMgr . init ( dbpath ) ; <nl> } <nl> mmm a / db / pdfile . h <nl> ppp b / db / pdfile . h <nl> <nl> - / / pdfile . h <nl> + / * pdfile . h <nl> + <nl> + Files : <nl> + client . ns - namespace index <nl> + client . 1 - data files <nl> + client . 2 <nl> + . . . <nl> + * / <nl> <nl> # pragma once <nl> <nl> + / / see version , versionMinor , below . <nl> + const int VERSION = 4 ; <nl> + <nl> # include " . . / stdafx . h " <nl> # include " . . / util / mmap . h " <nl> # include " storage . h " <nl> class Cursor ; <nl> <nl> / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> class PDFHeader ; <nl> class PhysicalDataFile { <nl> friend class DataFileMgr ; <nl> friend class BasicCursor ; <nl> public : <nl> - void open ( const char * filename , int length = 64 * 1024 * 1024 ) ; <nl> + PhysicalDataFile ( int fn ) : fileNo ( fn ) { } <nl> + void open ( int fileNo , const char * filename ) ; <nl> <nl> private : <nl> Extent * newExtent ( const char * ns , int approxSize ) ; <nl> class PhysicalDataFile { <nl> MemoryMappedFile mmf ; <nl> PDFHeader * header ; <nl> int length ; <nl> + int fileNo ; <nl> } ; <nl> <nl> class DataFileMgr { <nl> class DataFileMgr { <nl> static Extent * getExtent ( const DiskLoc & dl ) ; <nl> static Record * getRecord ( const DiskLoc & dl ) ; <nl> private : <nl> - PhysicalDataFile temp ; <nl> + vector < PhysicalDataFile * > files ; <nl> } ; <nl> <nl> extern DataFileMgr theDataFileMgr ; <nl> class Extent { <nl> Returns a DeletedRecord location which is the data in the extent ready for us . <nl> Caller will need to add that to the freelist structure in namespacedetail . <nl> * / <nl> - DiskLoc init ( const char * nsname , int _length , int _offset ) ; <nl> + DiskLoc init ( const char * nsname , int _length , int _fileNo , int _offset ) ; <nl> <nl> void assertOk ( ) { assert ( magic = = 0x41424344 ) ; } <nl> <nl> class PDFHeader { <nl> <nl> static int headerSize ( ) { return sizeof ( PDFHeader ) - 4 ; } <nl> <nl> - bool uninitialized ( ) { if ( version = = 0 ) return true ; assert ( version = = 3 ) ; return false ; } <nl> + bool uninitialized ( ) { if ( version = = 0 ) return true ; assert ( version = = VERSION ) ; return false ; } <nl> <nl> Record * getRecord ( DiskLoc dl ) { <nl> int ofs = dl . getOfs ( ) ; <nl> class PDFHeader { <nl> return ( Record * ) ( ( ( char * ) this ) + ofs ) ; <nl> } <nl> <nl> - void init ( int filelength ) { <nl> + void init ( int fileno , int filelength ) { <nl> if ( uninitialized ( ) ) { <nl> assert ( filelength > 32768 ) ; <nl> assert ( headerSize ( ) = = 8192 ) ; <nl> fileLength = filelength ; <nl> - version = 3 ; <nl> + version = VERSION ; <nl> versionMinor = 0 ; <nl> - unused . setOfs ( headerSize ( ) ) ; <nl> + unused . setOfs ( fileno , headerSize ( ) ) ; <nl> assert ( ( data - ( char * ) this ) = = headerSize ( ) ) ; <nl> unusedLength = fileLength - headerSize ( ) - 16 ; <nl> memcpy ( data + unusedLength , " \ nthe end \ n " , 16 ) ; <nl> class BasicCursor : public Cursor { <nl> <nl> Record * _current ( ) { <nl> assert ( ok ( ) ) ; <nl> - return theDataFileMgr . temp . recordAt ( curr ) ; <nl> + return curr . rec ( ) ; <nl> + / / return theDataFileMgr . temp . recordAt ( curr ) ; <nl> } <nl> JSObj current ( ) { <nl> return JSObj ( _current ( ) ) ; <nl> class BasicCursor : public Cursor { <nl> <nl> inline Record * PhysicalDataFile : : recordAt ( DiskLoc dl ) { return header - > getRecord ( dl ) ; } <nl> <nl> - inline Extent * DataFileMgr : : getExtent ( const DiskLoc & dl ) { <nl> - return theDataFileMgr . temp . getExtent ( dl ) ; <nl> - } <nl> - inline Record * DataFileMgr : : getRecord ( const DiskLoc & dl ) { <nl> - return theDataFileMgr . temp . recordAt ( dl ) ; <nl> - } <nl> - <nl> inline DiskLoc Record : : getNext ( const DiskLoc & myLoc ) { <nl> if ( nextOfs ! = DiskLoc : : NullOfs ) <nl> return DiskLoc ( myLoc . a ( ) , nextOfs ) ; <nl> inline Extent * DiskLoc : : ext ( ) const { <nl> inline BtreeBucket * DiskLoc : : btree ( ) const { <nl> return ( BtreeBucket * ) rec ( ) - > data ; <nl> } <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / / customer , or rather a customer ' s database - - i guess down the line <nl> + / / there might be more than one for a cust , we ' ll see . <nl> + class Client { <nl> + public : <nl> + Client ( const char * nm ) : name ( nm ) { <nl> + namespaceIndex = new NamespaceIndex ( ) ; <nl> + namespaceIndex - > init ( dbpath , nm ) ; <nl> + } <nl> + <nl> + PhysicalDataFile * getFile ( int n ) { <nl> + assert ( n > = 0 & & n < 100000 ) ; <nl> + # if defined ( _DEBUG ) <nl> + if ( n > 100 ) <nl> + cout < < " getFile ( ) : n = " < < n < < " ? " < < endl ; <nl> + # endif <nl> + while ( n > = ( int ) files . size ( ) ) <nl> + files . push_back ( 0 ) ; <nl> + PhysicalDataFile * p = files [ n ] ; <nl> + if ( p = = 0 ) { <nl> + p = new PhysicalDataFile ( n ) ; <nl> + files [ n ] = p ; <nl> + stringstream out ; <nl> + out < < dbpath < < name < < ' . ' < < n ; <nl> + p - > open ( n , out . str ( ) . c_str ( ) ) ; <nl> + } <nl> + return p ; <nl> + } <nl> + <nl> + PhysicalDataFile * addAFile ( ) { <nl> + int n = ( int ) files . size ( ) ; <nl> + return getFile ( n ) ; <nl> + } <nl> + <nl> + PhysicalDataFile * newestFile ( ) { <nl> + int n = ( int ) files . size ( ) ; <nl> + if ( n > 0 ) n - - ; <nl> + return getFile ( n ) ; <nl> + } <nl> + <nl> + vector < PhysicalDataFile * > files ; <nl> + string name ; / / " alleyinsider " <nl> + NamespaceIndex * namespaceIndex ; <nl> + } ; <nl> + <nl> + / / tempish . . . move to TLS or pass all the way down as a parm <nl> + extern map < string , Client * > clients ; <nl> + extern Client * client ; <nl> + inline void setClient ( const char * ns ) { <nl> + char cl [ 256 ] ; <nl> + nsToClient ( ns , cl ) ; <nl> + map < string , Client * > : : iterator it = clients . find ( cl ) ; <nl> + if ( it ! = clients . end ( ) ) { <nl> + client = it - > second ; <nl> + return ; <nl> + } <nl> + Client * c = new Client ( cl ) ; <nl> + clients [ cl ] = c ; <nl> + client = c ; <nl> + } <nl> + <nl> + inline NamespaceIndex * nsindex ( const char * ns ) { <nl> + # if defined ( _DEBUG ) <nl> + char buf [ 256 ] ; <nl> + nsToClient ( ns , buf ) ; <nl> + assert ( client - > name = = buf ) ; <nl> + # endif <nl> + return client - > namespaceIndex ; <nl> + } <nl> + <nl> + inline NamespaceDetails * nsdetails ( const char * ns ) { <nl> + return nsindex ( ns ) - > details ( ns ) ; <nl> + } <nl> + <nl> + inline PhysicalDataFile & DiskLoc : : pdf ( ) const { <nl> + return * client - > getFile ( fileNo ) ; <nl> + } <nl> + <nl> + inline Extent * DataFileMgr : : getExtent ( const DiskLoc & dl ) { <nl> + return client - > getFile ( dl . a ( ) ) - > getExtent ( dl ) ; <nl> + } <nl> + <nl> + inline Record * DataFileMgr : : getRecord ( const DiskLoc & dl ) { <nl> + return client - > getFile ( dl . a ( ) ) - > recordAt ( dl ) ; <nl> + } <nl> + <nl> mmm a / db / query . cpp <nl> ppp b / db / query . cpp <nl> <nl> # include < time . h > <nl> # include " introspect . h " <nl> # include " btree . h " <nl> + # include " . . / util / lruishmap . h " <nl> + <nl> + / / ns - > query - > DiskLoc <nl> + LRUishMap < JSObj , DiskLoc , 5 > lrutest ( 123 ) ; <nl> <nl> int nextCursorId = 1 ; <nl> <nl> JSObj emptyObj ; <nl> _ use index on partial match with the query <nl> * / <nl> auto_ptr < Cursor > getIndexCursor ( const char * ns , JSObj & query , JSObj & order ) { <nl> - NamespaceDetails * d = namespaceIndex . details ( ns ) ; <nl> + NamespaceDetails * d = nsdetails ( ns ) ; <nl> if ( d = = 0 ) return auto_ptr < Cursor > ( ) ; <nl> set < string > queryFields ; <nl> query . getFieldNames ( queryFields ) ; <nl> void deleteObjects ( const char * ns , JSObj pattern , bool justOne ) { <nl> / / cout < < " delete ns : " < < ns < < " queryobjsize : " < < <nl> / / pattern . objsize ( ) < < endl ; <nl> <nl> - if ( strncmp ( ns , " system . " , 7 ) = = 0 ) { <nl> + if ( strstr ( ns , " . system . " ) ) { <nl> cout < < " ERROR : attempt to delete in system namespace " < < ns < < endl ; <nl> return ; <nl> } <nl> cout < < " TEMP : " < < m . fieldName < < ' ' < < m . n < < endl ; <nl> } <nl> } <nl> <nl> - / * <nl> + / * <nl> todo : <nl> - support $ inc : n <nl> smart requery find record immediately <nl> * / <nl> void updateObjects ( const char * ns , JSObj updateobj , JSObj pattern , bool upsert ) { <nl> + / / cout < < " TEMP BAD " ; <nl> + / / lrutest . find ( updateobj ) ; <nl> + <nl> + <nl> / / cout < < " update ns : " < < ns < < " objsize : " < < updateobj . objsize ( ) < < " queryobjsize : " < < <nl> / / pattern . objsize ( ) ; <nl> <nl> - if ( strncmp ( ns , " system . " , 7 ) = = 0 ) { <nl> + if ( strstr ( ns , " . system . " ) ) { <nl> cout < < " \ nERROR : attempt to update in system namespace " < < ns < < endl ; <nl> return ; <nl> } <nl> inline bool runCommands ( const char * ns , JSObj & jsobj , stringstream & ss , BufBuild <nl> if ( strcmp ( e . fieldName ( ) , " deleteIndexes " ) = = 0 ) { <nl> valid = true ; <nl> / * note : temp implementation . space not reclaimed ! * / <nl> - NamespaceDetails * d = namespaceIndex . details ( e . valuestr ( ) ) ; <nl> + NamespaceDetails * d = nsdetails ( e . valuestr ( ) ) ; <nl> cout < < " CMD : deleteIndexes " < < e . valuestr ( ) < < endl ; <nl> if ( d ) { <nl> ok = true ; <nl> mmm a / db / storage . h <nl> ppp b / db / storage . h <nl> class DeletedRecord ; <nl> class Extent ; <nl> class BtreeBucket ; <nl> class JSObj ; <nl> + class PhysicalDataFile ; <nl> <nl> class DiskLoc { <nl> - int reserved ; / * this will be volume , file # , etc . * / <nl> + int fileNo ; / * this will be volume , file # , etc . * / <nl> int ofs ; <nl> public : <nl> enum { NullOfs = - 1 } ; <nl> - int a ( ) const { return reserved ; } <nl> - DiskLoc ( int a , int b ) : reserved ( a ) , ofs ( b ) { } <nl> - DiskLoc ( ) { reserved = - 1 ; ofs = NullOfs ; } <nl> - DiskLoc ( const DiskLoc & l ) { reserved = l . reserved ; ofs = l . ofs ; } <nl> + int a ( ) const { return fileNo ; } <nl> + DiskLoc ( int a , int b ) : fileNo ( a ) , ofs ( b ) { } <nl> + DiskLoc ( ) { fileNo = - 1 ; ofs = NullOfs ; } <nl> + DiskLoc ( const DiskLoc & l ) { fileNo = l . fileNo ; ofs = l . ofs ; } <nl> <nl> bool isNull ( ) const { return ofs = = NullOfs ; } <nl> - void Null ( ) { reserved = - 1 ; ofs = NullOfs ; } <nl> + void Null ( ) { fileNo = - 1 ; ofs = NullOfs ; } <nl> void assertOk ( ) { assert ( ! isNull ( ) ) ; } <nl> <nl> int getOfs ( ) const { return ofs ; } <nl> - void set ( int a , int b ) { reserved = a ; ofs = b ; } <nl> - void setOfs ( int _ofs ) { <nl> - reserved = - 2 ; / * temp : fix for multiple datafiles * / <nl> + void set ( int a , int b ) { fileNo = a ; ofs = b ; } <nl> + void setOfs ( int _fileNo , int _ofs ) { <nl> + fileNo = _fileNo ; <nl> ofs = _ofs ; <nl> } <nl> <nl> class DiskLoc { <nl> ofs + = amt ; <nl> } <nl> <nl> - bool sameFile ( DiskLoc b ) { return reserved = = b . reserved ; / * not really done . . . * / } <nl> + bool sameFile ( DiskLoc b ) { return fileNo = = b . fileNo ; } <nl> <nl> - bool operator = = ( const DiskLoc & b ) const { return reserved = = b . reserved & & ofs = = b . ofs ; } <nl> + bool operator = = ( const DiskLoc & b ) const { return fileNo = = b . fileNo & & ofs = = b . ofs ; } <nl> bool operator ! = ( const DiskLoc & b ) const { return ! ( * this = = b ) ; } <nl> const DiskLoc & operator = ( const DiskLoc & b ) { <nl> - reserved = b . reserved ; ofs = b . ofs ; <nl> + fileNo = b . fileNo ; ofs = b . ofs ; <nl> return * this ; <nl> } <nl> bool operator < ( const DiskLoc & b ) const { <nl> - if ( reserved = = b . reserved ) <nl> + if ( fileNo = = b . fileNo ) <nl> return ofs < b . ofs ; <nl> - return reserved < b . reserved ; <nl> + return fileNo < b . fileNo ; <nl> } <nl> <nl> JSObj obj ( ) const ; <nl> class DiskLoc { <nl> DeletedRecord * drec ( ) const ; <nl> Extent * ext ( ) const ; <nl> BtreeBucket * btree ( ) const ; <nl> + <nl> + PhysicalDataFile & pdf ( ) const ; <nl> } ; <nl> <nl> # pragma pack ( pop ) <nl> mmm a / util / goodies . h <nl> ppp b / util / goodies . h <nl> inline pthread_t GetCurrentThreadId ( ) { return pthread_self ( ) ; } <nl> / * set to TRUE if we are exiting * / <nl> extern bool goingAway ; <nl> <nl> + bool isPrime ( int n ) ; <nl> + int nextPrime ( int n ) ; <nl> + <nl> inline void dumpmemory ( const char * data , int len ) { <nl> if ( len > 1024 ) <nl> len = 1024 ; <nl> new file mode 100644 <nl> index 000000000000 . . 1fd63d577fb5 <nl> mmm / dev / null <nl> ppp b / util / lruishmap . h <nl> <nl> + / / lru - ish map . h <nl> + <nl> + # pragma once <nl> + <nl> + # include " . . / stdafx . h " <nl> + # include " . . / util / goodies . h " <nl> + <nl> + / * Your K object must define : <nl> + int hash ( ) - must always return > 0 . <nl> + operator = = <nl> + * / <nl> + <nl> + template < class K , class V , int MaxChain > <nl> + class LRUishMap { <nl> + public : <nl> + LRUishMap ( int _n ) { <nl> + n = nextPrime ( _n ) ; <nl> + keys = new K [ n ] ; <nl> + hashes = new int [ n ] ; <nl> + for ( int i = 0 ; i < n ; i + + ) hashes [ i ] = 0 ; <nl> + } <nl> + ~ LRUishMap ( ) { <nl> + delete [ ] keys ; <nl> + delete [ ] hashes ; <nl> + } <nl> + <nl> + int _find ( const K & k , bool & found ) { <nl> + int h = k . hash ( ) ; <nl> + assert ( h > 0 ) ; <nl> + int j = h % n ; <nl> + int first = j ; <nl> + for ( int i = 0 ; i < MaxChain ; i + + ) { <nl> + if ( hashes [ j ] = = h ) { <nl> + if ( keys [ j ] = = k ) { <nl> + found = true ; <nl> + return j ; <nl> + } <nl> + } <nl> + else if ( hashes [ j ] = = 0 ) { <nl> + found = false ; <nl> + return j ; <nl> + } <nl> + } <nl> + found = false ; <nl> + return first ; <nl> + } <nl> + <nl> + V * find ( const K & k ) { <nl> + bool found ; <nl> + int j = _find ( k , found ) ; <nl> + return found ? & values [ j ] : 0 ; <nl> + } <nl> + <nl> + private : <nl> + int n ; <nl> + K * keys ; <nl> + int * hashes ; <nl> + V * values ; <nl> + } ; <nl> mmm a / util / util . cpp <nl> ppp b / util / util . cpp <nl> <nl> <nl> bool goingAway = false ; <nl> <nl> + bool isPrime ( int n ) { <nl> + int z = 2 ; <nl> + while ( 1 ) { <nl> + if ( z * z > n ) <nl> + break ; <nl> + if ( n % z = = 0 ) <nl> + return false ; <nl> + z + + ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + int nextPrime ( int n ) { <nl> + n | = 1 ; / / 2 goes to 3 . . . don ' t care . . . <nl> + while ( ! isPrime ( n ) ) <nl> + n + = 2 ; <nl> + return n ; <nl> + } <nl> + <nl> struct UtilTest { <nl> UtilTest ( ) { <nl> assert ( WrappingInt ( 0 ) < = WrappingInt ( 0 ) ) ; <nl> struct UtilTest { <nl> assert ( tdiff ( 3 , 4 ) = = 1 ) ; <nl> assert ( tdiff ( 4 , 3 ) = = - 1 ) ; <nl> assert ( tdiff ( 0xffffffff , 0 ) = = 1 ) ; <nl> + <nl> + assert ( isPrime ( 3 ) ) ; <nl> + assert ( isPrime ( 2 ) ) ; <nl> + assert ( isPrime ( 13 ) ) ; <nl> + assert ( isPrime ( 17 ) ) ; <nl> + assert ( ! isPrime ( 9 ) ) ; <nl> + assert ( ! isPrime ( 6 ) ) ; <nl> + assert ( nextPrime ( 4 ) = = 5 ) ; <nl> + assert ( nextPrime ( 8 ) = = 11 ) ; <nl> } <nl> } utilTest ; <nl>
separate dbs
mongodb/mongo
a186665dd792aabe3f2cba60880e2d8f1b5017fb
2008-01-20T22:42:26Z
mmm a / tensorflow / stream_executor / dnn . cc <nl> ppp b / tensorflow / stream_executor / dnn . cc <nl> PoolingDescriptor : : PoolingDescriptor ( int ndims ) <nl> propagate_nans_ ( false ) , <nl> window_ ( ndims , 0 ) , <nl> padding_ ( ndims , 0 ) , <nl> - strides_ ( ndims , 1 ) , <nl> - propagate_nans_ ( false ) { } <nl> + strides_ ( ndims , 1 ) { } <nl> <nl> PoolingDescriptor : : PoolingDescriptor ( ) : PoolingDescriptor ( / * ndims = * / 2 ) { } <nl> <nl>
Remove extra propagate_nans from tensorflow / stream_executor / dnn . cc
tensorflow/tensorflow
51f5eb77f089f17f17653b5655f8207d3ff5d36b
2017-11-23T00:47:31Z
mmm a / lib / addons / library . kodi . guilib / Makefile . in <nl> ppp b / lib / addons / library . kodi . guilib / Makefile . in <nl> LIB_SHARED = . . / . . / . . / addons / library . kodi . guilib / $ ( LIBNAME ) - $ ( ARCH ) . so <nl> endif <nl> <nl> GENERATED_ADDON_GUILIB = . . / . . / . . / addons / kodi . guilib / addon . xml <nl> - LIB_VERSION : = $ ( shell sed - n ' s / . * KODI_GUILIB_API_VERSION \ s * " \ ( . * \ ) " / \ 1 / p ' $ ( LIB_INTERFACE ) ) <nl> - LIB_VERSION_MIN : = $ ( shell sed - n ' s / . * KODI_GUILIB_MIN_API_VERSION \ s * " \ ( . * \ ) " / \ 1 / p ' $ ( LIB_INTERFACE ) ) <nl> + LIB_VERSION : = $ ( shell sed - n ' s / . * KODI_GUILIB_API_VERSION [ [ : space : ] ] * " \ ( . * \ ) " / \ 1 / p ' $ ( LIB_INTERFACE ) ) <nl> + LIB_VERSION_MIN : = $ ( shell sed - n ' s / . * KODI_GUILIB_MIN_API_VERSION [ [ : space : ] ] * " \ ( . * \ ) " / \ 1 / p ' $ ( LIB_INTERFACE ) ) <nl> <nl> all : $ ( LIB_SHARED ) $ ( GENERATED_ADDON_GUILIB ) <nl> <nl>
Merge pull request from FernetMenta / guilib
xbmc/xbmc
2db776592f52d66d8bb0944775fa010531cb466e
2016-09-20T14:37:09Z
mmm a / imgui_draw . cpp <nl> ppp b / imgui_draw . cpp <nl> void ImDrawListSplitter : : ClearFreeMemory ( ) <nl> <nl> void ImDrawListSplitter : : Split ( ImDrawList * draw_list , int channels_count ) <nl> { <nl> - IM_ASSERT ( _Current = = 0 & & _Count = = 1 ) ; <nl> + IM_ASSERT ( _Current = = 0 & & _Count < = 1 ) ; <nl> int old_channels_count = _Channels . Size ; <nl> if ( old_channels_count < channels_count ) <nl> _Channels . resize ( channels_count ) ; <nl> void ImDrawListSplitter : : Split ( ImDrawList * draw_list , int channels_count ) <nl> } <nl> } <nl> <nl> + static inline bool CanMergeDrawCommands ( ImDrawCmd * a , ImDrawCmd * b ) <nl> + { <nl> + return memcmp ( & a - > ClipRect , & b - > ClipRect , sizeof ( a - > ClipRect ) ) = = 0 & & a - > TextureId = = b - > TextureId & & ! a - > UserCallback & & ! b - > UserCallback ; <nl> + } <nl> + <nl> void ImDrawListSplitter : : Merge ( ImDrawList * draw_list ) <nl> { <nl> / / Note that we never use or rely on channels . Size because it is merely a buffer that we never shrink back to 0 to keep all sub - buffers ready for use . <nl> void ImDrawListSplitter : : Merge ( ImDrawList * draw_list ) <nl> / / Calculate our final buffer sizes . Also fix the incorrect IdxOffset values in each command . <nl> int new_cmd_buffer_count = 0 ; <nl> int new_idx_buffer_count = 0 ; <nl> - int idx_offset = ( draw_list - > CmdBuffer . Size ! = 0 ) ? ( draw_list - > CmdBuffer . back ( ) . IdxOffset + draw_list - > CmdBuffer . back ( ) . ElemCount ) : 0 ; <nl> + ImDrawCmd * last_cmd = ( _Count > 0 & & _Channels [ 0 ] . CmdBuffer . Size > 0 ) ? & _Channels [ 0 ] . CmdBuffer . back ( ) : NULL ; <nl> + int idx_offset = last_cmd ? last_cmd - > IdxOffset + last_cmd - > ElemCount : 0 ; <nl> for ( int i = 1 ; i < _Count ; i + + ) <nl> { <nl> ImDrawChannel & ch = _Channels [ i ] ; <nl> if ( ch . CmdBuffer . Size & & ch . CmdBuffer . back ( ) . ElemCount = = 0 ) <nl> ch . CmdBuffer . pop_back ( ) ; <nl> + else if ( ch . CmdBuffer . Size > 0 & & last_cmd ! = NULL & & CanMergeDrawCommands ( last_cmd , & ch . CmdBuffer [ 0 ] ) ) <nl> + { <nl> + / / Merge previous channel last draw command with current channel first draw command if matching . <nl> + last_cmd - > ElemCount + = ch . CmdBuffer [ 0 ] . ElemCount ; <nl> + ch . CmdBuffer . erase ( ch . CmdBuffer . Data ) ; <nl> + } <nl> + if ( ch . CmdBuffer . Size > 0 ) <nl> + last_cmd = & ch . CmdBuffer . back ( ) ; <nl> new_cmd_buffer_count + = ch . CmdBuffer . Size ; <nl> new_idx_buffer_count + = ch . IdxBuffer . Size ; <nl> for ( int cmd_n = 0 ; cmd_n < ch . CmdBuffer . Size ; cmd_n + + ) <nl>
ImDrawListSplitter : Support merging consecutive draw commands straddling two channels . Support zero - init .
ocornut/imgui
cef88f6aae52bf0e9e558ea5e30eca95676f439b
2019-05-31T10:06:35Z
mmm a / lib / Frontend / CompilerInvocation . cpp <nl> ppp b / lib / Frontend / CompilerInvocation . cpp <nl> static bool ParseClangImporterArgs ( ClangImporterOptions & Opts , <nl> } ) ; <nl> } <nl> <nl> - Opts . InferDefaultArguments | = Args . hasArg ( OPT_enable_infer_default_arguments ) ; <nl> + Opts . InferImportAsMember | = Args . hasArg ( OPT_enable_infer_import_as_member ) ; <nl> Opts . DumpClangDiagnostics | = Args . hasArg ( OPT_dump_clang_diagnostics ) ; <nl> <nl> if ( Args . hasArg ( OPT_embed_bitcode ) ) <nl> mmm a / test / IDE / Inputs / custom - modules / ImportAsMemberProto . h <nl> ppp b / test / IDE / Inputs / custom - modules / ImportAsMemberProto . h <nl> typedef NSObject < ImportedProtocolBase > * ImportedProtocolBase_t ; <nl> @ protocol IAMProto < ImportedProtocolBase > <nl> @ end <nl> <nl> - / / HACK HACK HACK : There is a bug in the importer where we can ' t begin with the type name . . . <nl> - typedef NSObject < IAMProto > * zIAMProto_t ; <nl> - typedef NSObject < IAMProto > * Dummy ; <nl> + typedef NSObject < IAMProto > * IAMProto_t ; <nl> <nl> - <nl> - void mutateSomeState ( zIAMProto_t ) <nl> + void mutateSomeState ( IAMProto_t ) <nl> __attribute__ ( ( swift_name ( " IAMProto . mutateSomeState ( self : ) " ) ) ) ; <nl> <nl> - void mutateSomeStateWithOtherProto ( zIAMProto_t , zIAMProto_t other ) <nl> + void mutateSomeStateWithOtherProto ( IAMProto_t , IAMProto_t other ) <nl> __attribute__ ( ( swift_name ( " IAMProto . mutateSomeState ( self : otherProto : ) " ) ) ) ; <nl> <nl> - int getSomeValue ( zIAMProto_t ) <nl> + int getSomeValue ( IAMProto_t ) <nl> __attribute__ ( ( swift_name ( " getter : IAMProto . someValue ( self : ) " ) ) ) ; <nl> - int setSomeValue ( zIAMProto_t , int v ) <nl> + int setSomeValue ( IAMProto_t , int v ) <nl> __attribute__ ( ( swift_name ( " setter : IAMProto . someValue ( self : _ : ) " ) ) ) ; <nl> <nl> # endif / / IMPORT_AS_MEMBER_PROTO_H <nl> mmm a / test / IDE / import_as_member . swift <nl> ppp b / test / IDE / import_as_member . swift <nl> <nl> - / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = ImportAsMember . A - enable - omit - needless - words - always - argument - labels > % t . printed . A . txt <nl> - / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = ImportAsMember . B - enable - omit - needless - words - always - argument - labels > % t . printed . B . txt <nl> - / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = ImportAsMember . Proto - enable - omit - needless - words - always - argument - labels > % t . printed . Proto . txt <nl> + / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = ImportAsMember . A - always - argument - labels > % t . printed . A . txt <nl> + / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = ImportAsMember . B - always - argument - labels > % t . printed . B . txt <nl> + / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = ImportAsMember . Proto - always - argument - labels > % t . printed . Proto . txt <nl> <nl> / / RUN : FileCheck % s - check - prefix = PRINT - strict - whitespace < % t . printed . A . txt <nl> / / RUN : FileCheck % s - check - prefix = PRINTB - strict - whitespace < % t . printed . B . txt <nl> <nl> / / PRINT - PROTO - NEXT : typealias ImportedProtocolBase_t = ImportedProtocolBase <nl> / / PRINT - PROTO - NEXT : protocol IAMProto : ImportedProtocolBase { <nl> / / PRINT - PROTO - NEXT : } <nl> - / / PRINT - PROTO - NEXT : typealias zIAMProto_t = IAMProto <nl> - / / PRINT - PROTO - NEXT : typealias Dummy = NSObject <nl> + / / PRINT - PROTO - NEXT : typealias IAMProto_t = IAMProto <nl> / / PRINT - PROTO - NEXT : extension IAMProto { <nl> / / PRINT - PROTO - NEXT : func mutateSomeState ( ) <nl> - / / PRINT - PROTO - NEXT : func mutateSomeState ( otherProto other : zIAMProto_t ! ) <nl> + / / PRINT - PROTO - NEXT : func mutateSomeState ( otherProto other : IAMProto_t ! ) <nl> / / PRINT - PROTO - NEXT : var someValue : Int32 <nl> / / PRINT - PROTO - NEXT : } <nl> <nl> mmm a / test / IDE / import_as_member_cf . swift <nl> ppp b / test / IDE / import_as_member_cf . swift <nl> <nl> - / / RUN : % target - swift - ide - test ( mock - sdk : - sdk % S / . . / Inputs / clang - importer - sdk - I % t - I % S / Inputs / custom - modules ) - print - module - source - filename % s - module - to - print = ImportAsMember . C - enable - omit - needless - words - always - argument - labels > % t . printed . C . txt <nl> + / / RUN : % target - swift - ide - test ( mock - sdk : - sdk % S / . . / Inputs / clang - importer - sdk - I % t - I % S / Inputs / custom - modules ) - print - module - source - filename % s - module - to - print = ImportAsMember . C - always - argument - labels > % t . printed . C . txt <nl> <nl> / / REQUIRES : objc_interop <nl> <nl> mmm a / test / IDE / infer_import_as_member . swift <nl> ppp b / test / IDE / infer_import_as_member . swift <nl> <nl> - / / RUN : % target - swift - ide - test ( mock - sdk : - sdk % S / . . / Inputs / clang - importer - sdk - I % t - I % S / Inputs / custom - modules ) - print - module - source - filename % s - module - to - print = InferImportAsMember - enable - omit - needless - words - always - argument - labels - enable - infer - import - as - member > % t . printed . A . txt <nl> + / / RUN : % target - swift - ide - test ( mock - sdk : % clang - importer - sdk ) - I % t - I % S / Inputs / custom - modules - print - module - source - filename % s - module - to - print = InferImportAsMember - always - argument - labels - enable - infer - import - as - member > % t . printed . A . txt <nl> / / RUN : FileCheck % s - check - prefix = PRINT - strict - whitespace < % t . printed . A . txt <nl> <nl> import InferImportAsMember <nl>
[ Import as member ] Bring up to date with fixes from master
apple/swift
bb43d887921500144a7c78e63ebd69b4e6dfc25e
2016-03-24T00:02:03Z
mmm a / tools / release / auto_roll . py <nl> ppp b / tools / release / auto_roll . py <nl> <nl> <nl> ISSUE_MSG = ( <nl> " " " Please follow these instructions for assigning / CC ' ing issues : <nl> - https : / / code . google . com / p / v8 - wiki / wiki / TriagingIssues <nl> + https : / / github . com / v8 / v8 / wiki / Triaging % 20issues <nl> <nl> Please close rolling in case of a roll revert : <nl> https : / / v8 - roll . appspot . com / <nl> mmm a / tools / release / test_scripts . py <nl> ppp b / tools / release / test_scripts . py <nl> def CheckVersionCommit ( ) : <nl> https : / / chromium . googlesource . com / v8 / v8 / + log / last_rol . . roll_hsh <nl> <nl> Please follow these instructions for assigning / CC ' ing issues : <nl> - https : / / code . google . com / p / v8 - wiki / wiki / TriagingIssues <nl> + https : / / github . com / v8 / v8 / wiki / Triaging % 20issues <nl> <nl> Please close rolling in case of a roll revert : <nl> https : / / v8 - roll . appspot . com / <nl>
[ Release ] Update URL to point to the new V8 wiki
v8/v8
802c036ad5814bbf575213e4eb8ea2cede165133
2015-11-30T13:55:13Z
mmm a / src / Interpreters / Aggregator . cpp <nl> ppp b / src / Interpreters / Aggregator . cpp <nl> void NO_INLINE Aggregator : : mergeSingleLevelDataImpl ( <nl> } <nl> } <nl> <nl> + # define M ( NAME ) \ <nl> + template void NO_INLINE Aggregator : : mergeSingleLevelDataImpl < decltype ( AggregatedDataVariants : : NAME ) : : element_type > ( \ <nl> + ManyAggregatedDataVariants & non_empty_data ) const ; <nl> + APPLY_FOR_VARIANTS_SINGLE_LEVEL ( M ) <nl> + # undef M <nl> <nl> template < typename Method > <nl> void NO_INLINE Aggregator : : mergeBucketImpl ( <nl> mmm a / src / Parsers / ExpressionElementParsers . cpp <nl> ppp b / src / Parsers / ExpressionElementParsers . cpp <nl> bool ParserCollectionOfLiterals < Collection > : : parseImpl ( Pos & pos , ASTPtr & node , <nl> return false ; <nl> } <nl> <nl> + template bool ParserCollectionOfLiterals < Array > : : parseImpl ( Pos & pos , ASTPtr & node , Expected & expected ) ; <nl> + template bool ParserCollectionOfLiterals < Tuple > : : parseImpl ( Pos & pos , ASTPtr & node , Expected & expected ) ; <nl> <nl> bool ParserLiteral : : parseImpl ( Pos & pos , ASTPtr & node , Expected & expected ) <nl> { <nl>
Merge pull request from amosbird / shared - build - fix
ClickHouse/ClickHouse
8f7ee19a2de04fcde47afd19efb4976a22f83500
2020-05-09T16:33:31Z
mmm a / dlib / appveyor / python . yml <nl> ppp b / dlib / appveyor / python . yml <nl> <nl> <nl> environment : <nl> matrix : <nl> - - PATH : C : \ Python35 ; % PATH % <nl> - - PATH : C : \ Python35 - x64 ; % PATH % <nl> - PATH : C : \ Python36 ; % PATH % <nl> - PATH : C : \ Python36 - x64 ; % PATH % <nl> - PATH : C : \ Python37 ; % PATH % <nl>
Remove Python 3 . 5 tests on AppVeyor because something is wrong with python 3 . 5 on appveyor and the other tests are sufficient for python coverage .
davisking/dlib
ea451995728a625319bbe054bf8c74df92e3df80
2019-01-20T01:40:21Z
mmm a / Marlin / Configuration . h <nl> ppp b / Marlin / Configuration . h <nl> <nl> / / 82 = Brainwave ( AT90USB646 ) <nl> / / 9 = Gen3 + <nl> / / 70 = Megatronics <nl> + / / 701 = Megatronics v2 . 0 <nl> + / / 702 = Minitronics v1 . 0 <nl> / / 90 = Alpha OMCA board <nl> / / 91 = Final OMCA board <nl> / / 301 = Rambo <nl> mmm a / Marlin / fastio . h <nl> ppp b / Marlin / fastio . h <nl> pins <nl> # define PF7_DDR DDRF <nl> # endif <nl> <nl> + <nl> + # if defined ( __AVR_ATmega1281__ ) | | defined ( __AVR_ATmega2561__ ) <nl> + / / UART <nl> + # define RXD DIO0 <nl> + # define TXD DIO1 <nl> + <nl> + / / SPI <nl> + # define SCK DIO10 <nl> + # define MISO DIO12 <nl> + # define MOSI DIO11 <nl> + # define SS DIO16 <nl> + <nl> + / / TWI ( I2C ) <nl> + # define SCL DIO17 <nl> + # define SDA DIO18 <nl> + <nl> + / / timers and PWM <nl> + # define OC0A DIO9 <nl> + # define OC0B DIO4 <nl> + # define OC1A DIO7 <nl> + # define OC1B DIO8 <nl> + # define OC2A DIO6 <nl> + # define OC3A DIO5 <nl> + # define OC3B DIO2 <nl> + # define OC3C DIO3 <nl> + <nl> + <nl> + / / change for your board <nl> + # define DEBUG_LED DIO46 <nl> + <nl> + / * <nl> + pins <nl> + * / <nl> + # define DIO0_PIN PINE0 <nl> + # define DIO0_RPORT PINE <nl> + # define DIO0_WPORT PORTE <nl> + # define DIO0_DDR DDRE <nl> + # define DIO0_PWM NULL <nl> + <nl> + # define DIO1_PIN PINE1 <nl> + # define DIO1_RPORT PINE <nl> + # define DIO1_WPORT PORTE <nl> + # define DIO1_DDR DDRE <nl> + # define DIO1_PWM NULL <nl> + <nl> + # define DIO2_PIN PINE4 <nl> + # define DIO2_RPORT PINE <nl> + # define DIO2_WPORT PORTE <nl> + # define DIO2_DDR DDRE <nl> + # define DIO2_PWM & OCR3BL <nl> + <nl> + # define DIO3_PIN PINE5 <nl> + # define DIO3_RPORT PINE <nl> + # define DIO3_WPORT PORTE <nl> + # define DIO3_DDR DDRE <nl> + # define DIO3_PWM & OCR3CL <nl> + <nl> + # define DIO4_PIN PING5 <nl> + # define DIO4_RPORT PING <nl> + # define DIO4_WPORT PORTG <nl> + # define DIO4_DDR DDRG <nl> + # define DIO4_PWM & OCR0B <nl> + <nl> + # define DIO5_PIN PINE3 <nl> + # define DIO5_RPORT PINE <nl> + # define DIO5_WPORT PORTE <nl> + # define DIO5_DDR DDRE <nl> + # define DIO5_PWM & OCR3AL <nl> + <nl> + # define DIO6_PIN PINB4 <nl> + # define DIO6_RPORT PINB <nl> + # define DIO6_WPORT PORTB <nl> + # define DIO6_DDR DDRB <nl> + # define DIO6_PWM & OCR2AL <nl> + <nl> + # define DIO7_PIN PINB5 <nl> + # define DIO7_RPORT PINB <nl> + # define DIO7_WPORT PORTB <nl> + # define DIO7_DDR DDRB <nl> + # define DIO7_PWM & OCR1AL <nl> + <nl> + # define DIO8_PIN PINB6 <nl> + # define DIO8_RPORT PINB <nl> + # define DIO8_WPORT PORTB <nl> + # define DIO8_DDR DDRB <nl> + # define DIO8_PWM & OCR1BL <nl> + <nl> + # define DIO9_PIN PINB7 <nl> + # define DIO9_RPORT PINB <nl> + # define DIO9_WPORT PORTB <nl> + # define DIO9_DDR DDRB <nl> + # define DIO9_PWM & OCR0AL <nl> + <nl> + # define DIO10_PIN PINB1 <nl> + # define DIO10_RPORT PINB <nl> + # define DIO10_WPORT PORTB <nl> + # define DIO10_DDR DDRB <nl> + # define DIO10_PWM NULL <nl> + <nl> + # define DIO11_PIN PINB2 <nl> + # define DIO11_RPORT PINB <nl> + # define DIO11_WPORT PORTB <nl> + # define DIO11_DDR DDRB <nl> + # define DIO11_PWM NULL <nl> + <nl> + # define DIO12_PIN PINB3 <nl> + # define DIO12_RPORT PINB <nl> + # define DIO12_WPORT PORTB <nl> + # define DIO12_DDR DDRB <nl> + # define DIO12_PWM NULL <nl> + <nl> + # define DIO13_PIN PINE2 <nl> + # define DIO13_RPORT PINE <nl> + # define DIO13_WPORT PORTE <nl> + # define DIO13_DDR DDRE <nl> + # define DIO13_PWM NULL <nl> + <nl> + # define DIO14_PIN PINE6 <nl> + # define DIO14_RPORT PINE <nl> + # define DIO14_WPORT PORTE <nl> + # define DIO14_DDR DDRE <nl> + # define DIO14_PWM NULL <nl> + <nl> + # define DIO15_PIN PINE7 <nl> + # define DIO15_RPORT PINE <nl> + # define DIO15_WPORT PORTE <nl> + # define DIO15_DDR DDRE <nl> + # define DIO15_PWM NULL <nl> + <nl> + # define DIO16_PIN PINB0 <nl> + # define DIO16_RPORT PINB <nl> + # define DIO16_WPORT PORTB <nl> + # define DIO16_DDR DDRB <nl> + # define DIO16_PWM NULL <nl> + <nl> + # define DIO17_PIN PIND0 <nl> + # define DIO17_RPORT PIND <nl> + # define DIO17_WPORT PORTD <nl> + # define DIO17_DDR DDRD <nl> + # define DIO17_PWM NULL <nl> + <nl> + # define DIO18_PIN PIND1 <nl> + # define DIO18_RPORT PIND <nl> + # define DIO18_WPORT PORTD <nl> + # define DIO18_DDR DDRD <nl> + # define DIO18_PWM NULL <nl> + <nl> + # define DIO19_PIN PIND2 <nl> + # define DIO19_RPORT PIND <nl> + # define DIO19_WPORT PORTD <nl> + # define DIO19_DDR DDRD <nl> + # define DIO19_PWM NULL <nl> + <nl> + # define DIO20_PIN PIND3 <nl> + # define DIO20_RPORT PIND <nl> + # define DIO20_WPORT PORTD <nl> + # define DIO20_DDR DDRD <nl> + # define DIO20_PWM NULL <nl> + <nl> + # define DIO21_PIN PIND4 <nl> + # define DIO21_RPORT PIND <nl> + # define DIO21_WPORT PORTD <nl> + # define DIO21_DDR DDRD <nl> + # define DIO21_PWM NULL <nl> + <nl> + # define DIO22_PIN PIND5 <nl> + # define DIO22_RPORT PIND <nl> + # define DIO22_WPORT PORTD <nl> + # define DIO22_DDR DDRD <nl> + # define DIO22_PWM NULL <nl> + <nl> + # define DIO23_PIN PIND6 <nl> + # define DIO23_RPORT PIND <nl> + # define DIO23_WPORT PORTD <nl> + # define DIO23_DDR DDRD <nl> + # define DIO23_PWM NULL <nl> + <nl> + # define DIO24_PIN PIND7 <nl> + # define DIO24_RPORT PIND <nl> + # define DIO24_WPORT PORTD <nl> + # define DIO24_DDR DDRD <nl> + # define DIO24_PWM NULL <nl> + <nl> + # define DIO25_PIN PING0 <nl> + # define DIO25_RPORT PING <nl> + # define DIO25_WPORT PORTG <nl> + # define DIO25_DDR DDRG <nl> + # define DIO25_PWM NULL <nl> + <nl> + # define DIO26_PIN PING1 <nl> + # define DIO26_RPORT PING <nl> + # define DIO26_WPORT PORTG <nl> + # define DIO26_DDR DDRG <nl> + # define DIO26_PWM NULL <nl> + <nl> + # define DIO27_PIN PING2 <nl> + # define DIO27_RPORT PING <nl> + # define DIO27_WPORT PORTG <nl> + # define DIO27_DDR DDRG <nl> + # define DIO27_PWM NULL <nl> + <nl> + # define DIO28_PIN PING3 <nl> + # define DIO28_RPORT PING <nl> + # define DIO28_WPORT PORTG <nl> + # define DIO28_DDR DDRG <nl> + # define DIO28_PWM NULL <nl> + <nl> + # define DIO29_PIN PING4 <nl> + # define DIO29_RPORT PING <nl> + # define DIO29_WPORT PORTG <nl> + # define DIO29_DDR DDRG <nl> + # define DIO29_PWM NULL <nl> + <nl> + # define DIO30_PIN PINC0 <nl> + # define DIO30_RPORT PINC <nl> + # define DIO30_WPORT PORTC <nl> + # define DIO30_DDR DDRC <nl> + # define DIO30_PWM NULL <nl> + <nl> + # define DIO31_PIN PINC1 <nl> + # define DIO31_RPORT PINC <nl> + # define DIO31_WPORT PORTC <nl> + # define DIO31_DDR DDRC <nl> + # define DIO31_PWM NULL <nl> + <nl> + # define DIO32_PIN PINC2 <nl> + # define DIO32_RPORT PINC <nl> + # define DIO32_WPORT PORTC <nl> + # define DIO32_DDR DDRC <nl> + # define DIO32_PWM NULL <nl> + <nl> + # define DIO33_PIN PINC3 <nl> + # define DIO33_RPORT PINC <nl> + # define DIO33_WPORT PORTC <nl> + # define DIO33_DDR DDRC <nl> + # define DIO33_PWM NULL <nl> + <nl> + # define DIO34_PIN PINC4 <nl> + # define DIO34_RPORT PINC <nl> + # define DIO34_WPORT PORTC <nl> + # define DIO34_DDR DDRC <nl> + # define DIO34_PWM NULL <nl> + <nl> + # define DIO35_PIN PINC5 <nl> + # define DIO35_RPORT PINC <nl> + # define DIO35_WPORT PORTC <nl> + # define DIO35_DDR DDRC <nl> + # define DIO35_PWM NULL <nl> + <nl> + # define DIO36_PIN PINC6 <nl> + # define DIO36_RPORT PINC <nl> + # define DIO36_WPORT PORTC <nl> + # define DIO36_DDR DDRC <nl> + # define DIO36_PWM NULL <nl> + <nl> + # define DIO37_PIN PINC7 <nl> + # define DIO37_RPORT PINC <nl> + # define DIO37_WPORT PORTC <nl> + # define DIO37_DDR DDRC <nl> + # define DIO37_PWM NULL <nl> + <nl> + # define DIO38_PIN PINA0 <nl> + # define DIO38_RPORT PINA <nl> + # define DIO38_WPORT PORTA <nl> + # define DIO38_DDR DDRA <nl> + # define DIO38_PWM NULL <nl> + <nl> + # define DIO39_PIN PINA1 <nl> + # define DIO39_RPORT PINA <nl> + # define DIO39_WPORT PORTA <nl> + # define DIO39_DDR DDRA <nl> + # define DIO39_PWM NULL <nl> + <nl> + # define DIO40_PIN PINA2 <nl> + # define DIO40_RPORT PINA <nl> + # define DIO40_WPORT PORTA <nl> + # define DIO40_DDR DDRA <nl> + # define DIO40_PWM NULL <nl> + <nl> + # define DIO41_PIN PINA3 <nl> + # define DIO41_RPORT PINA <nl> + # define DIO41_WPORT PORTA <nl> + # define DIO41_DDR DDRA <nl> + # define DIO41_PWM NULL <nl> + <nl> + # define DIO42_PIN PINA4 <nl> + # define DIO42_RPORT PINA <nl> + # define DIO42_WPORT PORTA <nl> + # define DIO42_DDR DDRA <nl> + # define DIO42_PWM NULL <nl> + <nl> + # define DIO43_PIN PINA5 <nl> + # define DIO43_RPORT PINA <nl> + # define DIO43_WPORT PORTA <nl> + # define DIO43_DDR DDRA <nl> + # define DIO43_PWM NULL <nl> + <nl> + # define DIO44_PIN PINA6 <nl> + # define DIO44_RPORT PINA <nl> + # define DIO44_WPORT PORTA <nl> + # define DIO44_DDR DDRA <nl> + # define DIO44_PWM NULL <nl> + <nl> + # define DIO45_PIN PINA7 <nl> + # define DIO45_RPORT PINA <nl> + # define DIO45_WPORT PORTA <nl> + # define DIO45_DDR DDRA <nl> + # define DIO45_PWM NULL <nl> + <nl> + # define DIO46_PIN PINF0 <nl> + # define DIO46_RPORT PINF <nl> + # define DIO46_WPORT PORTF <nl> + # define DIO46_DDR DDRF <nl> + # define DIO46_PWM NULL <nl> + <nl> + # define DIO47_PIN PINF1 <nl> + # define DIO47_RPORT PINF <nl> + # define DIO47_WPORT PORTF <nl> + # define DIO47_DDR DDRF <nl> + # define DIO47_PWM NULL <nl> + <nl> + # define DIO48_PIN PINF2 <nl> + # define DIO48_RPORT PINF <nl> + # define DIO48_WPORT PORTF <nl> + # define DIO48_DDR DDRF <nl> + # define DIO48_PWM NULL <nl> + <nl> + # define DIO49_PIN PINF3 <nl> + # define DIO49_RPORT PINF <nl> + # define DIO49_WPORT PORTF <nl> + # define DIO49_DDR DDRF <nl> + # define DIO49_PWM NULL <nl> + <nl> + # define DIO50_PIN PINF4 <nl> + # define DIO50_RPORT PINF <nl> + # define DIO50_WPORT PORTF <nl> + # define DIO50_DDR DDRF <nl> + # define DIO50_PWM NULL <nl> + <nl> + # define DIO51_PIN PINF5 <nl> + # define DIO51_RPORT PINF <nl> + # define DIO51_WPORT PORTF <nl> + # define DIO51_DDR DDRF <nl> + # define DIO51_PWM NULL <nl> + <nl> + # define DIO52_PIN PINF6 <nl> + # define DIO52_RPORT PINF <nl> + # define DIO52_WPORT PORTF <nl> + # define DIO52_DDR DDRF <nl> + # define DIO52_PWM NULL <nl> + <nl> + # define DIO53_PIN PINF7 <nl> + # define DIO53_RPORT PINF <nl> + # define DIO53_WPORT PORTF <nl> + # define DIO53_DDR DDRF <nl> + # define DIO53_PWM NULL <nl> + <nl> + <nl> + <nl> + <nl> + # undef PA0 <nl> + # define PA0_PIN PINA0 <nl> + # define PA0_RPORT PINA <nl> + # define PA0_WPORT PORTA <nl> + # define PA0_DDR DDRA <nl> + # define PA0_PWM NULL <nl> + # undef PA1 <nl> + # define PA1_PIN PINA1 <nl> + # define PA1_RPORT PINA <nl> + # define PA1_WPORT PORTA <nl> + # define PA1_DDR DDRA <nl> + # define PA1_PWM NULL <nl> + # undef PA2 <nl> + # define PA2_PIN PINA2 <nl> + # define PA2_RPORT PINA <nl> + # define PA2_WPORT PORTA <nl> + # define PA2_DDR DDRA <nl> + # define PA2_PWM NULL <nl> + # undef PA3 <nl> + # define PA3_PIN PINA3 <nl> + # define PA3_RPORT PINA <nl> + # define PA3_WPORT PORTA <nl> + # define PA3_DDR DDRA <nl> + # define PA3_PWM NULL <nl> + # undef PA4 <nl> + # define PA4_PIN PINA4 <nl> + # define PA4_RPORT PINA <nl> + # define PA4_WPORT PORTA <nl> + # define PA4_DDR DDRA <nl> + # define PA4_PWM NULL <nl> + # undef PA5 <nl> + # define PA5_PIN PINA5 <nl> + # define PA5_RPORT PINA <nl> + # define PA5_WPORT PORTA <nl> + # define PA5_DDR DDRA <nl> + # define PA5_PWM NULL <nl> + # undef PA6 <nl> + # define PA6_PIN PINA6 <nl> + # define PA6_RPORT PINA <nl> + # define PA6_WPORT PORTA <nl> + # define PA6_DDR DDRA <nl> + # define PA6_PWM NULL <nl> + # undef PA7 <nl> + # define PA7_PIN PINA7 <nl> + # define PA7_RPORT PINA <nl> + # define PA7_WPORT PORTA <nl> + # define PA7_DDR DDRA <nl> + # define PA7_PWM NULL <nl> + <nl> + # undef PB0 <nl> + # define PB0_PIN PINB0 <nl> + # define PB0_RPORT PINB <nl> + # define PB0_WPORT PORTB <nl> + # define PB0_DDR DDRB <nl> + # define PB0_PWM NULL <nl> + # undef PB1 <nl> + # define PB1_PIN PINB1 <nl> + # define PB1_RPORT PINB <nl> + # define PB1_WPORT PORTB <nl> + # define PB1_DDR DDRB <nl> + # define PB1_PWM NULL <nl> + # undef PB2 <nl> + # define PB2_PIN PINB2 <nl> + # define PB2_RPORT PINB <nl> + # define PB2_WPORT PORTB <nl> + # define PB2_DDR DDRB <nl> + # define PB2_PWM NULL <nl> + # undef PB3 <nl> + # define PB3_PIN PINB3 <nl> + # define PB3_RPORT PINB <nl> + # define PB3_WPORT PORTB <nl> + # define PB3_DDR DDRB <nl> + # define PB3_PWM NULL <nl> + # undef PB4 <nl> + # define PB4_PIN PINB4 <nl> + # define PB4_RPORT PINB <nl> + # define PB4_WPORT PORTB <nl> + # define PB4_DDR DDRB <nl> + # define PB4_PWM & OCR2A <nl> + # undef PB5 <nl> + # define PB5_PIN PINB5 <nl> + # define PB5_RPORT PINB <nl> + # define PB5_WPORT PORTB <nl> + # define PB5_DDR DDRB <nl> + # define PB5_PWM NULL <nl> + # undef PB6 <nl> + # define PB6_PIN PINB6 <nl> + # define PB6_RPORT PINB <nl> + # define PB6_WPORT PORTB <nl> + # define PB6_DDR DDRB <nl> + # define PB6_PWM NULL <nl> + # undef PB7 <nl> + # define PB7_PIN PINB7 <nl> + # define PB7_RPORT PINB <nl> + # define PB7_WPORT PORTB <nl> + # define PB7_DDR DDRB <nl> + # define PB7_PWM & OCR0A <nl> + <nl> + # undef PC0 <nl> + # define PC0_PIN PINC0 <nl> + # define PC0_RPORT PINC <nl> + # define PC0_WPORT PORTC <nl> + # define PC0_DDR DDRC <nl> + # define PC0_PWM NULL <nl> + # undef PC1 <nl> + # define PC1_PIN PINC1 <nl> + # define PC1_RPORT PINC <nl> + # define PC1_WPORT PORTC <nl> + # define PC1_DDR DDRC <nl> + # define PC1_PWM NULL <nl> + # undef PC2 <nl> + # define PC2_PIN PINC2 <nl> + # define PC2_RPORT PINC <nl> + # define PC2_WPORT PORTC <nl> + # define PC2_DDR DDRC <nl> + # define PC2_PWM NULL <nl> + # undef PC3 <nl> + # define PC3_PIN PINC3 <nl> + # define PC3_RPORT PINC <nl> + # define PC3_WPORT PORTC <nl> + # define PC3_DDR DDRC <nl> + # define PC3_PWM NULL <nl> + # undef PC4 <nl> + # define PC4_PIN PINC4 <nl> + # define PC4_RPORT PINC <nl> + # define PC4_WPORT PORTC <nl> + # define PC4_DDR DDRC <nl> + # define PC4_PWM NULL <nl> + # undef PC5 <nl> + # define PC5_PIN PINC5 <nl> + # define PC5_RPORT PINC <nl> + # define PC5_WPORT PORTC <nl> + # define PC5_DDR DDRC <nl> + # define PC5_PWM NULL <nl> + # undef PC6 <nl> + # define PC6_PIN PINC6 <nl> + # define PC6_RPORT PINC <nl> + # define PC6_WPORT PORTC <nl> + # define PC6_DDR DDRC <nl> + # define PC6_PWM NULL <nl> + # undef PC7 <nl> + # define PC7_PIN PINC7 <nl> + # define PC7_RPORT PINC <nl> + # define PC7_WPORT PORTC <nl> + # define PC7_DDR DDRC <nl> + # define PC7_PWM NULL <nl> + <nl> + # undef PD0 <nl> + # define PD0_PIN PIND0 <nl> + # define PD0_RPORT PIND <nl> + # define PD0_WPORT PORTD <nl> + # define PD0_DDR DDRD <nl> + # define PD0_PWM NULL <nl> + # undef PD1 <nl> + # define PD1_PIN PIND1 <nl> + # define PD1_RPORT PIND <nl> + # define PD1_WPORT PORTD <nl> + # define PD1_DDR DDRD <nl> + # define PD1_PWM NULL <nl> + # undef PD2 <nl> + # define PD2_PIN PIND2 <nl> + # define PD2_RPORT PIND <nl> + # define PD2_WPORT PORTD <nl> + # define PD2_DDR DDRD <nl> + # define PD2_PWM NULL <nl> + # undef PD3 <nl> + # define PD3_PIN PIND3 <nl> + # define PD3_RPORT PIND <nl> + # define PD3_WPORT PORTD <nl> + # define PD3_DDR DDRD <nl> + # define PD3_PWM NULL <nl> + # undef PD4 <nl> + # define PD4_PIN PIND4 <nl> + # define PD4_RPORT PIND <nl> + # define PD4_WPORT PORTD <nl> + # define PD4_DDR DDRD <nl> + # define PD4_PWM NULL <nl> + # undef PD5 <nl> + # define PD5_PIN PIND5 <nl> + # define PD5_RPORT PIND <nl> + # define PD5_WPORT PORTD <nl> + # define PD5_DDR DDRD <nl> + # define PD5_PWM NULL <nl> + # undef PD6 <nl> + # define PD6_PIN PIND6 <nl> + # define PD6_RPORT PIND <nl> + # define PD6_WPORT PORTD <nl> + # define PD6_DDR DDRD <nl> + # define PD6_PWM NULL <nl> + # undef PD7 <nl> + # define PD7_PIN PIND7 <nl> + # define PD7_RPORT PIND <nl> + # define PD7_WPORT PORTD <nl> + # define PD7_DDR DDRD <nl> + # define PD7_PWM NULL <nl> + <nl> + # undef PE0 <nl> + # define PE0_PIN PINE0 <nl> + # define PE0_RPORT PINE <nl> + # define PE0_WPORT PORTE <nl> + # define PE0_DDR DDRE <nl> + # define PE0_PWM NULL <nl> + # undef PE1 <nl> + # define PE1_PIN PINE1 <nl> + # define PE1_RPORT PINE <nl> + # define PE1_WPORT PORTE <nl> + # define PE1_DDR DDRE <nl> + # define PE1_PWM NULL <nl> + # undef PE2 <nl> + # define PE2_PIN PINE2 <nl> + # define PE2_RPORT PINE <nl> + # define PE2_WPORT PORTE <nl> + # define PE2_DDR DDRE <nl> + # define PE2_PWM NULL <nl> + # undef PE3 <nl> + # define PE3_PIN PINE3 <nl> + # define PE3_RPORT PINE <nl> + # define PE3_WPORT PORTE <nl> + # define PE3_DDR DDRE <nl> + # define PE3_PWM & OCR3AL <nl> + # undef PE4 <nl> + # define PE4_PIN PINE4 <nl> + # define PE4_RPORT PINE <nl> + # define PE4_WPORT PORTE <nl> + # define PE4_DDR DDRE <nl> + # define PE4_PWM & OCR3BL <nl> + # undef PE5 <nl> + # define PE5_PIN PINE5 <nl> + # define PE5_RPORT PINE <nl> + # define PE5_WPORT PORTE <nl> + # define PE5_DDR DDRE <nl> + # define PE5_PWM & OCR3CL <nl> + # undef PE6 <nl> + # define PE6_PIN PINE6 <nl> + # define PE6_RPORT PINE <nl> + # define PE6_WPORT PORTE <nl> + # define PE6_DDR DDRE <nl> + # define PE6_PWM NULL <nl> + # undef PE7 <nl> + # define PE7_PIN PINE7 <nl> + # define PE7_RPORT PINE <nl> + # define PE7_WPORT PORTE <nl> + # define PE7_DDR DDRE <nl> + # define PE7_PWM NULL <nl> + <nl> + # undef PF0 <nl> + # define PF0_PIN PINF0 <nl> + # define PF0_RPORT PINF <nl> + # define PF0_WPORT PORTF <nl> + # define PF0_DDR DDRF <nl> + # define PF0_PWM NULL <nl> + # undef PF1 <nl> + # define PF1_PIN PINF1 <nl> + # define PF1_RPORT PINF <nl> + # define PF1_WPORT PORTF <nl> + # define PF1_DDR DDRF <nl> + # define PF1_PWM NULL <nl> + # undef PF2 <nl> + # define PF2_PIN PINF2 <nl> + # define PF2_RPORT PINF <nl> + # define PF2_WPORT PORTF <nl> + # define PF2_DDR DDRF <nl> + # define PF2_PWM NULL <nl> + # undef PF3 <nl> + # define PF3_PIN PINF3 <nl> + # define PF3_RPORT PINF <nl> + # define PF3_WPORT PORTF <nl> + # define PF3_DDR DDRF <nl> + # define PF3_PWM NULL <nl> + # undef PF4 <nl> + # define PF4_PIN PINF4 <nl> + # define PF4_RPORT PINF <nl> + # define PF4_WPORT PORTF <nl> + # define PF4_DDR DDRF <nl> + # define PF4_PWM NULL <nl> + # undef PF5 <nl> + # define PF5_PIN PINF5 <nl> + # define PF5_RPORT PINF <nl> + # define PF5_WPORT PORTF <nl> + # define PF5_DDR DDRF <nl> + # define PF5_PWM NULL <nl> + # undef PF6 <nl> + # define PF6_PIN PINF6 <nl> + # define PF6_RPORT PINF <nl> + # define PF6_WPORT PORTF <nl> + # define PF6_DDR DDRF <nl> + # define PF6_PWM NULL <nl> + # undef PF7 <nl> + # define PF7_PIN PINF7 <nl> + # define PF7_RPORT PINF <nl> + # define PF7_WPORT PORTF <nl> + # define PF7_DDR DDRF <nl> + # define PF7_PWM NULL <nl> + <nl> + # undef PG0 <nl> + # define PG0_PIN PING0 <nl> + # define PG0_RPORT PING <nl> + # define PG0_WPORT PORTG <nl> + # define PG0_DDR DDRG <nl> + # define PG0_PWM NULL <nl> + # undef PG1 <nl> + # define PG1_PIN PING1 <nl> + # define PG1_RPORT PING <nl> + # define PG1_WPORT PORTG <nl> + # define PG1_DDR DDRG <nl> + # define PG1_PWM NULL <nl> + # undef PG2 <nl> + # define PG2_PIN PING2 <nl> + # define PG2_RPORT PING <nl> + # define PG2_WPORT PORTG <nl> + # define PG2_DDR DDRG <nl> + # define PG2_PWM NULL <nl> + # undef PG3 <nl> + # define PG3_PIN PING3 <nl> + # define PG3_RPORT PING <nl> + # define PG3_WPORT PORTG <nl> + # define PG3_DDR DDRG <nl> + # define PG3_PWM NULL <nl> + # undef PG4 <nl> + # define PG4_PIN PING4 <nl> + # define PG4_RPORT PING <nl> + # define PG4_WPORT PORTG <nl> + # define PG4_DDR DDRG <nl> + # define PG4_PWM NULL <nl> + # undef PG5 <nl> + # define PG5_PIN PING5 <nl> + # define PG5_RPORT PING <nl> + # define PG5_WPORT PORTG <nl> + # define PG5_DDR DDRG <nl> + # define PG5_PWM & OCR0B <nl> + <nl> + <nl> + # endif <nl> + <nl> # ifndef DIO0_PIN <nl> # error pins for this chip not defined in arduino . h ! If you write an appropriate pin definition and have this firmware work on your chip , please submit a pull request <nl> # endif <nl> <nl> - # endif / * _FASTIO_ARDUINO_H * / <nl> + # endif / * _FASTIO_ARDUINO_H * / <nl> mmm a / Marlin / pins . h <nl> ppp b / Marlin / pins . h <nl> <nl> # if MOTHERBOARD = = 70 <nl> # define KNOWN_BOARD 1 <nl> <nl> - / / / / / / / / / / / / / / / / / / FIX THIS / / / / / / / / / / / / / / <nl> <nl> # ifndef __AVR_ATmega2560__ <nl> # error Oops ! Make sure you have ' Arduino Mega ' selected from the ' Tools - > Boards ' menu . <nl> <nl> # define BTN_EN2 64 <nl> # define BTN_ENC 43 / / the click <nl> <nl> - # define SDCARDDETECT - 1 / / Ramps does not use this port <nl> + # define BLEN_C 2 <nl> + # define BLEN_B 1 <nl> + # define BLEN_A 0 <nl> + <nl> + # define SDCARDDETECT - 1 / / Ramps does not use this port <nl> + <nl> + / / encoder rotation values <nl> + # define encrot0 0 <nl> + # define encrot1 2 <nl> + # define encrot2 3 <nl> + # define encrot3 1 <nl> # endif <nl> # endif / / ULTRA_LCD <nl> <nl> # endif <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * MegaTronics v2 . 0 <nl> + * <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if MOTHERBOARD = = 701 <nl> + # define KNOWN_BOARD 1 <nl> + <nl> + <nl> + # ifndef __AVR_ATmega2560__ <nl> + # error Oops ! Make sure you have ' Arduino Mega ' selected from the ' Tools - > Boards ' menu . <nl> + # endif <nl> + <nl> + # define LARGE_FLASH true <nl> + <nl> + # define X_STEP_PIN 26 <nl> + # define X_DIR_PIN 27 <nl> + # define X_ENABLE_PIN 25 <nl> + # define X_MIN_PIN 37 <nl> + # define X_MAX_PIN 40 / / 2 / / Max endstops default to disabled " - 1 " , set to commented value to enable . <nl> + <nl> + # define Y_STEP_PIN 4 / / A6 <nl> + # define Y_DIR_PIN 54 / / A0 <nl> + # define Y_ENABLE_PIN 5 <nl> + # define Y_MIN_PIN 41 <nl> + # define Y_MAX_PIN 38 / / 15 <nl> + <nl> + # define Z_STEP_PIN 56 / / A2 <nl> + # define Z_DIR_PIN 60 / / A6 <nl> + # define Z_ENABLE_PIN 55 / / A1 <nl> + # define Z_MIN_PIN 18 <nl> + # define Z_MAX_PIN 19 <nl> + <nl> + # define E0_STEP_PIN 35 <nl> + # define E0_DIR_PIN 36 <nl> + # define E0_ENABLE_PIN 34 <nl> + <nl> + # define E1_STEP_PIN 29 <nl> + # define E1_DIR_PIN 39 <nl> + # define E1_ENABLE_PIN 28 <nl> + <nl> + # define E2_STEP_PIN 23 <nl> + # define E2_DIR_PIN 24 <nl> + # define E2_ENABLE_PIN 22 <nl> + <nl> + # define SDPOWER - 1 <nl> + # define SDSS 53 <nl> + # define LED_PIN 13 <nl> + <nl> + # define FAN_PIN 7 <nl> + # define FAN2_PIN 6 <nl> + # define PS_ON_PIN 12 <nl> + # define KILL_PIN - 1 <nl> + <nl> + # define HEATER_0_PIN 9 / / EXTRUDER 1 <nl> + # define HEATER_1_PIN 8 / / EXTRUDER 2 <nl> + # define HEATER_2_PIN - 1 <nl> + <nl> + # if TEMP_SENSOR_0 = = - 1 <nl> + # define TEMP_0_PIN 4 / / ANALOG NUMBERING <nl> + # else <nl> + # define TEMP_0_PIN 13 / / ANALOG NUMBERING <nl> + # endif <nl> + <nl> + <nl> + # if TEMP_SENSOR_1 = = - 1 <nl> + # define TEMP_1_PIN 8 / / ANALOG NUMBERING <nl> + # else <nl> + # define TEMP_1_PIN 15 / / ANALOG NUMBERING <nl> + # endif <nl> + <nl> + # define TEMP_2_PIN - 1 / / ANALOG NUMBERING <nl> + <nl> + # define HEATER_BED_PIN 10 / / BED <nl> + <nl> + # if TEMP_SENSOR_BED = = - 1 <nl> + # define TEMP_BED_PIN 8 / / ANALOG NUMBERING <nl> + # else <nl> + # define TEMP_BED_PIN 14 / / ANALOG NUMBERING <nl> + # endif <nl> + <nl> + # define BEEPER 64 <nl> + <nl> + <nl> + # define LCD_PINS_RS 14 <nl> + # define LCD_PINS_ENABLE 15 <nl> + # define LCD_PINS_D4 30 <nl> + # define LCD_PINS_D5 31 <nl> + # define LCD_PINS_D6 32 <nl> + # define LCD_PINS_D7 33 <nl> + <nl> + <nl> + / / buttons are directly attached using keypad <nl> + # define BTN_EN1 61 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 43 / / the click <nl> + <nl> + # define BLEN_C 2 <nl> + # define BLEN_B 1 <nl> + # define BLEN_A 0 <nl> + <nl> + # define SDCARDDETECT - 1 / / Megatronics does not use this port <nl> + <nl> + / / encoder rotation values <nl> + # define encrot0 0 <nl> + # define encrot1 2 <nl> + # define encrot2 3 <nl> + # define encrot3 1 <nl> + <nl> + # endif <nl> + <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Minitronics v1 . 0 <nl> + * <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # if MOTHERBOARD = = 702 <nl> + # define KNOWN_BOARD 1 <nl> + <nl> + <nl> + # ifndef __AVR_ATmega1281__ <nl> + # error Oops ! Make sure you have ' Minitronics ' selected from the ' Tools - > Boards ' menu . <nl> + # endif <nl> + <nl> + # define LARGE_FLASH true <nl> + <nl> + # define X_STEP_PIN 48 <nl> + # define X_DIR_PIN 47 <nl> + # define X_ENABLE_PIN 49 <nl> + # define X_MIN_PIN 5 <nl> + # define X_MAX_PIN - 1 / / 2 / / Max endstops default to disabled " - 1 " , set to commented value to enable . <nl> + <nl> + # define Y_STEP_PIN 39 / / A6 <nl> + # define Y_DIR_PIN 40 / / A0 <nl> + # define Y_ENABLE_PIN 38 <nl> + # define Y_MIN_PIN 2 <nl> + # define Y_MAX_PIN - 1 / / 15 <nl> + <nl> + # define Z_STEP_PIN 42 / / A2 <nl> + # define Z_DIR_PIN 43 / / A6 <nl> + # define Z_ENABLE_PIN 41 / / A1 <nl> + # define Z_MIN_PIN 6 <nl> + # define Z_MAX_PIN - 1 <nl> + <nl> + # define E0_STEP_PIN 45 <nl> + # define E0_DIR_PIN 44 <nl> + # define E0_ENABLE_PIN 27 <nl> + <nl> + # define E1_STEP_PIN 36 <nl> + # define E1_DIR_PIN 35 <nl> + # define E1_ENABLE_PIN 37 <nl> + <nl> + # define E2_STEP_PIN - 1 <nl> + # define E2_DIR_PIN - 1 <nl> + # define E2_ENABLE_PIN - 1 <nl> + <nl> + # define SDPOWER - 1 <nl> + # define SDSS 16 <nl> + # define LED_PIN 46 <nl> + <nl> + # define FAN_PIN 9 <nl> + # define FAN2_PIN - 1 <nl> + # define PS_ON_PIN - 1 <nl> + # define KILL_PIN - 1 <nl> + <nl> + # define HEATER_0_PIN 7 / / EXTRUDER 1 <nl> + # define HEATER_1_PIN 8 / / EXTRUDER 2 <nl> + # define HEATER_2_PIN - 1 <nl> + <nl> + <nl> + # define TEMP_0_PIN 7 / / ANALOG NUMBERING <nl> + # define TEMP_1_PIN 6 / / ANALOG NUMBERING <nl> + # define TEMP_2_PIN - 1 / / ANALOG NUMBERING <nl> + <nl> + # define HEATER_BED_PIN 3 / / BED <nl> + # define TEMP_BED_PIN 6 / / ANALOG NUMBERING <nl> + <nl> + # define BEEPER - 1 <nl> + <nl> + <nl> + # define LCD_PINS_RS - 1 <nl> + # define LCD_PINS_ENABLE - 1 <nl> + # define LCD_PINS_D4 - 1 <nl> + # define LCD_PINS_D5 - 1 <nl> + # define LCD_PINS_D6 - 1 <nl> + # define LCD_PINS_D7 - 1 <nl> + <nl> + <nl> + / / buttons are directly attached using keypad <nl> + # define BTN_EN1 - 1 <nl> + # define BTN_EN2 - 1 <nl> + # define BTN_ENC - 1 / / the click <nl> + <nl> + # define BLEN_C 2 <nl> + # define BLEN_B 1 <nl> + # define BLEN_A 0 <nl> + <nl> + # define SDCARDDETECT - 1 / / Megatronics does not use this port <nl> + <nl> + / / encoder rotation values <nl> + # define encrot0 0 <nl> + # define encrot1 2 <nl> + # define encrot2 3 <nl> + # define encrot3 1 <nl> + <nl> + # endif <nl> + <nl> + <nl> + <nl> # ifndef KNOWN_BOARD <nl> # error Unknown MOTHERBOARD value in configuration . h <nl> # endif <nl>
Merge pull request from Gatulibu / Marlin_v1
MarlinFirmware/Marlin
a964b3cf3dc981b300ccce8933758331e948941e
2013-05-28T14:51:49Z
mmm a / tensorflow / core / kernels / cwise_ops . h <nl> ppp b / tensorflow / core / kernels / cwise_ops . h <nl> struct logical_not : base < bool , Eigen : : internal : : scalar_boolean_not_op < bool > > { <nl> / / NOTE : std : : isinf , std : : isnan , std : : isfinite are plain function . <nl> / / Therefore we need to wrap them in functors to be used with Eigen ' s <nl> / / type system . <nl> - <nl> template < typename T > <nl> - struct isinf_func { <nl> - typedef bool result_type ; <nl> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator ( ) ( T x ) const { <nl> - return Eigen : : numext : : isinf ( x ) ; <nl> - } <nl> - } ; <nl> + struct isinf : base < T , Eigen : : internal : : scalar_isinf_op < T > , bool > { } ; <nl> <nl> template < typename T > <nl> - struct isinf : base < T , isinf_func < T > , bool > { } ; <nl> + struct isnan : base < T , Eigen : : internal : : scalar_isnan_op < T > , bool > { } ; <nl> <nl> template < typename T > <nl> - struct isnan_func { <nl> - typedef bool result_type ; <nl> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator ( ) ( T x ) const { <nl> - return Eigen : : numext : : isnan ( x ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct isnan : base < T , isnan_func < T > , bool > { } ; <nl> - <nl> - template < typename T > <nl> - struct isfinite_func { <nl> - typedef bool result_type ; <nl> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator ( ) ( T x ) const { <nl> - return Eigen : : numext : : isfinite ( x ) ; <nl> - } <nl> - } ; <nl> + struct isfinite : base < T , Eigen : : internal : : scalar_isfinite_op < T > , bool > { } ; <nl> <nl> template < typename T > <nl> - struct isfinite : base < T , isfinite_func < T > , bool > { } ; <nl> - <nl> - template < typename T > <nl> - struct floor_func { <nl> - typedef T result_type ; <nl> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator ( ) ( T x ) const { <nl> - return Eigen : : numext : : floor ( x ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct floor : base < T , floor_func < T > > { } ; <nl> - <nl> - template < typename T > <nl> - struct ceil_func { <nl> - typedef T result_type ; <nl> - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator ( ) ( T x ) const { <nl> - return Eigen : : numext : : ceil ( x ) ; <nl> - } <nl> - } ; <nl> + struct floor : base < T , Eigen : : internal : : scalar_floor_op < T > > { } ; <nl> <nl> template < typename T > <nl> - struct ceil : base < T , ceil_func < T > > { } ; <nl> + struct ceil : base < T , Eigen : : internal : : scalar_ceil_op < T > > { } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Binary functors <nl> mmm a / tensorflow / core / util / tensor_slice_util . h <nl> ppp b / tensorflow / core / util / tensor_slice_util . h <nl> struct CopyThatWorksWithStringPointer < Eigen : : half > { <nl> d ( d_start [ 0 ] + i0 , d_start [ 1 ] + i1 , d_start [ 2 ] + i2 , <nl> d_start [ 3 ] + i3 , d_start [ 4 ] + i4 , d_start [ 5 ] + i5 , <nl> d_start [ 6 ] + i6 , d_start [ 7 ] + i7 ) = <nl> - Eigen : : internal : : raw_uint16_to_half ( <nl> + Eigen : : half_impl : : raw_uint16_to_half ( <nl> s ( s_start [ 0 ] + i0 , s_start [ 1 ] + i1 , s_start [ 2 ] + i2 , <nl> s_start [ 3 ] + i3 , s_start [ 4 ] + i4 , s_start [ 5 ] + i5 , <nl> s_start [ 6 ] + i6 , s_start [ 7 ] + i7 ) ) ; <nl> mmm a / tensorflow / python / kernel_tests / self_adjoint_eig_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / self_adjoint_eig_op_test . py <nl> def SortEigenDecomposition ( e , v ) : <nl> <nl> def _GetSelfAdjointEigTest ( dtype_ , shape_ ) : <nl> <nl> - def CompareEigenVectors ( self , x , y , atol ) : <nl> + def CompareEigenVectors ( self , x , y , tol ) : <nl> # Eigenvectors are only unique up to sign so we normalize the signs first . <nl> signs = np . sign ( np . sum ( np . divide ( x , y ) , - 2 , keepdims = True ) ) <nl> x * = signs <nl> - self . assertAllClose ( x , y , atol ) <nl> + self . assertAllClose ( x , y , atol = tol , rtol = tol ) <nl> <nl> - def CompareEigenDecompositions ( self , x_e , x_v , y_e , y_v , atol ) : <nl> + def CompareEigenDecompositions ( self , x_e , x_v , y_e , y_v , tol ) : <nl> num_batches = int ( np . prod ( x_e . shape [ : - 1 ] ) ) <nl> n = x_e . shape [ - 1 ] <nl> x_e = np . reshape ( x_e , [ num_batches ] + [ n ] ) <nl> def CompareEigenDecompositions ( self , x_e , x_v , y_e , y_v , atol ) : <nl> for i in range ( num_batches ) : <nl> x_ei , x_vi = SortEigenDecomposition ( x_e [ i , : ] , x_v [ i , : , : ] ) <nl> y_ei , y_vi = SortEigenDecomposition ( y_e [ i , : ] , y_v [ i , : , : ] ) <nl> - self . assertAllClose ( x_ei , y_ei , atol = atol ) <nl> - CompareEigenVectors ( self , x_vi , y_vi , atol ) <nl> + self . assertAllClose ( x_ei , y_ei , atol = tol , rtol = tol ) <nl> + CompareEigenVectors ( self , x_vi , y_vi , tol ) <nl> <nl> def Test ( self ) : <nl> np . random . seed ( 1 ) <nl> def Test ( self ) : <nl> if dtype_ = = np . float32 : <nl> atol = 1e - 4 <nl> else : <nl> - atol = 1e - 14 <nl> + atol = 1e - 12 <nl> for compute_v in False , True : <nl> np_e , np_v = np . linalg . eig ( a ) <nl> with self . test_session ( ) : <nl> mmm a / tensorflow / workspace . bzl <nl> ppp b / tensorflow / workspace . bzl <nl> def tf_workspace ( path_prefix = " " , tf_repo_name = " " ) : <nl> <nl> # These lines need to be changed when updating Eigen . They are parsed from <nl> # this file by the cmake and make builds to determine the eigen version and hash . <nl> - eigen_version = " b4fa9622b809 " <nl> - eigen_sha256 = " 2862840c2de9c0473a4ef20f8678949ae89ab25965352ee53329e63ba46cec62 " <nl> + eigen_version = " 6f952374ef2b " <nl> + eigen_sha256 = " 56d658324b09de3f418ae42ca0646dd1e6e0b897dd58b164ec0d21315764afd9 " <nl> <nl> native . new_http_archive ( <nl> name = " eigen_archive " , <nl>
Upgraded eigen to the latest version
tensorflow/tensorflow
0e12a0b0dbcf17da880402bc01d8511aa4568cda
2016-08-10T18:17:04Z
mmm a / 3rdparty / libwebp / src / dec / quant_dec . c <nl> ppp b / 3rdparty / libwebp / src / dec / quant_dec . c <nl> static const uint16_t kAcTable [ 128 ] = { <nl> <nl> void VP8ParseQuant ( VP8Decoder * const dec ) { <nl> VP8BitReader * const br = & dec - > br_ ; <nl> - const int base_q0 = VP8GetValue ( br , 7 ) ; <nl> - const int dqy1_dc = VP8Get ( br ) ? VP8GetSignedValue ( br , 4 ) : 0 ; <nl> - const int dqy2_dc = VP8Get ( br ) ? VP8GetSignedValue ( br , 4 ) : 0 ; <nl> - const int dqy2_ac = VP8Get ( br ) ? VP8GetSignedValue ( br , 4 ) : 0 ; <nl> - const int dquv_dc = VP8Get ( br ) ? VP8GetSignedValue ( br , 4 ) : 0 ; <nl> - const int dquv_ac = VP8Get ( br ) ? VP8GetSignedValue ( br , 4 ) : 0 ; <nl> + const int base_q0 = VP8GetValue ( br , 7 , " global - header " ) ; <nl> + const int dqy1_dc = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 4 , " global - header " ) : 0 ; <nl> + const int dqy2_dc = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 4 , " global - header " ) : 0 ; <nl> + const int dqy2_ac = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 4 , " global - header " ) : 0 ; <nl> + const int dquv_dc = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 4 , " global - header " ) : 0 ; <nl> + const int dquv_ac = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 4 , " global - header " ) : 0 ; <nl> <nl> const VP8SegmentHeader * const hdr = & dec - > segment_hdr_ ; <nl> int i ; <nl> mmm a / 3rdparty / libwebp / src / dec / tree_dec . c <nl> ppp b / 3rdparty / libwebp / src / dec / tree_dec . c <nl> static void ParseIntraMode ( VP8BitReader * const br , <nl> / / to decode more than 1 keyframe . <nl> if ( dec - > segment_hdr_ . update_map_ ) { <nl> / / Hardcoded tree parsing <nl> - block - > segment_ = ! VP8GetBit ( br , dec - > proba_ . segments_ [ 0 ] ) <nl> - ? VP8GetBit ( br , dec - > proba_ . segments_ [ 1 ] ) <nl> - : 2 + VP8GetBit ( br , dec - > proba_ . segments_ [ 2 ] ) ; <nl> + block - > segment_ = ! VP8GetBit ( br , dec - > proba_ . segments_ [ 0 ] , " segments " ) <nl> + ? VP8GetBit ( br , dec - > proba_ . segments_ [ 1 ] , " segments " ) <nl> + : VP8GetBit ( br , dec - > proba_ . segments_ [ 2 ] , " segments " ) + 2 ; <nl> } else { <nl> block - > segment_ = 0 ; / / default for intra <nl> } <nl> - if ( dec - > use_skip_proba_ ) block - > skip_ = VP8GetBit ( br , dec - > skip_p_ ) ; <nl> + if ( dec - > use_skip_proba_ ) block - > skip_ = VP8GetBit ( br , dec - > skip_p_ , " skip " ) ; <nl> <nl> - block - > is_i4x4_ = ! VP8GetBit ( br , 145 ) ; / / decide for B_PRED first <nl> + block - > is_i4x4_ = ! VP8GetBit ( br , 145 , " block - size " ) ; <nl> if ( ! block - > is_i4x4_ ) { <nl> / / Hardcoded 16x16 intra - mode decision tree . <nl> const int ymode = <nl> - VP8GetBit ( br , 156 ) ? ( VP8GetBit ( br , 128 ) ? TM_PRED : H_PRED ) <nl> - : ( VP8GetBit ( br , 163 ) ? V_PRED : DC_PRED ) ; <nl> + VP8GetBit ( br , 156 , " pred - modes " ) ? <nl> + ( VP8GetBit ( br , 128 , " pred - modes " ) ? TM_PRED : H_PRED ) : <nl> + ( VP8GetBit ( br , 163 , " pred - modes " ) ? V_PRED : DC_PRED ) ; <nl> block - > imodes_ [ 0 ] = ymode ; <nl> memset ( top , ymode , 4 * sizeof ( * top ) ) ; <nl> memset ( left , ymode , 4 * sizeof ( * left ) ) ; <nl> static void ParseIntraMode ( VP8BitReader * const br , <nl> const uint8_t * const prob = kBModesProba [ top [ x ] ] [ ymode ] ; <nl> # if ( USE_GENERIC_TREE = = 1 ) <nl> / / Generic tree - parsing <nl> - int i = kYModesIntra4 [ VP8GetBit ( br , prob [ 0 ] ) ] ; <nl> + int i = kYModesIntra4 [ VP8GetBit ( br , prob [ 0 ] , " pred - modes " ) ] ; <nl> while ( i > 0 ) { <nl> - i = kYModesIntra4 [ 2 * i + VP8GetBit ( br , prob [ i ] ) ] ; <nl> + i = kYModesIntra4 [ 2 * i + VP8GetBit ( br , prob [ i ] , " pred - modes " ) ] ; <nl> } <nl> ymode = - i ; <nl> # else <nl> / / Hardcoded tree parsing <nl> - ymode = ! VP8GetBit ( br , prob [ 0 ] ) ? B_DC_PRED : <nl> - ! VP8GetBit ( br , prob [ 1 ] ) ? B_TM_PRED : <nl> - ! VP8GetBit ( br , prob [ 2 ] ) ? B_VE_PRED : <nl> - ! VP8GetBit ( br , prob [ 3 ] ) ? <nl> - ( ! VP8GetBit ( br , prob [ 4 ] ) ? B_HE_PRED : <nl> - ( ! VP8GetBit ( br , prob [ 5 ] ) ? B_RD_PRED : B_VR_PRED ) ) : <nl> - ( ! VP8GetBit ( br , prob [ 6 ] ) ? B_LD_PRED : <nl> - ( ! VP8GetBit ( br , prob [ 7 ] ) ? B_VL_PRED : <nl> - ( ! VP8GetBit ( br , prob [ 8 ] ) ? B_HD_PRED : B_HU_PRED ) ) ) ; <nl> + ymode = ! VP8GetBit ( br , prob [ 0 ] , " pred - modes " ) ? B_DC_PRED : <nl> + ! VP8GetBit ( br , prob [ 1 ] , " pred - modes " ) ? B_TM_PRED : <nl> + ! VP8GetBit ( br , prob [ 2 ] , " pred - modes " ) ? B_VE_PRED : <nl> + ! VP8GetBit ( br , prob [ 3 ] , " pred - modes " ) ? <nl> + ( ! VP8GetBit ( br , prob [ 4 ] , " pred - modes " ) ? B_HE_PRED : <nl> + ( ! VP8GetBit ( br , prob [ 5 ] , " pred - modes " ) ? B_RD_PRED <nl> + : B_VR_PRED ) ) : <nl> + ( ! VP8GetBit ( br , prob [ 6 ] , " pred - modes " ) ? B_LD_PRED : <nl> + ( ! VP8GetBit ( br , prob [ 7 ] , " pred - modes " ) ? B_VL_PRED : <nl> + ( ! VP8GetBit ( br , prob [ 8 ] , " pred - modes " ) ? B_HD_PRED <nl> + : B_HU_PRED ) ) <nl> + ) ; <nl> # endif / / USE_GENERIC_TREE <nl> top [ x ] = ymode ; <nl> } <nl> static void ParseIntraMode ( VP8BitReader * const br , <nl> } <nl> } <nl> / / Hardcoded UVMode decision tree <nl> - block - > uvmode_ = ! VP8GetBit ( br , 142 ) ? DC_PRED <nl> - : ! VP8GetBit ( br , 114 ) ? V_PRED <nl> - : VP8GetBit ( br , 183 ) ? TM_PRED : H_PRED ; <nl> + block - > uvmode_ = ! VP8GetBit ( br , 142 , " pred - modes - uv " ) ? DC_PRED <nl> + : ! VP8GetBit ( br , 114 , " pred - modes - uv " ) ? V_PRED <nl> + : VP8GetBit ( br , 183 , " pred - modes - uv " ) ? TM_PRED : H_PRED ; <nl> } <nl> <nl> int VP8ParseIntraModeRow ( VP8BitReader * const br , VP8Decoder * const dec ) { <nl> void VP8ParseProba ( VP8BitReader * const br , VP8Decoder * const dec ) { <nl> for ( b = 0 ; b < NUM_BANDS ; + + b ) { <nl> for ( c = 0 ; c < NUM_CTX ; + + c ) { <nl> for ( p = 0 ; p < NUM_PROBAS ; + + p ) { <nl> - const int v = VP8GetBit ( br , CoeffsUpdateProba [ t ] [ b ] [ c ] [ p ] ) ? <nl> - VP8GetValue ( br , 8 ) : CoeffsProba0 [ t ] [ b ] [ c ] [ p ] ; <nl> + const int v = <nl> + VP8GetBit ( br , CoeffsUpdateProba [ t ] [ b ] [ c ] [ p ] , " global - header " ) ? <nl> + VP8GetValue ( br , 8 , " global - header " ) : <nl> + CoeffsProba0 [ t ] [ b ] [ c ] [ p ] ; <nl> proba - > bands_ [ t ] [ b ] . probas_ [ c ] [ p ] = v ; <nl> } <nl> } <nl> void VP8ParseProba ( VP8BitReader * const br , VP8Decoder * const dec ) { <nl> proba - > bands_ptr_ [ t ] [ b ] = & proba - > bands_ [ t ] [ kBands [ b ] ] ; <nl> } <nl> } <nl> - dec - > use_skip_proba_ = VP8Get ( br ) ; <nl> + dec - > use_skip_proba_ = VP8Get ( br , " global - header " ) ; <nl> if ( dec - > use_skip_proba_ ) { <nl> - dec - > skip_p_ = VP8GetValue ( br , 8 ) ; <nl> + dec - > skip_p_ = VP8GetValue ( br , 8 , " global - header " ) ; <nl> } <nl> } <nl> - <nl> mmm a / 3rdparty / libwebp / src / dec / vp8_dec . c <nl> ppp b / 3rdparty / libwebp / src / dec / vp8_dec . c <nl> static int ParseSegmentHeader ( VP8BitReader * br , <nl> VP8SegmentHeader * hdr , VP8Proba * proba ) { <nl> assert ( br ! = NULL ) ; <nl> assert ( hdr ! = NULL ) ; <nl> - hdr - > use_segment_ = VP8Get ( br ) ; <nl> + hdr - > use_segment_ = VP8Get ( br , " global - header " ) ; <nl> if ( hdr - > use_segment_ ) { <nl> - hdr - > update_map_ = VP8Get ( br ) ; <nl> - if ( VP8Get ( br ) ) { / / update data <nl> + hdr - > update_map_ = VP8Get ( br , " global - header " ) ; <nl> + if ( VP8Get ( br , " global - header " ) ) { / / update data <nl> int s ; <nl> - hdr - > absolute_delta_ = VP8Get ( br ) ; <nl> + hdr - > absolute_delta_ = VP8Get ( br , " global - header " ) ; <nl> for ( s = 0 ; s < NUM_MB_SEGMENTS ; + + s ) { <nl> - hdr - > quantizer_ [ s ] = VP8Get ( br ) ? VP8GetSignedValue ( br , 7 ) : 0 ; <nl> + hdr - > quantizer_ [ s ] = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 7 , " global - header " ) : 0 ; <nl> } <nl> for ( s = 0 ; s < NUM_MB_SEGMENTS ; + + s ) { <nl> - hdr - > filter_strength_ [ s ] = VP8Get ( br ) ? VP8GetSignedValue ( br , 6 ) : 0 ; <nl> + hdr - > filter_strength_ [ s ] = VP8Get ( br , " global - header " ) ? <nl> + VP8GetSignedValue ( br , 6 , " global - header " ) : 0 ; <nl> } <nl> } <nl> if ( hdr - > update_map_ ) { <nl> int s ; <nl> for ( s = 0 ; s < MB_FEATURE_TREE_PROBS ; + + s ) { <nl> - proba - > segments_ [ s ] = VP8Get ( br ) ? VP8GetValue ( br , 8 ) : 255u ; <nl> + proba - > segments_ [ s ] = VP8Get ( br , " global - header " ) ? <nl> + VP8GetValue ( br , 8 , " global - header " ) : 255u ; <nl> } <nl> } <nl> } else { <nl> static VP8StatusCode ParsePartitions ( VP8Decoder * const dec , <nl> size_t last_part ; <nl> size_t p ; <nl> <nl> - dec - > num_parts_minus_one_ = ( 1 < < VP8GetValue ( br , 2 ) ) - 1 ; <nl> + dec - > num_parts_minus_one_ = ( 1 < < VP8GetValue ( br , 2 , " global - header " ) ) - 1 ; <nl> last_part = dec - > num_parts_minus_one_ ; <nl> if ( size < 3 * last_part ) { <nl> / / we can ' t even read the sizes with sz [ ] ! That ' s a failure . <nl> static VP8StatusCode ParsePartitions ( VP8Decoder * const dec , <nl> / / Paragraph 9 . 4 <nl> static int ParseFilterHeader ( VP8BitReader * br , VP8Decoder * const dec ) { <nl> VP8FilterHeader * const hdr = & dec - > filter_hdr_ ; <nl> - hdr - > simple_ = VP8Get ( br ) ; <nl> - hdr - > level_ = VP8GetValue ( br , 6 ) ; <nl> - hdr - > sharpness_ = VP8GetValue ( br , 3 ) ; <nl> - hdr - > use_lf_delta_ = VP8Get ( br ) ; <nl> + hdr - > simple_ = VP8Get ( br , " global - header " ) ; <nl> + hdr - > level_ = VP8GetValue ( br , 6 , " global - header " ) ; <nl> + hdr - > sharpness_ = VP8GetValue ( br , 3 , " global - header " ) ; <nl> + hdr - > use_lf_delta_ = VP8Get ( br , " global - header " ) ; <nl> if ( hdr - > use_lf_delta_ ) { <nl> - if ( VP8Get ( br ) ) { / / update lf - delta ? <nl> + if ( VP8Get ( br , " global - header " ) ) { / / update lf - delta ? <nl> int i ; <nl> for ( i = 0 ; i < NUM_REF_LF_DELTAS ; + + i ) { <nl> - if ( VP8Get ( br ) ) { <nl> - hdr - > ref_lf_delta_ [ i ] = VP8GetSignedValue ( br , 6 ) ; <nl> + if ( VP8Get ( br , " global - header " ) ) { <nl> + hdr - > ref_lf_delta_ [ i ] = VP8GetSignedValue ( br , 6 , " global - header " ) ; <nl> } <nl> } <nl> for ( i = 0 ; i < NUM_MODE_LF_DELTAS ; + + i ) { <nl> - if ( VP8Get ( br ) ) { <nl> - hdr - > mode_lf_delta_ [ i ] = VP8GetSignedValue ( br , 6 ) ; <nl> + if ( VP8Get ( br , " global - header " ) ) { <nl> + hdr - > mode_lf_delta_ [ i ] = VP8GetSignedValue ( br , 6 , " global - header " ) ; <nl> } <nl> } <nl> } <nl> int VP8GetHeaders ( VP8Decoder * const dec , VP8Io * const io ) { <nl> buf_size - = frm_hdr - > partition_length_ ; <nl> <nl> if ( frm_hdr - > key_frame_ ) { <nl> - pic_hdr - > colorspace_ = VP8Get ( br ) ; <nl> - pic_hdr - > clamp_type_ = VP8Get ( br ) ; <nl> + pic_hdr - > colorspace_ = VP8Get ( br , " global - header " ) ; <nl> + pic_hdr - > clamp_type_ = VP8Get ( br , " global - header " ) ; <nl> } <nl> if ( ! ParseSegmentHeader ( br , & dec - > segment_hdr_ , & dec - > proba_ ) ) { <nl> return VP8SetError ( dec , VP8_STATUS_BITSTREAM_ERROR , <nl> int VP8GetHeaders ( VP8Decoder * const dec , VP8Io * const io ) { <nl> " Not a key frame . " ) ; <nl> } <nl> <nl> - VP8Get ( br ) ; / / ignore the value of update_proba_ <nl> + VP8Get ( br , " global - header " ) ; / / ignore the value of update_proba_ <nl> <nl> VP8ParseProba ( br , dec ) ; <nl> <nl> static const uint8_t kZigzag [ 16 ] = { <nl> / / See section 13 - 2 : http : / / tools . ietf . org / html / rfc6386 # section - 13 . 2 <nl> static int GetLargeValue ( VP8BitReader * const br , const uint8_t * const p ) { <nl> int v ; <nl> - if ( ! VP8GetBit ( br , p [ 3 ] ) ) { <nl> - if ( ! VP8GetBit ( br , p [ 4 ] ) ) { <nl> + if ( ! VP8GetBit ( br , p [ 3 ] , " coeffs " ) ) { <nl> + if ( ! VP8GetBit ( br , p [ 4 ] , " coeffs " ) ) { <nl> v = 2 ; <nl> } else { <nl> - v = 3 + VP8GetBit ( br , p [ 5 ] ) ; <nl> + v = 3 + VP8GetBit ( br , p [ 5 ] , " coeffs " ) ; <nl> } <nl> } else { <nl> - if ( ! VP8GetBit ( br , p [ 6 ] ) ) { <nl> - if ( ! VP8GetBit ( br , p [ 7 ] ) ) { <nl> - v = 5 + VP8GetBit ( br , 159 ) ; <nl> + if ( ! VP8GetBit ( br , p [ 6 ] , " coeffs " ) ) { <nl> + if ( ! VP8GetBit ( br , p [ 7 ] , " coeffs " ) ) { <nl> + v = 5 + VP8GetBit ( br , 159 , " coeffs " ) ; <nl> } else { <nl> - v = 7 + 2 * VP8GetBit ( br , 165 ) ; <nl> - v + = VP8GetBit ( br , 145 ) ; <nl> + v = 7 + 2 * VP8GetBit ( br , 165 , " coeffs " ) ; <nl> + v + = VP8GetBit ( br , 145 , " coeffs " ) ; <nl> } <nl> } else { <nl> const uint8_t * tab ; <nl> - const int bit1 = VP8GetBit ( br , p [ 8 ] ) ; <nl> - const int bit0 = VP8GetBit ( br , p [ 9 + bit1 ] ) ; <nl> + const int bit1 = VP8GetBit ( br , p [ 8 ] , " coeffs " ) ; <nl> + const int bit0 = VP8GetBit ( br , p [ 9 + bit1 ] , " coeffs " ) ; <nl> const int cat = 2 * bit1 + bit0 ; <nl> v = 0 ; <nl> for ( tab = kCat3456 [ cat ] ; * tab ; + + tab ) { <nl> - v + = v + VP8GetBit ( br , * tab ) ; <nl> + v + = v + VP8GetBit ( br , * tab , " coeffs " ) ; <nl> } <nl> v + = 3 + ( 8 < < cat ) ; <nl> } <nl> static int GetCoeffsFast ( VP8BitReader * const br , <nl> int ctx , const quant_t dq , int n , int16_t * out ) { <nl> const uint8_t * p = prob [ n ] - > probas_ [ ctx ] ; <nl> for ( ; n < 16 ; + + n ) { <nl> - if ( ! VP8GetBit ( br , p [ 0 ] ) ) { <nl> + if ( ! VP8GetBit ( br , p [ 0 ] , " coeffs " ) ) { <nl> return n ; / / previous coeff was last non - zero coeff <nl> } <nl> - while ( ! VP8GetBit ( br , p [ 1 ] ) ) { / / sequence of zero coeffs <nl> + while ( ! VP8GetBit ( br , p [ 1 ] , " coeffs " ) ) { / / sequence of zero coeffs <nl> p = prob [ + + n ] - > probas_ [ 0 ] ; <nl> if ( n = = 16 ) return 16 ; <nl> } <nl> { / / non zero coeff <nl> const VP8ProbaArray * const p_ctx = & prob [ n + 1 ] - > probas_ [ 0 ] ; <nl> int v ; <nl> - if ( ! VP8GetBit ( br , p [ 2 ] ) ) { <nl> + if ( ! VP8GetBit ( br , p [ 2 ] , " coeffs " ) ) { <nl> v = 1 ; <nl> p = p_ctx [ 1 ] ; <nl> } else { <nl> v = GetLargeValue ( br , p ) ; <nl> p = p_ctx [ 2 ] ; <nl> } <nl> - out [ kZigzag [ n ] ] = VP8GetSigned ( br , v ) * dq [ n > 0 ] ; <nl> + out [ kZigzag [ n ] ] = VP8GetSigned ( br , v , " coeffs " ) * dq [ n > 0 ] ; <nl> } <nl> } <nl> return 16 ; <nl> static int GetCoeffsAlt ( VP8BitReader * const br , <nl> int ctx , const quant_t dq , int n , int16_t * out ) { <nl> const uint8_t * p = prob [ n ] - > probas_ [ ctx ] ; <nl> for ( ; n < 16 ; + + n ) { <nl> - if ( ! VP8GetBitAlt ( br , p [ 0 ] ) ) { <nl> + if ( ! VP8GetBitAlt ( br , p [ 0 ] , " coeffs " ) ) { <nl> return n ; / / previous coeff was last non - zero coeff <nl> } <nl> - while ( ! VP8GetBitAlt ( br , p [ 1 ] ) ) { / / sequence of zero coeffs <nl> + while ( ! VP8GetBitAlt ( br , p [ 1 ] , " coeffs " ) ) { / / sequence of zero coeffs <nl> p = prob [ + + n ] - > probas_ [ 0 ] ; <nl> if ( n = = 16 ) return 16 ; <nl> } <nl> { / / non zero coeff <nl> const VP8ProbaArray * const p_ctx = & prob [ n + 1 ] - > probas_ [ 0 ] ; <nl> int v ; <nl> - if ( ! VP8GetBitAlt ( br , p [ 2 ] ) ) { <nl> + if ( ! VP8GetBitAlt ( br , p [ 2 ] , " coeffs " ) ) { <nl> v = 1 ; <nl> p = p_ctx [ 1 ] ; <nl> } else { <nl> v = GetLargeValue ( br , p ) ; <nl> p = p_ctx [ 2 ] ; <nl> } <nl> - out [ kZigzag [ n ] ] = VP8GetSigned ( br , v ) * dq [ n > 0 ] ; <nl> + out [ kZigzag [ n ] ] = VP8GetSigned ( br , v , " coeffs " ) * dq [ n > 0 ] ; <nl> } <nl> } <nl> return 16 ; <nl> mmm a / 3rdparty / libwebp / src / dec / vp8i_dec . h <nl> ppp b / 3rdparty / libwebp / src / dec / vp8i_dec . h <nl> extern " C " { <nl> / / version numbers <nl> # define DEC_MAJ_VERSION 1 <nl> # define DEC_MIN_VERSION 0 <nl> - # define DEC_REV_VERSION 2 <nl> + # define DEC_REV_VERSION 3 <nl> <nl> / / YUV - cache parameters . Cache is 32 - bytes wide ( = one cacheline ) . <nl> / / Constraints are : We need to store one 16x16 block of luma samples ( y ) , <nl> mmm a / 3rdparty / libwebp / src / dec / vp8l_dec . c <nl> ppp b / 3rdparty / libwebp / src / dec / vp8l_dec . c <nl> static int ReadHuffmanCodes ( VP8LDecoder * const dec , int xsize , int ysize , <nl> VP8LMetadata * const hdr = & dec - > hdr_ ; <nl> uint32_t * huffman_image = NULL ; <nl> HTreeGroup * htree_groups = NULL ; <nl> - / / When reading htrees , some might be unused , as the format allows it . <nl> - / / We will still read them but put them in this htree_group_bogus . <nl> - HTreeGroup htree_group_bogus ; <nl> HuffmanCode * huffman_tables = NULL ; <nl> - HuffmanCode * huffman_tables_bogus = NULL ; <nl> - HuffmanCode * next = NULL ; <nl> + HuffmanCode * huffman_table = NULL ; <nl> int num_htree_groups = 1 ; <nl> int num_htree_groups_max = 1 ; <nl> int max_alphabet_size = 0 ; <nl> static int ReadHuffmanCodes ( VP8LDecoder * const dec , int xsize , int ysize , <nl> if ( * mapped_group = = - 1 ) * mapped_group = num_htree_groups + + ; <nl> huffman_image [ i ] = * mapped_group ; <nl> } <nl> - huffman_tables_bogus = ( HuffmanCode * ) WebPSafeMalloc ( <nl> - table_size , sizeof ( * huffman_tables_bogus ) ) ; <nl> - if ( huffman_tables_bogus = = NULL ) { <nl> - dec - > status_ = VP8_STATUS_OUT_OF_MEMORY ; <nl> - goto Error ; <nl> - } <nl> } else { <nl> num_htree_groups = num_htree_groups_max ; <nl> } <nl> static int ReadHuffmanCodes ( VP8LDecoder * const dec , int xsize , int ysize , <nl> goto Error ; <nl> } <nl> <nl> - next = huffman_tables ; <nl> + huffman_table = huffman_tables ; <nl> for ( i = 0 ; i < num_htree_groups_max ; + + i ) { <nl> - / / If the index " i " is unused in the Huffman image , read the coefficients <nl> - / / but store them to a bogus htree_group . <nl> - const int is_bogus = ( mapping ! = NULL & & mapping [ i ] = = - 1 ) ; <nl> - HTreeGroup * const htree_group = <nl> - is_bogus ? & htree_group_bogus : <nl> - & htree_groups [ ( mapping = = NULL ) ? i : mapping [ i ] ] ; <nl> - HuffmanCode * * const htrees = htree_group - > htrees ; <nl> - HuffmanCode * huffman_tables_i = is_bogus ? huffman_tables_bogus : next ; <nl> - int size ; <nl> - int total_size = 0 ; <nl> - int is_trivial_literal = 1 ; <nl> - int max_bits = 0 ; <nl> - for ( j = 0 ; j < HUFFMAN_CODES_PER_META_CODE ; + + j ) { <nl> - int alphabet_size = kAlphabetSize [ j ] ; <nl> - htrees [ j ] = huffman_tables_i ; <nl> - if ( j = = 0 & & color_cache_bits > 0 ) { <nl> - alphabet_size + = 1 < < color_cache_bits ; <nl> - } <nl> - size = <nl> - ReadHuffmanCode ( alphabet_size , dec , code_lengths , huffman_tables_i ) ; <nl> - if ( size = = 0 ) { <nl> - goto Error ; <nl> - } <nl> - if ( is_trivial_literal & & kLiteralMap [ j ] = = 1 ) { <nl> - is_trivial_literal = ( huffman_tables_i - > bits = = 0 ) ; <nl> + / / If the index " i " is unused in the Huffman image , just make sure the <nl> + / / coefficients are valid but do not store them . <nl> + if ( mapping ! = NULL & & mapping [ i ] = = - 1 ) { <nl> + for ( j = 0 ; j < HUFFMAN_CODES_PER_META_CODE ; + + j ) { <nl> + int alphabet_size = kAlphabetSize [ j ] ; <nl> + if ( j = = 0 & & color_cache_bits > 0 ) { <nl> + alphabet_size + = ( 1 < < color_cache_bits ) ; <nl> + } <nl> + / / Passing in NULL so that nothing gets filled . <nl> + if ( ! ReadHuffmanCode ( alphabet_size , dec , code_lengths , NULL ) ) { <nl> + goto Error ; <nl> + } <nl> } <nl> - total_size + = huffman_tables_i - > bits ; <nl> - huffman_tables_i + = size ; <nl> - if ( j < = ALPHA ) { <nl> - int local_max_bits = code_lengths [ 0 ] ; <nl> - int k ; <nl> - for ( k = 1 ; k < alphabet_size ; + + k ) { <nl> - if ( code_lengths [ k ] > local_max_bits ) { <nl> - local_max_bits = code_lengths [ k ] ; <nl> + } else { <nl> + HTreeGroup * const htree_group = <nl> + & htree_groups [ ( mapping = = NULL ) ? i : mapping [ i ] ] ; <nl> + HuffmanCode * * const htrees = htree_group - > htrees ; <nl> + int size ; <nl> + int total_size = 0 ; <nl> + int is_trivial_literal = 1 ; <nl> + int max_bits = 0 ; <nl> + for ( j = 0 ; j < HUFFMAN_CODES_PER_META_CODE ; + + j ) { <nl> + int alphabet_size = kAlphabetSize [ j ] ; <nl> + htrees [ j ] = huffman_table ; <nl> + if ( j = = 0 & & color_cache_bits > 0 ) { <nl> + alphabet_size + = ( 1 < < color_cache_bits ) ; <nl> + } <nl> + size = ReadHuffmanCode ( alphabet_size , dec , code_lengths , huffman_table ) ; <nl> + if ( size = = 0 ) { <nl> + goto Error ; <nl> + } <nl> + if ( is_trivial_literal & & kLiteralMap [ j ] = = 1 ) { <nl> + is_trivial_literal = ( huffman_table - > bits = = 0 ) ; <nl> + } <nl> + total_size + = huffman_table - > bits ; <nl> + huffman_table + = size ; <nl> + if ( j < = ALPHA ) { <nl> + int local_max_bits = code_lengths [ 0 ] ; <nl> + int k ; <nl> + for ( k = 1 ; k < alphabet_size ; + + k ) { <nl> + if ( code_lengths [ k ] > local_max_bits ) { <nl> + local_max_bits = code_lengths [ k ] ; <nl> + } <nl> } <nl> + max_bits + = local_max_bits ; <nl> } <nl> - max_bits + = local_max_bits ; <nl> } <nl> - } <nl> - if ( ! is_bogus ) next = huffman_tables_i ; <nl> - htree_group - > is_trivial_literal = is_trivial_literal ; <nl> - htree_group - > is_trivial_code = 0 ; <nl> - if ( is_trivial_literal ) { <nl> - const int red = htrees [ RED ] [ 0 ] . value ; <nl> - const int blue = htrees [ BLUE ] [ 0 ] . value ; <nl> - const int alpha = htrees [ ALPHA ] [ 0 ] . value ; <nl> - htree_group - > literal_arb = ( ( uint32_t ) alpha < < 24 ) | ( red < < 16 ) | blue ; <nl> - if ( total_size = = 0 & & htrees [ GREEN ] [ 0 ] . value < NUM_LITERAL_CODES ) { <nl> - htree_group - > is_trivial_code = 1 ; <nl> - htree_group - > literal_arb | = htrees [ GREEN ] [ 0 ] . value < < 8 ; <nl> + htree_group - > is_trivial_literal = is_trivial_literal ; <nl> + htree_group - > is_trivial_code = 0 ; <nl> + if ( is_trivial_literal ) { <nl> + const int red = htrees [ RED ] [ 0 ] . value ; <nl> + const int blue = htrees [ BLUE ] [ 0 ] . value ; <nl> + const int alpha = htrees [ ALPHA ] [ 0 ] . value ; <nl> + htree_group - > literal_arb = ( ( uint32_t ) alpha < < 24 ) | ( red < < 16 ) | blue ; <nl> + if ( total_size = = 0 & & htrees [ GREEN ] [ 0 ] . value < NUM_LITERAL_CODES ) { <nl> + htree_group - > is_trivial_code = 1 ; <nl> + htree_group - > literal_arb | = htrees [ GREEN ] [ 0 ] . value < < 8 ; <nl> + } <nl> } <nl> + htree_group - > use_packed_table = <nl> + ! htree_group - > is_trivial_code & & ( max_bits < HUFFMAN_PACKED_BITS ) ; <nl> + if ( htree_group - > use_packed_table ) BuildPackedTable ( htree_group ) ; <nl> } <nl> - htree_group - > use_packed_table = <nl> - ! htree_group - > is_trivial_code & & ( max_bits < HUFFMAN_PACKED_BITS ) ; <nl> - if ( htree_group - > use_packed_table ) BuildPackedTable ( htree_group ) ; <nl> } <nl> ok = 1 ; <nl> <nl> static int ReadHuffmanCodes ( VP8LDecoder * const dec , int xsize , int ysize , <nl> <nl> Error : <nl> WebPSafeFree ( code_lengths ) ; <nl> - WebPSafeFree ( huffman_tables_bogus ) ; <nl> WebPSafeFree ( mapping ) ; <nl> if ( ! ok ) { <nl> WebPSafeFree ( huffman_image ) ; <nl> mmm a / 3rdparty / libwebp / src / demux / demux . c <nl> ppp b / 3rdparty / libwebp / src / demux / demux . c <nl> <nl> <nl> # define DMUX_MAJ_VERSION 1 <nl> # define DMUX_MIN_VERSION 0 <nl> - # define DMUX_REV_VERSION 2 <nl> + # define DMUX_REV_VERSION 3 <nl> <nl> typedef struct { <nl> size_t start_ ; / / start location of the data <nl> mmm a / 3rdparty / libwebp / src / dsp / alpha_processing_sse2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / alpha_processing_sse2 . c <nl> static void ApplyAlphaMultiply_SSE2 ( uint8_t * rgba , int alpha_first , <nl> / / Alpha detection <nl> <nl> static int HasAlpha8b_SSE2 ( const uint8_t * src , int length ) { <nl> - const __m128i all_0xff = _mm_set1_epi8 ( 0xff ) ; <nl> + const __m128i all_0xff = _mm_set1_epi8 ( ( char ) 0xff ) ; <nl> int i = 0 ; <nl> for ( ; i + 16 < = length ; i + = 16 ) { <nl> const __m128i v = _mm_loadu_si128 ( ( const __m128i * ) ( src + i ) ) ; <nl> static int HasAlpha8b_SSE2 ( const uint8_t * src , int length ) { <nl> <nl> static int HasAlpha32b_SSE2 ( const uint8_t * src , int length ) { <nl> const __m128i alpha_mask = _mm_set1_epi32 ( 0xff ) ; <nl> - const __m128i all_0xff = _mm_set1_epi8 ( 0xff ) ; <nl> + const __m128i all_0xff = _mm_set1_epi8 ( ( char ) 0xff ) ; <nl> int i = 0 ; <nl> / / We don ' t know if we can access the last 3 bytes after the last alpha <nl> / / value ' src [ 4 * length - 4 ] ' ( because we don ' t know if alpha is the first <nl> mmm a / 3rdparty / libwebp / src / dsp / cpu . c <nl> ppp b / 3rdparty / libwebp / src / dsp / cpu . c <nl> static int AndroidCPUInfo ( CPUFeature feature ) { <nl> const AndroidCpuFamily cpu_family = android_getCpuFamily ( ) ; <nl> const uint64_t cpu_features = android_getCpuFeatures ( ) ; <nl> if ( feature = = kNEON ) { <nl> - return ( cpu_family = = ANDROID_CPU_FAMILY_ARM & & <nl> - 0 ! = ( cpu_features & ANDROID_CPU_ARM_FEATURE_NEON ) ) ; <nl> + return cpu_family = = ANDROID_CPU_FAMILY_ARM & & <nl> + ( cpu_features & ANDROID_CPU_ARM_FEATURE_NEON ) ! = 0 ; <nl> } <nl> return 0 ; <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / dec_sse2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / dec_sse2 . c <nl> static WEBP_INLINE void Update2Pixels_SSE2 ( __m128i * const pi , __m128i * const qi , <nl> const __m128i a1_lo = _mm_srai_epi16 ( * a0_lo , 7 ) ; <nl> const __m128i a1_hi = _mm_srai_epi16 ( * a0_hi , 7 ) ; <nl> const __m128i delta = _mm_packs_epi16 ( a1_lo , a1_hi ) ; <nl> - const __m128i sign_bit = _mm_set1_epi8 ( 0x80 ) ; <nl> + const __m128i sign_bit = _mm_set1_epi8 ( ( char ) 0x80 ) ; <nl> * pi = _mm_adds_epi8 ( * pi , delta ) ; <nl> * qi = _mm_subs_epi8 ( * qi , delta ) ; <nl> FLIP_SIGN_BIT2 ( * pi , * qi ) ; <nl> static WEBP_INLINE void NeedsFilter_SSE2 ( const __m128i * const p1 , <nl> const __m128i * const q0 , <nl> const __m128i * const q1 , <nl> int thresh , __m128i * const mask ) { <nl> - const __m128i m_thresh = _mm_set1_epi8 ( thresh ) ; <nl> + const __m128i m_thresh = _mm_set1_epi8 ( ( char ) thresh ) ; <nl> const __m128i t1 = MM_ABS ( * p1 , * q1 ) ; / / abs ( p1 - q1 ) <nl> - const __m128i kFE = _mm_set1_epi8 ( 0xFE ) ; <nl> + const __m128i kFE = _mm_set1_epi8 ( ( char ) 0xFE ) ; <nl> const __m128i t2 = _mm_and_si128 ( t1 , kFE ) ; / / set lsb of each byte to zero <nl> const __m128i t3 = _mm_srli_epi16 ( t2 , 1 ) ; / / abs ( p1 - q1 ) / 2 <nl> <nl> static WEBP_INLINE void DoFilter2_SSE2 ( __m128i * const p1 , __m128i * const p0 , <nl> __m128i * const q0 , __m128i * const q1 , <nl> int thresh ) { <nl> __m128i a , mask ; <nl> - const __m128i sign_bit = _mm_set1_epi8 ( 0x80 ) ; <nl> + const __m128i sign_bit = _mm_set1_epi8 ( ( char ) 0x80 ) ; <nl> / / convert p1 / q1 to int8_t ( for GetBaseDelta_SSE2 ) <nl> const __m128i p1s = _mm_xor_si128 ( * p1 , sign_bit ) ; <nl> const __m128i q1s = _mm_xor_si128 ( * q1 , sign_bit ) ; <nl> static WEBP_INLINE void DoFilter4_SSE2 ( __m128i * const p1 , __m128i * const p0 , <nl> const __m128i * const mask , <nl> int hev_thresh ) { <nl> const __m128i zero = _mm_setzero_si128 ( ) ; <nl> - const __m128i sign_bit = _mm_set1_epi8 ( 0x80 ) ; <nl> + const __m128i sign_bit = _mm_set1_epi8 ( ( char ) 0x80 ) ; <nl> const __m128i k64 = _mm_set1_epi8 ( 64 ) ; <nl> const __m128i k3 = _mm_set1_epi8 ( 3 ) ; <nl> const __m128i k4 = _mm_set1_epi8 ( 4 ) ; <nl> static WEBP_INLINE void DoFilter6_SSE2 ( __m128i * const p2 , __m128i * const p1 , <nl> const __m128i * const mask , <nl> int hev_thresh ) { <nl> const __m128i zero = _mm_setzero_si128 ( ) ; <nl> - const __m128i sign_bit = _mm_set1_epi8 ( 0x80 ) ; <nl> + const __m128i sign_bit = _mm_set1_epi8 ( ( char ) 0x80 ) ; <nl> __m128i a , not_hev ; <nl> <nl> / / compute hev mask <nl> static void VR4_SSE2 ( uint8_t * dst ) { / / Vertical - Right <nl> const __m128i ABCD0 = _mm_srli_si128 ( XABCD , 1 ) ; <nl> const __m128i abcd = _mm_avg_epu8 ( XABCD , ABCD0 ) ; <nl> const __m128i _XABCD = _mm_slli_si128 ( XABCD , 1 ) ; <nl> - const __m128i IXABCD = _mm_insert_epi16 ( _XABCD , I | ( X < < 8 ) , 0 ) ; <nl> + const __m128i IXABCD = _mm_insert_epi16 ( _XABCD , ( short ) ( I | ( X < < 8 ) ) , 0 ) ; <nl> const __m128i avg1 = _mm_avg_epu8 ( IXABCD , ABCD0 ) ; <nl> const __m128i lsb = _mm_and_si128 ( _mm_xor_si128 ( IXABCD , ABCD0 ) , one ) ; <nl> const __m128i avg2 = _mm_subs_epu8 ( avg1 , lsb ) ; <nl> mmm a / 3rdparty / libwebp / src / dsp / enc_sse2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / enc_sse2 . c <nl> static WEBP_INLINE void VR4_SSE2 ( uint8_t * dst , <nl> const __m128i ABCD0 = _mm_srli_si128 ( XABCD , 1 ) ; <nl> const __m128i abcd = _mm_avg_epu8 ( XABCD , ABCD0 ) ; <nl> const __m128i _XABCD = _mm_slli_si128 ( XABCD , 1 ) ; <nl> - const __m128i IXABCD = _mm_insert_epi16 ( _XABCD , I | ( X < < 8 ) , 0 ) ; <nl> + const __m128i IXABCD = _mm_insert_epi16 ( _XABCD , ( short ) ( I | ( X < < 8 ) ) , 0 ) ; <nl> const __m128i avg1 = _mm_avg_epu8 ( IXABCD , ABCD0 ) ; <nl> const __m128i lsb = _mm_and_si128 ( _mm_xor_si128 ( IXABCD , ABCD0 ) , one ) ; <nl> const __m128i avg2 = _mm_subs_epu8 ( avg1 , lsb ) ; <nl> mmm a / 3rdparty / libwebp / src / dsp / filters . c <nl> ppp b / 3rdparty / libwebp / src / dsp / filters . c <nl> static WEBP_INLINE void PredictLine_C ( const uint8_t * src , const uint8_t * pred , <nl> uint8_t * dst , int length , int inverse ) { <nl> int i ; <nl> if ( inverse ) { <nl> - for ( i = 0 ; i < length ; + + i ) dst [ i ] = src [ i ] + pred [ i ] ; <nl> + for ( i = 0 ; i < length ; + + i ) dst [ i ] = ( uint8_t ) ( src [ i ] + pred [ i ] ) ; <nl> } else { <nl> - for ( i = 0 ; i < length ; + + i ) dst [ i ] = src [ i ] - pred [ i ] ; <nl> + for ( i = 0 ; i < length ; + + i ) dst [ i ] = ( uint8_t ) ( src [ i ] - pred [ i ] ) ; <nl> } <nl> } <nl> <nl> static WEBP_INLINE void DoGradientFilter_C ( const uint8_t * in , <nl> const int pred = GradientPredictor_C ( preds [ w - 1 ] , <nl> preds [ w - stride ] , <nl> preds [ w - stride - 1 ] ) ; <nl> - out [ w ] = in [ w ] + ( inverse ? pred : - pred ) ; <nl> + out [ w ] = ( uint8_t ) ( in [ w ] + ( inverse ? pred : - pred ) ) ; <nl> } <nl> + + row ; <nl> preds + = stride ; <nl> static void HorizontalUnfilter_C ( const uint8_t * prev , const uint8_t * in , <nl> uint8_t pred = ( prev = = NULL ) ? 0 : prev [ 0 ] ; <nl> int i ; <nl> for ( i = 0 ; i < width ; + + i ) { <nl> - out [ i ] = pred + in [ i ] ; <nl> + out [ i ] = ( uint8_t ) ( pred + in [ i ] ) ; <nl> pred = out [ i ] ; <nl> } <nl> } <nl> static void VerticalUnfilter_C ( const uint8_t * prev , const uint8_t * in , <nl> HorizontalUnfilter_C ( NULL , in , out , width ) ; <nl> } else { <nl> int i ; <nl> - for ( i = 0 ; i < width ; + + i ) out [ i ] = prev [ i ] + in [ i ] ; <nl> + for ( i = 0 ; i < width ; + + i ) out [ i ] = ( uint8_t ) ( prev [ i ] + in [ i ] ) ; <nl> } <nl> } <nl> # endif / / ! WEBP_NEON_OMIT_C_CODE <nl> static void GradientUnfilter_C ( const uint8_t * prev , const uint8_t * in , <nl> int i ; <nl> for ( i = 0 ; i < width ; + + i ) { <nl> top = prev [ i ] ; / / need to read this first , in case prev = = out <nl> - left = in [ i ] + GradientPredictor_C ( left , top , top_left ) ; <nl> + left = ( uint8_t ) ( in [ i ] + GradientPredictor_C ( left , top , top_left ) ) ; <nl> top_left = top ; <nl> out [ i ] = left ; <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / filters_sse2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / filters_sse2 . c <nl> static void GradientPredictDirect_SSE2 ( const uint8_t * const row , <nl> _mm_storel_epi64 ( ( __m128i * ) ( out + i ) , H ) ; <nl> } <nl> for ( ; i < length ; + + i ) { <nl> - out [ i ] = row [ i ] - GradientPredictor_SSE2 ( row [ i - 1 ] , top [ i ] , top [ i - 1 ] ) ; <nl> + const int delta = GradientPredictor_SSE2 ( row [ i - 1 ] , top [ i ] , top [ i - 1 ] ) ; <nl> + out [ i ] = ( uint8_t ) ( row [ i ] - delta ) ; <nl> } <nl> } <nl> <nl> static WEBP_INLINE void DoGradientFilter_SSE2 ( const uint8_t * in , <nl> <nl> / / Filter line - by - line . <nl> while ( row < last_row ) { <nl> - out [ 0 ] = in [ 0 ] - in [ - stride ] ; <nl> + out [ 0 ] = ( uint8_t ) ( in [ 0 ] - in [ - stride ] ) ; <nl> GradientPredictDirect_SSE2 ( in + 1 , in + 1 - stride , out + 1 , width - 1 ) ; <nl> + + row ; <nl> in + = stride ; <nl> static void HorizontalUnfilter_SSE2 ( const uint8_t * prev , const uint8_t * in , <nl> uint8_t * out , int width ) { <nl> int i ; <nl> __m128i last ; <nl> - out [ 0 ] = in [ 0 ] + ( prev = = NULL ? 0 : prev [ 0 ] ) ; <nl> + out [ 0 ] = ( uint8_t ) ( in [ 0 ] + ( prev = = NULL ? 0 : prev [ 0 ] ) ) ; <nl> if ( width < = 1 ) return ; <nl> last = _mm_set_epi32 ( 0 , 0 , 0 , out [ 0 ] ) ; <nl> for ( i = 1 ; i + 8 < = width ; i + = 8 ) { <nl> static void HorizontalUnfilter_SSE2 ( const uint8_t * prev , const uint8_t * in , <nl> _mm_storel_epi64 ( ( __m128i * ) ( out + i ) , A7 ) ; <nl> last = _mm_srli_epi64 ( A7 , 56 ) ; <nl> } <nl> - for ( ; i < width ; + + i ) out [ i ] = in [ i ] + out [ i - 1 ] ; <nl> + for ( ; i < width ; + + i ) out [ i ] = ( uint8_t ) ( in [ i ] + out [ i - 1 ] ) ; <nl> } <nl> <nl> static void VerticalUnfilter_SSE2 ( const uint8_t * prev , const uint8_t * in , <nl> static void VerticalUnfilter_SSE2 ( const uint8_t * prev , const uint8_t * in , <nl> _mm_storeu_si128 ( ( __m128i * ) & out [ i + 0 ] , C0 ) ; <nl> _mm_storeu_si128 ( ( __m128i * ) & out [ i + 16 ] , C1 ) ; <nl> } <nl> - for ( ; i < width ; + + i ) out [ i ] = in [ i ] + prev [ i ] ; <nl> + for ( ; i < width ; + + i ) out [ i ] = ( uint8_t ) ( in [ i ] + prev [ i ] ) ; <nl> } <nl> } <nl> <nl> static void GradientPredictInverse_SSE2 ( const uint8_t * const in , <nl> _mm_storel_epi64 ( ( __m128i * ) & row [ i ] , out ) ; <nl> } <nl> for ( ; i < length ; + + i ) { <nl> - row [ i ] = in [ i ] + GradientPredictor_SSE2 ( row [ i - 1 ] , top [ i ] , top [ i - 1 ] ) ; <nl> + const int delta = GradientPredictor_SSE2 ( row [ i - 1 ] , top [ i ] , top [ i - 1 ] ) ; <nl> + row [ i ] = ( uint8_t ) ( in [ i ] + delta ) ; <nl> } <nl> } <nl> } <nl> static void GradientUnfilter_SSE2 ( const uint8_t * prev , const uint8_t * in , <nl> if ( prev = = NULL ) { <nl> HorizontalUnfilter_SSE2 ( NULL , in , out , width ) ; <nl> } else { <nl> - out [ 0 ] = in [ 0 ] + prev [ 0 ] ; / / predict from above <nl> + out [ 0 ] = ( uint8_t ) ( in [ 0 ] + prev [ 0 ] ) ; / / predict from above <nl> GradientPredictInverse_SSE2 ( in + 1 , prev + 1 , out + 1 , width - 1 ) ; <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / lossless . c <nl> ppp b / 3rdparty / libwebp / src / dsp / lossless . c <nl> void VP8LTransformColorInverse_C ( const VP8LMultipliers * const m , <nl> int i ; <nl> for ( i = 0 ; i < num_pixels ; + + i ) { <nl> const uint32_t argb = src [ i ] ; <nl> - const uint32_t green = argb > > 8 ; <nl> + const int8_t green = ( int8_t ) ( argb > > 8 ) ; <nl> const uint32_t red = argb > > 16 ; <nl> int new_red = red & 0xff ; <nl> int new_blue = argb & 0xff ; <nl> new_red + = ColorTransformDelta ( m - > green_to_red_ , green ) ; <nl> new_red & = 0xff ; <nl> new_blue + = ColorTransformDelta ( m - > green_to_blue_ , green ) ; <nl> - new_blue + = ColorTransformDelta ( m - > red_to_blue_ , new_red ) ; <nl> + new_blue + = ColorTransformDelta ( m - > red_to_blue_ , ( int8_t ) new_red ) ; <nl> new_blue & = 0xff ; <nl> dst [ i ] = ( argb & 0xff00ff00u ) | ( new_red < < 16 ) | ( new_blue ) ; <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / lossless_enc . c <nl> ppp b / 3rdparty / libwebp / src / dsp / lossless_enc . c <nl> static WEBP_INLINE int ColorTransformDelta ( int8_t color_pred , int8_t color ) { <nl> return ( ( int ) color_pred * color ) > > 5 ; <nl> } <nl> <nl> + static WEBP_INLINE int8_t U32ToS8 ( uint32_t v ) { <nl> + return ( int8_t ) ( v & 0xff ) ; <nl> + } <nl> + <nl> void VP8LTransformColor_C ( const VP8LMultipliers * const m , uint32_t * data , <nl> int num_pixels ) { <nl> int i ; <nl> for ( i = 0 ; i < num_pixels ; + + i ) { <nl> const uint32_t argb = data [ i ] ; <nl> - const uint32_t green = argb > > 8 ; <nl> - const uint32_t red = argb > > 16 ; <nl> + const int8_t green = U32ToS8 ( argb > > 8 ) ; <nl> + const int8_t red = U32ToS8 ( argb > > 16 ) ; <nl> int new_red = red & 0xff ; <nl> int new_blue = argb & 0xff ; <nl> new_red - = ColorTransformDelta ( m - > green_to_red_ , green ) ; <nl> void VP8LTransformColor_C ( const VP8LMultipliers * const m , uint32_t * data , <nl> <nl> static WEBP_INLINE uint8_t TransformColorRed ( uint8_t green_to_red , <nl> uint32_t argb ) { <nl> - const uint32_t green = argb > > 8 ; <nl> + const int8_t green = U32ToS8 ( argb > > 8 ) ; <nl> int new_red = argb > > 16 ; <nl> new_red - = ColorTransformDelta ( green_to_red , green ) ; <nl> return ( new_red & 0xff ) ; <nl> static WEBP_INLINE uint8_t TransformColorRed ( uint8_t green_to_red , <nl> static WEBP_INLINE uint8_t TransformColorBlue ( uint8_t green_to_blue , <nl> uint8_t red_to_blue , <nl> uint32_t argb ) { <nl> - const uint32_t green = argb > > 8 ; <nl> - const uint32_t red = argb > > 16 ; <nl> - uint8_t new_blue = argb ; <nl> + const int8_t green = U32ToS8 ( argb > > 8 ) ; <nl> + const int8_t red = U32ToS8 ( argb > > 16 ) ; <nl> + uint8_t new_blue = argb & 0xff ; <nl> new_blue - = ColorTransformDelta ( green_to_blue , green ) ; <nl> new_blue - = ColorTransformDelta ( red_to_blue , red ) ; <nl> return ( new_blue & 0xff ) ; <nl> void VP8LCollectColorRedTransforms_C ( const uint32_t * argb , int stride , <nl> while ( tile_height - - > 0 ) { <nl> int x ; <nl> for ( x = 0 ; x < tile_width ; + + x ) { <nl> - + + histo [ TransformColorRed ( green_to_red , argb [ x ] ) ] ; <nl> + + + histo [ TransformColorRed ( ( uint8_t ) green_to_red , argb [ x ] ) ] ; <nl> } <nl> argb + = stride ; <nl> } <nl> void VP8LCollectColorBlueTransforms_C ( const uint32_t * argb , int stride , <nl> while ( tile_height - - > 0 ) { <nl> int x ; <nl> for ( x = 0 ; x < tile_width ; + + x ) { <nl> - + + histo [ TransformColorBlue ( green_to_blue , red_to_blue , argb [ x ] ) ] ; <nl> + + + histo [ TransformColorBlue ( ( uint8_t ) green_to_blue , ( uint8_t ) red_to_blue , <nl> + argb [ x ] ) ] ; <nl> } <nl> argb + = stride ; <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / lossless_enc_sse2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / lossless_enc_sse2 . c <nl> static void BundleColorMap_SSE2 ( const uint8_t * const row , int width , int xbits , <nl> assert ( xbits < = 3 ) ; <nl> switch ( xbits ) { <nl> case 0 : { <nl> - const __m128i ff = _mm_set1_epi16 ( 0xff00 ) ; <nl> + const __m128i ff = _mm_set1_epi16 ( ( short ) 0xff00 ) ; <nl> const __m128i zero = _mm_setzero_si128 ( ) ; <nl> / / Store 0xff000000 | ( row [ x ] < < 8 ) . <nl> for ( x = 0 ; x + 16 < = width ; x + = 16 , dst + = 16 ) { <nl> static void BundleColorMap_SSE2 ( const uint8_t * const row , int width , int xbits , <nl> break ; <nl> } <nl> case 1 : { <nl> - const __m128i ff = _mm_set1_epi16 ( 0xff00 ) ; <nl> + const __m128i ff = _mm_set1_epi16 ( ( short ) 0xff00 ) ; <nl> const __m128i mul = _mm_set1_epi16 ( 0x110 ) ; <nl> for ( x = 0 ; x + 16 < = width ; x + = 16 , dst + = 8 ) { <nl> / / 0a0b | ( where a / b are 4 bits ) . <nl> mmm a / 3rdparty / libwebp / src / dsp / lossless_enc_sse41 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / lossless_enc_sse41 . c <nl> static void CollectColorBlueTransforms_SSE41 ( const uint32_t * argb , int stride , <nl> int histo [ ] ) { <nl> const __m128i mults_r = _mm_set1_epi16 ( CST_5b ( red_to_blue ) ) ; <nl> const __m128i mults_g = _mm_set1_epi16 ( CST_5b ( green_to_blue ) ) ; <nl> - const __m128i mask_g = _mm_set1_epi16 ( 0xff00 ) ; / / green mask <nl> - const __m128i mask_gb = _mm_set1_epi32 ( 0xffff ) ; / / green / blue mask <nl> - const __m128i mask_b = _mm_set1_epi16 ( 0x00ff ) ; / / blue mask <nl> + const __m128i mask_g = _mm_set1_epi16 ( ( short ) 0xff00 ) ; / / green mask <nl> + const __m128i mask_gb = _mm_set1_epi32 ( 0xffff ) ; / / green / blue mask <nl> + const __m128i mask_b = _mm_set1_epi16 ( 0x00ff ) ; / / blue mask <nl> const __m128i shuffler_lo = _mm_setr_epi8 ( - 1 , 2 , - 1 , 6 , - 1 , 10 , - 1 , 14 , - 1 , <nl> - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 ) ; <nl> const __m128i shuffler_hi = _mm_setr_epi8 ( - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , <nl> mmm a / 3rdparty / libwebp / src / dsp / quant . h <nl> ppp b / 3rdparty / libwebp / src / dsp / quant . h <nl> <nl> # ifndef WEBP_DSP_QUANT_H_ <nl> # define WEBP_DSP_QUANT_H_ <nl> <nl> + # include < string . h > <nl> + <nl> # include " src / dsp / dsp . h " <nl> # include " src / webp / types . h " <nl> <nl> static WEBP_INLINE int IsFlat ( const int16_t * levels , int num_blocks , <nl> # endif / / defined ( WEBP_USE_NEON ) & & ! defined ( WEBP_ANDROID_NEON ) & & <nl> / / ! defined ( WEBP_HAVE_NEON_RTCD ) <nl> <nl> + static WEBP_INLINE int IsFlatSource16 ( const uint8_t * src ) { <nl> + const uint32_t v = src [ 0 ] * 0x01010101u ; <nl> + int i ; <nl> + for ( i = 0 ; i < 16 ; + + i ) { <nl> + if ( memcmp ( src + 0 , & v , 4 ) | | memcmp ( src + 4 , & v , 4 ) | | <nl> + memcmp ( src + 8 , & v , 4 ) | | memcmp ( src + 12 , & v , 4 ) ) { <nl> + return 0 ; <nl> + } <nl> + src + = BPS ; <nl> + } <nl> + return 1 ; <nl> + } <nl> + <nl> # endif / / WEBP_DSP_QUANT_H_ <nl> mmm a / 3rdparty / libwebp / src / dsp / rescaler . c <nl> ppp b / 3rdparty / libwebp / src / dsp / rescaler . c <nl> void WebPRescalerExportRowExpand_C ( WebPRescaler * const wrk ) { <nl> for ( x_out = 0 ; x_out < x_out_max ; + + x_out ) { <nl> const uint32_t J = frow [ x_out ] ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } else { <nl> const uint32_t B = WEBP_RESCALER_FRAC ( - wrk - > y_accum , wrk - > y_sub ) ; <nl> void WebPRescalerExportRowExpand_C ( WebPRescaler * const wrk ) { <nl> + ( uint64_t ) B * irow [ x_out ] ; <nl> const uint32_t J = ( uint32_t ) ( ( I + ROUNDER ) > > WEBP_RESCALER_RFIX ) ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } <nl> } <nl> void WebPRescalerExportRowShrink_C ( WebPRescaler * const wrk ) { <nl> assert ( ! wrk - > y_expand ) ; <nl> if ( yscale ) { <nl> for ( x_out = 0 ; x_out < x_out_max ; + + x_out ) { <nl> - const uint32_t frac = ( uint32_t ) MULT_FIX ( frow [ x_out ] , yscale ) ; <nl> - const int v = ( int ) MULT_FIX_FLOOR ( irow [ x_out ] - frac , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + const uint32_t frac = ( uint32_t ) MULT_FIX_FLOOR ( frow [ x_out ] , yscale ) ; <nl> + const int v = ( int ) MULT_FIX ( irow [ x_out ] - frac , wrk - > fxy_scale ) ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = frac ; / / new fractional start <nl> } <nl> } else { <nl> for ( x_out = 0 ; x_out < x_out_max ; + + x_out ) { <nl> const int v = ( int ) MULT_FIX ( irow [ x_out ] , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = 0 ; <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / rescaler_mips_dsp_r2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / rescaler_mips_dsp_r2 . c <nl> static void ExportRowShrink_MIPSdspR2 ( WebPRescaler * const wrk ) { <nl> ) ; <nl> } <nl> for ( i = 0 ; i < ( x_out_max & 0x3 ) ; + + i ) { <nl> - const uint32_t frac = ( uint32_t ) MULT_FIX ( * frow + + , yscale ) ; <nl> - const int v = ( int ) MULT_FIX_FLOOR ( * irow - frac , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - * dst + + = v ; <nl> + const uint32_t frac = ( uint32_t ) MULT_FIX_FLOOR ( * frow + + , yscale ) ; <nl> + const int v = ( int ) MULT_FIX ( * irow - frac , wrk - > fxy_scale ) ; <nl> + * dst + + = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> * irow + + = frac ; / / new fractional start <nl> } <nl> } else { <nl> static void ExportRowShrink_MIPSdspR2 ( WebPRescaler * const wrk ) { <nl> } <nl> for ( i = 0 ; i < ( x_out_max & 0x3 ) ; + + i ) { <nl> const int v = ( int ) MULT_FIX_FLOOR ( * irow , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - * dst + + = v ; <nl> + * dst + + = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> * irow + + = 0 ; <nl> } <nl> } <nl> static void ExportRowExpand_MIPSdspR2 ( WebPRescaler * const wrk ) { <nl> for ( i = 0 ; i < ( x_out_max & 0x3 ) ; + + i ) { <nl> const uint32_t J = * frow + + ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - * dst + + = v ; <nl> + * dst + + = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } else { <nl> const uint32_t B = WEBP_RESCALER_FRAC ( - wrk - > y_accum , wrk - > y_sub ) ; <nl> static void ExportRowExpand_MIPSdspR2 ( WebPRescaler * const wrk ) { <nl> + ( uint64_t ) B * * irow + + ; <nl> const uint32_t J = ( uint32_t ) ( ( I + ROUNDER ) > > WEBP_RESCALER_RFIX ) ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - * dst + + = v ; <nl> + * dst + + = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / rescaler_msa . c <nl> ppp b / 3rdparty / libwebp / src / dsp / rescaler_msa . c <nl> static WEBP_INLINE void ExportRowExpand_0 ( const uint32_t * frow , uint8_t * dst , <nl> for ( x_out = 0 ; x_out < length ; + + x_out ) { <nl> const uint32_t J = frow [ x_out ] ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } <nl> } <nl> static WEBP_INLINE void ExportRowExpand_1 ( const uint32_t * frow , uint32_t * irow , <nl> + ( uint64_t ) B * irow [ x_out ] ; <nl> const uint32_t J = ( uint32_t ) ( ( I + ROUNDER ) > > WEBP_RESCALER_RFIX ) ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } <nl> } <nl> static WEBP_INLINE void ExportRowShrink_0 ( const uint32_t * frow , uint32_t * irow , <nl> length - = 4 ; <nl> } <nl> for ( x_out = 0 ; x_out < length ; + + x_out ) { <nl> - const uint32_t frac = ( uint32_t ) MULT_FIX ( frow [ x_out ] , yscale ) ; <nl> - const int v = ( int ) MULT_FIX_FLOOR ( irow [ x_out ] - frac , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + const uint32_t frac = ( uint32_t ) MULT_FIX_FLOOR ( frow [ x_out ] , yscale ) ; <nl> + const int v = ( int ) MULT_FIX ( irow [ x_out ] - frac , wrk - > fxy_scale ) ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = frac ; <nl> } <nl> } <nl> static WEBP_INLINE void ExportRowShrink_1 ( uint32_t * irow , uint8_t * dst , <nl> } <nl> for ( x_out = 0 ; x_out < length ; + + x_out ) { <nl> const int v = ( int ) MULT_FIX ( irow [ x_out ] , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = 0 ; <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / rescaler_neon . c <nl> ppp b / 3rdparty / libwebp / src / dsp / rescaler_neon . c <nl> static void RescalerExportRowExpand_NEON ( WebPRescaler * const wrk ) { <nl> const uint32x4_t B1 = MULT_FIX ( A1 , fy_scale_half ) ; <nl> const uint16x4_t C0 = vmovn_u32 ( B0 ) ; <nl> const uint16x4_t C1 = vmovn_u32 ( B1 ) ; <nl> - const uint8x8_t D = vmovn_u16 ( vcombine_u16 ( C0 , C1 ) ) ; <nl> + const uint8x8_t D = vqmovn_u16 ( vcombine_u16 ( C0 , C1 ) ) ; <nl> vst1_u8 ( dst + x_out , D ) ; <nl> } <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> const uint32_t J = frow [ x_out ] ; <nl> const int v = ( int ) MULT_FIX_C ( J , fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } else { <nl> const uint32_t B = WEBP_RESCALER_FRAC ( - wrk - > y_accum , wrk - > y_sub ) ; <nl> static void RescalerExportRowExpand_NEON ( WebPRescaler * const wrk ) { <nl> const uint32x4_t D1 = MULT_FIX ( C1 , fy_scale_half ) ; <nl> const uint16x4_t E0 = vmovn_u32 ( D0 ) ; <nl> const uint16x4_t E1 = vmovn_u32 ( D1 ) ; <nl> - const uint8x8_t F = vmovn_u16 ( vcombine_u16 ( E0 , E1 ) ) ; <nl> + const uint8x8_t F = vqmovn_u16 ( vcombine_u16 ( E0 , E1 ) ) ; <nl> vst1_u8 ( dst + x_out , F ) ; <nl> } <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> static void RescalerExportRowExpand_NEON ( WebPRescaler * const wrk ) { <nl> + ( uint64_t ) B * irow [ x_out ] ; <nl> const uint32_t J = ( uint32_t ) ( ( I + ROUNDER ) > > WEBP_RESCALER_RFIX ) ; <nl> const int v = ( int ) MULT_FIX_C ( J , fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } <nl> } <nl> static void RescalerExportRowShrink_NEON ( WebPRescaler * const wrk ) { <nl> for ( x_out = 0 ; x_out < max_span ; x_out + = 8 ) { <nl> LOAD_32x8 ( frow + x_out , in0 , in1 ) ; <nl> LOAD_32x8 ( irow + x_out , in2 , in3 ) ; <nl> - const uint32x4_t A0 = MULT_FIX ( in0 , yscale_half ) ; <nl> - const uint32x4_t A1 = MULT_FIX ( in1 , yscale_half ) ; <nl> + const uint32x4_t A0 = MULT_FIX_FLOOR ( in0 , yscale_half ) ; <nl> + const uint32x4_t A1 = MULT_FIX_FLOOR ( in1 , yscale_half ) ; <nl> const uint32x4_t B0 = vqsubq_u32 ( in2 , A0 ) ; <nl> const uint32x4_t B1 = vqsubq_u32 ( in3 , A1 ) ; <nl> - const uint32x4_t C0 = MULT_FIX_FLOOR ( B0 , fxy_scale_half ) ; <nl> - const uint32x4_t C1 = MULT_FIX_FLOOR ( B1 , fxy_scale_half ) ; <nl> + const uint32x4_t C0 = MULT_FIX ( B0 , fxy_scale_half ) ; <nl> + const uint32x4_t C1 = MULT_FIX ( B1 , fxy_scale_half ) ; <nl> const uint16x4_t D0 = vmovn_u32 ( C0 ) ; <nl> const uint16x4_t D1 = vmovn_u32 ( C1 ) ; <nl> - const uint8x8_t E = vmovn_u16 ( vcombine_u16 ( D0 , D1 ) ) ; <nl> + const uint8x8_t E = vqmovn_u16 ( vcombine_u16 ( D0 , D1 ) ) ; <nl> vst1_u8 ( dst + x_out , E ) ; <nl> STORE_32x8 ( A0 , A1 , irow + x_out ) ; <nl> } <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> - const uint32_t frac = ( uint32_t ) MULT_FIX_C ( frow [ x_out ] , yscale ) ; <nl> - const int v = ( int ) MULT_FIX_FLOOR_C ( irow [ x_out ] - frac , fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + const uint32_t frac = ( uint32_t ) MULT_FIX_FLOOR_C ( frow [ x_out ] , yscale ) ; <nl> + const int v = ( int ) MULT_FIX_C ( irow [ x_out ] - frac , fxy_scale ) ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = frac ; / / new fractional start <nl> } <nl> } else { <nl> static void RescalerExportRowShrink_NEON ( WebPRescaler * const wrk ) { <nl> const uint32x4_t A1 = MULT_FIX ( in1 , fxy_scale_half ) ; <nl> const uint16x4_t B0 = vmovn_u32 ( A0 ) ; <nl> const uint16x4_t B1 = vmovn_u32 ( A1 ) ; <nl> - const uint8x8_t C = vmovn_u16 ( vcombine_u16 ( B0 , B1 ) ) ; <nl> + const uint8x8_t C = vqmovn_u16 ( vcombine_u16 ( B0 , B1 ) ) ; <nl> vst1_u8 ( dst + x_out , C ) ; <nl> STORE_32x8 ( zero , zero , irow + x_out ) ; <nl> } <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> const int v = ( int ) MULT_FIX_C ( irow [ x_out ] , fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = 0 ; <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / dsp / rescaler_sse2 . c <nl> ppp b / 3rdparty / libwebp / src / dsp / rescaler_sse2 . c <nl> static WEBP_INLINE void ProcessRow_SSE2 ( const __m128i * const A0 , <nl> _mm_storel_epi64 ( ( __m128i * ) dst , G ) ; <nl> } <nl> <nl> - static WEBP_INLINE void ProcessRow_Floor_SSE2 ( const __m128i * const A0 , <nl> - const __m128i * const A1 , <nl> - const __m128i * const A2 , <nl> - const __m128i * const A3 , <nl> - const __m128i * const mult , <nl> - uint8_t * const dst ) { <nl> - const __m128i mask = _mm_set_epi32 ( 0xffffffffu , 0 , 0xffffffffu , 0 ) ; <nl> - const __m128i B0 = _mm_mul_epu32 ( * A0 , * mult ) ; <nl> - const __m128i B1 = _mm_mul_epu32 ( * A1 , * mult ) ; <nl> - const __m128i B2 = _mm_mul_epu32 ( * A2 , * mult ) ; <nl> - const __m128i B3 = _mm_mul_epu32 ( * A3 , * mult ) ; <nl> - const __m128i D0 = _mm_srli_epi64 ( B0 , WEBP_RESCALER_RFIX ) ; <nl> - const __m128i D1 = _mm_srli_epi64 ( B1 , WEBP_RESCALER_RFIX ) ; <nl> - # if ( WEBP_RESCALER_RFIX < 32 ) <nl> - const __m128i D2 = <nl> - _mm_and_si128 ( _mm_slli_epi64 ( B2 , 32 - WEBP_RESCALER_RFIX ) , mask ) ; <nl> - const __m128i D3 = <nl> - _mm_and_si128 ( _mm_slli_epi64 ( B3 , 32 - WEBP_RESCALER_RFIX ) , mask ) ; <nl> - # else <nl> - const __m128i D2 = _mm_and_si128 ( B2 , mask ) ; <nl> - const __m128i D3 = _mm_and_si128 ( B3 , mask ) ; <nl> - # endif <nl> - const __m128i E0 = _mm_or_si128 ( D0 , D2 ) ; <nl> - const __m128i E1 = _mm_or_si128 ( D1 , D3 ) ; <nl> - const __m128i F = _mm_packs_epi32 ( E0 , E1 ) ; <nl> - const __m128i G = _mm_packus_epi16 ( F , F ) ; <nl> - _mm_storel_epi64 ( ( __m128i * ) dst , G ) ; <nl> - } <nl> - <nl> static void RescalerExportRowExpand_SSE2 ( WebPRescaler * const wrk ) { <nl> int x_out ; <nl> uint8_t * const dst = wrk - > dst ; <nl> static void RescalerExportRowExpand_SSE2 ( WebPRescaler * const wrk ) { <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> const uint32_t J = frow [ x_out ] ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } else { <nl> const uint32_t B = WEBP_RESCALER_FRAC ( - wrk - > y_accum , wrk - > y_sub ) ; <nl> static void RescalerExportRowExpand_SSE2 ( WebPRescaler * const wrk ) { <nl> + ( uint64_t ) B * irow [ x_out ] ; <nl> const uint32_t J = ( uint32_t ) ( ( I + ROUNDER ) > > WEBP_RESCALER_RFIX ) ; <nl> const int v = ( int ) MULT_FIX ( J , wrk - > fy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> } <nl> } <nl> } <nl> static void RescalerExportRowShrink_SSE2 ( WebPRescaler * const wrk ) { <nl> const int scale_xy = wrk - > fxy_scale ; <nl> const __m128i mult_xy = _mm_set_epi32 ( 0 , scale_xy , 0 , scale_xy ) ; <nl> const __m128i mult_y = _mm_set_epi32 ( 0 , yscale , 0 , yscale ) ; <nl> - const __m128i rounder = _mm_set_epi32 ( 0 , ROUNDER , 0 , ROUNDER ) ; <nl> for ( x_out = 0 ; x_out + 8 < = x_out_max ; x_out + = 8 ) { <nl> __m128i A0 , A1 , A2 , A3 , B0 , B1 , B2 , B3 ; <nl> LoadDispatchAndMult_SSE2 ( irow + x_out , NULL , & A0 , & A1 , & A2 , & A3 ) ; <nl> LoadDispatchAndMult_SSE2 ( frow + x_out , & mult_y , & B0 , & B1 , & B2 , & B3 ) ; <nl> { <nl> - const __m128i C0 = _mm_add_epi64 ( B0 , rounder ) ; <nl> - const __m128i C1 = _mm_add_epi64 ( B1 , rounder ) ; <nl> - const __m128i C2 = _mm_add_epi64 ( B2 , rounder ) ; <nl> - const __m128i C3 = _mm_add_epi64 ( B3 , rounder ) ; <nl> - const __m128i D0 = _mm_srli_epi64 ( C0 , WEBP_RESCALER_RFIX ) ; / / = frac <nl> - const __m128i D1 = _mm_srli_epi64 ( C1 , WEBP_RESCALER_RFIX ) ; <nl> - const __m128i D2 = _mm_srli_epi64 ( C2 , WEBP_RESCALER_RFIX ) ; <nl> - const __m128i D3 = _mm_srli_epi64 ( C3 , WEBP_RESCALER_RFIX ) ; <nl> + const __m128i D0 = _mm_srli_epi64 ( B0 , WEBP_RESCALER_RFIX ) ; / / = frac <nl> + const __m128i D1 = _mm_srli_epi64 ( B1 , WEBP_RESCALER_RFIX ) ; <nl> + const __m128i D2 = _mm_srli_epi64 ( B2 , WEBP_RESCALER_RFIX ) ; <nl> + const __m128i D3 = _mm_srli_epi64 ( B3 , WEBP_RESCALER_RFIX ) ; <nl> const __m128i E0 = _mm_sub_epi64 ( A0 , D0 ) ; / / irow [ x ] - frac <nl> const __m128i E1 = _mm_sub_epi64 ( A1 , D1 ) ; <nl> const __m128i E2 = _mm_sub_epi64 ( A2 , D2 ) ; <nl> static void RescalerExportRowShrink_SSE2 ( WebPRescaler * const wrk ) { <nl> const __m128i G1 = _mm_or_si128 ( D1 , F3 ) ; <nl> _mm_storeu_si128 ( ( __m128i * ) ( irow + x_out + 0 ) , G0 ) ; <nl> _mm_storeu_si128 ( ( __m128i * ) ( irow + x_out + 4 ) , G1 ) ; <nl> - ProcessRow_Floor_SSE2 ( & E0 , & E1 , & E2 , & E3 , & mult_xy , dst + x_out ) ; <nl> + ProcessRow_SSE2 ( & E0 , & E1 , & E2 , & E3 , & mult_xy , dst + x_out ) ; <nl> } <nl> } <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> - const uint32_t frac = ( int ) MULT_FIX ( frow [ x_out ] , yscale ) ; <nl> - const int v = ( int ) MULT_FIX_FLOOR ( irow [ x_out ] - frac , wrk - > fxy_scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + const uint32_t frac = ( int ) MULT_FIX_FLOOR ( frow [ x_out ] , yscale ) ; <nl> + const int v = ( int ) MULT_FIX ( irow [ x_out ] - frac , wrk - > fxy_scale ) ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = frac ; / / new fractional start <nl> } <nl> } else { <nl> static void RescalerExportRowShrink_SSE2 ( WebPRescaler * const wrk ) { <nl> } <nl> for ( ; x_out < x_out_max ; + + x_out ) { <nl> const int v = ( int ) MULT_FIX ( irow [ x_out ] , scale ) ; <nl> - assert ( v > = 0 & & v < = 255 ) ; <nl> - dst [ x_out ] = v ; <nl> + dst [ x_out ] = ( v > 255 ) ? 255u : ( uint8_t ) v ; <nl> irow [ x_out ] = 0 ; <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / enc / backward_references_enc . c <nl> ppp b / 3rdparty / libwebp / src / enc / backward_references_enc . c <nl> void VP8LHashChainClear ( VP8LHashChain * const p ) { <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> - # define HASH_MULTIPLIER_HI ( 0xc6a4a793ULL ) <nl> - # define HASH_MULTIPLIER_LO ( 0x5bd1e996ULL ) <nl> + static const uint32_t kHashMultiplierHi = 0xc6a4a793u ; <nl> + static const uint32_t kHashMultiplierLo = 0x5bd1e996u ; <nl> <nl> - static WEBP_INLINE uint32_t GetPixPairHash64 ( const uint32_t * const argb ) { <nl> + static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE <nl> + uint32_t GetPixPairHash64 ( const uint32_t * const argb ) { <nl> uint32_t key ; <nl> - key = ( argb [ 1 ] * HASH_MULTIPLIER_HI ) & 0xffffffffu ; <nl> - key + = ( argb [ 0 ] * HASH_MULTIPLIER_LO ) & 0xffffffffu ; <nl> + key = argb [ 1 ] * kHashMultiplierHi ; <nl> + key + = argb [ 0 ] * kHashMultiplierLo ; <nl> key = key > > ( 32 - HASH_BITS ) ; <nl> return key ; <nl> } <nl> mmm a / 3rdparty / libwebp / src / enc / histogram_enc . c <nl> ppp b / 3rdparty / libwebp / src / enc / histogram_enc . c <nl> static int HistogramCombineStochastic ( VP8LHistogramSet * const image_histo , <nl> } <nl> <nl> mappings = ( int * ) WebPSafeMalloc ( * num_used , sizeof ( * mappings ) ) ; <nl> - if ( mappings = = NULL | | ! HistoQueueInit ( & histo_queue , kHistoQueueSize ) ) { <nl> - goto End ; <nl> - } <nl> + if ( mappings = = NULL ) return 0 ; <nl> + if ( ! HistoQueueInit ( & histo_queue , kHistoQueueSize ) ) goto End ; <nl> / / Fill the initial mapping . <nl> for ( j = 0 , iter = 0 ; iter < image_histo - > size ; + + iter ) { <nl> if ( histograms [ iter ] = = NULL ) continue ; <nl> mmm a / 3rdparty / libwebp / src / enc / predictor_enc . c <nl> ppp b / 3rdparty / libwebp / src / enc / predictor_enc . c <nl> static uint32_t NearLossless ( uint32_t value , uint32_t predict , <nl> } <nl> if ( ( value > > 24 ) = = 0 | | ( value > > 24 ) = = 0xff ) { <nl> / / Preserve transparency of fully transparent or fully opaque pixels . <nl> - a = NearLosslessDiff ( value > > 24 , predict > > 24 ) ; <nl> + a = NearLosslessDiff ( ( value > > 24 ) & 0xff , ( predict > > 24 ) & 0xff ) ; <nl> } else { <nl> a = NearLosslessComponent ( value > > 24 , predict > > 24 , 0xff , quantization ) ; <nl> } <nl> static uint32_t NearLossless ( uint32_t value , uint32_t predict , <nl> / / The amount by which green has been adjusted during quantization . It is <nl> / / subtracted from red and blue for compensation , to avoid accumulating two <nl> / / quantization errors in them . <nl> - green_diff = NearLosslessDiff ( new_green , value > > 8 ) ; <nl> + green_diff = NearLosslessDiff ( new_green , ( value > > 8 ) & 0xff ) ; <nl> } <nl> - r = NearLosslessComponent ( NearLosslessDiff ( value > > 16 , green_diff ) , <nl> + r = NearLosslessComponent ( NearLosslessDiff ( ( value > > 16 ) & 0xff , green_diff ) , <nl> ( predict > > 16 ) & 0xff , 0xff - new_green , <nl> quantization ) ; <nl> - b = NearLosslessComponent ( NearLosslessDiff ( value , green_diff ) , <nl> + b = NearLosslessComponent ( NearLosslessDiff ( value & 0xff , green_diff ) , <nl> predict & 0xff , 0xff - new_green , quantization ) ; <nl> return ( ( uint32_t ) a < < 24 ) | ( ( uint32_t ) r < < 16 ) | ( ( uint32_t ) g < < 8 ) | b ; <nl> } <nl> static void GetBestGreenToRed ( <nl> } <nl> } <nl> } <nl> - best_tx - > green_to_red_ = green_to_red_best ; <nl> + best_tx - > green_to_red_ = ( green_to_red_best & 0xff ) ; <nl> } <nl> <nl> static float GetPredictionCostCrossColorBlue ( <nl> static void GetBestGreenRedToBlue ( <nl> break ; / / out of iter - loop . <nl> } <nl> } <nl> - best_tx - > green_to_blue_ = green_to_blue_best ; <nl> - best_tx - > red_to_blue_ = red_to_blue_best ; <nl> + best_tx - > green_to_blue_ = green_to_blue_best & 0xff ; <nl> + best_tx - > red_to_blue_ = red_to_blue_best & 0xff ; <nl> } <nl> # undef kGreenRedToBlueMaxIters <nl> # undef kGreenRedToBlueNumAxis <nl> mmm a / 3rdparty / libwebp / src / enc / quant_enc . c <nl> ppp b / 3rdparty / libwebp / src / enc / quant_enc . c <nl> <nl> <nl> / / number of non - zero coeffs below which we consider the block very flat <nl> / / ( and apply a penalty to complex predictions ) <nl> - # define FLATNESS_LIMIT_I16 10 / / I16 mode <nl> + # define FLATNESS_LIMIT_I16 0 / / I16 mode ( special case ) <nl> # define FLATNESS_LIMIT_I4 3 / / I4 mode <nl> # define FLATNESS_LIMIT_UV 2 / / UV mode <nl> # define FLATNESS_PENALTY 140 / / roughly ~ 1bit per block <nl> static void PickBestIntra16 ( VP8EncIterator * const it , VP8ModeScore * rd ) { <nl> VP8ModeScore * rd_cur = & rd_tmp ; <nl> VP8ModeScore * rd_best = rd ; <nl> int mode ; <nl> + int is_flat = IsFlatSource16 ( it - > yuv_in_ + Y_OFF_ENC ) ; <nl> <nl> rd - > mode_i16 = - 1 ; <nl> for ( mode = 0 ; mode < NUM_PRED_MODES ; + + mode ) { <nl> static void PickBestIntra16 ( VP8EncIterator * const it , VP8ModeScore * rd ) { <nl> tlambda ? MULT_8B ( tlambda , VP8TDisto16x16 ( src , tmp_dst , kWeightY ) ) : 0 ; <nl> rd_cur - > H = VP8FixedCostsI16 [ mode ] ; <nl> rd_cur - > R = VP8GetCostLuma16 ( it , rd_cur ) ; <nl> - if ( mode > 0 & & <nl> - IsFlat ( rd_cur - > y_ac_levels [ 0 ] , kNumBlocks , FLATNESS_LIMIT_I16 ) ) { <nl> - / / penalty to avoid flat area to be mispredicted by complex mode <nl> - rd_cur - > R + = FLATNESS_PENALTY * kNumBlocks ; <nl> + if ( is_flat ) { <nl> + / / refine the first impression ( which was in pixel space ) <nl> + is_flat = IsFlat ( rd_cur - > y_ac_levels [ 0 ] , kNumBlocks , FLATNESS_LIMIT_I16 ) ; <nl> + if ( is_flat ) { <nl> + / / Block is very flat . We put emphasis on the distortion being very low ! <nl> + rd_cur - > D * = 2 ; <nl> + rd_cur - > SD * = 2 ; <nl> + } <nl> } <nl> <nl> / / Since we always examine Intra16 first , we can overwrite * rd directly . <nl> static int PickBestIntra4 ( VP8EncIterator * const it , VP8ModeScore * const rd ) { <nl> : 0 ; <nl> rd_tmp . H = mode_costs [ mode ] ; <nl> <nl> - / / Add flatness penalty <nl> + / / Add flatness penalty , to avoid flat area to be mispredicted <nl> + / / by a complex mode . <nl> if ( mode > 0 & & IsFlat ( tmp_levels , kNumBlocks , FLATNESS_LIMIT_I4 ) ) { <nl> rd_tmp . R = FLATNESS_PENALTY * kNumBlocks ; <nl> } else { <nl> static void RefineUsingDistortion ( VP8EncIterator * const it , <nl> if ( mode > 0 & & VP8FixedCostsI16 [ mode ] > bit_limit ) { <nl> continue ; <nl> } <nl> + <nl> if ( score < best_score ) { <nl> best_mode = mode ; <nl> best_score = score ; <nl> } <nl> } <nl> + if ( it - > x_ = = 0 | | it - > y_ = = 0 ) { <nl> + / / avoid starting a checkerboard resonance from the border . See bug # 432 . <nl> + if ( IsFlatSource16 ( src ) ) { <nl> + best_mode = ( it - > x_ = = 0 ) ? 0 : 2 ; <nl> + try_both_modes = 0 ; / / stick to i16 <nl> + } <nl> + } <nl> VP8SetIntra16Mode ( it , best_mode ) ; <nl> / / we ' ll reconstruct later , if i16 mode actually gets selected <nl> } <nl> mmm a / 3rdparty / libwebp / src / enc / vp8i_enc . h <nl> ppp b / 3rdparty / libwebp / src / enc / vp8i_enc . h <nl> extern " C " { <nl> / / version numbers <nl> # define ENC_MAJ_VERSION 1 <nl> # define ENC_MIN_VERSION 0 <nl> - # define ENC_REV_VERSION 2 <nl> + # define ENC_REV_VERSION 3 <nl> <nl> enum { MAX_LF_LEVELS = 64 , / / Maximum loop filter level <nl> MAX_VARIABLE_LEVEL = 67 , / / last ( inclusive ) level with variable cost <nl> mmm a / 3rdparty / libwebp / src / mux / muxi . h <nl> ppp b / 3rdparty / libwebp / src / mux / muxi . h <nl> extern " C " { <nl> <nl> # define MUX_MAJ_VERSION 1 <nl> # define MUX_MIN_VERSION 0 <nl> - # define MUX_REV_VERSION 2 <nl> + # define MUX_REV_VERSION 3 <nl> <nl> / / Chunk object . <nl> typedef struct WebPChunk WebPChunk ; <nl> mmm a / 3rdparty / libwebp / src / utils / bit_reader_inl_utils . h <nl> ppp b / 3rdparty / libwebp / src / utils / bit_reader_inl_utils . h <nl> void VP8LoadNewBytes ( VP8BitReader * const br ) { <nl> } <nl> <nl> / / Read a bit with proba ' prob ' . Speed - critical function ! <nl> - static WEBP_INLINE int VP8GetBit ( VP8BitReader * const br , int prob ) { <nl> + static WEBP_INLINE int VP8GetBit ( VP8BitReader * const br , <nl> + int prob , const char label [ ] ) { <nl> / / Don ' t move this declaration ! It makes a big speed difference to store <nl> / / ' range ' * before * calling VP8LoadNewBytes ( ) , even if this function doesn ' t <nl> / / alter br - > range_ value . <nl> static WEBP_INLINE int VP8GetBit ( VP8BitReader * const br , int prob ) { <nl> br - > bits_ - = shift ; <nl> } <nl> br - > range_ = range - 1 ; <nl> + BT_TRACK ( br ) ; <nl> return bit ; <nl> } <nl> } <nl> <nl> / / simplified version of VP8GetBit ( ) for prob = 0x80 ( note shift is always 1 here ) <nl> static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE <nl> - int VP8GetSigned ( VP8BitReader * const br , int v ) { <nl> + int VP8GetSigned ( VP8BitReader * const br , int v , const char label [ ] ) { <nl> if ( br - > bits_ < 0 ) { <nl> VP8LoadNewBytes ( br ) ; <nl> } <nl> int VP8GetSigned ( VP8BitReader * const br , int v ) { <nl> br - > range_ + = mask ; <nl> br - > range_ | = 1 ; <nl> br - > value_ - = ( bit_t ) ( ( split + 1 ) & mask ) < < pos ; <nl> + BT_TRACK ( br ) ; <nl> return ( v ^ mask ) - mask ; <nl> } <nl> } <nl> <nl> - static WEBP_INLINE int VP8GetBitAlt ( VP8BitReader * const br , int prob ) { <nl> + static WEBP_INLINE int VP8GetBitAlt ( VP8BitReader * const br , <nl> + int prob , const char label [ ] ) { <nl> / / Don ' t move this declaration ! It makes a big speed difference to store <nl> / / ' range ' * before * calling VP8LoadNewBytes ( ) , even if this function doesn ' t <nl> / / alter br - > range_ value . <nl> static WEBP_INLINE int VP8GetBitAlt ( VP8BitReader * const br , int prob ) { <nl> br - > bits_ - = shift ; <nl> } <nl> br - > range_ = range ; <nl> + BT_TRACK ( br ) ; <nl> return bit ; <nl> } <nl> } <nl> mmm a / 3rdparty / libwebp / src / utils / bit_reader_utils . c <nl> ppp b / 3rdparty / libwebp / src / utils / bit_reader_utils . c <nl> void VP8LoadFinalBytes ( VP8BitReader * const br ) { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / Higher - level calls <nl> <nl> - uint32_t VP8GetValue ( VP8BitReader * const br , int bits ) { <nl> + uint32_t VP8GetValue ( VP8BitReader * const br , int bits , const char label [ ] ) { <nl> uint32_t v = 0 ; <nl> while ( bits - - > 0 ) { <nl> - v | = VP8GetBit ( br , 0x80 ) < < bits ; <nl> + v | = VP8GetBit ( br , 0x80 , label ) < < bits ; <nl> } <nl> return v ; <nl> } <nl> <nl> - int32_t VP8GetSignedValue ( VP8BitReader * const br , int bits ) { <nl> - const int value = VP8GetValue ( br , bits ) ; <nl> - return VP8Get ( br ) ? - value : value ; <nl> + int32_t VP8GetSignedValue ( VP8BitReader * const br , int bits , <nl> + const char label [ ] ) { <nl> + const int value = VP8GetValue ( br , bits , label ) ; <nl> + return VP8Get ( br , label ) ? - value : value ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> uint32_t VP8LReadBits ( VP8LBitReader * const br , int n_bits ) { <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / Bit - tracing tool <nl> + <nl> + # if ( BITTRACE > 0 ) <nl> + <nl> + # include < stdlib . h > / / for atexit ( ) <nl> + # include < stdio . h > <nl> + # include < string . h > <nl> + <nl> + # define MAX_NUM_LABELS 32 <nl> + static struct { <nl> + const char * label ; <nl> + int size ; <nl> + int count ; <nl> + } kLabels [ MAX_NUM_LABELS ] ; <nl> + <nl> + static int last_label = 0 ; <nl> + static int last_pos = 0 ; <nl> + static const uint8_t * buf_start = NULL ; <nl> + static int init_done = 0 ; <nl> + <nl> + static void PrintBitTraces ( void ) { <nl> + int i ; <nl> + int scale = 1 ; <nl> + int total = 0 ; <nl> + const char * units = " bits " ; <nl> + # if ( BITTRACE = = 2 ) <nl> + scale = 8 ; <nl> + units = " bytes " ; <nl> + # endif <nl> + for ( i = 0 ; i < last_label ; + + i ) total + = kLabels [ i ] . size ; <nl> + if ( total < 1 ) total = 1 ; / / avoid rounding errors <nl> + printf ( " = = = Bit traces = = = \ n " ) ; <nl> + for ( i = 0 ; i < last_label ; + + i ) { <nl> + const int skip = 16 - ( int ) strlen ( kLabels [ i ] . label ) ; <nl> + const int value = ( kLabels [ i ] . size + scale - 1 ) / scale ; <nl> + assert ( skip > 0 ) ; <nl> + printf ( " % s \ % * s : % 6d % s \ t [ % 5 . 2f % % ] [ count : % 7d ] \ n " , <nl> + kLabels [ i ] . label , skip , " " , value , units , <nl> + 100 . f * kLabels [ i ] . size / total , <nl> + kLabels [ i ] . count ) ; <nl> + } <nl> + total = ( total + scale - 1 ) / scale ; <nl> + printf ( " Total : % d % s \ n " , total , units ) ; <nl> + } <nl> + <nl> + void BitTrace ( const struct VP8BitReader * const br , const char label [ ] ) { <nl> + int i , pos ; <nl> + if ( ! init_done ) { <nl> + memset ( kLabels , 0 , sizeof ( kLabels ) ) ; <nl> + atexit ( PrintBitTraces ) ; <nl> + buf_start = br - > buf_ ; <nl> + init_done = 1 ; <nl> + } <nl> + pos = ( int ) ( br - > buf_ - buf_start ) * 8 - br - > bits_ ; <nl> + / / if there ' s a too large jump , we ' ve changed partition - > reset counter <nl> + if ( abs ( pos - last_pos ) > 32 ) { <nl> + buf_start = br - > buf_ ; <nl> + pos = 0 ; <nl> + last_pos = 0 ; <nl> + } <nl> + if ( br - > range_ > = 0x7f ) pos + = kVP8Log2Range [ br - > range_ - 0x7f ] ; <nl> + for ( i = 0 ; i < last_label ; + + i ) { <nl> + if ( ! strcmp ( label , kLabels [ i ] . label ) ) break ; <nl> + } <nl> + if ( i = = MAX_NUM_LABELS ) abort ( ) ; / / overflow ! <nl> + kLabels [ i ] . label = label ; <nl> + kLabels [ i ] . size + = pos - last_pos ; <nl> + kLabels [ i ] . count + = 1 ; <nl> + if ( i = = last_label ) + + last_label ; <nl> + last_pos = pos ; <nl> + } <nl> + <nl> + # endif / / BITTRACE > 0 <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> mmm a / 3rdparty / libwebp / src / utils / bit_reader_utils . h <nl> ppp b / 3rdparty / libwebp / src / utils / bit_reader_utils . h <nl> <nl> # endif <nl> # include " src / webp / types . h " <nl> <nl> + / / Warning ! This macro triggers quite some MACRO wizardry around func signature ! <nl> + # if ! defined ( BITTRACE ) <nl> + # define BITTRACE 0 / / 0 = off , 1 = print bits , 2 = print bytes <nl> + # endif <nl> + <nl> + # if ( BITTRACE > 0 ) <nl> + struct VP8BitReader ; <nl> + extern void BitTrace ( const struct VP8BitReader * const br , const char label [ ] ) ; <nl> + # define BT_TRACK ( br ) BitTrace ( br , label ) <nl> + # define VP8Get ( BR , L ) VP8GetValue ( BR , 1 , L ) <nl> + # else <nl> + # define BT_TRACK ( br ) <nl> + / / We ' ll REMOVE the ' const char label [ ] ' from all signatures and calls ( ! ! ) : <nl> + # define VP8GetValue ( BR , N , L ) VP8GetValue ( BR , N ) <nl> + # define VP8Get ( BR , L ) VP8GetValue ( BR , 1 , L ) <nl> + # define VP8GetSignedValue ( BR , N , L ) VP8GetSignedValue ( BR , N ) <nl> + # define VP8GetBit ( BR , P , L ) VP8GetBit ( BR , P ) <nl> + # define VP8GetBitAlt ( BR , P , L ) VP8GetBitAlt ( BR , P ) <nl> + # define VP8GetSigned ( BR , V , L ) VP8GetSigned ( BR , V ) <nl> + # endif <nl> + <nl> # ifdef __cplusplus <nl> extern " C " { <nl> # endif <nl> void VP8BitReaderSetBuffer ( VP8BitReader * const br , <nl> void VP8RemapBitReader ( VP8BitReader * const br , ptrdiff_t offset ) ; <nl> <nl> / / return the next value made of ' num_bits ' bits <nl> - uint32_t VP8GetValue ( VP8BitReader * const br , int num_bits ) ; <nl> - static WEBP_INLINE uint32_t VP8Get ( VP8BitReader * const br ) { <nl> - return VP8GetValue ( br , 1 ) ; <nl> - } <nl> + uint32_t VP8GetValue ( VP8BitReader * const br , int num_bits , const char label [ ] ) ; <nl> <nl> / / return the next value with sign - extension . <nl> - int32_t VP8GetSignedValue ( VP8BitReader * const br , int num_bits ) ; <nl> + int32_t VP8GetSignedValue ( VP8BitReader * const br , int num_bits , <nl> + const char label [ ] ) ; <nl> <nl> / / bit_reader_inl . h will implement the following methods : <nl> - / / static WEBP_INLINE int VP8GetBit ( VP8BitReader * const br , int prob ) <nl> - / / static WEBP_INLINE int VP8GetSigned ( VP8BitReader * const br , int v ) <nl> + / / static WEBP_INLINE int VP8GetBit ( VP8BitReader * const br , int prob , . . . ) <nl> + / / static WEBP_INLINE int VP8GetSigned ( VP8BitReader * const br , int v , . . . ) <nl> / / and should be included by the . c files that actually need them . <nl> / / This is to avoid recompiling the whole library whenever this file is touched , <nl> / / and also allowing platform - specific ad - hoc hacks . <nl> mmm a / 3rdparty / libwebp / src / utils / bit_writer_utils . c <nl> ppp b / 3rdparty / libwebp / src / utils / bit_writer_utils . c <nl> static void Flush ( VP8BitWriter * const bw ) { <nl> const int value = ( bits & 0x100 ) ? 0x00 : 0xff ; <nl> for ( ; bw - > run_ > 0 ; - - bw - > run_ ) bw - > buf_ [ pos + + ] = value ; <nl> } <nl> - bw - > buf_ [ pos + + ] = bits ; <nl> + bw - > buf_ [ pos + + ] = bits & 0xff ; <nl> bw - > pos_ = pos ; <nl> } else { <nl> bw - > run_ + + ; / / delay writing of bytes 0xff , pending eventual carry . <nl> mmm a / 3rdparty / libwebp / src / utils / color_cache_utils . h <nl> ppp b / 3rdparty / libwebp / src / utils / color_cache_utils . h <nl> <nl> <nl> # include < assert . h > <nl> <nl> + # include " src / dsp / dsp . h " <nl> # include " src / webp / types . h " <nl> <nl> # ifdef __cplusplus <nl> typedef struct { <nl> int hash_bits_ ; <nl> } VP8LColorCache ; <nl> <nl> - static const uint64_t kHashMul = 0x1e35a7bdull ; <nl> + static const uint32_t kHashMul = 0x1e35a7bdu ; <nl> <nl> - static WEBP_INLINE int VP8LHashPix ( uint32_t argb , int shift ) { <nl> - return ( int ) ( ( ( argb * kHashMul ) & 0xffffffffu ) > > shift ) ; <nl> + static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE <nl> + int VP8LHashPix ( uint32_t argb , int shift ) { <nl> + return ( int ) ( ( argb * kHashMul ) > > shift ) ; <nl> } <nl> <nl> static WEBP_INLINE uint32_t VP8LColorCacheLookup ( <nl> mmm a / 3rdparty / libwebp / src / utils / huffman_utils . c <nl> ppp b / 3rdparty / libwebp / src / utils / huffman_utils . c <nl> static int BuildHuffmanTable ( HuffmanCode * const root_table , int root_bits , <nl> <nl> assert ( code_lengths_size ! = 0 ) ; <nl> assert ( code_lengths ! = NULL ) ; <nl> - assert ( root_table ! = NULL ) ; <nl> + assert ( ( root_table ! = NULL & & sorted ! = NULL ) | | <nl> + ( root_table = = NULL & & sorted = = NULL ) ) ; <nl> assert ( root_bits > 0 ) ; <nl> <nl> / / Build histogram of code lengths . <nl> static int BuildHuffmanTable ( HuffmanCode * const root_table , int root_bits , <nl> for ( symbol = 0 ; symbol < code_lengths_size ; + + symbol ) { <nl> const int symbol_code_length = code_lengths [ symbol ] ; <nl> if ( code_lengths [ symbol ] > 0 ) { <nl> - sorted [ offset [ symbol_code_length ] + + ] = symbol ; <nl> + if ( sorted ! = NULL ) { <nl> + sorted [ offset [ symbol_code_length ] + + ] = symbol ; <nl> + } else { <nl> + offset [ symbol_code_length ] + + ; <nl> + } <nl> } <nl> } <nl> <nl> / / Special case code with only one value . <nl> if ( offset [ MAX_ALLOWED_CODE_LENGTH ] = = 1 ) { <nl> - HuffmanCode code ; <nl> - code . bits = 0 ; <nl> - code . value = ( uint16_t ) sorted [ 0 ] ; <nl> - ReplicateValue ( table , 1 , total_size , code ) ; <nl> + if ( sorted ! = NULL ) { <nl> + HuffmanCode code ; <nl> + code . bits = 0 ; <nl> + code . value = ( uint16_t ) sorted [ 0 ] ; <nl> + ReplicateValue ( table , 1 , total_size , code ) ; <nl> + } <nl> return total_size ; <nl> } <nl> <nl> static int BuildHuffmanTable ( HuffmanCode * const root_table , int root_bits , <nl> if ( num_open < 0 ) { <nl> return 0 ; <nl> } <nl> + if ( root_table = = NULL ) continue ; <nl> for ( ; count [ len ] > 0 ; - - count [ len ] ) { <nl> HuffmanCode code ; <nl> code . bits = ( uint8_t ) len ; <nl> static int BuildHuffmanTable ( HuffmanCode * const root_table , int root_bits , <nl> if ( num_open < 0 ) { <nl> return 0 ; <nl> } <nl> + if ( root_table = = NULL ) continue ; <nl> for ( ; count [ len ] > 0 ; - - count [ len ] ) { <nl> HuffmanCode code ; <nl> if ( ( key & mask ) ! = low ) { <nl> int VP8LBuildHuffmanTable ( HuffmanCode * const root_table , int root_bits , <nl> const int code_lengths [ ] , int code_lengths_size ) { <nl> int total_size ; <nl> assert ( code_lengths_size < = MAX_CODE_LENGTHS_SIZE ) ; <nl> - if ( code_lengths_size < = SORTED_SIZE_CUTOFF ) { <nl> + if ( root_table = = NULL ) { <nl> + total_size = BuildHuffmanTable ( NULL , root_bits , <nl> + code_lengths , code_lengths_size , NULL ) ; <nl> + } else if ( code_lengths_size < = SORTED_SIZE_CUTOFF ) { <nl> / / use local stack - allocated array . <nl> uint16_t sorted [ SORTED_SIZE_CUTOFF ] ; <nl> total_size = BuildHuffmanTable ( root_table , root_bits , <nl> mmm a / 3rdparty / libwebp / src / utils / huffman_utils . h <nl> ppp b / 3rdparty / libwebp / src / utils / huffman_utils . h <nl> void VP8LHtreeGroupsFree ( HTreeGroup * const htree_groups ) ; <nl> / / the huffman table . <nl> / / Returns built table size or 0 in case of error ( invalid tree or <nl> / / memory error ) . <nl> + / / If root_table is NULL , it returns 0 if a lookup cannot be built , something <nl> + / / > 0 otherwise ( but not the table size ) . <nl> int VP8LBuildHuffmanTable ( HuffmanCode * const root_table , int root_bits , <nl> const int code_lengths [ ] , int code_lengths_size ) ; <nl> <nl> mmm a / 3rdparty / libwebp / src / utils / rescaler_utils . c <nl> ppp b / 3rdparty / libwebp / src / utils / rescaler_utils . c <nl> int WebPRescalerGetScaledDimensions ( int src_width , int src_height , <nl> int height = * scaled_height ; <nl> <nl> / / if width is unspecified , scale original proportionally to height ratio . <nl> - if ( width = = 0 ) { <nl> + if ( width = = 0 & & src_height > 0 ) { <nl> width = <nl> - ( int ) ( ( ( uint64_t ) src_width * height + src_height / 2 ) / src_height ) ; <nl> + ( int ) ( ( ( uint64_t ) src_width * height + src_height - 1 ) / src_height ) ; <nl> } <nl> / / if height is unspecified , scale original proportionally to width ratio . <nl> - if ( height = = 0 ) { <nl> + if ( height = = 0 & & src_width > 0 ) { <nl> height = <nl> - ( int ) ( ( ( uint64_t ) src_height * width + src_width / 2 ) / src_width ) ; <nl> + ( int ) ( ( ( uint64_t ) src_height * width + src_width - 1 ) / src_width ) ; <nl> } <nl> / / Check if the overall dimensions still make sense . <nl> if ( width < = 0 | | height < = 0 ) { <nl> mmm a / 3rdparty / libwebp / src / utils / thread_utils . c <nl> ppp b / 3rdparty / libwebp / src / utils / thread_utils . c <nl> static THREADFN ThreadLoop ( void * ptr ) { <nl> done = 1 ; <nl> } <nl> / / signal to the main thread that we ' re done ( for Sync ( ) ) <nl> - pthread_cond_signal ( & impl - > condition_ ) ; <nl> + / / Note the associated mutex does not need to be held when signaling the <nl> + / / condition . Unlocking the mutex first may improve performance in some <nl> + / / implementations , avoiding the case where the waiting thread can ' t <nl> + / / reacquire the mutex when woken . <nl> pthread_mutex_unlock ( & impl - > mutex_ ) ; <nl> + pthread_cond_signal ( & impl - > condition_ ) ; <nl> } <nl> return THREAD_RETURN ( NULL ) ; / / Thread is finished <nl> } <nl> static void ChangeState ( WebPWorker * const worker , WebPWorkerStatus new_status ) { <nl> / / assign new status and release the working thread if needed <nl> if ( new_status ! = OK ) { <nl> worker - > status_ = new_status ; <nl> + / / Note the associated mutex does not need to be held when signaling the <nl> + / / condition . Unlocking the mutex first may improve performance in some <nl> + / / implementations , avoiding the case where the waiting thread can ' t <nl> + / / reacquire the mutex when woken . <nl> + pthread_mutex_unlock ( & impl - > mutex_ ) ; <nl> pthread_cond_signal ( & impl - > condition_ ) ; <nl> + return ; <nl> } <nl> } <nl> pthread_mutex_unlock ( & impl - > mutex_ ) ; <nl> mmm a / 3rdparty / libwebp / src / utils / utils . h <nl> ppp b / 3rdparty / libwebp / src / utils / utils . h <nl> static WEBP_INLINE uint32_t GetLE32 ( const uint8_t * const data ) { <nl> / / Store 16 , 24 or 32 bits in little - endian order . <nl> static WEBP_INLINE void PutLE16 ( uint8_t * const data , int val ) { <nl> assert ( val < ( 1 < < 16 ) ) ; <nl> - data [ 0 ] = ( val > > 0 ) ; <nl> - data [ 1 ] = ( val > > 8 ) ; <nl> + data [ 0 ] = ( val > > 0 ) & 0xff ; <nl> + data [ 1 ] = ( val > > 8 ) & 0xff ; <nl> } <nl> <nl> static WEBP_INLINE void PutLE24 ( uint8_t * const data , int val ) { <nl> assert ( val < ( 1 < < 24 ) ) ; <nl> PutLE16 ( data , val & 0xffff ) ; <nl> - data [ 2 ] = ( val > > 16 ) ; <nl> + data [ 2 ] = ( val > > 16 ) & 0xff ; <nl> } <nl> <nl> static WEBP_INLINE void PutLE32 ( uint8_t * const data , uint32_t val ) { <nl> mmm a / 3rdparty / libwebp / src / webp / encode . h <nl> ppp b / 3rdparty / libwebp / src / webp / encode . h <nl> WEBP_EXTERN size_t WebPEncodeBGRA ( const uint8_t * bgra , <nl> / / These functions are the equivalent of the above , but compressing in a <nl> / / lossless manner . Files are usually larger than lossy format , but will <nl> / / not suffer any compression loss . <nl> + / / Note these functions , like the lossy versions , use the library ' s default <nl> + / / settings . For lossless this means ' exact ' is disabled . RGB values in <nl> + / / transparent areas will be modified to improve compression . To avoid this , <nl> + / / use WebPEncode ( ) and set WebPConfig : : exact to 1 . <nl> WEBP_EXTERN size_t WebPEncodeLosslessRGB ( const uint8_t * rgb , <nl> int width , int height , int stride , <nl> uint8_t * * output ) ; <nl>
Merge pull request from alalek : update_libwebp_1 . 0 . 3
opencv/opencv
60f81032bb4438d742caad93415874299ccfd013
2019-12-13T14:54:42Z
mmm a / tensorflow / python / ops / distributions / exponential . py <nl> ppp b / tensorflow / python / ops / distributions / exponential . py <nl> def __init__ ( self , <nl> allow_nan_stats = allow_nan_stats , <nl> validate_args = validate_args , <nl> name = name ) <nl> - # While the Gamma distribution is not reparameterizable , the exponential <nl> - # distribution is . <nl> - self . _reparameterization_type = True <nl> self . _parameters = parameters <nl> self . _graph_parents + = [ self . _rate ] <nl> <nl>
Remove unnecessary reparameterization_type specification for tf . distributions . Exponential .
tensorflow/tensorflow
1695dd95ee7750e355ac64d527ff75fb5ecbbdc7
2018-06-27T15:45:08Z
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> ERROR ( property_wrapper_wrong_initial_value_init , none , <nl> ( DeclName , Type , Type ) ) <nl> ERROR ( property_wrapper_failable_init , none , <nl> " % 0 cannot be failable " , ( DeclName ) ) <nl> - ERROR ( property_wrapper_ambiguous_default_value_init , none , <nl> - " property wrapper type % 0 has multiple default - value initializers " , ( Type ) ) <nl> ERROR ( property_wrapper_type_requirement_not_accessible , none , <nl> " % select { private | fileprivate | internal | public | open } 0 % 1 % 2 cannot have " <nl> " more restrictive access than its enclosing property wrapper type % 3 " <nl> mmm a / include / swift / AST / PropertyWrappers . h <nl> ppp b / include / swift / AST / PropertyWrappers . h <nl> struct PropertyWrapperTypeInfo { <nl> HasInitialValueInit <nl> } wrappedValueInit = NoWrappedValueInit ; <nl> <nl> - / / / The initializer ` init ( ) ` that will be called to default - initialize a <nl> + / / / The initializer that will be called to default - initialize a <nl> / / / value with an attached property wrapper . <nl> - ConstructorDecl * defaultInit = nullptr ; <nl> + enum { <nl> + NoDefaultValueInit = 0 , <nl> + HasDefaultValueInit <nl> + } defaultInit = NoDefaultValueInit ; <nl> <nl> / / / The property through which the projection value ( $ foo ) will be accessed . <nl> / / / <nl> mmm a / lib / Sema / TypeCheckPropertyWrapper . cpp <nl> ppp b / lib / Sema / TypeCheckPropertyWrapper . cpp <nl> <nl> # include " swift / AST / TypeCheckRequests . h " <nl> using namespace swift ; <nl> <nl> + / / / The kind of property initializer to look for <nl> + enum class PropertyWrapperInitKind { <nl> + / / / An initial - value initializer ( i . e . ` init ( initialValue : ) ` ) <nl> + InitialValue , <nl> + / / / An wrapped - value initializer ( i . e . ` init ( wrappedValue : ) ` ) <nl> + WrappedValue , <nl> + / / / An default - value initializer ( i . e . ` init ( ) ` or ` init ( defaultArgs . . . ) ` ) <nl> + Default <nl> + } ; <nl> + <nl> / / / Find the named property in a property wrapper to which access will <nl> / / / be delegated . <nl> static VarDecl * findValueProperty ( ASTContext & ctx , NominalTypeDecl * nominal , <nl> static VarDecl * findValueProperty ( ASTContext & ctx , NominalTypeDecl * nominal , <nl> return var ; <nl> } <nl> <nl> - / / / Determine whether we have a suitable wrapped - value initializer within <nl> - / / / a property wrapper type . <nl> - static ConstructorDecl * findInitialValueInit ( <nl> - ASTContext & ctx , <nl> - NominalTypeDecl * nominal , <nl> - VarDecl * valueVar , <nl> - Identifier argumentLabel ) { <nl> - / / Retrieve the type of the ' value ' property . <nl> - Type valueVarType = valueVar - > getValueInterfaceType ( ) ; <nl> - <nl> + / / / Determine whether we have a suitable initializer within a property wrapper <nl> + / / / type . <nl> + static ConstructorDecl * <nl> + findSuitableWrapperInit ( ASTContext & ctx , NominalTypeDecl * nominal , <nl> + VarDecl * valueVar , PropertyWrapperInitKind initKind ) { <nl> enum class NonViableReason { <nl> Failable , <nl> ParameterTypeMismatch , <nl> Inaccessible , <nl> } ; <nl> - SmallVector < std : : tuple < ConstructorDecl * , NonViableReason , Type > , 2 > nonviable ; <nl> - SmallVector < ConstructorDecl * , 2 > initialValueInitializers ; <nl> <nl> + SmallVector < std : : tuple < ConstructorDecl * , NonViableReason , Type > , 2 > <nl> + nonviable ; <nl> + SmallVector < ConstructorDecl * , 2 > viableInitializers ; <nl> SmallVector < ValueDecl * , 2 > decls ; <nl> + <nl> + Identifier argumentLabel ; <nl> + switch ( initKind ) { <nl> + case PropertyWrapperInitKind : : InitialValue : <nl> + argumentLabel = ctx . Id_initialValue ; <nl> + break ; <nl> + case PropertyWrapperInitKind : : WrappedValue : <nl> + argumentLabel = ctx . Id_wrappedValue ; <nl> + break ; <nl> + case PropertyWrapperInitKind : : Default : <nl> + break ; <nl> + } <nl> + <nl> nominal - > lookupQualified ( nominal , DeclBaseName : : createConstructor ( ) , <nl> NL_QualifiedDefault , decls ) ; <nl> for ( const auto & decl : decls ) { <nl> auto init = dyn_cast < ConstructorDecl > ( decl ) ; <nl> - if ( ! init | | init - > getDeclContext ( ) ! = nominal | | init - > getGenericParams ( ) ) <nl> + if ( ! init | | init - > getDeclContext ( ) ! = nominal | | init - > isGeneric ( ) ) <nl> continue ; <nl> <nl> + ParamDecl * argumentParam = nullptr ; <nl> + bool allArgsDefault = true ; <nl> / / Check whether every parameter meets one of the following criteria : <nl> / / ( 1 ) The parameter has a default argument , or <nl> / / ( 2 ) The parameter has the given argument label . <nl> - ParamDecl * wrappedValueParam = nullptr ; <nl> for ( auto param : * init - > getParameters ( ) ) { <nl> / / Recognize the first parameter with the requested argument label . <nl> - if ( param - > getArgumentName ( ) = = argumentLabel & & ! wrappedValueParam ) { <nl> - wrappedValueParam = param ; <nl> + if ( param - > getArgumentName ( ) = = argumentLabel & & ! argumentParam ) { <nl> + argumentParam = param ; <nl> continue ; <nl> } <nl> <nl> - if ( param - > isDefaultArgument ( ) ) <nl> + if ( param - > isDefaultArgument ( ) ) { <nl> + allArgsDefault & = true ; <nl> continue ; <nl> - <nl> - / / Forget we had a match . <nl> - wrappedValueParam = nullptr ; <nl> - break ; <nl> + } else { <nl> + / / Forget we had a match . <nl> + allArgsDefault = false ; <nl> + argumentParam = nullptr ; <nl> + break ; <nl> + } <nl> } <nl> <nl> - if ( ! wrappedValueParam ) <nl> + if ( initKind ! = PropertyWrapperInitKind : : Default & & ! argumentParam ) <nl> continue ; <nl> <nl> + if ( initKind = = PropertyWrapperInitKind : : Default & & ! allArgsDefault ) { <nl> + continue ; <nl> + } <nl> + <nl> / / Failable initializers cannot be used . <nl> if ( init - > isFailable ( ) ) { <nl> nonviable . push_back ( <nl> static ConstructorDecl * findInitialValueInit ( <nl> continue ; <nl> } <nl> <nl> - if ( ! wrappedValueParam - > hasInterfaceType ( ) ) <nl> - continue ; <nl> + / / Additional checks for initial - value and wrapped - value initializers <nl> + if ( initKind ! = PropertyWrapperInitKind : : Default ) { <nl> + if ( ! argumentParam ) <nl> + continue ; <nl> <nl> - if ( wrappedValueParam - > isInOut ( ) | | wrappedValueParam - > isVariadic ( ) ) <nl> - continue ; <nl> + if ( ! argumentParam - > hasInterfaceType ( ) ) <nl> + continue ; <nl> <nl> - auto paramType = wrappedValueParam - > getInterfaceType ( ) ; <nl> - if ( wrappedValueParam - > isAutoClosure ( ) ) { <nl> - if ( auto * fnType = paramType - > getAs < FunctionType > ( ) ) <nl> - paramType = fnType - > getResult ( ) ; <nl> - } <nl> + if ( argumentParam - > isInOut ( ) | | argumentParam - > isVariadic ( ) ) <nl> + continue ; <nl> <nl> - / / The parameter type must be the same as the type of ` valueVar ` or an <nl> - / / autoclosure thereof . <nl> - if ( ! paramType - > isEqual ( valueVarType ) ) { <nl> - nonviable . push_back ( <nl> - std : : make_tuple ( init , NonViableReason : : ParameterTypeMismatch , <nl> - paramType ) ) ; <nl> - continue ; <nl> + auto paramType = argumentParam - > getInterfaceType ( ) ; <nl> + if ( argumentParam - > isAutoClosure ( ) ) { <nl> + if ( auto * fnType = paramType - > getAs < FunctionType > ( ) ) <nl> + paramType = fnType - > getResult ( ) ; <nl> + } <nl> + <nl> + / / The parameter type must be the same as the type of ` valueVar ` or an <nl> + / / autoclosure thereof . <nl> + if ( ! paramType - > isEqual ( valueVarType ) ) { <nl> + nonviable . push_back ( std : : make_tuple ( <nl> + init , NonViableReason : : ParameterTypeMismatch , paramType ) ) ; <nl> + continue ; <nl> + } <nl> } <nl> <nl> - / / Check the type <nl> - initialValueInitializers . push_back ( init ) ; <nl> + viableInitializers . push_back ( init ) ; <nl> } <nl> <nl> / / If we found some nonviable candidates but no viable ones , complain . <nl> - if ( initialValueInitializers . empty ( ) & & ! nonviable . empty ( ) ) { <nl> + if ( viableInitializers . empty ( ) & & ! nonviable . empty ( ) ) { <nl> for ( const auto & candidate : nonviable ) { <nl> auto init = std : : get < 0 > ( candidate ) ; <nl> auto reason = std : : get < 1 > ( candidate ) ; <nl> static ConstructorDecl * findInitialValueInit ( <nl> <nl> case NonViableReason : : ParameterTypeMismatch : <nl> init - > diagnose ( diag : : property_wrapper_wrong_initial_value_init , <nl> - init - > getFullName ( ) , paramType , valueVarType ) ; <nl> + init - > getFullName ( ) , paramType , <nl> + valueVar - > getValueInterfaceType ( ) ) ; <nl> valueVar - > diagnose ( diag : : decl_declared_here , valueVar - > getFullName ( ) ) ; <nl> break ; <nl> } <nl> } <nl> } <nl> <nl> - return initialValueInitializers . empty ( ) ? nullptr <nl> - : initialValueInitializers . front ( ) ; <nl> - } <nl> - <nl> - / / / Determine whether we have a suitable init ( ) within a property <nl> - / / / wrapper type . <nl> - static ConstructorDecl * findDefaultInit ( ASTContext & ctx , <nl> - NominalTypeDecl * nominal ) { <nl> - SmallVector < ConstructorDecl * , 2 > defaultValueInitializers ; <nl> - SmallVector < ValueDecl * , 2 > decls ; <nl> - auto initName = DeclBaseName : : createConstructor ( ) ; <nl> - nominal - > lookupQualified ( nominal , initName , NL_QualifiedDefault , decls ) ; <nl> - for ( const auto & decl : decls ) { <nl> - auto init = dyn_cast < ConstructorDecl > ( decl ) ; <nl> - if ( ! init | | init - > getDeclContext ( ) ! = nominal | | init - > isGeneric ( ) ) <nl> - continue ; <nl> - <nl> - assert ( init - > hasParameterList ( ) ) ; <nl> - / / A constructor which does not have any parameters or where all the <nl> - / / parameters have a default argument can be used to default initialize <nl> - / / the property wrapper type . <nl> - / / <nl> - / / A constructor with no parameters will satisfy the check below . <nl> - bool allParamsHaveDefaultArg = llvm : : all_of ( <nl> - init - > getParameters ( ) - > getArray ( ) , <nl> - [ ] ( const ParamDecl * decl ) { return decl - > isDefaultArgument ( ) ; } ) ; <nl> - <nl> - if ( allParamsHaveDefaultArg ) { <nl> - defaultValueInitializers . push_back ( init ) ; <nl> - } <nl> - } <nl> - <nl> - if ( defaultValueInitializers . size ( ) > 1 ) { <nl> - / / Let ' s find the single most specialized init . If we don ' t have one , then <nl> - / / we ' ll diagnose later . <nl> - if ( auto TC = static_cast < TypeChecker * > ( ctx . getLazyResolver ( ) ) ) { <nl> - Optional < unsigned > bestIdx ; <nl> - for ( unsigned i = 1 , n = defaultValueInitializers . size ( ) ; i ! = n ; + + i ) { <nl> - auto bestOrPrevIdx = bestIdx ? bestIdx . getValue ( ) : i - 1 ; <nl> - auto firstInit = <nl> - cast < ValueDecl > ( defaultValueInitializers [ bestOrPrevIdx ] ) ; <nl> - auto secondInit = cast < ValueDecl > ( defaultValueInitializers [ i ] ) ; <nl> - <nl> - switch ( TC - > compareDeclarations ( nominal , firstInit , secondInit ) ) { <nl> - case Comparison : : Better : <nl> - bestIdx = bestOrPrevIdx ; <nl> - break ; <nl> - case Comparison : : Worse : <nl> - bestIdx = i ; <nl> - break ; <nl> - case Comparison : : Unordered : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - if ( bestIdx . hasValue ( ) ) { <nl> - auto bestInit = defaultValueInitializers [ bestIdx . getValue ( ) ] ; <nl> - defaultValueInitializers = { bestInit } ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - switch ( defaultValueInitializers . size ( ) ) { <nl> - case 0 : <nl> - return nullptr ; <nl> - <nl> - case 1 : <nl> - break ; <nl> - <nl> - default : <nl> - / / Diagnose ambiguous default value initializers . <nl> - nominal - > diagnose ( diag : : property_wrapper_ambiguous_default_value_init , <nl> - nominal - > getDeclaredType ( ) ) ; <nl> - for ( auto init : defaultValueInitializers ) { <nl> - init - > diagnose ( diag : : kind_declname_declared_here , <nl> - init - > getDescriptiveKind ( ) , init - > getFullName ( ) ) ; <nl> - } <nl> - return nullptr ; <nl> - } <nl> - <nl> - / / The initializer must be as accessible as the nominal type . <nl> - auto init = defaultValueInitializers . front ( ) ; <nl> - if ( init - > getFormalAccess ( ) < nominal - > getFormalAccess ( ) ) { <nl> - init - > diagnose ( diag : : property_wrapper_type_requirement_not_accessible , <nl> - init - > getFormalAccess ( ) , init - > getDescriptiveKind ( ) , <nl> - init - > getFullName ( ) , nominal - > getDeclaredType ( ) , <nl> - nominal - > getFormalAccess ( ) ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - / / The initializer must not be failable . <nl> - if ( init - > isFailable ( ) ) { <nl> - init - > diagnose ( diag : : property_wrapper_failable_init , initName ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> - return init ; <nl> + return viableInitializers . empty ( ) ? nullptr : viableInitializers . front ( ) ; <nl> } <nl> <nl> / / / Determine whether we have a suitable static subscript to which we <nl> PropertyWrapperTypeInfoRequest : : evaluate ( <nl> <nl> PropertyWrapperTypeInfo result ; <nl> result . valueVar = valueVar ; <nl> - if ( findInitialValueInit ( ctx , nominal , valueVar , ctx . Id_wrappedValue ) ) <nl> + if ( findSuitableWrapperInit ( ctx , nominal , valueVar , <nl> + PropertyWrapperInitKind : : WrappedValue ) ) <nl> result . wrappedValueInit = PropertyWrapperTypeInfo : : HasWrappedValueInit ; <nl> - else if ( auto init = findInitialValueInit ( <nl> - ctx , nominal , valueVar , ctx . Id_initialValue ) ) { <nl> + else if ( auto init = findSuitableWrapperInit ( <nl> + ctx , nominal , valueVar , PropertyWrapperInitKind : : InitialValue ) ) { <nl> result . wrappedValueInit = PropertyWrapperTypeInfo : : HasInitialValueInit ; <nl> <nl> if ( init - > getLoc ( ) . isValid ( ) ) { <nl> PropertyWrapperTypeInfoRequest : : evaluate ( <nl> } <nl> } <nl> <nl> - result . defaultInit = findDefaultInit ( ctx , nominal ) ; <nl> + if ( findSuitableWrapperInit ( ctx , nominal , / * valueVar = * / nullptr , <nl> + PropertyWrapperInitKind : : Default ) ) { <nl> + result . defaultInit = PropertyWrapperTypeInfo : : HasDefaultValueInit ; <nl> + } <nl> + <nl> result . projectedValueVar = <nl> findValueProperty ( ctx , nominal , ctx . Id_projectedValue , <nl> / * allowMissing = * / true ) ; <nl> mmm a / test / decl / var / property_wrappers . swift <nl> ppp b / test / decl / var / property_wrappers . swift <nl> struct TestConcrete1 { <nl> / / Two initializers that can default initialize the wrapper / / <nl> <nl> @ propertyWrapper <nl> - struct SR_11477_W1 { / / Okay , because we ' ll pick the best one here <nl> + struct SR_11477_W1 { / / Okay <nl> let name : String <nl> <nl> init ( ) { <nl> struct SR_11477_W1 { / / Okay , because we ' ll pick the best one here <nl> / / Two initializers with default arguments that can default initialize the wrapper / / <nl> <nl> @ propertyWrapper <nl> - struct SR_11477_W2 { / / expected - error { { property wrapper type ' SR_11477_W2 ' has multiple default - value initializers } } <nl> + struct SR_11477_W2 { / / Okay <nl> let name : String <nl> <nl> - init ( anotherName : String = " DefaultParamInit " ) { } / / expected - note { { initializer ' init ( anotherName : ) ' declared here } } <nl> + init ( anotherName : String = " DefaultParamInit1 " ) { <nl> + self . name = anotherName <nl> + } <nl> <nl> - init ( name : String = " DefaultParamInit " ) { / / expected - note { { initializer ' init ( name : ) ' declared here } } <nl> + init ( name : String = " DefaultParamInit2 " ) { <nl> self . name = name <nl> } <nl> <nl>
[ PropertyWrappers ] Merge ' findDefaultInit ' and ' findInitialValueInit ' methods into a single ' findSuitableWrapperInit ' method
apple/swift
370f47c27a80a12e8ddb73c586782825cd883c22
2019-10-11T21:25:46Z
mmm a / src / dbg / dbghelp_safe . cpp <nl> ppp b / src / dbg / dbghelp_safe . cpp <nl> SafeSymEnumSymbols ( <nl> return SymEnumSymbols ( hProcess , BaseOfDll , Mask , EnumSymbolsCallback , UserContext ) ; <nl> } <nl> BOOL <nl> - SafeSymEnumerateModules64 ( <nl> - __in HANDLE hProcess , <nl> - __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback , <nl> - __in_opt PVOID UserContext <nl> - ) <nl> - { <nl> - EXCLUSIVE_ACQUIRE ( LockSym ) ; <nl> - return SymEnumerateModules64 ( hProcess , EnumModulesCallback , UserContext ) ; <nl> - } <nl> - BOOL <nl> SafeSymGetLineFromAddrW64 ( <nl> __in HANDLE hProcess , <nl> __in DWORD64 qwAddr , <nl> mmm a / src / dbg / dbghelp_safe . h <nl> ppp b / src / dbg / dbghelp_safe . h <nl> SafeSymEnumSymbols ( <nl> __in_opt PVOID UserContext <nl> ) ; <nl> BOOL <nl> - SafeSymEnumerateModules64 ( <nl> - __in HANDLE hProcess , <nl> - __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback , <nl> - __in_opt PVOID UserContext <nl> - ) ; <nl> - BOOL <nl> SafeSymGetLineFromAddrW64 ( <nl> __in HANDLE hProcess , <nl> __in DWORD64 qwAddr , <nl> mmm a / src / dbg / symbolinfo . cpp <nl> ppp b / src / dbg / symbolinfo . cpp <nl> void SymEnumFromCache ( duint Base , CBSYMBOLENUM EnumCallback , void * UserData ) <nl> <nl> bool SymGetModuleList ( std : : vector < SYMBOLMODULEINFO > * List ) <nl> { <nl> - / / <nl> - / / Inline lambda enum <nl> - / / <nl> - auto EnumModules = [ ] ( LPCTSTR ModuleName , DWORD64 BaseOfDll , PVOID UserContext ) - > BOOL <nl> - { <nl> - SYMBOLMODULEINFO curModule ; <nl> - curModule . base = ( duint ) BaseOfDll ; <nl> - <nl> - / / Terminate module name if one isn ' t found <nl> - if ( ! ModNameFromAddr ( curModule . base , curModule . name , true ) ) <nl> - curModule . name [ 0 ] = ' \ 0 ' ; <nl> - <nl> - ( ( std : : vector < SYMBOLMODULEINFO > * ) UserContext ) - > push_back ( curModule ) ; <nl> - return TRUE ; <nl> - } ; <nl> - <nl> - / / Execute the symbol enumerator ( Force cast to STDCALL ) <nl> - if ( ! SafeSymEnumerateModules64 ( fdProcessInfo - > hProcess , EnumModules , List ) ) <nl> + std : : vector < MODINFO > modList ; <nl> + ModGetList ( modList ) ; <nl> + for ( auto & mod : modList ) <nl> { <nl> - dputs ( QT_TRANSLATE_NOOP ( " DBG " , " SymEnumerateModules64 failed ! " ) ) ; <nl> - return false ; <nl> + SYMBOLMODULEINFO curMod ; <nl> + curMod . base = mod . base ; <nl> + strcpy_s ( curMod . name , mod . name ) ; <nl> + strcat_s ( curMod . name , mod . extension ) ; <nl> + List - > push_back ( curMod ) ; <nl> } <nl> - <nl> return true ; <nl> } <nl> <nl>
DBG : remove redundant SymEnumerateModules64 dbghelp import
x64dbg/x64dbg
9d71bd3b739b1a82121287d7b768ef6b4fe90fd5
2017-03-01T22:24:00Z
mmm a / src / runtime / ext / ext_string . ext_hhvm . cpp <nl> ppp b / src / runtime / ext / ext_string . ext_hhvm . cpp <nl> TypedValue * fg_strrchr ( HPHP : : VM : : ActRec * ar ) { <nl> <nl> <nl> / * <nl> - HPHP : : Variant HPHP : : f_strstr ( HPHP : : String const & , HPHP : : Variant const & ) <nl> - _ZN4HPHP8f_strstrERKNS_6StringERKNS_7VariantE <nl> + HPHP : : Variant HPHP : : f_strstr ( HPHP : : String const & , HPHP : : Variant const & , bool ) <nl> + _ZN4HPHP8f_strstrERKNS_6StringERKNS_7VariantEb <nl> <nl> ( return value ) = > rax <nl> _rv = > rdi <nl> haystack = > rsi <nl> needle = > rdx <nl> + before_needle = > rcx <nl> * / <nl> <nl> - TypedValue * fh_strstr ( TypedValue * _rv , Value * haystack , TypedValue * needle ) asm ( " _ZN4HPHP8f_strstrERKNS_6StringERKNS_7VariantE " ) ; <nl> + TypedValue * fh_strstr ( TypedValue * _rv , Value * haystack , TypedValue * needle , bool before_needle ) asm ( " _ZN4HPHP8f_strstrERKNS_6StringERKNS_7VariantEb " ) ; <nl> <nl> TypedValue * fg1_strstr ( TypedValue * rv , HPHP : : VM : : ActRec * ar , long long count ) __attribute__ ( ( noinline , cold ) ) ; <nl> TypedValue * fg1_strstr ( TypedValue * rv , HPHP : : VM : : ActRec * ar , long long count ) { <nl> TypedValue * args UNUSED = ( ( TypedValue * ) ar ) - 1 ; <nl> - tvCastToStringInPlace ( args - 0 ) ; <nl> - fh_strstr ( ( rv ) , ( Value * ) ( args - 0 ) , ( args - 1 ) ) ; <nl> + switch ( count ) { <nl> + default : / / count > = 3 <nl> + if ( ( args - 2 ) - > m_type ! = KindOfBoolean ) { <nl> + tvCastToBooleanInPlace ( args - 2 ) ; <nl> + } <nl> + case 2 : <nl> + break ; <nl> + } <nl> + if ( ! IS_STRING_TYPE ( ( args - 0 ) - > m_type ) ) { <nl> + tvCastToStringInPlace ( args - 0 ) ; <nl> + } <nl> + fh_strstr ( ( rv ) , ( Value * ) ( args - 0 ) , ( args - 1 ) , ( count > 2 ) ? ( bool ) ( args [ - 2 ] . m_data . num ) : ( bool ) ( false ) ) ; <nl> if ( rv - > m_type = = KindOfUninit ) rv - > m_type = KindOfNull ; <nl> return rv ; <nl> } <nl> TypedValue * fg_strstr ( HPHP : : VM : : ActRec * ar ) { <nl> TypedValue rv ; <nl> long long count = ar - > numArgs ( ) ; <nl> TypedValue * args UNUSED = ( ( TypedValue * ) ar ) - 1 ; <nl> - if ( count = = 2LL ) { <nl> - if ( IS_STRING_TYPE ( ( args - 0 ) - > m_type ) ) { <nl> - fh_strstr ( ( & ( rv ) ) , ( Value * ) ( args - 0 ) , ( args - 1 ) ) ; <nl> + if ( count > = 2LL & & count < = 3LL ) { <nl> + if ( ( count < = 2 | | ( args - 2 ) - > m_type = = KindOfBoolean ) & & IS_STRING_TYPE ( ( args - 0 ) - > m_type ) ) { <nl> + fh_strstr ( ( & ( rv ) ) , ( Value * ) ( args - 0 ) , ( args - 1 ) , ( count > 2 ) ? ( bool ) ( args [ - 2 ] . m_data . num ) : ( bool ) ( false ) ) ; <nl> if ( rv . m_type = = KindOfUninit ) rv . m_type = KindOfNull ; <nl> - frame_free_locals_no_this_inl ( ar , 2 ) ; <nl> + frame_free_locals_no_this_inl ( ar , 3 ) ; <nl> memcpy ( & ar - > m_r , & rv , sizeof ( TypedValue ) ) ; <nl> return & ar - > m_r ; <nl> } else { <nl> fg1_strstr ( & rv , ar , count ) ; <nl> - frame_free_locals_no_this_inl ( ar , 2 ) ; <nl> + frame_free_locals_no_this_inl ( ar , 3 ) ; <nl> memcpy ( & ar - > m_r , & rv , sizeof ( TypedValue ) ) ; <nl> return & ar - > m_r ; <nl> } <nl> } else { <nl> - throw_wrong_arguments_nr ( " strstr " , count , 2 , 2 , 1 ) ; <nl> + throw_wrong_arguments_nr ( " strstr " , count , 2 , 3 , 1 ) ; <nl> } <nl> rv . m_data . num = 0LL ; <nl> rv . _count = 0 ; <nl> rv . m_type = KindOfNull ; <nl> - frame_free_locals_no_this_inl ( ar , 2 ) ; <nl> + frame_free_locals_no_this_inl ( ar , 3 ) ; <nl> memcpy ( & ar - > m_r , & rv , sizeof ( TypedValue ) ) ; <nl> return & ar - > m_r ; <nl> EXCEPTION_GATE_RETURN ( & ar - > m_r ) ; <nl>
Update pregen source for ext_string hhvm build .
facebook/hhvm
5366fc671ec6c399f8098ea292af12859e24a376
2012-07-24T04:03:51Z
mmm a / lib / TBDGen / TBDGenVisitor . h <nl> ppp b / lib / TBDGen / TBDGenVisitor . h <nl> class TBDGenVisitor : public ASTVisitor < TBDGenVisitor > { <nl> / / HACK : ' main ' is a special symbol that ' s always emitted in SILGen if <nl> / / the file has an entry point . Since it doesn ' t show up in the <nl> / / module until SILGen , we need to explicitly add it here . <nl> - if ( file - > hasEntryPoint ( ) ) <nl> + / / <nl> + / / Make sure to only add the main symbol for the module that we ' re emitting <nl> + / / TBD for , and not for any statically linked libraries . <nl> + if ( file - > hasEntryPoint ( ) & & file - > getParentModule ( ) = = SwiftModule ) <nl> addSymbol ( " main " ) ; <nl> } <nl> <nl>
[ TBD ] Don ' t add main entrypoint for statically linked libs
apple/swift
12d14bbc1163411cc77629caa4b9526c25b3cc69
2020-02-14T04:44:39Z
mmm a / docs / api / tray . md <nl> ppp b / docs / api / tray . md <nl> Sets the title displayed aside of the tray icon in the status bar . <nl> <nl> Sets when the tray ' s icon background becomes highlighted ( in blue ) . <nl> <nl> + * * Note : * * You can use ` highlightMode ` with a [ ` BrowserWindow ` ] ( browser - window . md ) <nl> + by toggling between ` ' never ' ` and ` ' always ' ` modes when the window visibility <nl> + changes . <nl> + <nl> + ` ` ` js <nl> + const { BrowserWindow , Tray } = require ( ' electron ' ) <nl> + <nl> + const win = new BrowserWindow ( { width : 800 , height : 600 } ) <nl> + const tray = new Tray ( ' / path / to / my / icon ' ) <nl> + <nl> + tray . on ( ' click ' , ( ) = > { <nl> + win . isVisible ( ) ? win . hide ( ) : win . show ( ) <nl> + } ) <nl> + win . on ( ' show ' , ( ) = > { <nl> + tray . setHighlightMode ( ' always ' ) <nl> + } ) <nl> + win . on ( ' hide ' , ( ) = > { <nl> + tray . setHighlightMode ( ' never ' ) <nl> + } ) <nl> + ` ` ` <nl> + <nl> # # # # ` tray . displayBalloon ( options ) ` _Windows_ <nl> <nl> * ` options ` Object <nl>
Merge pull request from davej / patch - 1
electron/electron
34f33c3b45865a4321950ede3403170f82dbaebd
2016-07-27T22:57:34Z
mmm a / test / mjsunit / arguments . js <nl> ppp b / test / mjsunit / arguments . js <nl> function list_args ( a ) { <nl> } <nl> <nl> <nl> - function f1 ( x , y ) { <nl> + function f7 ( x , y ) { <nl> function g ( p ) { <nl> x = p ; <nl> } <nl> function f1 ( x , y ) { <nl> return list_args ( arguments ) ; <nl> } <nl> <nl> - assertArrayEquals ( [ 0 ] , f1 ( ) ) ; <nl> - assertArrayEquals ( [ 1 , void 0 ] , f1 ( 3 ) ) ; <nl> - assertArrayEquals ( [ 2 , 5 , 5 ] , f1 ( 3 , 5 ) ) ; <nl> - assertArrayEquals ( [ 3 , 5 , 5 , 7 ] , f1 ( 3 , 5 , 7 ) ) ; <nl> + assertArrayEquals ( [ 0 ] , f7 ( ) ) ; <nl> + assertArrayEquals ( [ 1 , void 0 ] , f7 ( 3 ) ) ; <nl> + assertArrayEquals ( [ 2 , 5 , 5 ] , f7 ( 3 , 5 ) ) ; <nl> + assertArrayEquals ( [ 3 , 5 , 5 , 7 ] , f7 ( 3 , 5 , 7 ) ) ; <nl> <nl> / / Check out of bounds behavior . <nl> function arg_get ( x ) { return arguments [ x ] ; } <nl>
Fix arguments . js test
v8/v8
dc778a3dc51b3c413c14f34070474c464021d38d
2017-07-25T07:58:13Z
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> NOTE ( suggest_partial_overloads , sema , none , <nl> " lists : % 1 " , ( StringRef , StringRef ) ) <nl> <nl> ERROR ( cannot_convert_to_return_type , sema , none , <nl> - " cannot convert return expression of type % 0 to expected return type % 1 " , <nl> + " cannot convert return expression of type % 0 to return type % 1 " , <nl> ( Type , Type ) ) <nl> <nl> ERROR ( cannot_return_value_from_void_func , sema , none , <nl> mmm a / test / Constraints / bridging . swift <nl> ppp b / test / Constraints / bridging . swift <nl> func bridgeToAnyObject ( s : BridgedStruct ) - > AnyObject { <nl> } <nl> <nl> func bridgeFromObjC ( c : BridgedClass ) - > BridgedStruct { <nl> - return c / / expected - error { { cannot convert return expression of type ' BridgedClass ' to expected return type ' BridgedStruct ' } } <nl> + return c / / expected - error { { cannot convert return expression of type ' BridgedClass ' to return type ' BridgedStruct ' } } <nl> return c as BridgedStruct <nl> } <nl> <nl> func bridgeFromObjCDerived ( s : BridgedClassSub ) - > BridgedStruct { <nl> - return s / / expected - error { { cannot convert return expression of type ' BridgedClassSub ' to expected return type ' BridgedStruct ' } } <nl> + return s / / expected - error { { cannot convert return expression of type ' BridgedClassSub ' to return type ' BridgedStruct ' } } <nl> return s as BridgedStruct <nl> } <nl> <nl> mmm a / test / Constraints / same_types . swift <nl> ppp b / test / Constraints / same_types . swift <nl> func fail2 < <nl> where <nl> T . Foo = = U . Foo , T . Foo = = X , U . Foo = = Y / / expected - error { { generic parameter ' Foo ' cannot be equal to both ' X ' and ' Y ' } } <nl> > ( t : T , u : U ) - > ( X , Y ) { <nl> - return ( t . foo , u . foo ) / / expected - error { { cannot convert return expression of type ' ( X , X ) ' to expected return type ' ( X , Y ) ' } } <nl> + return ( t . foo , u . foo ) / / expected - error { { cannot convert return expression of type ' ( X , X ) ' to return type ' ( X , Y ) ' } } <nl> } <nl> <nl> func test4 < T : Barrable where T . Bar = = Y > ( t : T ) - > Y { <nl> func fail3 < <nl> where <nl> T . Bar = = X / / expected - error { { ' X ' does not conform to required protocol ' Fooable ' } } <nl> > ( t : T ) - > X { <nl> - return t . bar / / expected - error { { cannot convert return expression of type ' T . Bar ' to expected return type ' X ' } } <nl> + return t . bar / / expected - error { { cannot convert return expression of type ' T . Bar ' to return type ' X ' } } <nl> } <nl> <nl> func test5 < T : Barrable where T . Bar . Foo = = X > ( t : T ) - > X { <nl> func fail4 < <nl> T . Bar = = Y , <nl> T . Bar . Foo = = Z / / expected - error { { generic parameter ' Foo ' cannot be equal to both ' Foo ' ( aka ' X ' ) and ' Z ' } } <nl> > ( t : T ) - > ( Y , Z ) { <nl> - return ( t . bar , t . bar . foo ) / / expected - error { { cannot convert return expression of type ' ( Y , X ) ' to expected return type ' ( Y , Z ) ' } } <nl> + return ( t . bar , t . bar . foo ) / / expected - error { { cannot convert return expression of type ' ( Y , X ) ' to return type ' ( Y , Z ) ' } } <nl> } <nl> <nl> / / TODO : repeat diagnostic <nl> func fail5 < <nl> T . Bar . Foo = = Z , <nl> T . Bar = = Y / / expected - error 2 { { generic parameter ' Foo ' cannot be equal to both ' Z ' and ' Foo ' } } <nl> > ( t : T ) - > ( Y , Z ) { <nl> - return ( t . bar , t . bar . foo ) / / expected - error { { cannot convert return expression of type ' ( Y , X ) ' to expected return type ' ( Y , Z ) ' } } <nl> + return ( t . bar , t . bar . foo ) / / expected - error { { cannot convert return expression of type ' ( Y , X ) ' to return type ' ( Y , Z ) ' } } <nl> } <nl> <nl> func test8 < T : Fooable where T . Foo = = X , T . Foo = = Y > ( t : T ) { } / / expected - error { { generic parameter ' Foo ' cannot be equal to both ' X ' and ' Y ' } } <nl> func testAssocTypeEquivalence < <nl> } <nl> <nl> func fail6 < T where T = = Int > ( t : T ) - > Int { / / expected - error { { same - type requirement makes generic parameter ' T ' non - generic } } <nl> - return t / / expected - error { { cannot convert return expression of type ' T ' to expected return type ' Int ' } } <nl> + return t / / expected - error { { cannot convert return expression of type ' T ' to return type ' Int ' } } <nl> } <nl> <nl> func test8 < <nl> mmm a / test / Misc / misc_diagnostics . swift <nl> ppp b / test / Misc / misc_diagnostics . swift <nl> var f2 : Float = 3 . 0 <nl> var dd : Double = f1 - f2 / / expected - error { { ' Float ' is not convertible to ' Double ' } } <nl> <nl> func f ( ) - > Bool { <nl> - return 1 + 1 / / expected - error { { cannot convert return expression of type ' Int ' to expected return type ' Bool ' } } <nl> + return 1 + 1 / / expected - error { { cannot convert return expression of type ' Int ' to return type ' Bool ' } } <nl> } <nl> <nl> / / Test that nested diagnostics are properly surfaced . <nl> func retV ( ) { return true } / / expected - error { { unexpected non - void return value <nl> func retAI ( ) - > Int { <nl> let a = [ " " ] <nl> let b = [ " " ] <nl> - return ( a + b ) / / expected - error { { cannot convert return expression of type ' [ String ] ' to expected return type ' Int ' } } <nl> + return ( a + b ) / / expected - error { { cannot convert return expression of type ' [ String ] ' to return type ' Int ' } } <nl> } <nl> <nl> func bad_return1 ( ) { <nl> func bad_return1 ( ) { <nl> } <nl> <nl> func bad_return2 ( ) - > ( Int , Int ) { <nl> - return 42 / / expected - error { { cannot convert return expression of type ' Int ' to expected return type ' ( Int , Int ) ' } } <nl> + return 42 / / expected - error { { cannot convert return expression of type ' Int ' to return type ' ( Int , Int ) ' } } <nl> } <nl> <nl> / / < rdar : / / problem / 14096697 > QoI : Diagnostics for trying to return values from void functions <nl> mmm a / test / decl / func / default - values . swift <nl> ppp b / test / decl / func / default - values . swift <nl> func tupleTypes ( ) { <nl> } <nl> <nl> func returnWithDefault ( ) - > ( a : Int , b : Int = 42 ) { / / expected - error { { default argument not permitted in a tuple type } } <nl> - return 5 / / expected - error { { cannot convert return expression of type ' Int ' to expected return type ' ( a : Int , b : Int ) ' } } <nl> + return 5 / / expected - error { { cannot convert return expression of type ' Int ' to return type ' ( a : Int , b : Int ) ' } } <nl> } <nl> <nl> / / Only the first parameter list of a curried function can have a <nl> mmm a / test / decl / func / dynamic_self . swift <nl> ppp b / test / decl / func / dynamic_self . swift <nl> class C1 { <nl> / / Instance methods have a self of type Self . <nl> func f ( b : Bool ) - > Self { <nl> / / FIXME : below diagnostic should complain about C1 - > Self conversion <nl> - if b { return C1 ( int : 5 ) } / / expected - error { { cannot convert return expression of type ' C1 ' to expected return type ' Self ' } } <nl> + if b { return C1 ( int : 5 ) } / / expected - error { { cannot convert return expression of type ' C1 ' to return type ' Self ' } } <nl> <nl> / / One can use . dynamicType to attempt to construct an object of type Self . <nl> if ! b { return self . dynamicType . init ( int : 5 ) } <nl> mmm a / test / decl / subscript / addressors . swift <nl> ppp b / test / decl / subscript / addressors . swift <nl> struct Repeated { <nl> return UnsafePointer ( base ) <nl> } <nl> unsafeAddress { / / expected - error { { duplicate definition } } <nl> - return base / / expected - error { { cannot convert return expression of type ' UnsafeMutablePointer < Int > ' to expected return type ' UnsafePointer < Int > ' } } <nl> + return base / / expected - error { { cannot convert return expression of type ' UnsafeMutablePointer < Int > ' to return type ' UnsafePointer < Int > ' } } <nl> } <nl> } <nl> } <nl> mmm a / test / decl / subscript / subscripting . swift <nl> ppp b / test / decl / subscript / subscripting . swift <nl> struct Y1 { <nl> <nl> subscript ( i : Int ) - > Int { <nl> get { <nl> - return x / / expected - error { { cannot convert return expression of type ' X ' to expected return type ' Int ' } } <nl> + return x / / expected - error { { cannot convert return expression of type ' X ' to return type ' Int ' } } <nl> } <nl> set { <nl> x = newValue / / expected - error { { cannot assign a value of type ' Int ' to a value of type ' X ' } } <nl> mmm a / test / decl / var / properties . swift <nl> ppp b / test / decl / var / properties . swift <nl> struct Y { } <nl> var y : Y <nl> var x20 : X { <nl> get { <nl> - return y / / expected - error { { cannot convert return expression of type ' Y ' to expected return type ' X ' } } <nl> + return y / / expected - error { { cannot convert return expression of type ' Y ' to return type ' X ' } } <nl> } <nl> set { <nl> y = newValue / / expected - error { { cannot assign a value of type ' X ' to a value of type ' Y ' } } <nl> var x20 : X { <nl> <nl> var x21 : X { <nl> get { <nl> - return y / / expected - error { { cannot convert return expression of type ' Y ' to expected return type ' X ' } } <nl> + return y / / expected - error { { cannot convert return expression of type ' Y ' to return type ' X ' } } <nl> } <nl> set ( v ) { <nl> y = v / / expected - error { { cannot assign a value of type ' X ' to a value of type ' Y ' } } <nl>
word - smith a diagnostic in preparation for it becoming a family .
apple/swift
eb01d5de9d2565a9dc55166c94c0351c67e0e62e
2015-07-26T22:42:32Z
mmm a / src / webui / www / private / preferences_content . html <nl> ppp b / src / webui / www / private / preferences_content . html <nl> <nl> } ; <nl> <nl> time_padding = function ( val ) { <nl> - ret = val . toString ( ) ; <nl> + var ret = val . toString ( ) ; <nl> if ( ret . length = = 1 ) <nl> ret = ' 0 ' + ret ; <nl> return ret ; <nl> <nl> <nl> loadPreferences = function ( ) { <nl> var url = ' api / v2 / app / preferences ' ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> method : ' get ' , <nl> noCache : true , <nl> <nl> } <nl> } <nl> } ) . send ( ) ; <nl> - } <nl> + } ; <nl> <nl> applyPreferences = function ( ) { <nl> var settings = new Hash ( ) ; <nl> mmm a / src / webui / www / private / scripts / client . js <nl> ppp b / src / webui / www / private / scripts / client . js <nl> window . addEvent ( ' load ' , function ( ) { <nl> var syncMainData = function ( ) { <nl> var url = new URI ( ' api / v2 / sync / maindata ' ) ; <nl> url . setData ( ' rid ' , syncMainDataLastResponseId ) ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> method : ' get ' , <nl> var loadTorrentPeersData = function ( ) { <nl> var url = new URI ( ' api / v2 / sync / torrentPeers ' ) ; <nl> url . setData ( ' rid ' , syncTorrentPeersLastResponseId ) ; <nl> url . setData ( ' hash ' , current_hash ) ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> method : ' get ' , <nl> mmm a / src / webui / www / private / scripts / contextmenu . js <nl> ppp b / src / webui / www / private / scripts / contextmenu . js <nl> var TorrentsTableContextMenu = new Class ( { <nl> Extends : ContextMenu , <nl> <nl> updateMenuItems : function ( ) { <nl> - all_are_seq_dl = true ; <nl> - there_are_seq_dl = false ; <nl> - all_are_f_l_piece_prio = true ; <nl> - there_are_f_l_piece_prio = false ; <nl> - all_are_downloaded = true ; <nl> - all_are_paused = true ; <nl> - there_are_paused = false ; <nl> - all_are_force_start = true ; <nl> - there_are_force_start = false ; <nl> - all_are_super_seeding = true ; <nl> - all_are_auto_tmm = true ; <nl> - there_are_auto_tmm = false ; <nl> + var all_are_seq_dl = true ; <nl> + var there_are_seq_dl = false ; <nl> + var all_are_f_l_piece_prio = true ; <nl> + var there_are_f_l_piece_prio = false ; <nl> + var all_are_downloaded = true ; <nl> + var all_are_paused = true ; <nl> + var there_are_paused = false ; <nl> + var all_are_force_start = true ; <nl> + var there_are_force_start = false ; <nl> + var all_are_super_seeding = true ; <nl> + var all_are_auto_tmm = true ; <nl> + var there_are_auto_tmm = false ; <nl> <nl> var h = torrentsTable . selectedRowsIds ( ) ; <nl> h . each ( function ( item , index ) { <nl> var TorrentsTableContextMenu = new Class ( { <nl> all_are_auto_tmm = false ; <nl> } ) ; <nl> <nl> - show_seq_dl = true ; <nl> + var show_seq_dl = true ; <nl> <nl> if ( ! all_are_seq_dl & & there_are_seq_dl ) <nl> show_seq_dl = false ; <nl> <nl> - show_f_l_piece_prio = true ; <nl> + var show_f_l_piece_prio = true ; <nl> <nl> if ( ! all_are_f_l_piece_prio & & there_are_f_l_piece_prio ) <nl> show_f_l_piece_prio = false ; <nl> mmm a / src / webui / www / private / scripts / download . js <nl> ppp b / src / webui / www / private / scripts / download . js <nl> <nl> * / <nl> <nl> getSavePath = function ( ) { <nl> - var req = new Request ( { <nl> + new Request ( { <nl> url : ' api / v2 / app / defaultSavePath ' , <nl> method : ' get ' , <nl> noCache : true , <nl> mmm a / src / webui / www / private / scripts / dynamicTable . js <nl> ppp b / src / webui / www / private / scripts / dynamicTable . js <nl> var DynamicTable = new Class ( { <nl> columnsOrder . push ( v ) ; <nl> } . bind ( this ) ) ; <nl> <nl> - for ( i = 0 ; i < this . columns . length ; + + i ) <nl> + for ( var i = 0 ; i < this . columns . length ; + + i ) <nl> if ( ! columnsOrder . contains ( this . columns [ i ] . name ) ) <nl> columnsOrder . push ( this . columns [ i ] . name ) ; <nl> <nl> var DynamicTable = new Class ( { <nl> } , <nl> <nl> saveColumnsOrder : function ( ) { <nl> - val = ' ' ; <nl> - for ( i = 0 ; i < this . columns . length ; + + i ) { <nl> + var val = ' ' ; <nl> + for ( var i = 0 ; i < this . columns . length ; + + i ) { <nl> if ( i > 0 ) <nl> val + = ' , ' ; <nl> val + = this . columns [ i ] . name ; <nl> var DynamicTable = new Class ( { <nl> var ths = header . getElements ( ' th ' ) ; <nl> <nl> for ( var i = 0 ; i < ths . length ; + + i ) { <nl> - th = ths [ i ] ; <nl> + var th = ths [ i ] ; <nl> th . _this = this ; <nl> th . setAttribute ( ' title ' , this . columns [ i ] . caption ) ; <nl> th . innerHTML = this . columns [ i ] . caption ; <nl> var DynamicTable = new Class ( { <nl> <nl> var rows = this . rows . getValues ( ) ; <nl> <nl> - for ( i = 0 ; i < rows . length ; + + i ) { <nl> + for ( var i = 0 ; i < rows . length ; + + i ) { <nl> filteredRows . push ( rows [ i ] ) ; <nl> filteredRows [ rows [ i ] . rowId ] = rows [ i ] ; <nl> } <nl> <nl> filteredRows . sort ( function ( row1 , row2 ) { <nl> var column = this . columns [ this . sortedColumn ] ; <nl> - res = column . compareRows ( row1 , row2 ) ; <nl> + var res = column . compareRows ( row1 , row2 ) ; <nl> if ( this . reverseSort = = ' 0 ' ) <nl> return res ; <nl> else <nl> var DynamicTable = new Class ( { <nl> } , <nl> <nl> getTrByRowId : function ( rowId ) { <nl> - trs = this . tableBody . getElements ( ' tr ' ) ; <nl> + var trs = this . tableBody . getElements ( ' tr ' ) ; <nl> for ( var i = 0 ; i < trs . length ; + + i ) <nl> if ( trs [ i ] . rowId = = rowId ) <nl> return trs [ i ] ; <nl> var DynamicTable = new Class ( { <nl> <nl> for ( var rowPos = 0 ; rowPos < rows . length ; + + rowPos ) { <nl> var rowId = rows [ rowPos ] [ ' rowId ' ] ; <nl> - tr_found = false ; <nl> + var tr_found = false ; <nl> for ( var j = rowPos ; j < trs . length ; + + j ) <nl> if ( trs [ j ] [ ' rowId ' ] = = rowId ) { <nl> tr_found = true ; <nl> var DynamicTable = new Class ( { <nl> <nl> updateRow : function ( tr , fullUpdate ) { <nl> var row = this . rows . get ( tr . rowId ) ; <nl> - data = row [ fullUpdate ? ' full_data ' : ' data ' ] ; <nl> + var data = row [ fullUpdate ? ' full_data ' : ' data ' ] ; <nl> <nl> - tds = tr . getElements ( ' td ' ) ; <nl> + var tds = tr . getElements ( ' td ' ) ; <nl> for ( var i = 0 ; i < this . columns . length ; + + i ) { <nl> if ( data . hasOwnProperty ( this . columns [ i ] . dataProperties [ 0 ] ) ) <nl> this . columns [ i ] . updateTd ( tds [ i ] , row ) ; <nl> var TorrentsTable = new Class ( { <nl> / / eta <nl> this . columns [ ' eta ' ] . updateTd = function ( td , row ) { <nl> var eta = this . getRowValue ( row ) ; <nl> - td . set ( ' html ' , friendlyDuration ( eta , true ) ) ; <nl> + td . set ( ' html ' , friendlyDuration ( eta ) ) ; <nl> } ; <nl> <nl> / / ratio <nl> var TorrentsTable = new Class ( { <nl> if ( val < 1 ) <nl> td . set ( ' html ' , ' ∞ ' ) ; <nl> else <nl> - td . set ( ' html ' , ' QBT_TR ( % 1 ago ) QBT_TR [ CONTEXT = TransferListDelegate ] ' . replace ( ' % 1 ' , friendlyDuration ( ( new Date ( ) ) / 1000 - val , true ) ) ) ; <nl> + td . set ( ' html ' , ' QBT_TR ( % 1 ago ) QBT_TR [ CONTEXT = TransferListDelegate ] ' . replace ( ' % 1 ' , friendlyDuration ( ( new Date ( ) ) / 1000 - val ) ) ) ; <nl> } ; <nl> <nl> / / time active <nl> var TorrentsTable = new Class ( { <nl> var cnt = 0 ; <nl> var rows = this . rows . getValues ( ) ; <nl> <nl> - for ( i = 0 ; i < rows . length ; + + i ) <nl> + for ( var i = 0 ; i < rows . length ; + + i ) <nl> if ( this . applyFilter ( rows [ i ] , filterName , categoryHash ) ) + + cnt ; <nl> return cnt ; <nl> } , <nl> var TorrentsTable = new Class ( { <nl> var rowsHashes = [ ] ; <nl> var rows = this . rows . getValues ( ) ; <nl> <nl> - for ( i = 0 ; i < rows . length ; + + i ) <nl> + for ( var i = 0 ; i < rows . length ; + + i ) <nl> if ( this . applyFilter ( rows [ i ] , filterName , categoryHash ) ) <nl> rowsHashes . push ( rows [ i ] [ ' rowId ' ] ) ; <nl> <nl> var TorrentsTable = new Class ( { <nl> <nl> var rows = this . rows . getValues ( ) ; <nl> <nl> - for ( i = 0 ; i < rows . length ; + + i ) <nl> + for ( var i = 0 ; i < rows . length ; + + i ) <nl> if ( this . applyFilter ( rows [ i ] , selected_filter , selected_category ) ) { <nl> filteredRows . push ( rows [ i ] ) ; <nl> filteredRows [ rows [ i ] . rowId ] = rows [ i ] ; <nl> var TorrentsTable = new Class ( { <nl> <nl> filteredRows . sort ( function ( row1 , row2 ) { <nl> var column = this . columns [ this . sortedColumn ] ; <nl> - res = column . compareRows ( row1 , row2 ) ; <nl> + var res = column . compareRows ( row1 , row2 ) ; <nl> if ( this . reverseSort = = ' 0 ' ) <nl> return res ; <nl> else <nl> mmm a / src / webui / www / private / scripts / lib / mocha . js <nl> ppp b / src / webui / www / private / scripts / lib / mocha . js <nl> <nl> - / * <nl> + / * <nl> <nl> Script : Core . js <nl> MUI - A Web Applications User Interface Framework . <nl> Note : <nl> * / <nl> <nl> var MUI = MochaUI = new Hash ( { <nl> - <nl> + <nl> version : ' 0 . 9 . 6 development ' , <nl> <nl> options : new Hash ( { <nl> - theme : ' default ' , <nl> + theme : ' default ' , <nl> advancedEffects : false , / / Effects that require fast browsers and are cpu intensive . <nl> standardEffects : true / / Basic effects that tend to run smoothly . <nl> } ) , <nl> <nl> - path : { <nl> + path : { <nl> source : ' scripts / source / ' , / / Path to MochaUI source JavaScript <nl> themes : ' themes / ' , / / Path to MochaUI Themes <nl> plugins : ' plugins / ' / / Path to Plugins <nl> } , <nl> - <nl> + <nl> / / Returns the path to the current theme directory <nl> themePath : function ( ) { <nl> - return MUI . path . themes + MUI . options . theme + ' / ' ; <nl> + return MUI . path . themes + MUI . options . theme + ' / ' ; <nl> } , <nl> - <nl> + <nl> files : new Hash ( ) <nl> - <nl> + <nl> } ) ; <nl> <nl> MUI . files [ MUI . path . source + ' Core / Core . js ' ] = ' loaded ' ; <nl> <nl> MUI . extend ( { <nl> - <nl> + <nl> Windows : { <nl> instances : new Hash ( ) <nl> } , <nl> <nl> - ieSupport : ' excanvas ' , / / Makes it easier to switch between Excanvas and Moocanvas for testing <nl> + ieSupport : ' excanvas ' , / / Makes it easier to switch between Excanvas and Moocanvas for testing <nl> <nl> ieLegacySupport : Browser . Engine . trident & & Browser . version < 9 , <nl> <nl> / * <nl> - <nl> + <nl> Function : updateContent <nl> Replace the content of a window or panel . <nl> - <nl> + <nl> Arguments : <nl> updateOptions - ( object ) <nl> - <nl> + <nl> updateOptions : <nl> element - The parent window or panel . <nl> childElement - The child element of the window or panel receiving the content . <nl> MUI . extend ( { <nl> content - ( string or element ) An html loadMethod option . <nl> loadMethod - ( ' html ' , ' xhr ' , or ' iframe ' ) <nl> url - Used if loadMethod is set to ' xhr ' or ' iframe ' . <nl> - scrollbars - ( boolean ) <nl> + scrollbars - ( boolean ) <nl> padding - ( object ) <nl> onContentLoaded - ( function ) <nl> <nl> - * / <nl> + * / <nl> updateContent : function ( options ) { <nl> <nl> var options = $ extend ( { <nl> MUI . extend ( { <nl> content : null , <nl> loadMethod : null , <nl> url : null , <nl> - scrollbars : null , <nl> + scrollbars : null , <nl> padding : null , <nl> require : { } , <nl> onContentLoaded : $ empty <nl> - } , options ) ; <nl> - <nl> + } , options ) ; <nl> + <nl> options . require = $ extend ( { <nl> css : [ ] , images : [ ] , js : [ ] , onload : null <nl> - } , options . require ) ; <nl> - <nl> + } , options . require ) ; <nl> + <nl> var args = { } ; <nl> - <nl> + <nl> if ( ! options . element ) return ; <nl> - var element = options . element ; <nl> + var element = options . element ; <nl> <nl> if ( MUI . Windows . instances . get ( element . id ) ) { <nl> - args . recipient = ' window ' ; <nl> + args . recipient = ' window ' ; <nl> } <nl> else { <nl> - args . recipient = ' panel ' ; <nl> + args . recipient = ' panel ' ; <nl> } <nl> <nl> var instance = element . retrieve ( ' instance ' ) ; <nl> - if ( options . title ) instance . titleEl . set ( ' html ' , options . title ) ; <nl> + if ( options . title ) instance . titleEl . set ( ' html ' , options . title ) ; <nl> <nl> var contentEl = instance . contentEl ; <nl> - args . contentContainer = options . childElement ! = null ? options . childElement : instance . contentEl ; <nl> + args . contentContainer = options . childElement ! = null ? options . childElement : instance . contentEl ; <nl> var contentWrapperEl = instance . contentWrapperEl ; <nl> <nl> if ( ! options . loadMethod ) { <nl> MUI . extend ( { <nl> options . loadMethod = ' xhr ' ; <nl> } <nl> } <nl> - else { <nl> + else { <nl> options . loadMethod = instance . options . loadMethod ; <nl> } <nl> - } <nl> - <nl> + } <nl> + <nl> / / Set scrollbars if loading content in main content container . <nl> / / Always use ' hidden ' for iframe windows <nl> var scrollbars = options . scrollbars | | instance . options . scrollbars ; <nl> MUI . extend ( { <nl> contentWrapperEl . setStyles ( { <nl> ' overflow ' : scrollbars ! = false & & options . loadMethod ! = ' iframe ' ? ' auto ' : ' hidden ' <nl> } ) ; <nl> - } <nl> + } <nl> <nl> if ( options . padding ! = null ) { <nl> contentEl . setStyles ( { <nl> MUI . extend ( { <nl> <nl> / / Remove old content . <nl> if ( args . contentContainer = = contentEl ) { <nl> - contentEl . empty ( ) . show ( ) ; <nl> + contentEl . empty ( ) . show ( ) ; <nl> / / Panels are not loaded into the padding div , so we remove them separately . <nl> contentEl . getAllNext ( ' . column ' ) . destroy ( ) ; <nl> contentEl . getAllNext ( ' . columnHandle ' ) . destroy ( ) ; <nl> } <nl> - <nl> + <nl> args . onContentLoaded = function ( ) { <nl> - <nl> + <nl> if ( options . require . js . length | | typeof options . require . onload = = ' function ' ) { <nl> new MUI . Require ( { <nl> js : options . require . js , <nl> MUI . extend ( { <nl> options . require . onload ( ) ; <nl> } <nl> options . onContentLoaded ? options . onContentLoaded ( ) : instance . fireEvent ( ' onContentLoaded ' , element ) ; <nl> - } . bind ( this ) <nl> + } . bind ( this ) <nl> } ) ; <nl> - } <nl> + } <nl> else { <nl> options . onContentLoaded ? options . onContentLoaded ( ) : instance . fireEvent ( ' onContentLoaded ' , element ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> } ; <nl> - <nl> + <nl> if ( options . require . css . length | | options . require . images . length ) { <nl> new MUI . Require ( { <nl> css : options . require . css , <nl> images : options . require . images , <nl> onload : function ( ) { <nl> this . loadSelect ( instance , options , args ) ; <nl> - } . bind ( this ) <nl> + } . bind ( this ) <nl> } ) ; <nl> - } <nl> + } <nl> else { <nl> this . loadSelect ( instance , options , args ) ; <nl> } <nl> } , <nl> - <nl> - loadSelect : function ( instance , options , args ) { <nl> - <nl> + <nl> + loadSelect : function ( instance , options , args ) { <nl> + <nl> / / Load new content . <nl> switch ( options . loadMethod ) { <nl> - case ' xhr ' : <nl> + case ' xhr ' : <nl> this . updateContentXHR ( instance , options , args ) ; <nl> break ; <nl> case ' iframe ' : <nl> - this . updateContentIframe ( instance , options , args ) ; <nl> + this . updateContentIframe ( instance , options , args ) ; <nl> break ; <nl> case ' html ' : <nl> default : <nl> MUI . extend ( { <nl> } <nl> <nl> } , <nl> - <nl> + <nl> updateContentXHR : function ( instance , options , args ) { <nl> var contentEl = instance . contentEl ; <nl> var contentContainer = args . contentContainer ; <nl> MUI . extend ( { <nl> url : options . url , <nl> update : contentContainer , <nl> method : options . method ! = null ? options . method : ' get ' , <nl> - data : options . data ! = null ? new Hash ( options . data ) . toQueryString ( ) : ' ' , <nl> + data : options . data ! = null ? new Hash ( options . data ) . toQueryString ( ) : ' ' , <nl> evalScripts : instance . options . evalScripts , <nl> - evalResponse : instance . options . evalResponse , <nl> + evalResponse : instance . options . evalResponse , <nl> onRequest : function ( ) { <nl> if ( args . recipient = = ' window ' & & contentContainer = = contentEl ) { <nl> instance . showSpinner ( ) ; <nl> } <nl> else if ( args . recipient = = ' panel ' & & contentContainer = = contentEl & & $ ( ' spinner ' ) ) { <nl> - $ ( ' spinner ' ) . show ( ) ; <nl> + $ ( ' spinner ' ) . show ( ) ; <nl> } <nl> } . bind ( this ) , <nl> onFailure : function ( response ) { <nl> if ( contentContainer = = contentEl ) { <nl> var getTitle = new RegExp ( " < title > [ \ n \ r \ s ] * ( . * ) [ \ n \ r \ s ] * < / title > " , " gmi " ) ; <nl> var error = getTitle . exec ( response . responseText ) ; <nl> - if ( ! error ) error = ' Unknown ' ; <nl> + if ( ! error ) error = ' Unknown ' ; <nl> contentContainer . set ( ' html ' , ' < h3 > Error : ' + error + ' < / h3 > ' ) ; <nl> if ( args . recipient = = ' window ' ) { <nl> instance . hideSpinner ( ) ; <nl> - } <nl> + } <nl> else if ( args . recipient = = ' panel ' & & $ ( ' spinner ' ) ) { <nl> $ ( ' spinner ' ) . hide ( ) ; <nl> - } <nl> + } <nl> } <nl> } . bind ( this ) , <nl> onSuccess : function ( ) { <nl> if ( contentContainer = = contentEl ) { <nl> - if ( args . recipient = = ' window ' ) instance . hideSpinner ( ) ; <nl> - else if ( args . recipient = = ' panel ' & & $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> + if ( args . recipient = = ' window ' ) instance . hideSpinner ( ) ; <nl> + else if ( args . recipient = = ' panel ' & & $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> } <nl> Browser . Engine . trident4 ? onContentLoaded . delay ( 750 ) : onContentLoaded ( ) ; <nl> } . bind ( this ) , <nl> onComplete : function ( ) { } . bind ( this ) <nl> } ) . send ( ) ; <nl> } , <nl> - <nl> + <nl> updateContentIframe : function ( instance , options , args ) { <nl> var contentEl = instance . contentEl ; <nl> var contentContainer = args . contentContainer ; <nl> var contentWrapperEl = instance . contentWrapperEl ; <nl> - var onContentLoaded = args . onContentLoaded ; <nl> + var onContentLoaded = args . onContentLoaded ; <nl> if ( instance . options . contentURL = = ' ' | | contentContainer ! = contentEl ) { <nl> return ; <nl> } <nl> MUI . extend ( { <nl> ' scrolling ' : ' auto ' , <nl> ' styles ' : { <nl> ' height ' : contentWrapperEl . offsetHeight - contentWrapperEl . getStyle ( ' margin - top ' ) . toInt ( ) - contentWrapperEl . getStyle ( ' margin - bottom ' ) . toInt ( ) , <nl> - ' width ' : instance . panelEl ? contentWrapperEl . offsetWidth - contentWrapperEl . getStyle ( ' margin - left ' ) . toInt ( ) - contentWrapperEl . getStyle ( ' margin - right ' ) . toInt ( ) : ' 100 % ' <nl> + ' width ' : instance . panelEl ? contentWrapperEl . offsetWidth - contentWrapperEl . getStyle ( ' margin - left ' ) . toInt ( ) - contentWrapperEl . getStyle ( ' margin - right ' ) . toInt ( ) : ' 100 % ' <nl> } <nl> } ) . injectInside ( contentEl ) ; <nl> <nl> / / Add onload event to iframe so we can hide the spinner and run onContentLoaded ( ) <nl> instance . iframeEl . addEvent ( ' load ' , function ( e ) { <nl> - if ( args . recipient = = ' window ' ) instance . hideSpinner ( ) ; <nl> + if ( args . recipient = = ' window ' ) instance . hideSpinner ( ) ; <nl> else if ( args . recipient = = ' panel ' & & contentContainer = = contentEl & & $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> Browser . Engine . trident4 ? onContentLoaded . delay ( 50 ) : onContentLoaded ( ) ; <nl> } . bind ( this ) ) ; <nl> - if ( args . recipient = = ' window ' ) instance . showSpinner ( ) ; <nl> + if ( args . recipient = = ' window ' ) instance . showSpinner ( ) ; <nl> else if ( args . recipient = = ' panel ' & & contentContainer = = contentEl & & $ ( ' spinner ' ) ) $ ( ' spinner ' ) . show ( ) ; <nl> } , <nl> - <nl> + <nl> updateContentHTML : function ( instance , options , args ) { <nl> var contentEl = instance . contentEl ; <nl> var contentContainer = args . contentContainer ; <nl> - var onContentLoaded = args . onContentLoaded ; <nl> + var onContentLoaded = args . onContentLoaded ; <nl> var elementTypes = new Array ( ' element ' , ' textnode ' , ' whitespace ' , ' collection ' ) ; <nl> - <nl> + <nl> if ( elementTypes . contains ( $ type ( options . content ) ) ) { <nl> options . content . inject ( contentContainer ) ; <nl> } else { <nl> contentContainer . set ( ' html ' , options . content ) ; <nl> - } <nl> + } <nl> if ( contentContainer = = contentEl ) { <nl> - if ( args . recipient = = ' window ' ) instance . hideSpinner ( ) ; <nl> - else if ( args . recipient = = ' panel ' & & $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> + if ( args . recipient = = ' window ' ) instance . hideSpinner ( ) ; <nl> + else if ( args . recipient = = ' panel ' & & $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> } <nl> Browser . Engine . trident4 ? onContentLoaded . delay ( 50 ) : onContentLoaded ( ) ; <nl> } , <nl> - <nl> + <nl> / * <nl> - <nl> + <nl> Function : reloadIframe <nl> Reload an iframe . Fixes an issue in Firefox when trying to use location . reload on an iframe that has been destroyed and recreated . <nl> <nl> MUI . extend ( { <nl> <nl> * / <nl> reloadIframe : function ( iframe ) { <nl> - Browser . Engine . gecko ? $ ( iframe ) . src = $ ( iframe ) . src : top . frames [ iframe ] . location . reload ( true ) ; <nl> + Browser . Engine . gecko ? $ ( iframe ) . src = $ ( iframe ) . src : top . frames [ iframe ] . location . reload ( true ) ; <nl> } , <nl> - <nl> + <nl> roundedRect : function ( ctx , x , y , width , height , radius , rgb , a ) { <nl> ctx . fillStyle = ' rgba ( ' + rgb . join ( ' , ' ) + ' , ' + a + ' ) ' ; <nl> ctx . beginPath ( ) ; <nl> MUI . extend ( { <nl> ctx . quadraticCurveTo ( x + width , y , x + width - radius , y ) ; <nl> ctx . lineTo ( x + radius , y ) ; <nl> ctx . quadraticCurveTo ( x , y , x , y + radius ) ; <nl> - ctx . fill ( ) ; <nl> + ctx . fill ( ) ; <nl> } , <nl> - <nl> + <nl> triangle : function ( ctx , x , y , width , height , rgb , a ) { <nl> ctx . beginPath ( ) ; <nl> ctx . moveTo ( x + width , y ) ; <nl> MUI . extend ( { <nl> ctx . fillStyle = ' rgba ( ' + rgb . join ( ' , ' ) + ' , ' + a + ' ) ' ; <nl> ctx . fill ( ) ; <nl> } , <nl> - <nl> + <nl> circle : function ( ctx , x , y , diameter , rgb , a ) { <nl> ctx . beginPath ( ) ; <nl> ctx . arc ( x , y , diameter , 0 , Math . PI * 2 , true ) ; <nl> ctx . fillStyle = ' rgba ( ' + rgb . join ( ' , ' ) + ' , ' + a + ' ) ' ; <nl> ctx . fill ( ) ; <nl> } , <nl> - <nl> + <nl> notification : function ( message ) { <nl> new MUI . Window ( { <nl> loadMethod : ' html ' , <nl> MUI . extend ( { <nl> height : 40 , <nl> y : 53 , <nl> padding : { top : 10 , right : 12 , bottom : 10 , left : 12 } , <nl> - shadowBlur : 5 <nl> + shadowBlur : 5 <nl> } ) ; <nl> } , <nl> - <nl> + <nl> / * <nl> - <nl> + <nl> Function : toggleEffects <nl> Turn effects on and off <nl> <nl> MUI . extend ( { <nl> ' class ' : ' check ' , <nl> ' id ' : ' toggleAdvancedEffects_check ' <nl> } ) . inject ( link ) ; <nl> - } <nl> + } <nl> } <nl> else { <nl> MUI . options . advancedEffects = false ; <nl> if ( this . toggleAdvancedEffectsLink ) { <nl> this . toggleAdvancedEffectsLink . destroy ( ) ; <nl> - } <nl> + } <nl> } <nl> } , <nl> / * <nl> - <nl> + <nl> Function : toggleStandardEffects <nl> Turn standard effects on and off <nl> <nl> MUI . extend ( { <nl> ' class ' : ' check ' , <nl> ' id ' : ' toggleStandardEffects_check ' <nl> } ) . inject ( link ) ; <nl> - } <nl> + } <nl> } <nl> else { <nl> MUI . options . standardEffects = false ; <nl> if ( this . toggleStandardEffectsLink ) { <nl> this . toggleStandardEffectsLink . destroy ( ) ; <nl> - } <nl> + } <nl> } <nl> - } , <nl> - <nl> + } , <nl> + <nl> / * <nl> - <nl> + <nl> The underlay is inserted directly under windows when they are being dragged or resized <nl> so that the cursor is not captured by iframes or other plugins ( such as Flash ) <nl> underneath the window . <nl> - <nl> + <nl> * / <nl> underlayInitialize : function ( ) { <nl> var windowUnderlay = new Element ( ' div ' , { <nl> MUI . extend ( { <nl> } <nl> } ) ; <nl> <nl> - / * <nl> + / * <nl> <nl> function : fixPNG <nl> Bob Osola ' s PngFix for IE6 . <nl> function fixPNG ( myImage ) { <nl> + " px ; " + imgStyle + " ; " <nl> + " filter : progid : DXImageTransform . Microsoft . AlphaImageLoader " <nl> + " ( src = \ ' " + myImage . src + " \ ' , sizingMethod = ' scale ' ) ; \ " > < / span > " ; <nl> - myImage . outerHTML = strNewHTML ; <nl> + myImage . outerHTML = strNewHTML ; <nl> } <nl> } <nl> <nl> Element . implement ( { <nl> show : function ( ) { <nl> this . setStyle ( ' display ' , ' block ' ) ; <nl> return this ; <nl> - } <nl> - } ) ; <nl> + } <nl> + } ) ; <nl> <nl> / * <nl> <nl> Example : <nl> ( start code ) <nl> $ ( ' parametrics ' ) . shake ( ) <nl> ( end ) <nl> - <nl> + <nl> * / <nl> <nl> Element . implement ( { <nl> Element . implement ( { <nl> } ) ; <nl> <nl> String . implement ( { <nl> - <nl> + <nl> parseQueryString : function ( ) { <nl> var vars = this . split ( / [ & ; ] / ) ; <nl> var rs = { } ; <nl> String . implement ( { <nl> } ) ; <nl> return rs ; <nl> } <nl> - <nl> + <nl> } ) ; <nl> <nl> - / / Mootools Patch : Fixes issues in Safari , Chrome , and Internet Explorer caused by processing text as XML . <nl> + / / Mootools Patch : Fixes issues in Safari , Chrome , and Internet Explorer caused by processing text as XML . <nl> Request . HTML . implement ( { <nl> - <nl> + <nl> processHTML : function ( text ) { <nl> var match = text . match ( / < body [ ^ > ] * > ( [ \ s \ S ] * ? ) < \ / body > / i ) ; <nl> - text = ( match ) ? match [ 1 ] : text ; <nl> - var container = new Element ( ' div ' ) ; <nl> + text = ( match ) ? match [ 1 ] : text ; <nl> + var container = new Element ( ' div ' ) ; <nl> return container . set ( ' html ' , text ) ; <nl> } <nl> - <nl> + <nl> } ) ; <nl> <nl> / * <nl> <nl> Examples : <nl> - ( start code ) <nl> + ( start code ) <nl> getCSSRule ( ' . myRule ' ) ; <nl> getCSSRule ( ' # myRule ' ) ; <nl> ( end ) <nl> - <nl> + <nl> * / <nl> MUI . getCSSRule = function ( selector ) { <nl> for ( var ii = 0 ; ii < document . styleSheets . length ; ii + + ) { <nl> MUI . getCSSRule = function ( selector ) { <nl> return myrules [ i ] ; <nl> } <nl> } <nl> - } <nl> + } <nl> return false ; <nl> } <nl> <nl> if ( location . protocol = = " file : " ) { <nl> return new XMLHttpRequest ( ) ; <nl> } ) ; <nl> } ; <nl> - <nl> + <nl> } <nl> <nl> MUI . Require = new Class ( { <nl> MUI . Require = new Class ( { <nl> options : { <nl> css : [ ] , <nl> images : [ ] , <nl> - js : [ ] , <nl> + js : [ ] , <nl> onload : $ empty <nl> } , <nl> - <nl> + <nl> initialize : function ( options ) { <nl> this . setOptions ( options ) ; <nl> - var options = this . options ; <nl> - <nl> - this . assetsToLoad = options . css . length + options . images . length + options . js . length ; <nl> + var options = this . options ; <nl> + <nl> + this . assetsToLoad = options . css . length + options . images . length + options . js . length ; <nl> this . assetsLoaded = 0 ; <nl> - <nl> + <nl> var cssLoaded = 0 ; <nl> - <nl> - / / Load CSS before images and JavaScript <nl> - <nl> + <nl> + / / Load CSS before images and JavaScript <nl> + <nl> if ( options . css . length ) { <nl> options . css . each ( function ( sheet ) { <nl> - <nl> + <nl> this . getAsset ( sheet , function ( ) { <nl> if ( cssLoaded = = options . css . length - 1 ) { <nl> - <nl> + <nl> if ( this . assetsLoaded = = this . assetsToLoad - 1 ) { <nl> this . requireOnload ( ) ; <nl> } <nl> else { <nl> / / Add a little delay since we are relying on cached CSS from XHR request . <nl> - this . assetsLoaded + + ; <nl> + this . assetsLoaded + + ; <nl> this . requireContinue . delay ( 50 , this ) ; <nl> - } <nl> + } <nl> } <nl> else { <nl> cssLoaded + + ; <nl> - this . assetsLoaded + + ; <nl> + this . assetsLoaded + + ; <nl> } <nl> } . bind ( this ) ) ; <nl> } . bind ( this ) ) ; <nl> MUI . Require = new Class ( { <nl> } <nl> else { <nl> this . requireContinue . delay ( 50 , this ) ; / / Delay is for Safari <nl> - } <nl> - <nl> + } <nl> + <nl> } , <nl> - <nl> + <nl> requireOnload : function ( ) { <nl> this . assetsLoaded + + ; <nl> if ( this . assetsLoaded = = this . assetsToLoad ) { <nl> this . options . onload ( ) ; <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> - } , <nl> - <nl> + } , <nl> + <nl> requireContinue : function ( ) { <nl> <nl> var options = this . options ; <nl> MUI . Require = new Class ( { <nl> this . getAsset ( image , this . requireOnload . bind ( this ) ) ; <nl> } . bind ( this ) ) ; <nl> } <nl> - <nl> + <nl> if ( options . js . length ) { <nl> options . js . each ( function ( script ) { <nl> - this . getAsset ( script , this . requireOnload . bind ( this ) ) ; <nl> + this . getAsset ( script , this . requireOnload . bind ( this ) ) ; <nl> } . bind ( this ) ) ; <nl> } <nl> - <nl> + <nl> } , <nl> - <nl> + <nl> getAsset : function ( source , onload ) { <nl> <nl> / / If the asset is loaded , fire the onload function . <nl> MUI . Require = new Class ( { <nl> if ( typeof onload = = ' function ' ) { <nl> onload ( ) ; <nl> } <nl> - return true ; <nl> + return true ; <nl> } <nl> - <nl> + <nl> / / If the asset is loading , wait until it is loaded and then fire the onload function . <nl> / / If asset doesn ' t load by a number of tries , fire onload anyway . <nl> else if ( MUI . files [ source ] = = ' loading ' ) { <nl> MUI . Require = new Class ( { <nl> } <nl> } ) . periodical ( 50 ) ; <nl> } <nl> - <nl> + <nl> / / If the asset is not yet loaded or loading , start loading the asset . <nl> else { <nl> - MUI . files [ source ] = ' loading ' ; <nl> - <nl> + MUI . files [ source ] = ' loading ' ; <nl> + <nl> properties = { <nl> - ' onload ' : onload ! = ' undefined ' ? onload : $ empty <nl> - } ; <nl> - <nl> + ' onload ' : onload ! = ' undefined ' ? onload : $ empty <nl> + } ; <nl> + <nl> / / Add to the onload function <nl> var oldonload = properties . onload ; <nl> properties . onload = function ( ) { <nl> MUI . files [ source ] = ' loaded ' ; <nl> if ( oldonload ) { <nl> oldonload ( ) ; <nl> - } <nl> - } . bind ( this ) ; <nl> - <nl> + } <nl> + } . bind ( this ) ; <nl> + <nl> switch ( source . match ( / \ . \ w + $ / ) [ 0 ] ) { <nl> case ' . js ' : return Asset . javascript ( source , properties ) ; <nl> case ' . css ' : return Asset . css ( source , properties ) ; <nl> MUI . Require = new Class ( { <nl> case ' . png ' : <nl> case ' . gif ' : return Asset . image ( source , properties ) ; <nl> } <nl> - <nl> + <nl> alert ( ' The required file " ' + source + ' " could not be loaded ' ) ; <nl> } <nl> - } <nl> - <nl> + } <nl> + <nl> } ) ; <nl> <nl> $ extend ( Asset , { <nl> $ extend ( Asset , { <nl> document : document , <nl> check : $ lambda ( true ) <nl> } , properties ) ; <nl> - <nl> + <nl> if ( $ ( properties . id ) ) { <nl> properties . onload ( ) ; <nl> return $ ( properties . id ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> var script = new Element ( ' script ' , { ' src ' : source , ' type ' : ' text / javascript ' } ) ; <nl> - <nl> + <nl> var load = properties . onload . bind ( script ) , check = properties . check , doc = properties . document ; <nl> delete properties . onload ; delete properties . check ; delete properties . document ; <nl> - <nl> + <nl> if ( ! Browser . Engine . webkit419 & & ! Browser . Engine . presto ) { <nl> script . addEvents ( { <nl> load : load , <nl> readystatechange : function ( ) { <nl> - if ( MUI . ieLegacySupport & & [ ' loaded ' , ' complete ' ] . contains ( this . readyState ) ) <nl> + if ( MUI . ieLegacySupport & & [ ' loaded ' , ' complete ' ] . contains ( this . readyState ) ) <nl> load ( ) ; <nl> } <nl> } ) . setProperties ( properties ) ; <nl> $ extend ( Asset , { <nl> / / Opera has difficulty with multiple scripts being injected into the head simultaneously . We need to give it time to catch up . <nl> Browser . Engine . presto ? load . delay ( 500 ) : load ( ) ; <nl> } ) . periodical ( 50 ) ; <nl> - } <nl> + } <nl> return script . inject ( doc . head ) ; <nl> } , <nl> - <nl> + <nl> / / Get the CSS with XHR before appending it to document . head so that we can have an onload callback . <nl> css : function ( source , properties ) { <nl> - <nl> + <nl> properties = $ extend ( { <nl> id : null , <nl> media : ' screen ' , <nl> onload : $ empty <nl> - } , properties ) ; <nl> - <nl> + } , properties ) ; <nl> + <nl> new Request ( { <nl> method : ' get ' , <nl> url : source , <nl> - onComplete : function ( response ) { <nl> + onComplete : function ( response ) { <nl> var newSheet = new Element ( ' link ' , { <nl> ' id ' : properties . id , <nl> ' rel ' : ' stylesheet ' , <nl> ' media ' : properties . media , <nl> ' type ' : ' text / css ' , <nl> ' href ' : source <nl> - } ) . inject ( document . head ) ; <nl> - properties . onload ( ) ; <nl> + } ) . inject ( document . head ) ; <nl> + properties . onload ( ) ; <nl> } . bind ( this ) , <nl> - onFailure : function ( response ) { <nl> - } , <nl> - onSuccess : function ( ) { <nl> + onFailure : function ( response ) { <nl> + } , <nl> + onSuccess : function ( ) { <nl> } . bind ( this ) <nl> - } ) . send ( ) ; <nl> - } <nl> - <nl> + } ) . send ( ) ; <nl> + } <nl> + <nl> } ) ; <nl> <nl> / * <nl> REGISTER PLUGINS <nl> it will overwrite the function below , and new MUI . Window ( arg ) will be ran <nl> again . This time it will create a new MUI . Window instance , and any future calls <nl> to new MUI . Window ( arg ) will immediately create new windows since the assets <nl> - have already been loaded and our temporary function below has been overwritten . <nl> - <nl> + have already been loaded and our temporary function below has been overwritten . <nl> + <nl> Example : <nl> - <nl> + <nl> MyPlugins . extend ( { <nl> <nl> MyGadget : function ( arg ) { <nl> REGISTER PLUGINS <nl> js : [ MUI . path . plugins + ' myGadget / scripts / myGadget . js ' ] , <nl> onload : function ( ) { <nl> new MyPlguins . MyGadget ( arg ) ; <nl> - } <nl> + } <nl> } ) ; <nl> } <nl> - <nl> - } ) ; <nl> - <nl> + <nl> + } ) ; <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - * / <nl> <nl> MUI . extend ( { <nl> MUI . extend ( { <nl> js : [ MUI . path . source + ' Window / Windows - from - json . js ' ] , <nl> onload : function ( ) { <nl> new MUI . newWindowsFromJSON ( arg ) ; <nl> - } <nl> + } <nl> } ) ; <nl> - } , <nl> - <nl> + } , <nl> + <nl> arrangeCascade : function ( ) { <nl> new MUI . Require ( { <nl> js : [ MUI . path . source + ' Window / Arrange - cascade . js ' ] , <nl> onload : function ( ) { <nl> new MUI . arrangeCascade ( ) ; <nl> - } <nl> - } ) ; <nl> + } <nl> + } ) ; <nl> } , <nl> - <nl> + <nl> arrangeTile : function ( ) { <nl> new MUI . Require ( { <nl> js : [ MUI . path . source + ' Window / Arrange - tile . js ' ] , <nl> onload : function ( ) { <nl> new MUI . arrangeTile ( ) ; <nl> - } <nl> - } ) ; <nl> + } <nl> + } ) ; <nl> } , <nl> - <nl> + <nl> saveWorkspace : function ( ) { <nl> new MUI . Require ( { <nl> js : [ MUI . path . source + ' Layout / Workspaces . js ' ] , <nl> onload : function ( ) { <nl> new MUI . saveWorkspace ( ) ; <nl> - } <nl> - } ) ; <nl> + } <nl> + } ) ; <nl> } , <nl> - <nl> + <nl> loadWorkspace : function ( ) { <nl> new MUI . Require ( { <nl> js : [ MUI . path . source + ' Layout / Workspaces . js ' ] , <nl> onload : function ( ) { <nl> new MUI . loadWorkspace ( ) ; <nl> - } <nl> - } ) ; <nl> + } <nl> + } ) ; <nl> } , <nl> <nl> Themes : { <nl> - init : function ( arg ) { <nl> + init : function ( arg ) { <nl> new MUI . Require ( { <nl> js : [ MUI . path . source + ' Utilities / Themes . js ' ] , <nl> onload : function ( ) { <nl> MUI . Themes . init ( arg ) ; <nl> - } <nl> - } ) ; <nl> + } <nl> + } ) ; <nl> } <nl> } <nl> - <nl> + <nl> } ) ; <nl> / * <nl> <nl> Script : Themes . js <nl> Allows for switching themes dynamically . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> MIT - style license . <nl> <nl> Requires : <nl> Core . js <nl> - <nl> + <nl> Notes : <nl> - Themes are new and experimental . <nl> - <nl> + Themes are new and experimental . <nl> + <nl> Syntax : <nl> ( start code ) <nl> new MUI . Themes . init ( newTheme ) ; <nl> ( end ) <nl> - <nl> + <nl> Example : <nl> ( start code ) <nl> new MUI . Themes . init ( ' charcoal ' ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> Arguments : <nl> - newTheme - ( string ) The theme name <nl> + newTheme - ( string ) The theme name <nl> <nl> * / <nl> <nl> MUI . files [ MUI . path . source + ' Utilities / Themes . js ' ] = 1 ; <nl> - <nl> + <nl> MUI . Themes = { <nl> <nl> / * <nl> - <nl> + <nl> Function : themeInit <nl> Initialize a theme . This is experimental and not fully implemented yet . <nl> - <nl> - * / <nl> + <nl> + * / <nl> init : function ( newTheme ) { <nl> this . newTheme = newTheme . toLowerCase ( ) ; <nl> if ( ! this . newTheme | | this . newTheme = = null | | this . newTheme = = MUI . options . theme . toLowerCase ( ) ) return ; <nl> <nl> if ( $ ( ' spinner ' ) ) $ ( ' spinner ' ) . show ( ) ; <nl> - <nl> + <nl> this . oldURIs = [ ] ; <nl> this . oldSheets = [ ] ; <nl> - <nl> - $ $ ( ' link ' ) . each ( function ( link ) { <nl> + <nl> + $ $ ( ' link ' ) . each ( function ( link ) { <nl> var href = link . get ( ' href ' ) ; <nl> if ( href . contains ( MUI . path . themes + MUI . options . theme ) ) { <nl> this . oldURIs . push ( href ) ; <nl> this . oldSheets . push ( link ) ; <nl> } <nl> - } . bind ( this ) ) ; <nl> - <nl> + } . bind ( this ) ) ; <nl> + <nl> / * <nl> - MUI . files . each ( function ( value , key , hash ) { <nl> + MUI . files . each ( function ( value , key , hash ) { <nl> if ( key . contains ( MUI . path . themes + MUI . options . theme ) ) { <nl> this . oldURIs . push ( key ) ; <nl> } <nl> } . bind ( this ) ) ; <nl> - * / <nl> - <nl> + * / <nl> + <nl> this . newSheetURLs = this . oldURIs . map ( function ( item , index ) { <nl> return item . replace ( " / " + MUI . options . theme + " / " , " / " + MUI . Themes . newTheme + " / " ) ; <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> this . sheetsToLoad = this . oldURIs . length ; <nl> this . sheetsLoaded = 0 ; <nl> - <nl> + <nl> / / Download new stylesheets and add them to an array <nl> this . newSheets = [ ] ; <nl> this . newSheetURLs . each ( function ( link ) { <nl> var href = link ; <nl> - <nl> + <nl> / / var id = link . id ; <nl> - <nl> + <nl> var cssRequest = new Request ( { <nl> method : ' get ' , <nl> url : href , <nl> - onComplete : function ( response ) { <nl> + onComplete : function ( response ) { <nl> var newSheet = new Element ( ' link ' , { <nl> / / ' id ' : id , <nl> ' rel ' : ' stylesheet ' , <nl> MUI . Themes = { <nl> ' type ' : ' text / css ' , <nl> ' href ' : href <nl> } ) ; <nl> - this . newSheets . push ( newSheet ) ; <nl> + this . newSheets . push ( newSheet ) ; <nl> } . bind ( this ) , <nl> onFailure : function ( response ) { <nl> this . themeLoadSuccess = false ; <nl> - if ( $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> - MUI . notification ( ' Stylesheets did not load . ' ) ; <nl> - } , <nl> - onSuccess : function ( ) { <nl> + if ( $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> + MUI . notification ( ' Stylesheets did not load . ' ) ; <nl> + } , <nl> + onSuccess : function ( ) { <nl> this . sheetsLoaded + + ; <nl> if ( this . sheetsLoaded = = this . sheetsToLoad ) { <nl> this . updateThemeStylesheets ( ) ; <nl> this . themeLoadSuccess = true ; <nl> - } <nl> + } <nl> } . bind ( this ) <nl> } ) ; <nl> - cssRequest . send ( ) ; <nl> + cssRequest . send ( ) ; <nl> <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> } , <nl> updateThemeStylesheets : function ( ) { <nl> <nl> this . oldSheets . each ( function ( sheet ) { <nl> sheet . destroy ( ) ; <nl> - } ) ; <nl> + } ) ; <nl> <nl> this . newSheets . each ( function ( sheet ) { <nl> MUI . files [ sheet . get ( ' href ' ) ] = 1 ; <nl> sheet . inject ( document . head ) ; <nl> - } ) ; <nl> + } ) ; <nl> <nl> - / / Delay gives the stylesheets time to take effect . IE6 needs more delay . <nl> + / / Delay gives the stylesheets time to take effect . IE6 needs more delay . <nl> if ( MUI . ieLegacySupport ) { <nl> this . redraw . delay ( 1250 , this ) ; <nl> } <nl> else { <nl> this . redraw . delay ( 250 , this ) ; <nl> - } <nl> - <nl> - } , <nl> + } <nl> + <nl> + } , <nl> redraw : function ( ) { <nl> <nl> $ $ ( ' . replaced ' ) . removeClass ( ' replaced ' ) ; <nl> <nl> - / / Redraw open windows <nl> - $ $ ( ' . mocha ' ) . each ( function ( element ) { <nl> + / / Redraw open windows <nl> + $ $ ( ' . mocha ' ) . each ( function ( element ) { <nl> var instance = element . retrieve ( ' instance ' ) ; <nl> - <nl> + <nl> / / Convert CSS colors to Canvas colors . <nl> - instance . setColors ( ) ; <nl> - instance . drawWindow ( ) ; <nl> + instance . setColors ( ) ; <nl> + instance . drawWindow ( ) ; <nl> } ) ; <nl> - <nl> + <nl> if ( MUI . Dock ) { <nl> if ( MUI . Dock . options . useControls ) { <nl> MUI . Dock . setDockColors ( ) ; <nl> MUI . Themes = { <nl> / / Reformat layout <nl> if ( MUI . Desktop . desktop ) { <nl> var checker = ( function ( ) { <nl> - / / Make sure the style sheets are really ready . <nl> - if ( MUI . Desktop . desktop . getStyle ( ' overflow ' ) ! = ' hidden ' ) { <nl> + / / Make sure the style sheets are really ready . <nl> + if ( MUI . Desktop . desktop . getStyle ( ' overflow ' ) ! = ' hidden ' ) { <nl> return ; <nl> } <nl> - $ clear ( checker ) ; <nl> - MUI . Desktop . setDesktopSize ( ) ; <nl> + $ clear ( checker ) ; <nl> + MUI . Desktop . setDesktopSize ( ) ; <nl> } ) . periodical ( 50 ) ; <nl> } <nl> - <nl> - if ( $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> + <nl> + if ( $ ( ' spinner ' ) ) $ ( ' spinner ' ) . hide ( ) ; <nl> MUI . options . theme = this . newTheme ; <nl> - <nl> - / * <nl> + <nl> + / * <nl> this . cookie = new Hash . Cookie ( ' mochaUIthemeCookie ' , { duration : 3600 } ) ; <nl> this . cookie . empty ( ) ; <nl> this . cookie . set ( ' theme ' , MUI . options . theme ) ; <nl> this . cookie . save ( ) ; <nl> - * / <nl> - <nl> + * / <nl> + <nl> } <nl> } ; <nl> <nl> window . addEvent ( ' load ' , function ( ) { <nl> / / Load theme the user was last using . This needs work . <nl> var cookie = new Hash . Cookie ( ' mochaUIthemeCookie ' , { duration : 3600 } ) ; <nl> var themeCookie = cookie . load ( ) ; <nl> - if ( cookie . getKeys ( ) . length ) { <nl> + if ( cookie . getKeys ( ) . length ) { <nl> if ( themeCookie . get ( ' theme ' ) ! = MUI . Themes . options . theme ) { <nl> MUI . Themes . init . delay ( 1000 , MUI . Themes , themeCookie . get ( ' theme ' ) ) ; <nl> } <nl> } <nl> * / <nl> - <nl> + <nl> if ( $ ( ' themeControl ' ) ) { <nl> $ ( ' themeControl ' ) . getElements ( ' option ' ) . setProperty ( ' selected ' , ' false ' ) ; <nl> if ( $ ( ' chooseTheme ' ) ) { <nl> Copyright : <nl> Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Requires : <nl> Core . js <nl> MUI . files [ MUI . path . source + ' Window / Window . js ' ] = ' loading ' ; <nl> / * <nl> Class : Window <nl> Creates a single MochaUI window . <nl> - <nl> + <nl> Syntax : <nl> ( start code ) <nl> new MUI . Window ( options ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> Arguments : <nl> options <nl> Options : <nl> toolbar2Height - ( number ) <nl> toolbar2URL - ( url ) Defaults to ' pages / lipsum . html ' . <nl> toolbar2Content - ( string ) <nl> - toolbar2Onload - ( function ) <nl> + toolbar2Onload - ( function ) <nl> container - ( element ID ) Element the window is injected in . The container defaults to ' desktop ' . If no desktop then to document . body . Use ' pageWrapper ' if you don ' t want the windows to overlap the toolbars . <nl> restrict - ( boolean ) Restrict window to container when dragging . <nl> shape - ( ' box ' or ' gauge ' ) Shape of window . Defaults to ' box ' . <nl> collapsible - ( boolean ) Defaults to true . <nl> - minimizable - ( boolean ) Requires MUI . Desktop and MUI . Dock . Defaults to true if dependenices are met . <nl> + minimizable - ( boolean ) Requires MUI . Desktop and MUI . Dock . Defaults to true if dependenices are met . <nl> maximizable - ( boolean ) Requires MUI . Desktop . Defaults to true if dependenices are met . <nl> closable - ( boolean ) Defaults to true . <nl> storeOnClose - ( boolean ) Hides a window and it ' s dock tab rather than destroying them on close . If you try to create the window again it will unhide the window and dock tab . <nl> modalOverlayClose - ( boolean ) Whether or not you can close a modal by clicking on the modal overlay . Defaults to true . <nl> draggable - ( boolean ) Defaults to false for modals ; otherwise true . <nl> - draggableGrid - ( false or number ) Distance in pixels for snap - to - grid dragging . Defaults to false . <nl> + draggableGrid - ( false or number ) Distance in pixels for snap - to - grid dragging . Defaults to false . <nl> draggableLimit - ( false or number ) An object with x and y properties used to limit the movement of the Window . Defaults to false . <nl> draggableSnap - ( boolean ) The distance to drag before the Window starts to respond to the drag . Defaults to false . <nl> resizable - ( boolean ) Defaults to false for modals , notifications and gauges ; otherwise true . <nl> resizeLimit - ( object ) Minimum and maximum width and height of window when resized . <nl> - addClass - ( string ) Add a class to the window for more control over styling . <nl> - width - ( number ) Width of content area . <nl> + addClass - ( string ) Add a class to the window for more control over styling . <nl> + width - ( number ) Width of content area . <nl> height - ( number ) Height of content area . <nl> headerHeight - ( number ) Height of window titlebar . <nl> footerHeight - ( number ) Height of window footer . <nl> - cornerRadius - ( number ) <nl> + cornerRadius - ( number ) <nl> x - ( number ) If x and y are left undefined the window is centered on the page . <nl> y - ( number ) <nl> scrollbars - ( boolean ) <nl> Example : <nl> <nl> Example : <nl> Create window onDomReady . <nl> - ( start code ) <nl> + ( start code ) <nl> window . addEvent ( ' domready ' , function ( ) { <nl> mywindow ( ) ; <nl> } ) ; <nl> Example : <nl> } <nl> <nl> / / HTML : <nl> - < a id = " mywindowLink " href = " pages / lipsum . html " > My Window < / a > <nl> + < a id = " mywindowLink " href = " pages / lipsum . html " > My Window < / a > <nl> ( end ) <nl> <nl> <nl> Loading Content with an XMLHttpRequest ( xhr ) : <nl> For content to load via xhr all the files must be online and in the same domain . If you need to load content from another domain or wish to have it work offline , load the content in an iframe instead of using the xhr option . <nl> - <nl> + <nl> Iframes : <nl> If you use the iframe loadMethod your iframe will automatically be resized when the window it is in is resized . If you want this same functionality when using one of the other load options simply add class = " mochaIframe " to those iframes and they will be resized for you as well . <nl> <nl> Example : <nl> / / individual options without rewriting all of them . <nl> <nl> MUI . extend ( { <nl> - Windows : { <nl> + Windows : { <nl> instances : new Hash ( ) , <nl> indexLevel : 100 , / / Used for window z - Index <nl> windowIDCount : 0 , / / Used for windows without an ID defined by the user <nl> windowsVisible : true , / / Ctrl - Alt - Q to toggle window visibility <nl> - focusingWindow : false <nl> - } <nl> - } ) ; <nl> + focusingWindow : false <nl> + } <nl> + } ) ; <nl> <nl> MUI . Windows . windowOptions = { <nl> id : null , <nl> MUI . Windows . windowOptions = { <nl> toolbar2URL : ' pages / lipsum . html ' , <nl> toolbar2Data : null , <nl> toolbar2Content : ' ' , <nl> - toolbar2Onload : $ empty , <nl> + toolbar2Onload : $ empty , <nl> <nl> / / Container options <nl> container : null , <nl> MUI . Windows . windowOptions = { <nl> minimizable : true , <nl> maximizable : true , <nl> closable : true , <nl> - <nl> - / / Close options <nl> - storeOnClose : false , <nl> <nl> - / / Modal options <nl> + / / Close options <nl> + storeOnClose : false , <nl> + <nl> + / / Modal options <nl> modalOverlayClose : true , <nl> <nl> / / Draggable <nl> MUI . Windows . windowOptions = { <nl> / / Resizable <nl> resizable : null , <nl> resizeLimit : { ' x ' : [ 250 , 2500 ] , ' y ' : [ 125 , 2000 ] } , <nl> - <nl> + <nl> / / Style options : <nl> addClass : ' ' , <nl> width : 300 , <nl> height : 125 , <nl> headerHeight : 25 , <nl> footerHeight : 25 , <nl> - cornerRadius : 8 , <nl> + cornerRadius : 8 , <nl> x : null , <nl> y : null , <nl> scrollbars : true , <nl> MUI . Window = new Class ( { <nl> Implements : [ Events , Options ] , <nl> <nl> options : MUI . Windows . windowOptions , <nl> - <nl> + <nl> initialize : function ( options ) { <nl> - this . setOptions ( options ) ; <nl> + this . setOptions ( options ) ; <nl> <nl> / / Shorten object chain <nl> var options = this . options ; <nl> MUI . Window = new Class ( { <nl> isCollapsed : false , <nl> timestamp : $ time ( ) <nl> } ) ; <nl> - <nl> + <nl> if ( options . type ! = ' window ' ) { <nl> options . container = document . body ; <nl> options . minimizable = false ; <nl> MUI . Window = new Class ( { <nl> options . resizable = false ; <nl> } <nl> else { <nl> - options . resizable = true ; <nl> + options . resizable = true ; <nl> } <nl> } <nl> <nl> MUI . Window = new Class ( { <nl> options . closable = false ; <nl> options . headerHeight = 0 ; <nl> } <nl> - <nl> + <nl> / / Minimizable , dock is required and window cannot be modal <nl> if ( MUI . Dock & & $ ( MUI . options . dock ) ) { <nl> if ( MUI . Dock . dock & & options . type ! = ' modal ' & & options . type ! = ' modal2 ' ) { <nl> MUI . Window = new Class ( { <nl> this . options . footerHeight = 0 ; <nl> this . options . headerHeight = 0 ; <nl> } <nl> - <nl> - / / If window has no ID , give it one . <nl> + <nl> + / / If window has no ID , give it one . <nl> options . id = options . id | | ' win ' + ( + + MUI . Windows . windowIDCount ) ; <nl> - <nl> - this . windowEl = $ ( options . id ) ; <nl> - <nl> + <nl> + this . windowEl = $ ( options . id ) ; <nl> + <nl> if ( options . require . css . length | | options . require . images . length ) { <nl> new MUI . Require ( { <nl> css : options . require . css , <nl> images : options . require . images , <nl> onload : function ( ) { <nl> this . newWindow ( ) ; <nl> - } . bind ( this ) <nl> + } . bind ( this ) <nl> } ) ; <nl> - } <nl> + } <nl> else { <nl> this . newWindow ( ) ; <nl> } <nl> - <nl> + <nl> / / Return window object <nl> return this ; <nl> } , <nl> - saveValues : function ( ) { <nl> + saveValues : function ( ) { <nl> var coordinates = this . windowEl . getCoordinates ( ) ; <nl> this . options . x = coordinates . left . toInt ( ) ; <nl> this . options . y = coordinates . top . toInt ( ) ; <nl> } , <nl> - <nl> + <nl> / * <nl> <nl> Internal Function : newWindow <nl> - <nl> - Arguments : <nl> + <nl> + Arguments : <nl> properties <nl> <nl> * / <nl> MUI . Window = new Class ( { <nl> var instances = MUI . Windows . instances ; <nl> var instanceID = MUI . Windows . instances . get ( this . options . id ) ; <nl> var options = this . options ; <nl> - <nl> + <nl> / / Here we check to see if there is already a class instance for this window <nl> - if ( instanceID ) var instance = instanceID ; <nl> + if ( instanceID ) var instance = instanceID ; <nl> <nl> / / Check if window already exists and is not in progress of closing <nl> if ( this . windowEl & & ! this . isClosing ) { <nl> MUI . Window = new Class ( { <nl> <nl> this . windowEl . removeClass ( ' windowClosed ' ) ; <nl> this . windowEl . setStyle ( ' opacity ' , 0 ) ; <nl> - this . windowEl . addClass ( ' mocha ' ) ; <nl> + this . windowEl . addClass ( ' mocha ' ) ; <nl> <nl> if ( MUI . Dock & & $ ( MUI . options . dock ) & & instance . options . type = = ' window ' ) { <nl> var currentButton = $ ( instance . options . id + ' _dockTab ' ) ; <nl> MUI . Window = new Class ( { <nl> } <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> } <nl> - <nl> + <nl> instance . displayNewWindow ( ) ; <nl> <nl> } <nl> MUI . Window = new Class ( { <nl> else { <nl> var coordinates = document . getCoordinates ( ) ; <nl> if ( this . windowEl . getStyle ( ' left ' ) . toInt ( ) > coordinates . width | | this . windowEl . getStyle ( ' top ' ) . toInt ( ) > coordinates . height ) { <nl> - MUI . centerWindow ( this . windowEl ) ; <nl> + MUI . centerWindow ( this . windowEl ) ; <nl> } <nl> setTimeout ( MUI . focusWindow . pass ( this . windowEl , this ) , 10 ) ; <nl> if ( MUI . options . standardEffects = = true ) { <nl> this . windowEl . shake ( ) ; <nl> - } <nl> + } <nl> } <nl> return ; <nl> } <nl> else { <nl> instances . set ( options . id , this ) ; <nl> } <nl> - <nl> + <nl> this . isClosing = false ; <nl> this . fireEvent ( ' onBeforeBuild ' ) ; <nl> <nl> MUI . Window = new Class ( { <nl> this . windowEl . store ( ' instance ' , this ) ; <nl> <nl> this . windowEl . addClass ( options . addClass ) ; <nl> - <nl> + <nl> if ( options . type = = ' modal2 ' ) { <nl> this . windowEl . addClass ( ' modal2 ' ) ; <nl> } <nl> MUI . Window = new Class ( { <nl> <nl> / / Inject window into DOM <nl> this . windowEl . inject ( options . container ) ; <nl> - <nl> + <nl> / / Convert CSS colors to Canvas colors . <nl> this . setColors ( ) ; <nl> - <nl> + <nl> if ( options . type ! = ' notification ' ) { <nl> this . setMochaControlsWidth ( ) ; <nl> - } <nl> + } <nl> <nl> / / Add content to window . <nl> MUI . updateContent ( { <nl> MUI . Window = new Class ( { <nl> ' require ' : { <nl> js : options . require . js , <nl> onload : options . require . onload <nl> - } <nl> - } ) ; <nl> - <nl> + } <nl> + } ) ; <nl> + <nl> / / Add content to window toolbar . <nl> if ( this . options . toolbar = = true ) { <nl> MUI . updateContent ( { <nl> MUI . Window = new Class ( { <nl> ' onContentLoaded ' : options . toolbar2Onload <nl> } ) ; <nl> } <nl> - <nl> + <nl> this . drawWindow ( ) ; <nl> - <nl> + <nl> / / Attach events to the window <nl> - this . attachDraggable ( ) ; <nl> + this . attachDraggable ( ) ; <nl> this . attachResizable ( ) ; <nl> this . setupEvents ( ) ; <nl> - <nl> + <nl> if ( options . resizable ) { <nl> this . adjustHandles ( ) ; <nl> } <nl> - <nl> + <nl> / / Position window . If position not specified by user then center the window on the page . <nl> if ( options . container = = document . body | | options . container = = MUI . Desktop . desktop ) { <nl> var dimensions = window . getSize ( ) ; <nl> MUI . Window = new Class ( { <nl> if ( ! options . y ) { <nl> if ( MUI . Desktop & & MUI . Desktop . desktop ) { <nl> var y = ( dimensions . y * . 5 ) - ( this . windowEl . offsetHeight * . 5 ) ; <nl> - if ( y < - options . shadowBlur ) y = - options . shadowBlur ; <nl> + if ( y < - options . shadowBlur ) y = - options . shadowBlur ; <nl> } <nl> else { <nl> var y = window . getScroll ( ) . y + ( window . getSize ( ) . y * . 5 ) - ( this . windowEl . offsetHeight * . 5 ) ; <nl> MUI . Window = new Class ( { <nl> ' top ' : y , <nl> ' left ' : x <nl> } ) ; <nl> - <nl> + <nl> / / Create opacityMorph <nl> - <nl> + <nl> this . opacityMorph = new Fx . Morph ( this . windowEl , { <nl> ' duration ' : 350 , <nl> transition : Fx . Transitions . Sine . easeInOut , <nl> MUI . Window = new Class ( { <nl> this . drawWindow ( ) ; <nl> } <nl> } . bind ( this ) <nl> - } ) ; <nl> + } ) ; <nl> + <nl> + this . displayNewWindow ( ) ; <nl> <nl> - this . displayNewWindow ( ) ; <nl> - <nl> / / This is a generic morph that can be reused later by functions like centerWindow ( ) <nl> / / It returns the windowEl element rather than this Class . <nl> this . morph = new Fx . Morph ( this . windowEl , { <nl> MUI . Window = new Class ( { <nl> } ) ; <nl> this . windowEl . store ( ' morph ' , this . morph ) ; <nl> <nl> - this . resizeMorph = new Fx . Elements ( [ this . contentWrapperEl , this . windowEl ] , { <nl> + this . resizeMorph = new Fx . Elements ( [ this . contentWrapperEl , this . windowEl ] , { <nl> duration : 400 , <nl> transition : Fx . Transitions . Sine . easeInOut , <nl> onStart : function ( ) { <nl> MUI . Window = new Class ( { <nl> / / Show iframe <nl> if ( this . iframeEl ) { <nl> this . iframeEl . setStyle ( ' visibility ' , ' visible ' ) ; <nl> - } <nl> + } <nl> } . bind ( this ) <nl> } ) ; <nl> - this . windowEl . store ( ' resizeMorph ' , this . resizeMorph ) ; <nl> + this . windowEl . store ( ' resizeMorph ' , this . resizeMorph ) ; <nl> <nl> / / Add check mark to menu if link exists in menu <nl> - / / Need to make sure the check mark is not added to links not in menu <nl> + / / Need to make sure the check mark is not added to links not in menu <nl> if ( $ ( this . windowEl . id + ' LinkCheck ' ) ) { <nl> this . check = new Element ( ' div ' , { <nl> ' class ' : ' check ' , <nl> ' id ' : this . options . id + ' _check ' <nl> } ) . inject ( this . windowEl . id + ' LinkCheck ' ) ; <nl> } <nl> - <nl> + <nl> if ( this . options . closeAfter ! = false ) { <nl> MUI . closeWindow . delay ( this . options . closeAfter , this , this . windowEl ) ; <nl> } <nl> MUI . Window = new Class ( { <nl> if ( MUI . Dock & & $ ( MUI . options . dock ) & & this . options . type = = ' window ' ) { <nl> MUI . Dock . createDockTab ( this . windowEl ) ; <nl> } <nl> - <nl> + <nl> } , <nl> displayNewWindow : function ( ) { <nl> <nl> options = this . options ; <nl> if ( options . type = = ' modal ' | | options . type = = ' modal2 ' ) { <nl> MUI . currentModal = this . windowEl ; <nl> - if ( Browser . Engine . trident4 ) { <nl> + if ( Browser . Engine . trident4 ) { <nl> $ ( ' modalFix ' ) . show ( ) ; <nl> } <nl> $ ( ' modalOverlay ' ) . show ( ) ; <nl> MUI . Window = new Class ( { <nl> $ $ ( ' . dockTab ' ) . removeClass ( ' activeDockTab ' ) ; <nl> $ $ ( ' . mocha ' ) . removeClass ( ' isFocused ' ) ; <nl> this . windowEl . addClass ( ' isFocused ' ) ; <nl> - <nl> + <nl> } <nl> else if ( MUI . options . advancedEffects = = false ) { <nl> this . windowEl . setStyle ( ' opacity ' , 1 ) ; <nl> MUI . Window = new Class ( { <nl> setTimeout ( MUI . focusWindow . pass ( this . windowEl , this ) , 10 ) ; <nl> } <nl> <nl> - } , <nl> + } , <nl> setupEvents : function ( ) { <nl> var windowEl = this . windowEl ; <nl> / / Set events <nl> MUI . Window = new Class ( { <nl> MUI . focusWindow ( windowEl ) ; <nl> if ( windowEl . getStyle ( ' top ' ) . toInt ( ) < - this . options . shadowBlur ) { <nl> windowEl . setStyle ( ' top ' , - this . options . shadowBlur ) ; <nl> - } <nl> + } <nl> } . bind ( this ) ) ; <nl> } <nl> <nl> MUI . Window = new Class ( { <nl> <nl> if ( this . maximizeButtonEl ) { <nl> this . maximizeButtonEl . addEvent ( ' click ' , function ( e ) { <nl> - new Event ( e ) . stop ( ) ; <nl> + new Event ( e ) . stop ( ) ; <nl> if ( this . isMaximized ) { <nl> MUI . Desktop . restoreWindow ( windowEl ) ; <nl> } else { <nl> MUI . Window = new Class ( { <nl> this . titleEl . addEvent ( ' selectstart ' , function ( e ) { <nl> e = new Event ( e ) . stop ( ) ; <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> if ( MUI . ieLegacySupport ) { <nl> this . titleBarEl . addEvent ( ' mousedown ' , function ( e ) { <nl> - this . titleEl . setCapture ( ) ; <nl> + this . titleEl . setCapture ( ) ; <nl> } . bind ( this ) ) ; <nl> this . titleBarEl . addEvent ( ' mouseup ' , function ( e ) { <nl> this . titleEl . releaseCapture ( ) ; <nl> } . bind ( this ) ) ; <nl> } <nl> - <nl> + <nl> this . titleBarEl . addEvent ( ' dblclick ' , function ( e ) { <nl> e = new Event ( e ) . stop ( ) ; <nl> MUI . collapseToggle ( this . windowEl ) ; <nl> MUI . Window = new Class ( { <nl> <nl> Internal Function : attachDraggable ( ) <nl> Make window draggable . <nl> - <nl> + <nl> * / <nl> attachDraggable : function ( ) { <nl> var windowEl = this . windowEl ; <nl> MUI . Window = new Class ( { <nl> limit : this . options . draggableLimit , <nl> snap : this . options . draggableSnap , <nl> onStart : function ( ) { <nl> - if ( this . options . type ! = ' modal ' & & this . options . type ! = ' modal2 ' ) { <nl> + if ( this . options . type ! = ' modal ' & & this . options . type ! = ' modal2 ' ) { <nl> MUI . focusWindow ( windowEl ) ; <nl> $ ( ' windowUnderlay ' ) . show ( ) ; <nl> } <nl> MUI . Window = new Class ( { <nl> else { <nl> this . iframeEl . hide ( ) ; <nl> } <nl> - } <nl> + } <nl> } . bind ( this ) , <nl> onComplete : function ( ) { <nl> if ( this . options . type ! = ' modal ' & & this . options . type ! = ' modal2 ' ) { <nl> MUI . Window = new Class ( { <nl> handle : [ this . e , this . ne ] , <nl> limit : { <nl> x : [ this . options . resizeLimit . x [ 0 ] - ( this . options . shadowBlur * 2 ) , this . options . resizeLimit . x [ 1 ] - ( this . options . shadowBlur * 2 ) ] <nl> - } , <nl> + } , <nl> modifiers : { x : ' width ' , y : false } , <nl> onStart : function ( ) { <nl> this . resizeOnStart ( ) ; <nl> MUI . Window = new Class ( { <nl> } . bind ( this ) , <nl> onComplete : function ( ) { <nl> this . resizeOnComplete ( ) ; <nl> - } . bind ( this ) <nl> + } . bind ( this ) <nl> } ) ; <nl> <nl> this . resizable4 = this . contentWrapperEl . makeResizable ( { <nl> MUI . Window = new Class ( { <nl> else { <nl> this . iframeEl . hide ( ) ; <nl> } <nl> - } <nl> + } <nl> } , <nl> resizeOnDrag : function ( ) { <nl> this . drawWindow ( ) ; <nl> this . adjustHandles ( ) ; <nl> - } , <nl> + } , <nl> resizeOnComplete : function ( ) { <nl> $ ( ' windowUnderlay ' ) . hide ( ) ; <nl> if ( this . iframeEl ) { <nl> MUI . Window = new Class ( { <nl> this . iframeEl . setStyle ( ' width ' , ' 99 % ' ) ; <nl> this . iframeEl . setStyle ( ' height ' , this . contentWrapperEl . offsetHeight ) ; <nl> this . iframeEl . setStyle ( ' width ' , ' 100 % ' ) ; <nl> - this . iframeEl . setStyle ( ' height ' , this . contentWrapperEl . offsetHeight ) ; <nl> + this . iframeEl . setStyle ( ' height ' , this . contentWrapperEl . offsetHeight ) ; <nl> } <nl> } <nl> - <nl> + <nl> / / Resize panels if there are any <nl> if ( this . contentWrapperEl . getChildren ( ' . column ' ) ! = null ) { <nl> MUI . rWidth ( this . contentWrapperEl ) ; <nl> MUI . Window = new Class ( { <nl> MUI . panelHeight ( column ) ; <nl> } ) ; <nl> } <nl> - <nl> + <nl> this . fireEvent ( ' onResize ' , this . windowEl ) ; <nl> } , <nl> adjustHandles : function ( ) { <nl> MUI . Window = new Class ( { <nl> var right = shadowBlur + shadowOffset . x - 1 ; <nl> var bottom = shadowBlur + shadowOffset . y - 1 ; <nl> var left = shadowBlur - shadowOffset . x - 1 ; <nl> - <nl> + <nl> var coordinates = this . windowEl . getCoordinates ( ) ; <nl> var width = coordinates . width - shadowBlur2x + 2 ; <nl> var height = coordinates . height - shadowBlur2x + 2 ; <nl> MUI . Window = new Class ( { <nl> } ) ; <nl> this . ne . setStyles ( { <nl> ' top ' : top , <nl> - ' right ' : right <nl> + ' right ' : right <nl> } ) ; <nl> this . se . setStyles ( { <nl> ' bottom ' : bottom , <nl> MUI . Window = new Class ( { <nl> <nl> * / <nl> insertWindowElements : function ( ) { <nl> - <nl> + <nl> var options = this . options ; <nl> var height = options . height ; <nl> var width = options . width ; <nl> MUI . Window = new Class ( { <nl> ' background ' : ' url ( ' + options . icon + ' ) 5px 4px no - repeat ' <nl> } ) ; <nl> } <nl> - <nl> + <nl> cache . contentBorderEl = new Element ( ' div ' , { <nl> ' id ' : id + ' _contentBorder ' , <nl> ' class ' : ' mochaContentBorder ' <nl> MUI . Window = new Class ( { <nl> ' height ' : height + ' px ' <nl> } <nl> } ) . inject ( cache . contentBorderEl ) ; <nl> - <nl> + <nl> if ( this . options . shape = = ' gauge ' ) { <nl> cache . contentBorderEl . setStyle ( ' borderWidth ' , 0 ) ; <nl> } <nl> MUI . Window = new Class ( { <nl> ' height ' : 10 <nl> } ) . inject ( this . windowEl ) ; <nl> } <nl> - <nl> + <nl> if ( this . options . useCanvas = = true & & MUI . ieLegacySupport ) { <nl> cache . canvasEl = new Element ( ' canvas ' , { <nl> ' id ' : id + ' _canvas ' , <nl> MUI . Window = new Class ( { <nl> G_vmlCanvasManager . initElement ( cache . canvasEl ) ; <nl> cache . canvasEl = this . windowEl . getElement ( ' . mochaCanvas ' ) ; <nl> } <nl> - } <nl> + } <nl> <nl> cache . controlsEl = new Element ( ' div ' , { <nl> ' id ' : id + ' _controls ' , <nl> MUI . Window = new Class ( { <nl> ' width ' : this . options . width , <nl> ' height ' : 26 <nl> } ) . inject ( this . windowEl , ' bottom ' ) ; <nl> - <nl> + <nl> if ( MUI . ieLegacySupport & & MUI . ieSupport = = ' excanvas ' ) { <nl> G_vmlCanvasManager . initElement ( cache . canvasHeaderEl ) ; <nl> cache . canvasHeaderEl = this . windowEl . getElement ( ' . mochaCanvasHeader ' ) ; <nl> MUI . Window = new Class ( { <nl> ' cursor ' : ' ne - resize ' <nl> } <nl> } ) . inject ( cache . overlayEl , ' after ' ) ; <nl> - <nl> + <nl> cache . e = new Element ( ' div ' , { <nl> ' id ' : id + ' _resizeHandle_e ' , <nl> - ' class ' : ' handle ' , <nl> + ' class ' : ' handle ' , <nl> ' styles ' : { <nl> ' top ' : 10 , <nl> ' right ' : 0 , <nl> ' cursor ' : ' e - resize ' <nl> } <nl> } ) . inject ( cache . overlayEl , ' after ' ) ; <nl> - <nl> + <nl> cache . se = new Element ( ' div ' , { <nl> ' id ' : id + ' _resizeHandle_se ' , <nl> ' class ' : ' handle cornerSE ' , <nl> MUI . Window = new Class ( { <nl> ' cursor ' : ' s - resize ' <nl> } <nl> } ) . inject ( cache . overlayEl , ' after ' ) ; <nl> - <nl> + <nl> cache . sw = new Element ( ' div ' , { <nl> ' id ' : id + ' _resizeHandle_sw ' , <nl> ' class ' : ' handle corner ' , <nl> MUI . Window = new Class ( { <nl> ' cursor ' : ' sw - resize ' <nl> } <nl> } ) . inject ( cache . overlayEl , ' after ' ) ; <nl> - <nl> + <nl> cache . w = new Element ( ' div ' , { <nl> ' id ' : id + ' _resizeHandle_w ' , <nl> - ' class ' : ' handle ' , <nl> + ' class ' : ' handle ' , <nl> ' styles ' : { <nl> ' top ' : 10 , <nl> ' left ' : 0 , <nl> ' cursor ' : ' w - resize ' <nl> } <nl> } ) . inject ( cache . overlayEl , ' after ' ) ; <nl> - <nl> + <nl> cache . nw = new Element ( ' div ' , { <nl> ' id ' : id + ' _resizeHandle_nw ' , <nl> - ' class ' : ' handle corner ' , <nl> + ' class ' : ' handle corner ' , <nl> ' styles ' : { <nl> ' top ' : 0 , <nl> ' left ' : 0 , <nl> MUI . Window = new Class ( { <nl> } ) . inject ( cache . overlayEl , ' after ' ) ; <nl> } <nl> $ extend ( this , cache ) ; <nl> - <nl> + <nl> } , <nl> / * <nl> - <nl> - Convert CSS colors to Canvas colors . <nl> - <nl> - * / <nl> + <nl> + Convert CSS colors to Canvas colors . <nl> + <nl> + * / <nl> setColors : function ( ) { <nl> - <nl> + <nl> if ( this . options . useCanvas = = true ) { <nl> <nl> / / Set TitlebarColor <nl> var pattern = / \ ? ( . * ? ) \ ) / ; <nl> if ( this . titleBarEl . getStyle ( ' backgroundImage ' ) ! = ' none ' ) { <nl> - var gradient = this . titleBarEl . getStyle ( ' backgroundImage ' ) ; <nl> + var gradient = this . titleBarEl . getStyle ( ' backgroundImage ' ) ; <nl> gradient = gradient . match ( pattern ) [ 1 ] ; <nl> gradient = gradient . parseQueryString ( ) ; <nl> - var gradientFrom = gradient . from ; <nl> - var gradientTo = gradient . to . replace ( / \ " / , ' ' ) ; / / IE7 was adding a quotation mark in . No idea why . <nl> - <nl> + var gradientFrom = gradient . from ; <nl> + var gradientTo = gradient . to . replace ( / \ " / , ' ' ) ; / / IE7 was adding a quotation mark in . No idea why . <nl> + <nl> this . options . headerStartColor = new Color ( gradientFrom ) ; <nl> this . options . headerStopColor = new Color ( gradientTo ) ; <nl> this . titleBarEl . addClass ( ' replaced ' ) ; <nl> - } <nl> - else if ( this . titleBarEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . titleBarEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> - this . options . headerStartColor = new Color ( this . titleBarEl . getStyle ( ' background - color ' ) ) . mix ( ' # fff ' , 20 ) ; <nl> + } <nl> + else if ( this . titleBarEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . titleBarEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> + this . options . headerStartColor = new Color ( this . titleBarEl . getStyle ( ' background - color ' ) ) . mix ( ' # fff ' , 20 ) ; <nl> this . options . headerStopColor = new Color ( this . titleBarEl . getStyle ( ' background - color ' ) ) . mix ( ' # 000 ' , 20 ) ; <nl> this . titleBarEl . addClass ( ' replaced ' ) ; <nl> } <nl> - <nl> + <nl> / / Set BodyBGColor <nl> - if ( this . windowEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . windowEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> + if ( this . windowEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . windowEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> this . options . bodyBgColor = new Color ( this . windowEl . getStyle ( ' background - color ' ) ) ; <nl> - this . windowEl . addClass ( ' replaced ' ) ; <nl> + this . windowEl . addClass ( ' replaced ' ) ; <nl> } <nl> - <nl> - / / Set resizableColor , the color of the SE corner resize handle <nl> - if ( this . options . resizable & & this . se . getStyle ( ' background - color ' ) ! = = ' ' & & this . se . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> + <nl> + / / Set resizableColor , the color of the SE corner resize handle <nl> + if ( this . options . resizable & & this . se . getStyle ( ' background - color ' ) ! = = ' ' & & this . se . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> this . options . resizableColor = new Color ( this . se . getStyle ( ' background - color ' ) ) ; <nl> - this . se . addClass ( ' replaced ' ) ; <nl> - } <nl> + this . se . addClass ( ' replaced ' ) ; <nl> + } <nl> <nl> } <nl> - <nl> + <nl> if ( this . options . useCanvasControls = = true ) { <nl> <nl> if ( this . minimizeButtonEl ) { <nl> <nl> / / Set Minimize Button Foreground Color <nl> - if ( this . minimizeButtonEl . getStyle ( ' color ' ) ! = = ' ' & & this . minimizeButtonEl . getStyle ( ' color ' ) ! = = ' transparent ' ) { <nl> - this . options . minimizeColor = new Color ( this . minimizeButtonEl . getStyle ( ' color ' ) ) ; <nl> + if ( this . minimizeButtonEl . getStyle ( ' color ' ) ! = = ' ' & & this . minimizeButtonEl . getStyle ( ' color ' ) ! = = ' transparent ' ) { <nl> + this . options . minimizeColor = new Color ( this . minimizeButtonEl . getStyle ( ' color ' ) ) ; <nl> } <nl> <nl> / / Set Minimize Button Background Color <nl> - if ( this . minimizeButtonEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . minimizeButtonEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> + if ( this . minimizeButtonEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . minimizeButtonEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> this . options . minimizeBgColor = new Color ( this . minimizeButtonEl . getStyle ( ' background - color ' ) ) ; <nl> this . minimizeButtonEl . addClass ( ' replaced ' ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> } <nl> - <nl> + <nl> if ( this . maximizeButtonEl ) { <nl> <nl> / / Set Maximize Button Foreground Color <nl> - if ( this . maximizeButtonEl . getStyle ( ' color ' ) ! = = ' ' & & this . maximizeButtonEl . getStyle ( ' color ' ) ! = = ' transparent ' ) { <nl> - this . options . maximizeColor = new Color ( this . maximizeButtonEl . getStyle ( ' color ' ) ) ; <nl> + if ( this . maximizeButtonEl . getStyle ( ' color ' ) ! = = ' ' & & this . maximizeButtonEl . getStyle ( ' color ' ) ! = = ' transparent ' ) { <nl> + this . options . maximizeColor = new Color ( this . maximizeButtonEl . getStyle ( ' color ' ) ) ; <nl> } <nl> - <nl> + <nl> / / Set Maximize Button Background Color <nl> - if ( this . maximizeButtonEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . maximizeButtonEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> + if ( this . maximizeButtonEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . maximizeButtonEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> this . options . maximizeBgColor = new Color ( this . maximizeButtonEl . getStyle ( ' background - color ' ) ) ; <nl> this . maximizeButtonEl . addClass ( ' replaced ' ) ; <nl> } <nl> - <nl> + <nl> } <nl> - <nl> + <nl> if ( this . closeButtonEl ) { <nl> <nl> / / Set Close Button Foreground Color <nl> - if ( this . closeButtonEl . getStyle ( ' color ' ) ! = = ' ' & & this . closeButtonEl . getStyle ( ' color ' ) ! = = ' transparent ' ) { <nl> - this . options . closeColor = new Color ( this . closeButtonEl . getStyle ( ' color ' ) ) ; <nl> + if ( this . closeButtonEl . getStyle ( ' color ' ) ! = = ' ' & & this . closeButtonEl . getStyle ( ' color ' ) ! = = ' transparent ' ) { <nl> + this . options . closeColor = new Color ( this . closeButtonEl . getStyle ( ' color ' ) ) ; <nl> } <nl> - <nl> + <nl> / / Set Close Button Background Color <nl> - if ( this . closeButtonEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . closeButtonEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> + if ( this . closeButtonEl . getStyle ( ' background - color ' ) ! = = ' ' & & this . closeButtonEl . getStyle ( ' background - color ' ) ! = = ' transparent ' ) { <nl> this . options . closeBgColor = new Color ( this . closeButtonEl . getStyle ( ' background - color ' ) ) ; <nl> this . closeButtonEl . addClass ( ' replaced ' ) ; <nl> } <nl> - <nl> + <nl> } <nl> } <nl> } , <nl> / * <nl> <nl> Internal function : drawWindow <nl> - This is where we create the canvas GUI <nl> + This is where we create the canvas GUI <nl> <nl> - Arguments : <nl> + Arguments : <nl> windowEl : the $ ( window ) <nl> shadows : ( boolean ) false will draw a window without shadows <nl> <nl> - * / <nl> - drawWindow : function ( shadows ) { <nl> - <nl> + * / <nl> + drawWindow : function ( shadows ) { <nl> + <nl> if ( this . drawingWindow = = true ) return ; <nl> this . drawingWindow = true ; <nl> - <nl> + <nl> if ( this . isCollapsed ) { <nl> this . drawWindowCollapsed ( shadows ) ; <nl> return ; <nl> } <nl> - <nl> + <nl> var windowEl = this . windowEl ; <nl> <nl> var options = this . options ; <nl> MUI . Window = new Class ( { <nl> ' height ' : height , <nl> ' top ' : shadowBlur - shadowOffset . y , <nl> ' left ' : shadowBlur - shadowOffset . x <nl> - } ) ; <nl> + } ) ; <nl> <nl> if ( this . options . useCanvas = = true ) { <nl> if ( MUI . ieLegacySupport ) { <nl> MUI . Window = new Class ( { <nl> ' bottom ' : shadowBlur + shadowOffset . y + 4 <nl> } ) ; <nl> } <nl> - <nl> + <nl> if ( this . options . useCanvas ! = false ) { <nl> - <nl> + <nl> / / Draw Window <nl> var ctx = this . canvasEl . getContext ( ' 2d ' ) ; <nl> ctx . clearRect ( 0 , 0 , width , height ) ; <nl> - <nl> + <nl> switch ( options . shape ) { <nl> case ' box ' : <nl> this . drawBox ( ctx , width , height , shadowBlur , shadowOffset , shadows ) ; <nl> MUI . Window = new Class ( { <nl> break ; <nl> } <nl> <nl> - if ( options . resizable ) { <nl> + if ( options . resizable ) { <nl> MUI . triangle ( <nl> ctx , <nl> width - ( shadowBlur + shadowOffset . x + 17 ) , <nl> MUI . Window = new Class ( { <nl> MUI . triangle ( ctx , 0 , 0 , 10 , 10 , options . resizableColor , 0 ) ; <nl> } <nl> } <nl> - <nl> + <nl> if ( options . type ! = ' notification ' & & options . useCanvasControls = = true ) { <nl> this . drawControls ( width , height , shadows ) ; <nl> } <nl> - <nl> + <nl> / / Resize panels if there are any <nl> if ( MUI . Desktop & & this . contentWrapperEl . getChildren ( ' . column ' ) . length ! = 0 ) { <nl> MUI . rWidth ( this . contentWrapperEl ) ; <nl> MUI . Window = new Class ( { <nl> MUI . panelHeight ( column ) ; <nl> } ) ; <nl> } <nl> - <nl> + <nl> this . drawingWindow = false ; <nl> - return this ; <nl> + return this ; <nl> <nl> } , <nl> drawWindowCollapsed : function ( shadows ) { <nl> <nl> var windowEl = this . windowEl ; <nl> - <nl> + <nl> var options = this . options ; <nl> var shadowBlur = options . shadowBlur ; <nl> var shadowBlur2x = shadowBlur * 2 ; <nl> var shadowOffset = options . shadowOffset ; <nl> - <nl> + <nl> var headerShadow = options . headerHeight + shadowBlur2x + 2 ; <nl> var height = headerShadow ; <nl> var width = this . contentWrapperEl . getStyle ( ' width ' ) . toInt ( ) + shadowBlur2x ; <nl> this . windowEl . setStyle ( ' height ' , height ) ; <nl> - <nl> + <nl> this . overlayEl . setStyles ( { <nl> ' height ' : height , <nl> ' top ' : shadowBlur - shadowOffset . y , <nl> ' left ' : shadowBlur - shadowOffset . x <nl> - } ) ; <nl> + } ) ; <nl> <nl> / / Part of the fix for IE6 select z - index bug <nl> if ( Browser . Engine . trident4 ) { <nl> MUI . Window = new Class ( { <nl> ' width ' : width - shadowBlur2x , <nl> ' height ' : options . headerHeight <nl> } ) ; <nl> - <nl> + <nl> / / Draw Window <nl> if ( this . options . useCanvas ! = false ) { <nl> this . canvasEl . height = height ; <nl> MUI . Window = new Class ( { <nl> <nl> var ctx = this . canvasEl . getContext ( ' 2d ' ) ; <nl> ctx . clearRect ( 0 , 0 , width , height ) ; <nl> - <nl> + <nl> this . drawBoxCollapsed ( ctx , width , height , shadowBlur , shadowOffset , shadows ) ; <nl> if ( options . useCanvasControls = = true ) { <nl> this . drawControls ( width , height , shadows ) ; <nl> } <nl> - <nl> + <nl> / / Invisible dummy object . The last element drawn is not rendered consistently while resizing in IE6 and IE7 <nl> if ( MUI . ieLegacySupport ) { <nl> MUI . triangle ( ctx , 0 , 0 , 10 , 10 , options . resizableColor , 0 ) ; <nl> } <nl> } <nl> - <nl> + <nl> this . drawingWindow = false ; <nl> return this ; <nl> <nl> - } , <nl> + } , <nl> drawControls : function ( width , height , shadows ) { <nl> var options = this . options ; <nl> var shadowBlur = options . shadowBlur ; <nl> var shadowOffset = options . shadowOffset ; <nl> var controlsOffset = options . controlsOffset ; <nl> - <nl> + <nl> / / Make sure controls are placed correctly . <nl> this . controlsEl . setStyles ( { <nl> ' right ' : shadowBlur + shadowOffset . x + controlsOffset . right , <nl> MUI . Window = new Class ( { <nl> this . closebuttonX = options . closable ? this . mochaControlsWidth - 7 : this . mochaControlsWidth + 12 ; <nl> this . maximizebuttonX = this . closebuttonX - ( options . maximizable ? 19 : 0 ) ; <nl> this . minimizebuttonX = this . maximizebuttonX - ( options . minimizable ? 19 : 0 ) ; <nl> - <nl> + <nl> var ctx2 = this . canvasControlsEl . getContext ( ' 2d ' ) ; <nl> ctx2 . clearRect ( 0 , 0 , 100 , 100 ) ; <nl> <nl> MUI . Window = new Class ( { <nl> if ( MUI . ieLegacySupport ) { <nl> MUI . circle ( ctx2 , 0 , 0 , 3 , this . options . resizableColor , 0 ) ; <nl> } <nl> - <nl> + <nl> } , <nl> drawBox : function ( ctx , width , height , shadowBlur , shadowOffset , shadows ) { <nl> <nl> MUI . Window = new Class ( { <nl> var cornerRadius = this . options . cornerRadius ; <nl> <nl> / / This is the drop shadow . It is created onion style . <nl> - if ( shadows ! = false ) { <nl> + if ( shadows ! = false ) { <nl> for ( var x = 0 ; x < = shadowBlur ; x + + ) { <nl> MUI . roundedRect ( <nl> ctx , <nl> MUI . Window = new Class ( { <nl> options . headerStartColor , / / Header gradient ' s top color <nl> options . headerStopColor / / Header gradient ' s bottom color <nl> ) ; <nl> - } <nl> + } <nl> } , <nl> drawBoxCollapsed : function ( ctx , width , height , shadowBlur , shadowOffset , shadows ) { <nl> <nl> var options = this . options ; <nl> var shadowBlur2x = shadowBlur * 2 ; <nl> var cornerRadius = options . cornerRadius ; <nl> - <nl> + <nl> / / This is the drop shadow . It is created onion style . <nl> if ( shadows ! = false ) { <nl> for ( var x = 0 ; x < = shadowBlur ; x + + ) { <nl> MUI . Window = new Class ( { <nl> options . headerStopColor / / Header gradient ' s bottom color <nl> ) ; <nl> <nl> - } , <nl> + } , <nl> drawGauge : function ( ctx , width , height , shadowBlur , shadowOffset , shadows ) { <nl> var options = this . options ; <nl> var radius = ( width * . 5 ) - ( shadowBlur ) + 16 ; <nl> - if ( shadows ! = false ) { <nl> + if ( shadows ! = false ) { <nl> for ( var x = 0 ; x < = shadowBlur ; x + + ) { <nl> MUI . circle ( <nl> ctx , <nl> MUI . Window = new Class ( { <nl> this . canvasHeaderEl . setStyles ( { <nl> ' top ' : shadowBlur - shadowOffset . y , <nl> ' left ' : shadowBlur - shadowOffset . x <nl> - } ) ; <nl> + } ) ; <nl> var ctx = this . canvasHeaderEl . getContext ( ' 2d ' ) ; <nl> ctx . clearRect ( 0 , 0 , width , 100 ) ; <nl> ctx . beginPath ( ) ; <nl> MUI . Window = new Class ( { <nl> topRoundedRect : function ( ctx , x , y , width , height , radius , headerStartColor , headerStopColor ) { <nl> var lingrad = ctx . createLinearGradient ( 0 , 0 , 0 , height ) ; <nl> lingrad . addColorStop ( 0 , ' rgb ( ' + headerStartColor . join ( ' , ' ) + ' ) ' ) ; <nl> - lingrad . addColorStop ( 1 , ' rgb ( ' + headerStopColor . join ( ' , ' ) + ' ) ' ) ; <nl> + lingrad . addColorStop ( 1 , ' rgb ( ' + headerStopColor . join ( ' , ' ) + ' ) ' ) ; <nl> ctx . fillStyle = lingrad ; <nl> ctx . beginPath ( ) ; <nl> ctx . moveTo ( x , y ) ; <nl> MUI . Window = new Class ( { <nl> ctx . quadraticCurveTo ( x + width , y , x + width - radius , y ) ; <nl> ctx . lineTo ( x + radius , y ) ; <nl> ctx . quadraticCurveTo ( x , y , x , y + radius ) ; <nl> - ctx . fill ( ) ; <nl> + ctx . fill ( ) ; <nl> } , <nl> maximizebutton : function ( ctx , x , y , rgbBg , aBg , rgb , a ) { <nl> / / Circle <nl> MUI . Window = new Class ( { <nl> ctx . fill ( ) ; <nl> / / X sign <nl> ctx . strokeStyle = ' rgba ( ' + rgb . join ( ' , ' ) + ' , ' + a + ' ) ' ; <nl> - ctx . lineWidth = 2 ; <nl> + ctx . lineWidth = 2 ; <nl> ctx . beginPath ( ) ; <nl> ctx . moveTo ( x , y - 3 . 5 ) ; <nl> ctx . lineTo ( x , y + 3 . 5 ) ; <nl> MUI . Window = new Class ( { <nl> ctx . fill ( ) ; <nl> / / Plus sign <nl> ctx . strokeStyle = ' rgba ( ' + rgb . join ( ' , ' ) + ' , ' + a + ' ) ' ; <nl> - ctx . lineWidth = 2 ; <nl> + ctx . lineWidth = 2 ; <nl> ctx . beginPath ( ) ; <nl> ctx . moveTo ( x - 3 , y - 3 ) ; <nl> ctx . lineTo ( x + 3 , y + 3 ) ; <nl> MUI . Window = new Class ( { <nl> ctx . fill ( ) ; <nl> / / Minus sign <nl> ctx . strokeStyle = ' rgba ( ' + rgb . join ( ' , ' ) + ' , ' + a + ' ) ' ; <nl> - ctx . lineWidth = 2 ; <nl> + ctx . lineWidth = 2 ; <nl> ctx . beginPath ( ) ; <nl> ctx . moveTo ( x - 3 . 5 , y ) ; <nl> ctx . lineTo ( x + 3 . 5 , y ) ; <nl> MUI . Window = new Class ( { <nl> <nl> Function : hideSpinner <nl> Hides the spinner . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . hideSpinner ( ) ; <nl> - ( end ) <nl> - <nl> - * / <nl> + ( end ) <nl> + <nl> + * / <nl> hideSpinner : function ( ) { <nl> if ( this . spinnerEl ) this . spinnerEl . hide ( ) ; <nl> return this ; <nl> MUI . Window = new Class ( { <nl> <nl> Function : showSpinner <nl> Shows the spinner . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . showSpinner ( ) ; <nl> - ( end ) <nl> - <nl> - * / <nl> - showSpinner : function ( ) { <nl> + ( end ) <nl> + <nl> + * / <nl> + showSpinner : function ( ) { <nl> if ( this . spinnerEl ) this . spinnerEl . show ( ) ; <nl> return this ; <nl> - } , <nl> - / * <nl> + } , <nl> + / * <nl> <nl> Function : close <nl> Closes the window . This is an alternative to using MUI . Core . closeWindow ( ) . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . close ( ) ; <nl> - ( end ) <nl> - <nl> + ( end ) <nl> + <nl> * / <nl> close : function ( ) { <nl> if ( ! this . isClosing ) MUI . closeWindow ( this . windowEl ) ; <nl> MUI . Window = new Class ( { <nl> <nl> Function : minimize <nl> Minimizes the window . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . minimize ( ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> * / <nl> minimize : function ( ) { <nl> MUI . Window = new Class ( { <nl> <nl> Function : maximize <nl> Maximizes the window . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . maximize ( ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> * / <nl> maximize : function ( ) { <nl> if ( this . isMinimized ) { <nl> MUI . Dock . restoreMinimized ( this . windowEl ) ; <nl> - } <nl> + } <nl> MUI . Desktop . maximizeWindow ( this . windowEl ) ; <nl> return this ; <nl> } , <nl> MUI . Window = new Class ( { <nl> <nl> Function : restore <nl> Restores a minimized / maximized window to its original size . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . restore ( ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> * / <nl> restore : function ( ) { <nl> MUI . Window = new Class ( { <nl> <nl> Function : resize <nl> Resize a window . <nl> - <nl> + <nl> Notes : <nl> - If Advanced Effects are on the resize is animated . If centered is set to true the window remains centered as it resizes . <nl> - <nl> - Example : <nl> + If Advanced Effects are on the resize is animated . If centered is set to true the window remains centered as it resizes . <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . resize ( { width : 500 , height : 300 , centered : true } ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> - * / <nl> - resize : function ( options ) { <nl> + * / <nl> + resize : function ( options ) { <nl> MUI . resizeWindow ( this . windowEl , options ) ; <nl> return this ; <nl> - } , <nl> + } , <nl> / * <nl> <nl> Function : center <nl> Center a window . <nl> - <nl> - Example : <nl> + <nl> + Example : <nl> ( start code ) <nl> $ ( ' myWindow ' ) . retrieve ( ' instance ' ) . center ( ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> * / <nl> center : function ( ) { <nl> MUI . centerWindow ( this . windowEl ) ; <nl> return this ; <nl> - } , <nl> - <nl> + } , <nl> + <nl> hide : function ( ) { <nl> this . windowEl . setStyle ( ' display ' , ' none ' ) ; <nl> return this ; <nl> } , <nl> - <nl> + <nl> show : function ( ) { <nl> this . windowEl . setStyle ( ' display ' , ' block ' ) ; <nl> return this ; <nl> - } <nl> - <nl> + } <nl> + <nl> } ) ; <nl> <nl> MUI . extend ( { <nl> MUI . extend ( { <nl> MUI . closeWindow ( ) ; <nl> ( end ) <nl> <nl> - Arguments : <nl> + Arguments : <nl> windowEl - the ID of the window to be closed <nl> <nl> Returns : <nl> MUI . extend ( { <nl> false - the window was not closed <nl> <nl> * / <nl> - closeWindow : function ( windowEl ) { <nl> + closeWindow : function ( windowEl ) { <nl> <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> - <nl> + <nl> / / Does window exist and is not already in process of closing ? <nl> if ( windowEl ! = $ ( windowEl ) | | instance . isClosing ) return ; <nl> - <nl> + <nl> instance . isClosing = true ; <nl> instance . fireEvent ( ' onClose ' , windowEl ) ; <nl> - <nl> + <nl> if ( instance . options . storeOnClose ) { <nl> this . storeOnClose ( instance , windowEl ) ; <nl> return ; <nl> MUI . extend ( { <nl> if ( ( instance . options . type = = ' modal ' | | instance . options . type = = ' modal2 ' ) & & Browser . Engine . trident4 ) { <nl> $ ( ' modalFix ' ) . hide ( ) ; <nl> } <nl> - <nl> - if ( MUI . options . advancedEffects = = false ) { <nl> + <nl> + if ( MUI . options . advancedEffects = = false ) { <nl> if ( instance . options . type = = ' modal ' | | instance . options . type = = ' modal2 ' ) { <nl> $ ( ' modalOverlay ' ) . setStyle ( ' opacity ' , 0 ) ; <nl> - } <nl> - MUI . closingJobs ( windowEl ) ; <nl> - return true ; <nl> + } <nl> + MUI . closingJobs ( windowEl ) ; <nl> + return true ; <nl> } <nl> else { <nl> / / Redraws IE windows without shadows since IE messes up canvas alpha when you change element opacity <nl> MUI . extend ( { <nl> closingJobs : function ( windowEl ) { <nl> <nl> var instances = MUI . Windows . instances ; <nl> - var instance = instances . get ( windowEl . id ) ; <nl> + var instance = instances . get ( windowEl . id ) ; <nl> windowEl . setStyle ( ' visibility ' , ' hidden ' ) ; <nl> / / Destroy throws an error in IE8 <nl> if ( MUI . ieLegacySupport ) { <nl> MUI . extend ( { <nl> else { <nl> windowEl . destroy ( ) ; <nl> } <nl> - instance . fireEvent ( ' onCloseComplete ' ) ; <nl> - <nl> + instance . fireEvent ( ' onCloseComplete ' ) ; <nl> + <nl> if ( instance . options . type ! = ' notification ' ) { <nl> var newFocus = this . getWindowWithHighestZindex ( ) ; <nl> this . focusWindow ( newFocus ) ; <nl> MUI . extend ( { <nl> } <nl> } , <nl> storeOnClose : function ( instance , windowEl ) { <nl> - <nl> + <nl> if ( instance . check ) instance . check . hide ( ) ; <nl> <nl> windowEl . setStyles ( { <nl> zIndex : - 1 <nl> } ) ; <nl> windowEl . addClass ( ' windowClosed ' ) ; <nl> - windowEl . removeClass ( ' mocha ' ) ; <nl> + windowEl . removeClass ( ' mocha ' ) ; <nl> <nl> if ( MUI . Dock & & $ ( MUI . options . dock ) & & instance . options . type = = ' window ' ) { <nl> var currentButton = $ ( instance . options . id + ' _dockTab ' ) ; <nl> MUI . extend ( { <nl> } <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> } <nl> - <nl> - instance . fireEvent ( ' onCloseComplete ' ) ; <nl> - <nl> + <nl> + instance . fireEvent ( ' onCloseComplete ' ) ; <nl> + <nl> if ( instance . options . type ! = ' notification ' ) { <nl> var newFocus = this . getWindowWithHighestZindex ( ) ; <nl> this . focusWindow ( newFocus ) ; <nl> } <nl> - <nl> - instance . isClosing = false ; <nl> - <nl> + <nl> + instance . isClosing = false ; <nl> + <nl> } , <nl> / * <nl> - <nl> - Function : closeAll <nl> + <nl> + Function : closeAll <nl> Close all open windows . <nl> <nl> * / <nl> - closeAll : function ( ) { <nl> + closeAll : function ( ) { <nl> $ $ ( ' . mocha ' ) . each ( function ( windowEl ) { <nl> this . closeWindow ( windowEl ) ; <nl> } . bind ( this ) ) ; <nl> } , <nl> / * <nl> - <nl> + <nl> Function : collapseToggle <nl> Collapses an expanded window . Expands a collapsed window . <nl> <nl> MUI . extend ( { <nl> collapseToggle : function ( windowEl ) { <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> var handles = windowEl . getElements ( ' . handle ' ) ; <nl> - if ( instance . isMaximized = = true ) return ; <nl> + if ( instance . isMaximized = = true ) return ; <nl> if ( instance . isCollapsed = = false ) { <nl> instance . isCollapsed = true ; <nl> handles . hide ( ) ; <nl> MUI . extend ( { <nl> } <nl> handles . show ( ) ; <nl> } <nl> - } , <nl> + } , <nl> / * <nl> <nl> Function : toggleWindowVisibility <nl> Toggle window visibility with Ctrl - Alt - Q . <nl> <nl> - * / <nl> + * / <nl> toggleWindowVisibility : function ( ) { <nl> MUI . Windows . instances . each ( function ( instance ) { <nl> - if ( instance . options . type = = ' modal ' | | instance . options . type = = ' modal2 ' | | instance . isMinimized = = true ) return ; <nl> + if ( instance . options . type = = ' modal ' | | instance . options . type = = ' modal2 ' | | instance . isMinimized = = true ) return ; <nl> var id = $ ( instance . options . id ) ; <nl> if ( id . getStyle ( ' visibility ' ) = = ' visible ' ) { <nl> if ( instance . iframe ) { <nl> MUI . extend ( { <nl> MUI . Windows . focusingWindow = false ; <nl> } ; <nl> windowClicked . delay ( 170 , this ) ; <nl> - <nl> + <nl> / / Only focus when needed <nl> if ( $ $ ( ' . mocha ' ) . length = = 0 ) return ; <nl> if ( windowEl ! = $ ( windowEl ) | | windowEl . hasClass ( ' isFocused ' ) ) return ; <nl> <nl> var instances = MUI . Windows . instances ; <nl> var instance = instances . get ( windowEl . id ) ; <nl> - <nl> + <nl> if ( instance . options . type = = ' notification ' ) { <nl> windowEl . setStyle ( ' zIndex ' , 11001 ) ; <nl> return ; <nl> MUI . extend ( { <nl> this . zIndex = element . getStyle ( ' zIndex ' ) ; <nl> if ( this . zIndex > = this . highestZindex ) { <nl> this . highestZindex = this . zIndex ; <nl> - } <nl> + } <nl> } . bind ( this ) ) ; <nl> $ $ ( ' . mocha ' ) . each ( function ( element ) { <nl> if ( element . getStyle ( ' zIndex ' ) = = this . highestZindex ) { <nl> MUI . extend ( { <nl> } . bind ( this ) ) ; <nl> return this . windowWithHighestZindex ; <nl> } , <nl> - blurAll : function ( ) { <nl> + blurAll : function ( ) { <nl> if ( MUI . Windows . focusingWindow = = false ) { <nl> $ $ ( ' . mocha ' ) . each ( function ( windowEl ) { <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> MUI . extend ( { <nl> } <nl> } , <nl> centerWindow : function ( windowEl ) { <nl> - <nl> + <nl> if ( ! windowEl ) { <nl> MUI . Windows . instances . each ( function ( instance ) { <nl> if ( instance . windowEl . hasClass ( ' isFocused ' ) ) { <nl> MUI . extend ( { <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> var options = instance . options ; <nl> var dimensions = options . container . getCoordinates ( ) ; <nl> - <nl> + <nl> var windowPosTop = window . getScroll ( ) . y + ( window . getSize ( ) . y * . 5 ) - ( windowEl . offsetHeight * . 5 ) ; <nl> if ( windowPosTop < - instance . options . shadowBlur ) { <nl> windowPosTop = - instance . options . shadowBlur ; <nl> MUI . extend ( { <nl> } , <nl> resizeWindow : function ( windowEl , options ) { <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> - <nl> + <nl> $ extend ( { <nl> width : null , <nl> height : null , <nl> MUI . extend ( { <nl> left : null , <nl> centered : true <nl> } , options ) ; <nl> - <nl> + <nl> var oldWidth = windowEl . getStyle ( ' width ' ) . toInt ( ) ; <nl> var oldHeight = windowEl . getStyle ( ' height ' ) . toInt ( ) ; <nl> var oldTop = windowEl . getStyle ( ' top ' ) . toInt ( ) ; <nl> var oldLeft = windowEl . getStyle ( ' left ' ) . toInt ( ) ; <nl> - <nl> + <nl> if ( options . centered ) { <nl> var top = options . top | | oldTop - ( ( options . height - oldHeight ) * . 5 ) ; <nl> var left = options . left | | oldLeft - ( ( options . width - oldWidth ) * . 5 ) ; <nl> MUI . extend ( { <nl> else { <nl> var top = options . top | | oldTop ; <nl> var left = options . left | | oldLeft ; <nl> - } <nl> - <nl> + } <nl> + <nl> if ( MUI . options . advancedEffects = = false ) { <nl> windowEl . setStyles ( { <nl> ' top ' : top , <nl> MUI . extend ( { <nl> ' width ' : options . width <nl> } , <nl> ' 1 ' : { ' top ' : top , <nl> - ' left ' : left <nl> + ' left ' : left <nl> } <nl> - } ) ; <nl> + } ) ; <nl> } <nl> return instance ; <nl> } , <nl> MUI . extend ( { <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> var contentWrapperEl = instance . contentWrapperEl ; <nl> var contentEl = instance . contentEl ; <nl> - <nl> + <nl> contentWrapperEl . setStyles ( { <nl> ' height ' : contentEl . offsetHeight , <nl> ' width ' : contentEl . offsetWidth <nl> - } ) ; <nl> + } ) ; <nl> instance . drawWindow ( ) ; <nl> - } <nl> + } <nl> } ) ; <nl> <nl> / / Toggle window visibility with Ctrl - Alt - Q <nl> Script : Modal . js <nl> Create modal dialog windows . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Requires : <nl> Core . js , Window . js <nl> <nl> See Also : <nl> - < Window > <nl> - <nl> + < Window > <nl> + <nl> * / <nl> <nl> MUI . files [ MUI . path . source + ' Window / Modal . js ' ] = ' loaded ' ; <nl> MUI . files [ MUI . path . source + ' Window / Modal . js ' ] = ' loaded ' ; <nl> MUI . Modal = new Class ( { <nl> <nl> Extends : MUI . Window , <nl> - <nl> + <nl> options : { <nl> type : ' modal ' <nl> - } , <nl> - <nl> + } , <nl> + <nl> initialize : function ( options ) { <nl> - <nl> + <nl> if ( ! $ ( ' modalOverlay ' ) ) { <nl> this . modalInitialize ( ) ; <nl> - <nl> + <nl> window . addEvent ( ' resize ' , function ( ) { <nl> this . setModalSize ( ) ; <nl> } . bind ( this ) ) ; <nl> - } <nl> + } <nl> this . parent ( options ) ; <nl> <nl> } , <nl> MUI . Modal = new Class ( { <nl> var modalOverlay = new Element ( ' div ' , { <nl> ' id ' : ' modalOverlay ' , <nl> ' styles ' : { <nl> - ' height ' : document . getCoordinates ( ) . height , <nl> + ' height ' : document . getCoordinates ( ) . height , <nl> ' opacity ' : . 6 <nl> } <nl> } ) . inject ( document . body ) ; <nl> - <nl> + <nl> modalOverlay . setStyles ( { <nl> ' position ' : Browser . Engine . trident4 ? ' absolute ' : ' fixed ' <nl> } ) ; <nl> - <nl> + <nl> modalOverlay . addEvent ( ' click ' , function ( e ) { <nl> var instance = MUI . Windows . instances . get ( MUI . currentModal . id ) ; <nl> if ( instance . options . modalOverlayClose = = true ) { <nl> MUI . closeWindow ( MUI . currentModal ) ; <nl> } <nl> } ) ; <nl> - <nl> + <nl> if ( Browser . Engine . trident4 ) { <nl> var modalFix = new Element ( ' iframe ' , { <nl> ' id ' : ' modalFix ' , <nl> Script : Windows - from - html . js <nl> Create windows from html markup in page . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Requires : <nl> Core . js , Window . js <nl> Example : <nl> < div class = " mocha " id = " mywindow " style = " width : 300px ; height : 255px ; top : 50px ; left : 350px " > <nl> < h3 class = " mochaTitle " > My Window < / h3 > <nl> < p > My Window Content < / p > <nl> - < / div > <nl> + < / div > <nl> ( end ) <nl> <nl> See Also : <nl> MUI . extend ( { <nl> el . hide ( ) ; / / Required by Opera , and probably IE7 <nl> } <nl> var title = el . getElement ( ' h3 . mochaTitle ' ) ; <nl> - <nl> + <nl> if ( Browser . Engine . presto ) el . show ( ) ; <nl> - <nl> + <nl> var elDimensions = el . getStyles ( ' height ' , ' width ' ) ; <nl> var properties = { <nl> id : el . getProperty ( ' id ' ) , <nl> MUI . extend ( { <nl> properties . title = title . innerHTML ; <nl> title . destroy ( ) ; <nl> } <nl> - <nl> + <nl> / / Get content and destroy the element <nl> properties . content = el . innerHTML ; <nl> el . destroy ( ) ; <nl> - <nl> + <nl> / / Create window <nl> new MUI . Window ( properties , true ) ; <nl> } . bind ( this ) ) ; <nl> Script : Windows - from - json . js <nl> Create one or more windows from JSON data . You can define all the same properties as you can for new MUI . Window ( ) . Undefined properties are set to their defaults . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Syntax : <nl> ( start code ) <nl> Example : <nl> } <nl> ( end ) <nl> <nl> - Note : <nl> + Note : <nl> Windows created from JSON are not compatible with the current cookie based version <nl> - of Save and Load Workspace . <nl> + of Save and Load Workspace . <nl> <nl> See Also : <nl> < Window > <nl> See Also : <nl> <nl> MUI . files [ MUI . path . source + ' Window / Windows - from - json . js ' ] = ' loaded ' ; <nl> <nl> - MUI . extend ( { <nl> + MUI . extend ( { <nl> newWindowsFromJSON : function ( newWindows ) { <nl> newWindows . each ( function ( options ) { <nl> var temp = new Hash ( options ) ; <nl> MUI . extend ( { <nl> if ( value . substring ( 0 , 8 ) = = ' function ' ) { <nl> eval ( " options . " + key + " = " + value ) ; <nl> } <nl> - } ) ; <nl> + } ) ; <nl> new MUI . Window ( options ) ; <nl> } ) ; <nl> } <nl> Script : Arrange - cascade . js <nl> Cascade windows . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Requires : <nl> Core . js , Window . js <nl> Syntax : <nl> <nl> MUI . files [ MUI . path . source + ' Window / Arrange - cascade . js ' ] = ' loaded ' ; <nl> <nl> - MUI . extend ( { <nl> + MUI . extend ( { <nl> arrangeCascade : function ( ) { <nl> <nl> var viewportTopOffset = 30 ; / / Use a negative number if necessary to place first window where you want it <nl> var viewportLeftOffset = 20 ; <nl> var windowTopOffset = 50 ; / / Initial vertical spacing of each window <nl> - var windowLeftOffset = 40 ; <nl> + var windowLeftOffset = 40 ; <nl> <nl> / / See how much space we have to work with <nl> var coordinates = document . getCoordinates ( ) ; <nl> - <nl> + <nl> var openWindows = 0 ; <nl> MUI . Windows . instances . each ( function ( instance ) { <nl> - if ( ! instance . isMinimized & & instance . options . draggable ) openWindows + + ; <nl> + if ( ! instance . isMinimized & & instance . options . draggable ) openWindows + + ; <nl> } ) ; <nl> - <nl> + <nl> if ( ( windowTopOffset * ( openWindows + 1 ) ) > = ( coordinates . height - viewportTopOffset ) ) { <nl> var topOffset = ( coordinates . height - viewportTopOffset ) / ( openWindows + 1 ) ; <nl> } <nl> else { <nl> var topOffset = windowTopOffset ; <nl> } <nl> - <nl> + <nl> if ( ( windowLeftOffset * ( openWindows + 1 ) ) > = ( coordinates . width - viewportLeftOffset - 20 ) ) { <nl> var leftOffset = ( coordinates . width - viewportLeftOffset - 20 ) / ( openWindows + 1 ) ; <nl> } <nl> MUI . extend ( { <nl> <nl> Script : Arrange - tile . js <nl> Cascade windows . <nl> - <nl> + <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> Authors : <nl> Harry Roberts and Greg Houston <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Requires : <nl> Core . js , Window . js <nl> Syntax : <nl> * / <nl> <nl> MUI . files [ MUI . path . source + ' Window / Arrange - tile . js ' ] = ' loaded ' ; <nl> - <nl> + <nl> MUI . extend ( { <nl> arrangeTile : function ( ) { <nl> <nl> MUI . extend ( { <nl> <nl> var x = 10 ; <nl> var y = 80 ; <nl> - <nl> + <nl> var instances = MUI . Windows . instances ; <nl> <nl> var windowsNum = 0 ; <nl> MUI . extend ( { <nl> <nl> var cols = 3 ; <nl> var rows = Math . ceil ( windowsNum / cols ) ; <nl> - <nl> + <nl> var coordinates = document . getCoordinates ( ) ; <nl> - <nl> + <nl> var col_width = ( ( coordinates . width - viewportLeftOffset ) / cols ) ; <nl> var col_height = ( ( coordinates . height - viewportTopOffset ) / rows ) ; <nl> - <nl> + <nl> var row = 0 ; <nl> var col = 0 ; <nl> - <nl> + <nl> instances . each ( function ( instance ) { <nl> if ( ! instance . isMinimized & & ! instance . isMaximized & & instance . options . draggable ) { <nl> - <nl> + <nl> var content = instance . contentWrapperEl ; <nl> var content_coords = content . getCoordinates ( ) ; <nl> var window_coords = instance . windowEl . getCoordinates ( ) ; <nl> - <nl> + <nl> / / Calculate the amount of padding around the content window <nl> var padding_top = content_coords . top - window_coords . top ; <nl> var padding_bottom = window_coords . height - content_coords . height - padding_top ; <nl> MUI . extend ( { <nl> var top = ( y + ( row * col_height ) ) ; <nl> <nl> instance . drawWindow ( ) ; <nl> - <nl> + <nl> MUI . focusWindow ( instance . windowEl ) ; <nl> - <nl> + <nl> if ( MUI . options . advancedEffects = = false ) { <nl> instance . windowEl . setStyles ( { <nl> ' top ' : top , <nl> MUI . extend ( { <nl> ' top ' : top , <nl> ' left ' : left <nl> } ) ; <nl> - } <nl> + } <nl> <nl> if ( + + col = = = cols ) { <nl> row + + ; <nl> Script : Tabs . js <nl> Functionality for window tabs . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> MIT - style license . <nl> MUI . extend ( { <nl> <nl> Script : Layout . js <nl> Create web application layouts . Enables window maximize . <nl> - <nl> + <nl> Copyright : <nl> Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> - MIT - style license . <nl> + MIT - style license . <nl> <nl> Requires : <nl> Core . js <nl> - <nl> + <nl> * / <nl> <nl> MUI . files [ MUI . path . source + ' Layout / Layout . js ' ] = ' loaded ' ; <nl> MUI . extend ( { <nl> } ) ; <nl> <nl> MUI . Desktop = { <nl> - <nl> + <nl> options : { <nl> / / Naming options : <nl> / / If you change the IDs of the MochaUI Desktop containers in your HTML , you need to change them here as well . <nl> MUI . Desktop = { <nl> pageWrapper : ' pageWrapper ' , <nl> page : ' page ' , <nl> desktopFooter : ' desktopFooterWrapper ' <nl> - } , <nl> + } , <nl> initialize : function ( ) { <nl> <nl> this . desktop = $ ( this . options . desktop ) ; <nl> MUI . Desktop = { <nl> this . pageWrapper = $ ( this . options . pageWrapper ) ; <nl> this . page = $ ( this . options . page ) ; <nl> this . desktopFooter = $ ( this . options . desktopFooter ) ; <nl> - <nl> + <nl> if ( this . desktop ) { <nl> ( $ $ ( ' body ' ) ) . setStyles ( { <nl> overflow : ' hidden ' , <nl> MUI . Desktop = { <nl> ( $ $ ( ' html ' ) ) . setStyles ( { <nl> overflow : ' hidden ' , <nl> height : ' 100 % ' <nl> - } ) ; <nl> - } <nl> - <nl> + } ) ; <nl> + } <nl> + <nl> / / This is run on dock initialize so no need to do it twice . <nl> if ( ! MUI . Dock ) { <nl> this . setDesktopSize ( ) ; <nl> } <nl> - this . menuInitialize ( ) ; <nl> + this . menuInitialize ( ) ; <nl> <nl> / / Resize desktop , page wrapper , modal overlay , and maximized windows when browser window is resized <nl> window . addEvent ( ' resize ' , function ( e ) { <nl> this . onBrowserResize ( ) ; <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> if ( MUI . myChain ) { <nl> MUI . myChain . callChain ( ) ; <nl> } <nl> - <nl> + <nl> } , <nl> menuInitialize : function ( ) { <nl> / / Fix for dropdown menus in IE6 <nl> MUI . Desktop = { <nl> <nl> / / var dock = $ ( MUI . options . dock ) ; <nl> var dockWrapper = $ ( MUI . options . dockWrapper ) ; <nl> - <nl> + <nl> / / Setting the desktop height may only be needed by IE7 <nl> if ( this . desktop ) { <nl> this . desktop . setStyle ( ' height ' , windowDimensions . height ) ; <nl> MUI . Desktop = { <nl> <nl> if ( MUI . Columns . instances . getKeys ( ) . length > 0 ) { / / Conditional is a fix for a bug in IE6 in the no toolbars demo . <nl> MUI . Desktop . resizePanels ( ) ; <nl> - } <nl> + } <nl> } , <nl> resizePanels : function ( ) { <nl> MUI . panelHeight ( ) ; <nl> - MUI . rWidth ( ) ; <nl> - } , <nl> + MUI . rWidth ( ) ; <nl> + } , <nl> / * <nl> - <nl> + <nl> Function : maximizeWindow <nl> Maximize a window . <nl> - <nl> + <nl> Syntax : <nl> ( start code ) <nl> MUI . Desktop . maximizeWindow ( windowEl ) ; <nl> - ( end ) <nl> + ( end ) <nl> <nl> - * / <nl> + * / <nl> maximizeWindow : function ( windowEl ) { <nl> <nl> var instance = MUI . Windows . instances . get ( windowEl . id ) ; <nl> MUI . Desktop = { <nl> <nl> / / If window no longer exists or is maximized , stop <nl> if ( windowEl ! = $ ( windowEl ) | | instance . isMaximized ) return ; <nl> - <nl> + <nl> if ( instance . isCollapsed ) { <nl> - MUI . collapseToggle ( windowEl ) ; <nl> + MUI . collapseToggle ( windowEl ) ; <nl> } <nl> <nl> instance . isMaximized = true ; <nl> - <nl> + <nl> / / If window is restricted to a container , it should not be draggable when maximized . <nl> if ( instance . options . restrict ) { <nl> windowDrag . detach ( ) ; <nl> MUI . Desktop = { <nl> instance . detachResizable ( ) ; <nl> } <nl> instance . titleBarEl . setStyle ( ' cursor ' , ' default ' ) ; <nl> - } <nl> + } <nl> <nl> / / If the window has a container that is not the desktop <nl> / / temporarily move the window to the desktop while it is minimized . <nl> MUI . Desktop = { <nl> if ( this . options . restrict ) { <nl> windowDrag . container = this . desktop ; <nl> } <nl> - } <nl> + } <nl> <nl> / / Save original position <nl> instance . oldTop = windowEl . getStyle ( ' top ' ) ; <nl> MUI . Desktop = { <nl> instance . iframeEl . hide ( ) ; <nl> } <nl> } <nl> - <nl> + <nl> var windowDimensions = document . getCoordinates ( ) ; <nl> var options = instance . options ; <nl> var shadowBlur = options . shadowBlur ; <nl> MUI . Desktop = { <nl> newHeight - = instance . contentBorderEl . getStyle ( ' margin - top ' ) . toInt ( ) ; <nl> newHeight - = instance . contentBorderEl . getStyle ( ' margin - bottom ' ) . toInt ( ) ; <nl> newHeight - = ( instance . toolbarWrapperEl ? instance . toolbarWrapperEl . getStyle ( ' height ' ) . toInt ( ) + instance . toolbarWrapperEl . getStyle ( ' margin - top ' ) . toInt ( ) : 0 ) ; <nl> - <nl> + <nl> MUI . resizeWindow ( windowEl , { <nl> width : windowDimensions . width , <nl> height : newHeight , <nl> MUI . Desktop = { <nl> left : shadowOffset . x - shadowBlur <nl> } ) ; <nl> instance . fireEvent ( ' onMaximize ' , windowEl ) ; <nl> - <nl> + <nl> if ( instance . maximizeButtonEl ) { <nl> instance . maximizeButtonEl . setProperty ( ' title ' , ' Restore ' ) ; <nl> } <nl> MUI . Desktop = { <nl> Syntax : <nl> ( start code ) <nl> MUI . Desktop . restoreWindow ( windowEl ) ; <nl> - ( end ) <nl> + ( end ) <nl> + <nl> + * / <nl> + restoreWindow : function ( windowEl ) { <nl> <nl> - * / <nl> - restoreWindow : function ( windowEl ) { <nl> - <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> - <nl> + <nl> / / Window exists and is maximized ? <nl> if ( windowEl ! = $ ( windowEl ) | | ! instance . isMaximized ) return ; <nl> - <nl> + <nl> var options = instance . options ; <nl> instance . isMaximized = false ; <nl> - <nl> + <nl> if ( options . restrict ) { <nl> instance . windowDrag . attach ( ) ; <nl> if ( options . resizable ) { <nl> instance . reattachResizable ( ) ; <nl> - } <nl> + } <nl> instance . titleBarEl . setStyle ( ' cursor ' , ' move ' ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> / / Hide iframe <nl> / / Iframe should be hidden when minimizing , maximizing , and moving for performance and Flash issues <nl> if ( instance . iframeEl ) { <nl> MUI . Desktop = { <nl> instance . iframeEl . hide ( ) ; <nl> } <nl> } <nl> - <nl> - var contentWrapperEl = instance . contentWrapperEl ; <nl> - <nl> + <nl> + var contentWrapperEl = instance . contentWrapperEl ; <nl> + <nl> MUI . resizeWindow ( windowEl , { <nl> width : contentWrapperEl . oldWidth , <nl> height : contentWrapperEl . oldHeight , <nl> MUI . Desktop = { <nl> left : instance . oldLeft <nl> } ) ; <nl> instance . fireEvent ( ' onRestore ' , windowEl ) ; <nl> - <nl> - if ( instance . maximizeButtonEl ) { <nl> + <nl> + if ( instance . maximizeButtonEl ) { <nl> instance . maximizeButtonEl . setProperty ( ' title ' , ' Maximize ' ) ; <nl> } <nl> } <nl> Arguments : <nl> <nl> Options : <nl> id - The ID of the column . This must be set when creating the column . <nl> - container - Defaults to MUI . Desktop . pageWrapper . <nl> + container - Defaults to MUI . Desktop . pageWrapper . <nl> placement - Can be ' right ' , ' main ' , or ' left ' . There must be at least one column with the ' main ' option . <nl> width - ' main ' column is fluid and should not be given a width . <nl> resizeLimit - resizelimit of a ' right ' or ' left ' column . <nl> Options : <nl> onResize - ( function ) Fired when the column is resized . <nl> onCollapse - ( function ) Fired when the column is collapsed . <nl> onExpand - ( function ) Fired when the column is expanded . <nl> - <nl> + <nl> * / <nl> MUI . Column = new Class ( { <nl> <nl> MUI . Column = new Class ( { <nl> options : { <nl> id : null , <nl> container : null , <nl> - placement : null , <nl> + placement : null , <nl> width : null , <nl> resizeLimit : [ ] , <nl> sortable : true , <nl> <nl> / / Events <nl> - onResize : $ empty , <nl> + onResize : $ empty , <nl> onCollapse : $ empty , <nl> onExpand : $ empty <nl> <nl> } , <nl> - <nl> + <nl> initialize : function ( options ) { <nl> this . setOptions ( options ) ; <nl> - <nl> + <nl> $ extend ( this , { <nl> timestamp : $ time ( ) , <nl> isCollapsed : false , <nl> oldWidth : 0 <nl> } ) ; <nl> - <nl> + <nl> / / If column has no ID , give it one . <nl> if ( this . options . id = = null ) { <nl> this . options . id = ' column ' + ( + + MUI . Columns . columnIDCount ) ; <nl> - } <nl> + } <nl> <nl> / / Shorten object chain <nl> var options = this . options ; <nl> MUI . Column = new Class ( { <nl> if ( this . columnEl ) { <nl> return ; <nl> } <nl> - else { <nl> + else { <nl> instances . set ( options . id , this ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> / / If loading columns into a panel , hide the regular content container . <nl> if ( $ ( options . container ) . getElement ( ' . pad ' ) ! = null ) { <nl> $ ( options . container ) . getElement ( ' . pad ' ) . hide ( ) ; <nl> } <nl> - <nl> + <nl> / / If loading columns into a window , hide the regular content container . <nl> if ( $ ( options . container ) . getElement ( ' . mochaContent ' ) ! = null ) { <nl> $ ( options . container ) . getElement ( ' . mochaContent ' ) . hide ( ) ; <nl> } <nl> - <nl> + <nl> this . columnEl = new Element ( ' div ' , { <nl> ' id ' : this . options . id , <nl> ' class ' : ' column expanded ' , <nl> MUI . Column = new Class ( { <nl> ' width ' : options . placement = = ' main ' ? null : options . width <nl> } <nl> } ) . inject ( $ ( options . container ) ) ; <nl> - <nl> + <nl> this . columnEl . store ( ' instance ' , this ) ; <nl> - <nl> + <nl> var parent = this . columnEl . getParent ( ) ; <nl> var columnHeight = parent . getStyle ( ' height ' ) . toInt ( ) ; <nl> - this . columnEl . setStyle ( ' height ' , columnHeight ) ; <nl> - <nl> + this . columnEl . setStyle ( ' height ' , columnHeight ) ; <nl> + <nl> if ( this . options . sortable ) { <nl> if ( ! this . options . container . retrieve ( ' sortables ' ) ) { <nl> var sortables = new Sortables ( this . columnEl , { <nl> opacity : 1 , <nl> - handle : ' . panel - header ' , <nl> + handle : ' . panel - header ' , <nl> constrain : false , <nl> - revert : false , <nl> + revert : false , <nl> onSort : function ( ) { <nl> $ $ ( ' . column ' ) . each ( function ( column ) { <nl> column . getChildren ( ' . panelWrapper ' ) . each ( function ( panelWrapper ) { <nl> MUI . Column = new Class ( { <nl> } . bind ( this ) ) ; <nl> } . bind ( this ) <nl> } ) ; <nl> - this . options . container . store ( ' sortables ' , sortables ) ; <nl> + this . options . container . store ( ' sortables ' , sortables ) ; <nl> } <nl> else { <nl> this . options . container . retrieve ( ' sortables ' ) . addLists ( this . columnEl ) ; <nl> } <nl> - } <nl> - <nl> + } <nl> + <nl> if ( options . placement = = ' main ' ) { <nl> this . columnEl . addClass ( ' rWidth ' ) ; <nl> } <nl> MUI . Column = new Class ( { <nl> } , <nl> columnToggle : function ( ) { <nl> var column = this . columnEl ; <nl> - <nl> + <nl> / / Collapse <nl> if ( this . isCollapsed = = false ) { <nl> this . oldWidth = column . getStyle ( ' width ' ) . toInt ( ) ; <nl> MUI . Column = new Class ( { <nl> this . columnToggle ( ) ; <nl> } . bind ( this ) ) ; <nl> this . handleEl . setStyle ( ' cursor ' , ' pointer ' ) . addClass ( ' detached ' ) ; <nl> - <nl> + <nl> column . setStyle ( ' width ' , 0 ) ; <nl> this . isCollapsed = true ; <nl> column . addClass ( ' collapsed ' ) ; <nl> column . removeClass ( ' expanded ' ) ; <nl> - MUI . rWidth ( ) ; <nl> + MUI . rWidth ( ) ; <nl> this . fireEvent ( ' onCollapse ' ) ; <nl> } <nl> / / Expand <nl> Options : <nl> evalScripts - ( boolean ) An xhr loadMethod option . Defaults to true . <nl> evalResponse - ( boolean ) An xhr loadMethod option . Defaults to false . <nl> content - ( string or element ) An html loadMethod option . <nl> - tabsURL - ( url ) <nl> + tabsURL - ( url ) <nl> tabsData - ( hash ) Data to send with the URL . Defaults to null . <nl> tabsOnload - ( function ) <nl> header - ( boolean ) Display the panel header or not <nl> Options : <nl> onResize - ( function ) Fired when the panel is resized . <nl> onCollapse - ( function ) Fired when the panel is collapsed . <nl> onExpand - ( function ) Fired when the panel is expanded . <nl> - <nl> + <nl> * / <nl> MUI . Panel = new Class ( { <nl> - <nl> + <nl> Implements : [ Events , Options ] , <nl> - <nl> + <nl> options : { <nl> id : null , <nl> title : ' New Panel ' , <nl> MUI . Panel = new Class ( { <nl> images : [ ] , <nl> js : [ ] , <nl> onload : null <nl> - } , <nl> + } , <nl> loadMethod : null , <nl> contentURL : null , <nl> - <nl> + <nl> / / xhr options <nl> method : ' get ' , <nl> data : null , <nl> evalScripts : true , <nl> evalResponse : false , <nl> - <nl> + <nl> / / html options <nl> content : ' Panel content ' , <nl> - <nl> + <nl> / / Tabs <nl> tabsURL : null , <nl> tabsData : null , <nl> tabsOnload : $ empty , <nl> <nl> - header : true , <nl> + header : true , <nl> headerToolbox : false , <nl> headerToolboxURL : ' pages / lipsum . html ' , <nl> - headerToolboxOnload : $ empty , <nl> + headerToolboxOnload : $ empty , <nl> <nl> / / Style options : <nl> height : 125 , <nl> addClass : ' ' , <nl> scrollbars : true , <nl> padding : { top : 8 , right : 8 , bottom : 8 , left : 8 } , <nl> - <nl> + <nl> / / Other : <nl> collapsible : true , <nl> <nl> MUI . Panel = new Class ( { <nl> onCollapse : $ empty , <nl> onExpand : $ empty <nl> <nl> - } , <nl> + } , <nl> initialize : function ( options ) { <nl> this . setOptions ( options ) ; <nl> <nl> MUI . Panel = new Class ( { <nl> var instances = MUI . Panels . instances ; <nl> var instanceID = instances . get ( this . options . id ) ; <nl> var options = this . options ; <nl> - <nl> + <nl> / / Check to see if there is already a class instance for this panel <nl> if ( instanceID ) { <nl> var instance = instanceID ; <nl> MUI . Panel = new Class ( { <nl> if ( this . panelEl ) { <nl> return ; <nl> } <nl> - else { <nl> + else { <nl> instances . set ( this . options . id , this ) ; <nl> } <nl> <nl> - this . fireEvent ( ' onBeforeBuild ' ) ; <nl> - <nl> + this . fireEvent ( ' onBeforeBuild ' ) ; <nl> + <nl> if ( options . loadMethod = = ' iframe ' ) { <nl> / / Iframes have their own padding . <nl> options . padding = { top : 0 , right : 0 , bottom : 0 , left : 0 } ; <nl> MUI . Panel = new Class ( { <nl> if ( $ ( options . column ) . getChildren ( ) . length = = 0 ) { <nl> this . showHandle = false ; <nl> } <nl> - <nl> + <nl> this . panelWrapperEl = new Element ( ' div ' , { <nl> ' id ' : this . options . id + ' _wrapper ' , <nl> - ' class ' : ' panelWrapper expanded ' <nl> - } ) . inject ( $ ( options . column ) ) ; <nl> - <nl> + ' class ' : ' panelWrapper expanded ' <nl> + } ) . inject ( $ ( options . column ) ) ; <nl> + <nl> this . panelEl = new Element ( ' div ' , { <nl> ' id ' : this . options . id , <nl> ' class ' : ' panel expanded ' , <nl> MUI . Panel = new Class ( { <nl> ' height ' : options . height <nl> } <nl> } ) . inject ( this . panelWrapperEl ) ; <nl> - <nl> + <nl> this . panelEl . store ( ' instance ' , this ) ; <nl> - <nl> + <nl> this . panelEl . addClass ( options . addClass ) ; <nl> - <nl> + <nl> this . contentEl = new Element ( ' div ' , { <nl> ' id ' : options . id + ' _pad ' , <nl> ' class ' : ' pad ' <nl> MUI . Panel = new Class ( { <nl> / / This is in order to use the same variable as the windows do in updateContent . <nl> / / May rethink this . <nl> this . contentWrapperEl = this . panelEl ; <nl> - <nl> + <nl> this . contentEl . setStyles ( { <nl> ' padding - top ' : options . padding . top , <nl> ' padding - bottom ' : options . padding . bottom , <nl> ' padding - left ' : options . padding . left , <nl> ' padding - right ' : options . padding . right <nl> } ) ; <nl> - <nl> + <nl> this . panelHeaderEl = new Element ( ' div ' , { <nl> ' id ' : this . options . id + ' _header ' , <nl> ' class ' : ' panel - header ' , <nl> MUI . Panel = new Class ( { <nl> ' display ' : options . header ? ' block ' : ' none ' <nl> } <nl> } ) . inject ( this . panelEl , ' before ' ) ; <nl> - <nl> + <nl> var columnInstances = MUI . Columns . instances ; <nl> var columnInstance = columnInstances . get ( this . options . column ) ; <nl> - <nl> + <nl> if ( columnInstance . options . sortable ) { <nl> - this . panelHeaderEl . setStyle ( ' cursor ' , ' move ' ) ; <nl> - columnInstance . options . container . retrieve ( ' sortables ' ) . addItems ( this . panelWrapperEl ) ; <nl> + this . panelHeaderEl . setStyle ( ' cursor ' , ' move ' ) ; <nl> + columnInstance . options . container . retrieve ( ' sortables ' ) . addItems ( this . panelWrapperEl ) ; <nl> } <nl> - <nl> + <nl> if ( this . options . collapsible ) { <nl> this . collapseToggleInit ( ) ; <nl> } <nl> - <nl> + <nl> if ( this . options . headerToolbox ) { <nl> this . panelHeaderToolboxEl = new Element ( ' div ' , { <nl> ' id ' : options . id + ' _headerToolbox ' , <nl> ' class ' : ' panel - header - toolbox ' <nl> } ) . inject ( this . panelHeaderEl ) ; <nl> } <nl> - <nl> + <nl> this . panelHeaderContentEl = new Element ( ' div ' , { <nl> ' id ' : options . id + ' _headerContent ' , <nl> ' class ' : ' panel - headerContent ' <nl> } ) . inject ( this . panelHeaderEl ) ; <nl> - <nl> + <nl> this . titleEl = new Element ( ' h2 ' , { <nl> ' id ' : options . id + ' _title ' <nl> } ) . inject ( this . panelHeaderContentEl ) ; <nl> - <nl> + <nl> this . handleEl = new Element ( ' div ' , { <nl> ' id ' : options . id + ' _handle ' , <nl> ' class ' : ' horizontalHandle ' , <nl> MUI . Panel = new Class ( { <nl> ' display ' : this . showHandle = = true ? ' block ' : ' none ' <nl> } <nl> } ) . inject ( this . panelEl , ' after ' ) ; <nl> - <nl> + <nl> this . handleIconEl = new Element ( ' div ' , { <nl> ' id ' : options . id + ' _handle_icon ' , <nl> ' class ' : ' handleIcon ' <nl> - } ) . inject ( this . handleEl ) ; <nl> - <nl> + } ) . inject ( this . handleEl ) ; <nl> + <nl> addResizeBottom ( options . id ) ; <nl> - <nl> + <nl> if ( options . require . css . length | | options . require . images . length ) { <nl> new MUI . Require ( { <nl> css : options . require . css , <nl> images : options . require . images , <nl> onload : function ( ) { <nl> this . newPanel ( ) ; <nl> - } . bind ( this ) <nl> + } . bind ( this ) <nl> } ) ; <nl> - } <nl> + } <nl> else { <nl> this . newPanel ( ) ; <nl> } <nl> } , <nl> newPanel : function ( ) { <nl> - <nl> + <nl> options = this . options ; <nl> - <nl> - if ( this . options . headerToolbox ) { <nl> + <nl> + if ( this . options . headerToolbox ) { <nl> MUI . updateContent ( { <nl> ' element ' : this . panelEl , <nl> ' childElement ' : this . panelHeaderToolboxEl , <nl> MUI . Panel = new Class ( { <nl> ' url ' : options . headerToolboxURL , <nl> ' onContentLoaded ' : options . headerToolboxOnload <nl> } ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> if ( options . tabsURL = = null ) { <nl> this . titleEl . set ( ' html ' , options . title ) ; <nl> } else { <nl> MUI . Panel = new Class ( { <nl> ' data ' : options . tabsData , <nl> ' onContentLoaded ' : options . tabsOnload <nl> } ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> / / Add content to panel . <nl> MUI . updateContent ( { <nl> ' element ' : this . panelEl , <nl> MUI . Panel = new Class ( { <nl> ' require ' : { <nl> js : options . require . js , <nl> onload : options . require . onload <nl> - } <nl> + } <nl> } ) ; <nl> - <nl> + <nl> / / Do this when creating and removing panels <nl> $ ( options . column ) . getChildren ( ' . panelWrapper ' ) . each ( function ( panelWrapper ) { <nl> panelWrapper . getElement ( ' . panel ' ) . removeClass ( ' bottomPanel ' ) ; <nl> } ) ; <nl> $ ( options . column ) . getChildren ( ' . panelWrapper ' ) . getLast ( ) . getElement ( ' . panel ' ) . addClass ( ' bottomPanel ' ) ; <nl> - <nl> + <nl> MUI . panelHeight ( options . column , this . panelEl , ' new ' ) ; <nl> <nl> } , <nl> MUI . Panel = new Class ( { <nl> this . collapseToggleEl . addEvent ( ' click ' , function ( event ) { <nl> var panel = this . panelEl ; <nl> var panelWrapper = this . panelWrapperEl <nl> - <nl> + <nl> / / Get siblings and make sure they are not all collapsed . <nl> / / If they are all collapsed and the current panel is collapsing <nl> / / Then collapse the column . <nl> var instances = MUI . Panels . instances ; <nl> var expandedSiblings = [ ] ; <nl> - <nl> + <nl> panelWrapper . getAllPrevious ( ' . panelWrapper ' ) . each ( function ( sibling ) { <nl> var instance = instances . get ( sibling . getElement ( ' . panel ' ) . id ) ; <nl> if ( instance . isCollapsed = = false ) { <nl> expandedSiblings . push ( sibling . getElement ( ' . panel ' ) . id ) ; <nl> } <nl> } ) ; <nl> - <nl> + <nl> panelWrapper . getAllNext ( ' . panelWrapper ' ) . each ( function ( sibling ) { <nl> var instance = instances . get ( sibling . getElement ( ' . panel ' ) . id ) ; <nl> if ( instance . isCollapsed = = false ) { <nl> MUI . Panel = new Class ( { <nl> } <nl> this . oldHeight = panel . getStyle ( ' height ' ) . toInt ( ) ; <nl> if ( this . oldHeight < 10 ) this . oldHeight = 20 ; <nl> - this . contentEl . setStyle ( ' position ' , ' absolute ' ) ; / / This is so IE6 and IE7 will collapse the panel all the way <nl> - panel . setStyle ( ' height ' , 0 ) ; <nl> - this . isCollapsed = true ; <nl> + this . contentEl . setStyle ( ' position ' , ' absolute ' ) ; / / This is so IE6 and IE7 will collapse the panel all the way <nl> + panel . setStyle ( ' height ' , 0 ) ; <nl> + this . isCollapsed = true ; <nl> panelWrapper . addClass ( ' collapsed ' ) ; <nl> - panelWrapper . removeClass ( ' expanded ' ) ; <nl> + panelWrapper . removeClass ( ' expanded ' ) ; <nl> MUI . panelHeight ( options . column , panel , ' collapsing ' ) ; <nl> MUI . panelHeight ( ) ; / / Run this a second time for panels within panels <nl> this . collapseToggleEl . removeClass ( ' panel - collapsed ' ) ; <nl> this . collapseToggleEl . addClass ( ' panel - expand ' ) ; <nl> this . collapseToggleEl . setProperty ( ' title ' , ' Expand Panel ' ) ; <nl> - this . fireEvent ( ' onCollapse ' ) ; <nl> + this . fireEvent ( ' onCollapse ' ) ; <nl> } <nl> - <nl> + <nl> / / Expand Panel <nl> else { <nl> - this . contentEl . setStyle ( ' position ' , null ) ; / / This is so IE6 and IE7 will collapse the panel all the way <nl> + this . contentEl . setStyle ( ' position ' , null ) ; / / This is so IE6 and IE7 will collapse the panel all the way <nl> panel . setStyle ( ' height ' , this . oldHeight ) ; <nl> - this . isCollapsed = false ; <nl> + this . isCollapsed = false ; <nl> panelWrapper . addClass ( ' expanded ' ) ; <nl> panelWrapper . removeClass ( ' collapsed ' ) ; <nl> MUI . panelHeight ( this . options . column , panel , ' expanding ' ) ; <nl> MUI . Panel = new Class ( { <nl> this . collapseToggleEl . setProperty ( ' title ' , ' Collapse Panel ' ) ; <nl> this . fireEvent ( ' onExpand ' ) ; <nl> } <nl> - } . bind ( this ) ) ; <nl> - } <nl> + } . bind ( this ) ) ; <nl> + } <nl> } ) ; <nl> MUI . Panel . implement ( new Options , new Events ) ; <nl> <nl> MUI . Panel . implement ( new Options , new Events ) ; <nl> column - The column to resize the panels in <nl> changing - The panel that is collapsing , expanding , or new <nl> action - collapsing , expanding , or new <nl> - <nl> + <nl> * / <nl> <nl> MUI . extend ( { <nl> - / / Panel Height <nl> + / / Panel Height <nl> panelHeight : function ( column , changing , action ) { <nl> if ( column ! = null ) { <nl> MUI . panelHeight2 ( $ ( column ) , changing , action ) ; <nl> MUI . extend ( { <nl> panelHeight2 : function ( column , changing , action ) { <nl> <nl> var instances = MUI . Panels . instances ; <nl> - <nl> + <nl> var parent = column . getParent ( ) ; <nl> var columnHeight = parent . getStyle ( ' height ' ) . toInt ( ) ; <nl> if ( Browser . Engine . trident4 & & parent = = MUI . Desktop . pageWrapper ) { <nl> columnHeight - = 1 ; <nl> } <nl> column . setStyle ( ' height ' , columnHeight ) ; <nl> - <nl> + <nl> / / Get column panels <nl> var panels = [ ] ; <nl> column . getChildren ( ' . panelWrapper ' ) . each ( function ( panelWrapper ) { <nl> panels . push ( panelWrapper . getElement ( ' . panel ' ) ) ; <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> / / Get expanded column panels <nl> var panelsExpanded = [ ] ; <nl> column . getChildren ( ' . expanded ' ) . each ( function ( panelWrapper ) { <nl> panelsExpanded . push ( panelWrapper . getElement ( ' . panel ' ) ) ; <nl> - } . bind ( this ) ) ; <nl> - <nl> + } . bind ( this ) ) ; <nl> + <nl> / / All the panels in the column whose height will be effected . <nl> var panelsToResize = [ ] ; <nl> - <nl> + <nl> / / The panel with the greatest height . Remainders will be added to this panel <nl> - var tallestPanel ; <nl> + var tallestPanel ; <nl> var tallestPanelHeight = 0 ; <nl> - <nl> - this . panelsTotalHeight = 0 ; / / Height of all the panels in the column <nl> + <nl> + this . panelsTotalHeight = 0 ; / / Height of all the panels in the column <nl> this . height = 0 ; / / Height of all the elements in the column <nl> - <nl> + <nl> / / Set panel resize partners <nl> panels . each ( function ( panel ) { <nl> instance = instances . get ( panel . id ) ; <nl> MUI . extend ( { <nl> instance . handleEl . hide ( ) ; <nl> } <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> / / Add panels to panelsToResize <nl> / / Get the total height of all the resizable panels <nl> / / Get the total height of all the column ' s children <nl> column . getChildren ( ) . each ( function ( panelWrapper ) { <nl> - <nl> + <nl> panelWrapper . getChildren ( ) . each ( function ( el ) { <nl> <nl> if ( el . hasClass ( ' panel ' ) ) { <nl> MUI . extend ( { <nl> } . bind ( this ) ) ; <nl> return test ; <nl> } . bind ( this ) ; <nl> - <nl> + <nl> / / Is the panel that is collapsing , expanding , or new located after this panel ? <nl> - anyNextContainsChanging = function ( el ) { <nl> + anyNextContainsChanging = function ( el ) { <nl> var allNext = [ ] ; <nl> el . getParent ( ) . getAllNext ( ' . panelWrapper ' ) . each ( function ( panelWrapper ) { <nl> - allNext . push ( panelWrapper . getElement ( ' . panel ' ) ) ; <nl> - } . bind ( this ) ) ; <nl> - var test = allNext . contains ( changing ) ; <nl> - return test ; <nl> + allNext . push ( panelWrapper . getElement ( ' . panel ' ) ) ; <nl> + } . bind ( this ) ) ; <nl> + var test = allNext . contains ( changing ) ; <nl> + return test ; <nl> } . bind ( this ) ; <nl> - <nl> + <nl> nextExpandedChanging = function ( el ) { <nl> var test ; <nl> if ( el . getParent ( ) . getNext ( ' . expanded ' ) ) { <nl> MUI . extend ( { <nl> } <nl> return test ; <nl> } <nl> - <nl> - / / NEW PANEL <nl> + <nl> + / / NEW PANEL <nl> / / Resize panels that are " new " or not collapsed <nl> if ( action = = ' new ' ) { <nl> if ( ! instance . isCollapsed & & el ! = changing ) { <nl> MUI . extend ( { <nl> this . panelsTotalHeight + = el . offsetHeight . toInt ( ) ; <nl> } <nl> } <nl> - <nl> + <nl> / / COLLAPSING PANELS and CURRENTLY EXPANDED PANELS <nl> - / / Resize panels that are not collapsed . <nl> + / / Resize panels that are not collapsed . <nl> / / If a panel is collapsing resize any expanded panels below . <nl> / / If there are no expanded panels below it , resize the expanded panels above it . <nl> else if ( action = = null | | action = = ' collapsing ' ) { <nl> MUI . extend ( { <nl> this . panelsTotalHeight + = el . offsetHeight . toInt ( ) ; <nl> } <nl> } <nl> - <nl> + <nl> / / EXPANDING PANEL <nl> / / Resize panels that are not collapsed and are not expanding . <nl> / / Resize any expanded panels below the expanding panel . <nl> MUI . extend ( { <nl> if ( ! anyNextContainsChanging ( el ) | | ( ! anyExpandingNextSiblingsExpanded ( el ) & & nextExpandedChanging ( el ) ) ) { <nl> panelsToResize . push ( el ) ; <nl> this . panelsTotalHeight + = el . offsetHeight . toInt ( ) ; <nl> - } <nl> + } <nl> } <nl> <nl> if ( el . style . height ) { <nl> MUI . extend ( { <nl> this . height + = el . offsetHeight . toInt ( ) ; <nl> } <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> } . bind ( this ) ) ; <nl> <nl> / / Get the remaining height <nl> var remainingHeight = column . offsetHeight . toInt ( ) - this . height ; <nl> - <nl> + <nl> this . height = 0 ; <nl> <nl> / / Get height of all the column ' s children <nl> column . getChildren ( ) . each ( function ( el ) { <nl> this . height + = el . offsetHeight . toInt ( ) ; <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> var remainingHeight = column . offsetHeight . toInt ( ) - this . height ; <nl> <nl> panelsToResize . each ( function ( panel ) { <nl> MUI . extend ( { <nl> newPanelHeight = 0 ; <nl> } <nl> panel . setStyle ( ' height ' , newPanelHeight ) ; <nl> - } . bind ( this ) ) ; <nl> + } . bind ( this ) ) ; <nl> <nl> / / Make sure the remaining height is 0 . If not add / subtract the <nl> / / remaining height to the tallest panel . This makes up for browser resizing , <nl> / / off ratios , and users trying to give panels too much height . <nl> - <nl> + <nl> / / Get height of all the column ' s children <nl> this . height = 0 ; <nl> column . getChildren ( ) . each ( function ( panelWrapper ) { <nl> MUI . extend ( { <nl> } <nl> handle . setStyle ( ' height ' , handleHeight ) ; <nl> } ) ; <nl> - <nl> + <nl> panelsExpanded . each ( function ( panel ) { <nl> MUI . resizeChildren ( panel ) ; <nl> - } . bind ( this ) ) ; <nl> - <nl> + } . bind ( this ) ) ; <nl> + <nl> } , <nl> / / May rename this resizeIframeEl ( ) <nl> resizeChildren : function ( panel ) { <nl> MUI . extend ( { <nl> } ) ; <nl> instance . iframeEl . setStyles ( { <nl> ' width ' : contentWrapperEl . offsetWidth - contentWrapperEl . getStyle ( ' margin - left ' ) . toInt ( ) - contentWrapperEl . getStyle ( ' margin - right ' ) . toInt ( ) <nl> - } ) ; <nl> - } <nl> - } <nl> - <nl> + } ) ; <nl> + } <nl> + } <nl> + <nl> } , <nl> / / Remaining Width <nl> rWidth : function ( container ) { <nl> MUI . extend ( { <nl> currentWidth - = column . getStyle ( ' margin - right ' ) . toInt ( ) ; <nl> var parent = column . getParent ( ) ; <nl> this . width = 0 ; <nl> - <nl> + <nl> / / Get the total width of all the parent element ' s children <nl> parent . getChildren ( ) . each ( function ( el ) { <nl> if ( el . hasClass ( ' mocha ' ) ! = true ) { <nl> this . width + = el . offsetWidth . toInt ( ) ; <nl> } <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> / / Add the remaining width to the current element <nl> var remainingWidth = parent . offsetWidth . toInt ( ) - this . width ; <nl> var newWidth = currentWidth + remainingWidth ; <nl> MUI . extend ( { <nl> panel . setStyle ( ' width ' , newWidth - panel . getStyle ( ' margin - left ' ) . toInt ( ) - panel . getStyle ( ' margin - right ' ) . toInt ( ) ) ; <nl> MUI . resizeChildren ( panel ) ; <nl> } . bind ( this ) ) ; <nl> - <nl> + <nl> } ) ; <nl> } <nl> <nl> MUI . extend ( { <nl> function addResizeRight ( element , min , max ) { <nl> if ( ! $ ( element ) ) return ; <nl> element = $ ( element ) ; <nl> - <nl> + <nl> var instances = MUI . Columns . instances ; <nl> var instance = instances . get ( element . id ) ; <nl> - <nl> + <nl> var handle = element . getNext ( ' . columnHandle ' ) ; <nl> handle . setStyle ( ' cursor ' , ( Browser . Engine . webkit | | Browser . Engine . gecko ) ? ' col - resize ' : ' e - resize ' ) ; <nl> if ( ! min ) min = 50 ; <nl> function addResizeLeft ( element , min , max ) { <nl> var partner = element . getPrevious ( ' . column ' ) ; <nl> if ( ! min ) min = 50 ; <nl> if ( ! max ) max = 250 ; <nl> - if ( MUI . ieLegacySupport ) { <nl> + if ( MUI . ieLegacySupport ) { <nl> handle . addEvents ( { <nl> ' mousedown ' : function ( ) { <nl> handle . setCapture ( ) ; <nl> - } , <nl> + } , <nl> ' mouseup ' : function ( ) { <nl> handle . releaseCapture ( ) ; <nl> } <nl> function addResizeLeft ( element , min , max ) { <nl> MUI . rWidth ( element . getParent ( ) ) ; <nl> $ ( element ) . getElements ( ' iframe ' ) . setStyle ( ' visibility ' , ' visible ' ) ; <nl> partner . getElements ( ' iframe ' ) . setStyle ( ' visibility ' , ' visible ' ) ; <nl> - instance . fireEvent ( ' onResize ' ) ; <nl> + instance . fireEvent ( ' onResize ' ) ; <nl> } . bind ( this ) <nl> } ) ; <nl> } <nl> function addResizeLeft ( element , min , max ) { <nl> function addResizeBottom ( element ) { <nl> if ( ! $ ( element ) ) return ; <nl> var element = $ ( element ) ; <nl> - <nl> + <nl> var instances = MUI . Panels . instances ; <nl> var instance = instances . get ( element . id ) ; <nl> var handle = instance . handleEl ; <nl> function addResizeBottom ( element ) { <nl> max = function ( ) { <nl> return element . getStyle ( ' height ' ) . toInt ( ) + partner . getStyle ( ' height ' ) . toInt ( ) ; <nl> } . bind ( this ) ; <nl> - <nl> + <nl> if ( MUI . ieLegacySupport ) { <nl> handle . addEvents ( { <nl> ' mousedown ' : function ( ) { <nl> function addResizeBottom ( element ) { <nl> partner . getElements ( ' iframe ' ) . hide ( ) ; <nl> } <nl> } <nl> - <nl> + <nl> } . bind ( this ) , <nl> onDrag : function ( ) { <nl> partnerHeight = partnerOriginalHeight ; <nl> function addResizeBottom ( element ) { <nl> } ) ; <nl> partner . getChildren ( ' . column ' ) . each ( function ( column ) { <nl> MUI . panelHeight ( column ) ; <nl> - } ) ; <nl> + } ) ; <nl> } . bind ( this ) , <nl> onComplete : function ( ) { <nl> partnerHeight = partnerOriginalHeight ; <nl> function addResizeBottom ( element ) { <nl> } ) ; <nl> partner . getChildren ( ' . column ' ) . each ( function ( column ) { <nl> MUI . panelHeight ( column ) ; <nl> - } ) ; <nl> + } ) ; <nl> if ( instance . iframeEl ) { <nl> if ( ! MUI . ieLegacySupport ) { <nl> instance . iframeEl . setStyle ( ' visibility ' , ' visible ' ) ; <nl> function addResizeBottom ( element ) { <nl> var width = instance . iframeEl . getStyle ( ' width ' ) . toInt ( ) ; <nl> instance . iframeEl . setStyle ( ' width ' , width - 1 ) ; <nl> MUI . rWidth ( ) ; <nl> - instance . iframeEl . setStyle ( ' width ' , width ) ; <nl> + instance . iframeEl . setStyle ( ' width ' , width ) ; <nl> } <nl> - } <nl> + } <nl> instance . fireEvent ( ' onResize ' ) ; <nl> } . bind ( this ) <nl> } ) ; <nl> MUI . extend ( { <nl> MUI . closeColumn ( ) ; <nl> ( end ) <nl> <nl> - Arguments : <nl> + Arguments : <nl> columnEl - the ID of the column to be closed <nl> <nl> Returns : <nl> true - the column was closed <nl> false - the column was not closed <nl> <nl> - * / <nl> + * / <nl> closeColumn : function ( columnEl ) { <nl> var instances = MUI . Columns . instances ; <nl> var instance = instances . get ( columnEl . id ) ; <nl> if ( columnEl ! = $ ( columnEl ) | | instance . isClosing ) return ; <nl> - <nl> + <nl> instance . isClosing = true ; <nl> - <nl> + <nl> if ( instance . options . sortable ) { <nl> instance . container . retrieve ( ' sortables ' ) . removeLists ( this . columnEl ) ; <nl> - } <nl> - <nl> + } <nl> + <nl> / / Destroy all the panels in the column . <nl> - var panels = columnEl . getChildren ( ' . panel ' ) ; <nl> + var panels = columnEl . getChildren ( ' . panel ' ) ; <nl> panels . each ( function ( panel ) { <nl> MUI . closePanel ( $ ( panel . id ) ) ; <nl> - } . bind ( this ) ) ; <nl> - <nl> + } . bind ( this ) ) ; <nl> + <nl> if ( MUI . ieLegacySupport ) { <nl> columnEl . dispose ( ) ; <nl> if ( instance . handleEl ! = null ) { <nl> instance . handleEl . dispose ( ) ; <nl> - } <nl> + } <nl> } <nl> else { <nl> columnEl . destroy ( ) ; <nl> if ( instance . handleEl ! = null ) { <nl> instance . handleEl . destroy ( ) ; <nl> - } <nl> + } <nl> } <nl> if ( MUI . Desktop ) { <nl> MUI . Desktop . resizePanels ( ) ; <nl> - } <nl> + } <nl> instances . erase ( instance . options . id ) ; <nl> - return true ; <nl> + return true ; <nl> } , <nl> / * <nl> <nl> MUI . extend ( { <nl> MUI . closePanel ( ) ; <nl> ( end ) <nl> <nl> - Arguments : <nl> + Arguments : <nl> panelEl - the ID of the panel to be closed <nl> <nl> Returns : <nl> true - the panel was closed <nl> false - the panel was not closed <nl> <nl> - * / <nl> + * / <nl> closePanel : function ( panelEl ) { <nl> var instances = MUI . Panels . instances ; <nl> var instance = instances . get ( panelEl . id ) ; <nl> if ( panelEl ! = $ ( panelEl ) | | instance . isClosing ) return ; <nl> - <nl> + <nl> var column = instance . options . column ; <nl> - <nl> + <nl> instance . isClosing = true ; <nl> - <nl> + <nl> var columnInstances = MUI . Columns . instances ; <nl> var columnInstance = columnInstances . get ( column ) ; <nl> - <nl> + <nl> if ( columnInstance . options . sortable ) { <nl> columnInstance . options . container . retrieve ( ' sortables ' ) . removeItems ( instance . panelWrapperEl ) ; <nl> - } <nl> + } <nl> <nl> instance . panelWrapperEl . destroy ( ) ; <nl> <nl> if ( MUI . Desktop ) { <nl> MUI . Desktop . resizePanels ( ) ; <nl> } <nl> - <nl> + <nl> / / Do this when creating and removing panels <nl> $ ( column ) . getChildren ( ' . panelWrapper ' ) . each ( function ( panelWrapper ) { <nl> panelWrapper . getElement ( ' . panel ' ) . removeClass ( ' bottomPanel ' ) ; <nl> } ) ; <nl> $ ( column ) . getChildren ( ' . panelWrapper ' ) . getLast ( ) . getElement ( ' . panel ' ) . addClass ( ' bottomPanel ' ) ; <nl> - <nl> + <nl> instances . erase ( instance . options . id ) ; <nl> return true ; <nl> - <nl> + <nl> } <nl> } ) ; <nl> / * <nl> Script : Dock . js <nl> Implements the dock / taskbar . Enables window minimize . <nl> <nl> Copyright : <nl> - Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> + Copyright ( c ) 2007 - 2009 Greg Houston , < http : / / greghoustondesign . com / > . <nl> <nl> License : <nl> MIT - style license . <nl> <nl> Requires : <nl> - Core . js , Window . js , Layout . js <nl> + Core . js , Window . js , Layout . js <nl> <nl> Todo : <nl> - Make it so the dock requires no initial html markup . <nl> MUI . extend ( { <nl> Function : minimizeAll <nl> Minimize all windows that are minimizable . <nl> <nl> - * / <nl> + * / <nl> minimizeAll : function ( ) { <nl> $ $ ( ' . mocha ' ) . each ( function ( windowEl ) { <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> MUI . Dock = { <nl> dockPosition : ' bottom ' , / / Position the dock starts in , top or bottom . <nl> / / Style options <nl> trueButtonColor : [ 70 , 245 , 70 ] , / / Color for autohide on <nl> - enabledButtonColor : [ 115 , 153 , 191 ] , <nl> + enabledButtonColor : [ 115 , 153 , 191 ] , <nl> disabledButtonColor : [ 170 , 170 , 170 ] <nl> } , <nl> - <nl> + <nl> initialize : function ( options ) { <nl> / / Stops if MUI . Desktop is not implemented <nl> if ( ! MUI . Desktop ) return ; <nl> - <nl> + <nl> MUI . dockVisible = true ; <nl> this . dockWrapper = $ ( MUI . options . dockWrapper ) ; <nl> this . dock = $ ( MUI . options . dock ) ; <nl> - this . autoHideEvent = null ; <nl> + this . autoHideEvent = null ; <nl> this . dockAutoHide = false ; / / True when dock autohide is set to on , false if set to off <nl> <nl> if ( ! this . dockWrapper ) return ; <nl> MUI . Dock = { <nl> ' bottom ' : MUI . Desktop . desktopFooter ? MUI . Desktop . desktopFooter . offsetHeight : 0 , <nl> ' left ' : 0 <nl> } ) ; <nl> - <nl> + <nl> if ( this . options . useControls ) { <nl> this . initializeDockControls ( ) ; <nl> } <nl> MUI . Dock = { <nl> } ) ; <nl> <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> - <nl> + <nl> if ( MUI . myChain ) { <nl> MUI . myChain . callChain ( ) ; <nl> } <nl> - <nl> + <nl> } , <nl> - <nl> + <nl> initializeDockControls : function ( ) { <nl> - <nl> + <nl> / / Convert CSS colors to Canvas colors . <nl> this . setDockColors ( ) ; <nl> - <nl> + <nl> if ( this . options . useControls ) { <nl> / / Insert canvas <nl> var canvas = new Element ( ' canvas ' , { <nl> MUI . Dock = { <nl> G_vmlCanvasManager . initElement ( canvas ) ; <nl> } <nl> } <nl> - <nl> + <nl> var dockPlacement = $ ( ' dockPlacement ' ) ; <nl> var dockAutoHide = $ ( ' dockAutoHide ' ) ; <nl> <nl> MUI . Dock = { <nl> <nl> / / Auto Hide toggle switch <nl> dockAutoHide . setProperty ( ' title ' , ' Turn Auto Hide On ' ) ; <nl> - <nl> - / / Attach event Auto Hide <nl> + <nl> + / / Attach event Auto Hide <nl> dockAutoHide . addEvent ( ' click ' , function ( event ) { <nl> if ( this . dockWrapper . getProperty ( ' dockPosition ' ) = = ' top ' ) <nl> return false ; <nl> MUI . Dock = { <nl> else if ( MUI . Desktop . desktopFooter ) { <nl> var dockHotspotHeight = this . dockWrapper . offsetHeight + MUI . Desktop . desktopFooter . offsetHeight ; <nl> if ( dockHotspotHeight < 25 ) dockHotspotHeight = 25 ; <nl> - } <nl> + } <nl> if ( ! MUI . Desktop . desktopFooter & & event . client . y > ( document . getCoordinates ( ) . height - dockHotspotHeight ) ) { <nl> if ( ! MUI . dockVisible ) { <nl> this . dockWrapper . show ( ) ; <nl> MUI . Dock = { <nl> this . dockWrapper . hide ( ) ; <nl> MUI . dockVisible = false ; <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> - <nl> + <nl> } <nl> } . bind ( this ) ; <nl> <nl> MUI . Dock = { <nl> } . bind ( this ) ) ; <nl> <nl> this . renderDockControls ( ) ; <nl> - <nl> + <nl> if ( this . options . dockPosition = = ' top ' ) { <nl> this . moveDock ( ) ; <nl> } <nl> <nl> } , <nl> - <nl> - setDockColors : function ( ) { <nl> + <nl> + setDockColors : function ( ) { <nl> var dockButtonEnabled = MUI . getCSSRule ( ' . dockButtonEnabled ' ) ; <nl> - if ( dockButtonEnabled & & dockButtonEnabled . style . backgroundColor ) { <nl> + if ( dockButtonEnabled & & dockButtonEnabled . style . backgroundColor ) { <nl> this . options . enabledButtonColor = new Color ( dockButtonEnabled . style . backgroundColor ) ; <nl> } <nl> - <nl> + <nl> var dockButtonDisabled = MUI . getCSSRule ( ' . dockButtonDisabled ' ) ; <nl> - if ( dockButtonDisabled & & dockButtonDisabled . style . backgroundColor ) { <nl> + if ( dockButtonDisabled & & dockButtonDisabled . style . backgroundColor ) { <nl> this . options . disabledButtonColor = new Color ( dockButtonDisabled . style . backgroundColor ) ; <nl> } <nl> - <nl> + <nl> var trueButtonColor = MUI . getCSSRule ( ' . dockButtonTrue ' ) ; <nl> - if ( trueButtonColor & & trueButtonColor . style . backgroundColor ) { <nl> + if ( trueButtonColor & & trueButtonColor . style . backgroundColor ) { <nl> this . options . trueButtonColor = new Color ( trueButtonColor . style . backgroundColor ) ; <nl> - } <nl> + } <nl> } , <nl> - <nl> + <nl> renderDockControls : function ( ) { <nl> / / Draw dock controls <nl> var ctx = $ ( ' dockCanvas ' ) . getContext ( ' 2d ' ) ; <nl> ctx . clearRect ( 0 , 0 , 100 , 100 ) ; <nl> MUI . circle ( ctx , 5 , 4 , 3 , this . options . enabledButtonColor , 1 . 0 ) ; <nl> - <nl> + <nl> if ( this . dockWrapper . getProperty ( ' dockPosition ' ) = = ' top ' ) { <nl> MUI . circle ( ctx , 5 , 14 , 3 , this . options . disabledButtonColor , 1 . 0 ) <nl> } <nl> MUI . Dock = { <nl> MUI . circle ( ctx , 5 , 14 , 3 , this . options . enabledButtonColor , 1 . 0 ) ; <nl> } <nl> } , <nl> - <nl> + <nl> moveDock : function ( ) { <nl> var ctx = $ ( ' dockCanvas ' ) . getContext ( ' 2d ' ) ; <nl> / / Move dock to top position <nl> MUI . Dock = { <nl> $ ( ' dockAutoHide ' ) . setProperty ( ' title ' , ' Turn Auto Hide On ' ) ; <nl> } <nl> } , <nl> - <nl> + <nl> createDockTab : function ( windowEl ) { <nl> <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> + var titleText = instance . titleEl . innerHTML ; <nl> <nl> var dockTab = new Element ( ' div ' , { <nl> ' id ' : instance . options . id + ' _dockTab ' , <nl> ' class ' : ' dockTab ' , <nl> ' title ' : titleText <nl> } ) . inject ( $ ( ' dockClear ' ) , ' before ' ) ; <nl> - <nl> + <nl> dockTab . addEvent ( ' mousedown ' , function ( e ) { <nl> new Event ( e ) . stop ( ) ; <nl> this . timeDown = $ time ( ) ; <nl> } ) ; <nl> - <nl> + <nl> dockTab . addEvent ( ' mouseup ' , function ( e ) { <nl> this . timeUp = $ time ( ) ; <nl> if ( ( this . timeUp - this . timeDown ) < 275 ) { <nl> MUI . Dock = { <nl> if ( instance . windowEl . hasClass ( ' isFocused ' ) & & instance . options . minimizable = = true ) { <nl> MUI . Dock . minimizeWindow ( windowEl ) <nl> } <nl> - / / If window is not minimized and is not focused , focus window . <nl> + / / If window is not minimized and is not focused , focus window . <nl> else { <nl> MUI . focusWindow ( windowEl ) ; <nl> } <nl> / / if the window is not minimized and is outside the viewport , center it in the viewport . <nl> var coordinates = document . getCoordinates ( ) ; <nl> if ( windowEl . getStyle ( ' left ' ) . toInt ( ) > coordinates . width | | windowEl . getStyle ( ' top ' ) . toInt ( ) > coordinates . height ) { <nl> - MUI . centerWindow ( windowEl ) ; <nl> + MUI . centerWindow ( windowEl ) ; <nl> } <nl> } <nl> } <nl> MUI . Dock = { <nl> <nl> this . dockSortables . addItems ( dockTab ) ; <nl> <nl> - var titleText = instance . titleEl . innerHTML ; <nl> - <nl> var dockTabText = new Element ( ' div ' , { <nl> ' id ' : instance . options . id + ' _dockTabText ' , <nl> ' class ' : ' dockText ' <nl> MUI . Dock = { <nl> if ( instance . options . icon ! = false ) { <nl> / / dockTabText . setStyle ( ' background ' , ' url ( ' + instance . options . icon + ' ) 4px 4px no - repeat ' ) ; <nl> } <nl> - <nl> + <nl> / / Need to resize everything in case the dock wraps when a new tab is added <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> <nl> } , <nl> - <nl> + <nl> makeActiveTab : function ( ) { <nl> <nl> / / getWindowWith HighestZindex is used in case the currently focused window <nl> - / / is closed . <nl> + / / is closed . <nl> var windowEl = MUI . getWindowWithHighestZindex ( ) ; <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> - <nl> + <nl> $ $ ( ' . dockTab ' ) . removeClass ( ' activeDockTab ' ) ; <nl> if ( instance . isMinimized ! = true ) { <nl> - <nl> + <nl> instance . windowEl . addClass ( ' isFocused ' ) ; <nl> <nl> var currentButton = $ ( instance . options . id + ' _dockTab ' ) ; <nl> MUI . Dock = { <nl> } <nl> else { <nl> instance . windowEl . removeClass ( ' isFocused ' ) ; <nl> - } <nl> + } <nl> } , <nl> - <nl> + <nl> minimizeWindow : function ( windowEl ) { <nl> if ( windowEl ! = $ ( windowEl ) ) return ; <nl> - <nl> + <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> instance . isMinimized = true ; <nl> <nl> MUI . Dock = { <nl> } <nl> } <nl> <nl> - / / Hide window and add to dock <nl> + / / Hide window and add to dock <nl> instance . contentBorderEl . setStyle ( ' visibility ' , ' hidden ' ) ; <nl> - if ( instance . toolbarWrapperEl ) { <nl> + if ( instance . toolbarWrapperEl ) { <nl> instance . toolbarWrapperEl . hide ( ) ; <nl> } <nl> windowEl . setStyle ( ' visibility ' , ' hidden ' ) ; <nl> - <nl> + <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> <nl> / / Have to use timeout because window gets focused when you click on the minimize button <nl> setTimeout ( function ( ) { <nl> windowEl . setStyle ( ' zIndex ' , 1 ) ; <nl> windowEl . removeClass ( ' isFocused ' ) ; <nl> - this . makeActiveTab ( ) ; <nl> - } . bind ( this ) , 100 ) ; <nl> + this . makeActiveTab ( ) ; <nl> + } . bind ( this ) , 100 ) ; <nl> <nl> instance . fireEvent ( ' onMinimize ' , windowEl ) ; <nl> } , <nl> - <nl> + <nl> restoreMinimized : function ( windowEl ) { <nl> <nl> var instance = windowEl . retrieve ( ' instance ' ) ; <nl> MUI . Dock = { <nl> MUI . Desktop . setDesktopSize ( ) ; <nl> <nl> / / Part of Mac FF2 scrollbar fix <nl> - if ( instance . options . scrollbars = = true & & ! instance . iframeEl ) { <nl> + if ( instance . options . scrollbars = = true & & ! instance . iframeEl ) { <nl> instance . contentWrapperEl . setStyle ( ' overflow ' , ' auto ' ) ; <nl> } <nl> <nl> To do : <nl> <nl> MUI . files [ MUI . path . source + ' Layout / Workspaces . js ' ] = ' loaded ' ; <nl> <nl> - MUI . extend ( { <nl> + MUI . extend ( { <nl> / * <nl> - <nl> + <nl> Function : saveWorkspace <nl> Save the current workspace . <nl> - <nl> + <nl> Syntax : <nl> ( start code ) <nl> MUI . saveWorkspace ( ) ; <nl> ( end ) <nl> - <nl> + <nl> Notes : <nl> This version saves the ID of each open window to a cookie , and reloads those windows using the functions in mocha - init . js . This requires that each window have a function in mocha - init . js used to open them . Functions must be named the windowID + " Window " . So if your window is called mywindow , it needs a function called mywindowWindow in mocha - init . js . <nl> - <nl> + <nl> * / <nl> saveWorkspace : function ( ) { <nl> this . cookie = new Hash . Cookie ( ' mochaUIworkspaceCookie ' , { duration : 3600 } ) ; <nl> MUI . extend ( { <nl> shadowBlur : 5 , <nl> bodyBgColor : [ 255 , 255 , 255 ] <nl> } ) ; <nl> - <nl> + <nl> } , <nl> windowUnload : function ( ) { <nl> if ( $ $ ( ' . mocha ' ) . length = = 0 & & this . myChain ) { <nl> this . myChain . callChain ( ) ; <nl> - } <nl> + } <nl> } , <nl> - loadWorkspace2 : function ( workspaceWindows ) { <nl> - workspaceWindows . each ( function ( workspaceWindow ) { <nl> + loadWorkspace2 : function ( workspaceWindows ) { <nl> + workspaceWindows . each ( function ( workspaceWindow ) { <nl> windowFunction = eval ( ' MUI . ' + workspaceWindow . id + ' Window ' ) ; <nl> if ( windowFunction ) { <nl> eval ( ' MUI . ' + workspaceWindow . id + ' Window ( { width : ' + workspaceWindow . width + ' , height : ' + workspaceWindow . height + ' } ) ; ' ) ; <nl> mmm a / src / webui / www / private / scripts / misc . js <nl> ppp b / src / webui / www / private / scripts / misc . js <nl> <nl> * JS counterpart of the function in src / misc . cpp <nl> * / <nl> function friendlyUnit ( value , isSpeed ) { <nl> - units = [ <nl> + var units = [ <nl> " QBT_TR ( B ) QBT_TR [ CONTEXT = misc ] " , <nl> " QBT_TR ( KiB ) QBT_TR [ CONTEXT = misc ] " , <nl> " QBT_TR ( MiB ) QBT_TR [ CONTEXT = misc ] " , <nl> mmm a / src / webui / www / private / scripts / mocha - init . js <nl> ppp b / src / webui / www / private / scripts / mocha - init . js <nl> if ( typeof localStorage = = ' undefined ' ) { <nl> } <nl> <nl> function getLocalStorageItem ( name , defaultVal ) { <nl> - val = localStorage . getItem ( name ) ; <nl> + var val = localStorage . getItem ( name ) ; <nl> if ( val = = = null | | val = = = undefined ) <nl> val = defaultVal ; <nl> return val ; <nl> mmm a / src / webui / www / private / scripts / prop - files . js <nl> ppp b / src / webui / www / private / scripts / prop - files . js <nl> var loadTorrentFilesData = function ( ) { <nl> current_hash = new_hash ; <nl> } <nl> var url = new URI ( ' api / v2 / torrents / files ? hash = ' + current_hash ) ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> method : ' get ' , <nl> mmm a / src / webui / www / private / scripts / prop - general . js <nl> ppp b / src / webui / www / private / scripts / prop - general . js <nl> var loadTorrentData = function ( ) { <nl> / / Display hash <nl> $ ( ' torrent_hash ' ) . set ( ' html ' , current_hash ) ; <nl> var url = new URI ( ' api / v2 / torrents / properties ? hash = ' + current_hash ) ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> method : ' get ' , <nl> mmm a / src / webui / www / private / scripts / prop - trackers . js <nl> ppp b / src / webui / www / private / scripts / prop - trackers . js <nl> var loadTrackersData = function ( ) { <nl> current_hash = new_hash ; <nl> } <nl> var url = new URI ( ' api / v2 / torrents / trackers ? hash = ' + current_hash ) ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> method : ' get ' , <nl> mmm a / src / webui / www / private / scripts / prop - webseeds . js <nl> ppp b / src / webui / www / private / scripts / prop - webseeds . js <nl> var loadWebSeedsData = function ( ) { <nl> current_hash = new_hash ; <nl> } <nl> var url = new URI ( ' api / v2 / torrents / webseeds ? hash = ' + current_hash ) ; <nl> - var request = new Request . JSON ( { <nl> + new Request . JSON ( { <nl> url : url , <nl> noCache : true , <nl> method : ' get ' , <nl>
Merge pull request from Piccirello / js - defects
qbittorrent/qBittorrent
5aaa51881e137539bcfdd1932c043c8961f0fc0c
2018-10-02T02:19:47Z
mmm a / test / common / protobuf / utility_test . cc <nl> ppp b / test / common / protobuf / utility_test . cc <nl> TEST ( UtilityTest , JsonConvertFail ) { <nl> ProtobufWkt : : Duration source_duration ; <nl> source_duration . set_seconds ( - 281474976710656 ) ; <nl> ProtobufWkt : : Duration dest_duration ; <nl> - EXPECT_THROW_WITH_MESSAGE ( MessageUtil : : jsonConvert ( source_duration , dest_duration ) , <nl> - EnvoyException , <nl> - " Unable to convert protobuf message to JSON string : INTERNAL : Duration " <nl> - " seconds exceeds limit for field : seconds : - 281474976710656 \ n " ) ; <nl> + EXPECT_THROW_WITH_REGEX ( MessageUtil : : jsonConvert ( source_duration , dest_duration ) , EnvoyException , <nl> + " Unable to convert protobuf message to JSON string . * " <nl> + " seconds exceeds limit for field : seconds : - 281474976710656 \ n " ) ; <nl> } <nl> <nl> TEST ( DurationUtilTest , OutOfRange ) { <nl>
tests : Remove dependence on util : : Status implementation ( )
envoyproxy/envoy
111da863d087b49ca27af356c0bd29f10a2c2f80
2018-04-28T10:22:56Z
new file mode 100644 <nl> index 000000000000 . . 39270b809f85 <nl> mmm / dev / null <nl> ppp b / include / swift / AST / ASTConsumer . h <nl> <nl> + / / = = = mmm ASTConsumer . h - Consumer for ASTs mmmmmmmmmmmmmmmmmmmmm - * - C + + - * - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This file defines the ASTConsumer class . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef SWIFT_AST_ASTCONSUMER_H <nl> + # define SWIFT_AST_ASTCONSUMER_H <nl> + <nl> + namespace swift { <nl> + class Decl ; <nl> + class ASTContext ; <nl> + <nl> + / / / ASTConsumer - This is an abstract interface that should be implemented by <nl> + / / / clients that read ASTs . This abstraction layer allows the client to be <nl> + / / / independent of the AST producer ( e . g . parser vs AST dump file reader , etc ) . <nl> + class ASTConsumer { <nl> + ASTContext & Context ; <nl> + <nl> + ASTConsumer ( const ASTConsumer & ) ; / / DO NOT IMPLEMENT <nl> + void operator = ( const ASTConsumer & ) ; / / DO NOT IMPLEMENT <nl> + public : <nl> + ASTConsumer ( ASTContext & Ctx ) : Context ( Ctx ) { } <nl> + virtual ~ ASTConsumer ( ) ; <nl> + <nl> + ASTContext & getContext ( ) const { return Context ; } <nl> + <nl> + virtual void HandleTopLevelDecl ( Decl * D ) { } <nl> + } ; <nl> + <nl> + } / / end namespace swift <nl> + <nl> + # endif <nl> mmm a / include / swift / Parse / Parser . h <nl> ppp b / include / swift / Parse / Parser . h <nl> namespace llvm { <nl> namespace swift { <nl> class Lexer ; <nl> class Sema ; <nl> - class ASTContext ; <nl> class Expr ; <nl> class Type ; <nl> class Decl ; <nl> + class ASTContext ; <nl> + class ASTConsumer ; <nl> <nl> class Parser { <nl> + ASTConsumer & Consumer ; <nl> llvm : : SourceMgr & SourceMgr ; <nl> Lexer & L ; <nl> Sema & S ; <nl> class Parser { <nl> Parser ( const Parser & ) ; / / DO NOT IMPLEMENT <nl> void operator = ( const Parser & ) ; / / DO NOT IMPLEMENT <nl> public : <nl> - Parser ( unsigned BufferID , ASTContext & Context ) ; <nl> + Parser ( unsigned BufferID , ASTConsumer & Consumer ) ; <nl> ~ Parser ( ) ; <nl> <nl> void ParseTranslationUnit ( ) ; <nl> new file mode 100644 <nl> index 000000000000 . . d6667cbf82fa <nl> mmm / dev / null <nl> ppp b / lib / AST / ASTConsumer . cpp <nl> <nl> + / / = = = mmm ASTConsumer . cpp - Consumer for ASTs mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This file implements the Swift parser . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # include " swift / AST / ASTConsumer . h " <nl> + using namespace swift ; <nl> + <nl> + ASTConsumer : : ~ ASTConsumer ( ) { } <nl> mmm a / lib / Parse / Parser . cpp <nl> ppp b / lib / Parse / Parser . cpp <nl> <nl> # include " swift / Sema / Sema . h " <nl> # include " swift / AST / Decl . h " <nl> # include " swift / AST / Expr . h " <nl> + # include " swift / AST / ASTConsumer . h " <nl> # include " llvm / Support / SourceMgr . h " <nl> using namespace swift ; <nl> using llvm : : SMLoc ; <nl> using llvm : : SMLoc ; <nl> / / Setup and Helper Methods <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - Parser : : Parser ( unsigned BufferID , ASTContext & Context ) <nl> - : SourceMgr ( Context . SourceMgr ) , <nl> + Parser : : Parser ( unsigned BufferID , ASTConsumer & consumer ) <nl> + : Consumer ( consumer ) , <nl> + SourceMgr ( Consumer . getContext ( ) . SourceMgr ) , <nl> L ( * new Lexer ( BufferID , SourceMgr ) ) , <nl> - S ( * new Sema ( Context ) ) { <nl> + S ( * new Sema ( Consumer . getContext ( ) ) ) { <nl> } <nl> <nl> Parser : : ~ Parser ( ) { <nl>
introduce new ASTConsumer interface , have parser invoke methods
apple/swift
669c129ab0c8a3a470db7cc9a0e30f8cc18dacd8
2010-07-19T05:50:41Z
mmm a / test / cpp / end2end / grpclb_end2end_test . cc <nl> ppp b / test / cpp / end2end / grpclb_end2end_test . cc <nl> <nl> / / TODO ( dgq ) : Other scenarios in need of testing : <nl> / / - Send a serverlist with faulty ip : port addresses ( port > 2 ^ 16 , etc ) . <nl> / / - Test reception of invalid serverlist <nl> - / / - Test pinging <nl> / / - Test against a non - LB server . <nl> / / - Random LB server closing the stream unexpectedly . <nl> - / / - Test using DNS - resolvable names ( localhost ? ) <nl> - / / - Test handling of creation of faulty RR instance by having the LB return a <nl> - / / serverlist with non - existent backends after having initially returned a <nl> - / / valid one . <nl> / / <nl> / / Findings from end to end testing to be covered here : <nl> / / - Handling of LB servers restart , including reconnection after backing - off <nl> <nl> / / part of the grpclb shutdown process . <nl> / / 2 ) the retry timer is active . Again , the weak reference it holds should <nl> / / prevent a premature call to \ a glb_destroy . <nl> - / / - Restart of backend servers with no changes to serverlist . This exercises <nl> - / / the RR handover mechanism . <nl> <nl> using std : : chrono : : system_clock ; <nl> <nl> class BackendServiceImpl : public BackendService { <nl> return status ; <nl> } <nl> <nl> - / / Returns true on its first invocation , false otherwise . <nl> - bool Shutdown ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - const bool prev = ! shutdown_ ; <nl> - shutdown_ = true ; <nl> - gpr_log ( GPR_INFO , " Backend : shut down " ) ; <nl> - return prev ; <nl> - } <nl> + void Shutdown ( ) { } <nl> <nl> std : : set < grpc : : string > clients ( ) { <nl> std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> class BackendServiceImpl : public BackendService { <nl> } <nl> <nl> std : : mutex mu_ ; <nl> - bool shutdown_ = false ; <nl> std : : mutex clients_mu_ ; <nl> std : : set < grpc : : string > clients_ ; <nl> } ; <nl> struct ClientStats { <nl> } <nl> return * this ; <nl> } <nl> + <nl> + void Reset ( ) { <nl> + num_calls_started = 0 ; <nl> + num_calls_finished = 0 ; <nl> + num_calls_finished_with_client_failed_to_send = 0 ; <nl> + num_calls_finished_known_received = 0 ; <nl> + drop_token_counts . clear ( ) ; <nl> + } <nl> } ; <nl> <nl> class BalancerServiceImpl : public BalancerService { <nl> class BalancerServiceImpl : public BalancerService { <nl> <nl> explicit BalancerServiceImpl ( int client_load_reporting_interval_seconds ) <nl> : client_load_reporting_interval_seconds_ ( <nl> - client_load_reporting_interval_seconds ) , <nl> - shutdown_ ( false ) { } <nl> + client_load_reporting_interval_seconds ) { } <nl> <nl> Status BalanceLoad ( ServerContext * context , Stream * stream ) override { <nl> / / Balancer shouldn ' t receive the call credentials metadata . <nl> class BalancerServiceImpl : public BalancerService { <nl> responses_and_delays = responses_and_delays_ ; <nl> } <nl> for ( const auto & response_and_delay : responses_and_delays ) { <nl> - { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - if ( shutdown_ ) goto done ; <nl> - } <nl> SendResponse ( stream , response_and_delay . first , response_and_delay . second ) ; <nl> } <nl> { <nl> std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - if ( shutdown_ ) goto done ; <nl> - serverlist_cond_ . wait ( lock , [ this ] { return serverlist_ready_ ; } ) ; <nl> + serverlist_cond_ . wait ( lock , [ this ] { return serverlist_done_ ; } ) ; <nl> } <nl> <nl> if ( client_load_reporting_interval_seconds_ > 0 ) { <nl> class BalancerServiceImpl : public BalancerService { <nl> responses_and_delays_ . push_back ( std : : make_pair ( response , send_after_ms ) ) ; <nl> } <nl> <nl> - / / Returns true on its first invocation , false otherwise . <nl> - bool Shutdown ( ) { <nl> - NotifyDoneWithServerlists ( ) ; <nl> + void Shutdown ( ) { <nl> std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - const bool prev = ! shutdown_ ; <nl> - shutdown_ = true ; <nl> + NotifyDoneWithServerlistsLocked ( ) ; <nl> + responses_and_delays_ . clear ( ) ; <nl> + client_stats_ . Reset ( ) ; <nl> gpr_log ( GPR_INFO , " LB [ % p ] : shut down " , this ) ; <nl> - return prev ; <nl> } <nl> <nl> static LoadBalanceResponse BuildResponseForBackends ( <nl> class BalancerServiceImpl : public BalancerService { <nl> <nl> void NotifyDoneWithServerlists ( ) { <nl> std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> - serverlist_ready_ = true ; <nl> - serverlist_cond_ . notify_all ( ) ; <nl> + NotifyDoneWithServerlistsLocked ( ) ; <nl> + } <nl> + <nl> + void NotifyDoneWithServerlistsLocked ( ) { <nl> + if ( ! serverlist_done_ ) { <nl> + serverlist_done_ = true ; <nl> + serverlist_cond_ . notify_all ( ) ; <nl> + } <nl> } <nl> <nl> private : <nl> class BalancerServiceImpl : public BalancerService { <nl> std : : condition_variable load_report_cond_ ; <nl> bool load_report_ready_ = false ; <nl> std : : condition_variable serverlist_cond_ ; <nl> - bool serverlist_ready_ = false ; <nl> + bool serverlist_done_ = false ; <nl> ClientStats client_stats_ ; <nl> - bool shutdown_ ; <nl> } ; <nl> <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> protected : <nl> - GrpclbEnd2endTest ( int num_backends , int num_balancers , <nl> + GrpclbEnd2endTest ( size_t num_backends , size_t num_balancers , <nl> int client_load_reporting_interval_seconds ) <nl> : server_host_ ( " localhost " ) , <nl> num_backends_ ( num_backends ) , <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> grpc_core : : MakeRefCounted < grpc_core : : FakeResolverResponseGenerator > ( ) ; <nl> / / Start the backends . <nl> for ( size_t i = 0 ; i < num_backends_ ; + + i ) { <nl> - backends_ . emplace_back ( new BackendServiceImpl ( ) ) ; <nl> - backend_servers_ . emplace_back ( ServerThread < BackendService > ( <nl> - " backend " , server_host_ , backends_ . back ( ) . get ( ) ) ) ; <nl> + backends_ . emplace_back ( new ServerThread < BackendServiceImpl > ( " backend " ) ) ; <nl> + backends_ . back ( ) - > Start ( server_host_ ) ; <nl> } <nl> / / Start the load balancers . <nl> for ( size_t i = 0 ; i < num_balancers_ ; + + i ) { <nl> - balancers_ . emplace_back ( <nl> - new BalancerServiceImpl ( client_load_reporting_interval_seconds_ ) ) ; <nl> - balancer_servers_ . emplace_back ( ServerThread < BalancerService > ( <nl> - " balancer " , server_host_ , balancers_ . back ( ) . get ( ) ) ) ; <nl> + balancers_ . emplace_back ( new ServerThread < BalancerServiceImpl > ( <nl> + " balancer " , client_load_reporting_interval_seconds_ ) ) ; <nl> + balancers_ . back ( ) - > Start ( server_host_ ) ; <nl> } <nl> ResetStub ( ) ; <nl> } <nl> <nl> void TearDown ( ) override { <nl> - for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - if ( backends_ [ i ] - > Shutdown ( ) ) backend_servers_ [ i ] . Shutdown ( ) ; <nl> - } <nl> - for ( size_t i = 0 ; i < balancers_ . size ( ) ; + + i ) { <nl> - if ( balancers_ [ i ] - > Shutdown ( ) ) balancer_servers_ [ i ] . Shutdown ( ) ; <nl> - } <nl> + ShutdownAllBackends ( ) ; <nl> + for ( auto & balancer : balancers_ ) balancer - > Shutdown ( ) ; <nl> } <nl> <nl> + void StartAllBackends ( ) { <nl> + for ( auto & backend : backends_ ) backend - > Start ( server_host_ ) ; <nl> + } <nl> + <nl> + void StartBackend ( size_t index ) { backends_ [ index ] - > Start ( server_host_ ) ; } <nl> + <nl> + void ShutdownAllBackends ( ) { <nl> + for ( auto & backend : backends_ ) backend - > Shutdown ( ) ; <nl> + } <nl> + <nl> + void ShutdownBackend ( size_t index ) { backends_ [ index ] - > Shutdown ( ) ; } <nl> + <nl> void ResetStub ( int fallback_timeout = 0 , <nl> const grpc : : string & expected_targets = " " ) { <nl> ChannelArguments args ; <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> } <nl> <nl> void ResetBackendCounters ( ) { <nl> - for ( const auto & backend : backends_ ) backend - > ResetCounters ( ) ; <nl> + for ( auto & backend : backends_ ) backend - > service_ . ResetCounters ( ) ; <nl> } <nl> <nl> ClientStats WaitForLoadReports ( ) { <nl> ClientStats client_stats ; <nl> - for ( const auto & balancer : balancers_ ) { <nl> - client_stats + = balancer - > WaitForLoadReport ( ) ; <nl> + for ( auto & balancer : balancers_ ) { <nl> + client_stats + = balancer - > service_ . WaitForLoadReport ( ) ; <nl> } <nl> return client_stats ; <nl> } <nl> <nl> - bool SeenAllBackends ( ) { <nl> - for ( const auto & backend : backends_ ) { <nl> - if ( backend - > request_count ( ) = = 0 ) return false ; <nl> + bool SeenAllBackends ( size_t start_index = 0 , size_t stop_index = 0 ) { <nl> + if ( stop_index = = 0 ) stop_index = backends_ . size ( ) ; <nl> + for ( size_t i = start_index ; i < stop_index ; + + i ) { <nl> + if ( backends_ [ i ] - > service_ . request_count ( ) = = 0 ) return false ; <nl> } <nl> return true ; <nl> } <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> + + * num_total ; <nl> } <nl> <nl> - std : : tuple < int , int , int > WaitForAllBackends ( <nl> - int num_requests_multiple_of = 1 ) { <nl> + std : : tuple < int , int , int > WaitForAllBackends ( int num_requests_multiple_of = 1 , <nl> + size_t start_index = 0 , <nl> + size_t stop_index = 0 ) { <nl> int num_ok = 0 ; <nl> int num_failure = 0 ; <nl> int num_drops = 0 ; <nl> int num_total = 0 ; <nl> - while ( ! SeenAllBackends ( ) ) { <nl> + while ( ! SeenAllBackends ( start_index , stop_index ) ) { <nl> SendRpcAndCount ( & num_total , & num_ok , & num_failure , & num_drops ) ; <nl> } <nl> while ( num_total % num_requests_multiple_of ! = 0 ) { <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> void WaitForBackend ( size_t backend_idx ) { <nl> do { <nl> ( void ) SendRpc ( ) ; <nl> - } while ( backends_ [ backend_idx ] - > request_count ( ) = = 0 ) ; <nl> + } while ( backends_ [ backend_idx ] - > service_ . request_count ( ) = = 0 ) ; <nl> ResetBackendCounters ( ) ; <nl> } <nl> <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> void SetNextResolutionAllBalancers ( <nl> const char * service_config_json = nullptr ) { <nl> std : : vector < AddressData > addresses ; <nl> - for ( size_t i = 0 ; i < balancer_servers_ . size ( ) ; + + i ) { <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ i ] . port_ , true , " " } ) ; <nl> + for ( size_t i = 0 ; i < balancers_ . size ( ) ; + + i ) { <nl> + addresses . emplace_back ( AddressData { balancers_ [ i ] - > port_ , true , " " } ) ; <nl> } <nl> SetNextResolution ( addresses , service_config_json ) ; <nl> } <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> response_generator_ - > SetReresolutionResponse ( & fake_result ) ; <nl> } <nl> <nl> - const std : : vector < int > GetBackendPorts ( const size_t start_index = 0 ) const { <nl> + const std : : vector < int > GetBackendPorts ( size_t start_index = 0 , <nl> + size_t stop_index = 0 ) const { <nl> + if ( stop_index = = 0 ) stop_index = backends_ . size ( ) ; <nl> std : : vector < int > backend_ports ; <nl> - for ( size_t i = start_index ; i < backend_servers_ . size ( ) ; + + i ) { <nl> - backend_ports . push_back ( backend_servers_ [ i ] . port_ ) ; <nl> + for ( size_t i = start_index ; i < stop_index ; + + i ) { <nl> + backend_ports . push_back ( backends_ [ i ] - > port_ ) ; <nl> } <nl> return backend_ports ; <nl> } <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> void ScheduleResponseForBalancer ( size_t i , <nl> const LoadBalanceResponse & response , <nl> int delay_ms ) { <nl> - balancers_ . at ( i ) - > add_response ( response , delay_ms ) ; <nl> + balancers_ [ i ] - > service_ . add_response ( response , delay_ms ) ; <nl> } <nl> <nl> Status SendRpc ( EchoResponse * response = nullptr , int timeout_ms = 1000 , <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> <nl> template < typename T > <nl> struct ServerThread { <nl> - explicit ServerThread ( const grpc : : string & type , <nl> - const grpc : : string & server_host , T * service ) <nl> - : type_ ( type ) , service_ ( service ) { <nl> + template < typename . . . Args > <nl> + explicit ServerThread ( const grpc : : string & type , Args & & . . . args ) <nl> + : port_ ( grpc_pick_unused_port_or_die ( ) ) , <nl> + type_ ( type ) , <nl> + service_ ( std : : forward < Args > ( args ) . . . ) { } <nl> + <nl> + void Start ( const grpc : : string & server_host ) { <nl> + gpr_log ( GPR_INFO , " starting % s server on port % d " , type_ . c_str ( ) , port_ ) ; <nl> + GPR_ASSERT ( ! running_ ) ; <nl> + running_ = true ; <nl> std : : mutex mu ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> - / / by ServerThread : : Start from firing before the wait below is hit . <nl> + / / by ServerThread : : Serve from firing before the wait below is hit . <nl> std : : unique_lock < std : : mutex > lock ( mu ) ; <nl> - port_ = grpc_pick_unused_port_or_die ( ) ; <nl> - gpr_log ( GPR_INFO , " starting % s server on port % d " , type_ . c_str ( ) , port_ ) ; <nl> std : : condition_variable cond ; <nl> thread_ . reset ( new std : : thread ( <nl> - std : : bind ( & ServerThread : : Start , this , server_host , & mu , & cond ) ) ) ; <nl> + std : : bind ( & ServerThread : : Serve , this , server_host , & mu , & cond ) ) ) ; <nl> cond . wait ( lock ) ; <nl> gpr_log ( GPR_INFO , " % s server startup complete " , type_ . c_str ( ) ) ; <nl> } <nl> <nl> - void Start ( const grpc : : string & server_host , std : : mutex * mu , <nl> + void Serve ( const grpc : : string & server_host , std : : mutex * mu , <nl> std : : condition_variable * cond ) { <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> std : : shared_ptr < ServerCredentials > creds ( new SecureServerCredentials ( <nl> grpc_fake_transport_security_server_credentials_create ( ) ) ) ; <nl> builder . AddListeningPort ( server_address . str ( ) , creds ) ; <nl> - builder . RegisterService ( service_ ) ; <nl> + builder . RegisterService ( & service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> cond - > notify_one ( ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> + if ( ! running_ ) return ; <nl> gpr_log ( GPR_INFO , " % s about to shutdown " , type_ . c_str ( ) ) ; <nl> + service_ . Shutdown ( ) ; <nl> server_ - > Shutdown ( grpc_timeout_milliseconds_to_deadline ( 0 ) ) ; <nl> thread_ - > join ( ) ; <nl> gpr_log ( GPR_INFO , " % s shutdown completed " , type_ . c_str ( ) ) ; <nl> + running_ = false ; <nl> } <nl> <nl> - int port_ ; <nl> + const int port_ ; <nl> grpc : : string type_ ; <nl> + T service_ ; <nl> std : : unique_ptr < Server > server_ ; <nl> - T * service_ ; <nl> std : : unique_ptr < std : : thread > thread_ ; <nl> + bool running_ = false ; <nl> } ; <nl> <nl> const grpc : : string server_host_ ; <nl> class GrpclbEnd2endTest : public : : testing : : Test { <nl> const int client_load_reporting_interval_seconds_ ; <nl> std : : shared_ptr < Channel > channel_ ; <nl> std : : unique_ptr < grpc : : testing : : EchoTestService : : Stub > stub_ ; <nl> - std : : vector < std : : unique_ptr < BackendServiceImpl > > backends_ ; <nl> - std : : vector < std : : unique_ptr < BalancerServiceImpl > > balancers_ ; <nl> - std : : vector < ServerThread < BackendService > > backend_servers_ ; <nl> - std : : vector < ServerThread < BalancerService > > balancer_servers_ ; <nl> + std : : vector < std : : unique_ptr < ServerThread < BackendServiceImpl > > > backends_ ; <nl> + std : : vector < std : : unique_ptr < ServerThread < BalancerServiceImpl > > > balancers_ ; <nl> grpc_core : : RefCountedPtr < grpc_core : : FakeResolverResponseGenerator > <nl> response_generator_ ; <nl> const grpc : : string kRequestMessage_ = " Live long and prosper . " ; <nl> TEST_F ( SingleBalancerTest , Vanilla ) { <nl> <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> <nl> / / Check LB policy name for the channel . <nl> EXPECT_EQ ( " grpclb " , channel_ - > GetLoadBalancingPolicyName ( ) ) ; <nl> TEST_F ( SingleBalancerTest , SelectGrpclbWithMigrationServiceConfig ) { <nl> 0 , BalancerServiceImpl : : BuildResponseForBackends ( GetBackendPorts ( ) , { } ) , <nl> 0 ) ; <nl> CheckRpcSendOk ( 1 , 1000 / * timeout_ms * / , true / * wait_for_ready * / ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / Check LB policy name for the channel . <nl> EXPECT_EQ ( " grpclb " , channel_ - > GetLoadBalancingPolicyName ( ) ) ; <nl> } <nl> TEST_F ( SingleBalancerTest , <nl> const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor ( ) ; <nl> ResetStub ( kFallbackTimeoutMs ) ; <nl> / / Resolution includes fallback address but no balancers . <nl> - SetNextResolution ( { AddressData { backend_servers_ [ 0 ] . port_ , false , " " } } , <nl> + SetNextResolution ( { AddressData { backends_ [ 0 ] - > port_ , false , " " } } , <nl> " { \ n " <nl> " \ " loadBalancingConfig \ " : [ \ n " <nl> " { \ " does_not_exist \ " : { } } , \ n " <nl> TEST_F ( SingleBalancerTest , UsePickFirstChildPolicy ) { <nl> 0 ) ; <nl> const size_t kNumRpcs = num_backends_ * 2 ; <nl> CheckRpcSendOk ( kNumRpcs , 1000 / * timeout_ms * / , true / * wait_for_ready * / ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / Check that all requests went to the first backend . This verifies <nl> / / that we used pick_first instead of round_robin as the child policy . <nl> - EXPECT_EQ ( backend_servers_ [ 0 ] . service_ - > request_count ( ) , kNumRpcs ) ; <nl> + EXPECT_EQ ( backends_ [ 0 ] - > service_ . request_count ( ) , kNumRpcs ) ; <nl> for ( size_t i = 1 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( backend_servers_ [ i ] . service_ - > request_count ( ) , 0UL ) ; <nl> + EXPECT_EQ ( backends_ [ i ] - > service_ . request_count ( ) , 0UL ) ; <nl> } <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / Check LB policy name for the channel . <nl> EXPECT_EQ ( " grpclb " , channel_ - > GetLoadBalancingPolicyName ( ) ) ; <nl> } <nl> TEST_F ( SingleBalancerTest , SwapChildPolicy ) { <nl> CheckRpcSendOk ( kNumRpcs , 1000 / * timeout_ms * / , true / * wait_for_ready * / ) ; <nl> / / Check that all requests went to the first backend . This verifies <nl> / / that we used pick_first instead of round_robin as the child policy . <nl> - EXPECT_EQ ( backend_servers_ [ 0 ] . service_ - > request_count ( ) , kNumRpcs ) ; <nl> + EXPECT_EQ ( backends_ [ 0 ] - > service_ . request_count ( ) , kNumRpcs ) ; <nl> for ( size_t i = 1 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( backend_servers_ [ i ] . service_ - > request_count ( ) , 0UL ) ; <nl> + EXPECT_EQ ( backends_ [ i ] - > service_ . request_count ( ) , 0UL ) ; <nl> } <nl> / / Send new resolution that removes child policy from service config . <nl> SetNextResolutionAllBalancers ( " { } " ) ; <nl> TEST_F ( SingleBalancerTest , SwapChildPolicy ) { <nl> / / Check that every backend saw the same number of requests . This verifies <nl> / / that we used round_robin . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( backend_servers_ [ i ] . service_ - > request_count ( ) , 2UL ) ; <nl> + EXPECT_EQ ( backends_ [ i ] - > service_ . request_count ( ) , 2UL ) ; <nl> } <nl> / / Done . <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / Check LB policy name for the channel . <nl> EXPECT_EQ ( " grpclb " , channel_ - > GetLoadBalancingPolicyName ( ) ) ; <nl> } <nl> TEST_F ( SingleBalancerTest , UpdatesGoToMostRecentChildPolicy ) { <nl> / / Unreachable balancer . <nl> { unreachable_balancer_port , true , " " } , <nl> / / Fallback address : first backend . <nl> - { backend_servers_ [ 0 ] . port_ , false , " " } , <nl> + { backends_ [ 0 ] - > port_ , false , " " } , <nl> } , <nl> " { \ n " <nl> " \ " loadBalancingConfig \ " : [ \ n " <nl> TEST_F ( SingleBalancerTest , UpdatesGoToMostRecentChildPolicy ) { <nl> / / Unreachable balancer . <nl> { unreachable_balancer_port , true , " " } , <nl> / / Fallback address : second and third backends . <nl> - { backend_servers_ [ 1 ] . port_ , false , " " } , <nl> - { backend_servers_ [ 2 ] . port_ , false , " " } , <nl> + { backends_ [ 1 ] - > port_ , false , " " } , <nl> + { backends_ [ 2 ] - > port_ , false , " " } , <nl> } , <nl> " { \ n " <nl> " \ " loadBalancingConfig \ " : [ \ n " <nl> TEST_F ( SingleBalancerTest , SameBackendListedMultipleTimes ) { <nl> SetNextResolutionAllBalancers ( ) ; <nl> / / Same backend listed twice . <nl> std : : vector < int > ports ; <nl> - ports . push_back ( backend_servers_ [ 0 ] . port_ ) ; <nl> - ports . push_back ( backend_servers_ [ 0 ] . port_ ) ; <nl> + ports . push_back ( backends_ [ 0 ] - > port_ ) ; <nl> + ports . push_back ( backends_ [ 0 ] - > port_ ) ; <nl> const size_t kNumRpcsPerAddress = 10 ; <nl> ScheduleResponseForBalancer ( <nl> 0 , BalancerServiceImpl : : BuildResponseForBackends ( ports , { } ) , 0 ) ; <nl> TEST_F ( SingleBalancerTest , SameBackendListedMultipleTimes ) { <nl> / / Send kNumRpcsPerAddress RPCs per server . <nl> CheckRpcSendOk ( kNumRpcsPerAddress * ports . size ( ) ) ; <nl> / / Backend should have gotten 20 requests . <nl> - EXPECT_EQ ( kNumRpcsPerAddress * 2 , <nl> - backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress * 2 , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / And they should have come from a single client port , because of <nl> / / subchannel sharing . <nl> - EXPECT_EQ ( 1UL , backends_ [ 0 ] - > clients ( ) . size ( ) ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 1UL , backends_ [ 0 ] - > service_ . clients ( ) . size ( ) ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , SecureNaming ) { <nl> ResetStub ( 0 , kApplicationTargetName_ + " ; lb " ) ; <nl> - SetNextResolution ( { AddressData { balancer_servers_ [ 0 ] . port_ , true , " lb " } } ) ; <nl> + SetNextResolution ( { AddressData { balancers_ [ 0 ] - > port_ , true , " lb " } } ) ; <nl> const size_t kNumRpcsPerAddress = 100 ; <nl> ScheduleResponseForBalancer ( <nl> 0 , BalancerServiceImpl : : BuildResponseForBackends ( GetBackendPorts ( ) , { } ) , <nl> TEST_F ( SingleBalancerTest , SecureNaming ) { <nl> <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / Check LB policy name for the channel . <nl> EXPECT_EQ ( " grpclb " , channel_ - > GetLoadBalancingPolicyName ( ) ) ; <nl> } <nl> TEST_F ( SingleBalancerTest , SecureNamingDeathTest ) { <nl> ASSERT_DEATH ( <nl> { <nl> ResetStub ( 0 , kApplicationTargetName_ + " ; lb " ) ; <nl> - SetNextResolution ( <nl> - { AddressData { balancer_servers_ [ 0 ] . port_ , true , " woops " } } ) ; <nl> + SetNextResolution ( { AddressData { balancers_ [ 0 ] - > port_ , true , " woops " } } ) ; <nl> channel_ - > WaitForConnected ( grpc_timeout_seconds_to_deadline ( 1 ) ) ; <nl> } , <nl> " " ) ; <nl> TEST_F ( SingleBalancerTest , InitiallyEmptyServerlist ) { <nl> / / populated serverlist but under the call ' s deadline ( which is enforced by <nl> / / the call ' s deadline ) . <nl> EXPECT_GT ( ellapsed_ms . count ( ) , kServerlistDelayMs ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent two responses . <nl> - EXPECT_EQ ( 2U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 2U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , AllServersUnreachableFailFast ) { <nl> TEST_F ( SingleBalancerTest , AllServersUnreachableFailFast ) { <nl> const Status status = SendRpc ( ) ; <nl> / / The error shouldn ' t be DEADLINE_EXCEEDED . <nl> EXPECT_EQ ( StatusCode : : UNAVAILABLE , status . error_code ( ) ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , Fallback ) { <nl> TEST_F ( SingleBalancerTest , Fallback ) { <nl> <nl> ResetStub ( kFallbackTimeoutMs ) ; <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> for ( size_t i = 0 ; i < kNumBackendInResolution ; + + i ) { <nl> - addresses . emplace_back ( AddressData { backend_servers_ [ i ] . port_ , false , " " } ) ; <nl> + addresses . emplace_back ( AddressData { backends_ [ i ] - > port_ , false , " " } ) ; <nl> } <nl> SetNextResolution ( addresses ) ; <nl> <nl> TEST_F ( SingleBalancerTest , Fallback ) { <nl> / / Fallback is used : each backend returned by the resolver should have <nl> / / gotten one request . <nl> for ( size_t i = 0 ; i < kNumBackendInResolution ; + + i ) { <nl> - EXPECT_EQ ( 1U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> for ( size_t i = kNumBackendInResolution ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( 0U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> <nl> / / Wait until the serverlist reception has been processed and all backends <nl> TEST_F ( SingleBalancerTest , Fallback ) { <nl> / / Serverlist is used : each backend returned by the balancer should <nl> / / have gotten one request . <nl> for ( size_t i = 0 ; i < kNumBackendInResolution ; + + i ) { <nl> - EXPECT_EQ ( 0U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> for ( size_t i = kNumBackendInResolution ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( 1U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , FallbackUpdate ) { <nl> TEST_F ( SingleBalancerTest , FallbackUpdate ) { <nl> <nl> ResetStub ( kFallbackTimeoutMs ) ; <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> for ( size_t i = 0 ; i < kNumBackendInResolution ; + + i ) { <nl> - addresses . emplace_back ( AddressData { backend_servers_ [ i ] . port_ , false , " " } ) ; <nl> + addresses . emplace_back ( AddressData { backends_ [ i ] - > port_ , false , " " } ) ; <nl> } <nl> SetNextResolution ( addresses ) ; <nl> <nl> TEST_F ( SingleBalancerTest , FallbackUpdate ) { <nl> / / Fallback is used : each backend returned by the resolver should have <nl> / / gotten one request . <nl> for ( size_t i = 0 ; i < kNumBackendInResolution ; + + i ) { <nl> - EXPECT_EQ ( 1U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> for ( size_t i = kNumBackendInResolution ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( 0U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> <nl> addresses . clear ( ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> for ( size_t i = kNumBackendInResolution ; <nl> i < kNumBackendInResolution + kNumBackendInResolutionUpdate ; + + i ) { <nl> - addresses . emplace_back ( AddressData { backend_servers_ [ i ] . port_ , false , " " } ) ; <nl> + addresses . emplace_back ( AddressData { backends_ [ i ] - > port_ , false , " " } ) ; <nl> } <nl> SetNextResolution ( addresses ) ; <nl> <nl> TEST_F ( SingleBalancerTest , FallbackUpdate ) { <nl> / / The resolution update is used : each backend in the resolution update should <nl> / / have gotten one request . <nl> for ( size_t i = 0 ; i < kNumBackendInResolution ; + + i ) { <nl> - EXPECT_EQ ( 0U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> for ( size_t i = kNumBackendInResolution ; <nl> i < kNumBackendInResolution + kNumBackendInResolutionUpdate ; + + i ) { <nl> - EXPECT_EQ ( 1U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> for ( size_t i = kNumBackendInResolution + kNumBackendInResolutionUpdate ; <nl> i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( 0U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> <nl> / / Wait until the serverlist reception has been processed and all backends <nl> TEST_F ( SingleBalancerTest , FallbackUpdate ) { <nl> / / have gotten one request . <nl> for ( size_t i = 0 ; <nl> i < kNumBackendInResolution + kNumBackendInResolutionUpdate ; + + i ) { <nl> - EXPECT_EQ ( 0U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> for ( size_t i = kNumBackendInResolution + kNumBackendInResolutionUpdate ; <nl> i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( 1U , backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , FallbackEarlyWhenBalancerChannelFails ) { <nl> TEST_F ( SingleBalancerTest , FallbackEarlyWhenBalancerChannelFails ) { <nl> / / Return an unreachable balancer and one fallback backend . <nl> std : : vector < AddressData > addresses ; <nl> addresses . emplace_back ( AddressData { grpc_pick_unused_port_or_die ( ) , true , " " } ) ; <nl> - addresses . emplace_back ( AddressData { backend_servers_ [ 0 ] . port_ , false , " " } ) ; <nl> + addresses . emplace_back ( AddressData { backends_ [ 0 ] - > port_ , false , " " } ) ; <nl> SetNextResolution ( addresses ) ; <nl> / / Send RPC with deadline less than the fallback timeout and make sure it <nl> / / succeeds . <nl> TEST_F ( SingleBalancerTest , BackendsRestart ) { <nl> channel_ - > GetState ( true / * try_to_connect * / ) ; <nl> / / Send kNumRpcsPerAddress RPCs per server . <nl> CheckRpcSendOk ( kNumRpcsPerAddress * num_backends_ ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - if ( backends_ [ i ] - > Shutdown ( ) ) backend_servers_ [ i ] . Shutdown ( ) ; <nl> - } <nl> - CheckRpcSendFailure ( ) ; <nl> - for ( size_t i = 0 ; i < num_backends_ ; + + i ) { <nl> - backends_ . emplace_back ( new BackendServiceImpl ( ) ) ; <nl> - backend_servers_ . emplace_back ( ServerThread < BackendService > ( <nl> - " backend " , server_host_ , backends_ . back ( ) . get ( ) ) ) ; <nl> - } <nl> - / / The following RPC will fail due to the backend ports having changed . It <nl> - / / will nonetheless exercise the grpclb - roundrobin handling of the RR policy <nl> - / / having gone into shutdown . <nl> - / / TODO ( dgq ) : implement the " backend restart " component as well . We need extra <nl> - / / machinery to either update the LB responses " on the fly " or instruct <nl> - / / backends which ports to restart on . <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + / / Stop backends . RPCs should fail . <nl> + ShutdownAllBackends ( ) ; <nl> CheckRpcSendFailure ( ) ; <nl> + / / Restart backends . RPCs should start succeeding again . <nl> + StartAllBackends ( ) ; <nl> + CheckRpcSendOk ( 1 / * times * / , 1000 / * timeout_ms * / , <nl> + true / * wait_for_ready * / ) ; <nl> } <nl> <nl> class UpdatesTest : public GrpclbEnd2endTest { <nl> TEST_F ( UpdatesTest , UpdateBalancers ) { <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 1 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 2 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 1 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 2 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 1 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 1 ] - > port_ , true , " " } ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 1 = = = = = = = = = = " ) ; <nl> SetNextResolution ( addresses ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 1 DONE = = = = = = = = = = " ) ; <nl> <nl> / / Wait until update has been processed , as signaled by the second backend <nl> / / receiving a request . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> WaitForBackend ( 1 ) ; <nl> <nl> - backend_servers_ [ 1 ] . service_ - > ResetCounters ( ) ; <nl> + backends_ [ 1 ] - > service_ . ResetCounters ( ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = BEFORE SECOND BATCH = = = = = = = = = = " ) ; <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH SECOND BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the second backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 1 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 2 ] - > NotifyDoneWithServerlists ( ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 1 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 2 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> / / Send an update with the same set of LBs as the one in SetUp ( ) in order to <nl> TEST_F ( UpdatesTest , UpdateBalancersRepeated ) { <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 1 ] . port_ , true , " " } ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 2 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 1 ] - > port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 2 ] - > port_ , true , " " } ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 1 = = = = = = = = = = " ) ; <nl> SetNextResolution ( addresses ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 1 DONE = = = = = = = = = = " ) ; <nl> <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> gpr_timespec deadline = gpr_time_add ( <nl> gpr_now ( GPR_CLOCK_REALTIME ) , gpr_time_from_millis ( 10000 , GPR_TIMESPAN ) ) ; <nl> / / Send 10 seconds worth of RPCs <nl> TEST_F ( UpdatesTest , UpdateBalancersRepeated ) { <nl> } while ( gpr_time_cmp ( gpr_now ( GPR_CLOCK_REALTIME ) , deadline ) < 0 ) ; <nl> / / grpclb continued using the original LB call to the first balancer , which <nl> / / doesn ' t assign the second backend . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> <nl> addresses . clear ( ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 1 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 1 ] - > port_ , true , " " } ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 2 = = = = = = = = = = " ) ; <nl> SetNextResolution ( addresses ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 2 DONE = = = = = = = = = = " ) ; <nl> <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> deadline = gpr_time_add ( gpr_now ( GPR_CLOCK_REALTIME ) , <nl> gpr_time_from_millis ( 10000 , GPR_TIMESPAN ) ) ; <nl> / / Send 10 seconds worth of RPCs <nl> TEST_F ( UpdatesTest , UpdateBalancersRepeated ) { <nl> } while ( gpr_time_cmp ( gpr_now ( GPR_CLOCK_REALTIME ) , deadline ) < 0 ) ; <nl> / / grpclb continued using the original LB call to the first balancer , which <nl> / / doesn ' t assign the second backend . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> } <nl> <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> SetNextResolution ( addresses ) ; <nl> const std : : vector < int > first_backend { GetBackendPorts ( ) [ 0 ] } ; <nl> const std : : vector < int > second_backend { GetBackendPorts ( ) [ 1 ] } ; <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Kill balancer 0 <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * ABOUT TO KILL BALANCER 0 * * * * * * * * * * * * * " ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> - if ( balancers_ [ 0 ] - > Shutdown ( ) ) balancer_servers_ [ 0 ] . Shutdown ( ) ; <nl> + balancers_ [ 0 ] - > Shutdown ( ) ; <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * KILLED BALANCER 0 * * * * * * * * * * * * * " ) ; <nl> <nl> / / This is serviced by the existing RR policy <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH SECOND BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should again have gone to the first backend . <nl> - EXPECT_EQ ( 20U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 20U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 1 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 2 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 1 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 2 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> addresses . clear ( ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 1 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 1 ] - > port_ , true , " " } ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 1 = = = = = = = = = = " ) ; <nl> SetNextResolution ( addresses ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 1 DONE = = = = = = = = = = " ) ; <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> / / Wait until update has been processed , as signaled by the second backend <nl> / / receiving a request . In the meantime , the client continues to be serviced <nl> / / ( by the first backend ) without interruption . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> WaitForBackend ( 1 ) ; <nl> <nl> / / This is serviced by the updated RR policy <nl> - backend_servers_ [ 1 ] . service_ - > ResetCounters ( ) ; <nl> + backends_ [ 1 ] - > service_ . ResetCounters ( ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = BEFORE THIRD BATCH = = = = = = = = = = " ) ; <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH THIRD BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the second backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 1 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 2 ] - > NotifyDoneWithServerlists ( ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 1 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 2 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / The second balancer , published as part of the first update , may end up <nl> / / getting two requests ( that is , 1 < = # req < = 2 ) if the LB call retry timer <nl> / / firing races with the arrival of the update containing the second <nl> / / balancer . <nl> - EXPECT_GE ( balancer_servers_ [ 1 ] . service_ - > request_count ( ) , 1U ) ; <nl> - EXPECT_GE ( balancer_servers_ [ 1 ] . service_ - > response_count ( ) , 1U ) ; <nl> - EXPECT_LE ( balancer_servers_ [ 1 ] . service_ - > request_count ( ) , 2U ) ; <nl> - EXPECT_LE ( balancer_servers_ [ 1 ] . service_ - > response_count ( ) , 2U ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_GE ( balancers_ [ 1 ] - > service_ . request_count ( ) , 1U ) ; <nl> + EXPECT_GE ( balancers_ [ 1 ] - > service_ . response_count ( ) , 1U ) ; <nl> + EXPECT_LE ( balancers_ [ 1 ] - > service_ . request_count ( ) , 2U ) ; <nl> + EXPECT_LE ( balancers_ [ 1 ] - > service_ . response_count ( ) , 2U ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( UpdatesTest , ReresolveDeadBackend ) { <nl> TEST_F ( UpdatesTest , ReresolveDeadBackend ) { <nl> / / The first resolution contains the addresses of a balancer that never <nl> / / responds , and a fallback backend . <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> - addresses . emplace_back ( AddressData { backend_servers_ [ 0 ] . port_ , false , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { backends_ [ 0 ] - > port_ , false , " " } ) ; <nl> SetNextResolution ( addresses ) ; <nl> / / The re - resolution result will contain the addresses of the same balancer <nl> / / and a new fallback backend . <nl> addresses . clear ( ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> - addresses . emplace_back ( AddressData { backend_servers_ [ 1 ] . port_ , false , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { backends_ [ 1 ] - > port_ , false , " " } ) ; <nl> SetNextReresolutionResponse ( addresses ) ; <nl> <nl> / / Start servers and send 10 RPCs per server . <nl> TEST_F ( UpdatesTest , ReresolveDeadBackend ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the fallback backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Kill backend 0 . <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * ABOUT TO KILL BACKEND 0 * * * * * * * * * * * * * " ) ; <nl> - if ( backends_ [ 0 ] - > Shutdown ( ) ) backend_servers_ [ 0 ] . Shutdown ( ) ; <nl> + backends_ [ 0 ] - > Shutdown ( ) ; <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * KILLED BACKEND 0 * * * * * * * * * * * * * " ) ; <nl> <nl> / / Wait until re - resolution has finished , as signaled by the second backend <nl> TEST_F ( UpdatesTest , ReresolveDeadBackend ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH SECOND BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the second backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 1 ] - > NotifyDoneWithServerlists ( ) ; <nl> - balancers_ [ 2 ] - > NotifyDoneWithServerlists ( ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 1 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 2 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> / / TODO ( juanlishen ) : Should be removed when the first response is always the <nl> class UpdatesWithClientLoadReportingTest : public GrpclbEnd2endTest { <nl> <nl> TEST_F ( UpdatesWithClientLoadReportingTest , ReresolveDeadBalancer ) { <nl> std : : vector < AddressData > addresses ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 0 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 0 ] - > port_ , true , " " } ) ; <nl> SetNextResolution ( addresses ) ; <nl> addresses . clear ( ) ; <nl> - addresses . emplace_back ( AddressData { balancer_servers_ [ 1 ] . port_ , true , " " } ) ; <nl> + addresses . emplace_back ( AddressData { balancers_ [ 1 ] - > port_ , true , " " } ) ; <nl> SetNextReresolutionResponse ( addresses ) ; <nl> const std : : vector < int > first_backend { GetBackendPorts ( ) [ 0 ] } ; <nl> const std : : vector < int > second_backend { GetBackendPorts ( ) [ 1 ] } ; <nl> TEST_F ( UpdatesWithClientLoadReportingTest , ReresolveDeadBalancer ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Kill backend 0 . <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * ABOUT TO KILL BACKEND 0 * * * * * * * * * * * * * " ) ; <nl> - if ( backends_ [ 0 ] - > Shutdown ( ) ) backend_servers_ [ 0 ] . Shutdown ( ) ; <nl> + backends_ [ 0 ] - > Shutdown ( ) ; <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * KILLED BACKEND 0 * * * * * * * * * * * * * " ) ; <nl> <nl> CheckRpcSendFailure ( ) ; <nl> <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> / / Kill balancer 0 . <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * ABOUT TO KILL BALANCER 0 * * * * * * * * * * * * * " ) ; <nl> - if ( balancers_ [ 0 ] - > Shutdown ( ) ) balancer_servers_ [ 0 ] . Shutdown ( ) ; <nl> + balancers_ [ 0 ] - > Shutdown ( ) ; <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * KILLED BALANCER 0 * * * * * * * * * * * * * " ) ; <nl> <nl> / / Wait until re - resolution has finished , as signaled by the second backend <nl> TEST_F ( UpdatesWithClientLoadReportingTest , ReresolveDeadBalancer ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH SECOND BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the second backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / After balancer 0 is killed , we restart an LB call immediately ( because we <nl> / / disconnect to a previously connected balancer ) . Although we will cancel <nl> / / this call when the re - resolution update is done and another LB call restart <nl> / / is needed , this old call may still succeed reaching the LB server if <nl> / / re - resolution is slow . So balancer 1 may have received 2 requests and sent <nl> / / 2 responses . <nl> - EXPECT_GE ( balancer_servers_ [ 1 ] . service_ - > request_count ( ) , 1U ) ; <nl> - EXPECT_GE ( balancer_servers_ [ 1 ] . service_ - > response_count ( ) , 1U ) ; <nl> - EXPECT_LE ( balancer_servers_ [ 1 ] . service_ - > request_count ( ) , 2U ) ; <nl> - EXPECT_LE ( balancer_servers_ [ 1 ] . service_ - > response_count ( ) , 2U ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_GE ( balancers_ [ 1 ] - > service_ . request_count ( ) , 1U ) ; <nl> + EXPECT_GE ( balancers_ [ 1 ] - > service_ . response_count ( ) , 1U ) ; <nl> + EXPECT_LE ( balancers_ [ 1 ] - > service_ . request_count ( ) , 2U ) ; <nl> + EXPECT_LE ( balancers_ [ 1 ] - > service_ . response_count ( ) , 2U ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , Drop ) { <nl> TEST_F ( SingleBalancerTest , Drop ) { <nl> } <nl> } <nl> EXPECT_EQ ( kNumRpcsPerAddress * num_of_drop_addresses , num_drops ) ; <nl> - <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , DropAllFirst ) { <nl> class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest { <nl> SingleBalancerWithClientLoadReportingTest ( ) : GrpclbEnd2endTest ( 4 , 1 , 3 ) { } <nl> } ; <nl> <nl> - / / TODO ( roth ) : Add test that when switching balancers , we don ' t include <nl> - / / any calls that were sent prior to connecting to the new balancer . <nl> - <nl> TEST_F ( SingleBalancerWithClientLoadReportingTest , Vanilla ) { <nl> SetNextResolutionAllBalancers ( ) ; <nl> const size_t kNumRpcsPerAddress = 100 ; <nl> TEST_F ( SingleBalancerWithClientLoadReportingTest , Vanilla ) { <nl> CheckRpcSendOk ( kNumRpcsPerAddress * num_backends_ ) ; <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> <nl> const ClientStats client_stats = WaitForLoadReports ( ) ; <nl> EXPECT_EQ ( kNumRpcsPerAddress * num_backends_ + num_ok , <nl> TEST_F ( SingleBalancerWithClientLoadReportingTest , Vanilla ) { <nl> EXPECT_THAT ( client_stats . drop_token_counts , : : testing : : ElementsAre ( ) ) ; <nl> } <nl> <nl> + TEST_F ( SingleBalancerWithClientLoadReportingTest , BalancerRestart ) { <nl> + SetNextResolutionAllBalancers ( ) ; <nl> + const size_t kNumBackendsFirstPass = 2 ; <nl> + const size_t kNumBackendsSecondPass = <nl> + backends_ . size ( ) - kNumBackendsFirstPass ; <nl> + / / Balancer returns backends starting at index 1 . <nl> + ScheduleResponseForBalancer ( <nl> + 0 , <nl> + BalancerServiceImpl : : BuildResponseForBackends ( <nl> + GetBackendPorts ( 0 , kNumBackendsFirstPass ) , { } ) , <nl> + 0 ) ; <nl> + / / Wait until all backends returned by the balancer are ready . <nl> + int num_ok = 0 ; <nl> + int num_failure = 0 ; <nl> + int num_drops = 0 ; <nl> + std : : tie ( num_ok , num_failure , num_drops ) = <nl> + WaitForAllBackends ( / * num_requests_multiple_of * / 1 , / * start_index * / 0 , <nl> + / * stop_index * / kNumBackendsFirstPass ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + ClientStats client_stats = WaitForLoadReports ( ) ; <nl> + EXPECT_EQ ( static_cast < size_t > ( num_ok ) , client_stats . num_calls_started ) ; <nl> + EXPECT_EQ ( static_cast < size_t > ( num_ok ) , client_stats . num_calls_finished ) ; <nl> + EXPECT_EQ ( 0U , client_stats . num_calls_finished_with_client_failed_to_send ) ; <nl> + EXPECT_EQ ( static_cast < size_t > ( num_ok ) , <nl> + client_stats . num_calls_finished_known_received ) ; <nl> + EXPECT_THAT ( client_stats . drop_token_counts , : : testing : : ElementsAre ( ) ) ; <nl> + / / Shut down the balancer . <nl> + balancers_ [ 0 ] - > Shutdown ( ) ; <nl> + / / Send 10 more requests per backend . This will continue using the <nl> + / / last serverlist we received from the balancer before it was shut down . <nl> + ResetBackendCounters ( ) ; <nl> + CheckRpcSendOk ( kNumBackendsFirstPass ) ; <nl> + / / Each backend should have gotten 1 request . <nl> + for ( size_t i = 0 ; i < kNumBackendsFirstPass ; + + i ) { <nl> + EXPECT_EQ ( 1UL , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> + } <nl> + / / Now restart the balancer , this time pointing to all backends . <nl> + balancers_ [ 0 ] - > Start ( server_host_ ) ; <nl> + ScheduleResponseForBalancer ( 0 , <nl> + BalancerServiceImpl : : BuildResponseForBackends ( <nl> + GetBackendPorts ( kNumBackendsFirstPass ) , { } ) , <nl> + 0 ) ; <nl> + / / Wait for queries to start going to one of the new backends . <nl> + / / This tells us that we ' re now using the new serverlist . <nl> + do { <nl> + CheckRpcSendOk ( ) ; <nl> + } while ( backends_ [ 2 ] - > service_ . request_count ( ) = = 0 & & <nl> + backends_ [ 3 ] - > service_ . request_count ( ) = = 0 ) ; <nl> + / / Send one RPC per backend . <nl> + CheckRpcSendOk ( kNumBackendsSecondPass ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 2U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 2U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + / / Check client stats . <nl> + client_stats = WaitForLoadReports ( ) ; <nl> + EXPECT_EQ ( kNumBackendsSecondPass + 1 , client_stats . num_calls_started ) ; <nl> + EXPECT_EQ ( kNumBackendsSecondPass + 1 , client_stats . num_calls_finished ) ; <nl> + EXPECT_EQ ( 0U , client_stats . num_calls_finished_with_client_failed_to_send ) ; <nl> + EXPECT_EQ ( kNumBackendsSecondPass + 1 , <nl> + client_stats . num_calls_finished_known_received ) ; <nl> + EXPECT_THAT ( client_stats . drop_token_counts , : : testing : : ElementsAre ( ) ) ; <nl> + } <nl> + <nl> TEST_F ( SingleBalancerWithClientLoadReportingTest , Drop ) { <nl> SetNextResolutionAllBalancers ( ) ; <nl> const size_t kNumRpcsPerAddress = 3 ; <nl> TEST_F ( SingleBalancerWithClientLoadReportingTest , Drop ) { <nl> EXPECT_EQ ( kNumRpcsPerAddress * num_of_drop_addresses , num_drops ) ; <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> <nl> const ClientStats client_stats = WaitForLoadReports ( ) ; <nl> EXPECT_EQ ( <nl> mmm a / test / cpp / end2end / xds_end2end_test . cc <nl> ppp b / test / cpp / end2end / xds_end2end_test . cc <nl> <nl> / / TODO ( dgq ) : Other scenarios in need of testing : <nl> / / - Send a serverlist with faulty ip : port addresses ( port > 2 ^ 16 , etc ) . <nl> / / - Test reception of invalid serverlist <nl> - / / - Test pinging <nl> / / - Test against a non - LB server . <nl> / / - Random LB server closing the stream unexpectedly . <nl> - / / - Test using DNS - resolvable names ( localhost ? ) <nl> - / / - Test handling of creation of faulty RR instance by having the LB return a <nl> - / / serverlist with non - existent backends after having initially returned a <nl> - / / valid one . <nl> / / <nl> / / Findings from end to end testing to be covered here : <nl> / / - Handling of LB servers restart , including reconnection after backing - off <nl> <nl> / / part of the xds shutdown process . <nl> / / 2 ) the retry timer is active . Again , the weak reference it holds should <nl> / / prevent a premature call to \ a glb_destroy . <nl> - / / - Restart of backend servers with no changes to serverlist . This exercises <nl> - / / the RR handover mechanism . <nl> <nl> using std : : chrono : : system_clock ; <nl> <nl> class BackendServiceImpl : public BackendService { <nl> return status ; <nl> } <nl> <nl> - / / Returns true on its first invocation , false otherwise . <nl> - bool Shutdown ( ) { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - const bool prev = ! shutdown_ ; <nl> - shutdown_ = true ; <nl> - gpr_log ( GPR_INFO , " Backend : shut down " ) ; <nl> - return prev ; <nl> - } <nl> + void Shutdown ( ) { } <nl> <nl> std : : set < grpc : : string > clients ( ) { <nl> std : : unique_lock < std : : mutex > lock ( clients_mu_ ) ; <nl> class BackendServiceImpl : public BackendService { <nl> } <nl> <nl> std : : mutex mu_ ; <nl> - bool shutdown_ = false ; <nl> std : : mutex clients_mu_ ; <nl> std : : set < grpc : : string > clients_ ; <nl> } ; <nl> struct ClientStats { <nl> } <nl> return * this ; <nl> } <nl> + <nl> + void Reset ( ) { <nl> + num_calls_started = 0 ; <nl> + num_calls_finished = 0 ; <nl> + num_calls_finished_with_client_failed_to_send = 0 ; <nl> + num_calls_finished_known_received = 0 ; <nl> + drop_token_counts . clear ( ) ; <nl> + } <nl> } ; <nl> <nl> class BalancerServiceImpl : public BalancerService { <nl> class BalancerServiceImpl : public BalancerService { <nl> <nl> explicit BalancerServiceImpl ( int client_load_reporting_interval_seconds ) <nl> : client_load_reporting_interval_seconds_ ( <nl> - client_load_reporting_interval_seconds ) , <nl> - shutdown_ ( false ) { } <nl> + client_load_reporting_interval_seconds ) { } <nl> <nl> Status BalanceLoad ( ServerContext * context , Stream * stream ) override { <nl> / / TODO ( juanlishen ) : Clean up the scoping . <nl> gpr_log ( GPR_INFO , " LB [ % p ] : BalanceLoad " , this ) ; <nl> - { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - if ( shutdown_ ) goto done ; <nl> - } <nl> - <nl> { <nl> / / Balancer shouldn ' t receive the call credentials metadata . <nl> EXPECT_EQ ( context - > client_metadata ( ) . find ( g_kCallCredsMdKey ) , <nl> class BalancerServiceImpl : public BalancerService { <nl> responses_and_delays = responses_and_delays_ ; <nl> } <nl> for ( const auto & response_and_delay : responses_and_delays ) { <nl> - { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - if ( shutdown_ ) goto done ; <nl> - } <nl> SendResponse ( stream , response_and_delay . first , <nl> response_and_delay . second ) ; <nl> } <nl> { <nl> std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - if ( shutdown_ ) goto done ; <nl> - serverlist_cond_ . wait ( lock , [ this ] { return serverlist_ready_ ; } ) ; <nl> + serverlist_cond_ . wait ( lock , [ this ] { return serverlist_done_ ; } ) ; <nl> } <nl> <nl> if ( client_load_reporting_interval_seconds_ > 0 ) { <nl> class BalancerServiceImpl : public BalancerService { <nl> responses_and_delays_ . push_back ( std : : make_pair ( response , send_after_ms ) ) ; <nl> } <nl> <nl> - / / Returns true on its first invocation , false otherwise . <nl> - bool Shutdown ( ) { <nl> - bool prev ; <nl> - { <nl> - std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> - prev = ! shutdown_ ; <nl> - shutdown_ = true ; <nl> - } <nl> - NotifyDoneWithServerlists ( ) ; <nl> + void Shutdown ( ) { <nl> + std : : unique_lock < std : : mutex > lock ( mu_ ) ; <nl> + NotifyDoneWithServerlistsLocked ( ) ; <nl> + responses_and_delays_ . clear ( ) ; <nl> + client_stats_ . Reset ( ) ; <nl> gpr_log ( GPR_INFO , " LB [ % p ] : shut down " , this ) ; <nl> - return prev ; <nl> } <nl> <nl> static LoadBalanceResponse BuildResponseForBackends ( <nl> class BalancerServiceImpl : public BalancerService { <nl> <nl> void NotifyDoneWithServerlists ( ) { <nl> std : : lock_guard < std : : mutex > lock ( mu_ ) ; <nl> - serverlist_ready_ = true ; <nl> - serverlist_cond_ . notify_all ( ) ; <nl> + NotifyDoneWithServerlistsLocked ( ) ; <nl> + } <nl> + <nl> + void NotifyDoneWithServerlistsLocked ( ) { <nl> + if ( ! serverlist_done_ ) { <nl> + serverlist_done_ = true ; <nl> + serverlist_cond_ . notify_all ( ) ; <nl> + } <nl> } <nl> <nl> private : <nl> class BalancerServiceImpl : public BalancerService { <nl> std : : condition_variable load_report_cond_ ; <nl> bool load_report_ready_ = false ; <nl> std : : condition_variable serverlist_cond_ ; <nl> - bool serverlist_ready_ = false ; <nl> + bool serverlist_done_ = false ; <nl> ClientStats client_stats_ ; <nl> - bool shutdown_ ; <nl> } ; <nl> <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> protected : <nl> - XdsEnd2endTest ( int num_backends , int num_balancers , <nl> + XdsEnd2endTest ( size_t num_backends , size_t num_balancers , <nl> int client_load_reporting_interval_seconds ) <nl> : server_host_ ( " localhost " ) , <nl> num_backends_ ( num_backends ) , <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> grpc_core : : MakeRefCounted < grpc_core : : FakeResolverResponseGenerator > ( ) ; <nl> / / Start the backends . <nl> for ( size_t i = 0 ; i < num_backends_ ; + + i ) { <nl> - backends_ . emplace_back ( new BackendServiceImpl ( ) ) ; <nl> - backend_servers_ . emplace_back ( ServerThread < BackendService > ( <nl> - " backend " , server_host_ , backends_ . back ( ) . get ( ) ) ) ; <nl> + backends_ . emplace_back ( new ServerThread < BackendServiceImpl > ( " backend " ) ) ; <nl> + backends_ . back ( ) - > Start ( server_host_ ) ; <nl> } <nl> / / Start the load balancers . <nl> for ( size_t i = 0 ; i < num_balancers_ ; + + i ) { <nl> - balancers_ . emplace_back ( <nl> - new BalancerServiceImpl ( client_load_reporting_interval_seconds_ ) ) ; <nl> - balancer_servers_ . emplace_back ( ServerThread < BalancerService > ( <nl> - " balancer " , server_host_ , balancers_ . back ( ) . get ( ) ) ) ; <nl> + balancers_ . emplace_back ( new ServerThread < BalancerServiceImpl > ( <nl> + " balancer " , client_load_reporting_interval_seconds_ ) ) ; <nl> + balancers_ . back ( ) - > Start ( server_host_ ) ; <nl> } <nl> ResetStub ( ) ; <nl> } <nl> <nl> void TearDown ( ) override { <nl> - for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - if ( backends_ [ i ] - > Shutdown ( ) ) backend_servers_ [ i ] . Shutdown ( ) ; <nl> - } <nl> - for ( size_t i = 0 ; i < balancers_ . size ( ) ; + + i ) { <nl> - if ( balancers_ [ i ] - > Shutdown ( ) ) balancer_servers_ [ i ] . Shutdown ( ) ; <nl> - } <nl> + ShutdownAllBackends ( ) ; <nl> + for ( auto & balancer : balancers_ ) balancer - > Shutdown ( ) ; <nl> + } <nl> + <nl> + void StartAllBackends ( ) { <nl> + for ( auto & backend : backends_ ) backend - > Start ( server_host_ ) ; <nl> + } <nl> + <nl> + void StartBackend ( size_t index ) { backends_ [ index ] - > Start ( server_host_ ) ; } <nl> + <nl> + void ShutdownAllBackends ( ) { <nl> + for ( auto & backend : backends_ ) backend - > Shutdown ( ) ; <nl> } <nl> <nl> + void ShutdownBackend ( size_t index ) { backends_ [ index ] - > Shutdown ( ) ; } <nl> + <nl> void ResetStub ( int fallback_timeout = 0 , <nl> const grpc : : string & expected_targets = " " ) { <nl> ChannelArguments args ; <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> } <nl> <nl> void ResetBackendCounters ( ) { <nl> - for ( const auto & backend : backends_ ) backend - > ResetCounters ( ) ; <nl> + for ( auto & backend : backends_ ) backend - > service_ . ResetCounters ( ) ; <nl> } <nl> <nl> ClientStats WaitForLoadReports ( ) { <nl> ClientStats client_stats ; <nl> - for ( const auto & balancer : balancers_ ) { <nl> - client_stats + = balancer - > WaitForLoadReport ( ) ; <nl> + for ( auto & balancer : balancers_ ) { <nl> + client_stats + = balancer - > service_ . WaitForLoadReport ( ) ; <nl> } <nl> return client_stats ; <nl> } <nl> <nl> - bool SeenAllBackends ( ) { <nl> - for ( const auto & backend : backends_ ) { <nl> - if ( backend - > request_count ( ) = = 0 ) return false ; <nl> + bool SeenAllBackends ( size_t start_index = 0 , size_t stop_index = 0 ) { <nl> + if ( stop_index = = 0 ) stop_index = backends_ . size ( ) ; <nl> + for ( size_t i = start_index ; i < stop_index ; + + i ) { <nl> + if ( backends_ [ i ] - > service_ . request_count ( ) = = 0 ) return false ; <nl> } <nl> return true ; <nl> } <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> + + * num_total ; <nl> } <nl> <nl> - std : : tuple < int , int , int > WaitForAllBackends ( <nl> - int num_requests_multiple_of = 1 ) { <nl> + std : : tuple < int , int , int > WaitForAllBackends ( int num_requests_multiple_of = 1 , <nl> + size_t start_index = 0 , <nl> + size_t stop_index = 0 ) { <nl> int num_ok = 0 ; <nl> int num_failure = 0 ; <nl> int num_drops = 0 ; <nl> int num_total = 0 ; <nl> - while ( ! SeenAllBackends ( ) ) { <nl> + while ( ! SeenAllBackends ( start_index , stop_index ) ) { <nl> SendRpcAndCount ( & num_total , & num_ok , & num_failure , & num_drops ) ; <nl> } <nl> while ( num_total % num_requests_multiple_of ! = 0 ) { <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> void WaitForBackend ( size_t backend_idx ) { <nl> do { <nl> ( void ) SendRpc ( ) ; <nl> - } while ( backends_ [ backend_idx ] - > request_count ( ) = = 0 ) ; <nl> + } while ( backends_ [ backend_idx ] - > service_ . request_count ( ) = = 0 ) ; <nl> ResetBackendCounters ( ) ; <nl> } <nl> <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> grpc_core : : FakeResolverResponseGenerator * lb_channel_response_generator = <nl> nullptr ) { <nl> std : : vector < int > ports ; <nl> - for ( size_t i = 0 ; i < balancer_servers_ . size ( ) ; + + i ) { <nl> - ports . emplace_back ( balancer_servers_ [ i ] . port_ ) ; <nl> + for ( size_t i = 0 ; i < balancers_ . size ( ) ; + + i ) { <nl> + ports . emplace_back ( balancers_ [ i ] - > port_ ) ; <nl> } <nl> SetNextResolutionForLbChannel ( ports , service_config_json , <nl> lb_channel_response_generator ) ; <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> response_generator_ - > SetReresolutionResponse ( & fake_result ) ; <nl> } <nl> <nl> - const std : : vector < int > GetBackendPorts ( const size_t start_index = 0 ) const { <nl> + const std : : vector < int > GetBackendPorts ( size_t start_index = 0 , <nl> + size_t stop_index = 0 ) const { <nl> + if ( stop_index = = 0 ) stop_index = backends_ . size ( ) ; <nl> std : : vector < int > backend_ports ; <nl> - for ( size_t i = start_index ; i < backend_servers_ . size ( ) ; + + i ) { <nl> - backend_ports . push_back ( backend_servers_ [ i ] . port_ ) ; <nl> + for ( size_t i = start_index ; i < stop_index ; + + i ) { <nl> + backend_ports . push_back ( backends_ [ i ] - > port_ ) ; <nl> } <nl> return backend_ports ; <nl> } <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> void ScheduleResponseForBalancer ( size_t i , <nl> const LoadBalanceResponse & response , <nl> int delay_ms ) { <nl> - balancers_ . at ( i ) - > add_response ( response , delay_ms ) ; <nl> + balancers_ [ i ] - > service_ . add_response ( response , delay_ms ) ; <nl> } <nl> <nl> Status SendRpc ( EchoResponse * response = nullptr , int timeout_ms = 1000 , <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> <nl> template < typename T > <nl> struct ServerThread { <nl> - explicit ServerThread ( const grpc : : string & type , <nl> - const grpc : : string & server_host , T * service ) <nl> - : type_ ( type ) , service_ ( service ) { <nl> + template < typename . . . Args > <nl> + explicit ServerThread ( const grpc : : string & type , Args & & . . . args ) <nl> + : port_ ( grpc_pick_unused_port_or_die ( ) ) , <nl> + type_ ( type ) , <nl> + service_ ( std : : forward < Args > ( args ) . . . ) { } <nl> + <nl> + void Start ( const grpc : : string & server_host ) { <nl> + gpr_log ( GPR_INFO , " starting % s server on port % d " , type_ . c_str ( ) , port_ ) ; <nl> + GPR_ASSERT ( ! running_ ) ; <nl> + running_ = true ; <nl> std : : mutex mu ; <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> - / / by ServerThread : : Start from firing before the wait below is hit . <nl> + / / by ServerThread : : Serve from firing before the wait below is hit . <nl> std : : unique_lock < std : : mutex > lock ( mu ) ; <nl> - port_ = grpc_pick_unused_port_or_die ( ) ; <nl> - gpr_log ( GPR_INFO , " starting % s server on port % d " , type_ . c_str ( ) , port_ ) ; <nl> std : : condition_variable cond ; <nl> thread_ . reset ( new std : : thread ( <nl> - std : : bind ( & ServerThread : : Start , this , server_host , & mu , & cond ) ) ) ; <nl> + std : : bind ( & ServerThread : : Serve , this , server_host , & mu , & cond ) ) ) ; <nl> cond . wait ( lock ) ; <nl> gpr_log ( GPR_INFO , " % s server startup complete " , type_ . c_str ( ) ) ; <nl> } <nl> <nl> - void Start ( const grpc : : string & server_host , std : : mutex * mu , <nl> + void Serve ( const grpc : : string & server_host , std : : mutex * mu , <nl> std : : condition_variable * cond ) { <nl> / / We need to acquire the lock here in order to prevent the notify_one <nl> / / below from firing before its corresponding wait is executed . <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> std : : shared_ptr < ServerCredentials > creds ( new SecureServerCredentials ( <nl> grpc_fake_transport_security_server_credentials_create ( ) ) ) ; <nl> builder . AddListeningPort ( server_address . str ( ) , creds ) ; <nl> - builder . RegisterService ( service_ ) ; <nl> + builder . RegisterService ( & service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> cond - > notify_one ( ) ; <nl> } <nl> <nl> void Shutdown ( ) { <nl> + if ( ! running_ ) return ; <nl> gpr_log ( GPR_INFO , " % s about to shutdown " , type_ . c_str ( ) ) ; <nl> + service_ . Shutdown ( ) ; <nl> server_ - > Shutdown ( grpc_timeout_milliseconds_to_deadline ( 0 ) ) ; <nl> thread_ - > join ( ) ; <nl> gpr_log ( GPR_INFO , " % s shutdown completed " , type_ . c_str ( ) ) ; <nl> + running_ = false ; <nl> } <nl> <nl> - int port_ ; <nl> + const int port_ ; <nl> grpc : : string type_ ; <nl> + T service_ ; <nl> std : : unique_ptr < Server > server_ ; <nl> - T * service_ ; <nl> std : : unique_ptr < std : : thread > thread_ ; <nl> + bool running_ = false ; <nl> } ; <nl> <nl> const grpc : : string server_host_ ; <nl> class XdsEnd2endTest : public : : testing : : Test { <nl> const int client_load_reporting_interval_seconds_ ; <nl> std : : shared_ptr < Channel > channel_ ; <nl> std : : unique_ptr < grpc : : testing : : EchoTestService : : Stub > stub_ ; <nl> - std : : vector < std : : unique_ptr < BackendServiceImpl > > backends_ ; <nl> - std : : vector < std : : unique_ptr < BalancerServiceImpl > > balancers_ ; <nl> - std : : vector < ServerThread < BackendService > > backend_servers_ ; <nl> - std : : vector < ServerThread < BalancerService > > balancer_servers_ ; <nl> + std : : vector < std : : unique_ptr < ServerThread < BackendServiceImpl > > > backends_ ; <nl> + std : : vector < std : : unique_ptr < ServerThread < BalancerServiceImpl > > > balancers_ ; <nl> grpc_core : : RefCountedPtr < grpc_core : : FakeResolverResponseGenerator > <nl> response_generator_ ; <nl> grpc_core : : RefCountedPtr < grpc_core : : FakeResolverResponseGenerator > <nl> TEST_F ( SingleBalancerTest , Vanilla ) { <nl> CheckRpcSendOk ( kNumRpcsPerAddress * num_backends_ ) ; <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> <nl> / / Check LB policy name for the channel . <nl> EXPECT_EQ ( " xds_experimental " , channel_ - > GetLoadBalancingPolicyName ( ) ) ; <nl> TEST_F ( SingleBalancerTest , SameBackendListedMultipleTimes ) { <nl> SetNextResolutionForLbChannelAllBalancers ( ) ; <nl> / / Same backend listed twice . <nl> std : : vector < int > ports ; <nl> - ports . push_back ( backend_servers_ [ 0 ] . port_ ) ; <nl> - ports . push_back ( backend_servers_ [ 0 ] . port_ ) ; <nl> + ports . push_back ( backends_ [ 0 ] - > port_ ) ; <nl> + ports . push_back ( backends_ [ 0 ] - > port_ ) ; <nl> const size_t kNumRpcsPerAddress = 10 ; <nl> ScheduleResponseForBalancer ( <nl> 0 , BalancerServiceImpl : : BuildResponseForBackends ( ports , { } ) , 0 ) ; <nl> TEST_F ( SingleBalancerTest , SameBackendListedMultipleTimes ) { <nl> / / Send kNumRpcsPerAddress RPCs per server . <nl> CheckRpcSendOk ( kNumRpcsPerAddress * ports . size ( ) ) ; <nl> / / Backend should have gotten 20 requests . <nl> - EXPECT_EQ ( kNumRpcsPerAddress * 2 , <nl> - backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress * 2 , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / And they should have come from a single client port , because of <nl> / / subchannel sharing . <nl> - EXPECT_EQ ( 1UL , backends_ [ 0 ] - > clients ( ) . size ( ) ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + EXPECT_EQ ( 1UL , backends_ [ 0 ] - > service_ . clients ( ) . size ( ) ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , SecureNaming ) { <nl> / / TODO ( juanlishen ) : Use separate fake creds for the balancer channel . <nl> ResetStub ( 0 , kApplicationTargetName_ + " ; lb " ) ; <nl> SetNextResolution ( { } , kDefaultServiceConfig_ . c_str ( ) ) ; <nl> - SetNextResolutionForLbChannel ( { balancer_servers_ [ 0 ] . port_ } ) ; <nl> + SetNextResolutionForLbChannel ( { balancers_ [ 0 ] - > port_ } ) ; <nl> const size_t kNumRpcsPerAddress = 100 ; <nl> ScheduleResponseForBalancer ( <nl> 0 , BalancerServiceImpl : : BuildResponseForBackends ( GetBackendPorts ( ) , { } ) , <nl> TEST_F ( SingleBalancerTest , SecureNaming ) { <nl> <nl> / / Each backend should have gotten 100 requests . <nl> for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - EXPECT_EQ ( kNumRpcsPerAddress , <nl> - backend_servers_ [ i ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( kNumRpcsPerAddress , backends_ [ i ] - > service_ . request_count ( ) ) ; <nl> } <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , SecureNamingDeathTest ) { <nl> TEST_F ( SingleBalancerTest , SecureNamingDeathTest ) { <nl> " \ " fake : / / / wrong_lb \ " } } \ n " <nl> " ] \ n " <nl> " } " ) ; <nl> - SetNextResolutionForLbChannel ( { balancer_servers_ [ 0 ] . port_ } ) ; <nl> + SetNextResolutionForLbChannel ( { balancers_ [ 0 ] - > port_ } ) ; <nl> channel_ - > WaitForConnected ( grpc_timeout_seconds_to_deadline ( 1 ) ) ; <nl> } , <nl> " " ) ; <nl> TEST_F ( SingleBalancerTest , InitiallyEmptyServerlist ) { <nl> / / populated serverlist but under the call ' s deadline ( which is enforced by <nl> / / the call ' s deadline ) . <nl> EXPECT_GT ( ellapsed_ms . count ( ) , kServerlistDelayMs ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent two responses . <nl> - EXPECT_EQ ( 2U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 2U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( SingleBalancerTest , AllServersUnreachableFailFast ) { <nl> TEST_F ( SingleBalancerTest , AllServersUnreachableFailFast ) { <nl> const Status status = SendRpc ( ) ; <nl> / / The error shouldn ' t be DEADLINE_EXCEEDED . <nl> EXPECT_EQ ( StatusCode : : UNAVAILABLE , status . error_code ( ) ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> / / The fallback tests are deferred because the fallback mode hasn ' t been <nl> TEST_F ( SingleBalancerTest , BackendsRestart ) { <nl> channel_ - > GetState ( true / * try_to_connect * / ) ; <nl> / / Send kNumRpcsPerAddress RPCs per server . <nl> CheckRpcSendOk ( kNumRpcsPerAddress * num_backends_ ) ; <nl> - balancers_ [ 0 ] - > NotifyDoneWithServerlists ( ) ; <nl> + balancers_ [ 0 ] - > service_ . NotifyDoneWithServerlists ( ) ; <nl> / / The balancer got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - for ( size_t i = 0 ; i < backends_ . size ( ) ; + + i ) { <nl> - if ( backends_ [ i ] - > Shutdown ( ) ) backend_servers_ [ i ] . Shutdown ( ) ; <nl> - } <nl> - CheckRpcSendFailure ( ) ; <nl> - for ( size_t i = 0 ; i < num_backends_ ; + + i ) { <nl> - backends_ . emplace_back ( new BackendServiceImpl ( ) ) ; <nl> - backend_servers_ . emplace_back ( ServerThread < BackendService > ( <nl> - " backend " , server_host_ , backends_ . back ( ) . get ( ) ) ) ; <nl> - } <nl> - / / The following RPC will fail due to the backend ports having changed . It <nl> - / / will nonetheless exercise the xds - roundrobin handling of the RR policy <nl> - / / having gone into shutdown . <nl> - / / TODO ( dgq ) : implement the " backend restart " component as well . We need extra <nl> - / / machinery to either update the LB responses " on the fly " or instruct <nl> - / / backends which ports to restart on . <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + / / Stop backends . RPCs should fail . <nl> + ShutdownAllBackends ( ) ; <nl> CheckRpcSendFailure ( ) ; <nl> + / / Restart all backends . RPCs should start succeeding again . <nl> + StartAllBackends ( ) ; <nl> + CheckRpcSendOk ( 1 / * times * / , 1000 / * timeout_ms * / , <nl> + true / * wait_for_ready * / ) ; <nl> } <nl> <nl> class UpdatesTest : public XdsEnd2endTest { <nl> TEST_F ( UpdatesTest , UpdateBalancersButKeepUsingOriginalBalancer ) { <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 1 = = = = = = = = = = " ) ; <nl> - SetNextResolutionForLbChannel ( { balancer_servers_ [ 1 ] . port_ } ) ; <nl> + SetNextResolutionForLbChannel ( { balancers_ [ 1 ] - > port_ } ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 1 DONE = = = = = = = = = = " ) ; <nl> <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> gpr_timespec deadline = gpr_time_add ( <nl> gpr_now ( GPR_CLOCK_REALTIME ) , gpr_time_from_millis ( 10000 , GPR_TIMESPAN ) ) ; <nl> / / Send 10 seconds worth of RPCs <nl> TEST_F ( UpdatesTest , UpdateBalancersButKeepUsingOriginalBalancer ) { <nl> } while ( gpr_time_cmp ( gpr_now ( GPR_CLOCK_REALTIME ) , deadline ) < 0 ) ; <nl> / / The current LB call is still working , so xds continued using it to the <nl> / / first balancer , which doesn ' t assign the second backend . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( UpdatesTest , UpdateBalancerName ) { <nl> TEST_F ( UpdatesTest , UpdateBalancerName ) { <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> std : : vector < int > ports ; <nl> - ports . emplace_back ( balancer_servers_ [ 1 ] . port_ ) ; <nl> + ports . emplace_back ( balancers_ [ 1 ] - > port_ ) ; <nl> auto new_lb_channel_response_generator = <nl> grpc_core : : MakeRefCounted < grpc_core : : FakeResolverResponseGenerator > ( ) ; <nl> SetNextResolutionForLbChannel ( ports , nullptr , <nl> TEST_F ( UpdatesTest , UpdateBalancerName ) { <nl> <nl> / / Wait until update has been processed , as signaled by the second backend <nl> / / receiving a request . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> WaitForBackend ( 1 ) ; <nl> <nl> - backend_servers_ [ 1 ] . service_ - > ResetCounters ( ) ; <nl> + backends_ [ 1 ] - > service_ . ResetCounters ( ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = BEFORE SECOND BATCH = = = = = = = = = = " ) ; <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH SECOND BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the second backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> / / Send an update with the same set of LBs as the one in SetUp ( ) in order to <nl> TEST_F ( UpdatesTest , UpdateBalancersRepeated ) { <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> std : : vector < int > ports ; <nl> - ports . emplace_back ( balancer_servers_ [ 0 ] . port_ ) ; <nl> - ports . emplace_back ( balancer_servers_ [ 1 ] . port_ ) ; <nl> - ports . emplace_back ( balancer_servers_ [ 2 ] . port_ ) ; <nl> + ports . emplace_back ( balancers_ [ 0 ] - > port_ ) ; <nl> + ports . emplace_back ( balancers_ [ 1 ] - > port_ ) ; <nl> + ports . emplace_back ( balancers_ [ 2 ] - > port_ ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 1 = = = = = = = = = = " ) ; <nl> SetNextResolutionForLbChannel ( ports ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 1 DONE = = = = = = = = = = " ) ; <nl> <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> gpr_timespec deadline = gpr_time_add ( <nl> gpr_now ( GPR_CLOCK_REALTIME ) , gpr_time_from_millis ( 10000 , GPR_TIMESPAN ) ) ; <nl> / / Send 10 seconds worth of RPCs <nl> TEST_F ( UpdatesTest , UpdateBalancersRepeated ) { <nl> } while ( gpr_time_cmp ( gpr_now ( GPR_CLOCK_REALTIME ) , deadline ) < 0 ) ; <nl> / / xds continued using the original LB call to the first balancer , which <nl> / / doesn ' t assign the second backend . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> <nl> ports . clear ( ) ; <nl> - ports . emplace_back ( balancer_servers_ [ 0 ] . port_ ) ; <nl> - ports . emplace_back ( balancer_servers_ [ 1 ] . port_ ) ; <nl> + ports . emplace_back ( balancers_ [ 0 ] - > port_ ) ; <nl> + ports . emplace_back ( balancers_ [ 1 ] - > port_ ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 2 = = = = = = = = = = " ) ; <nl> SetNextResolutionForLbChannel ( ports ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 2 DONE = = = = = = = = = = " ) ; <nl> <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> deadline = gpr_time_add ( gpr_now ( GPR_CLOCK_REALTIME ) , <nl> gpr_time_from_millis ( 10000 , GPR_TIMESPAN ) ) ; <nl> / / Send 10 seconds worth of RPCs <nl> TEST_F ( UpdatesTest , UpdateBalancersRepeated ) { <nl> } while ( gpr_time_cmp ( gpr_now ( GPR_CLOCK_REALTIME ) , deadline ) < 0 ) ; <nl> / / xds continued using the original LB call to the first balancer , which <nl> / / doesn ' t assign the second backend . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> } <nl> <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> SetNextResolution ( { } , kDefaultServiceConfig_ . c_str ( ) ) ; <nl> - SetNextResolutionForLbChannel ( { balancer_servers_ [ 0 ] . port_ } ) ; <nl> + SetNextResolutionForLbChannel ( { balancers_ [ 0 ] - > port_ } ) ; <nl> const std : : vector < int > first_backend { GetBackendPorts ( ) [ 0 ] } ; <nl> const std : : vector < int > second_backend { GetBackendPorts ( ) [ 1 ] } ; <nl> <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH FIRST BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the first backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Kill balancer 0 <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * ABOUT TO KILL BALANCER 0 * * * * * * * * * * * * * " ) ; <nl> - if ( balancers_ [ 0 ] - > Shutdown ( ) ) balancer_servers_ [ 0 ] . Shutdown ( ) ; <nl> + balancers_ [ 0 ] - > Shutdown ( ) ; <nl> gpr_log ( GPR_INFO , " * * * * * * * * * * KILLED BALANCER 0 * * * * * * * * * * * * * " ) ; <nl> <nl> / / This is serviced by the existing child policy . <nl> TEST_F ( UpdatesTest , UpdateBalancersDeadUpdate ) { <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH SECOND BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should again have gone to the first backend . <nl> - EXPECT_EQ ( 20U , backend_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 20U , backends_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> <nl> / / Balancer 0 got a single request . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> / / and sent a single response . <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 1 ] . service_ - > response_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 1 ] - > service_ . response_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> <nl> gpr_log ( GPR_INFO , " = = = = = = = = = ABOUT TO UPDATE 1 = = = = = = = = = = " ) ; <nl> - SetNextResolutionForLbChannel ( { balancer_servers_ [ 1 ] . port_ } ) ; <nl> + SetNextResolutionForLbChannel ( { balancers_ [ 1 ] - > port_ } ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = UPDATE 1 DONE = = = = = = = = = = " ) ; <nl> <nl> / / Wait until update has been processed , as signaled by the second backend <nl> / / receiving a request . In the meantime , the client continues to be serviced <nl> / / ( by the first backend ) without interruption . <nl> - EXPECT_EQ ( 0U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> WaitForBackend ( 1 ) ; <nl> <nl> / / This is serviced by the updated RR policy <nl> - backend_servers_ [ 1 ] . service_ - > ResetCounters ( ) ; <nl> + backends_ [ 1 ] - > service_ . ResetCounters ( ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = BEFORE THIRD BATCH = = = = = = = = = = " ) ; <nl> CheckRpcSendOk ( 10 ) ; <nl> gpr_log ( GPR_INFO , " = = = = = = = = = DONE WITH THIRD BATCH = = = = = = = = = = " ) ; <nl> / / All 10 requests should have gone to the second backend . <nl> - EXPECT_EQ ( 10U , backend_servers_ [ 1 ] . service_ - > request_count ( ) ) ; <nl> + EXPECT_EQ ( 10U , backends_ [ 1 ] - > service_ . request_count ( ) ) ; <nl> <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 1U , balancer_servers_ [ 0 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 1U , balancers_ [ 0 ] - > service_ . response_count ( ) ) ; <nl> / / The second balancer , published as part of the first update , may end up <nl> / / getting two requests ( that is , 1 < = # req < = 2 ) if the LB call retry timer <nl> / / firing races with the arrival of the update containing the second <nl> / / balancer . <nl> - EXPECT_GE ( balancer_servers_ [ 1 ] . service_ - > request_count ( ) , 1U ) ; <nl> - EXPECT_GE ( balancer_servers_ [ 1 ] . service_ - > response_count ( ) , 1U ) ; <nl> - EXPECT_LE ( balancer_servers_ [ 1 ] . service_ - > request_count ( ) , 2U ) ; <nl> - EXPECT_LE ( balancer_servers_ [ 1 ] . service_ - > response_count ( ) , 2U ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > request_count ( ) ) ; <nl> - EXPECT_EQ ( 0U , balancer_servers_ [ 2 ] . service_ - > response_count ( ) ) ; <nl> + EXPECT_GE ( balancers_ [ 1 ] - > service_ . request_count ( ) , 1U ) ; <nl> + EXPECT_GE ( balancers_ [ 1 ] - > service_ . response_count ( ) , 1U ) ; <nl> + EXPECT_LE ( balancers_ [ 1 ] - > service_ . request_count ( ) , 2U ) ; <nl> + EXPECT_LE ( balancers_ [ 1 ] - > service_ . response_count ( ) , 2U ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . request_count ( ) ) ; <nl> + EXPECT_EQ ( 0U , balancers_ [ 2 ] - > service_ . response_count ( ) ) ; <nl> } <nl> <nl> / / The re - resolution tests are deferred because they rely on the fallback mode , <nl> class SingleBalancerWithClientLoadReportingTest : public XdsEnd2endTest { <nl> <nl> / / TODO ( vpowar ) : Add TEST_F ( SingleBalancerWithClientLoadReportingTest , Vanilla ) <nl> <nl> + / / TODO ( roth ) : Add TEST_F ( SingleBalancerWithClientLoadReportingTest , <nl> + / / BalancerRestart ) <nl> + <nl> / / TODO ( roth ) : Add TEST_F ( SingleBalancerWithClientLoadReportingTest , Drop ) <nl> <nl> } / / namespace <nl>
Merge pull request from markdroth / grpclb_test_improvement
grpc/grpc
55d8238b0e5348f282941163d41ada90302ea364
2019-03-15T22:23:44Z
mmm a / src / stub - cache . cc <nl> ppp b / src / stub - cache . cc <nl> Object * CallStubCompiler : : GetCode ( PropertyType type , String * name ) { <nl> <nl> Object * ConstructStubCompiler : : GetCode ( ) { <nl> Code : : Flags flags = Code : : ComputeFlags ( Code : : STUB ) ; <nl> - return GetCodeWithFlags ( flags , " ConstructStub " ) ; <nl> + Object * result = GetCodeWithFlags ( flags , " ConstructStub " ) ; <nl> + if ( ! result - > IsFailure ( ) ) { <nl> + Code * code = Code : : cast ( result ) ; <nl> + USE ( code ) ; <nl> + LOG ( CodeCreateEvent ( Logger : : STUB_TAG , code , " ConstructStub " ) ) ; <nl> + } <nl> + return result ; <nl> } <nl> <nl> <nl> - <nl> } } / / namespace v8 : : internal <nl>
Add code creation logging for construct stubs .
v8/v8
4339205dd26d1d450d496e1afc458be0b0c72511
2009-09-02T06:55:49Z
mmm a / contrib / Python / cntk / graph . py <nl> ppp b / contrib / Python / cntk / graph . py <nl> <nl> from abc import ABCMeta , abstractmethod <nl> import numpy as np <nl> - import scipy . sparse as sparse <nl> + <nl> + # Workaround until we have switched to Anaconde with scipy support <nl> + # import scipy . sparse as sparse <nl> + class sparse ( object ) : <nl> + @ staticmethod <nl> + def issparse ( obj ) : <nl> + return hasattr ( obj , ' todense ' ) <nl> <nl> from . utils import MODEL_INDENTATION <nl> <nl>
Remove temporarily the dependency on scipy . sparse
microsoft/CNTK
285c65466468945a1f87b2f5f2f77be021930901
2016-03-30T08:14:58Z
mmm a / contrib / debian / examples / bitcoin . conf <nl> ppp b / contrib / debian / examples / bitcoin . conf <nl> <nl> # rpcuser = Ulysseys <nl> # rpcpassword = YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593 <nl> # <nl> - # The second method ` rpcauth ` can be added to server startup argument . It is set at intialization time <nl> + # The second method ` rpcauth ` can be added to server startup argument . It is set at initialization time <nl> # using the output from the script in share / rpcuser / rpcuser . py after providing a username : <nl> # <nl> # . / share / rpcuser / rpcuser . py alice <nl> mmm a / doc / developer - notes . md <nl> ppp b / doc / developer - notes . md <nl> Developer Notes <nl> Various coding styles have been used during the history of the codebase , <nl> and the result is not very consistent . However , we ' re now trying to converge to <nl> a single style , which is specified below . When writing patches , favor the new <nl> - style over attempting to mimick the surrounding style , except for move - only <nl> + style over attempting to mimic the surrounding style , except for move - only <nl> commits . <nl> <nl> Do not submit patches solely to modify the style of existing code . <nl> mmm a / src / httpserver . cpp <nl> ppp b / src / httpserver . cpp <nl> bool InitHTTPServer ( ) <nl> LogPrintf ( " HTTP : creating work queue of depth % d \ n " , workQueueDepth ) ; <nl> <nl> workQueue = new WorkQueue < HTTPClosure > ( workQueueDepth ) ; <nl> - / / tranfer ownership to eventBase / HTTP via . release ( ) <nl> + / / transfer ownership to eventBase / HTTP via . release ( ) <nl> eventBase = base_ctr . release ( ) ; <nl> eventHTTP = http_ctr . release ( ) ; <nl> return true ; <nl> mmm a / src / qt / networkstyle . cpp <nl> ppp b / src / qt / networkstyle . cpp <nl> NetworkStyle : : NetworkStyle ( const QString & _appName , const int iconColorHueShift , <nl> / / loop through pixels <nl> for ( int x = 0 ; x < img . width ( ) ; x + + ) <nl> { <nl> - / / preserve alpha because QColor : : getHsl doesen ' t return the alpha value <nl> + / / preserve alpha because QColor : : getHsl doesn ' t return the alpha value <nl> a = qAlpha ( scL [ x ] ) ; <nl> QColor col ( scL [ x ] ) ; <nl> <nl> mmm a / src / qt / test / rpcnestedtests . cpp <nl> ppp b / src / qt / test / rpcnestedtests . cpp <nl> void RPCNestedTests : : rpcNestedTests ( ) <nl> RPCConsole : : RPCExecuteCommandLine ( result , " getblockchaininfo " ) ; / / whitespace at the end will be tolerated <nl> QVERIFY ( result . substr ( 0 , 1 ) = = " { " ) ; <nl> <nl> - ( RPCConsole : : RPCExecuteCommandLine ( result , " getblockchaininfo ( ) [ \ " chain \ " ] " ) ) ; / / Quote path identifier are allowed , but look after a child contaning the quotes in the key <nl> + ( RPCConsole : : RPCExecuteCommandLine ( result , " getblockchaininfo ( ) [ \ " chain \ " ] " ) ) ; / / Quote path identifier are allowed , but look after a child containing the quotes in the key <nl> QVERIFY ( result = = " null " ) ; <nl> <nl> ( RPCConsole : : RPCExecuteCommandLine ( result , " createrawtransaction [ ] { } 0 " ) ) ; / / parameter not in brackets are allowed <nl> mmm a / src / qt / test / test_main . cpp <nl> ppp b / src / qt / test / test_main . cpp <nl> int main ( int argc , char * argv [ ] ) <nl> bool fInvalid = false ; <nl> <nl> / / Prefer the " minimal " platform for the test instead of the normal default <nl> - / / platform ( " xcb " , " windows " , or " cocoa " ) so tests can ' t unintentially <nl> + / / platform ( " xcb " , " windows " , or " cocoa " ) so tests can ' t unintentionally <nl> / / interfere with any background GUIs and don ' t require extra resources . <nl> setenv ( " QT_QPA_PLATFORM " , " minimal " , 0 ) ; <nl> <nl> mmm a / src / test / blockencodings_tests . cpp <nl> ppp b / src / test / blockencodings_tests . cpp <nl> static CBlock BuildBlockTestCase ( ) { <nl> return block ; <nl> } <nl> <nl> - / / Number of shared use_counts we expect for a tx we havent touched <nl> + / / Number of shared use_counts we expect for a tx we haven ' t touched <nl> / / = = 2 ( mempool + our copy from the GetSharedTx call ) <nl> # define SHARED_TX_OFFSET 2 <nl> <nl> mmm a / src / test / coins_tests . cpp <nl> ppp b / src / test / coins_tests . cpp <nl> UtxoData : : iterator FindRandomFrom ( const std : : set < COutPoint > & utxoSet ) { <nl> / / except the emphasis is on testing the functionality of UpdateCoins <nl> / / random txs are created and UpdateCoins is used to update the cache stack <nl> / / In particular it is tested that spending a duplicate coinbase tx <nl> - / / has the expected effect ( the other duplicate is overwitten at all cache levels ) <nl> + / / has the expected effect ( the other duplicate is overwritten at all cache levels ) <nl> BOOST_AUTO_TEST_CASE ( updatecoins_simulation_test ) <nl> { <nl> bool spent_a_duplicate_coinbase = false ; <nl> mmm a / src / test / data / tx_invalid . json <nl> ppp b / src / test / data / tx_invalid . json <nl> <nl> [ [ [ " 0000000000000000000000000000000000000000000000000000000000000100 " , 0 , " 4259839 CHECKSEQUENCEVERIFY 1 " ] ] , <nl> " 020000000100010000000000000000000000000000000000000000000000000000000000000000000000feff40000100000000000000000000000000 " , " P2SH , CHECKSEQUENCEVERIFY " ] , <nl> <nl> - [ " By - time locks , with argument just beyond txin . nSequence ( but within numerical boundries ) " ] , <nl> + [ " By - time locks , with argument just beyond txin . nSequence ( but within numerical boundaries ) " ] , <nl> [ [ [ " 0000000000000000000000000000000000000000000000000000000000000100 " , 0 , " 4194305 CHECKSEQUENCEVERIFY 1 " ] ] , <nl> " 020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000 " , " P2SH , CHECKSEQUENCEVERIFY " ] , <nl> [ [ [ " 0000000000000000000000000000000000000000000000000000000000000100 " , 0 , " 4259839 CHECKSEQUENCEVERIFY 1 " ] ] , <nl> mmm a / test / functional / bumpfee . py <nl> ppp b / test / functional / bumpfee . py <nl> def test_simple_bumpfee_succeeds ( rbf_node , peer_node , dest_address ) : <nl> bumped_tx = rbf_node . bumpfee ( rbfid ) <nl> assert_equal ( bumped_tx [ " errors " ] , [ ] ) <nl> assert bumped_tx [ " fee " ] - abs ( rbftx [ " fee " ] ) > 0 <nl> - # check that bumped_tx propogates , original tx was evicted and has a wallet conflict <nl> + # check that bumped_tx propagates , original tx was evicted and has a wallet conflict <nl> sync_mempools ( ( rbf_node , peer_node ) ) <nl> assert bumped_tx [ " txid " ] in rbf_node . getrawmempool ( ) <nl> assert bumped_tx [ " txid " ] in peer_node . getrawmempool ( ) <nl> mmm a / test / functional / example_test . py <nl> ppp b / test / functional / example_test . py <nl> def run_test ( self ) : <nl> node2 . add_connection ( connections [ 1 ] ) <nl> node2 . wait_for_verack ( ) <nl> <nl> - self . log . info ( " Wait for node2 reach current tip . Test that it has propogated all the blocks to us " ) <nl> + self . log . info ( " Wait for node2 reach current tip . Test that it has propagated all the blocks to us " ) <nl> <nl> for block in blocks : <nl> getdata_request = msg_getdata ( ) <nl> mmm a / test / functional / net . py <nl> ppp b / test / functional / net . py <nl> def _test_getaddednodeinfo ( self ) : <nl> added_nodes = self . nodes [ 0 ] . getaddednodeinfo ( ip_port ) <nl> assert_equal ( len ( added_nodes ) , 1 ) <nl> assert_equal ( added_nodes [ 0 ] [ ' addednode ' ] , ip_port ) <nl> - # check that a non - existant node returns an error <nl> + # check that a non - existent node returns an error <nl> assert_raises_jsonrpc ( - 24 , " Node has not been added " , <nl> self . nodes [ 0 ] . getaddednodeinfo , ' 1 . 1 . 1 . 1 ' ) <nl> <nl> mmm a / test / functional / pruning . py <nl> ppp b / test / functional / pruning . py <nl> def reorg_test ( self ) : <nl> self . log . info ( " Invalidating block % s at height % d " % ( badhash , invalidheight ) ) <nl> self . nodes [ 1 ] . invalidateblock ( badhash ) <nl> <nl> - # We ' ve now switched to our previously mined - 24 block fork on node 1 , but thats not what we want <nl> + # We ' ve now switched to our previously mined - 24 block fork on node 1 , but that ' s not what we want <nl> # So invalidate that fork as well , until we ' re on the same chain as node 0 / 2 ( but at an ancestor 288 blocks ago ) <nl> mainchainhash = self . nodes [ 0 ] . getblockhash ( invalidheight - 1 ) <nl> curhash = self . nodes [ 1 ] . getblockhash ( invalidheight - 1 ) <nl> def reorg_back ( self ) : <nl> goalbesthash = self . mainchainhash2 <nl> <nl> # As of 0 . 10 the current block download logic is not able to reorg to the original chain created in <nl> - # create_chain_with_stale_blocks because it doesn ' t know of any peer thats on that chain from which to <nl> + # create_chain_with_stale_blocks because it doesn ' t know of any peer that ' s on that chain from which to <nl> # redownload its missing blocks . <nl> # Invalidate the reorg_test chain in node 0 as well , it can successfully switch to the original chain <nl> # because it has all the block data . <nl> mmm a / test / functional / test_runner . py <nl> ppp b / test / functional / test_runner . py <nl> def main ( ) : <nl> Help text and arguments for individual test script : ' ' ' , <nl> formatter_class = argparse . RawTextHelpFormatter ) <nl> parser . add_argument ( ' - - coverage ' , action = ' store_true ' , help = ' generate a basic coverage report for the RPC interface ' ) <nl> - parser . add_argument ( ' - - exclude ' , ' - x ' , help = ' specify a comma - seperated - list of scripts to exclude . ' ) <nl> + parser . add_argument ( ' - - exclude ' , ' - x ' , help = ' specify a comma - separated - list of scripts to exclude . ' ) <nl> parser . add_argument ( ' - - extended ' , action = ' store_true ' , help = ' run the extended test suite in addition to the basic tests ' ) <nl> parser . add_argument ( ' - - force ' , ' - f ' , action = ' store_true ' , help = ' run tests even on platforms where they are disabled by default ( e . g . windows ) . ' ) <nl> parser . add_argument ( ' - - help ' , ' - h ' , ' - ? ' , action = ' store_true ' , help = ' print help text and exit ' ) <nl>
doc : spelling fixes
bitcoin/bitcoin
f42fc1d508f24447519f79cf6304b2e4e2233a51
2017-08-15T22:24:39Z
mmm a / CHANGELOG . md <nl> ppp b / CHANGELOG . md <nl> <nl> # # ClickHouse release 18 . 14 . 14 , 2018 - 11 - 20 <nl> <nl> # # # Bug fixes : <nl> - * Fixed ` ON CLUSTER ` queries when cluster configured as secure ( flag ` < secure > ` ) . [ # 3599 ] <nl> + * Fixed ` ON CLUSTER ` queries when cluster configured as secure ( flag ` < secure > ` ) . [ # 3599 ] ( https : / / github . com / yandex / ClickHouse / pull / 3599 ) <nl> <nl> # # # Build changes : <nl> - * Fixed problems ( llvm - 7 from system , macos ) [ # 3582 ] <nl> + * Fixed problems ( llvm - 7 from system , macos ) [ # 3582 ] ( https : / / github . com / yandex / ClickHouse / pull / 3582 ) <nl> <nl> # # ClickHouse release 18 . 14 . 11 , 2018 - 10 - 29 <nl> <nl> mmm a / CHANGELOG_RU . md <nl> ppp b / CHANGELOG_RU . md <nl> <nl> # # ClickHouse release 18 . 14 . 14 , 2018 - 11 - 20 <nl> <nl> # # # Исправления ошибок : <nl> - * Исправлена работа запросов ` ON CLUSTER ` в случае , когда в конфигурации кластера включено шифрование ( флаг ` < secure > ` ) . [ # 3599 ] <nl> + * Исправлена работа запросов ` ON CLUSTER ` в случае , когда в конфигурации кластера включено шифрование ( флаг ` < secure > ` ) . [ # 3599 ] ( https : / / github . com / yandex / ClickHouse / pull / 3599 ) <nl> <nl> # # # Улучшения процесса сборки ClickHouse : <nl> - * Испрпавлены проблемы сборки ( llvm - 7 из системы , macos ) [ # 3582 ] <nl> + * Испрпавлены проблемы сборки ( llvm - 7 из системы , macos ) [ # 3582 ] ( https : / / github . com / yandex / ClickHouse / pull / 3582 ) <nl> <nl> # # ClickHouse release 18 . 14 . 13 , 2018 - 11 - 08 <nl> <nl>
Fix links in CHANGELOG . md
ClickHouse/ClickHouse
ed35e7cdbb56585625082cd442d2e65bb36a2de9
2018-11-21T21:11:11Z
mmm a / scene / 2d / line_2d . cpp <nl> ppp b / scene / 2d / line_2d . cpp <nl> void Line2D : : set_point_position ( int i , Vector2 pos ) { <nl> } <nl> <nl> Vector2 Line2D : : get_point_position ( int i ) const { <nl> + ERR_FAIL_INDEX_V ( i , _points . size ( ) , Vector2 ( ) ) <nl> return _points . get ( i ) ; <nl> } <nl> <nl>
Fix 2D Line crash
godotengine/godot
2621131549164d0a6107d7c957a792c1707d6ce4
2019-06-06T19:09:37Z
mmm a / cocos / base / CCMap . h <nl> ppp b / cocos / base / CCMap . h <nl> class CC_DLL Map <nl> const_iterator cbegin ( ) const { return _data . cbegin ( ) ; } <nl> const_iterator cend ( ) const { return _data . cend ( ) ; } <nl> <nl> + / * * Default constructor * / <nl> Map < K , V > ( ) <nl> : _data ( ) <nl> { <nl> CCLOGINFO ( " In the default constructor of Map ! " ) ; <nl> } <nl> <nl> + / * * Contructor with capacity * / <nl> explicit Map < K , V > ( int capacity ) <nl> : _data ( ) <nl> { <nl> class CC_DLL Map <nl> _data . reserve ( capacity ) ; <nl> } <nl> <nl> + / * * Copy constructor * / <nl> Map < K , V > ( const Map < K , V > & other ) <nl> { <nl> CCLOGINFO ( " In the copy constructor of Map ! " ) ; <nl> class CC_DLL Map <nl> addRefForAllObjects ( ) ; <nl> } <nl> <nl> + / * * Move constructor * / <nl> Map < K , V > ( Map < K , V > & & other ) <nl> { <nl> CCLOGINFO ( " In the move constructor of Map ! " ) ; <nl> _data = std : : move ( other . _data ) ; <nl> } <nl> <nl> + / * * Destructor <nl> + * It will release all objects in map . <nl> + * / <nl> ~ Map < K , V > ( ) <nl> { <nl> CCLOGINFO ( " In the destructor of Map ! " ) ; <nl> clear ( ) ; <nl> } <nl> <nl> - / * * Sets capacity of current array * / <nl> + / * * Sets capacity of the map * / <nl> void reserve ( int capacity ) <nl> { <nl> _data . reserve ( capacity ) ; <nl> } <nl> <nl> - / * * Returns capacity of the array * / <nl> + / * * Returns capacity of the map * / <nl> size_t capacity ( ) const <nl> { <nl> return _data . capacity ( ) ; <nl> } <nl> <nl> + / * * The number of elements in the map . * / <nl> size_t size ( ) const <nl> { <nl> return _data . size ( ) ; <nl> } <nl> <nl> + / * * Returns a bool value indicating whether the map container is empty , i . e . whether its size is 0 . <nl> + * @ note This function does not modify the content of the container in any way . <nl> + * To clear the content of an array object , member function unordered_map : : clear exists . <nl> + * / <nl> bool empty ( ) const <nl> { <nl> return _data . empty ( ) ; <nl> } <nl> <nl> + / * * Returns all keys in the map * / <nl> std : : vector < K > keys ( ) const <nl> { <nl> std : : vector < K > keys ; <nl> class CC_DLL Map <nl> return keys ; <nl> } <nl> <nl> + / * * Returns all keys that matches the object * / <nl> std : : vector < K > keys ( V object ) const <nl> { <nl> std : : vector < K > keys ; <nl> class CC_DLL Map <nl> return keys ; <nl> } <nl> <nl> + / * * @ brief Returns a reference to the mapped value of the element with key k in the map . <nl> + * @ note If key does not match the key of any element in the container , the function return nullptr . <nl> + * @ param key Key value of the element whose mapped value is accessed . <nl> + * Member type K is the keys for the elements in the container . defined in Map < K , V > as an alias of its first template parameter ( Key ) . <nl> + * / <nl> const V at ( const K & key ) const <nl> { <nl> auto iter = _data . find ( key ) ; <nl> class CC_DLL Map <nl> return nullptr ; <nl> } <nl> <nl> + / * * @ brief Searches the container for an element with ' key ' as key and returns an iterator to it if found , <nl> + * otherwise it returns an iterator to Map < K , V > : : end ( the element past the end of the container ) . <nl> + * @ param key Key to be searched for . <nl> + * Member type ' K ' is the type of the keys for the elements in the container , <nl> + * defined in Map < K , V > as an alias of its first template parameter ( Key ) . <nl> + * <nl> + * / <nl> const_iterator find ( const K & key ) const <nl> { <nl> return _data . find ( key ) ; <nl> class CC_DLL Map <nl> return _data . find ( key ) ; <nl> } <nl> <nl> + / * * @ brief Inserts new elements in the map . <nl> + * @ note If the container has already contained the key , this function will erase the old pair ( key , object ) and insert the new pair . <nl> + * @ param key The key to be inserted . <nl> + * @ param object The object to be inserted . <nl> + * / <nl> void insert ( const K & key , V object ) <nl> { <nl> CCASSERT ( object ! = nullptr , " Object is nullptr ! " ) ; <nl> class CC_DLL Map <nl> object - > retain ( ) ; <nl> } <nl> <nl> + / * * @ brief Removes an element with an iterator from the Map < K , V > container . <nl> + * @ param position Iterator pointing to a single element to be removed from the Map < K , V > . <nl> + * Member type const_iterator is a forward iterator type . <nl> + * / <nl> iterator erase ( const_iterator position ) <nl> { <nl> + CCASSERT ( position > = _data . begin ( ) & & position < _data . end ( ) , " " ) ; <nl> + position - > second - > release ( ) ; <nl> return _data . erase ( position ) ; <nl> } <nl> <nl> + / * * @ brief Removes an element with an iterator from the Map < K , V > container . <nl> + * @ param k Key of the element to be erased . <nl> + * Member type ' K ' is the type of the keys for the elements in the container , <nl> + * defined in Map < K , V > as an alias of its first template parameter ( Key ) . <nl> + * / <nl> size_t erase ( const K & k ) <nl> { <nl> auto iter = _data . find ( k ) ; <nl> class CC_DLL Map <nl> return 0 ; <nl> } <nl> <nl> + / * * @ brief Removes some elements with a vector which contains keys in the map . <nl> + * @ param keys Keys of elements to be erased . <nl> + * / <nl> void erase ( const std : : vector < K > & keys ) <nl> { <nl> std : : for_each ( keys . cbegin ( ) , keys . cend ( ) , [ this ] ( const K & key ) { <nl> class CC_DLL Map <nl> } ) ; <nl> } <nl> <nl> + / * * All the elements in the Map < K , V > container are dropped : <nl> + * their reference count will be decreased , and they are removed from the container , <nl> + * leaving it with a size of 0 . Al <nl> + * / <nl> void clear ( ) <nl> { <nl> for ( auto iter = _data . cbegin ( ) ; iter ! = _data . cend ( ) ; + + iter ) <nl> class CC_DLL Map <nl> _data . clear ( ) ; <nl> } <nl> <nl> + / * * @ brief Gets a random object in the map <nl> + * @ return Returns the random object if the map isn ' t empty , otherwise it returns nullptr . <nl> + * / <nl> V getRandomObject ( ) const <nl> { <nl> if ( ! _data . empty ( ) ) <nl> class CC_DLL Map <nl> / / return _data . at ( key ) ; <nl> / / } <nl> <nl> + / * * Copy assignment operator * / <nl> Map < K , V > & operator = ( const Map < K , V > & other ) <nl> { <nl> CCLOGINFO ( " In the copy assignment operator of Map ! " ) ; <nl> class CC_DLL Map <nl> return * this ; <nl> } <nl> <nl> + / * * Move assignment operator * / <nl> Map < K , V > & operator = ( Map < K , V > & & other ) <nl> { <nl> CCLOGINFO ( " In the move assignment operator of Map ! " ) ; <nl> class CC_DLL Map <nl> <nl> protected : <nl> <nl> + / * * Retains all the objects in the map * / <nl> void addRefForAllObjects ( ) <nl> { <nl> for ( auto iter = _data . begin ( ) ; iter ! = _data . end ( ) ; + + iter ) <nl>
issue : Updates comments for Map < K , V > container .
cocos2d/cocos2d-x
6264336809a2cb630af74a42dbb094421de80dea
2013-12-12T03:54:03Z
mmm a / doc / user - docs / ThirdPartyToolProfiles . md <nl> ppp b / doc / user - docs / ThirdPartyToolProfiles . md <nl> Assuming that you ' ve installed Git Bash into ` C : / Program Files / Git ` : <nl> } <nl> ` ` ` ` <nl> <nl> + # # MSYS2 <nl> + <nl> + Assuming that you ' ve installed MSYS2 into ` C : / msys64 ` : <nl> + <nl> + ` ` ` json <nl> + { <nl> + " name " : " MSYS2 " , <nl> + " commandline " : " C : / msys64 / msys2_shell . cmd - defterm - no - start - mingw64 " , <nl> + " icon " : " C : / msys64 / msys2 . ico " , <nl> + " startingDirectory " : " C : / msys64 / home / user " <nl> + } <nl> + ` ` ` ` <nl> + <nl> < ! - - Adding a tool here ? Make sure to add it in alphabetical order ! - - > <nl>
doc : add MSYS2 profile to ThirdPartyToolProfiles . md ( )
microsoft/terminal
03f805cc0ab6d5a3ef21c68180a199267b4c5e22
2020-03-23T17:30:52Z
mmm a / PythonClient / PythonClient . pyproj <nl> ppp b / PythonClient / PythonClient . pyproj <nl> <nl> < SchemaVersion > 2 . 0 < / SchemaVersion > <nl> < ProjectGuid > e2049e20 - b6dd - 474e - 8bca - 1c8dc54725aa < / ProjectGuid > <nl> < ProjectHome > . < / ProjectHome > <nl> - < StartupFile > car \ hello_car . py < / StartupFile > <nl> + < StartupFile > car \ multi_agent_car . py < / StartupFile > <nl> < SearchPath > <nl> < / SearchPath > <nl> < WorkingDirectory > . < / WorkingDirectory > <nl> <nl> < Compile Include = " car \ legacy_hello_car . py " > <nl> < SubType > Code < / SubType > <nl> < / Compile > <nl> + < Compile Include = " car \ multi_agent_car . py " > <nl> + < SubType > Code < / SubType > <nl> + < / Compile > <nl> < Compile Include = " car \ setup_path . py " > <nl> < SubType > Code < / SubType > <nl> < / Compile > <nl> new file mode 100644 <nl> index 000000000 . . f0c7689c9 <nl> mmm / dev / null <nl> ppp b / PythonClient / car / multi_agent_car . py <nl> <nl> + import setup_path <nl> + import airsim <nl> + <nl> + import time <nl> + import os <nl> + import numpy as np <nl> + <nl> + # connect to the AirSim simulator <nl> + client = airsim . CarClient ( ) <nl> + client . confirmConnection ( ) <nl> + client . enableApiControl ( True , " Car1 " ) <nl> + client . enableApiControl ( True , " Car2 " ) <nl> + <nl> + car_controls1 = airsim . CarControls ( ) <nl> + car_controls2 = airsim . CarControls ( ) <nl> + <nl> + <nl> + for idx in range ( 3 ) : <nl> + # get state of the car <nl> + car_state1 = client . getCarState ( " Car1 " ) <nl> + print ( " Car1 : Speed % d , Gear % d " % ( car_state1 . speed , car_state1 . gear ) ) <nl> + car_state2 = client . getCarState ( " Car2 " ) <nl> + print ( " Car1 : Speed % d , Gear % d " % ( car_state2 . speed , car_state2 . gear ) ) <nl> + <nl> + # go forward <nl> + car_controls1 . throttle = 0 . 5 <nl> + car_controls1 . steering = 0 . 5 <nl> + client . setCarControls ( car_controls1 , " Car1 " ) <nl> + print ( " Car1 : Go Forward " ) <nl> + <nl> + car_controls2 . throttle = 0 . 5 <nl> + car_controls2 . steering = - 0 . 5 <nl> + client . setCarControls ( car_controls2 , " Car2 " ) <nl> + print ( " Car2 : Go Forward " ) <nl> + time . sleep ( 3 ) # let car drive a bit <nl> + <nl> + <nl> + # go reverse <nl> + car_controls1 . throttle = - 0 . 5 <nl> + car_controls1 . is_manual_gear = True ; <nl> + car_controls1 . manual_gear = - 1 <nl> + car_controls1 . steering = - 0 . 5 <nl> + client . setCarControls ( car_controls1 , " Car1 " ) <nl> + print ( " Car1 : Go reverse , steer right " ) <nl> + car_controls1 . is_manual_gear = False ; # change back gear to auto <nl> + car_controls1 . manual_gear = 0 <nl> + <nl> + car_controls2 . throttle = - 0 . 5 <nl> + car_controls2 . is_manual_gear = True ; <nl> + car_controls2 . manual_gear = - 1 <nl> + car_controls2 . steering = 0 . 5 <nl> + client . setCarControls ( car_controls2 , " Car2 " ) <nl> + print ( " Car2 : Go reverse , steer right " ) <nl> + car_controls2 . is_manual_gear = False ; # change back gear to auto <nl> + car_controls2 . manual_gear = 0 <nl> + time . sleep ( 3 ) # let car drive a bit <nl> + <nl> + <nl> + # apply breaks <nl> + car_controls1 . brake = 1 <nl> + client . setCarControls ( car_controls1 , " Car1 " ) <nl> + print ( " Car1 : Apply break " ) <nl> + car_controls1 . brake = 0 # remove break <nl> + <nl> + car_controls2 . brake = 1 <nl> + client . setCarControls ( car_controls2 , " Car2 " ) <nl> + print ( " Car2 : Apply break " ) <nl> + car_controls2 . brake = 0 # remove break <nl> + time . sleep ( 3 ) # let car drive a bit <nl> + <nl> + # get camera images from the car <nl> + responses1 = client . simGetImages ( [ <nl> + airsim . ImageRequest ( " 0 " , airsim . ImageType . DepthVis ) , # depth visualization image <nl> + airsim . ImageRequest ( " 1 " , airsim . ImageType . Scene , False , False ) ] , " Car1 " ) # scene vision image in uncompressed RGBA array <nl> + print ( ' Car1 : Retrieved images : % d ' % ( len ( responses1 ) ) ) <nl> + responses2 = client . simGetImages ( [ <nl> + airsim . ImageRequest ( " 0 " , airsim . ImageType . Segmentation ) , # depth visualization image <nl> + airsim . ImageRequest ( " 1 " , airsim . ImageType . Scene , False , False ) ] , " Car2 " ) # scene vision image in uncompressed RGBA array <nl> + print ( ' Car2 : Retrieved images : % d ' % ( len ( responses2 ) ) ) <nl> + <nl> + for response in responses1 + responses2 : <nl> + filename = ' c : / temp / car_multi_py ' + str ( idx ) <nl> + <nl> + if response . pixels_as_float : <nl> + print ( " Type % d , size % d " % ( response . image_type , len ( response . image_data_float ) ) ) <nl> + airsim . write_pfm ( os . path . normpath ( filename + ' . pfm ' ) , airsim . get_pfm_array ( response ) ) <nl> + elif response . compress : # png format <nl> + print ( " Type % d , size % d " % ( response . image_type , len ( response . image_data_uint8 ) ) ) <nl> + airsim . write_file ( os . path . normpath ( filename + ' . png ' ) , response . image_data_uint8 ) <nl> + else : # uncompressed array <nl> + print ( " Type % d , size % d " % ( response . image_type , len ( response . image_data_uint8 ) ) ) <nl> + img1d = np . fromstring ( response . image_data_uint8 , dtype = np . uint8 ) # get numpy array <nl> + img_rgba = img1d . reshape ( response . height , response . width , 4 ) # reshape array to 4 channel image array H X W X 4 <nl> + img_rgba = np . flipud ( img_rgba ) # original image is flipped vertically <nl> + img_rgba [ : , : , 1 : 2 ] = 100 # just for fun add little bit of green in all pixels <nl> + airsim . write_png ( os . path . normpath ( filename + ' . greener . png ' ) , img_rgba ) # write to png <nl> + <nl> + <nl> + # restore to original state <nl> + client . reset ( ) <nl> + <nl> + client . enableApiControl ( False ) <nl> + <nl> + <nl> + <nl> mmm a / Unreal / Plugins / AirSim / Source / Vehicles / Car / CarPawn . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / Vehicles / Car / CarPawn . cpp <nl> void ACarPawn : : initializeForBeginPlay ( bool engine_sound ) <nl> FActorSpawnParameters camera_spawn_params ; <nl> camera_spawn_params . SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod : : AdjustIfPossibleButAlwaysSpawn ; <nl> <nl> - camera_spawn_params . Name = " camera_front_center " ; <nl> + camera_spawn_params . Name = FName ( * ( this - > GetName ( ) + " _camera_front_center " ) ) ; <nl> camera_front_center_ = this - > GetWorld ( ) - > SpawnActor < APIPCamera > ( pip_camera_class_ , camera_transform , camera_spawn_params ) ; <nl> camera_front_center_ - > AttachToComponent ( camera_front_center_base_ , FAttachmentTransformRules : : KeepRelativeTransform ) ; <nl> <nl> - camera_spawn_params . Name = " camera_front_left " ; <nl> + camera_spawn_params . Name = FName ( * ( this - > GetName ( ) + " _camera_front_left " ) ) ; <nl> camera_front_left_ = this - > GetWorld ( ) - > SpawnActor < APIPCamera > ( pip_camera_class_ , camera_transform , camera_spawn_params ) ; <nl> camera_front_left_ - > AttachToComponent ( camera_front_left_base_ , FAttachmentTransformRules : : KeepRelativeTransform ) ; <nl> <nl> - camera_spawn_params . Name = " camera_front_right " ; <nl> + camera_spawn_params . Name = FName ( * ( this - > GetName ( ) + " _camera_front_right " ) ) ; <nl> camera_front_right_ = this - > GetWorld ( ) - > SpawnActor < APIPCamera > ( pip_camera_class_ , camera_transform , camera_spawn_params ) ; <nl> camera_front_right_ - > AttachToComponent ( camera_front_right_base_ , FAttachmentTransformRules : : KeepRelativeTransform ) ; <nl> <nl> - camera_spawn_params . Name = " camera_driver " ; <nl> + camera_spawn_params . Name = FName ( * ( this - > GetName ( ) + " _camera_driver " ) ) ; <nl> camera_driver_ = this - > GetWorld ( ) - > SpawnActor < APIPCamera > ( pip_camera_class_ , camera_transform , camera_spawn_params ) ; <nl> camera_driver_ - > AttachToComponent ( camera_driver_base_ , FAttachmentTransformRules : : KeepRelativeTransform ) ; <nl> <nl> - camera_spawn_params . Name = " camera_back_center " ; <nl> + camera_spawn_params . Name = FName ( * ( this - > GetName ( ) + " _camera_back_center " ) ) ; <nl> camera_back_center_ = this - > GetWorld ( ) - > SpawnActor < APIPCamera > ( pip_camera_class_ , <nl> FTransform ( FRotator ( 0 , - 180 , 0 ) , FVector : : ZeroVector ) , camera_spawn_params ) ; <nl> camera_back_center_ - > AttachToComponent ( camera_back_center_base_ , FAttachmentTransformRules : : KeepRelativeTransform ) ; <nl> mmm a / build . cmd <nl> ppp b / build . cmd <nl> robocopy / MIR external \ rpclib \ rpclib - 2 . 2 . 1 \ build \ Release % RPCLIB_TARGET_LIB % \ Rel <nl> <nl> REM / / mmmmmmmmm - get High PolyCount SUV Car Model mmmmmmmmmmmm <nl> IF NOT EXIST Unreal \ Plugins \ AirSim \ Content \ VehicleAdv mkdir Unreal \ Plugins \ AirSim \ Content \ VehicleAdv <nl> - IF NOT EXIST Unreal \ Plugins \ AirSim \ Content \ VehicleAdv \ SUV \ v1 . 1 . 10 ( <nl> + IF NOT EXIST Unreal \ Plugins \ AirSim \ Content \ VehicleAdv \ SUV \ v1 . 2 . 0 ( <nl> IF NOT DEFINED noFullPolyCar ( <nl> REM / / leave some blank lines because powershell shows download banner at top of console <nl> ECHO ( <nl> IF NOT EXIST Unreal \ Plugins \ AirSim \ Content \ VehicleAdv \ SUV \ v1 . 1 . 10 ( <nl> IF EXIST suv_download_tmp rmdir suv_download_tmp / q / s <nl> mkdir suv_download_tmp <nl> @ echo on <nl> - REM powershell - command " & { Start - BitsTransfer - Source https : / / github . com / Microsoft / AirSim / releases / download / v1 . 1 . 10 / car_assets . zip - Destination suv_download_tmp \ car_assets . zip } " <nl> - REM powershell - command " & { ( New - Object System . Net . WebClient ) . DownloadFile ( ' https : / / github . com / Microsoft / AirSim / releases / download / v1 . 1 . 10 / car_assets . zip ' , ' suv_download_tmp \ car_assets . zip ' ) } " <nl> - powershell - command " & { [ Net . ServicePointManager ] : : SecurityProtocol = [ Net . SecurityProtocolType ] : : Tls12 ; iwr https : / / github . com / Microsoft / AirSim / releases / download / v1 . 1 . 10 / car_assets . zip - OutFile suv_download_tmp \ car_assets . zip } " <nl> + REM powershell - command " & { Start - BitsTransfer - Source https : / / github . com / Microsoft / AirSim / releases / download / v1 . 2 . 0 / car_assets . zip - Destination suv_download_tmp \ car_assets . zip } " <nl> + REM powershell - command " & { ( New - Object System . Net . WebClient ) . DownloadFile ( ' https : / / github . com / Microsoft / AirSim / releases / download / v1 . 2 . 0 / car_assets . zip ' , ' suv_download_tmp \ car_assets . zip ' ) } " <nl> + powershell - command " & { [ Net . ServicePointManager ] : : SecurityProtocol = [ Net . SecurityProtocolType ] : : Tls12 ; iwr https : / / github . com / Microsoft / AirSim / releases / download / v1 . 2 . 0 / car_assets . zip - OutFile suv_download_tmp \ car_assets . zip } " <nl> @ echo off <nl> rmdir / S / Q Unreal \ Plugins \ AirSim \ Content \ VehicleAdv \ SUV <nl> powershell - command " & { Expand - Archive - Path suv_download_tmp \ car_assets . zip - DestinationPath Unreal \ Plugins \ AirSim \ Content \ VehicleAdv } " <nl> mmm a / setup . sh <nl> ppp b / setup . sh <nl> fi <nl> if [ ! - d " Unreal / Plugins / AirSim / Content / VehicleAdv " ] ; then <nl> mkdir - p " Unreal / Plugins / AirSim / Content / VehicleAdv " <nl> fi <nl> - if [ ! - d " Unreal / Plugins / AirSim / Content / VehicleAdv / SUV / v1 . 1 . 10 " ] ; then <nl> + if [ ! - d " Unreal / Plugins / AirSim / Content / VehicleAdv / SUV / v1 . 2 . 0 " ] ; then <nl> if $ downloadHighPolySuv ; then <nl> echo " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * " <nl> echo " Downloading high - poly car assets . . . . The download is ~ 37MB and can take some time . " <nl> if [ ! - d " Unreal / Plugins / AirSim / Content / VehicleAdv / SUV / v1 . 1 . 10 " ] ; then <nl> fi <nl> mkdir - p " suv_download_tmp " <nl> cd suv_download_tmp <nl> - wget https : / / github . com / Microsoft / AirSim / releases / download / v1 . 1 . 10 / car_assets . zip <nl> + wget https : / / github . com / Microsoft / AirSim / releases / download / v1 . 2 . 0 / car_assets . zip <nl> if [ - d " . . / Unreal / Plugins / AirSim / Content / VehicleAdv / SUV " ] ; then <nl> rm - rf " . . / Unreal / Plugins / AirSim / Content / VehicleAdv / SUV " <nl> fi <nl>
Fix multi - agent issues for car
microsoft/AirSim
c3580ca324a5fc506273a45b4f19e6119fab5601
2018-06-25T08:43:07Z
mmm a / cocos / platform / CCFileUtils . cpp <nl> ppp b / cocos / platform / CCFileUtils . cpp <nl> std : : string FileUtils : : getSuitableFOpen ( const std : : string & filenameUtf8 ) const <nl> return filenameUtf8 ; <nl> } <nl> <nl> + long FileUtils : : getFileSize ( const std : : string & filepath ) <nl> + { <nl> + CCASSERT ( false , " getFileSize should be override by platform FileUtils " ) ; <nl> + return 0 ; <nl> + } <nl> + <nl> # else <nl> / / default implements for unix like os <nl> # include < sys / types . h > <nl> std : : string FileUtils : : getSuitableFOpen ( const std : : string & filenameUtf8 ) const <nl> return filenameUtf8 ; <nl> } <nl> <nl> - # endif <nl> <nl> long FileUtils : : getFileSize ( const std : : string & filepath ) <nl> { <nl> long FileUtils : : getFileSize ( const std : : string & filepath ) <nl> <nl> struct stat info ; <nl> / / Get data associated with " crt_stat . c " : <nl> - int result = stat ( fullpath . c_str ( ) , & info ) ; <nl> + int result = stat ( fullpath . c_str ( ) , & info ) ; <nl> <nl> / / Check if statistics are valid : <nl> - if ( result ! = 0 ) <nl> + if ( result ! = 0 ) <nl> { <nl> / / Failed <nl> return - 1 ; <nl> long FileUtils : : getFileSize ( const std : : string & filepath ) <nl> return ( long ) ( info . st_size ) ; <nl> } <nl> } <nl> + # endif <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Notification support when getFileData from invalid file path . <nl> mmm a / cocos / platform / win32 / CCFileUtils - win32 . cpp <nl> ppp b / cocos / platform / win32 / CCFileUtils - win32 . cpp <nl> std : : string FileUtilsWin32 : : getSuitableFOpen ( const std : : string & filenameUtf8 ) co <nl> return UTF8StringToMultiByte ( filenameUtf8 ) ; <nl> } <nl> <nl> + long FileUtilsWin32 : : getFileSize ( const std : : string & filepath ) <nl> + { <nl> + WIN32_FILE_ATTRIBUTE_DATA fad ; <nl> + if ( ! GetFileAttributesEx ( StringUtf8ToWideChar ( filepath ) . c_str ( ) , GetFileExInfoStandard , & fad ) ) <nl> + { <nl> + return 0 ; / / error condition , could call GetLastError to find out more <nl> + } <nl> + LARGE_INTEGER size ; <nl> + size . HighPart = fad . nFileSizeHigh ; <nl> + size . LowPart = fad . nFileSizeLow ; <nl> + return ( long ) size . QuadPart ; <nl> + } <nl> + <nl> bool FileUtilsWin32 : : isFileExistInternal ( const std : : string & strFilePath ) const <nl> { <nl> if ( strFilePath . empty ( ) ) <nl> mmm a / cocos / platform / win32 / CCFileUtils - win32 . h <nl> ppp b / cocos / platform / win32 / CCFileUtils - win32 . h <nl> class CC_DLL FileUtilsWin32 : public FileUtils <nl> virtual std : : string getWritablePath ( ) const override ; <nl> virtual bool isAbsolutePath ( const std : : string & strPath ) const override ; <nl> virtual std : : string getSuitableFOpen ( const std : : string & filenameUtf8 ) const override ; <nl> + virtual long getFileSize ( const std : : string & filepath ) ; <nl> protected : <nl> <nl> virtual bool isFileExistInternal ( const std : : string & strFilePath ) const override ; <nl> class CC_DLL FileUtilsWin32 : public FileUtils <nl> * @ return The full path of the file , if the file can ' t be found , it will return an empty string . <nl> * / <nl> virtual std : : string getFullPathForDirectoryAndFilename ( const std : : string & directory , const std : : string & filename ) const override ; <nl> - <nl> } ; <nl> <nl> / / end of platform group <nl>
Fix bug : FileUtils : : GetFileSize can ' t treat multi - char path .
cocos2d/cocos2d-x
5c0d6691ca584971ce59dd73fc2f378414ae31b0
2015-09-25T06:50:20Z
mmm a / taichi / platform / metal / metal_runtime . cpp <nl> ppp b / taichi / platform / metal / metal_runtime . cpp <nl> <nl> # include " metal_runtime . h " <nl> <nl> + # include < taichi / arithmetic . h > <nl> + <nl> # include < algorithm > <nl> # include < cstring > <nl> + # include < string_view > <nl> <nl> - # include < taichi / arithmetic . h > <nl> # define TI_RUNTIME_HOST <nl> # include < taichi / context . h > <nl> # undef TI_RUNTIME_HOST <nl> class BufferMemoryView { <nl> void * ptr_ ; <nl> } ; <nl> <nl> + struct MtlDataBuffers { <nl> + MTLBuffer * root ; <nl> + MTLBuffer * global_tmps ; <nl> + MTLBuffer * args ; / / nullable <nl> + } ; <nl> + <nl> / / Info for launching a compiled Metal kernel <nl> class CompiledMtlKernel { <nl> public : <nl> - CompiledMtlKernel ( const MetalKernelAttributes & md , MTLDevice * device , <nl> - MTLFunction * func , ProfilerBase * profiler ) <nl> - : kernel_attribs_ ( md ) , <nl> - pipeline_state_ ( new_compute_pipeline_state_with_function ( device , func ) ) , <nl> - profiler_ ( profiler ) , <nl> + struct Params { <nl> + const MetalKernelAttributes * kerenl_attribs ; <nl> + MTLDevice * device ; <nl> + MTLFunction * mtl_func ; <nl> + ProfilerBase * profiler ; <nl> + } ; <nl> + <nl> + CompiledMtlKernel ( Params params ) <nl> + : kernel_attribs_ ( * params . kerenl_attribs ) , <nl> + pipeline_state_ ( new_compute_pipeline_state_with_function ( <nl> + params . device , params . mtl_func ) ) , <nl> + profiler_ ( params . profiler ) , <nl> profiler_id_ ( fmt : : format ( " { } _dispatch " , kernel_attribs_ . name ) ) { <nl> TI_ASSERT ( pipeline_state_ ! = nullptr ) ; <nl> } <nl> <nl> - void launch ( MTLBuffer * root_buffer , MTLBuffer * global_tmps_buffer , <nl> - MTLBuffer * args_buffer , MTLCommandBuffer * command_buffer ) { <nl> + void launch ( MtlDataBuffers data_buffers , MTLCommandBuffer * command_buffer ) { <nl> / / 0 is valid for | num_threads | ! <nl> TI_ASSERT ( kernel_attribs_ . num_threads > = 0 ) ; <nl> - launch_if_not_empty ( root_buffer , global_tmps_buffer , args_buffer , <nl> - command_buffer ) ; <nl> + launch_if_not_empty ( std : : move ( data_buffers ) , command_buffer ) ; <nl> if ( ( kernel_attribs_ . task_type = = KernelTaskType : : range_for ) & & <nl> ! kernel_attribs_ . range_for_attribs . const_range ( ) ) { <nl> / / Set | num_thread | to an invalid number to make sure the next launch <nl> class CompiledMtlKernel { <nl> } <nl> } <nl> <nl> - inline MetalKernelAttributes * kernel_attribs ( ) { <nl> - return & kernel_attribs_ ; <nl> - } <nl> + inline MetalKernelAttributes * kernel_attribs ( ) { return & kernel_attribs_ ; } <nl> <nl> private : <nl> - void launch_if_not_empty ( MTLBuffer * root_buffer , <nl> - MTLBuffer * global_tmps_buffer , <nl> - MTLBuffer * args_buffer , <nl> + void launch_if_not_empty ( MtlDataBuffers data_buffers , <nl> MTLCommandBuffer * command_buffer ) { <nl> const int num_threads = kernel_attribs_ . num_threads ; <nl> if ( num_threads = = 0 ) { <nl> class CompiledMtlKernel { <nl> <nl> set_compute_pipeline_state ( encoder . get ( ) , pipeline_state_ . get ( ) ) ; <nl> int buffer_index = 0 ; <nl> - set_mtl_buffer ( encoder . get ( ) , root_buffer , / * offset = * / 0 , buffer_index + + ) ; <nl> - set_mtl_buffer ( encoder . get ( ) , global_tmps_buffer , / * offset = * / 0 , <nl> + set_mtl_buffer ( encoder . get ( ) , data_buffers . root , / * offset = * / 0 , <nl> buffer_index + + ) ; <nl> - if ( args_buffer ) { <nl> - set_mtl_buffer ( encoder . get ( ) , args_buffer , / * offset = * / 0 , buffer_index + + ) ; <nl> + set_mtl_buffer ( encoder . get ( ) , data_buffers . global_tmps , / * offset = * / 0 , <nl> + buffer_index + + ) ; <nl> + if ( data_buffers . args ) { <nl> + set_mtl_buffer ( encoder . get ( ) , data_buffers . args , / * offset = * / 0 , <nl> + buffer_index + + ) ; <nl> } <nl> const int num_threads_per_group = <nl> get_max_total_threads_per_threadgroup ( pipeline_state_ . get ( ) ) ; <nl> class CompiledMtlKernel { <nl> / / compiled Metal kernels . <nl> class CompiledTaichiKernel { <nl> public : <nl> - CompiledTaichiKernel ( <nl> - const std : : string & taichi_kernel_name , const std : : string & source_code , <nl> - const std : : vector < MetalKernelAttributes > & mtl_kernels_attribs , <nl> - size_t global_tmps_size , const MetalKernelArgsAttributes & args_attribs , <nl> - MTLDevice * device , MemoryPool * mem_pool , ProfilerBase * profiler ) <nl> - : global_tmps_mem ( global_tmps_size , mem_pool ) , <nl> - args_attribs ( args_attribs ) , <nl> - mtl_source_code_ ( source_code ) , <nl> - profiler_ ( profiler ) { <nl> + struct Params { <nl> + std : : string_view taichi_kernel_name ; <nl> + std : : string_view mtl_source_code ; <nl> + const std : : vector < MetalKernelAttributes > * mtl_kernels_attribs ; <nl> + size_t global_tmps_size ; <nl> + const MetalKernelArgsAttributes * args_attribs ; <nl> + MTLDevice * device ; <nl> + MemoryPool * mem_pool ; <nl> + ProfilerBase * profiler ; <nl> + } ; <nl> + <nl> + CompiledTaichiKernel ( Params params ) <nl> + : global_tmps_mem ( params . global_tmps_size , params . mem_pool ) , <nl> + args_attribs ( * params . args_attribs ) , <nl> + mtl_source_code_ ( params . mtl_source_code ) , <nl> + profiler_ ( params . profiler ) { <nl> + auto * const device = params . device ; <nl> auto kernel_lib = new_library_with_source ( device , mtl_source_code_ ) ; <nl> TI_ASSERT ( kernel_lib ! = nullptr ) ; <nl> - for ( const auto & ka : mtl_kernels_attribs ) { <nl> - auto kernel_func = new_function_with_name ( kernel_lib . get ( ) , ka . name ) ; <nl> - TI_ASSERT ( kernel_func ! = nullptr ) ; <nl> + for ( const auto & ka : * ( params . mtl_kernels_attribs ) ) { <nl> + auto mtl_func = new_function_with_name ( kernel_lib . get ( ) , ka . name ) ; <nl> + TI_ASSERT ( mtl_func ! = nullptr ) ; <nl> / / Note that CompiledMtlKernel doesn ' t own | kernel_func | . <nl> - compiled_mtl_kernels . push_back ( std : : make_unique < CompiledMtlKernel > ( <nl> - ka , device , kernel_func . get ( ) , profiler_ ) ) ; <nl> + CompiledMtlKernel : : Params params ; <nl> + params . kerenl_attribs = & ka ; <nl> + params . device = device ; <nl> + params . mtl_func = mtl_func . get ( ) ; <nl> + params . profiler = profiler_ ; <nl> + compiled_mtl_kernels . push_back ( <nl> + std : : make_unique < CompiledMtlKernel > ( params ) ) ; <nl> } <nl> global_tmps_buffer = new_mtl_buffer_no_copy ( device , global_tmps_mem . ptr ( ) , <nl> global_tmps_mem . size ( ) ) ; <nl> if ( args_attribs . has_args ( ) ) { <nl> args_mem = std : : make_unique < BufferMemoryView > ( args_attribs . total_bytes ( ) , <nl> - mem_pool ) ; <nl> + params . mem_pool ) ; <nl> args_buffer = <nl> new_mtl_buffer_no_copy ( device , args_mem - > ptr ( ) , args_mem - > size ( ) ) ; <nl> } <nl> } <nl> + <nl> / / Have to be exposed as public for Impl to use . We cannot friend the Impl <nl> / / class because it is private . <nl> std : : vector < std : : unique_ptr < CompiledMtlKernel > > compiled_mtl_kernels ; <nl> class HostMetalArgsBlitter { <nl> <nl> class MetalRuntime : : Impl { <nl> public : <nl> - explicit Impl ( Options options ) <nl> - : config_ ( options . config ) , <nl> - mem_pool_ ( options . mem_pool ) , <nl> - profiler_ ( options . profiler ) { <nl> + explicit Impl ( Params params ) <nl> + : config_ ( params . config ) , <nl> + mem_pool_ ( params . mem_pool ) , <nl> + profiler_ ( params . profiler ) { <nl> if ( config_ - > debug ) { <nl> TI_ASSERT ( is_metal_api_available ( ) ) ; <nl> } <nl> class MetalRuntime : : Impl { <nl> TI_ASSERT ( command_queue_ ! = nullptr ) ; <nl> create_new_command_buffer ( ) ; <nl> <nl> - auto * llvm_ctx = options . llvm_ctx ; <nl> - auto * llvm_rtm = options . llvm_runtime ; <nl> + auto * llvm_ctx = params . llvm_ctx ; <nl> + auto * llvm_rtm = params . llvm_runtime ; <nl> const size_t rtm_root_mem_size = llvm_ctx - > lookup_function < size_t ( void * ) > ( <nl> " Runtime_get_root_mem_size " ) ( llvm_rtm ) ; <nl> if ( rtm_root_mem_size > 0 ) { <nl> - TI_ASSERT ( iroundup ( options . root_size , kPageSize ) < = rtm_root_mem_size ) ; <nl> - auto * rtm_root_mem = options . llvm_ctx - > lookup_function < uint8 * ( void * ) > ( <nl> + TI_ASSERT ( iroundup ( params . root_size , kPageSize ) < = rtm_root_mem_size ) ; <nl> + auto * rtm_root_mem = params . llvm_ctx - > lookup_function < uint8 * ( void * ) > ( <nl> " Runtime_get_root " ) ( llvm_rtm ) ; <nl> root_buffer_ = new_mtl_buffer_no_copy ( device_ . get ( ) , rtm_root_mem , <nl> rtm_root_mem_size ) ; <nl> class MetalRuntime : : Impl { <nl> TI_INFO ( " Metal source code for kernel < { } > \ n { } " , taichi_kernel_name , <nl> mtl_kernel_source_code ) ; <nl> } <nl> + CompiledTaichiKernel : : Params params ; <nl> + params . taichi_kernel_name = taichi_kernel_name ; <nl> + params . mtl_source_code = mtl_kernel_source_code ; <nl> + params . mtl_kernels_attribs = & kernels_attribs ; <nl> + params . global_tmps_size = global_tmps_size ; <nl> + params . args_attribs = & args_attribs ; <nl> + params . device = device_ . get ( ) ; <nl> + params . mem_pool = mem_pool_ ; <nl> + params . profiler = profiler_ ; <nl> compiled_taichi_kernels_ [ taichi_kernel_name ] = <nl> - std : : make_unique < CompiledTaichiKernel > ( <nl> - taichi_kernel_name , mtl_kernel_source_code , kernels_attribs , <nl> - global_tmps_size , args_attribs , device_ . get ( ) , mem_pool_ , <nl> - profiler_ ) ; <nl> + std : : make_unique < CompiledTaichiKernel > ( params ) ; <nl> TI_INFO ( " Registered Taichi kernel < { } > " , taichi_kernel_name ) ; <nl> } <nl> <nl> class MetalRuntime : : Impl { <nl> TI_ASSERT ( ka - > num_threads = = - 1 ) ; <nl> ka - > num_threads = end - begin ; <nl> } <nl> - mk - > launch ( root_buffer_ . get ( ) , ctk . global_tmps_buffer . get ( ) , <nl> - ctk . args_buffer . get ( ) , cur_command_buffer_ . get ( ) ) ; <nl> + MtlDataBuffers data_buffers ; <nl> + data_buffers . root = root_buffer_ . get ( ) ; <nl> + data_buffers . global_tmps = ctk . global_tmps_buffer . get ( ) ; <nl> + data_buffers . args = ctk . args_buffer . get ( ) ; <nl> + mk - > launch ( std : : move ( data_buffers ) , cur_command_buffer_ . get ( ) ) ; <nl> } <nl> if ( args_blitter ) { <nl> / / TODO ( k - ye ) : One optimization is to synchronize only when we absolutely <nl> class MetalRuntime : : Impl { <nl> <nl> class MetalRuntime : : Impl { <nl> public : <nl> - explicit Impl ( Options options ) { <nl> - TI_ERROR ( " Metal not supported on the current OS " ) ; <nl> - } <nl> + explicit Impl ( Params ) { TI_ERROR ( " Metal not supported on the current OS " ) ; } <nl> <nl> void register_taichi_kernel ( <nl> const std : : string & taichi_kernel_name , <nl> class MetalRuntime : : Impl { <nl> <nl> # endif / / TI_PLATFORM_OSX <nl> <nl> - MetalRuntime : : MetalRuntime ( Options options ) <nl> - : impl_ ( std : : make_unique < Impl > ( std : : move ( options ) ) ) { <nl> - } <nl> + MetalRuntime : : MetalRuntime ( Params params ) <nl> + : impl_ ( std : : make_unique < Impl > ( std : : move ( params ) ) ) { } <nl> <nl> MetalRuntime : : ~ MetalRuntime ( ) { } <nl> <nl> mmm a / taichi / platform / metal / metal_runtime . h <nl> ppp b / taichi / platform / metal / metal_runtime . h <nl> namespace metal { <nl> / / series of Metal kernels generated from a Taichi kernel . <nl> class MetalRuntime { <nl> public : <nl> - struct Options { <nl> + struct Params { <nl> size_t root_size ; <nl> void * llvm_runtime ; <nl> TaichiLLVMContext * llvm_ctx ; <nl> class MetalRuntime { <nl> ProfilerBase * profiler ; <nl> } ; <nl> <nl> - explicit MetalRuntime ( Options options ) ; <nl> + explicit MetalRuntime ( Params params ) ; <nl> / / To make Pimpl + std : : unique_ptr work <nl> ~ MetalRuntime ( ) ; <nl> <nl> mmm a / taichi / program . cpp <nl> ppp b / taichi / program . cpp <nl> void Program : : materialize_layout ( ) { <nl> metal : : MetalStructCompiler scomp ; <nl> metal_struct_compiled_ = scomp . run ( * snode_root ) ; <nl> if ( metal_runtime_ = = nullptr ) { <nl> - metal : : MetalRuntime : : Options options ; <nl> - options . root_size = metal_struct_compiled_ - > root_size ; <nl> - options . llvm_runtime = llvm_runtime ; <nl> - options . llvm_ctx = get_llvm_context ( get_host_arch ( ) ) ; <nl> - options . config = & config ; <nl> - options . mem_pool = memory_pool . get ( ) ; <nl> - options . profiler = profiler_llvm . get ( ) ; <nl> + metal : : MetalRuntime : : Params params ; <nl> + params . root_size = metal_struct_compiled_ - > root_size ; <nl> + params . llvm_runtime = llvm_runtime ; <nl> + params . llvm_ctx = get_llvm_context ( get_host_arch ( ) ) ; <nl> + params . config = & config ; <nl> + params . mem_pool = memory_pool . get ( ) ; <nl> + params . profiler = profiler_llvm . get ( ) ; <nl> metal_runtime_ = <nl> - std : : make_unique < metal : : MetalRuntime > ( std : : move ( options ) ) ; <nl> + std : : make_unique < metal : : MetalRuntime > ( std : : move ( params ) ) ; <nl> } <nl> TI_INFO ( " Metal root buffer size : { } B " , metal_struct_compiled_ - > root_size ) ; <nl> } <nl>
Refactor Metal runtime to take in a single params struct in its constructor ( )
taichi-dev/taichi
bad5adfb8d5d1e769765ffaae84e0733e843cd85
2020-02-18T12:30:30Z
mmm a / include / grpc + + / impl / codegen / call . h <nl> ppp b / include / grpc + + / impl / codegen / call . h <nl> class CallOpClientRecvStatus { <nl> op - > data . recv_status_on_client . trailing_metadata = metadata_map_ - > arr ( ) ; <nl> op - > data . recv_status_on_client . status = & status_code_ ; <nl> op - > data . recv_status_on_client . status_details = & error_message_ ; <nl> + op - > data . recv_status_on_client . error_string = nullptr ; <nl> op - > flags = 0 ; <nl> op - > reserved = NULL ; <nl> } <nl> mmm a / include / grpc / impl / codegen / grpc_types . h <nl> ppp b / include / grpc / impl / codegen / grpc_types . h <nl> typedef struct grpc_op { <nl> grpc_metadata_array * trailing_metadata ; <nl> grpc_status_code * status ; <nl> grpc_slice * status_details ; <nl> + / * * If this is not nullptr , it will be populated with the full fidelity <nl> + * error string for debugging purposes . The application is responsible <nl> + * for freeing the data . * / <nl> + const char * * error_string ; <nl> } recv_status_on_client ; <nl> struct grpc_op_recv_close_on_server { <nl> / * * out argument , set to 1 if the call failed in any way ( seen as a <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> static void send_goaway ( grpc_exec_ctx * exec_ctx , grpc_chttp2_transport * t , <nl> grpc_http2_error_code http_error ; <nl> grpc_slice slice ; <nl> grpc_error_get_status ( exec_ctx , error , GRPC_MILLIS_INF_FUTURE , nullptr , <nl> - & slice , & http_error ) ; <nl> + & slice , & http_error , nullptr ) ; <nl> grpc_chttp2_goaway_append ( t - > last_new_stream_id , ( uint32_t ) http_error , <nl> grpc_slice_ref_internal ( slice ) , & t - > qbuf ) ; <nl> grpc_chttp2_initiate_write ( exec_ctx , t , <nl> void grpc_chttp2_cancel_stream ( grpc_exec_ctx * exec_ctx , <nl> if ( s - > id ! = 0 ) { <nl> grpc_http2_error_code http_error ; <nl> grpc_error_get_status ( exec_ctx , due_to_error , s - > deadline , nullptr , <nl> - nullptr , & http_error ) ; <nl> + nullptr , & http_error , nullptr ) ; <nl> grpc_slice_buffer_add ( <nl> & t - > qbuf , grpc_chttp2_rst_stream_create ( s - > id , ( uint32_t ) http_error , <nl> & s - > stats . outgoing ) ) ; <nl> void grpc_chttp2_fake_status ( grpc_exec_ctx * exec_ctx , grpc_chttp2_transport * t , <nl> grpc_chttp2_stream * s , grpc_error * error ) { <nl> grpc_status_code status ; <nl> grpc_slice slice ; <nl> - grpc_error_get_status ( exec_ctx , error , s - > deadline , & status , & slice , nullptr ) ; <nl> + grpc_error_get_status ( exec_ctx , error , s - > deadline , & status , & slice , nullptr , <nl> + nullptr ) ; <nl> if ( status ! = GRPC_STATUS_OK ) { <nl> s - > seen_error = true ; <nl> } <nl> static void close_from_api ( grpc_exec_ctx * exec_ctx , grpc_chttp2_transport * t , <nl> grpc_status_code grpc_status ; <nl> grpc_slice slice ; <nl> grpc_error_get_status ( exec_ctx , error , s - > deadline , & grpc_status , & slice , <nl> - nullptr ) ; <nl> + nullptr , nullptr ) ; <nl> <nl> GPR_ASSERT ( grpc_status > = 0 & & ( int ) grpc_status < 100 ) ; <nl> <nl> mmm a / src / core / lib / channel / channel_stack . h <nl> ppp b / src / core / lib / channel / channel_stack . h <nl> typedef struct { <nl> typedef struct { <nl> grpc_call_stats stats ; <nl> grpc_status_code final_status ; <nl> + const char * * error_string ; <nl> } grpc_call_final_info ; <nl> <nl> / * Channel filters specify : <nl> mmm a / src / core / lib / surface / call . cc <nl> ppp b / src / core / lib / surface / call . cc <nl> struct grpc_call { <nl> struct { <nl> grpc_status_code * status ; <nl> grpc_slice * status_details ; <nl> + const char * * error_string ; <nl> } client ; <nl> struct { <nl> int * cancelled ; <nl> static void receiving_slice_ready ( grpc_exec_ctx * exec_ctx , void * bctlp , <nl> static void get_final_status ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> void ( * set_value ) ( grpc_status_code code , <nl> void * user_data ) , <nl> - void * set_value_user_data , grpc_slice * details ) ; <nl> + void * set_value_user_data , grpc_slice * details , <nl> + const char * * error_string ) ; <nl> static void set_status_value_directly ( grpc_status_code status , void * dest ) ; <nl> static void set_status_from_error ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> status_source source , grpc_error * error ) ; <nl> static void destroy_call ( grpc_exec_ctx * exec_ctx , void * call , <nl> } <nl> <nl> get_final_status ( exec_ctx , c , set_status_value_directly , <nl> - & c - > final_info . final_status , nullptr ) ; <nl> + & c - > final_info . final_status , nullptr , <nl> + c - > final_info . error_string ) ; <nl> c - > final_info . stats . latency = <nl> gpr_time_sub ( gpr_now ( GPR_CLOCK_MONOTONIC ) , c - > start_time ) ; <nl> <nl> static void cancel_with_status ( grpc_exec_ctx * exec_ctx , grpc_call * c , <nl> * FINAL STATUS CODE MANIPULATION <nl> * / <nl> <nl> - static bool get_final_status_from ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> - grpc_error * error , bool allow_ok_status , <nl> - void ( * set_value ) ( grpc_status_code code , <nl> - void * user_data ) , <nl> - void * set_value_user_data , <nl> - grpc_slice * details ) { <nl> + static bool get_final_status_from ( <nl> + grpc_exec_ctx * exec_ctx , grpc_call * call , grpc_error * error , <nl> + bool allow_ok_status , <nl> + void ( * set_value ) ( grpc_status_code code , void * user_data ) , <nl> + void * set_value_user_data , grpc_slice * details , const char * * error_string ) { <nl> grpc_status_code code ; <nl> grpc_slice slice = grpc_empty_slice ( ) ; <nl> grpc_error_get_status ( exec_ctx , error , call - > send_deadline , & code , & slice , <nl> - nullptr ) ; <nl> + nullptr , error_string ) ; <nl> if ( code = = GRPC_STATUS_OK & & ! allow_ok_status ) { <nl> return false ; <nl> } <nl> static bool get_final_status_from ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> static void get_final_status ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> void ( * set_value ) ( grpc_status_code code , <nl> void * user_data ) , <nl> - void * set_value_user_data , grpc_slice * details ) { <nl> + void * set_value_user_data , grpc_slice * details , <nl> + const char * * error_string ) { <nl> int i ; <nl> received_status status [ STATUS_SOURCE_COUNT ] ; <nl> for ( i = 0 ; i < STATUS_SOURCE_COUNT ; i + + ) { <nl> static void get_final_status ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> grpc_error_has_clear_grpc_status ( status [ i ] . error ) ) { <nl> if ( get_final_status_from ( exec_ctx , call , status [ i ] . error , <nl> allow_ok_status ! = 0 , set_value , <nl> - set_value_user_data , details ) ) { <nl> + set_value_user_data , details , error_string ) ) { <nl> return ; <nl> } <nl> } <nl> static void get_final_status ( grpc_exec_ctx * exec_ctx , grpc_call * call , <nl> if ( status [ i ] . is_set ) { <nl> if ( get_final_status_from ( exec_ctx , call , status [ i ] . error , <nl> allow_ok_status ! = 0 , set_value , <nl> - set_value_user_data , details ) ) { <nl> + set_value_user_data , details , error_string ) ) { <nl> return ; <nl> } <nl> } <nl> static void post_batch_completion ( grpc_exec_ctx * exec_ctx , <nl> if ( call - > is_client ) { <nl> get_final_status ( exec_ctx , call , set_status_value_directly , <nl> call - > final_op . client . status , <nl> - call - > final_op . client . status_details ) ; <nl> + call - > final_op . client . status_details , <nl> + call - > final_op . client . error_string ) ; <nl> } else { <nl> get_final_status ( exec_ctx , call , set_cancelled_value , <nl> - call - > final_op . server . cancelled , nullptr ) ; <nl> + call - > final_op . server . cancelled , nullptr , nullptr ) ; <nl> } <nl> <nl> GRPC_ERROR_UNREF ( error ) ; <nl> static grpc_call_error call_start_batch ( grpc_exec_ctx * exec_ctx , <nl> call - > final_op . client . status = op - > data . recv_status_on_client . status ; <nl> call - > final_op . client . status_details = <nl> op - > data . recv_status_on_client . status_details ; <nl> + call - > final_op . client . error_string = <nl> + op - > data . recv_status_on_client . error_string ; <nl> stream_op - > recv_trailing_metadata = true ; <nl> stream_op - > collect_stats = true ; <nl> stream_op_payload - > recv_trailing_metadata . recv_trailing_metadata = <nl> mmm a / src / core / lib / transport / error_utils . cc <nl> ppp b / src / core / lib / transport / error_utils . cc <nl> <nl> <nl> # include " src / core / lib / transport / error_utils . h " <nl> <nl> + # include < grpc / support / string_util . h > <nl> # include " src / core / lib / iomgr / error_internal . h " <nl> # include " src / core / lib / transport / status_conversion . h " <nl> <nl> static grpc_error * recursively_find_error_with_field ( grpc_error * error , <nl> <nl> void grpc_error_get_status ( grpc_exec_ctx * exec_ctx , grpc_error * error , <nl> grpc_millis deadline , grpc_status_code * code , <nl> - grpc_slice * slice , <nl> - grpc_http2_error_code * http_error ) { <nl> + grpc_slice * slice , grpc_http2_error_code * http_error , <nl> + const char * * error_string ) { <nl> / / Start with the parent error and recurse through the tree of children <nl> / / until we find the first one that has a status code . <nl> grpc_error * found_error = <nl> void grpc_error_get_status ( grpc_exec_ctx * exec_ctx , grpc_error * error , <nl> } <nl> if ( code ! = nullptr ) * code = status ; <nl> <nl> + if ( error_string ! = NULL & & status ! = GRPC_STATUS_OK ) { <nl> + * error_string = gpr_strdup ( grpc_error_string ( error ) ) ; <nl> + } <nl> + <nl> if ( http_error ! = nullptr ) { <nl> if ( grpc_error_get_int ( found_error , GRPC_ERROR_INT_HTTP2_ERROR , & integer ) ) { <nl> * http_error = ( grpc_http2_error_code ) integer ; <nl> mmm a / src / core / lib / transport / error_utils . h <nl> ppp b / src / core / lib / transport / error_utils . h <nl> extern " C " { <nl> / / / A utility function to get the status code and message to be returned <nl> / / / to the application . If not set in the top - level message , looks <nl> / / / through child errors until it finds the first one with these attributes . <nl> - / / / All attributes are pulled from the same child error . If any of the <nl> - / / / attributes ( code , msg , http_status ) are unneeded , they can be passed as <nl> + / / / All attributes are pulled from the same child error . error_string will <nl> + / / / be populated with the entire error string . If any of the attributes ( code , <nl> + / / / msg , http_status , error_string ) are unneeded , they can be passed as <nl> / / / NULL . <nl> void grpc_error_get_status ( grpc_exec_ctx * exec_ctx , grpc_error * error , <nl> grpc_millis deadline , grpc_status_code * code , <nl> grpc_slice * slice , <nl> - grpc_http2_error_code * http_status ) ; <nl> + grpc_http2_error_code * http_status , <nl> + const char * * error_string ) ; <nl> <nl> / / / A utility function to check whether there is a clear status code that <nl> / / / doesn ' t need to be guessed in \ a error . This means that \ a error or some <nl> mmm a / test / cpp / microbenchmarks / bm_error . cc <nl> ppp b / test / cpp / microbenchmarks / bm_error . cc <nl> static void BM_ErrorGetStatus ( benchmark : : State & state ) { <nl> grpc_status_code status ; <nl> grpc_slice slice ; <nl> grpc_error_get_status ( & exec_ctx , fixture . error ( ) , fixture . deadline ( ) , <nl> - & status , & slice , nullptr ) ; <nl> + & status , & slice , nullptr , nullptr ) ; <nl> } <nl> grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> track_counters . Finish ( state ) ; <nl> static void BM_ErrorGetStatusCode ( benchmark : : State & state ) { <nl> while ( state . KeepRunning ( ) ) { <nl> grpc_status_code status ; <nl> grpc_error_get_status ( & exec_ctx , fixture . error ( ) , fixture . deadline ( ) , <nl> - & status , nullptr , nullptr ) ; <nl> + & status , nullptr , nullptr , nullptr ) ; <nl> } <nl> grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> track_counters . Finish ( state ) ; <nl> static void BM_ErrorHttpError ( benchmark : : State & state ) { <nl> while ( state . KeepRunning ( ) ) { <nl> grpc_http2_error_code error ; <nl> grpc_error_get_status ( & exec_ctx , fixture . error ( ) , fixture . deadline ( ) , <nl> - nullptr , nullptr , & error ) ; <nl> + nullptr , nullptr , & error , nullptr ) ; <nl> } <nl> grpc_exec_ctx_finish ( & exec_ctx ) ; <nl> track_counters . Finish ( state ) ; <nl>
Merge pull request from ncteisen / surfacing - error - details
grpc/grpc
dd010f2297560edcfa863c90988020ade485f53a
2017-11-21T15:35:32Z
mmm a / scripts / abi_to_rc / abi_to_rc . py <nl> ppp b / scripts / abi_to_rc / abi_to_rc . py <nl> <nl> import os <nl> import re <nl> <nl> - # purpose of abi_to_rc . py <nl> - purpose = ' ' ' purpose : \ n The abi_to_rc . py script processes a contract ' s . abi file in order to generate <nl> - an overview Ricardian Contract and a Ricardian Contract for each action . The <nl> - overview Ricardian Contract provides a description of the contract ' s purpose <nl> - and also specifies the contract ' s action ( s ) , input ( s ) , and input type ( s ) . The <nl> - action Ricardian Contract provides a description of the action ' s purpose and <nl> - also specifies the action ' s input ( s ) , and input type ( s ) . ' ' ' <nl> - <nl> - # # how to run abi_to_rc . py <nl> - how_to = ' ' ' \ n \ nhow to run : \ n $ python abi_to_rc . py / path / to / smart - contract . abi ' ' ' <nl> - <nl> - # # example of how to run abi_to_rc . py <nl> - example = ' ' ' \ n \ nexample : \ n $ python abi_to_rc . py . . / . . / contracts / currency / currency . abi ' ' ' <nl> - <nl> # argument parser <nl> parser = argparse . ArgumentParser ( <nl> prog = " abi_to_rc . py " , <nl> - formatter_class = argparse . RawDescriptionHelpFormatter , <nl> - description = purpose + how_to + example , <nl> - usage = " \ n $ python % ( prog ) s [ - h ] abi_file " ) <nl> + description = " The abi_to_rc . py script processes a contract ' s . abi file in order to generate an overview Ricardian Contract and a Ricardian Contract for each action . The overview Ricardian Contract provides a description of the contract ' s purpose and also specifies the contract ' s action ( s ) , input ( s ) , and input type ( s ) . The action Ricardian Contract provides a description of the action ' s purpose and also specifies the action ' s input ( s ) , and input type ( s ) . " , <nl> + epilog = " example : $ python abi_to_rc . py . . / . . / contracts / currency / currency . abi " , <nl> + usage = " $ python % ( prog ) s [ - h ] abi_file " ) <nl> parser . add_argument ( " abi_file " , help = " path to smart contract ' s . abi file " ) <nl> args = parser . parse_args ( ) <nl> <nl> def build_table_rows ( ) : <nl> # generates an overview ricardian contract from the overview template <nl> def generate_rc_overview_file ( ) : <nl> tr = build_table_rows ( ) <nl> - plural = { ' action ' : ' actions ' if len ( actions ) > 1 else ' action ' , <nl> - ' input ' : ' inputs ' if len ( inputs ) > 1 else ' input ' , <nl> - ' type ' : ' types ' if len ( types ) > 1 else ' type ' } <nl> abi_file_name = os . path . split ( args . abi_file ) [ 1 ] <nl> contract_name = os . path . splitext ( abi_file_name ) [ 0 ] <nl> rc_file_name = contract_name + ' - rc . md ' <nl> dirname = os . path . split ( args . abi_file ) [ 0 ] <nl> + subs = { ' contract ' : contract_name , <nl> + ' action ' : ' actions ' if len ( actions ) > 1 else ' action ' , <nl> + ' input ' : ' inputs ' if len ( inputs ) > 1 else ' input ' , <nl> + ' type ' : ' types ' if len ( types ) > 1 else ' type ' } <nl> + subs . update ( [ ( k + ' _header ' , v . title ( ) ) for k , v in subs . copy ( ) . items ( ) ] ) <nl> rc_file = open ( os . path . join ( dirname , rc_file_name ) , " w + " ) <nl> with open ( os . path . join ( os . path . dirname ( sys . argv [ 0 ] ) , _RC_OVERVIEW ) ) as fp : <nl> overview_template = Template ( fp . read ( ) ) <nl> - rc_file . write ( overview_template . substitute ( contract = contract_name , <nl> - action = plural [ ' action ' ] , <nl> - input = plural [ ' input ' ] , <nl> - type = plural [ ' type ' ] , <nl> - action_header = plural [ ' action ' ] . title ( ) , <nl> - input_header = plural [ ' input ' ] . title ( ) , <nl> - type_header = plural [ ' type ' ] . title ( ) ) ) <nl> + rc_file . write ( overview_template . substitute ( subs ) ) <nl> rc_file . write ( ' \ n ' . join ( tr ) ) <nl> rc_file . close ( ) <nl> <nl> def generate_rc_action_files ( ) : <nl> contract_name = os . path . splitext ( abi_filename ) [ 0 ] <nl> dirname = os . path . split ( args . abi_file ) [ 0 ] <nl> for action in actions : <nl> - plural = { ' input ' : ' inputs ' if len ( inputs [ action [ ' name ' ] ] ) > 1 else ' input ' , <nl> - ' type ' : ' types ' if len ( types [ action [ ' name ' ] ] ) > 1 else ' type ' } <nl> + subs = { ' action ' : action [ ' name ' ] , <nl> + ' input ' : ' inputs ' if len ( inputs [ action [ ' name ' ] ] ) > 1 else ' input ' , <nl> + ' type ' : ' types ' if len ( types [ action [ ' name ' ] ] ) > 1 else ' type ' } <nl> + subs . update ( [ ( k + ' _header ' , v . title ( ) ) for k , v in subs . copy ( ) . items ( ) ] ) <nl> rc_action_file_name = contract_name + " - " + action [ ' name ' ] + ' - rc . md ' <nl> rc_file = open ( os . path . join ( dirname , rc_action_file_name ) , " w + " ) <nl> with open ( os . path . join ( os . path . dirname ( sys . argv [ 0 ] ) , _RC_ACTION ) ) as fp : <nl> action_template = Template ( fp . read ( ) ) <nl> - rc_file . write ( action_template . substitute ( action = action [ ' name ' ] , <nl> - input = plural [ ' input ' ] , <nl> - type = plural [ ' type ' ] , <nl> - input_header = plural [ ' input ' ] . title ( ) , <nl> - type_header = plural [ ' type ' ] . title ( ) ) ) <nl> + rc_file . write ( action_template . substitute ( subs ) ) <nl> for row in tr : <nl> if re . search ( " \ \ b " + action [ ' name ' ] + " \ \ b " , row ) : <nl> rc_file . write ( row + " \ n " ) <nl>
used dictionary for substitute , removed help formatter
EOSIO/eos
23dc9814185554f005a264b7277de499bfa36c4c
2018-03-23T02:10:26Z
mmm a / docs / README . md <nl> ppp b / docs / README . md <nl> <nl> - # Atom Shell Documentations <nl> + # Atom Shell documents <nl> <nl> # # Tutorials <nl> <nl> <nl> * [ Build instructions ( Windows ) ] ( development / build - instructions - windows . md ) <nl> * [ Build instructions ( Linux ) ] ( development / build - instructions - linux . md ) <nl> <nl> - # # API References <nl> + # # API references <nl> <nl> - Renderer side modules : <nl> + Browser side modules : <nl> <nl> - * [ ipc ( renderer ) ] ( api / renderer / ipc - renderer . md ) <nl> - * [ remote ] ( api / renderer / remote . md ) <nl> + * [ app ] ( api / app . md ) <nl> + * [ auto - updater ] ( api / auto - updater . md ) <nl> + * [ browser - window ] ( api / browser - window . md ) <nl> + * [ dialog ] ( api / dialog . md ) <nl> + * [ ipc ( browser ) ] ( api / ipc - browser . md ) <nl> + * [ menu ] ( api / menu . md ) <nl> + * [ menu - item ] ( api / menu - item . md ) <nl> + * [ power - monitor ] ( api / power - monitor . md ) <nl> + * [ protocol ] ( api / protocol . md ) <nl> <nl> - Browser side modules : <nl> + Renderer side modules : <nl> <nl> - * [ app ] ( api / browser / app . md ) <nl> - * [ auto - updater ] ( api / browser / auto - updater . md ) <nl> - * [ browser - window ] ( api / browser / browser - window . md ) <nl> - * [ dialog ] ( api / browser / dialog . md ) <nl> - * [ ipc ( browser ) ] ( api / browser / ipc - browser . md ) <nl> - * [ menu ] ( api / browser / menu . md ) <nl> - * [ menu - item ] ( api / browser / menu - item . md ) <nl> - * [ power - monitor ] ( api / browser / power - monitor . md ) <nl> - * [ protocol ] ( api / browser / protocol . md ) <nl> + * [ ipc ( renderer ) ] ( api / ipc - renderer . md ) <nl> + * [ remote ] ( api / remote . md ) <nl> <nl> Common modules : <nl> <nl> - * [ clipboard ] ( api / common / clipboard . md ) <nl> - * [ crash - reporter ] ( api / common / crash - reporter . md ) <nl> - * [ screen ] ( api / common / screen . md ) <nl> - * [ shell ] ( api / common / shell . md ) <nl> + * [ clipboard ] ( api / clipboard . md ) <nl> + * [ crash - reporter ] ( api / crash - reporter . md ) <nl> + * [ screen ] ( api / screen . md ) <nl> + * [ shell ] ( api / shell . md ) <nl> similarity index 100 % <nl> rename from docs / api / browser / app . md <nl> rename to docs / api / app . md <nl> similarity index 100 % <nl> rename from docs / api / browser / auto - updater . md <nl> rename to docs / api / auto - updater . md <nl> similarity index 99 % <nl> rename from docs / api / browser / browser - window . md <nl> rename to docs / api / browser - window . md <nl> mmm a / docs / api / browser / browser - window . md <nl> ppp b / docs / api / browser - window . md <nl> You can write received ` image ` directly to a ` . png ` file , or you can base64 <nl> encode it and use data URL to embed the image in HTML . <nl> <nl> * * Note : * * Be sure to read documents on remote buffer in <nl> - [ remote ] ( . . / renderer / remote . md ) if you are going to use this API in renderer <nl> + [ remote ] ( remote . md ) if you are going to use this API in renderer <nl> process . <nl> <nl> # # # BrowserWindow . loadUrl ( url ) <nl> similarity index 100 % <nl> rename from docs / api / common / clipboard . md <nl> rename to docs / api / clipboard . md <nl> similarity index 100 % <nl> rename from docs / api / common / crash - reporter . md <nl> rename to docs / api / crash - reporter . md <nl> similarity index 100 % <nl> rename from docs / api / browser / dialog . md <nl> rename to docs / api / dialog . md <nl> similarity index 100 % <nl> rename from docs / api / browser / frameless - window . md <nl> rename to docs / api / frameless - window . md <nl> similarity index 100 % <nl> rename from docs / api / browser / ipc - browser . md <nl> rename to docs / api / ipc - browser . md <nl> similarity index 93 % <nl> rename from docs / api / renderer / ipc - renderer . md <nl> rename to docs / api / ipc - renderer . md <nl> mmm a / docs / api / renderer / ipc - renderer . md <nl> ppp b / docs / api / ipc - renderer . md <nl> asynchronous messages to the browser , and also receive messages sent from <nl> browser . If you want to make use of modules of browser from renderer , you <nl> might consider using the [ remote ] ( remote . md ) module . <nl> <nl> - See [ ipc ( browser ) ] ( . . / browser / ipc - browser . md ) for examples . <nl> + See [ ipc ( browser ) ] ( ipc - browser . md ) for examples . <nl> <nl> # # ipc . send ( channel [ , args . . . ] ) <nl> <nl> similarity index 100 % <nl> rename from docs / api / browser / menu - item . md <nl> rename to docs / api / menu - item . md <nl> similarity index 100 % <nl> rename from docs / api / browser / menu . md <nl> rename to docs / api / menu . md <nl> similarity index 100 % <nl> rename from docs / api / browser / power - monitor . md <nl> rename to docs / api / power - monitor . md <nl> similarity index 100 % <nl> rename from docs / api / browser / protocol . md <nl> rename to docs / api / protocol . md <nl> similarity index 98 % <nl> rename from docs / api / renderer / remote . md <nl> rename to docs / api / remote . md <nl> mmm a / docs / api / renderer / remote . md <nl> ppp b / docs / api / remote . md <nl> Returns the object returned by ` require ( module ) ` in the browser process . <nl> <nl> # # remote . getCurrentWindow ( ) <nl> <nl> - Returns the [ BrowserWindow ] ( . . / browser / browser - window . md ) object which <nl> + Returns the [ BrowserWindow ] ( browser - window . md ) object which <nl> represents current window . <nl> <nl> # # remote . getGlobal ( name ) <nl> similarity index 100 % <nl> rename from docs / api / common / screen . md <nl> rename to docs / api / screen . md <nl> similarity index 100 % <nl> rename from docs / api / common / shell . md <nl> rename to docs / api / shell . md <nl> mmm a / docs / tutorial / quick - start . md <nl> ppp b / docs / tutorial / quick - start . md <nl> scripts . <nl> <nl> In traditional node . js applications , communication between server side and <nl> client side are usually done by web sockets . In atom - shell , we have provided <nl> - the [ ipc ] ( . . / api / renderer / ipc - renderer . md ) module for browser side to client <nl> - communication , and the [ remote ] ( . . / api / renderer / remote . md ) module for easy RPC <nl> + the [ ipc ] ( . . / api / ipc - renderer . md ) module for browser side to client <nl> + communication , and the [ remote ] ( . . / api / remote . md ) module for easy RPC <nl> support . <nl> <nl> # # # Web page and node . js <nl> in web pages so you could access native resources in web pages , just like <nl> <nl> But unlike node - webkit , you could not do native GUI related operations in web <nl> pages , instead you need to do them on the browser side by sending messages or <nl> - use the easy [ remote ] ( . . / api / renderer / remote . md ) module . <nl> + use the easy [ remote ] ( . . / api / remote . md ) module . <nl> <nl> <nl> # # Write your first atom - shell app <nl> similarity index 100 % <nl> rename from docs / tutorial / use - native - node - module . md <nl> rename to docs / tutorial / use - native - node - modules . md <nl>
: memo : Simpilify the structure of API references .
electron/electron
59339470001dbdeac97088eba047531d2632209d
2014-05-05T06:24:57Z
mmm a / tensorflow / tools / docs / generate2 . py <nl> ppp b / tensorflow / tools / docs / generate2 . py <nl> def build_docs ( output_dir , code_url_prefix , search_hints = True ) : <nl> base_dir = path . dirname ( tf . __file__ ) <nl> base_dirs = ( <nl> base_dir , <nl> - path . normpath ( path . join ( base_dir , " . . / . . / tensorflow " ) ) , <nl> + # External packages base directories , <nl> path . dirname ( tensorboard . __file__ ) , <nl> path . dirname ( tensorflow_estimator . __file__ ) , <nl> ) <nl>
Internal change
tensorflow/tensorflow
5581c1ca60d7979baefa66d6dbfb9d8697d9f23e
2019-05-01T01:40:47Z
mmm a / modules / core / src / parallel . cpp <nl> ppp b / modules / core / src / parallel . cpp <nl> <nl> <nl> # include " precomp . hpp " <nl> <nl> + # if defined __linux__ | | defined __APPLE__ <nl> + # include < unistd . h > <nl> + # include < stdio . h > <nl> + # include < sys / types . h > <nl> + # if defined ANDROID <nl> + # include < sys / sysconf . h > <nl> + # else <nl> + # include < sys / sysctl . h > <nl> + # endif <nl> + # endif <nl> + <nl> # ifdef _OPENMP <nl> # define HAVE_OPENMP <nl> # endif <nl> <nl> # include < omp . h > <nl> # elif defined HAVE_GCD <nl> # include < dispatch / dispatch . h > <nl> - # include < sys / sysctl . h > <nl> # include < pthread . h > <nl> # elif defined HAVE_CONCURRENCY <nl> # include < ppl . h > <nl>
Merge pull request from taka - no - me : parallel / fix - build - 2445
opencv/opencv
09abcd567e11924985b374ae9a4935051aeb9cb7
2012-10-19T10:57:08Z
mmm a / emscripten . py <nl> ppp b / emscripten . py <nl> def path_from_root ( * pathelems ) : <nl> " " " <nl> return os . path . join ( __rootpath__ , * pathelems ) <nl> <nl> + def get_configuration ( ) : <nl> + if hasattr ( get_configuration , ' configuration ' ) : <nl> + return get_configuration . configuration <nl> + <nl> + from tools import shared <nl> + configuration = shared . Configuration ( environ = os . environ ) <nl> + get_configuration . configuration = configuration <nl> + return configuration <nl> + <nl> def scan ( ll , settings ) : <nl> # blockaddress ( @ main , % 23 ) <nl> blockaddrs = [ ] <nl> def _main ( environ ) : <nl> else : <nl> relooper = None # use the cache <nl> <nl> - def get_configuration ( ) : <nl> - if hasattr ( get_configuration , ' configuration ' ) : <nl> - return get_configuration . configuration <nl> - <nl> - from tools import shared <nl> - configuration = shared . Configuration ( environ = os . environ ) <nl> - get_configuration . configuration = configuration <nl> - return configuration <nl> - <nl> if keywords . temp_dir is None : <nl> temp_files = get_configuration ( ) . get_temp_files ( ) <nl> else : <nl>
Merge pull request from waywardmonkeys / fix - get - configuration
emscripten-core/emscripten
2e989babe021ee8b08d3d75917e74f8f8b2c334a
2013-04-04T21:15:57Z
mmm a / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> ppp b / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> namespace { <nl> } <nl> <nl> float getRatio ( ) { <nl> + _ratio = 1 . 0f * _percent / _maxPercent ; <nl> return _ratio ; <nl> } <nl> <nl> bool AudioControlTest : : init ( ) <nl> float ratio = ( float ) slider - > getPercent ( ) / 100 ; <nl> ratio = clampf ( ratio , 0 . 0f , 1 . 0f ) ; <nl> AudioEngine : : setCurrentTime ( _audioID , _duration * ratio ) ; <nl> - slider - > setRatio ( ratio ) ; <nl> } <nl> case Slider : : EventType : : ON_SLIDEBALL_CANCEL : <nl> _updateTimeSlider = true ; <nl> mmm a / tests / js - tests / src / NativeTest / AudioEngineTest . js <nl> ppp b / tests / js - tests / src / NativeTest / AudioEngineTest . js <nl> var AudioEngineBase = BaseTestLayer . extend ( { <nl> } , <nl> onRestartCallback : function ( sender ) { <nl> var s = new cc . Scene ( ) ; <nl> - s . addChild ( FlowControl . current ( ) ) ; <nl> + s . addChild ( AudioTestFlow . current ( ) ) ; <nl> director . runScene ( s ) ; <nl> } , <nl> onNextCallback : function ( sender ) { <nl> var s = new cc . Scene ( ) ; <nl> - s . addChild ( FlowControl . next ( ) ) ; <nl> + s . addChild ( AudioTestFlow . next ( ) ) ; <nl> director . runScene ( s ) ; <nl> } , <nl> onBackCallback : function ( sender ) { <nl> var s = new cc . Scene ( ) ; <nl> - s . addChild ( FlowControl . previous ( ) ) ; <nl> + s . addChild ( AudioTestFlow . previous ( ) ) ; <nl> director . runScene ( s ) ; <nl> } , <nl> / / automation <nl> var TextButton = ccui . Button . extend ( { <nl> this . setTouchEnabled ( true ) ; <nl> this . loadTextures ( " ccs - res / cocosui / animationbuttonnormal . png " , " ccs - res / cocosui / animationbuttonpressed . png " , " " ) ; <nl> this . setTitleText ( text ) ; <nl> - this . addTouchEventListener ( callback , this ) ; <nl> + this . addClickEventListener ( callback ) ; <nl> } <nl> } ) ; <nl> <nl> var AudioControlTest = AudioEngineBase . extend ( { <nl> <nl> if ( self . _audioID ! = = jsb . AudioEngine . INVALID_AUDIO_ID ) { <nl> button . setEnabled ( false ) ; <nl> + button . setBright ( false ) ; <nl> jsb . AudioEngine . setFinishCallback ( self . _audioID , function ( id , filePath ) { <nl> self . _audioID = jsb . AudioEngine . INVALID_AUDIO_ID ; <nl> self . _playItem . setEnabled ( true ) ; <nl> + self . _playItem . setBright ( true ) ; <nl> <nl> self . _timeRatio = 0 ; <nl> self . _timeSlider . setRatio ( self . _timeRatio ) ; <nl> var AudioControlTest = AudioEngineBase . extend ( { <nl> <nl> self . _audioID = jsb . AudioEngine . INVALID_AUDIO_ID ; <nl> self . _playItem . setEnabled ( true ) ; <nl> + self . _playItem . setBright ( true ) ; <nl> } <nl> } ) ; <nl> stopItem . setPosition ( layerSize . width * 0 . 7 , layerSize . height * 0 . 8 ) ; <nl> var AudioControlTest = AudioEngineBase . extend ( { <nl> <nl> self . _audioID = jsb . AudioEngine . INVALID_AUDIO_ID ; <nl> self . _playItem . setEnabled ( true ) ; <nl> + self . _playItem . setBright ( true ) ; <nl> } ) ; <nl> uncacheItem . setPosition ( layerSize . width * 0 . 7 , layerSize . height * 0 . 6 ) ; <nl> this . addChild ( uncacheItem ) ; <nl> var AudioControlTest = AudioEngineBase . extend ( { <nl> } <nl> } ) ; <nl> <nl> + var TEST_COUNT = 10 <nl> + <nl> + var PlaySimultaneouslyTest = AudioEngineBase . extend ( { <nl> + _title : " Simultaneously play multiple audio " , <nl> + _files : null , <nl> + _playingcount : 0 , <nl> + <nl> + _playItem : null , <nl> + ctor : function ( ) { <nl> + this . _super ( ) ; <nl> + <nl> + var text , tmp = 81 , index , self = this ; <nl> + this . _files = [ ] ; <nl> + for ( index = 0 ; index < TEST_COUNT ; + + index ) { <nl> + this . _files . push ( " audio / SoundEffectsFX009 / FX0 " + ( tmp + index ) + " . mp3 " ) ; <nl> + } <nl> + <nl> + var playItem = new TextButton ( " play - simultaneously " , function ( button ) { <nl> + var audioId ; <nl> + self . _playingcount = 0 ; <nl> + button . setEnabled ( false ) ; <nl> + button . setBright ( false ) ; <nl> + var startTime = Date . now ( ) ; <nl> + cc . log ( startTime ) ; <nl> + for ( index = 0 ; index < TEST_COUNT ; + + index ) { <nl> + audioId = jsb . AudioEngine . play2d ( self . _files [ index ] ) ; <nl> + if ( audioId ! = jsb . AudioEngine . INVALID_AUDIO_ID ) { <nl> + self . _playingcount + = 1 ; <nl> + <nl> + jsb . AudioEngine . setFinishCallback ( audioId , function ( id , filePath ) { <nl> + self . _playingcount - = 1 ; <nl> + if ( self . _playingcount < = 0 ) { <nl> + self . _playItem . setEnabled ( true ) ; <nl> + self . _playItem . setBright ( true ) ; <nl> + } <nl> + } ) ; <nl> + } <nl> + else { <nl> + cc . log ( " Fail to play file : " + self . _files [ index ] ) ; <nl> + } <nl> + } <nl> + var diff = Date . now ( ) - startTime ; <nl> + cc . log ( " Diff time : " + diff ) ; <nl> + } ) ; <nl> + playItem . setNormalizedPosition ( cc . p ( 0 . 5 , 0 . 5 ) ) ; <nl> + this . addChild ( playItem ) ; <nl> + this . _playItem = playItem ; <nl> + } <nl> + } ) ; <nl> + <nl> + var FILE_COUNT = 2 ; <nl> + <nl> + var AudioProfileTest = AudioEngineBase . extend ( { <nl> + _title : " AudioProfileTest " , <nl> + _subtitle : " See the console . " , <nl> + _minDelay : 1 , <nl> + _time : 0 , <nl> + _audioCount : 0 , <nl> + <nl> + _files : null , <nl> + _audioProfile : null , <nl> + _showLabel : null , <nl> + ctor : function ( ) { <nl> + this . _super ( ) ; <nl> + <nl> + var text ; <nl> + this . _files = [ ] ; <nl> + this . _files . push ( " background . mp3 " ) ; <nl> + if ( cc . sys . os = = cc . sys . OS_IOS | | cc . sys . os = = cc . sys . OS_OSX ) <nl> + this . _files . push ( " background . caf " ) ; <nl> + else <nl> + this . _files . push ( " background . ogg " ) ; <nl> + <nl> + this . _audioProfile = new jsb . AudioProfile ( ) ; <nl> + this . _audioProfile . name = " AudioProfileTest " ; <nl> + this . _audioProfile . maxInstances = 3 ; <nl> + this . _audioProfile . minDelay = 1 . 0 ; <nl> + <nl> + var pos = cc . p ( 0 . 5 , 0 . 7 ) , index , self = this ; <nl> + for ( index = 0 ; index < FILE_COUNT ; + + index ) { <nl> + text = " play " + this . _files [ index ] ; <nl> + <nl> + var playItem = new TextButton ( text , function ( button ) { <nl> + var index = button . getTag ( ) ; <nl> + var id = jsb . AudioEngine . play2d ( self . _files [ index ] , false , 1 , self . _audioProfile ) ; <nl> + if ( id ! = jsb . AudioEngine . INVALID_AUDIO_ID ) { <nl> + self . _time = self . _minDelay ; <nl> + self . _audioCount + = 1 ; <nl> + var show = " audio count : " + self . _audioCount ; <nl> + self . _showLabel . setString ( show ) ; <nl> + <nl> + jsb . AudioEngine . setFinishCallback ( id , function ( id , filePath ) { <nl> + self . _audioCount - = 1 ; <nl> + var show = " audio count : " + self . _audioCount ; <nl> + self . _showLabel . setString ( show ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + } ) ; <nl> + playItem . setTag ( index ) ; <nl> + playItem . setNormalizedPosition ( pos ) ; <nl> + this . addChild ( playItem ) ; <nl> + pos . y - = 0 . 15 ; <nl> + } <nl> + <nl> + var origin = cc . visibleRect . bottomLeft ; <nl> + var size = cc . winSize ; <nl> + <nl> + var profileInfoLabel = new cc . LabelTTF ( " AudioProfile Info : \ n max instance : 3 \ n minimum delay : 1 . 0 " , " Arial " , 12 ) ; <nl> + profileInfoLabel . setAnchorPoint ( cc . p ( 0 , 0 . 5 ) ) ; <nl> + profileInfoLabel . setPosition ( cc . p ( origin . x , origin . y + size . height * 0 . 65 ) ) ; <nl> + this . addChild ( profileInfoLabel ) ; <nl> + <nl> + this . _showLabel = new cc . LabelTTF ( " audio count : 0 " , " Arial " , 12 ) ; <nl> + this . _showLabel . setAnchorPoint ( cc . p ( 0 , 0 . 5 ) ) ; <nl> + this . _showLabel . setPosition ( cc . p ( origin . x , origin . y + size . height * 0 . 5 ) ) ; <nl> + this . addChild ( this . _showLabel ) ; <nl> + <nl> + var timeSlider = new Slider ( ) ; <nl> + timeSlider . setEnabled ( false ) ; <nl> + timeSlider . setNormalizedPosition ( pos ) ; <nl> + this . addChild ( timeSlider ) ; <nl> + this . _timeSlider = timeSlider ; <nl> + <nl> + this . schedule ( this . update , 0 . 05 ) ; <nl> + } , <nl> + <nl> + update : function ( dt ) { <nl> + if ( this . _time > 0 . 0 ) <nl> + { <nl> + this . _time - = dt ; <nl> + this . _timeSlider . setRatio ( this . _time / this . _minDelay ) ; <nl> + } <nl> + } <nl> + } ) ; <nl> + <nl> + var InvalidAudioFileTest = AudioEngineBase . extend ( { <nl> + _title : " Test invalid audio file " , <nl> + _subtitle : " Not crash , please see the console . " , <nl> + <nl> + ctor : function ( ) { <nl> + this . _super ( ) ; <nl> + <nl> + var playItem = new TextButton ( " play unsupported media type " , function ( button ) { <nl> + if ( cc . sys . os = = cc . sys . OS_IOS | | cc . sys . os = = cc . sys . OS_OSX ) { <nl> + jsb . AudioEngine . play2d ( " background . ogg " ) ; <nl> + } <nl> + else if ( cc . sys . os = = cc . sys . OS_ANDROID | | cc . sys . os = = cc . sys . OS_WINDOWS ) { <nl> + jsb . AudioEngine . play2d ( " background . caf " ) ; <nl> + } <nl> + } ) ; <nl> + playItem . setNormalizedPosition ( cc . p ( 0 . 5 , 0 . 6 ) ) ; <nl> + this . addChild ( playItem ) ; <nl> + <nl> + var playItem2 = new TextButton ( " play not - existent file " , function ( button ) { <nl> + jsb . AudioEngine . play2d ( " not - existent file . mp3 " ) ; <nl> + } ) ; <nl> + playItem2 . setNormalizedPosition ( cc . p ( 0 . 5 , 0 . 4 ) ) ; <nl> + this . addChild ( playItem2 ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + var LargeAudioFileTest = AudioEngineBase . extend ( { <nl> + _title : " Test large audio file " , <nl> + ctor : function ( ) { <nl> + this . _super ( ) ; <nl> + var playItem = new TextButton ( " play large audio file " , function ( button ) { <nl> + jsb . AudioEngine . play2d ( " audio / LuckyDay . mp3 " ) ; <nl> + } ) ; <nl> + playItem . setNormalizedPosition ( cc . p ( 0 . 5 , 0 . 5 ) ) ; <nl> + this . addChild ( playItem ) ; <nl> + } <nl> + } ) <nl> + <nl> window . AudioTestFlow = new FlowControl ( [ <nl> AudioControlTest , <nl> - / / PlaySimultaneouslyTest , <nl> - / / AudioProfileTest , <nl> - / / InvalidAudioFileTest , <nl> - / / LargeAudioFileTest <nl> + PlaySimultaneouslyTest , <nl> + AudioProfileTest , <nl> + InvalidAudioFileTest , <nl> + LargeAudioFileTest <nl> ] ) ; <nl> <nl> - } ) ( window ) ; <nl> \ No newline at end of file <nl> + } ) ( window ) ; <nl>
Complete AudioEngineTest
cocos2d/cocos2d-x
8d8c7fe14bfa7fd6c7c3b2211984689dd10e1acb
2015-07-30T09:14:08Z
mmm a / src / base / bittorrent / trackerentry . h <nl> ppp b / src / base / bittorrent / trackerentry . h <nl> namespace BitTorrent <nl> public : <nl> enum Status <nl> { <nl> - NotContacted , <nl> - Working , <nl> - Updating , <nl> - NotWorking <nl> + NotContacted = 1 , <nl> + Working = 2 , <nl> + Updating = 3 , <nl> + NotWorking = 4 <nl> } ; <nl> <nl> TrackerEntry ( const QString & url ) ; <nl> mmm a / src / gui / properties / trackerlistwidget . cpp <nl> ppp b / src / gui / properties / trackerlistwidget . cpp <nl> TrackerListWidget : : TrackerListWidget ( PropertiesWidget * properties ) <nl> insertTopLevelItem ( 2 , m_LSDItem ) ; <nl> setRowColor ( 2 , QColor ( " grey " ) ) ; <nl> / / Set static items alignment <nl> - m_DHTItem - > setTextAlignment ( COL_RECEIVED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - m_PEXItem - > setTextAlignment ( COL_RECEIVED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - m_LSDItem - > setTextAlignment ( COL_RECEIVED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - m_DHTItem - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - m_PEXItem - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - m_LSDItem - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> m_DHTItem - > setTextAlignment ( COL_PEERS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> m_PEXItem - > setTextAlignment ( COL_PEERS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> m_LSDItem - > setTextAlignment ( COL_PEERS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + m_DHTItem - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + m_PEXItem - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + m_LSDItem - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + m_DHTItem - > setTextAlignment ( COL_LEECHES , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + m_PEXItem - > setTextAlignment ( COL_LEECHES , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + m_LSDItem - > setTextAlignment ( COL_LEECHES , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> m_DHTItem - > setTextAlignment ( COL_DOWNLOADED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> m_PEXItem - > setTextAlignment ( COL_DOWNLOADED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> m_LSDItem - > setTextAlignment ( COL_DOWNLOADED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> / / Set header alignment <nl> headerItem ( ) - > setTextAlignment ( COL_TIER , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - headerItem ( ) - > setTextAlignment ( COL_RECEIVED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - headerItem ( ) - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> headerItem ( ) - > setTextAlignment ( COL_PEERS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + headerItem ( ) - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + headerItem ( ) - > setTextAlignment ( COL_LEECHES , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> headerItem ( ) - > setTextAlignment ( COL_DOWNLOADED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> / / Set hotkeys <nl> m_editHotkey = new QShortcut ( Qt : : Key_F2 , this , nullptr , nullptr , Qt : : WidgetShortcut ) ; <nl> void TrackerListWidget : : clear ( ) <nl> m_trackerItems . clear ( ) ; <nl> m_DHTItem - > setText ( COL_STATUS , " " ) ; <nl> m_DHTItem - > setText ( COL_SEEDS , " " ) ; <nl> - m_DHTItem - > setText ( COL_PEERS , " " ) ; <nl> + m_DHTItem - > setText ( COL_LEECHES , " " ) ; <nl> m_DHTItem - > setText ( COL_MSG , " " ) ; <nl> m_PEXItem - > setText ( COL_STATUS , " " ) ; <nl> m_PEXItem - > setText ( COL_SEEDS , " " ) ; <nl> - m_PEXItem - > setText ( COL_PEERS , " " ) ; <nl> + m_PEXItem - > setText ( COL_LEECHES , " " ) ; <nl> m_PEXItem - > setText ( COL_MSG , " " ) ; <nl> m_LSDItem - > setText ( COL_STATUS , " " ) ; <nl> m_LSDItem - > setText ( COL_SEEDS , " " ) ; <nl> - m_LSDItem - > setText ( COL_PEERS , " " ) ; <nl> + m_LSDItem - > setText ( COL_LEECHES , " " ) ; <nl> m_LSDItem - > setText ( COL_MSG , " " ) ; <nl> } <nl> <nl> void TrackerListWidget : : loadStickyItems ( BitTorrent : : TorrentHandle * const torrent <nl> } <nl> <nl> m_DHTItem - > setText ( COL_SEEDS , QString : : number ( seedsDHT ) ) ; <nl> - m_DHTItem - > setText ( COL_PEERS , QString : : number ( peersDHT ) ) ; <nl> + m_DHTItem - > setText ( COL_LEECHES , QString : : number ( peersDHT ) ) ; <nl> m_PEXItem - > setText ( COL_SEEDS , QString : : number ( seedsPeX ) ) ; <nl> - m_PEXItem - > setText ( COL_PEERS , QString : : number ( peersPeX ) ) ; <nl> + m_PEXItem - > setText ( COL_LEECHES , QString : : number ( peersPeX ) ) ; <nl> m_LSDItem - > setText ( COL_SEEDS , QString : : number ( seedsLSD ) ) ; <nl> - m_LSDItem - > setText ( COL_PEERS , QString : : number ( peersLSD ) ) ; <nl> + m_LSDItem - > setText ( COL_LEECHES , QString : : number ( peersLSD ) ) ; <nl> } <nl> <nl> void TrackerListWidget : : loadTrackers ( ) <nl> void TrackerListWidget : : loadTrackers ( ) <nl> break ; <nl> } <nl> <nl> - item - > setText ( COL_RECEIVED , QString : : number ( data . numPeers ) ) ; <nl> - # if LIBTORRENT_VERSION_NUM > = 10000 <nl> + item - > setText ( COL_PEERS , QString : : number ( data . numPeers ) ) ; <nl> item - > setText ( COL_SEEDS , ( entry . nativeEntry ( ) . scrape_complete > - 1 ) ? QString : : number ( entry . nativeEntry ( ) . scrape_complete ) : tr ( " N / A " ) ) ; <nl> - item - > setText ( COL_PEERS , ( entry . nativeEntry ( ) . scrape_incomplete > - 1 ) ? QString : : number ( entry . nativeEntry ( ) . scrape_incomplete ) : tr ( " N / A " ) ) ; <nl> + item - > setText ( COL_LEECHES , ( entry . nativeEntry ( ) . scrape_incomplete > - 1 ) ? QString : : number ( entry . nativeEntry ( ) . scrape_incomplete ) : tr ( " N / A " ) ) ; <nl> item - > setText ( COL_DOWNLOADED , ( entry . nativeEntry ( ) . scrape_downloaded > - 1 ) ? QString : : number ( entry . nativeEntry ( ) . scrape_downloaded ) : tr ( " N / A " ) ) ; <nl> - # else <nl> - item - > setText ( COL_SEEDS , tr ( " N / A " ) ) ; <nl> - item - > setText ( COL_PEERS , tr ( " N / A " ) ) ; <nl> - item - > setText ( COL_DOWNLOADED , tr ( " N / A " ) ) ; <nl> - # endif <nl> <nl> item - > setTextAlignment ( COL_TIER , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - item - > setTextAlignment ( COL_RECEIVED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> - item - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> item - > setTextAlignment ( COL_PEERS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + item - > setTextAlignment ( COL_SEEDS , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> + item - > setTextAlignment ( COL_LEECHES , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> item - > setTextAlignment ( COL_DOWNLOADED , ( Qt : : AlignRight | Qt : : AlignVCenter ) ) ; <nl> } <nl> / / Remove old trackers <nl> void TrackerListWidget : : showTrackerListMenu ( QPoint ) <nl> QAction * delAct = nullptr ; <nl> QAction * editAct = nullptr ; <nl> if ( ! getSelectedTrackerItems ( ) . isEmpty ( ) ) { <nl> + editAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " edit - rename " ) , tr ( " Edit tracker URL . . . " ) ) ; <nl> delAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " list - remove " ) , tr ( " Remove tracker " ) ) ; <nl> copyAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " edit - copy " ) , tr ( " Copy tracker URL " ) ) ; <nl> - editAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " edit - rename " ) , tr ( " Edit selected tracker URL " ) ) ; <nl> } <nl> QAction * reannounceSelAct = nullptr ; <nl> QAction * reannounceAllAct = nullptr ; <nl> QStringList TrackerListWidget : : headerLabels ( ) <nl> " # " <nl> , tr ( " URL " ) <nl> , tr ( " Status " ) <nl> - , tr ( " Received " ) <nl> - , tr ( " Seeds " ) <nl> , tr ( " Peers " ) <nl> + , tr ( " Seeds " ) <nl> + , tr ( " Leeches " ) <nl> , tr ( " Downloaded " ) <nl> , tr ( " Message " ) <nl> } ; <nl> mmm a / src / gui / properties / trackerlistwidget . h <nl> ppp b / src / gui / properties / trackerlistwidget . h <nl> class TrackerListWidget : public QTreeWidget <nl> COL_TIER , <nl> COL_URL , <nl> COL_STATUS , <nl> - COL_RECEIVED , <nl> - COL_SEEDS , <nl> COL_PEERS , <nl> + COL_SEEDS , <nl> + COL_LEECHES , <nl> COL_DOWNLOADED , <nl> COL_MSG , <nl> <nl> mmm a / src / webui / api / torrentscontroller . cpp <nl> ppp b / src / webui / api / torrentscontroller . cpp <nl> <nl> # include < QUrl > <nl> <nl> # include " base / bittorrent / filepriority . h " <nl> + # include " base / bittorrent / peerinfo . h " <nl> # include " base / bittorrent / session . h " <nl> # include " base / bittorrent / torrenthandle . h " <nl> # include " base / bittorrent / torrentinfo . h " <nl> <nl> / / Tracker keys <nl> const char KEY_TRACKER_URL [ ] = " url " ; <nl> const char KEY_TRACKER_STATUS [ ] = " status " ; <nl> + const char KEY_TRACKER_TIER [ ] = " tier " ; <nl> const char KEY_TRACKER_MSG [ ] = " msg " ; <nl> - const char KEY_TRACKER_PEERS [ ] = " num_peers " ; <nl> + const char KEY_TRACKER_PEERS_COUNT [ ] = " num_peers " ; <nl> + const char KEY_TRACKER_SEEDS_COUNT [ ] = " num_seeds " ; <nl> + const char KEY_TRACKER_LEECHES_COUNT [ ] = " num_leeches " ; <nl> + const char KEY_TRACKER_DOWNLOADED_COUNT [ ] = " num_downloaded " ; <nl> <nl> / / Web seed keys <nl> const char KEY_WEBSEED_URL [ ] = " url " ; <nl> namespace <nl> void applyToTorrents ( const QStringList & hashes , const std : : function < void ( BitTorrent : : TorrentHandle * torrent ) > & func ) <nl> { <nl> if ( ( hashes . size ( ) = = 1 ) & & ( hashes [ 0 ] = = QLatin1String ( " all " ) ) ) { <nl> - for ( BitTorrent : : TorrentHandle * torrent : asConst ( BitTorrent : : Session : : instance ( ) - > torrents ( ) ) ) <nl> + for ( BitTorrent : : TorrentHandle * const torrent : asConst ( BitTorrent : : Session : : instance ( ) - > torrents ( ) ) ) <nl> func ( torrent ) ; <nl> } <nl> else { <nl> for ( const QString & hash : hashes ) { <nl> - BitTorrent : : TorrentHandle * torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> + BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> if ( torrent ) <nl> func ( torrent ) ; <nl> } <nl> } <nl> } <nl> + <nl> + QVariantList getStickyTrackers ( const BitTorrent : : TorrentHandle * const torrent ) <nl> + { <nl> + uint seedsDHT = 0 , seedsPeX = 0 , seedsLSD = 0 , leechesDHT = 0 , leechesPeX = 0 , leechesLSD = 0 ; <nl> + for ( const BitTorrent : : PeerInfo & peer : torrent - > peers ( ) ) { <nl> + if ( peer . isConnecting ( ) ) continue ; <nl> + <nl> + if ( peer . isSeed ( ) ) { <nl> + if ( peer . fromDHT ( ) ) <nl> + + + seedsDHT ; <nl> + if ( peer . fromPeX ( ) ) <nl> + + + seedsPeX ; <nl> + if ( peer . fromLSD ( ) ) <nl> + + + seedsLSD ; <nl> + } <nl> + else { <nl> + if ( peer . fromDHT ( ) ) <nl> + + + leechesDHT ; <nl> + if ( peer . fromPeX ( ) ) <nl> + + + leechesPeX ; <nl> + if ( peer . fromLSD ( ) ) <nl> + + + leechesLSD ; <nl> + } <nl> + } <nl> + <nl> + const int working = static_cast < int > ( BitTorrent : : TrackerEntry : : Working ) ; <nl> + const int disabled = 0 ; <nl> + <nl> + const QString privateMsg { QCoreApplication : : translate ( " TrackerListWidget " , " This torrent is private " ) } ; <nl> + const bool isTorrentPrivate = torrent - > isPrivate ( ) ; <nl> + <nl> + const QVariantMap dht { <nl> + { KEY_TRACKER_URL , " * * [ DHT ] * * " } , <nl> + { KEY_TRACKER_TIER , " " } , <nl> + { KEY_TRACKER_MSG , ( isTorrentPrivate ? privateMsg : " " ) } , <nl> + { KEY_TRACKER_STATUS , ( ( BitTorrent : : Session : : instance ( ) - > isDHTEnabled ( ) & & ! isTorrentPrivate ) ? working : disabled ) } , <nl> + { KEY_TRACKER_PEERS_COUNT , 0 } , <nl> + { KEY_TRACKER_DOWNLOADED_COUNT , 0 } , <nl> + { KEY_TRACKER_SEEDS_COUNT , seedsDHT } , <nl> + { KEY_TRACKER_LEECHES_COUNT , leechesDHT } <nl> + } ; <nl> + <nl> + const QVariantMap pex { <nl> + { KEY_TRACKER_URL , " * * [ PeX ] * * " } , <nl> + { KEY_TRACKER_TIER , " " } , <nl> + { KEY_TRACKER_MSG , ( isTorrentPrivate ? privateMsg : " " ) } , <nl> + { KEY_TRACKER_STATUS , ( ( BitTorrent : : Session : : instance ( ) - > isPeXEnabled ( ) & & ! isTorrentPrivate ) ? working : disabled ) } , <nl> + { KEY_TRACKER_PEERS_COUNT , 0 } , <nl> + { KEY_TRACKER_DOWNLOADED_COUNT , 0 } , <nl> + { KEY_TRACKER_SEEDS_COUNT , seedsPeX } , <nl> + { KEY_TRACKER_LEECHES_COUNT , leechesPeX } <nl> + } ; <nl> + <nl> + const QVariantMap lsd { <nl> + { KEY_TRACKER_URL , " * * [ LSD ] * * " } , <nl> + { KEY_TRACKER_TIER , " " } , <nl> + { KEY_TRACKER_MSG , ( isTorrentPrivate ? privateMsg : " " ) } , <nl> + { KEY_TRACKER_STATUS , ( ( BitTorrent : : Session : : instance ( ) - > isLSDEnabled ( ) & & ! isTorrentPrivate ) ? working : disabled ) } , <nl> + { KEY_TRACKER_PEERS_COUNT , 0 } , <nl> + { KEY_TRACKER_DOWNLOADED_COUNT , 0 } , <nl> + { KEY_TRACKER_SEEDS_COUNT , seedsLSD } , <nl> + { KEY_TRACKER_LEECHES_COUNT , leechesLSD } <nl> + } ; <nl> + <nl> + return QVariantList { dht , pex , lsd } ; <nl> + } <nl> } <nl> <nl> / / Returns all the torrents in JSON format . <nl> void TorrentsController : : propertiesAction ( ) <nl> / / The dictionary keys are : <nl> / / - " url " : Tracker URL <nl> / / - " status " : Tracker status <nl> - / / - " num_peers " : Tracker peer count <nl> + / / - " tier " : Tracker tier <nl> + / / - " num_peers " : Number of peers this torrent is currently connected to <nl> + / / - " num_seeds " : Number of peers that have the whole file <nl> + / / - " num_leeches " : Number of peers that are still downloading <nl> + / / - " num_downloaded " : Tracker downloaded count <nl> / / - " msg " : Tracker message ( last ) <nl> void TorrentsController : : trackersAction ( ) <nl> { <nl> checkParams ( { " hash " } ) ; <nl> <nl> const QString hash { params ( ) [ " hash " ] } ; <nl> - QVariantList trackerList ; <nl> - BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> + const BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> if ( ! torrent ) <nl> throw APIError ( APIErrorType : : NotFound ) ; <nl> <nl> + QVariantList trackerList = getStickyTrackers ( torrent ) ; <nl> + <nl> QHash < QString , BitTorrent : : TrackerInfo > trackersData = torrent - > trackerInfos ( ) ; <nl> for ( const BitTorrent : : TrackerEntry & tracker : asConst ( torrent - > trackers ( ) ) ) { <nl> - QVariantMap trackerDict ; <nl> - trackerDict [ KEY_TRACKER_URL ] = tracker . url ( ) ; <nl> const BitTorrent : : TrackerInfo data = trackersData . value ( tracker . url ( ) ) ; <nl> - QString status ; <nl> - switch ( tracker . status ( ) ) { <nl> - case BitTorrent : : TrackerEntry : : NotContacted : <nl> - status = tr ( " Not contacted yet " ) ; break ; <nl> - case BitTorrent : : TrackerEntry : : Updating : <nl> - status = tr ( " Updating . . . " ) ; break ; <nl> - case BitTorrent : : TrackerEntry : : Working : <nl> - status = tr ( " Working " ) ; break ; <nl> - case BitTorrent : : TrackerEntry : : NotWorking : <nl> - status = tr ( " Not working " ) ; break ; <nl> - } <nl> - trackerDict [ KEY_TRACKER_STATUS ] = status ; <nl> - trackerDict [ KEY_TRACKER_PEERS ] = data . numPeers ; <nl> - trackerDict [ KEY_TRACKER_MSG ] = data . lastMessage . trimmed ( ) ; <nl> <nl> - trackerList . append ( trackerDict ) ; <nl> + trackerList < < QVariantMap { <nl> + { KEY_TRACKER_URL , tracker . url ( ) } , <nl> + { KEY_TRACKER_TIER , tracker . tier ( ) } , <nl> + { KEY_TRACKER_STATUS , static_cast < int > ( tracker . status ( ) ) } , <nl> + { KEY_TRACKER_PEERS_COUNT , data . numPeers } , <nl> + { KEY_TRACKER_MSG , data . lastMessage . trimmed ( ) } , <nl> + { KEY_TRACKER_SEEDS_COUNT , tracker . nativeEntry ( ) . scrape_complete } , <nl> + { KEY_TRACKER_LEECHES_COUNT , tracker . nativeEntry ( ) . scrape_incomplete } , <nl> + { KEY_TRACKER_DOWNLOADED_COUNT , tracker . nativeEntry ( ) . scrape_downloaded } <nl> + } ; <nl> } <nl> <nl> setResult ( QJsonArray : : fromVariantList ( trackerList ) ) ; <nl> void TorrentsController : : addTrackersAction ( ) <nl> const QString hash = params ( ) [ " hash " ] ; <nl> <nl> BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> - if ( torrent ) { <nl> - QList < BitTorrent : : TrackerEntry > trackers ; <nl> - for ( QString url : asConst ( params ( ) [ " urls " ] . split ( ' \ n ' ) ) ) { <nl> - url = url . trimmed ( ) ; <nl> - if ( ! url . isEmpty ( ) ) <nl> - trackers < < url ; <nl> + if ( ! torrent ) <nl> + throw APIError ( APIErrorType : : NotFound ) ; <nl> + <nl> + QList < BitTorrent : : TrackerEntry > trackers ; <nl> + for ( const QString & urlStr : asConst ( params ( ) [ " urls " ] . split ( ' \ n ' ) ) ) { <nl> + const QUrl url { urlStr . trimmed ( ) } ; <nl> + if ( url . isValid ( ) ) <nl> + trackers < < url . toString ( ) ; <nl> + } <nl> + torrent - > addTrackers ( trackers ) ; <nl> + } <nl> + <nl> + void TorrentsController : : editTrackerAction ( ) <nl> + { <nl> + checkParams ( { " hash " , " origUrl " , " newUrl " } ) ; <nl> + <nl> + const QString hash = params ( ) [ " hash " ] ; <nl> + const QString origUrl = params ( ) [ " origUrl " ] ; <nl> + const QString newUrl = params ( ) [ " newUrl " ] ; <nl> + <nl> + BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> + if ( ! torrent ) <nl> + throw APIError ( APIErrorType : : NotFound ) ; <nl> + <nl> + const QUrl origTrackerUrl ( origUrl ) ; <nl> + const QUrl newTrackerUrl ( newUrl ) ; <nl> + if ( origTrackerUrl = = newTrackerUrl ) <nl> + return ; <nl> + if ( ! newTrackerUrl . isValid ( ) ) <nl> + throw APIError ( APIErrorType : : BadParams , " New tracker URL is invalid " ) ; <nl> + <nl> + QList < BitTorrent : : TrackerEntry > trackers = torrent - > trackers ( ) ; <nl> + bool match = false ; <nl> + for ( BitTorrent : : TrackerEntry & tracker : trackers ) { <nl> + const QUrl trackerUrl ( tracker . url ( ) ) ; <nl> + if ( trackerUrl = = newTrackerUrl ) <nl> + throw APIError ( APIErrorType : : Conflict , " New tracker URL already exists " ) ; <nl> + if ( trackerUrl = = origTrackerUrl ) { <nl> + match = true ; <nl> + BitTorrent : : TrackerEntry newTracker ( newTrackerUrl . toString ( ) ) ; <nl> + newTracker . setTier ( tracker . tier ( ) ) ; <nl> + tracker = newTracker ; <nl> } <nl> - torrent - > addTrackers ( trackers ) ; <nl> } <nl> + if ( ! match ) <nl> + throw APIError ( APIErrorType : : Conflict , " Tracker not found " ) ; <nl> + <nl> + torrent - > replaceTrackers ( trackers ) ; <nl> + if ( ! torrent - > isPaused ( ) ) <nl> + torrent - > forceReannounce ( ) ; <nl> + } <nl> + <nl> + void TorrentsController : : removeTrackersAction ( ) <nl> + { <nl> + checkParams ( { " hash " , " urls " } ) ; <nl> + <nl> + const QString hash = params ( ) [ " hash " ] ; <nl> + const QStringList urls = params ( ) [ " urls " ] . split ( ' | ' ) ; <nl> + <nl> + BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> + if ( ! torrent ) <nl> + throw APIError ( APIErrorType : : NotFound ) ; <nl> + <nl> + QList < BitTorrent : : TrackerEntry > remainingTrackers ; <nl> + const QList < BitTorrent : : TrackerEntry > trackers = torrent - > trackers ( ) ; <nl> + for ( const BitTorrent : : TrackerEntry & entry : trackers ) { <nl> + if ( ! urls . contains ( entry . url ( ) ) ) <nl> + remainingTrackers . push_back ( entry ) ; <nl> + } <nl> + <nl> + if ( remainingTrackers . size ( ) = = trackers . size ( ) ) <nl> + throw APIError ( APIErrorType : : Conflict , " No trackers were removed " ) ; <nl> + <nl> + torrent - > replaceTrackers ( remainingTrackers ) ; <nl> + if ( ! torrent - > isPaused ( ) ) <nl> + torrent - > forceReannounce ( ) ; <nl> } <nl> <nl> void TorrentsController : : pauseAction ( ) <nl> void TorrentsController : : pauseAction ( ) <nl> checkParams ( { " hashes " } ) ; <nl> <nl> const QStringList hashes = params ( ) [ " hashes " ] . split ( ' | ' ) ; <nl> - applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > pause ( ) ; } ) ; <nl> + applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > pause ( ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : resumeAction ( ) <nl> void TorrentsController : : resumeAction ( ) <nl> checkParams ( { " hashes " } ) ; <nl> <nl> const QStringList hashes = params ( ) [ " hashes " ] . split ( ' | ' ) ; <nl> - applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > resume ( ) ; } ) ; <nl> + applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > resume ( ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : filePrioAction ( ) <nl> void TorrentsController : : uploadLimitAction ( ) <nl> QVariantMap map ; <nl> for ( const QString & hash : hashes ) { <nl> int limit = - 1 ; <nl> - BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> + const BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> if ( torrent ) <nl> limit = torrent - > uploadLimit ( ) ; <nl> map [ hash ] = limit ; <nl> void TorrentsController : : downloadLimitAction ( ) <nl> QVariantMap map ; <nl> for ( const QString & hash : hashes ) { <nl> int limit = - 1 ; <nl> - BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> + const BitTorrent : : TorrentHandle * const torrent = BitTorrent : : Session : : instance ( ) - > findTorrent ( hash ) ; <nl> if ( torrent ) <nl> limit = torrent - > downloadLimit ( ) ; <nl> map [ hash ] = limit ; <nl> void TorrentsController : : setUploadLimitAction ( ) <nl> limit = - 1 ; <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ limit ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > setUploadLimit ( limit ) ; } ) ; <nl> + applyToTorrents ( hashes , [ limit ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > setUploadLimit ( limit ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : setDownloadLimitAction ( ) <nl> void TorrentsController : : setDownloadLimitAction ( ) <nl> limit = - 1 ; <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ limit ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > setDownloadLimit ( limit ) ; } ) ; <nl> + applyToTorrents ( hashes , [ limit ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > setDownloadLimit ( limit ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : setShareLimitsAction ( ) <nl> void TorrentsController : : setShareLimitsAction ( ) <nl> const qlonglong seedingTimeLimit = params ( ) [ " seedingTimeLimit " ] . toLongLong ( ) ; <nl> const QStringList hashes = params ( ) [ " hashes " ] . split ( ' | ' ) ; <nl> <nl> - applyToTorrents ( hashes , [ ratioLimit , seedingTimeLimit ] ( BitTorrent : : TorrentHandle * torrent ) <nl> + applyToTorrents ( hashes , [ ratioLimit , seedingTimeLimit ] ( BitTorrent : : TorrentHandle * const torrent ) <nl> { <nl> torrent - > setRatioLimit ( ratioLimit ) ; <nl> torrent - > setSeedingTimeLimit ( seedingTimeLimit ) ; <nl> void TorrentsController : : toggleSequentialDownloadAction ( ) <nl> checkParams ( { " hashes " } ) ; <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > toggleSequentialDownload ( ) ; } ) ; <nl> + applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > toggleSequentialDownload ( ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : toggleFirstLastPiecePrioAction ( ) <nl> void TorrentsController : : toggleFirstLastPiecePrioAction ( ) <nl> checkParams ( { " hashes " } ) ; <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > toggleFirstLastPiecePriority ( ) ; } ) ; <nl> + applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > toggleFirstLastPiecePriority ( ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : setSuperSeedingAction ( ) <nl> void TorrentsController : : setSuperSeedingAction ( ) <nl> <nl> const bool value { parseBool ( params ( ) [ " value " ] , false ) } ; <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ value ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > setSuperSeeding ( value ) ; } ) ; <nl> + applyToTorrents ( hashes , [ value ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > setSuperSeeding ( value ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : setForceStartAction ( ) <nl> void TorrentsController : : setForceStartAction ( ) <nl> <nl> const bool value { parseBool ( params ( ) [ " value " ] , false ) } ; <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ value ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > resume ( value ) ; } ) ; <nl> + applyToTorrents ( hashes , [ value ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > resume ( value ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : deleteAction ( ) <nl> void TorrentsController : : deleteAction ( ) <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> const bool deleteFiles { parseBool ( params ( ) [ " deleteFiles " ] , false ) } ; <nl> - applyToTorrents ( hashes , [ deleteFiles ] ( BitTorrent : : TorrentHandle * torrent ) <nl> + applyToTorrents ( hashes , [ deleteFiles ] ( BitTorrent : : TorrentHandle * const torrent ) <nl> { <nl> BitTorrent : : Session : : instance ( ) - > deleteTorrent ( torrent - > hash ( ) , deleteFiles ) ; <nl> } ) ; <nl> void TorrentsController : : setLocationAction ( ) <nl> if ( ! QFileInfo ( newLocation ) . isWritable ( ) ) <nl> throw APIError ( APIErrorType : : AccessDenied , tr ( " Cannot write to directory " ) ) ; <nl> <nl> - applyToTorrents ( hashes , [ newLocation ] ( BitTorrent : : TorrentHandle * torrent ) <nl> + applyToTorrents ( hashes , [ newLocation ] ( BitTorrent : : TorrentHandle * const torrent ) <nl> { <nl> LogMsg ( tr ( " WebUI Set location : moving \ " % 1 \ " , from \ " % 2 \ " to \ " % 3 \ " " ) <nl> . arg ( torrent - > name ( ) , Utils : : Fs : : toNativePath ( torrent - > savePath ( ) ) , Utils : : Fs : : toNativePath ( newLocation ) ) ) ; <nl> void TorrentsController : : setAutoManagementAction ( ) <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> const bool isEnabled { parseBool ( params ( ) [ " enable " ] , false ) } ; <nl> <nl> - applyToTorrents ( hashes , [ isEnabled ] ( BitTorrent : : TorrentHandle * torrent ) <nl> + applyToTorrents ( hashes , [ isEnabled ] ( BitTorrent : : TorrentHandle * const torrent ) <nl> { <nl> torrent - > setAutoTMMEnabled ( isEnabled ) ; <nl> } ) ; <nl> void TorrentsController : : recheckAction ( ) <nl> checkParams ( { " hashes " } ) ; <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > forceRecheck ( ) ; } ) ; <nl> + applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > forceRecheck ( ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : reannounceAction ( ) <nl> void TorrentsController : : reannounceAction ( ) <nl> checkParams ( { " hashes " } ) ; <nl> <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> - applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * torrent ) { torrent - > forceReannounce ( ) ; } ) ; <nl> + applyToTorrents ( hashes , [ ] ( BitTorrent : : TorrentHandle * const torrent ) { torrent - > forceReannounce ( ) ; } ) ; <nl> } <nl> <nl> void TorrentsController : : setCategoryAction ( ) <nl> void TorrentsController : : setCategoryAction ( ) <nl> const QStringList hashes { params ( ) [ " hashes " ] . split ( ' | ' ) } ; <nl> const QString category { params ( ) [ " category " ] . trimmed ( ) } ; <nl> <nl> - applyToTorrents ( hashes , [ category ] ( BitTorrent : : TorrentHandle * torrent ) <nl> + applyToTorrents ( hashes , [ category ] ( BitTorrent : : TorrentHandle * const torrent ) <nl> { <nl> if ( ! torrent - > setCategory ( category ) ) <nl> throw APIError ( APIErrorType : : Conflict , tr ( " Incorrect category name " ) ) ; <nl> mmm a / src / webui / api / torrentscontroller . h <nl> ppp b / src / webui / api / torrentscontroller . h <nl> private slots : <nl> void addAction ( ) ; <nl> void deleteAction ( ) ; <nl> void addTrackersAction ( ) ; <nl> + void editTrackerAction ( ) ; <nl> + void removeTrackersAction ( ) ; <nl> void filePrioAction ( ) ; <nl> void uploadLimitAction ( ) ; <nl> void downloadLimitAction ( ) ; <nl> mmm a / src / webui / webapplication . h <nl> ppp b / src / webui / webapplication . h <nl> <nl> # include " base / utils / net . h " <nl> # include " base / utils / version . h " <nl> <nl> - constexpr Utils : : Version < int , 3 , 2 > API_VERSION { 2 , 1 , 1 } ; <nl> - constexpr int COMPAT_API_VERSION = 22 ; <nl> - constexpr int COMPAT_API_VERSION_MIN = 21 ; <nl> + constexpr Utils : : Version < int , 3 , 2 > API_VERSION { 2 , 2 , 0 } ; <nl> + constexpr int COMPAT_API_VERSION = 23 ; <nl> + constexpr int COMPAT_API_VERSION_MIN = 23 ; <nl> <nl> class APIController ; <nl> class WebApplication ; <nl> mmm a / src / webui / www / private / addtrackers . html <nl> ppp b / src / webui / www / private / addtrackers . html <nl> <nl> < script src = " scripts / lib / mootools - 1 . 2 - more . js " > < / script > <nl> < script > <nl> window . addEvent ( ' domready ' , function ( ) { <nl> + var setLocationKeyboardEvents = new Keyboard ( { <nl> + defaultEventType : ' keydown ' , <nl> + events : { <nl> + ' enter ' : function ( event ) { <nl> + $ ( ' addTrackersButton ' ) . click ( ) ; <nl> + event . preventDefault ( ) ; <nl> + } <nl> + } <nl> + } ) ; <nl> + setLocationKeyboardEvents . activate ( ) ; <nl> + <nl> $ ( ' trackersUrls ' ) . focus ( ) ; <nl> $ ( ' addTrackersButton ' ) . addEvent ( ' click ' , function ( e ) { <nl> new Event ( e ) . stop ( ) ; <nl> mmm a / src / webui / www / private / css / style . css <nl> ppp b / src / webui / www / private / css / style . css <nl> td . generalLabel { <nl> line - height : 25px ; <nl> } <nl> <nl> - # addTrackersPlus { <nl> - width : 16px ; <nl> - cursor : pointer ; <nl> - margin - bottom : - 3px ; <nl> - } <nl> - <nl> . unselectable { <nl> - webkit - touch - callout : none ; <nl> - webkit - user - select : none ; <nl> new file mode 100644 <nl> index 0000000000 . . 7e1d8076f2 <nl> mmm / dev / null <nl> ppp b / src / webui / www / private / edittracker . html <nl> <nl> + < ! DOCTYPE html > <nl> + < html lang = " $ { LANG } " > <nl> + <nl> + < head > <nl> + < meta charset = " UTF - 8 " / > <nl> + < title > QBT_TR ( Tracker editing ) QBT_TR [ CONTEXT = TrackerListWidget ] < / title > <nl> + < link rel = " stylesheet " href = " css / style . css " type = " text / css " / > <nl> + < script src = " scripts / lib / mootools - 1 . 2 - core - yc . js " > < / script > <nl> + < script src = " scripts / lib / mootools - 1 . 2 - more . js " > < / script > <nl> + < script > <nl> + ' use strict ' ; <nl> + <nl> + window . addEvent ( ' domready ' , function ( ) { <nl> + var setLocationKeyboardEvents = new Keyboard ( { <nl> + defaultEventType : ' keydown ' , <nl> + events : { <nl> + ' enter ' : function ( event ) { <nl> + $ ( ' editTrackerButton ' ) . click ( ) ; <nl> + event . preventDefault ( ) ; <nl> + } <nl> + } <nl> + } ) ; <nl> + setLocationKeyboardEvents . activate ( ) ; <nl> + <nl> + var currentUrl = new URI ( ) . getData ( ' url ' ) ; <nl> + if ( ! currentUrl ) <nl> + return false ; <nl> + <nl> + var decodedUrl = decodeURIComponent ( currentUrl ) ; <nl> + $ ( ' trackerUrl ' ) . value = decodedUrl ; <nl> + $ ( ' trackerUrl ' ) . focus ( ) ; <nl> + <nl> + $ ( ' editTrackerButton ' ) . addEvent ( ' click ' , function ( e ) { <nl> + new Event ( e ) . stop ( ) ; <nl> + var hash = new URI ( ) . getData ( ' hash ' ) ; <nl> + new Request ( { <nl> + url : ' api / v2 / torrents / editTracker ' , <nl> + method : ' post ' , <nl> + data : { <nl> + hash : hash , <nl> + origUrl : decodedUrl , <nl> + newUrl : $ ( ' trackerUrl ' ) . value <nl> + } , <nl> + onComplete : function ( ) { <nl> + window . parent . closeWindows ( ) ; <nl> + } <nl> + } ) . send ( ) ; <nl> + } ) ; <nl> + } ) ; <nl> + < / script > <nl> + < / head > <nl> + <nl> + < body > <nl> + < div style = " text - align : center ; " > <nl> + < br / > <nl> + < h2 class = " vcenter " > QBT_TR ( Tracker URL : ) QBT_TR [ CONTEXT = TrackerListWidget ] < / h2 > <nl> + < div style = " text - align : center ; padding - top : 10px ; " > <nl> + < input id = " trackerUrl " style = " width : 90 % ; " / > <nl> + < / div > <nl> + < br / > <nl> + < input type = " button " value = " QBT_TR ( Edit ) QBT_TR [ CONTEXT = HttpServer ] " id = " editTrackerButton " / > <nl> + < / div > <nl> + < / body > <nl> + <nl> + < / html > <nl> mmm a / src / webui / www / private / index . html <nl> ppp b / src / webui / www / private / index . html <nl> < h1 class = " applicationTitle " > qBittorrent Web User Interface < span class = " version <nl> < li > < a href = " # PauseTorrentsByCategory " > < img src = " images / qbt - theme / media - playback - pause . svg " alt = " QBT_TR ( Pause torrents ) QBT_TR [ CONTEXT = CategoryFilterWidget ] " / > QBT_TR ( Pause torrents ) QBT_TR [ CONTEXT = CategoryFilterWidget ] < / a > < / li > <nl> < li > < a href = " # DeleteTorrentsByCategory " > < img src = " images / qbt - theme / edit - delete . svg " alt = " QBT_TR ( Delete torrents ) QBT_TR [ CONTEXT = CategoryFilterWidget ] " / > QBT_TR ( Delete torrents ) QBT_TR [ CONTEXT = CategoryFilterWidget ] < / a > < / li > <nl> < / ul > <nl> + < ul id = " torrentTrackersMenu " class = " contextMenu " > <nl> + < li > < a href = " # AddTracker " > < img src = " images / qbt - theme / list - add . svg " alt = " QBT_TR ( Add a new tracker . . . ) QBT_TR [ CONTEXT = TrackerListWidget ] " / > QBT_TR ( Add a new tracker . . . ) QBT_TR [ CONTEXT = TrackerListWidget ] < / a > < / li > <nl> + < li class = " separator " > < a href = " # EditTracker " > < img src = " images / qbt - theme / document - edit . svg " alt = " QBT_TR ( Edit tracker URL . . . ) QBT_TR [ CONTEXT = TrackerListWidget ] " / > QBT_TR ( Edit tracker URL . . . ) QBT_TR [ CONTEXT = TrackerListWidget ] < / a > < / li > <nl> + < li > < a href = " # RemoveTracker " > < img src = " images / qbt - theme / list - remove . svg " alt = " QBT_TR ( Remove tracker ) QBT_TR [ CONTEXT = TrackerListWidget ] " / > QBT_TR ( Remove tracker ) QBT_TR [ CONTEXT = TrackerListWidget ] < / a > < / li > <nl> + < li > < a href = " # CopyTrackerUrl " id = " CopyTrackerUrl " > < img src = " images / qbt - theme / edit - copy . svg " alt = " QBT_TR ( Copy tracker URL ) QBT_TR [ CONTEXT = TrackerListWidget ] " / > QBT_TR ( Copy tracker URL ) QBT_TR [ CONTEXT = TrackerListWidget ] < / a > < / li > <nl> + < / ul > <nl> < div id = " desktopFooterWrapper " > <nl> < div id = " desktopFooter " > <nl> < span id = " error_div " > < / span > <nl> mmm a / src / webui / www / private / properties_content . html <nl> ppp b / src / webui / www / private / properties_content . html <nl> <nl> < table class = " dynamicTable " style = " width : 100 % " > <nl> < thead > <nl> < tr > <nl> - < th style = " width : 30 % ; " > QBT_TR ( URL ) QBT_TR [ CONTEXT = TrackerListWidget ] < img src = " images / qbt - theme / list - add . svg " id = " addTrackersPlus " alt = " Add Trackers " / > < / th > <nl> + < th style = " width : 5 % ; " > QBT_TR ( # ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> + < th style = " width : 30 % ; " > QBT_TR ( URL ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> < th style = " width : 10 % ; " > QBT_TR ( Status ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> - < th style = " width : 10 % ; " > QBT_TR ( Peers ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> - < th style = " width : 50 % ; " > QBT_TR ( Message ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> + < th style = " width : 5 % ; " > QBT_TR ( Peers ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> + < th style = " width : 5 % ; " > QBT_TR ( Seeds ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> + < th style = " width : 5 % ; " > QBT_TR ( Leeches ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> + < th style = " width : 5 % ; " > QBT_TR ( Downloaded ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> + < th style = " width : 35 % ; " > QBT_TR ( Message ) QBT_TR [ CONTEXT = TrackerListWidget ] < / th > <nl> < / tr > <nl> < / thead > <nl> < tbody id = " trackersTable " > < / tbody > <nl> mmm a / src / webui / www / private / scripts / prop - trackers . js <nl> ppp b / src / webui / www / private / scripts / prop - trackers . js <nl> var trackersDynTable = new Class ( { <nl> <nl> initialize : function ( ) { } , <nl> <nl> - setup : function ( table ) { <nl> + setup : function ( table , contextMenu ) { <nl> this . table = $ ( table ) ; <nl> this . rows = new Hash ( ) ; <nl> + this . contextMenu = contextMenu ; <nl> } , <nl> <nl> removeRow : function ( url ) { <nl> var trackersDynTable = new Class ( { <nl> } , <nl> <nl> insertRow : function ( row ) { <nl> - var url = row [ 0 ] ; <nl> + var url = row [ 1 ] ; <nl> if ( this . rows . has ( url ) ) { <nl> var tableRow = this . rows . get ( url ) ; <nl> this . updateRow ( tableRow , row ) ; <nl> var trackersDynTable = new Class ( { <nl> td . set ( ' html ' , row [ i ] ) ; <nl> td . injectInside ( tr ) ; <nl> } <nl> + this . contextMenu . addTarget ( tr ) ; <nl> tr . injectInside ( this . table ) ; <nl> - } , <nl> + } <nl> } ) ; <nl> <nl> var current_hash = " " ; <nl> + var selectedTracker = " " ; <nl> <nl> var loadTrackersDataTimer ; <nl> var loadTrackersData = function ( ) { <nl> var loadTrackersData = function ( ) { <nl> } <nl> var new_hash = torrentsTable . getCurrentTorrentHash ( ) ; <nl> if ( new_hash = = = " " ) { <nl> - tTable . removeAllRows ( ) ; <nl> + torrentTrackersTable . removeAllRows ( ) ; <nl> clearTimeout ( loadTrackersDataTimer ) ; <nl> loadTrackersDataTimer = loadTrackersData . delay ( 10000 ) ; <nl> return ; <nl> } <nl> if ( new_hash ! = current_hash ) { <nl> - tTable . removeAllRows ( ) ; <nl> + torrentTrackersTable . removeAllRows ( ) ; <nl> current_hash = new_hash ; <nl> } <nl> var url = new URI ( ' api / v2 / torrents / trackers ? hash = ' + current_hash ) ; <nl> var loadTrackersData = function ( ) { <nl> } , <nl> onSuccess : function ( trackers ) { <nl> $ ( ' error_div ' ) . set ( ' html ' , ' ' ) ; <nl> + torrentTrackersTable . removeAllRows ( ) ; <nl> + <nl> if ( trackers ) { <nl> / / Update Trackers data <nl> trackers . each ( function ( tracker ) { <nl> - var row = [ ] ; <nl> - row . length = 4 ; <nl> - row [ 0 ] = escapeHtml ( tracker . url ) ; <nl> - row [ 1 ] = tracker . status ; <nl> - row [ 2 ] = tracker . num_peers ; <nl> - row [ 3 ] = escapeHtml ( tracker . msg ) ; <nl> - tTable . insertRow ( row ) ; <nl> + var status ; <nl> + switch ( tracker . status ) { <nl> + case 0 : <nl> + status = " QBT_TR ( Disabled ) QBT_TR [ CONTEXT = TrackerListWidget ] " ; <nl> + break ; <nl> + case 1 : <nl> + status = " QBT_TR ( Not contacted yet ) QBT_TR [ CONTEXT = TrackerListWidget ] " ; <nl> + break ; <nl> + case 2 : <nl> + status = " QBT_TR ( Working ) QBT_TR [ CONTEXT = TrackerListWidget ] " ; <nl> + break ; <nl> + case 3 : <nl> + status = " QBT_TR ( Updating . . . ) QBT_TR [ CONTEXT = TrackerListWidget ] " ; <nl> + break ; <nl> + case 4 : <nl> + status = " QBT_TR ( Not working ) QBT_TR [ CONTEXT = TrackerListWidget ] " ; <nl> + break ; <nl> + } <nl> + <nl> + var row = [ <nl> + tracker . tier , <nl> + escapeHtml ( tracker . url ) , <nl> + status , <nl> + tracker . num_peers , <nl> + ( tracker . num_seeds > = 0 ) ? tracker . num_seeds : " QBT_TR ( N / A ) QBT_TR [ CONTEXT = TrackerListWidget ] " , <nl> + ( tracker . num_leeches > = 0 ) ? tracker . num_leeches : " QBT_TR ( N / A ) QBT_TR [ CONTEXT = TrackerListWidget ] " , <nl> + ( tracker . num_downloaded > = 0 ) ? tracker . num_downloaded : " QBT_TR ( N / A ) QBT_TR [ CONTEXT = TrackerListWidget ] " , <nl> + escapeHtml ( tracker . msg ) <nl> + ] ; <nl> + <nl> + torrentTrackersTable . insertRow ( row ) ; <nl> } ) ; <nl> } <nl> - else { <nl> - tTable . removeAllRows ( ) ; <nl> - } <nl> clearTimeout ( loadTrackersDataTimer ) ; <nl> loadTrackersDataTimer = loadTrackersData . delay ( 10000 ) ; <nl> } <nl> var updateTrackersData = function ( ) { <nl> loadTrackersData ( ) ; <nl> } ; <nl> <nl> - tTable = new trackersDynTable ( ) ; <nl> - tTable . setup ( $ ( ' trackersTable ' ) ) ; <nl> + var torrentTrackersContextMenu = new ContextMenu ( { <nl> + targets : ' . torrentTrackersMenuTarget ' , <nl> + menu : ' torrentTrackersMenu ' , <nl> + actions : { <nl> + AddTracker : function ( element , ref ) { <nl> + addTrackerFN ( ) ; <nl> + } , <nl> + EditTracker : function ( element , ref ) { <nl> + editTrackerFN ( element ) ; <nl> + } , <nl> + RemoveTracker : function ( element , ref ) { <nl> + removeTrackerFN ( element ) ; <nl> + } <nl> + } , <nl> + offsets : { <nl> + x : - 15 , <nl> + y : 2 <nl> + } , <nl> + onShow : function ( ) { <nl> + var element = this . options . element ; <nl> + selectedTracker = element ; <nl> + if ( element . childNodes [ 1 ] . innerText . indexOf ( " * * [ " ) = = = 0 ) { <nl> + this . hideItem ( ' EditTracker ' ) ; <nl> + this . hideItem ( ' RemoveTracker ' ) ; <nl> + this . hideItem ( ' CopyTrackerUrl ' ) ; <nl> + } <nl> + else { <nl> + this . showItem ( ' EditTracker ' ) ; <nl> + this . showItem ( ' RemoveTracker ' ) ; <nl> + this . showItem ( ' CopyTrackerUrl ' ) ; <nl> + } <nl> + this . options . element . firstChild . click ( ) ; <nl> + } <nl> + } ) ; <nl> <nl> - / / Add trackers code <nl> - $ ( ' addTrackersPlus ' ) . addEvent ( ' click ' , function addTrackerDlg ( ) { <nl> + var addTrackerFN = function ( ) { <nl> if ( current_hash . length = = = 0 ) return ; <nl> new MochaUI . Window ( { <nl> id : ' trackersPage ' , <nl> $ ( ' addTrackersPlus ' ) . addEvent ( ' click ' , function addTrackerDlg ( ) { <nl> paddingVertical : 0 , <nl> paddingHorizontal : 0 , <nl> width : 500 , <nl> - height : 250 <nl> + height : 250 , <nl> + onCloseComplete : function ( ) { <nl> + updateTrackersData ( ) ; <nl> + } <nl> + } ) ; <nl> + } ; <nl> + <nl> + var editTrackerFN = function ( element ) { <nl> + if ( current_hash . length = = = 0 ) return ; <nl> + <nl> + var trackerUrl = encodeURIComponent ( element . childNodes [ 1 ] . innerText ) ; <nl> + new MochaUI . Window ( { <nl> + id : ' trackersPage ' , <nl> + title : " QBT_TR ( Tracker editing ) QBT_TR [ CONTEXT = TrackerListWidget ] " , <nl> + loadMethod : ' iframe ' , <nl> + contentURL : ' edittracker . html ? hash = ' + current_hash + ' & url = ' + trackerUrl , <nl> + scrollbars : true , <nl> + resizable : false , <nl> + maximizable : false , <nl> + closable : true , <nl> + paddingVertical : 0 , <nl> + paddingHorizontal : 0 , <nl> + width : 500 , <nl> + height : 150 , <nl> + onCloseComplete : function ( ) { <nl> + updateTrackersData ( ) ; <nl> + } <nl> } ) ; <nl> + } ; <nl> + <nl> + var removeTrackerFN = function ( element ) { <nl> + if ( current_hash . length = = = 0 ) return ; <nl> + <nl> + var trackerUrl = element . childNodes [ 1 ] . innerText ; <nl> + new Request ( { <nl> + url : ' api / v2 / torrents / removeTrackers ' , <nl> + method : ' post ' , <nl> + data : { <nl> + hash : current_hash , <nl> + urls : trackerUrl <nl> + } , <nl> + onSuccess : function ( ) { <nl> + updateTrackersData ( ) ; <nl> + } <nl> + } ) . send ( ) ; <nl> + } ; <nl> + <nl> + torrentTrackersTable = new trackersDynTable ( ) ; <nl> + torrentTrackersTable . setup ( $ ( ' trackersTable ' ) , torrentTrackersContextMenu ) ; <nl> + <nl> + new ClipboardJS ( ' # CopyTrackerUrl ' , { <nl> + text : function ( trigger ) { <nl> + if ( selectedTracker ) { <nl> + var url = selectedTracker . childNodes [ 1 ] . innerText ; <nl> + selectedTracker = " " ; <nl> + return url ; <nl> + } <nl> + } <nl> } ) ; <nl> mmm a / src / webui / www / webui . qrc <nl> ppp b / src / webui / www / webui . qrc <nl> <nl> < file > private / css / Window . css < / file > <nl> < file > private / download . html < / file > <nl> < file > private / downloadlimit . html < / file > <nl> + < file > private / edittracker . html < / file > <nl> < file > private / filters . html < / file > <nl> < file > private / index . html < / file > <nl> < file > private / installsearchplugin . html < / file > <nl>
Merge pull request from Piccirello / webui - trackers
qbittorrent/qBittorrent
1c525d9c199a6b5a36158849cb47781c8c3a8870
2018-12-12T04:06:32Z
mmm a / java / org / rocksdb / TtlDB . java <nl> ppp b / java / org / rocksdb / TtlDB . java <nl> <nl> <nl> import java . util . List ; <nl> <nl> - <nl> + / * * <nl> + * Database with TTL support . <nl> + * <nl> + * < p > < strong > Use case < / strong > < / p > <nl> + * < p > This API should be used to open the db when key - values inserted are <nl> + * meant to be removed from the db in a non - strict ' ttl ' amount of time <nl> + * Therefore , this guarantees that key - values inserted will remain in the <nl> + * db for & gt ; = ttl amount of time and the db will make efforts to remove the <nl> + * key - values as soon as possible after ttl seconds of their insertion . <nl> + * < / p > <nl> + * <nl> + * < p > < strong > Behaviour < / strong > < / p > <nl> + * < p > TTL is accepted in seconds <nl> + * ( int32_t ) Timestamp ( creation ) is suffixed to values in Put internally <nl> + * Expired TTL values deleted in compaction only : ( Timestamp + ttl & lt ; time_now ) <nl> + * Get / Iterator may return expired entries ( compaction not run on them yet ) <nl> + * Different TTL may be used during different Opens <nl> + * < / p > <nl> + * <nl> + * < p > < strong > Example < / strong > < / p > <nl> + * < ul > <nl> + * < li > Open1 at t = 0 with ttl = 4 and insert k1 , k2 , close at t = 2 < / li > <nl> + * < li > Open2 at t = 3 with ttl = 5 . Now k1 , k2 should be deleted at t & gt ; = 5 < / li > <nl> + * < / ul > <nl> + * <nl> + * < p > <nl> + * read_only = true opens in the usual read - only mode . Compactions will not be <nl> + * triggered ( neither manual nor automatic ) , so no expired entries removed <nl> + * < / p > <nl> + * <nl> + * < p > < strong > Constraints < / strong > < / p > <nl> + * < p > Not specifying / passing or non - positive TTL behaves <nl> + * like TTL = infinity < / p > <nl> + * <nl> + * < p > < strong > ! ! ! WARNING ! ! ! < / strong > < / p > <nl> + * < p > Calling DB : : Open directly to re - open a db created by this API will get <nl> + * corrupt values ( timestamp suffixed ) and no ttl effect will be there <nl> + * during the second Open , so use this API consistently to open the db <nl> + * Be careful when passing ttl with a small positive value because the <nl> + * whole database may be deleted in a small amount of time . < / p > <nl> + * / <nl> public class TtlDB extends RocksDB { <nl> <nl> - / / static Status Open ( const Options & options , const std : : string & dbname , <nl> - / / DBWithTTL * * dbptr , int32_t ttl = 0 , <nl> - / / bool read_only = false ) ; <nl> + / * * <nl> + * < p > Opens a TtlDB . < / p > <nl> + * <nl> + * < p > Database is opened in read - write mode without default TTL . < / p > <nl> + * <nl> + * @ param options { @ link org . rocksdb . Options } instance . <nl> + * @ param db_path path to database . <nl> + * <nl> + * @ return TtlDB instance . <nl> + * <nl> + * @ throws RocksDBException thrown if an error occurs within the native <nl> + * part of the library . <nl> + * / <nl> + public static TtlDB open ( Options options , String db_path ) <nl> + throws RocksDBException { <nl> + return open ( options , db_path , 0 , false ) ; <nl> + } <nl> + <nl> + / * * <nl> + * < p > Opens a TtlDB . < / p > <nl> + * <nl> + * @ param options { @ link org . rocksdb . Options } instance . <nl> + * @ param db_path path to database . <nl> + * @ param ttl time to live for new entries . <nl> + * @ param readOnly boolean value indicating if database if db is <nl> + * opened read - only . <nl> + * <nl> + * @ return TtlDB instance . <nl> + * <nl> + * @ throws RocksDBException thrown if an error occurs within the native <nl> + * part of the library . <nl> + * / <nl> public static TtlDB open ( Options options , String db_path , int ttl , <nl> boolean readOnly ) throws RocksDBException { <nl> TtlDB ttldb = new TtlDB ( ) ; <nl> ttldb . open ( options . nativeHandle_ , db_path , ttl , readOnly ) ; <nl> - <nl> - / / Prevent the RocksDB object from attempting to delete <nl> - / / the underly C + + DB object . <nl> - / / ttldb . disOwnNativeHandle ( ) ; <nl> return ttldb ; <nl> } <nl> <nl> public static TtlDB open ( DBOptions options , String db_path , <nl> return null ; <nl> } <nl> <nl> + / * * <nl> + * < p > Creates a new ttl based column family with a name defined <nl> + * in given ColumnFamilyDescriptor and allocates a <nl> + * ColumnFamilyHandle within an internal structure . < / p > <nl> + * <nl> + * < p > The ColumnFamilyHandle is automatically disposed with DB <nl> + * disposal . < / p > <nl> + * <nl> + * @ param columnFamilyDescriptor column family to be created . <nl> + * @ param ttl TTL to set for this column family . <nl> + * <nl> + * @ return { @ link org . rocksdb . ColumnFamilyHandle } instance . <nl> + * <nl> + * @ throws RocksDBException thrown if error happens in underlying <nl> + * native library . <nl> + * / <nl> public ColumnFamilyHandle createColumnFamilyWithTtl ( <nl> - ColumnFamilyDescriptor columnFamilyDescriptor , int ttl ) { <nl> - return null ; <nl> + ColumnFamilyDescriptor columnFamilyDescriptor , int ttl ) <nl> + throws RocksDBException { <nl> + assert ( isInitialized ( ) ) ; <nl> + return new ColumnFamilyHandle ( this , <nl> + createColumnFamilyWithTtl ( nativeHandle_ , <nl> + columnFamilyDescriptor , ttl ) ) ; <nl> } <nl> <nl> / * * <nl> - * Close the TtlDB instance and release resource . <nl> + * < p > Close the TtlDB instance and release resource . < / p > <nl> * <nl> - * Internally , TtlDB owns the { @ code rocksdb : : DB } pointer to its associated <nl> - * { @ link org . rocksdb . RocksDB } . The release of that RocksDB pointer is handled in the destructor <nl> - * of the c + + { @ code rocksdb : : TtlDB } and should be transparent to Java developers . <nl> + * < p > Internally , TtlDB owns the { @ code rocksdb : : DB } pointer <nl> + * to its associated { @ link org . rocksdb . RocksDB } . The release <nl> + * of that RocksDB pointer is handled in the destructor of the <nl> + * c + + { @ code rocksdb : : TtlDB } and should be transparent to <nl> + * Java developers . < / p > <nl> * / <nl> @ Override public synchronized void close ( ) { <nl> if ( isInitialized ( ) ) { <nl> public ColumnFamilyHandle createColumnFamilyWithTtl ( <nl> } <nl> <nl> / * * <nl> - * A protected construction that will be used in the static factory <nl> - * method { @ link # open ( DBOptions , String , java . util . List , java . util . List ) } and <nl> - * { @ link # open ( DBOptions , String , java . util . List , java . util . List , java . util . List , boolean ) } . <nl> + * < p > A protected constructor that will be used in the static <nl> + * factory method <nl> + * { @ link # open ( DBOptions , String , java . util . List , java . util . List ) } <nl> + * and <nl> + * { @ link # open ( DBOptions , String , java . util . List , <nl> + * java . util . List , java . util . List , boolean ) } . <nl> + * < / p > <nl> * / <nl> protected TtlDB ( ) { <nl> super ( ) ; <nl> protected TtlDB ( ) { <nl> <nl> private native void open ( long optionsHandle , String db_path , int ttl , <nl> boolean readOnly ) throws RocksDBException ; <nl> + private native long createColumnFamilyWithTtl ( long handle , <nl> + ColumnFamilyDescriptor columnFamilyDescriptor , int ttl ) <nl> + throws RocksDBException ; <nl> } <nl> mmm a / java / org / rocksdb / test / TtlDBTest . java <nl> ppp b / java / org / rocksdb / test / TtlDBTest . java <nl> <nl> import org . junit . Rule ; <nl> import org . junit . Test ; <nl> import org . junit . rules . TemporaryFolder ; <nl> - import org . rocksdb . Options ; <nl> - import org . rocksdb . RocksDBException ; <nl> - import org . rocksdb . TtlDB ; <nl> + import org . rocksdb . * ; <nl> + <nl> + import java . util . concurrent . TimeUnit ; <nl> <nl> import static org . assertj . core . api . Assertions . assertThat ; <nl> <nl> <nl> public TemporaryFolder dbFolder = new TemporaryFolder ( ) ; <nl> <nl> @ Test <nl> - public void ttlDBOpen ( ) throws RocksDBException , InterruptedException { <nl> + public void ttlDBOpen ( ) throws RocksDBException , <nl> + InterruptedException { <nl> Options options = null ; <nl> TtlDB ttlDB = null ; <nl> try { <nl> - options = new Options ( ) . setCreateIfMissing ( true ) ; <nl> + options = new Options ( ) . <nl> + setCreateIfMissing ( true ) . <nl> + setMaxGrandparentOverlapFactor ( 0 ) . <nl> + setMaxMemCompactionLevel ( 0 ) ; <nl> + ttlDB = TtlDB . open ( options , <nl> + dbFolder . getRoot ( ) . getAbsolutePath ( ) ) ; <nl> + ttlDB . put ( " key " . getBytes ( ) , " value " . getBytes ( ) ) ; <nl> + assertThat ( ttlDB . get ( " key " . getBytes ( ) ) ) . <nl> + isEqualTo ( " value " . getBytes ( ) ) ; <nl> + assertThat ( ttlDB . get ( " key " . getBytes ( ) ) ) . isNotNull ( ) ; <nl> + } finally { <nl> + if ( ttlDB ! = null ) { <nl> + ttlDB . close ( ) ; <nl> + } <nl> + if ( options ! = null ) { <nl> + options . dispose ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + @ Test <nl> + public void ttlDBOpenWithTtl ( ) throws RocksDBException , <nl> + InterruptedException { <nl> + Options options = null ; <nl> + TtlDB ttlDB = null ; <nl> + try { <nl> + options = new Options ( ) . <nl> + setCreateIfMissing ( true ) . <nl> + setMaxGrandparentOverlapFactor ( 0 ) . <nl> + setMaxMemCompactionLevel ( 0 ) ; <nl> ttlDB = TtlDB . open ( options , dbFolder . getRoot ( ) . getAbsolutePath ( ) , <nl> 1 , false ) ; <nl> ttlDB . put ( " key " . getBytes ( ) , " value " . getBytes ( ) ) ; <nl> assertThat ( ttlDB . get ( " key " . getBytes ( ) ) ) . <nl> isEqualTo ( " value " . getBytes ( ) ) ; <nl> - Thread . sleep ( 1250 ) ; <nl> - ttlDB . compactRange ( ) ; <nl> + TimeUnit . SECONDS . sleep ( 2 ) ; <nl> <nl> + ttlDB . compactRange ( ) ; <nl> assertThat ( ttlDB . get ( " key " . getBytes ( ) ) ) . isNull ( ) ; <nl> } finally { <nl> if ( ttlDB ! = null ) { <nl> public void ttlDBOpen ( ) throws RocksDBException , InterruptedException { <nl> } <nl> } <nl> } <nl> + <nl> + @ Test <nl> + public void createTtlColumnFamily ( ) throws RocksDBException , <nl> + InterruptedException { <nl> + Options options = null ; <nl> + TtlDB ttlDB = null ; <nl> + ColumnFamilyHandle columnFamilyHandle = null ; <nl> + try { <nl> + options = new Options ( ) . setCreateIfMissing ( true ) ; <nl> + ttlDB = TtlDB . open ( options , <nl> + dbFolder . getRoot ( ) . getAbsolutePath ( ) ) ; <nl> + columnFamilyHandle = ttlDB . createColumnFamilyWithTtl ( <nl> + new ColumnFamilyDescriptor ( " new_cf " ) , 1 ) ; <nl> + ttlDB . put ( columnFamilyHandle , " key " . getBytes ( ) , <nl> + " value " . getBytes ( ) ) ; <nl> + assertThat ( ttlDB . get ( columnFamilyHandle , " key " . getBytes ( ) ) ) . <nl> + isEqualTo ( " value " . getBytes ( ) ) ; <nl> + Thread . sleep ( 2500 ) ; <nl> + ttlDB . compactRange ( columnFamilyHandle ) ; <nl> + assertThat ( ttlDB . get ( columnFamilyHandle , " key " . getBytes ( ) ) ) . isNull ( ) ; <nl> + } finally { <nl> + if ( columnFamilyHandle ! = null ) { <nl> + columnFamilyHandle . dispose ( ) ; <nl> + } <nl> + if ( ttlDB ! = null ) { <nl> + ttlDB . close ( ) ; <nl> + } <nl> + if ( options ! = null ) { <nl> + options . dispose ( ) ; <nl> + } <nl> + } <nl> + } <nl> } <nl> mmm a / java / rocksjni / ttl . cc <nl> ppp b / java / rocksjni / ttl . cc <nl> void Java_org_rocksdb_TtlDB_open ( JNIEnv * env , jobject jttldb , <nl> } <nl> rocksdb : : RocksDBExceptionJni : : ThrowNew ( env , s ) ; <nl> } <nl> + <nl> + / * <nl> + * Class : org_rocksdb_TtlDB <nl> + * Method : createColumnFamilyWithTtl <nl> + * Signature : ( JLorg / rocksdb / ColumnFamilyDescriptor ; I ) J ; <nl> + * / <nl> + jlong Java_org_rocksdb_TtlDB_createColumnFamilyWithTtl ( <nl> + JNIEnv * env , jobject jobj , jlong jdb_handle , <nl> + jobject jcf_descriptor , jint jttl ) { <nl> + rocksdb : : ColumnFamilyHandle * handle ; <nl> + auto db_handle = reinterpret_cast < rocksdb : : DBWithTTL * > ( jdb_handle ) ; <nl> + <nl> + jstring jstr = ( jstring ) env - > CallObjectMethod ( jcf_descriptor , <nl> + rocksdb : : ColumnFamilyDescriptorJni : : getColumnFamilyNameMethod ( <nl> + env ) ) ; <nl> + / / get CF Options <nl> + jobject jcf_opt_obj = env - > CallObjectMethod ( jcf_descriptor , <nl> + rocksdb : : ColumnFamilyDescriptorJni : : getColumnFamilyOptionsMethod ( <nl> + env ) ) ; <nl> + rocksdb : : ColumnFamilyOptions * cfOptions = <nl> + rocksdb : : ColumnFamilyOptionsJni : : getHandle ( env , jcf_opt_obj ) ; <nl> + <nl> + const char * cfname = env - > GetStringUTFChars ( jstr , 0 ) ; <nl> + rocksdb : : Status s = db_handle - > CreateColumnFamilyWithTtl ( <nl> + * cfOptions , cfname , & handle , jttl ) ; <nl> + env - > ReleaseStringUTFChars ( jstr , cfname ) ; <nl> + <nl> + if ( s . ok ( ) ) { <nl> + return reinterpret_cast < jlong > ( handle ) ; <nl> + } <nl> + rocksdb : : RocksDBExceptionJni : : ThrowNew ( env , s ) ; <nl> + return 0 ; <nl> + } <nl>
[ RocksJava ] TTL Support
facebook/rocksdb
5ff8aec4db7534a2e6ab1118d824ce021b897fc0
2015-01-17T22:28:06Z
new file mode 100644 <nl> index 000000000000 . . 684db1557910 <nl> mmm / dev / null <nl> ppp b / db / queryutil - inl . h <nl> <nl> + / / queryutil - inl . h - Inline definitions for frequently called queryutil . h functions <nl> + <nl> + / * Copyright 2011 10gen Inc . <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> + namespace mongo { <nl> + <nl> + inline bool FieldInterval : : equality ( ) const { <nl> + if ( _cachedEquality = = - 1 ) { <nl> + _cachedEquality = ( _lower . _inclusive & & _upper . _inclusive & & _lower . _bound . woCompare ( _upper . _bound , false ) = = 0 ) ; <nl> + } <nl> + return _cachedEquality ; <nl> + } <nl> + <nl> + inline bool FieldRange : : equality ( ) const { <nl> + return <nl> + ! empty ( ) & & <nl> + min ( ) . woCompare ( max ( ) , false ) = = 0 & & <nl> + maxInclusive ( ) & & <nl> + minInclusive ( ) ; <nl> + } <nl> + <nl> + inline bool FieldRange : : inQuery ( ) const { <nl> + if ( equality ( ) ) { <nl> + return true ; <nl> + } <nl> + for ( vector < FieldInterval > : : const_iterator i = _intervals . begin ( ) ; i ! = _intervals . end ( ) ; + + i ) { <nl> + if ( ! i - > equality ( ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> + / * * <nl> + * TODO Assumes intervals are contiguous and minKey / maxKey will not be <nl> + * matched against . <nl> + * / <nl> + inline bool FieldRange : : nontrivial ( ) const { <nl> + return <nl> + ! empty ( ) & & <nl> + ( _intervals . size ( ) ! = 1 | | <nl> + minKey . firstElement ( ) . woCompare ( min ( ) , false ) ! = 0 | | <nl> + maxKey . firstElement ( ) . woCompare ( max ( ) , false ) ! = 0 ) ; <nl> + } <nl> + <nl> + inline bool QueryPattern : : operator < ( const QueryPattern & other ) const { <nl> + map < string , Type > : : const_iterator i = _fieldTypes . begin ( ) ; <nl> + map < string , Type > : : const_iterator j = other . _fieldTypes . begin ( ) ; <nl> + while ( i ! = _fieldTypes . end ( ) ) { <nl> + if ( j = = other . _fieldTypes . end ( ) ) <nl> + return false ; <nl> + if ( i - > first < j - > first ) <nl> + return true ; <nl> + else if ( i - > first > j - > first ) <nl> + return false ; <nl> + if ( i - > second < j - > second ) <nl> + return true ; <nl> + else if ( i - > second > j - > second ) <nl> + return false ; <nl> + + + i ; <nl> + + + j ; <nl> + } <nl> + if ( j ! = other . _fieldTypes . end ( ) ) <nl> + return true ; <nl> + return _sort . woCompare ( other . _sort ) < 0 ; <nl> + } <nl> + <nl> + inline const FieldRange & FieldRangeSet : : range ( const char * fieldName ) const { <nl> + map < string , FieldRange > : : const_iterator f = _ranges . find ( fieldName ) ; <nl> + if ( f = = _ranges . end ( ) ) <nl> + return trivialRange ( ) ; <nl> + return f - > second ; <nl> + } <nl> + <nl> + inline FieldRange & FieldRangeSet : : range ( const char * fieldName ) { <nl> + map < string , FieldRange > : : iterator f = _ranges . find ( fieldName ) ; <nl> + if ( f = = _ranges . end ( ) ) <nl> + return trivialRange ( ) ; <nl> + return f - > second ; <nl> + } <nl> + <nl> + inline int FieldRangeSet : : nNontrivialRanges ( ) const { <nl> + int count = 0 ; <nl> + for ( map < string , FieldRange > : : const_iterator i = _ranges . begin ( ) ; i ! = _ranges . end ( ) ; + + i ) { <nl> + if ( i - > second . nontrivial ( ) ) <nl> + + + count ; <nl> + } <nl> + return count ; <nl> + } <nl> + <nl> + inline bool FieldRangeSet : : matchPossible ( ) const { <nl> + for ( map < string , FieldRange > : : const_iterator i = _ranges . begin ( ) ; i ! = _ranges . end ( ) ; + + i ) <nl> + if ( i - > second . empty ( ) ) <nl> + return false ; <nl> + return true ; <nl> + } <nl> + <nl> + inline long long FieldRangeVector : : size ( ) { <nl> + long long ret = 1 ; <nl> + for ( vector < FieldRange > : : const_iterator i = _ranges . begin ( ) ; i ! = _ranges . end ( ) ; + + i ) { <nl> + ret * = i - > intervals ( ) . size ( ) ; <nl> + } <nl> + return ret ; <nl> + } <nl> + <nl> + inline FieldRangeSet * FieldRangeOrSet : : topFrs ( ) const { <nl> + FieldRangeSet * ret = new FieldRangeSet ( _baseSet ) ; <nl> + if ( _orSets . size ( ) ) { <nl> + * ret & = _orSets . front ( ) ; <nl> + } <nl> + return ret ; <nl> + } <nl> + <nl> + inline FieldRangeSet * FieldRangeOrSet : : topFrsOriginal ( ) const { <nl> + FieldRangeSet * ret = new FieldRangeSet ( _baseSet ) ; <nl> + if ( _originalOrSets . size ( ) ) { <nl> + * ret & = _originalOrSets . front ( ) ; <nl> + } <nl> + return ret ; <nl> + } <nl> + <nl> + } / / namespace mongo <nl> mmm a / db / queryutil . h <nl> ppp b / db / queryutil . h <nl> <nl> - / / queryutil . h <nl> + / / queryutil . h - Utility classes representing ranges of valid BSONElement values for a query . <nl> <nl> / * Copyright 2009 10gen Inc . <nl> * <nl> namespace mongo { <nl> return ( cmp < 0 | | ( cmp = = 0 & & _lower . _inclusive & & _upper . _inclusive ) ) ; <nl> } <nl> / * * @ return true iff the interval is an equality constraint . * / <nl> - bool equality ( ) const { <nl> - if ( _cachedEquality = = - 1 ) { <nl> - _cachedEquality = ( _lower . _inclusive & & _upper . _inclusive & & _lower . _bound . woCompare ( _upper . _bound , false ) = = 0 ) ; <nl> - } <nl> - return _cachedEquality ; <nl> - } <nl> + bool equality ( ) const ; <nl> mutable int _cachedEquality ; <nl> } ; <nl> <nl> namespace mongo { <nl> bool maxInclusive ( ) const { assert ( ! empty ( ) ) ; return _intervals [ _intervals . size ( ) - 1 ] . _upper . _inclusive ; } <nl> <nl> / * * @ return true iff this range expresses a single equality interval . * / <nl> - bool equality ( ) const { <nl> - return <nl> - ! empty ( ) & & <nl> - min ( ) . woCompare ( max ( ) , false ) = = 0 & & <nl> - maxInclusive ( ) & & <nl> - minInclusive ( ) ; <nl> - } <nl> + bool equality ( ) const ; <nl> / * * @ return true if all the intervals for this range are equalities * / <nl> - bool inQuery ( ) const { <nl> - if ( equality ( ) ) { <nl> - return true ; <nl> - } <nl> - for ( vector < FieldInterval > : : const_iterator i = _intervals . begin ( ) ; i ! = _intervals . end ( ) ; + + i ) { <nl> - if ( ! i - > equality ( ) ) { <nl> - return false ; <nl> - } <nl> - } <nl> - return true ; <nl> - } <nl> - / * * <nl> - * @ return true iff this range does not include every BSONElement <nl> - * <nl> - * TODO Assumes intervals are contiguous and minKey / maxKey will not be <nl> - * matched against . <nl> - * / <nl> - bool nontrivial ( ) const { <nl> - return <nl> - ! empty ( ) & & <nl> - ( _intervals . size ( ) ! = 1 | | <nl> - minKey . firstElement ( ) . woCompare ( min ( ) , false ) ! = 0 | | <nl> - maxKey . firstElement ( ) . woCompare ( max ( ) , false ) ! = 0 ) ; <nl> - } <nl> + bool inQuery ( ) const ; <nl> + / * * @ return true iff this range does not include every BSONElement * / <nl> + bool nontrivial ( ) const ; <nl> / * * @ return true iff this range matches no BSONElements . * / <nl> bool empty ( ) const { return _intervals . empty ( ) ; } <nl> <nl> namespace mongo { <nl> UpperBound , <nl> UpperAndLowerBound <nl> } ; <nl> - bool operator < ( const QueryPattern & other ) const { <nl> - map < string , Type > : : const_iterator i = _fieldTypes . begin ( ) ; <nl> - map < string , Type > : : const_iterator j = other . _fieldTypes . begin ( ) ; <nl> - while ( i ! = _fieldTypes . end ( ) ) { <nl> - if ( j = = other . _fieldTypes . end ( ) ) <nl> - return false ; <nl> - if ( i - > first < j - > first ) <nl> - return true ; <nl> - else if ( i - > first > j - > first ) <nl> - return false ; <nl> - if ( i - > second < j - > second ) <nl> - return true ; <nl> - else if ( i - > second > j - > second ) <nl> - return false ; <nl> - + + i ; <nl> - + + j ; <nl> - } <nl> - if ( j ! = other . _fieldTypes . end ( ) ) <nl> - return true ; <nl> - return _sort . woCompare ( other . _sort ) < 0 ; <nl> - } <nl> + bool operator < ( const QueryPattern & other ) const ; <nl> / * * for testing only * / <nl> bool operator = = ( const QueryPattern & other ) const ; <nl> / * * for testing only * / <nl> namespace mongo { <nl> return f ! = _ranges . end ( ) ; <nl> } <nl> / * * @ return range for the given field . * / <nl> - const FieldRange & range ( const char * fieldName ) const { <nl> - map < string , FieldRange > : : const_iterator f = _ranges . find ( fieldName ) ; <nl> - if ( f = = _ranges . end ( ) ) <nl> - return trivialRange ( ) ; <nl> - return f - > second ; <nl> - } <nl> + const FieldRange & range ( const char * fieldName ) const ; <nl> / * * @ return range for the given field . * / <nl> - FieldRange & range ( const char * fieldName ) { <nl> - map < string , FieldRange > : : iterator f = _ranges . find ( fieldName ) ; <nl> - if ( f = = _ranges . end ( ) ) <nl> - return trivialRange ( ) ; <nl> - return f - > second ; <nl> - } <nl> + FieldRange & range ( const char * fieldName ) ; <nl> / * * @ return the number of nontrivial ranges . * / <nl> - int nNontrivialRanges ( ) const { <nl> - int count = 0 ; <nl> - for ( map < string , FieldRange > : : const_iterator i = _ranges . begin ( ) ; i ! = _ranges . end ( ) ; + + i ) { <nl> - if ( i - > second . nontrivial ( ) ) <nl> - + + count ; <nl> - } <nl> - return count ; <nl> - } <nl> + int nNontrivialRanges ( ) const ; <nl> / * * <nl> * @ return true iff no FieldRanges are empty . <nl> * / <nl> - bool matchPossible ( ) const { <nl> - for ( map < string , FieldRange > : : const_iterator i = _ranges . begin ( ) ; i ! = _ranges . end ( ) ; + + i ) <nl> - if ( i - > second . empty ( ) ) <nl> - return false ; <nl> - return true ; <nl> - } <nl> + bool matchPossible ( ) const ; <nl> <nl> const char * ns ( ) const { return _ns ; } <nl> <nl> namespace mongo { <nl> FieldRangeVector ( const FieldRangeSet & frs , const IndexSpec & indexSpec , int direction ) ; <nl> <nl> / * * @ return the number of index ranges represented by ' this ' * / <nl> - long long size ( ) { <nl> - long long ret = 1 ; <nl> - for ( vector < FieldRange > : : const_iterator i = _ranges . begin ( ) ; i ! = _ranges . end ( ) ; + + i ) { <nl> - ret * = i - > intervals ( ) . size ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> + long long size ( ) ; <nl> / * * @ return starting point for an index traversal . * / <nl> BSONObj startKey ( ) const ; <nl> / * * @ return end point for an index traversal . * / <nl> namespace mongo { <nl> Iterator ( const FieldRangeVector & v ) : _v ( v ) , _i ( _v . _ranges . size ( ) , - 1 ) , _cmp ( _v . _ranges . size ( ) , 0 ) , _inc ( _v . _ranges . size ( ) , false ) , _after ( ) { <nl> } <nl> static BSONObj minObject ( ) { <nl> - BSONObjBuilder b ; <nl> - b . appendMinKey ( " " ) ; <nl> + BSONObjBuilder b ; b . appendMinKey ( " " ) ; <nl> return b . obj ( ) ; <nl> } <nl> static BSONObj maxObject ( ) { <nl> - BSONObjBuilder b ; <nl> - b . appendMaxKey ( " " ) ; <nl> + BSONObjBuilder b ; b . appendMaxKey ( " " ) ; <nl> return b . obj ( ) ; <nl> } <nl> / * * <nl> namespace mongo { <nl> const vector < bool > & inc ( ) const { return _inc ; } <nl> bool after ( ) const { return _after ; } <nl> void prepDive ( ) ; <nl> - void setZero ( int i ) { <nl> - for ( int j = i ; j < ( int ) _i . size ( ) ; + + j ) { <nl> - _i [ j ] = 0 ; <nl> - } <nl> - } <nl> - void setMinus ( int i ) { <nl> - for ( int j = i ; j < ( int ) _i . size ( ) ; + + j ) { <nl> - _i [ j ] = - 1 ; <nl> - } <nl> - } <nl> - bool ok ( ) { <nl> - return _i [ 0 ] < ( int ) _v . _ranges [ 0 ] . intervals ( ) . size ( ) ; <nl> - } <nl> + void setZero ( int i ) { for ( int j = i ; j < ( int ) _i . size ( ) ; + + j ) _i [ j ] = 0 ; } <nl> + void setMinus ( int i ) { for ( int j = i ; j < ( int ) _i . size ( ) ; + + j ) _i [ j ] = - 1 ; } <nl> + bool ok ( ) { return _i [ 0 ] < ( int ) _v . _ranges [ 0 ] . intervals ( ) . size ( ) ; } <nl> BSONObj startKey ( ) ; <nl> / / temp <nl> BSONObj endKey ( ) ; <nl> namespace mongo { <nl> / * * Iterates to the next $ or clause by removing the current $ or clause . * / <nl> void popOrClause ( const BSONObj & indexSpec = BSONObj ( ) ) ; <nl> / * * @ return FieldRangeSet for the current $ or clause . * / <nl> - FieldRangeSet * topFrs ( ) const { <nl> - FieldRangeSet * ret = new FieldRangeSet ( _baseSet ) ; <nl> - if ( _orSets . size ( ) ) { <nl> - * ret & = _orSets . front ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> + FieldRangeSet * topFrs ( ) const ; <nl> / * * <nl> * @ return original FieldRangeSet for the current $ or clause . While the <nl> * original bounds are looser , they are composed of fewer ranges and it <nl> * is faster to do operations with them ; when they can be used instead of <nl> * more precise bounds , they should . <nl> * / <nl> - FieldRangeSet * topFrsOriginal ( ) const { <nl> - FieldRangeSet * ret = new FieldRangeSet ( _baseSet ) ; <nl> - if ( _originalOrSets . size ( ) ) { <nl> - * ret & = _originalOrSets . front ( ) ; <nl> - } <nl> - return ret ; <nl> - } <nl> + FieldRangeSet * topFrsOriginal ( ) const ; <nl> <nl> / * * @ ret a returned vector of simplified queries for all clauses . * / <nl> void allClausesSimplified ( vector < BSONObj > & ret ) const ; <nl> namespace mongo { <nl> long long applySkipLimit ( long long num , const BSONObj & cmd ) ; <nl> <nl> } / / namespace mongo <nl> + <nl> + # include " queryutil - inl . h " <nl>
Add queryutil - inl
mongodb/mongo
ff395882d2aa4c85d6023c58ade489b3e38fe617
2011-04-07T21:43:39Z
mmm a / hphp / runtime / vm / jit / ir - translator . cpp <nl> ppp b / hphp / runtime / vm / jit / ir - translator . cpp <nl> IRTranslator : : translateAssignToLocalOp ( const NormalizedInstruction & ni ) { <nl> } <nl> } <nl> <nl> - void IRTranslator : : translatePopA ( const NormalizedInstruction & ) { <nl> - HHIR_EMIT ( PopA ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translatePopC ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( PopC ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translatePopV ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( PopV ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translatePopR ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( PopR ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateUnboxR ( const NormalizedInstruction & i ) { <nl> if ( i . noOp ) { <nl> void IRTranslator : : translateBoxRNop ( const NormalizedInstruction & i ) { <nl> m_hhbcTrans . assertTypeStack ( 0 , JIT : : Type : : BoxedCell ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateNull ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Null ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateNullUninit ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( NullUninit ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateTrue ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( True ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateFalse ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( False ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateInt ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( Int , i . imm [ 0 ] . u_I64A ) ; <nl> IRTranslator : : translateNewArray ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( NewArray , i . imm [ 0 ] . u_IVA ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateNop ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Nop ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateAddElemC ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( AddElemC ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateFloor ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Floor ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCeil ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Ceil ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateCheckProp ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( CheckProp , i . imm [ 0 ] . u_SA ) ; <nl> void IRTranslator : : translatePredictTStk ( const NormalizedInstruction & i ) { <nl> void IRTranslator : : translateBreakTraceHint ( const NormalizedInstruction & ) { <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateAddNewElemC ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( AddNewElemC ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateCns ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( Cns , i . imm [ 0 ] . u_SA ) ; <nl> IRTranslator : : translateClsCnsD ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( ClsCnsD , ( i . imm [ 0 ] . u_SA ) , ( i . imm [ 1 ] . u_SA ) , i . outPred ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateConcat ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Concat ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateAdd ( const NormalizedInstruction & i ) { <nl> auto leftType = m_hhbcTrans . topType ( 1 ) ; <nl> IRTranslator : : translateAddO ( const NormalizedInstruction & i ) { <nl> } <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateSqrt ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Sqrt ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateAbs ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Abs ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateXor ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Xor ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateNot ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Not ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateBitNot ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( BitNot ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateShl ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Shl ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateShr ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Shr ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCastInt ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CastInt ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCastArray ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CastArray ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCastObject ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CastObject ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCastDouble ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CastDouble ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCastString ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CastString ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translatePrint ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Print ) ; <nl> - } <nl> - <nl> void IRTranslator : : translateJmp ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( Jmp , i . offset ( ) + i . imm [ 0 ] . u_BA , i . breaksTracelet , false ) ; <nl> } <nl> IRTranslator : : translateRetV ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( RetV , i . inlineReturn ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateNativeImpl ( const NormalizedInstruction & ni ) { <nl> - HHIR_EMIT ( NativeImpl ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateAGetC ( const NormalizedInstruction & ni ) { <nl> - HHIR_EMIT ( AGetC ) ; <nl> - } <nl> - <nl> void IRTranslator : : translateAGetL ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( AGetL , i . imm [ 0 ] . u_LA ) ; <nl> } <nl> <nl> - void IRTranslator : : translateSelf ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Self ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateParent ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Parent ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateDup ( const NormalizedInstruction & ni ) { <nl> - HHIR_EMIT ( Dup ) ; <nl> - } <nl> - <nl> void IRTranslator : : translateCreateCont ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( CreateCont , i . nextSk ( ) . offset ( ) ) ; <nl> } <nl> void IRTranslator : : translateContCheck ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( ContCheck , i . imm [ 0 ] . u_IVA ) ; <nl> } <nl> <nl> - void IRTranslator : : translateContValid ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ContValid ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateContKey ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ContKey ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateContCurrent ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ContCurrent ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateContStopped ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ContStopped ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateAsyncAwait ( const NormalizedInstruction & ) { <nl> - HHIR_EMIT ( AsyncAwait ) ; <nl> - } <nl> - <nl> void IRTranslator : : translateAsyncSuspend ( const NormalizedInstruction & i ) { <nl> if ( m_hhbcTrans . resumed ( ) ) { <nl> HHIR_EMIT ( AsyncSuspendR , i . nextSk ( ) . offset ( ) ) ; <nl> void IRTranslator : : translateAsyncSuspend ( const NormalizedInstruction & i ) { <nl> } <nl> } <nl> <nl> - void IRTranslator : : translateStrlen ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Strlen ) ; <nl> - } <nl> - <nl> void IRTranslator : : translateIncStat ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( IncStat , i . imm [ 0 ] . u_IVA , i . imm [ 1 ] . u_IVA , false ) ; <nl> } <nl> <nl> - void IRTranslator : : translateIdx ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( Idx ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateArrayIdx ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ArrayIdx ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateClassExists ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ClassExists ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateInterfaceExists ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( InterfaceExists ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateTraitExists ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( TraitExists ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateVGetS ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( VGetS ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateVGetG ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( VGetG ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateBindS ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( BindS ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateEmptyS ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( EmptyS ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateEmptyG ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( EmptyG ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateIssetS ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( IssetS ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateIssetG ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( IssetG ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateCGetS ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CGetS ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateSetS ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( SetS ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateCGetG ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CGetG ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateSetG ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( SetG ) ; <nl> - } <nl> - <nl> - void IRTranslator : : translateBindG ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( BindG ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateLateBoundCls ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( LateBoundCls ) ; <nl> - } <nl> - <nl> void IRTranslator : : translateFPassL ( const NormalizedInstruction & ni ) { <nl> auto locId = ni . imm [ 1 ] . u_LA ; <nl> if ( ni . preppedByRef ) { <nl> IRTranslator : : translateCheckTypeCOp ( const NormalizedInstruction & ni ) { <nl> } <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateAKExists ( const NormalizedInstruction & ni ) { <nl> - HHIR_EMIT ( AKExists ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateSetOpL ( const NormalizedInstruction & i ) { <nl> auto const opc = [ & ] { <nl> void IRTranslator : : translateCreateCl ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( CreateCl , ( i . imm [ 0 ] . u_IVA ) , ( i . imm [ 1 ] . u_SA ) ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateThis ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( This ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateBareThis ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( BareThis , ( i . imm [ 0 ] . u_OA ) ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateCheckThis ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( CheckThis ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateInitThisLoc ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( InitThisLoc , i . imm [ 0 ] . u_LA ) ; <nl> IRTranslator : : translateNewCol ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( NewCol , i . imm [ 0 ] . u_IVA , i . imm [ 1 ] . u_IVA ) ; <nl> } <nl> <nl> - void IRTranslator : : translateClone ( const NormalizedInstruction & ) { <nl> - HHIR_EMIT ( Clone ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateColAddNewElemC ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ColAddNewElemC ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateColAddElemC ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( ColAddElemC ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateStaticLocInit ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( StaticLocInit , i . imm [ 0 ] . u_IVA , i . imm [ 1 ] . u_SA ) ; <nl> IRTranslator : : translateVerifyParamType ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( VerifyParamType , param ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateVerifyRetTypeC ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( VerifyRetTypeC ) ; <nl> - } <nl> - <nl> - void <nl> - IRTranslator : : translateVerifyRetTypeV ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( VerifyRetTypeV ) ; <nl> - } <nl> - <nl> void <nl> IRTranslator : : translateInstanceOfD ( const NormalizedInstruction & i ) { <nl> HHIR_EMIT ( InstanceOfD , ( i . imm [ 0 ] . u_SA ) ) ; <nl> } <nl> <nl> - void <nl> - IRTranslator : : translateInstanceOf ( const NormalizedInstruction & i ) { <nl> - HHIR_EMIT ( InstanceOf ) ; <nl> - } <nl> - <nl> / * <nl> * This function returns the offset of instruction i ' s branch target . <nl> * This is normally the offset corresponding to the branch being <nl> MINSTRS <nl> MII ( FPass ) <nl> # undef MII <nl> <nl> + / * <nl> + * Generate translateBluh methods for regular instructions . <nl> + * / <nl> + # define CASE ( name ) \ <nl> + void IRTranslator : : translate # # name ( const NormalizedInstruction & ) { \ <nl> + HHIR_EMIT ( name ) ; \ <nl> + } <nl> + <nl> + REGULAR_INSTRS <nl> + # undef CASE <nl> + <nl> void <nl> IRTranslator : : translateInstrWork ( const NormalizedInstruction & i ) { <nl> auto const op = i . op ( ) ; <nl> mmm a / hphp / runtime / vm / jit / translator - instrs . h <nl> ppp b / hphp / runtime / vm / jit / translator - instrs . h <nl> <nl> * Macros used for dispatch in the translator . <nl> * / <nl> <nl> - # define INSTRS \ <nl> - CASE ( BreakTraceHint ) \ <nl> - CASE ( PopA ) \ <nl> - CASE ( PopC ) \ <nl> - CASE ( PopV ) \ <nl> - CASE ( PopR ) \ <nl> - CASE ( UnboxR ) \ <nl> + # define IRREGULAR_INSTRS \ <nl> + CASE ( AGetL ) \ <nl> + CASE ( Add ) \ <nl> + CASE ( AddO ) \ <nl> + CASE ( Array ) \ <nl> + CASE ( AssertObjL ) \ <nl> + CASE ( AssertObjStk ) \ <nl> + CASE ( AssertTL ) \ <nl> + CASE ( AssertTStk ) \ <nl> + CASE ( AsyncSuspend ) \ <nl> + CASE ( BareThis ) \ <nl> + CASE ( BindM ) \ <nl> CASE ( BoxR ) \ <nl> - CASE ( UnboxRNop ) \ <nl> CASE ( BoxRNop ) \ <nl> - CASE ( Null ) \ <nl> - CASE ( NullUninit ) \ <nl> - CASE ( True ) \ <nl> - CASE ( False ) \ <nl> - CASE ( Int ) \ <nl> - CASE ( Double ) \ <nl> - CASE ( String ) \ <nl> - CASE ( Array ) \ <nl> - CASE ( NewArray ) \ <nl> - CASE ( NewPackedArray ) \ <nl> - CASE ( NewStructArray ) \ <nl> - CASE ( NewCol ) \ <nl> - CASE ( Clone ) \ <nl> - CASE ( Nop ) \ <nl> - CASE ( AddElemC ) \ <nl> - CASE ( AddNewElemC ) \ <nl> - CASE ( ColAddElemC ) \ <nl> - CASE ( ColAddNewElemC ) \ <nl> + CASE ( BreakTraceHint ) \ <nl> + CASE ( CGetL ) \ <nl> + CASE ( CGetL2 ) \ <nl> + CASE ( CGetM ) \ <nl> + CASE ( CIterFree ) \ <nl> + CASE ( CheckProp ) \ <nl> + CASE ( ClsCnsD ) \ <nl> CASE ( Cns ) \ <nl> CASE ( CnsE ) \ <nl> CASE ( CnsU ) \ <nl> + CASE ( ContCheck ) \ <nl> + CASE ( ContEnter ) \ <nl> + CASE ( ContRaise ) \ <nl> + CASE ( CreateCl ) \ <nl> + CASE ( CreateCont ) \ <nl> + CASE ( DecodeCufIter ) \ <nl> + CASE ( DefCls ) \ <nl> CASE ( DefCns ) \ <nl> - CASE ( ClsCnsD ) \ <nl> - CASE ( Concat ) \ <nl> - CASE ( Abs ) \ <nl> - CASE ( Add ) \ <nl> - CASE ( AddO ) \ <nl> - CASE ( Xor ) \ <nl> - CASE ( Not ) \ <nl> - CASE ( Mod ) \ <nl> - CASE ( Sqrt ) \ <nl> - CASE ( BitNot ) \ <nl> - CASE ( CastInt ) \ <nl> - CASE ( CastString ) \ <nl> - CASE ( CastDouble ) \ <nl> - CASE ( CastArray ) \ <nl> - CASE ( CastObject ) \ <nl> - CASE ( Print ) \ <nl> - CASE ( Jmp ) \ <nl> - CASE ( JmpNS ) \ <nl> - CASE ( Switch ) \ <nl> - CASE ( SSwitch ) \ <nl> - CASE ( RetC ) \ <nl> - CASE ( RetV ) \ <nl> - CASE ( NativeImpl ) \ <nl> - CASE ( AGetC ) \ <nl> - CASE ( AGetL ) \ <nl> - CASE ( CGetL ) \ <nl> - CASE ( PushL ) \ <nl> - CASE ( CGetL2 ) \ <nl> - CASE ( CGetS ) \ <nl> - CASE ( CGetM ) \ <nl> - CASE ( CGetG ) \ <nl> - CASE ( VGetL ) \ <nl> - CASE ( VGetG ) \ <nl> - CASE ( VGetM ) \ <nl> - CASE ( IssetM ) \ <nl> + CASE ( DefFunc ) \ <nl> + CASE ( Div ) \ <nl> + CASE ( Double ) \ <nl> CASE ( EmptyM ) \ <nl> - CASE ( AKExists ) \ <nl> - CASE ( SetS ) \ <nl> - CASE ( SetG ) \ <nl> - CASE ( SetM ) \ <nl> - CASE ( SetWithRefLM ) \ <nl> - CASE ( SetWithRefRM ) \ <nl> - CASE ( SetOpL ) \ <nl> - CASE ( SetOpM ) \ <nl> - CASE ( IncDecL ) \ <nl> - CASE ( IncDecM ) \ <nl> - CASE ( UnsetL ) \ <nl> - CASE ( UnsetM ) \ <nl> - CASE ( BindM ) \ <nl> - CASE ( FPushFuncD ) \ <nl> - CASE ( FPushFuncU ) \ <nl> - CASE ( FPushFunc ) \ <nl> - CASE ( FPushClsMethod ) \ <nl> - CASE ( FPushClsMethodD ) \ <nl> - CASE ( FPushClsMethodF ) \ <nl> - CASE ( FPushObjMethodD ) \ <nl> - CASE ( FPushCtor ) \ <nl> - CASE ( FPushCtorD ) \ <nl> - CASE ( FPassR ) \ <nl> + CASE ( FCall ) \ <nl> + CASE ( FCallArray ) \ <nl> + CASE ( FCallBuiltin ) \ <nl> + CASE ( FCallD ) \ <nl> + CASE ( FPassG ) \ <nl> CASE ( FPassL ) \ <nl> CASE ( FPassM ) \ <nl> + CASE ( FPassR ) \ <nl> CASE ( FPassS ) \ <nl> - CASE ( FPassG ) \ <nl> CASE ( FPassV ) \ <nl> CASE ( FPassVNop ) \ <nl> - CASE ( This ) \ <nl> - CASE ( BareThis ) \ <nl> - CASE ( CheckThis ) \ <nl> + CASE ( FPushClsMethod ) \ <nl> + CASE ( FPushClsMethodD ) \ <nl> + CASE ( FPushClsMethodF ) \ <nl> + CASE ( FPushCtor ) \ <nl> + CASE ( FPushCtorD ) \ <nl> + CASE ( FPushCufIter ) \ <nl> + CASE ( FPushFunc ) \ <nl> + CASE ( FPushFuncD ) \ <nl> + CASE ( FPushFuncU ) \ <nl> + CASE ( FPushObjMethodD ) \ <nl> + CASE ( IncDecL ) \ <nl> + CASE ( IncDecM ) \ <nl> + CASE ( IncStat ) \ <nl> + CASE ( InitProp ) \ <nl> CASE ( InitThisLoc ) \ <nl> - CASE ( FCall ) \ <nl> - CASE ( FCallD ) \ <nl> - CASE ( FCallArray ) \ <nl> - CASE ( FCallBuiltin ) \ <nl> - CASE ( VerifyParamType ) \ <nl> - CASE ( VerifyRetTypeC ) \ <nl> - CASE ( VerifyRetTypeV ) \ <nl> CASE ( InstanceOfD ) \ <nl> - CASE ( InstanceOf ) \ <nl> - CASE ( StaticLocInit ) \ <nl> - CASE ( StaticLoc ) \ <nl> + CASE ( Int ) \ <nl> + CASE ( IssetL ) \ <nl> + CASE ( IssetM ) \ <nl> + CASE ( IterBreak ) \ <nl> + CASE ( IterFree ) \ <nl> CASE ( IterInit ) \ <nl> CASE ( IterInitK ) \ <nl> CASE ( IterNext ) \ <nl> CASE ( IterNextK ) \ <nl> - CASE ( WIterInit ) \ <nl> - CASE ( WIterInitK ) \ <nl> - CASE ( WIterNext ) \ <nl> - CASE ( WIterNextK ) \ <nl> + CASE ( Jmp ) \ <nl> + CASE ( JmpNS ) \ <nl> + CASE ( MIterFree ) \ <nl> CASE ( MIterInit ) \ <nl> CASE ( MIterInitK ) \ <nl> CASE ( MIterNext ) \ <nl> CASE ( MIterNextK ) \ <nl> - CASE ( DefCls ) \ <nl> + CASE ( Mod ) \ <nl> + CASE ( NewArray ) \ <nl> + CASE ( NewCol ) \ <nl> + CASE ( NewPackedArray ) \ <nl> + CASE ( NewStructArray ) \ <nl> CASE ( NopDefCls ) \ <nl> - CASE ( DefFunc ) \ <nl> - CASE ( Self ) \ <nl> - CASE ( Parent ) \ <nl> - CASE ( ClassExists ) \ <nl> - CASE ( InterfaceExists ) \ <nl> - CASE ( TraitExists ) \ <nl> - CASE ( Dup ) \ <nl> - CASE ( CreateCl ) \ <nl> - CASE ( CreateCont ) \ <nl> - CASE ( ContEnter ) \ <nl> - CASE ( ContRaise ) \ <nl> + CASE ( PredictTL ) \ <nl> + CASE ( PredictTStk ) \ <nl> + CASE ( PushL ) \ <nl> + CASE ( RetC ) \ <nl> + CASE ( RetV ) \ <nl> + CASE ( SSwitch ) \ <nl> + CASE ( SetM ) \ <nl> + CASE ( SetOpL ) \ <nl> + CASE ( SetOpM ) \ <nl> + CASE ( SetWithRefLM ) \ <nl> + CASE ( SetWithRefRM ) \ <nl> + CASE ( StaticLoc ) \ <nl> + CASE ( StaticLocInit ) \ <nl> + CASE ( String ) \ <nl> + CASE ( Switch ) \ <nl> + CASE ( UnboxR ) \ <nl> + CASE ( UnboxRNop ) \ <nl> + CASE ( UnsetL ) \ <nl> + CASE ( UnsetM ) \ <nl> + CASE ( VGetL ) \ <nl> + CASE ( VGetM ) \ <nl> + CASE ( VerifyParamType ) \ <nl> + CASE ( WIterInit ) \ <nl> + CASE ( WIterInitK ) \ <nl> + CASE ( WIterNext ) \ <nl> + CASE ( WIterNextK ) \ <nl> CASE ( Yield ) \ <nl> CASE ( YieldK ) \ <nl> - CASE ( ContCheck ) \ <nl> - CASE ( ContValid ) \ <nl> - CASE ( ContKey ) \ <nl> + / * * / <nl> + <nl> + # define REGULAR_INSTRS \ <nl> + CASE ( AGetC ) \ <nl> + CASE ( AKExists ) \ <nl> + CASE ( Abs ) \ <nl> + CASE ( AddElemC ) \ <nl> + CASE ( AddNewElemC ) \ <nl> + CASE ( ArrayIdx ) \ <nl> + CASE ( AsyncAwait ) \ <nl> + CASE ( BindG ) \ <nl> + CASE ( BindS ) \ <nl> + CASE ( BitNot ) \ <nl> + CASE ( CGetG ) \ <nl> + CASE ( CGetS ) \ <nl> + CASE ( CastArray ) \ <nl> + CASE ( CastDouble ) \ <nl> + CASE ( CastInt ) \ <nl> + CASE ( CastObject ) \ <nl> + CASE ( CastString ) \ <nl> + CASE ( Ceil ) \ <nl> + CASE ( CheckThis ) \ <nl> + CASE ( ClassExists ) \ <nl> + CASE ( Clone ) \ <nl> + CASE ( ColAddElemC ) \ <nl> + CASE ( ColAddNewElemC ) \ <nl> + CASE ( Concat ) \ <nl> CASE ( ContCurrent ) \ <nl> + CASE ( ContKey ) \ <nl> CASE ( ContStopped ) \ <nl> - CASE ( AsyncAwait ) \ <nl> - CASE ( AsyncSuspend ) \ <nl> - CASE ( Strlen ) \ <nl> - CASE ( IncStat ) \ <nl> + CASE ( ContValid ) \ <nl> + CASE ( Dup ) \ <nl> + CASE ( EmptyG ) \ <nl> + CASE ( EmptyS ) \ <nl> + CASE ( False ) \ <nl> + CASE ( Floor ) \ <nl> CASE ( Idx ) \ <nl> - CASE ( ArrayIdx ) \ <nl> - CASE ( FPushCufIter ) \ <nl> - CASE ( CIterFree ) \ <nl> - CASE ( LateBoundCls ) \ <nl> - CASE ( IssetS ) \ <nl> + CASE ( InstanceOf ) \ <nl> + CASE ( InterfaceExists ) \ <nl> CASE ( IssetG ) \ <nl> - CASE ( IssetL ) \ <nl> - CASE ( EmptyS ) \ <nl> - CASE ( EmptyG ) \ <nl> - CASE ( VGetS ) \ <nl> - CASE ( BindS ) \ <nl> - CASE ( BindG ) \ <nl> - CASE ( IterFree ) \ <nl> - CASE ( MIterFree ) \ <nl> - CASE ( IterBreak ) \ <nl> - CASE ( DecodeCufIter ) \ <nl> + CASE ( IssetS ) \ <nl> + CASE ( LateBoundCls ) \ <nl> + CASE ( NativeImpl ) \ <nl> + CASE ( Nop ) \ <nl> + CASE ( Not ) \ <nl> + CASE ( Null ) \ <nl> + CASE ( NullUninit ) \ <nl> + CASE ( Parent ) \ <nl> + CASE ( PopA ) \ <nl> + CASE ( PopC ) \ <nl> + CASE ( PopR ) \ <nl> + CASE ( PopV ) \ <nl> + CASE ( Print ) \ <nl> + CASE ( Self ) \ <nl> + CASE ( SetG ) \ <nl> + CASE ( SetS ) \ <nl> CASE ( Shl ) \ <nl> CASE ( Shr ) \ <nl> - CASE ( Div ) \ <nl> - CASE ( Floor ) \ <nl> - CASE ( Ceil ) \ <nl> - CASE ( CheckProp ) \ <nl> - CASE ( InitProp ) \ <nl> - CASE ( AssertTL ) \ <nl> - CASE ( AssertTStk ) \ <nl> - CASE ( AssertObjL ) \ <nl> - CASE ( AssertObjStk ) \ <nl> - CASE ( PredictTL ) \ <nl> - CASE ( PredictTStk ) \ <nl> + CASE ( Sqrt ) \ <nl> + CASE ( Strlen ) \ <nl> + CASE ( This ) \ <nl> + CASE ( TraitExists ) \ <nl> + CASE ( True ) \ <nl> + CASE ( VGetG ) \ <nl> + CASE ( VGetS ) \ <nl> + CASE ( VerifyRetTypeC ) \ <nl> + CASE ( VerifyRetTypeV ) \ <nl> + CASE ( Xor ) \ <nl> / * * / <nl> <nl> + <nl> + # define INSTRS \ <nl> + REGULAR_INSTRS \ <nl> + IRREGULAR_INSTRS <nl> + <nl> / / These are instruction - like functions which cover more than one <nl> / / opcode . <nl> # define PSEUDOINSTRS \ <nl>
Replace IRTranslator : : translate * with macros for nullary opcodes
facebook/hhvm
fe0ff65d438f354b8f9ada0cbc986a480dcb2883
2014-04-21T20:27:54Z
mmm a / src / common / common . h <nl> ppp b / src / common / common . h <nl> inline std : : vector < std : : string > Split ( const std : : string & s , char delim ) { <nl> return ret ; <nl> } <nl> <nl> + template < typename T > <nl> + XGBOOST_DEVICE T Max ( T a , T b ) { <nl> + return a < b ? b : a ; <nl> + } <nl> + <nl> / / simple routine to convert any data to string <nl> template < typename T > <nl> inline std : : string ToString ( const T & data ) { <nl> mmm a / src / common / compressed_iterator . h <nl> ppp b / src / common / compressed_iterator . h <nl> <nl> # include < cstddef > <nl> # include < algorithm > <nl> <nl> + # include " common . h " <nl> + <nl> # ifdef __CUDACC__ <nl> # include " device_helpers . cuh " <nl> # endif / / __CUDACC__ <nl> inline void ClearBit ( CompressedByteT * byte , int bit_idx ) { <nl> * byte & = ~ ( 1 < < bit_idx ) ; <nl> } <nl> static const int kPadding = 4 ; / / Assign padding so we can read slightly off <nl> - / / the beginning of the array <nl> + / / the beginning of the array <nl> <nl> / / The number of bits required to represent a given unsigned range <nl> inline XGBOOST_DEVICE size_t SymbolBits ( size_t num_symbols ) { <nl> auto bits = std : : ceil ( log2 ( static_cast < double > ( num_symbols ) ) ) ; <nl> - return std : : max ( static_cast < size_t > ( bits ) , size_t ( 1 ) ) ; <nl> + return common : : Max ( static_cast < size_t > ( bits ) , size_t ( 1 ) ) ; <nl> } <nl> } / / namespace detail <nl> <nl> mmm a / src / common / hist_util . h <nl> ppp b / src / common / hist_util . h <nl> struct Index { <nl> std : : vector < uint8_t > data_ ; <nl> std : : vector < uint32_t > offset_ ; / / size of this field is equal to number of features <nl> void * data_ptr_ ; <nl> - uint32_t * offset_ptr_ ; <nl> - size_t p_ ; <nl> BinTypeSize binTypeSize_ ; <nl> + size_t p_ ; <nl> + uint32_t * offset_ptr_ ; <nl> Func func_ ; <nl> } ; <nl> <nl> mmm a / src / common / quantile . h <nl> ppp b / src / common / quantile . h <nl> class QuantileSketchTemplate { <nl> / / check invariant <nl> size_t n = ( 1ULL < < nlevel ) ; <nl> CHECK ( n * limit_size > = maxn ) < < " invalid init parameter " ; <nl> - CHECK ( nlevel < = std : : max ( 1 , static_cast < int > ( limit_size * eps ) ) ) <nl> + CHECK ( nlevel < = std : : max ( static_cast < size_t > ( 1 ) , static_cast < size_t > ( limit_size * eps ) ) ) <nl> < < " invalid init parameter " ; <nl> } <nl> <nl> mmm a / src / data / data . cc <nl> ppp b / src / data / data . cc <nl> DMatrix * DMatrix : : Load ( const std : : string & uri , <nl> return dmat ; <nl> } <nl> <nl> - <nl> - / * <nl> - DMatrix * DMatrix : : Create ( std : : unique_ptr < DataSource < SparsePage > > & & source , <nl> - const std : : string & cache_prefix ) { <nl> - if ( cache_prefix . length ( ) = = 0 ) { <nl> - / / Data split mode is fixed to be row right now . <nl> - rabit : : Allreduce < rabit : : op : : Max > ( & source - > info . num_col_ , 1 ) ; <nl> - return new data : : SimpleDMatrix ( std : : move ( source ) ) ; <nl> - } else { <nl> - # if DMLC_ENABLE_STD_THREAD <nl> - return new data : : SparsePageDMatrix ( std : : move ( source ) , cache_prefix ) ; <nl> - # else <nl> - LOG ( FATAL ) < < " External memory is not enabled in mingw " ; <nl> - return nullptr ; <nl> - # endif / / DMLC_ENABLE_STD_THREAD <nl> - } <nl> - } <nl> - * / <nl> - <nl> template < typename AdapterT > <nl> DMatrix * DMatrix : : Create ( AdapterT * adapter , float missing , int nthread , <nl> const std : : string & cache_prefix , size_t page_size ) { <nl> mmm a / src / data / simple_dmatrix . h <nl> ppp b / src / data / simple_dmatrix . h <nl> class SimpleDMatrix : public DMatrix { <nl> explicit SimpleDMatrix ( AdapterT * adapter , float missing , int nthread ) ; <nl> <nl> explicit SimpleDMatrix ( dmlc : : Stream * in_stream ) ; <nl> + ~ SimpleDMatrix ( ) override = default ; <nl> <nl> void SaveToLocalFile ( const std : : string & fname ) ; <nl> <nl> mmm a / src / data / sparse_page_dmatrix . h <nl> ppp b / src / data / sparse_page_dmatrix . h <nl> class SparsePageDMatrix : public DMatrix { <nl> row_source_ . reset ( new data : : SparsePageSource ( adapter , missing , nthread , <nl> cache_prefix , page_size ) ) ; <nl> } <nl> - / / Set number of threads but keep old value so we can reset it after <nl> ~ SparsePageDMatrix ( ) override = default ; <nl> <nl> MetaInfo & Info ( ) override ; <nl> mmm a / tests / cpp / common / test_hist_util . cc <nl> ppp b / tests / cpp / common / test_hist_util . cc <nl> TEST ( hist_util , IndexBinData ) { <nl> size_t constexpr kRows = 100 ; <nl> size_t constexpr kCols = 10 ; <nl> <nl> - size_t bin_id = 0 ; <nl> for ( auto max_bin : kBinSizes ) { <nl> auto p_fmat = RandomDataGenerator ( kRows , kCols , 0 ) . GenerateDMatix ( ) ; <nl> common : : GHistIndexMatrix hmat ; <nl> TEST ( hist_util , SparseIndexBinData ) { <nl> size_t constexpr kRows = 100 ; <nl> size_t constexpr kCols = 10 ; <nl> <nl> - size_t bin_id = 0 ; <nl> for ( auto max_bin : bin_sizes ) { <nl> auto p_fmat = RandomDataGenerator ( kRows , kCols , 0 . 2 ) . GenerateDMatix ( ) ; <nl> common : : GHistIndexMatrix hmat ; <nl> mmm a / tests / cpp / data / test_simple_dmatrix . cc <nl> ppp b / tests / cpp / data / test_simple_dmatrix . cc <nl> TEST ( SimpleDMatrix , Empty ) { <nl> <nl> data : : CSRAdapter csr_adapter ( row_ptr . data ( ) , feature_idx . data ( ) , data . data ( ) , <nl> 0 , 0 , 0 ) ; <nl> - data : : SimpleDMatrix dmat ( & csr_adapter , <nl> - std : : numeric_limits < float > : : quiet_NaN ( ) , 1 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_nonzero_ , 0 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_row_ , 0 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_col_ , 0 ) ; <nl> - for ( auto & batch : dmat . GetBatches < SparsePage > ( ) ) { <nl> + std : : unique_ptr < data : : SimpleDMatrix > dmat ( new data : : SimpleDMatrix ( <nl> + & csr_adapter , std : : numeric_limits < float > : : quiet_NaN ( ) , 1 ) ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_nonzero_ , 0 ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_row_ , 0 ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_col_ , 0 ) ; <nl> + for ( auto & batch : dmat - > GetBatches < SparsePage > ( ) ) { <nl> CHECK_EQ ( batch . Size ( ) , 0 ) ; <nl> } <nl> <nl> data : : DenseAdapter dense_adapter ( nullptr , 0 , 0 ) ; <nl> - dmat = data : : SimpleDMatrix ( & dense_adapter , <nl> - std : : numeric_limits < float > : : quiet_NaN ( ) , 1 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_nonzero_ , 0 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_row_ , 0 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_col_ , 0 ) ; <nl> - for ( auto & batch : dmat . GetBatches < SparsePage > ( ) ) { <nl> + dmat . reset ( new data : : SimpleDMatrix ( & dense_adapter , <nl> + std : : numeric_limits < float > : : quiet_NaN ( ) , 1 ) ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_nonzero_ , 0 ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_row_ , 0 ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_col_ , 0 ) ; <nl> + for ( auto & batch : dmat - > GetBatches < SparsePage > ( ) ) { <nl> CHECK_EQ ( batch . Size ( ) , 0 ) ; <nl> } <nl> <nl> data : : CSCAdapter csc_adapter ( nullptr , nullptr , nullptr , 0 , 0 ) ; <nl> - dmat = data : : SimpleDMatrix ( & csc_adapter , <nl> - std : : numeric_limits < float > : : quiet_NaN ( ) , 1 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_nonzero_ , 0 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_row_ , 0 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_col_ , 0 ) ; <nl> - for ( auto & batch : dmat . GetBatches < SparsePage > ( ) ) { <nl> + dmat . reset ( new data : : SimpleDMatrix ( <nl> + & csc_adapter , std : : numeric_limits < float > : : quiet_NaN ( ) , 1 ) ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_nonzero_ , 0 ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_row_ , 0 ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_col_ , 0 ) ; <nl> + for ( auto & batch : dmat - > GetBatches < SparsePage > ( ) ) { <nl> CHECK_EQ ( batch . Size ( ) , 0 ) ; <nl> } <nl> } <nl> TEST ( SimpleDMatrix , MissingData ) { <nl> <nl> data : : CSRAdapter adapter ( row_ptr . data ( ) , feature_idx . data ( ) , data . data ( ) , 2 , <nl> 3 , 2 ) ; <nl> - data : : SimpleDMatrix dmat ( & adapter , std : : numeric_limits < float > : : quiet_NaN ( ) , <nl> - 1 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_nonzero_ , 2 ) ; <nl> - dmat = data : : SimpleDMatrix ( & adapter , 1 . 0 , 1 ) ; <nl> - CHECK_EQ ( dmat . Info ( ) . num_nonzero_ , 1 ) ; <nl> + std : : unique_ptr < data : : SimpleDMatrix > dmat { new data : : SimpleDMatrix { <nl> + & adapter , std : : numeric_limits < float > : : quiet_NaN ( ) , 1 } } ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_nonzero_ , 2 ) ; <nl> + dmat . reset ( new data : : SimpleDMatrix ( & adapter , 1 . 0 , 1 ) ) ; <nl> + CHECK_EQ ( dmat - > Info ( ) . num_nonzero_ , 1 ) ; <nl> } <nl> <nl> TEST ( SimpleDMatrix , EmptyRow ) { <nl>
Prevent copying SimpleDMatrix . ( )
dmlc/xgboost
29c6ad943a9e0f309b9f59ee4b49ae4caa83d65f
2020-04-01T23:01:49Z
mmm a / db / repl / consensus . cpp <nl> ppp b / db / repl / consensus . cpp <nl> <nl> * / <nl> <nl> # include " pch . h " <nl> + # include " . . / commands . h " <nl> # include " replset . h " <nl> # include " multicmd . h " <nl> <nl> namespace mongo { <nl> <nl> + class CmdReplSetElect : public Command { <nl> + public : <nl> + virtual bool slaveOk ( ) const { return true ; } <nl> + virtual bool adminOnly ( ) const { return true ; } <nl> + virtual bool logTheOp ( ) { return false ; } <nl> + virtual LockType locktype ( ) const { return NONE ; } <nl> + virtual void help ( stringstream & help ) const { help < < " internal " ; } <nl> + CmdReplSetElect ( ) : Command ( " replSetElect " ) { } <nl> + virtual bool run ( const string & , BSONObj & cmdObj , string & errmsg , BSONObjBuilder & result , bool fromRepl ) { <nl> + if ( ! replSet ) { <nl> + errmsg = " not running with - - replSet " ; <nl> + return false ; <nl> + } <nl> + if ( theReplSet = = 0 ) { <nl> + result . append ( " startupStatus " , ReplSet : : startupStatus ) ; <nl> + errmsg = ReplSet : : startupStatusMsg . empty ( ) ? " replset unknown error 2 " : ReplSet : : startupStatusMsg ; <nl> + return false ; <nl> + } <nl> + theReplSet - > elect . electCmdReceived ( cmdObj , result ) ; <nl> + return true ; <nl> + } <nl> + } cmdReplSetElect ; <nl> + <nl> int ReplSet : : Consensus : : totalVotes ( ) const { <nl> static int complain = 0 ; <nl> int vTot = rs . _self - > config ( ) . votes ; <nl> for ( Member * m = rs . head ( ) ; m ; m = m - > next ( ) ) <nl> vTot + = m - > config ( ) . votes ; <nl> if ( vTot % 2 = = 0 & & vTot & & complain + + = = 0 ) <nl> - log ( ) < < " replSet warning : total number of votes is even - considering giving one member an extra vote " < < rsLog ; <nl> + log ( ) < < " replSet warning total number of votes is even - considering giving one member an extra vote " < < rsLog ; <nl> return vTot ; <nl> } <nl> <nl> namespace mongo { <nl> <nl> const time_t LeaseTime = 30 ; <nl> <nl> - void ReplSet : : Consensus : : yea ( unsigned memberId ) { <nl> + unsigned ReplSet : : Consensus : : yea ( unsigned memberId ) / * throws VoteException * / { <nl> Atomic < LastYea > : : tran t ( ly ) ; <nl> LastYea & ly = t . ref ( ) ; <nl> time_t now = time ( 0 ) ; <nl> namespace mongo { <nl> throw VoteException ( ) ; <nl> ly . when = now ; <nl> ly . who = memberId ; <nl> + return rs . _self - > config ( ) . votes ; <nl> + } <nl> + <nl> + / * todo : threading * * * * * * * * * * * * * * * * ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! * / <nl> + void ReplSet : : Consensus : : electCmdReceived ( BSONObj cmd , BSONObjBuilder & b ) { <nl> + string name = cmd [ " name " ] . String ( ) ; <nl> + unsigned whoid = cmd [ " whoid " ] . Int ( ) ; <nl> + int cfgver = cmd [ " cfgver " ] . Int ( ) ; <nl> + OID round = cmd [ " round " ] . OID ( ) ; <nl> + int myver = rs . config ( ) . version ; <nl> + <nl> + int vote = 0 ; <nl> + if ( name ! = rs . name ( ) ) { <nl> + log ( ) < < " replSet error received an elect request for ' " < < name < < " ' but our set name is ' " < < rs . name ( ) < < " ' " < < rsLog ; <nl> + <nl> + } <nl> + else if ( myver < cfgver ) { <nl> + / / we are stale . don ' t vote <nl> + } <nl> + else if ( myver > cfgver ) { <nl> + / / they are stale ! <nl> + log ( ) < < " replSet info got stale version # during election " < < rsLog ; <nl> + vote = - 10000 ; <nl> + } <nl> + else { <nl> + try { <nl> + vote = yea ( whoid ) ; <nl> + } <nl> + catch ( VoteException & ) { <nl> + log ( ) < < " replSet voting no already voted for another " < < rsLog ; <nl> + } <nl> + } <nl> + <nl> + b . append ( " vote " , vote ) ; <nl> + b . append ( " round " , round ) ; <nl> } <nl> <nl> void ReplSet : : Consensus : : _electSelf ( ) { <nl> - ReplSet : : Member & me = * rs . _self ; <nl> + log ( ) < < " replSet info electSelf " < < rsLog ; <nl> + time_t start = time ( 0 ) ; <nl> + ReplSet : : Member & me = * rs . _self ; <nl> + int tally = yea ( me . id ( ) ) ; <nl> + <nl> BSONObj electCmd = BSON ( <nl> " replSetElect " < < 1 < < <nl> " set " < < rs . name ( ) < < <nl> " who " < < me . fullName ( ) < < <nl> " whoid " < < me . hbinfo ( ) . id ( ) < < <nl> - " cfgver " < < rs . _cfg - > version <nl> + " cfgver " < < rs . _cfg - > version < < <nl> + " round " < < OID : : gen ( ) / * this is just for diagnostics * / <nl> ) ; <nl> <nl> list < Target > L ; <nl> namespace mongo { <nl> if ( m - > hbinfo ( ) . up ( ) ) <nl> L . push_back ( Target ( m - > fullName ( ) ) ) ; <nl> <nl> - time_t start = time ( 0 ) ; <nl> multiCommand ( electCmd , L ) ; <nl> <nl> - int tally = me . config ( ) . votes ; / / we vote yes . ? <nl> for ( list < Target > : : iterator i = L . begin ( ) ; i ! = L . end ( ) ; i + + ) { <nl> - cout < < " TEMP electres : " < < i - > result . toString ( ) < < endl ; <nl> + cout < < " TEMP elect res : " < < i - > result . toString ( ) < < endl ; <nl> if ( i - > ok ) { <nl> int v = i - > result [ " vote " ] . Int ( ) ; <nl> tally + = v ; <nl> namespace mongo { <nl> log ( ) < < " replSet elected self as primary " < < rsLog ; <nl> return ; <nl> } <nl> + else { <nl> + log ( ) < < " replSet couldn ' t elect self , majority not achieved tally : " < < tally < < rsLog ; <nl> + } <nl> } <nl> <nl> void ReplSet : : Consensus : : electSelf ( ) { <nl> - try { _electSelf ( ) ; } catch ( . . . ) { } <nl> + try { <nl> + _electSelf ( ) ; <nl> + } <nl> + catch ( VoteException & ) { <nl> + log ( ) < < " replSet not trying to elect self as responded yea to someone else recently " < < rsLog ; <nl> + } <nl> + catch ( . . . ) { } <nl> } <nl> <nl> } <nl> mmm a / db / repl / health . cpp <nl> ppp b / db / repl / health . cpp <nl> namespace mongo { <nl> return v [ i ] ; <nl> } <nl> <nl> - static bool isWarning ( const char * line ) { <nl> + / * static bool isWarning ( const char * line ) { <nl> const char * p = strstr ( line , " replSet " ) ; <nl> if ( p ) { <nl> p + = 8 ; <nl> return startsWith ( p , " warning " ) | | startsWith ( p , " error " ) ; <nl> } <nl> return false ; <nl> + } * / <nl> + static string color ( string line ) { <nl> + string s = str : : after ( line , " replSet " ) ; <nl> + if ( str : : startsWith ( s , " warning " ) | | startsWith ( s , " error " ) ) <nl> + return red ( line ) ; <nl> + if ( str : : startsWith ( s , " info " ) ) { <nl> + if ( str : : endsWith ( s , " up \ n " ) ) <nl> + return green ( line ) ; <nl> + if ( str : : endsWith ( s , " down \ n " ) ) <nl> + return yellow ( line ) ; <nl> + return blue ( line ) ; <nl> + } <nl> + <nl> + return line ; <nl> } <nl> <nl> void fillRsLog ( stringstream & s ) { <nl> namespace mongo { <nl> assert ( strlen ( v [ i ] ) > 20 ) ; <nl> int r = repeats ( v , i ) ; <nl> if ( r < 0 ) { <nl> - s < < red ( clean ( v , i ) , isWarning ( v [ i ] ) ) ; <nl> + s < < color ( clean ( v , i ) ) ; <nl> } else { <nl> stringstream x ; <nl> x < < string ( v [ i ] , 0 , 20 ) ; <nl> mmm a / db / repl / replset . cpp <nl> ppp b / db / repl / replset . cpp <nl> namespace mongo { <nl> for ( Member * m = head ( ) ; m ; m = m - > next ( ) ) <nl> seedSet . erase ( m - > h ( ) ) ; <nl> for ( set < HostAndPort > : : iterator i = seedSet . begin ( ) ; i ! = seedSet . end ( ) ; i + + ) { <nl> - log ( ) < < " replSet warning : command line seed " < < i - > toString ( ) < < " is not present in the current repl set config " < < rsLog ; <nl> + log ( ) < < " replSet warning command line seed " < < i - > toString ( ) < < " is not present in the current repl set config " < < rsLog ; <nl> } <nl> } <nl> <nl> mmm a / db / repl / replset . h <nl> ppp b / db / repl / replset . h <nl> namespace mongo { <nl> public : <nl> static enum StartupStatus { <nl> PRESTART = 0 , LOADINGCONFIG = 1 , BADCONFIG = 2 , EMPTYCONFIG = 3 , <nl> - EMPTYUNREACHABLE = 4 , STARTED = 5 , SOON = 6 } startupStatus ; <nl> + EMPTYUNREACHABLE = 4 , STARTED = 5 , SOON = 6 <nl> + } startupStatus ; <nl> static string startupStatusMsg ; <nl> <nl> - private : <nl> - MemberState _myState ; <nl> - <nl> - public : <nl> void fatal ( ) ; <nl> bool isMaster ( const char * client ) ; <nl> void fillIsMaster ( BSONObjBuilder & ) ; <nl> namespace mongo { <nl> / * cfgString format is <nl> replsetname / host1 , host2 : port , . . . <nl> where : port is optional . <nl> - <nl> throws exception if a problem initializing . * / <nl> ReplSet ( string cfgString ) ; <nl> <nl> namespace mongo { <nl> const ReplSetConfig & config ( ) { return * _cfg ; } <nl> <nl> private : <nl> + MemberState _myState ; <nl> string _name ; <nl> const vector < HostAndPort > * _seeds ; <nl> ReplSetConfig * _cfg ; <nl> namespace mongo { <nl> unsigned who ; <nl> } ; <nl> Atomic < LastYea > ly ; <nl> - void yea ( unsigned memberId ) ; <nl> + unsigned yea ( unsigned memberId ) ; / / throws VoteException <nl> void _electSelf ( ) ; <nl> public : <nl> Consensus ( ReplSet * t ) : rs ( * t ) { } <nl> int totalVotes ( ) const ; <nl> bool aMajoritySeemsToBeUp ( ) const ; <nl> void electSelf ( ) ; <nl> + void electCmdReceived ( BSONObj , BSONObjBuilder & ) ; <nl> } elect ; <nl> <nl> public : <nl> namespace mongo { <nl> <nl> private : <nl> const Member * _currentPrimary ; <nl> - <nl> - static string stateAsStr ( MemberState state ) ; <nl> - static string stateAsHtml ( MemberState state ) ; <nl> - <nl> Member * _self ; <nl> / * all members of the set EXCEPT self . * / <nl> List1 < Member > _members ; <nl> - Member * head ( ) const { return _members . head ( ) ; } <nl> - <nl> - void startThreads ( ) ; <nl> - friend class FeedbackThread ; <nl> <nl> public : <nl> class Manager : public task : : Port { <nl> namespace mongo { <nl> } ; <nl> shared_ptr < Manager > mgr ; <nl> <nl> + private : <nl> + Member * head ( ) const { return _members . head ( ) ; } <nl> + static string stateAsStr ( MemberState state ) ; <nl> + static string stateAsHtml ( MemberState state ) ; <nl> + void startThreads ( ) ; <nl> + friend class FeedbackThread ; <nl> + friend class CmdReplSetElect ; <nl> } ; <nl> <nl> inline void ReplSet : : fatal ( ) <nl> mmm a / db / repl / replset_commands . cpp <nl> ppp b / db / repl / replset_commands . cpp <nl> namespace mongo { <nl> } <nl> if ( theReplSet = = 0 ) { <nl> result . append ( " startupStatus " , ReplSet : : startupStatus ) ; <nl> - errmsg = ReplSet : : startupStatusMsg . empty ( ) ? <nl> - errmsg = " replset unknown error 1 " : ReplSet : : startupStatusMsg ; <nl> + errmsg = ReplSet : : startupStatusMsg . empty ( ) ? " replset unknown error 1 " : ReplSet : : startupStatusMsg ; <nl> return false ; <nl> } <nl> <nl> mmm a / util / mongoutils / html . h <nl> ppp b / util / mongoutils / html . h <nl> namespace mongoutils { <nl> return ss . str ( ) ; <nl> } <nl> <nl> - inline string red ( string contentHtml , bool color ) { <nl> + inline string red ( string contentHtml , bool color = true ) { <nl> if ( ! color ) return contentHtml ; <nl> stringstream ss ; <nl> ss < < " < span style = \ " color : # A00 ; \ " > " < < contentHtml < < " < / span > " ; <nl> return ss . str ( ) ; <nl> } <nl> + inline string blue ( string contentHtml , bool color = true ) { <nl> + if ( ! color ) return contentHtml ; <nl> + stringstream ss ; <nl> + ss < < " < span style = \ " color : # 00A ; \ " > " < < contentHtml < < " < / span > " ; <nl> + return ss . str ( ) ; <nl> + } <nl> + inline string yellow ( string contentHtml , bool color = true ) { <nl> + if ( ! color ) return contentHtml ; <nl> + stringstream ss ; <nl> + ss < < " < span style = \ " color : # FD0 ; \ " > " < < contentHtml < < " < / span > " ; <nl> + return ss . str ( ) ; <nl> + } <nl> + inline string green ( string contentHtml , bool color = true ) { <nl> + if ( ! color ) return contentHtml ; <nl> + stringstream ss ; <nl> + ss < < " < span style = \ " color : # 0A0 ; \ " > " < < contentHtml < < " < / span > " ; <nl> + return ss . str ( ) ; <nl> + } <nl> <nl> inline string p ( string contentHtml ) { <nl> stringstream ss ; <nl> mmm a / util / mongoutils / str . h <nl> ppp b / util / mongoutils / str . h <nl> namespace mongoutils { <nl> <nl> using namespace std ; <nl> <nl> + inline bool startsWith ( const char * str , const char * prefix ) { <nl> + size_t l = strlen ( prefix ) ; <nl> + if ( strlen ( str ) < l ) return false ; <nl> + return strncmp ( str , prefix , l ) = = 0 ; <nl> + } <nl> + inline bool startsWith ( string s , string p ) { return startsWith ( s . c_str ( ) , p . c_str ( ) ) ; } <nl> + <nl> + inline bool endsWith ( string s , string p ) { <nl> + int l = p . size ( ) ; <nl> + int x = s . size ( ) ; <nl> + if ( x < l ) return false ; <nl> + return strncmp ( s . c_str ( ) + x - l , p . c_str ( ) , l ) = = 0 ; <nl> + } <nl> + <nl> / * * find char x , and return rest of string thereafter , or " " if not found * / <nl> inline const char * after ( const char * s , char x ) { <nl> const char * p = strchr ( s , x ) ; <nl> namespace mongoutils { <nl> const char * p = strchr ( s . c_str ( ) , x ) ; <nl> return ( p ! = 0 ) ? string ( p + 1 ) : " " ; } <nl> <nl> + inline const char * after ( const char * s , const char * x ) { <nl> + const char * p = strstr ( s , x ) ; <nl> + return ( p ! = 0 ) ? p + strlen ( x ) : " " ; } <nl> + inline string after ( string s , string x ) { <nl> + const char * p = strstr ( s . c_str ( ) , x . c_str ( ) ) ; <nl> + return ( p ! = 0 ) ? string ( p + x . size ( ) ) : " " ; } <nl> + <nl> + inline bool contains ( string s , string x ) { <nl> + return strstr ( s . c_str ( ) , x . c_str ( ) ) ! = 0 ; } <nl> + <nl> / * * @ return everything befor the character x , else entire string * / <nl> inline string before ( const string & s , char x ) { <nl> const char * p = strchr ( s . c_str ( ) , x ) ; <nl>
rs
mongodb/mongo
1b1fbec129cd118b90c2299405929729e1cecef6
2010-05-24T17:38:53Z
mmm a / src / hydrogen - check - elimination . cc <nl> ppp b / src / hydrogen - check - elimination . cc <nl> class HCheckTable : public ZoneObject { <nl> ReduceCompareObjectEqAndBranch ( HCompareObjectEqAndBranch : : cast ( instr ) ) ; <nl> break ; <nl> } <nl> + case HValue : : kIsStringAndBranch : { <nl> + ReduceIsStringAndBranch ( HIsStringAndBranch : : cast ( instr ) ) ; <nl> + break ; <nl> + } <nl> case HValue : : kTransitionElementsKind : { <nl> ReduceTransitionElementsKind ( <nl> HTransitionElementsKind : : cast ( instr ) ) ; <nl> class HCheckTable : public ZoneObject { <nl> ReduceCheckHeapObject ( HCheckHeapObject : : cast ( instr ) ) ; <nl> break ; <nl> } <nl> + case HValue : : kCheckInstanceType : { <nl> + ReduceCheckInstanceType ( HCheckInstanceType : : cast ( instr ) ) ; <nl> + break ; <nl> + } <nl> default : { <nl> / / If the instruction changes maps uncontrollably , drop everything . <nl> if ( instr - > CheckChangesFlag ( kOsrEntries ) ) { <nl> class HCheckTable : public ZoneObject { <nl> } <nl> } <nl> / / Improvements possible : <nl> - / / - eliminate redundant HCheckSmi , HCheckInstanceType instructions <nl> + / / - eliminate redundant HCheckSmi instructions <nl> / / - track which values have been HCheckHeapObject ' d <nl> } <nl> <nl> class HCheckTable : public ZoneObject { <nl> ASSERT_NE ( HCheckTableEntry : : UNCHECKED_STABLE , re - > state_ ) ; <nl> } <nl> learned = true ; <nl> + } else if ( end - > IsIsStringAndBranch ( ) ) { <nl> + HIsStringAndBranch * cmp = HIsStringAndBranch : : cast ( end ) ; <nl> + HValue * object = cmp - > value ( ) - > ActualValue ( ) ; <nl> + HCheckTableEntry * entry = copy - > Find ( object ) ; <nl> + if ( is_true_branch ) { <nl> + / / Learn on the true branch of if ( IsString ( x ) ) . <nl> + if ( entry = = NULL ) { <nl> + copy - > Insert ( object , NULL , string_maps ( ) , <nl> + HCheckTableEntry : : CHECKED ) ; <nl> + } else { <nl> + EnsureChecked ( entry , object , cmp ) ; <nl> + entry - > maps_ = entry - > maps_ - > Intersect ( string_maps ( ) , zone ) ; <nl> + ASSERT_NE ( HCheckTableEntry : : UNCHECKED_STABLE , entry - > state_ ) ; <nl> + } <nl> + } else { <nl> + / / Learn on the false branch of if ( IsString ( x ) ) . <nl> + if ( entry ! = NULL ) { <nl> + EnsureChecked ( entry , object , cmp ) ; <nl> + entry - > maps_ = entry - > maps_ - > Subtract ( string_maps ( ) , zone ) ; <nl> + ASSERT_NE ( HCheckTableEntry : : UNCHECKED_STABLE , entry - > state_ ) ; <nl> + } <nl> + } <nl> } <nl> / / Learning on false branches requires storing negative facts . <nl> } <nl> class HCheckTable : public ZoneObject { <nl> } <nl> } <nl> <nl> + void ReduceCheckInstanceType ( HCheckInstanceType * instr ) { <nl> + HValue * value = instr - > value ( ) - > ActualValue ( ) ; <nl> + HCheckTableEntry * entry = Find ( value ) ; <nl> + if ( entry = = NULL ) { <nl> + if ( instr - > check ( ) = = HCheckInstanceType : : IS_STRING ) { <nl> + Insert ( value , NULL , string_maps ( ) , HCheckTableEntry : : CHECKED ) ; <nl> + } <nl> + return ; <nl> + } <nl> + UniqueSet < Map > * maps = new ( zone ( ) ) UniqueSet < Map > ( <nl> + entry - > maps_ - > size ( ) , zone ( ) ) ; <nl> + for ( int i = 0 ; i < entry - > maps_ - > size ( ) ; + + i ) { <nl> + InstanceType type ; <nl> + Unique < Map > map = entry - > maps_ - > at ( i ) ; <nl> + { <nl> + / / This is safe , because maps don ' t move and their instance type does <nl> + / / not change . <nl> + AllowHandleDereference allow_deref ; <nl> + type = map . handle ( ) - > instance_type ( ) ; <nl> + } <nl> + if ( instr - > is_interval_check ( ) ) { <nl> + InstanceType first_type , last_type ; <nl> + instr - > GetCheckInterval ( & first_type , & last_type ) ; <nl> + if ( first_type < = type & & type < = last_type ) maps - > Add ( map , zone ( ) ) ; <nl> + } else { <nl> + uint8_t mask , tag ; <nl> + instr - > GetCheckMaskAndTag ( & mask , & tag ) ; <nl> + if ( ( type & mask ) = = tag ) maps - > Add ( map , zone ( ) ) ; <nl> + } <nl> + } <nl> + if ( maps - > size ( ) = = entry - > maps_ - > size ( ) ) { <nl> + TRACE ( ( " Removing redundant CheckInstanceType # % d at B % d \ n " , <nl> + instr - > id ( ) , instr - > block ( ) - > block_id ( ) ) ) ; <nl> + EnsureChecked ( entry , value , instr ) ; <nl> + instr - > DeleteAndReplaceWith ( value ) ; <nl> + INC_STAT ( removed_cit_ ) ; <nl> + } else if ( maps - > size ( ) ! = 0 ) { <nl> + entry - > maps_ = maps ; <nl> + if ( entry - > state_ = = HCheckTableEntry : : UNCHECKED_STABLE ) { <nl> + entry - > state_ = HCheckTableEntry : : CHECKED_STABLE ; <nl> + } <nl> + } <nl> + } <nl> + <nl> void ReduceLoadNamedField ( HLoadNamedField * instr ) { <nl> / / Reduce a load of the map field when it is known to be a constant . <nl> if ( ! instr - > access ( ) . IsMap ( ) ) { <nl> class HCheckTable : public ZoneObject { <nl> instr - > block ( ) - > MarkSuccEdgeUnreachable ( unreachable_succ ) ; <nl> } <nl> <nl> + void ReduceIsStringAndBranch ( HIsStringAndBranch * instr ) { <nl> + HValue * value = instr - > value ( ) - > ActualValue ( ) ; <nl> + HCheckTableEntry * entry = Find ( value ) ; <nl> + if ( entry = = NULL ) return ; <nl> + EnsureChecked ( entry , value , instr ) ; <nl> + int succ ; <nl> + if ( entry - > maps_ - > IsSubset ( string_maps ( ) ) ) { <nl> + TRACE ( ( " Marking redundant IsStringAndBranch # % d at B % d as true \ n " , <nl> + instr - > id ( ) , instr - > block ( ) - > block_id ( ) ) ) ; <nl> + succ = 0 ; <nl> + } else { <nl> + MapSet intersection = entry - > maps_ - > Intersect ( string_maps ( ) , zone ( ) ) ; <nl> + if ( intersection - > size ( ) > 0 ) return ; <nl> + TRACE ( ( " Marking redundant IsStringAndBranch # % d at B % d as false \ n " , <nl> + instr - > id ( ) , instr - > block ( ) - > block_id ( ) ) ) ; <nl> + succ = 1 ; <nl> + } <nl> + instr - > set_known_successor_index ( succ ) ; <nl> + int unreachable_succ = 1 - succ ; <nl> + instr - > block ( ) - > MarkSuccEdgeUnreachable ( unreachable_succ ) ; <nl> + } <nl> + <nl> void ReduceTransitionElementsKind ( HTransitionElementsKind * instr ) { <nl> HValue * object = instr - > object ( ) - > ActualValue ( ) ; <nl> HCheckTableEntry * entry = Find ( object ) ; <nl> class HCheckTable : public ZoneObject { <nl> } <nl> <nl> Zone * zone ( ) const { return phase_ - > zone ( ) ; } <nl> + MapSet string_maps ( ) const { return phase_ - > string_maps ( ) ; } <nl> <nl> friend class HCheckMapsEffects ; <nl> friend class HCheckEliminationPhase ; <nl> void HCheckEliminationPhase : : PrintStats ( ) { <nl> PRINT_STAT ( redundant ) ; <nl> PRINT_STAT ( removed ) ; <nl> PRINT_STAT ( removed_cho ) ; <nl> + PRINT_STAT ( removed_cit ) ; <nl> PRINT_STAT ( narrowed ) ; <nl> PRINT_STAT ( loads ) ; <nl> PRINT_STAT ( empty ) ; <nl> mmm a / src / hydrogen - check - elimination . h <nl> ppp b / src / hydrogen - check - elimination . h <nl> namespace internal { <nl> class HCheckEliminationPhase : public HPhase { <nl> public : <nl> explicit HCheckEliminationPhase ( HGraph * graph ) <nl> - : HPhase ( " H_Check Elimination " , graph ) , aliasing_ ( ) { <nl> + : HPhase ( " H_Check Elimination " , graph ) , aliasing_ ( ) , <nl> + string_maps_ ( kStringMapsSize , zone ( ) ) { <nl> + / / Compute the set of string maps . <nl> + # define ADD_STRING_MAP ( type , size , name , Name ) \ <nl> + string_maps_ . Add ( Unique < Map > : : CreateImmovable ( \ <nl> + graph - > isolate ( ) - > factory ( ) - > name # # _map ( ) ) , zone ( ) ) ; <nl> + STRING_TYPE_LIST ( ADD_STRING_MAP ) <nl> + # undef ADD_STRING_MAP <nl> + ASSERT_EQ ( kStringMapsSize , string_maps_ . size ( ) ) ; <nl> # ifdef DEBUG <nl> redundant_ = 0 ; <nl> removed_ = 0 ; <nl> removed_cho_ = 0 ; <nl> + removed_cit_ = 0 ; <nl> narrowed_ = 0 ; <nl> loads_ = 0 ; <nl> empty_ = 0 ; <nl> class HCheckEliminationPhase : public HPhase { <nl> friend class HCheckTable ; <nl> <nl> private : <nl> + const UniqueSet < Map > * string_maps ( ) const { return & string_maps_ ; } <nl> + <nl> void PrintStats ( ) ; <nl> <nl> HAliasAnalyzer * aliasing_ ; <nl> + # define COUNT ( type , size , name , Name ) + 1 <nl> + static const int kStringMapsSize = 0 STRING_TYPE_LIST ( COUNT ) ; <nl> + # undef COUNT <nl> + UniqueSet < Map > string_maps_ ; <nl> # ifdef DEBUG <nl> int redundant_ ; <nl> int removed_ ; <nl> int removed_cho_ ; <nl> + int removed_cit_ ; <nl> int narrowed_ ; <nl> int loads_ ; <nl> int empty_ ; <nl> mmm a / src / hydrogen - instructions . cc <nl> ppp b / src / hydrogen - instructions . cc <nl> bool HIsObjectAndBranch : : KnownSuccessorBlock ( HBasicBlock * * block ) { <nl> <nl> <nl> bool HIsStringAndBranch : : KnownSuccessorBlock ( HBasicBlock * * block ) { <nl> + if ( known_successor_index ( ) ! = kNoKnownSuccessorIndex ) { <nl> + * block = SuccessorAt ( known_successor_index ( ) ) ; <nl> + return true ; <nl> + } <nl> if ( FLAG_fold_constants & & value ( ) - > IsConstant ( ) ) { <nl> * block = HConstant : : cast ( value ( ) ) - > HasStringValue ( ) <nl> ? FirstSuccessor ( ) : SecondSuccessor ( ) ; <nl> return true ; <nl> } <nl> + if ( value ( ) - > type ( ) . IsString ( ) ) { <nl> + * block = FirstSuccessor ( ) ; <nl> + return true ; <nl> + } <nl> + if ( value ( ) - > type ( ) . IsSmi ( ) | | <nl> + value ( ) - > type ( ) . IsNull ( ) | | <nl> + value ( ) - > type ( ) . IsBoolean ( ) | | <nl> + value ( ) - > type ( ) . IsUndefined ( ) | | <nl> + value ( ) - > type ( ) . IsJSObject ( ) ) { <nl> + * block = SecondSuccessor ( ) ; <nl> + return true ; <nl> + } <nl> * block = NULL ; <nl> return false ; <nl> } <nl> mmm a / src / hydrogen - instructions . h <nl> ppp b / src / hydrogen - instructions . h <nl> class HCheckInstanceType V8_FINAL : public HUnaryOperation { <nl> void GetCheckInterval ( InstanceType * first , InstanceType * last ) ; <nl> void GetCheckMaskAndTag ( uint8_t * mask , uint8_t * tag ) ; <nl> <nl> + Check check ( ) const { return check_ ; } <nl> + <nl> DECLARE_CONCRETE_INSTRUCTION ( CheckInstanceType ) <nl> <nl> protected : <nl> class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction { <nl> <nl> virtual bool KnownSuccessorBlock ( HBasicBlock * * block ) V8_OVERRIDE ; <nl> <nl> + static const int kNoKnownSuccessorIndex = - 1 ; <nl> + int known_successor_index ( ) const { return known_successor_index_ ; } <nl> + void set_known_successor_index ( int known_successor_index ) { <nl> + known_successor_index_ = known_successor_index ; <nl> + } <nl> + <nl> DECLARE_CONCRETE_INSTRUCTION ( IsStringAndBranch ) <nl> <nl> protected : <nl> class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction { <nl> HIsStringAndBranch ( HValue * value , <nl> HBasicBlock * true_target = NULL , <nl> HBasicBlock * false_target = NULL ) <nl> - : HUnaryControlInstruction ( value , true_target , false_target ) { } <nl> + : HUnaryControlInstruction ( value , true_target , false_target ) , <nl> + known_successor_index_ ( kNoKnownSuccessorIndex ) { } <nl> + <nl> + int known_successor_index_ ; <nl> } ; <nl> <nl> <nl> mmm a / src / unique . h <nl> ppp b / src / unique . h <nl> class UniqueSet V8_FINAL : public ZoneObject { <nl> return out ; <nl> } <nl> <nl> + / / Returns a new set representing all elements from this set which are not in <nl> + / / that set . O ( | this | * | that | ) . <nl> + UniqueSet < T > * Subtract ( const UniqueSet < T > * that , Zone * zone ) const { <nl> + if ( that - > size_ = = 0 ) return this - > Copy ( zone ) ; <nl> + <nl> + UniqueSet < T > * out = new ( zone ) UniqueSet < T > ( this - > size_ , zone ) ; <nl> + <nl> + int i = 0 , j = 0 ; <nl> + while ( i < this - > size_ ) { <nl> + Unique < T > cand = this - > array_ [ i ] ; <nl> + if ( ! that - > Contains ( cand ) ) { <nl> + out - > array_ [ j + + ] = cand ; <nl> + } <nl> + } <nl> + <nl> + out - > size_ = j ; <nl> + return out ; <nl> + } <nl> + <nl> / / Makes an exact copy of this set . O ( | this | ) . <nl> UniqueSet < T > * Copy ( Zone * zone ) const { <nl> UniqueSet < T > * copy = new ( zone ) UniqueSet < T > ( this - > size_ , zone ) ; <nl>
Handle HCheckInstanceType and HIsStringAndBranch in check elimination .
v8/v8
1c17e61629f41d43dfa412a19fef84fe531a8e72
2014-06-02T08:51:25Z
mmm a / modules / core / src / hal_internal . cpp <nl> ppp b / modules / core / src / hal_internal . cpp <nl> lapack_QR ( fptype * a , size_t a_step , int m , int n , int k , fptype * b , size_t b_ste <nl> else if ( typeid ( fptype ) = = typeid ( double ) ) <nl> dgels_ ( mode , & m , & n , & k , ( double * ) tmpA , & ldtmpA , ( double * ) b , & m , ( double * ) & work1 , & lwork , info ) ; <nl> <nl> - lwork = ( int ) round ( work1 ) ; / / optimal buffer size <nl> + lwork = cvRound ( work1 ) ; / / optimal buffer size <nl> std : : vector < fptype > workBufMemHolder ( lwork + 1 ) ; <nl> fptype * buffer = & workBufMemHolder . front ( ) ; <nl> <nl> lapack_QR ( fptype * a , size_t a_step , int m , int n , int k , fptype * b , size_t b_ste <nl> else if ( typeid ( fptype ) = = typeid ( double ) ) <nl> dgels_ ( mode , & m , & n , & k , ( double * ) tmpA , & ldtmpA , ( double * ) tmpB , & m , ( double * ) & work1 , & lwork , info ) ; <nl> <nl> - lwork = ( int ) round ( work1 ) ; / / optimal buffer size <nl> + lwork = cvRound ( work1 ) ; / / optimal buffer size <nl> std : : vector < fptype > workBufMemHolder ( lwork + 1 ) ; <nl> fptype * buffer = & workBufMemHolder . front ( ) ; <nl> <nl> lapack_QR ( fptype * a , size_t a_step , int m , int n , int k , fptype * b , size_t b_ste <nl> else if ( typeid ( fptype ) = = typeid ( double ) ) <nl> dgeqrf_ ( & m , & n , ( double * ) tmpA , & ldtmpA , ( double * ) dst , ( double * ) & work1 , & lwork , info ) ; <nl> <nl> - lwork = ( int ) round ( work1 ) ; / / optimal buffer size <nl> + lwork = cvRound ( work1 ) ; / / optimal buffer size <nl> std : : vector < fptype > workBufMemHolder ( lwork + 1 ) ; <nl> fptype * buffer = & workBufMemHolder . front ( ) ; <nl> <nl>
Merge pull request from sovrasov : hal_round_to_cvround
opencv/opencv
a9e33fe54edca15cdb667f765fbeb6f3e1831290
2017-02-22T15:52:10Z
mmm a / modules / calib3d / src / fisheye . cpp <nl> ppp b / modules / calib3d / src / fisheye . cpp <nl> void cv : : fisheye : : estimateNewCameraMatrixForUndistortRectify ( InputArray K , Input <nl> int w = image_size . width , h = image_size . height ; <nl> balance = std : : min ( std : : max ( balance , 0 . 0 ) , 1 . 0 ) ; <nl> <nl> - cv : : Mat points ( 1 , 4 , CV_64FC2 ) ; <nl> + cv : : Mat points ( 1 , 8 , CV_64FC2 ) ; <nl> Vec2d * pptr = points . ptr < Vec2d > ( ) ; <nl> - pptr [ 0 ] = Vec2d ( w / 2 , 0 ) ; <nl> - pptr [ 1 ] = Vec2d ( w , h / 2 ) ; <nl> - pptr [ 2 ] = Vec2d ( w / 2 , h ) ; <nl> - pptr [ 3 ] = Vec2d ( 0 , h / 2 ) ; <nl> + pptr [ 0 ] = Vec2d ( 0 , 0 ) ; <nl> + pptr [ 1 ] = Vec2d ( w / 2 , 0 ) ; <nl> + pptr [ 2 ] = Vec2d ( w , 0 ) ; <nl> + pptr [ 3 ] = Vec2d ( w , h / 2 ) ; <nl> + pptr [ 4 ] = Vec2d ( w , h ) ; <nl> + pptr [ 5 ] = Vec2d ( w / 2 , h ) ; <nl> + pptr [ 6 ] = Vec2d ( 0 , h ) ; <nl> + pptr [ 7 ] = Vec2d ( 0 , h / 2 ) ; <nl> <nl> # if 0 <nl> const int N = 10 ; <nl> void cv : : fisheye : : estimateNewCameraMatrixForUndistortRectify ( InputArray K , Input <nl> { <nl> pptr [ k + + ] = Vec2d ( w / 2 , 0 ) - Vec2d ( w / 8 , 0 ) + Vec2d ( w / 4 / N * i , 0 ) ; <nl> pptr [ k + + ] = Vec2d ( w / 2 , h - 1 ) - Vec2d ( w / 8 , h - 1 ) + Vec2d ( w / 4 / N * i , h - 1 ) ; <nl> - <nl> pptr [ k + + ] = Vec2d ( 0 , h / 2 ) - Vec2d ( 0 , h / 8 ) + Vec2d ( 0 , h / 4 / N * i ) ; <nl> pptr [ k + + ] = Vec2d ( w - 1 , h / 2 ) - Vec2d ( w - 1 , h / 8 ) + Vec2d ( w - 1 , h / 4 / N * i ) ; <nl> } <nl> void cv : : fisheye : : estimateNewCameraMatrixForUndistortRectify ( InputArray K , Input <nl> double minx = DBL_MAX , miny = DBL_MAX , maxx = - DBL_MAX , maxy = - DBL_MAX ; <nl> for ( size_t i = 0 ; i < points . total ( ) ; + + i ) <nl> { <nl> - miny = std : : min ( miny , pptr [ i ] [ 1 ] ) ; <nl> - maxy = std : : max ( maxy , pptr [ i ] [ 1 ] ) ; <nl> - minx = std : : min ( minx , pptr [ i ] [ 0 ] ) ; <nl> - maxx = std : : max ( maxx , pptr [ i ] [ 0 ] ) ; <nl> + if ( i ! = 1 & & i ! = 5 ) { <nl> + minx = std : : min ( minx , std : : abs ( pptr [ i ] [ 0 ] - cn [ 0 ] ) ) ; <nl> + } <nl> + if ( i ! = 3 & & i ! = 7 ) { <nl> + miny = std : : min ( miny , std : : abs ( pptr [ i ] [ 1 ] - cn [ 1 ] ) ) ; <nl> + } <nl> + maxy = std : : max ( maxy , std : : abs ( pptr [ i ] [ 1 ] - cn [ 1 ] ) ) ; <nl> + maxx = std : : max ( maxx , std : : abs ( pptr [ i ] [ 0 ] - cn [ 0 ] ) ) ; <nl> } <nl> <nl> # if 0 <nl> void cv : : fisheye : : estimateNewCameraMatrixForUndistortRectify ( InputArray K , Input <nl> } <nl> # endif <nl> <nl> - double f1 = w * 0 . 5 / ( cn [ 0 ] - minx ) ; <nl> - double f2 = w * 0 . 5 / ( maxx - cn [ 0 ] ) ; <nl> - double f3 = h * 0 . 5 * aspect_ratio / ( cn [ 1 ] - miny ) ; <nl> - double f4 = h * 0 . 5 * aspect_ratio / ( maxy - cn [ 1 ] ) ; <nl> + double f1 = w * 0 . 5 / ( minx ) ; <nl> + double f2 = w * 0 . 5 / ( maxx ) ; <nl> + double f3 = h * 0 . 5 * aspect_ratio / ( miny ) ; <nl> + double f4 = h * 0 . 5 * aspect_ratio / ( maxy ) ; <nl> <nl> - double fmin = std : : min ( f1 , std : : min ( f2 , std : : min ( f3 , f4 ) ) ) ; <nl> - double fmax = std : : max ( f1 , std : : max ( f2 , std : : max ( f3 , f4 ) ) ) ; <nl> + double fmax = std : : max ( f1 , f3 ) ; <nl> + double fmin = std : : min ( f2 , f4 ) ; <nl> <nl> double f = balance * fmin + ( 1 . 0 - balance ) * fmax ; <nl> f * = fov_scale > 0 ? 1 . 0 / fov_scale : 1 . 0 ; <nl>
Merge pull request from jbosch : master
opencv/opencv
fbc44bcb78d61a0e081c9d2106436b650d0e3567
2016-09-22T11:57:06Z
mmm a / lib / AST / ASTPrinter . cpp <nl> ppp b / lib / AST / ASTPrinter . cpp <nl> <nl> # include < queue > <nl> <nl> using namespace swift ; <nl> - namespace swift { <nl> <nl> struct SynthesizedExtensionAnalyzer : : Implementation { <nl> static bool isMemberFavored ( const NominalTypeDecl * Target , const Decl * D ) { <nl> hasMergeGroup ( MergeGroupKind Kind ) { <nl> } <nl> return false ; <nl> } <nl> - } / / end anonymous namespace <nl> <nl> PrintOptions PrintOptions : : printTypeInterface ( Type T ) { <nl> PrintOptions result = printInterface ( ) ; <nl>
Merge pull request from practicalswift / namespace - mismatch
apple/swift
e830110227e633e9cb58b5ba1cee9ee44f5924e6
2016-12-21T21:03:18Z
mmm a / MachineLearning / CNTK / CNTK . cpp <nl> ppp b / MachineLearning / CNTK / CNTK . cpp <nl> void PrintBuiltInfo ( ) <nl> fprintf ( stderr , " \ t \ tCUDA_PATH : % s \ n " , _CUDA_PATH_ ) ; <nl> # endif <nl> # ifdef _CUB_PATH_ <nl> - fprintf ( stderr , " \ t \ tCUDA_PATH : % s \ n " , _CUB_PATH_ ) ; <nl> + fprintf ( stderr , " \ t \ tCUB_PATH : % s \ n " , _CUB_PATH_ ) ; <nl> # endif <nl> # ifdef _GIT_EXIST <nl> fprintf ( stderr , " \ t \ tBuild Branch : % s \ n " , _BUILDBRANCH_ ) ; <nl> mmm a / MachineLearning / CNTKComputationNetworkLib / ComputationNetwork . h <nl> ppp b / MachineLearning / CNTKComputationNetworkLib / ComputationNetwork . h <nl> class ComputationNetwork : public ScriptableObjects : : Object , public ScriptableOb <nl> m_deviceId = EnforceOneGPUOnly ( m_deviceId ) ; / / see EnforceOneGPUOnly ( ) for comment on what this is <nl> } <nl> <nl> - DEVICEID_TYPE GetDeviceId ( ) { return m_deviceId ; } <nl> + DEVICEID_TYPE GetDeviceId ( ) const { return m_deviceId ; } <nl> <nl> unsigned long GetRandomSeedOffset ( ) { return m_randomSeedOffset ; } <nl> void SetRandomSeedOffset ( unsigned long value ) { m_randomSeedOffset = value ; } <nl> mmm a / MachineLearning / CNTKComputationNetworkLib / ComputationNode . h <nl> ppp b / MachineLearning / CNTKComputationNetworkLib / ComputationNode . h <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> virtual ~ IComputationNode ( ) { } <nl> } ; <nl> <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / This provide a interface for stateful node ( e . g . , DelayNodeBase ) and definition of state <nl> + / / This interface allows to Export and Import state from elsewhere <nl> + / / It is needed when doing sub - minibatch implementation <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + class INodeState : public std : : enable_shared_from_this < INodeState > <nl> + { <nl> + public : <nl> + virtual ~ INodeState ( ) { } <nl> + } ; <nl> + <nl> + struct / * interface * / IStateFulNode <nl> + { <nl> + typedef std : : shared_ptr < INodeState > NodeStatePtr ; <nl> + virtual NodeStatePtr ExportState ( ) = 0 ; <nl> + virtual void ImportState ( const NodeStatePtr & pImportedState ) = 0 ; <nl> + } ; <nl> + <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> / / ComputationNetworkOwnedNodeState - - class to collect ComputationNode members that are really owned by ComputationNetwork <nl> / / These members are only to be set , changed , and read by ComputationNetwork code . <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> } <nl> } ; <nl> <nl> + <nl> + <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> / / helper macro to ease access to base members in presence of C + + two - phase name lookup <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> mmm a / MachineLearning / CNTKComputationNetworkLib / RecurrentNodes . h <nl> ppp b / MachineLearning / CNTKComputationNetworkLib / RecurrentNodes . h <nl> <nl> <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / The following defines a state of a delay node which is going to be exported to others ( saving for the next minibatch ) <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + template < class ElemType > <nl> + class DelayedValueNodeState : public INodeState <nl> + { <nl> + <nl> + public : <nl> + DelayedValueNodeState ( int deviceID ) : <nl> + m_cachedActivity ( ( size_t ) 0 , ( size_t ) 0 , deviceID ) , m_delayedActivationMBLayout ( nullptr ) , m_isEmpty ( true ) <nl> + { } <nl> + void CacheDelayedMBLayout ( const MBLayoutPtr & pMBLayout ) <nl> + { <nl> + m_delayedActivationMBLayout = make_shared < MBLayout > ( ) ; <nl> + m_delayedActivationMBLayout - > CopyFrom ( pMBLayout ) ; <nl> + } <nl> + void CacheState ( const Matrix < ElemType > & cachedActivity ) <nl> + { <nl> + m_cachedActivity . SetValue ( cachedActivity ) ; <nl> + m_isEmpty = false ; <nl> + } <nl> + void ExportDelayedMBLayout ( MBLayoutPtr & pMBLayout ) <nl> + { <nl> + pMBLayout - > CopyFrom ( m_delayedActivationMBLayout ) ; <nl> + } <nl> + bool IsEmpty ( ) <nl> + { <nl> + return m_isEmpty ; <nl> + } <nl> + const Matrix < ElemType > & ExportCachedActivity ( ) <nl> + { <nl> + return m_cachedActivity ; <nl> + } <nl> + <nl> + protected : <nl> + Matrix < ElemType > m_cachedActivity ; / / 1 column per parallel sequence <nl> + / / MBLayoutPtr m_shiftedMBLayout ; <nl> + / / Currently , we only support saving state for m_timeStep = = 1 <nl> + / / there is no need for this m_shiftedMBLayout if m_timeStep = = 1 <nl> + MBLayoutPtr m_delayedActivationMBLayout ; <nl> + bool m_isEmpty ; / / in some case <nl> + / / ( e . g . , at the boundary of sentence end or begin / full utterance mode ) , we don ' t need to store state ( but we do need to need know m_delayedActivationMBLayout ) <nl> + } ; <nl> + <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / DelayedValueNodeBase ( input ) - - abstract base class for PastValueNode and FutureValueNode to hold all shared code <nl> / / The two differ in the step direction , some loop directions , and sequence - boundary flags . <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> <nl> / / TODO : ' direction ' is really too general . signOfTimeOffset ? <nl> template < class ElemType , int direction / * - 1 for Past / left - to - right or + 1 for Future / right - to - left * / , MinibatchPackingFlags SequenceStart_or_End / * - Start or - End * / > <nl> - class DelayedValueNodeBase : public ComputationNode < ElemType > , public ILateAttachingNode , public NumInputs < 1 > <nl> + class DelayedValueNodeBase : public ComputationNode < ElemType > , public <nl> + ILateAttachingNode , public IStateFulNode , public NumInputs < 1 > <nl> { <nl> typedef ComputationNode < ElemType > Base ; UsingComputationNodeMembersBoilerplate ; <nl> + typedef std : : shared_ptr < DelayedValueNodeState < ElemType > > DelayedNodeStatePtr ; <nl> static const std : : wstring TypeName ( ) { return L " DelayedValue " ; } <nl> private : <nl> void Init ( size_t row_size , size_t col_size , ElemType initialActivationValue = ( ElemType ) DEFAULT_HIDDEN_ACTIVATION ) <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> } <nl> } <nl> <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / implement the IStateFulNode interface <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + virtual NodeStatePtr ExportState ( ) override <nl> + { <nl> + NodeStatePtr pExportedState ; <nl> + size_t nT = m_pMBLayout - > GetNumTimeSteps ( ) ; <nl> + size_t nU = m_pMBLayout - > GetNumParallelSequences ( ) ; <nl> + int dir = direction ; <nl> + if ( m_timeStep ! = 1 ) <nl> + { <nl> + / / not support yet ; give user a hint <nl> + RuntimeError ( " Currently importing / exporting state info for timeStep > 1 is not supported . Contact erw @ microsoft . com for more detail " ) ; <nl> + } <nl> + if ( dir = = - 1 ) / / we look into past <nl> + { <nl> + bool allAtBoundary = true ; <nl> + / / if the current last frames are all sentence end or no feature , there is no need to carry on state info <nl> + if ( m_pMBLayout - > Is ( nT - 1 , MinibatchPackingFlags : : SequenceEnd | MinibatchPackingFlags : : NoFeature ) ) <nl> + { <nl> + for ( size_t u = 0 ; u < nU ; u + + ) <nl> + { <nl> + if ( ! m_pMBLayout - > Is ( u , nT - 1 , MinibatchPackingFlags : : SequenceEnd | MinibatchPackingFlags : : NoFeature ) ) <nl> + { <nl> + allAtBoundary = false ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + else <nl> + { <nl> + allAtBoundary = false ; <nl> + } <nl> + <nl> + if ( allAtBoundary ) <nl> + { <nl> + auto pState = make_shared < DelayedValueNodeState < ElemType > > ( m_deviceId ) ; <nl> + pState - > CacheDelayedMBLayout ( m_delayedActivationMBLayout ) ; <nl> + / / return an empty one <nl> + } <nl> + else <nl> + { <nl> + auto pState = make_shared < DelayedValueNodeState < ElemType > > ( m_deviceId ) ; <nl> + / / pState - > CacheState ( FunctionValues ( ) . Reshaped ( nD * nU , nT ) . RowSlice ( nD * ( nT - 1 ) , nD ) ) ; <nl> + pState - > CacheState ( m_delayedActivation . ColumnSlice ( ( nT - 1 ) * nU , nU ) ) ; <nl> + pState - > CacheDelayedMBLayout ( m_delayedActivationMBLayout ) ; <nl> + pExportedState = pState ; <nl> + } <nl> + } <nl> + if ( dir = = 1 ) / / we look into future <nl> + { <nl> + / / TODO : check whether all at boundary and don ' t carry state if it is the case <nl> + size_t nT = m_pMBLayout - > GetNumTimeSteps ( ) ; <nl> + size_t nU = m_pMBLayout - > GetNumParallelSequences ( ) ; <nl> + bool allAtBoundary = true ; <nl> + if ( m_pMBLayout - > Is ( 0 , MinibatchPackingFlags : : NoFeature | MinibatchPackingFlags : : SequenceStart ) ) <nl> + { <nl> + for ( size_t u = 0 ; u < nU ; u + + ) <nl> + { <nl> + if ( ! m_pMBLayout - > Is ( u , 0 , MinibatchPackingFlags : : SequenceStart | MinibatchPackingFlags : : NoFeature ) ) <nl> + { <nl> + allAtBoundary = false ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( allAtBoundary ) <nl> + { <nl> + auto pState = make_shared < DelayedValueNodeState < ElemType > > ( m_deviceId ) ; <nl> + pState - > CacheDelayedMBLayout ( m_delayedActivationMBLayout ) ; <nl> + pExportedState = pState ; <nl> + } <nl> + else <nl> + { <nl> + auto pState = make_shared < DelayedValueNodeState < ElemType > > ( m_deviceId ) ; <nl> + pState - > CacheState ( m_delayedActivation . ColumnSlice ( ( nT - 1 ) * nU , nU ) ) ; <nl> + pState - > CacheDelayedMBLayout ( m_delayedActivationMBLayout ) ; <nl> + pExportedState = pState ; <nl> + } <nl> + <nl> + <nl> + } <nl> + if ( dir ! = - 1 & & dir ! = 1 ) <nl> + { <nl> + RuntimeError ( " Unrecognized direction in DelayedValueNodeBase " ) ; <nl> + } <nl> + return pExportedState ; <nl> + } <nl> + virtual void ImportState ( const NodeStatePtr & pImportedState ) override <nl> + { <nl> + DelayedNodeStatePtr pState = dynamic_pointer_cast < DelayedValueNodeState < ElemType > > ( pImportedState ) ; <nl> + <nl> + if ( ! pState ) <nl> + RuntimeError ( " Expecting DelayValueNodeState after down casting " ) ; <nl> + <nl> + pState - > ExportDelayedMBLayout ( m_delayedActivationMBLayout ) ; / / pstate copy to m_delayedActivationMBLayout <nl> + if ( pState - > IsEmpty ( ) ) <nl> + { <nl> + return ; <nl> + } <nl> + <nl> + const Matrix < ElemType > & delayedActivation = pState - > ExportCachedActivity ( ) ; <nl> + size_t nT = m_delayedActivationMBLayout - > GetNumTimeSteps ( ) ; <nl> + size_t nU = m_delayedActivationMBLayout - > GetNumParallelSequences ( ) ; <nl> + <nl> + int dir = direction ; <nl> + if ( dir = = - 1 ) / / looking backward <nl> + { <nl> + m_delayedActivation . SetColumnSlice ( delayedActivation , ( nT - 1 ) * nU , nU ) ; <nl> + } <nl> + if ( dir = = 1 ) <nl> + { <nl> + / / m_delayedActivation . CopyColumnsStrided ( delayedActivation , nU , 1 , nT ) ; <nl> + m_delayedActivation . SetColumnSlice ( delayedActivation , 0 , nU ) ; <nl> + } <nl> + if ( dir ! = - 1 & & dir = = 1 ) <nl> + { / / it is really a compile error ? <nl> + RuntimeError ( " Unrecognized direction in DelayedValueNodeBase " ) ; <nl> + } <nl> + <nl> + } <nl> protected : <nl> <nl> ElemType m_initialActivationValue ; / / starting value for hidden activation vector at boundary <nl> mmm a / MachineLearning / CNTKSGDLib / DataReaderHelpers . h <nl> ppp b / MachineLearning / CNTKSGDLib / DataReaderHelpers . h <nl> <nl> # include < map > <nl> # include " TrainingCriterionNodes . h " <nl> <nl> + / / # define SMB_DEBUG <nl> + <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> <nl> / * static * / struct DataReaderHelpers <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> } <nl> } ; <nl> <nl> + / / SubminibatchHelpers <nl> + / / Helper for sub - minibatch implementation <nl> + / / A sub - minibathc is a part of a minibatch which helps computing large minibatches that cannot load into GPU memory in one forward - backward computation <nl> + / / The usage would be : <nl> + / / SubminibatchHelpers sbhelper ; <nl> + / / for ( ; ; ) <nl> + / / { <nl> + / / size_t nsb = sb . GetMinibatchIntoCache ( . . . ) ; <nl> + / / for ( size_t i = 0 ; i < nsb ; i + + ) <nl> + / / { <nl> + / / sbhelper . GetSubMinibatchToNet ( i ) ; <nl> + / / net . Evaluate ( criterionNodes [ 0 ] ) ; <nl> + / / sbhelper . DoneWithCurrentSubMinibatch ( ) ; <nl> + / / } <nl> + / / UpdateWeights ( . . . ) ; <nl> + / / } <nl> + <nl> + template < class ElemType > <nl> + class SubminibatchDispatcher <nl> + { <nl> + private : <nl> + typedef std : : vector < shared_ptr < const msra : : dbn : : latticesource : : latticepair > > Lattice ; <nl> + typedef std : : vector < size_t > Uid ; <nl> + typedef std : : vector < size_t > ExtrauttMap ; <nl> + <nl> + typedef std : : vector < shared_ptr < const msra : : dbn : : latticesource : : latticepair > > * LatticePtr ; <nl> + typedef std : : vector < size_t > * UidPtr ; <nl> + typedef std : : vector < size_t > * ExtrauttMapPtr ; <nl> + typedef std : : map < std : : wstring , Matrix < ElemType > * > Matrices ; <nl> + <nl> + <nl> + / / member variables served as caching space <nl> + Matrices m_inputMatricesCache ; <nl> + MBLayoutPtr m_MBLayoutCache ; <nl> + LatticePtr m_LatticeCache ; <nl> + UidPtr m_uidCache ; <nl> + ExtrauttMapPtr m_extrauttmapCache ; <nl> + shared_ptr < Matrix < ElemType > > m_NetCriterionAccumulator ; <nl> + shared_ptr < Matrix < ElemType > > m_NetEvaluationAccumulator ; <nl> + std : : map < wstring , vector < shared_ptr < INodeState > > > m_NetStates ; / / m_NetStatefulNodes [ node ] [ i ] caches the state of i - th subminibatch of node <nl> + <nl> + <nl> + Matrices m_CachedGraident ; <nl> + / / we also need to remember where to put into the net <nl> + MBLayoutPtr m_NetMBLayoutPtr ; <nl> + std : : map < wstring , shared_ptr < ComputationNode < ElemType > > > m_LearnableNodePtr ; <nl> + / / followings are lattice - related <nl> + Matrices m_NetInputMatrixPtr ; <nl> + LatticePtr m_NetLatticePtr ; <nl> + UidPtr m_NetUidPtr ; <nl> + ExtrauttMapPtr m_NetExtrauttMapPtr ; <nl> + / / we remember the pointer to the learnable Nodes so that we can accumulate the gradient once a sub - minibatch is done <nl> + <nl> + <nl> + size_t m_numParallelSequences ; / / number of paralle sequence in the cached matrix and MBLayout <nl> + size_t m_numSubminibatches ; / / how many subminibatches we are going to use ? <nl> + <nl> + std : : vector < shared_ptr < ComputationNode < ElemType > > > m_NetCriterionNodes ; <nl> + std : : vector < shared_ptr < ComputationNode < ElemType > > > m_NetEvaluationNodes ; <nl> + std : : map < wstring , shared_ptr < IStateFulNode > > m_NetStatefulNodes ; / / we need to Export / Import states of stateful nodes when we swtich subminibatches <nl> + <nl> + private : <nl> + <nl> + void EnumerateStatefulNodeWithRoot ( ComputationNetwork & net , ComputationNodeBasePtr root , std : : map < wstring , shared_ptr < IStateFulNode > > & statefulnode ) <nl> + { <nl> + std : : list < ComputationNodeBasePtr > evalorder = net . GetEvalOrder ( root , false ) ; <nl> + for ( auto & x : evalorder ) <nl> + { <nl> + wstring name = x - > GetName ( ) ; <nl> + if ( statefulnode . find ( name ) ! = statefulnode . end ( ) ) continue ; / / already in the list <nl> + shared_ptr < IStateFulNode > pNode = dynamic_pointer_cast < IStateFulNode > ( x ) ; <nl> + if ( pNode ) <nl> + { <nl> + statefulnode [ name ] = pNode ; <nl> + } <nl> + } <nl> + } <nl> + std : : map < wstring , shared_ptr < IStateFulNode > > EnumerateStatefulNode ( ComputationNetwork & net , <nl> + const std : : vector < ComputationNodeBasePtr > & criterionNode , <nl> + const std : : vector < ComputationNodeBasePtr > & evaluationNode ) <nl> + { <nl> + std : : map < wstring , shared_ptr < IStateFulNode > > statefulnodes ; <nl> + for ( auto & root : criterionNode ) <nl> + { <nl> + EnumerateStatefulNodeWithRoot ( net , root , statefulnodes ) ; <nl> + } <nl> + for ( auto & root : evaluationNode ) <nl> + { <nl> + EnumerateStatefulNodeWithRoot ( net , root , statefulnodes ) ; <nl> + } <nl> + return statefulnodes ; <nl> + } <nl> + <nl> + public : <nl> + SubminibatchDispatcher ( ) : <nl> + m_MBLayoutCache ( nullptr ) , m_LatticeCache ( nullptr ) , m_uidCache ( nullptr ) , m_extrauttmapCache ( nullptr ) <nl> + { } <nl> + <nl> + void Init ( ComputationNetworkPtr & net , <nl> + const std : : list < ComputationNodeBasePtr > & learnableNodes , <nl> + const std : : vector < ComputationNodeBasePtr > & criterionNodes , <nl> + const std : : vector < ComputationNodeBasePtr > & evaluationNodes ) <nl> + { <nl> + m_MBLayoutCache = make_shared < MBLayout > ( ) ; <nl> + m_NetCriterionAccumulator = make_shared < Matrix < ElemType > > ( 1 , 1 , net - > GetDeviceId ( ) ) ; <nl> + m_NetEvaluationAccumulator = make_shared < Matrix < ElemType > > ( 1 , evaluationNodes . size ( ) , net - > GetDeviceId ( ) ) ; <nl> + / / remember ptr to learnableNode <nl> + for ( auto x : learnableNodes ) <nl> + { <nl> + shared_ptr < ComputationNode < ElemType > > pLearnableNode = dynamic_pointer_cast < ComputationNode < ElemType > > ( x ) ; <nl> + wstring nodename = x - > NodeName ( ) ; <nl> + m_LearnableNodePtr [ nodename ] = pLearnableNode ; <nl> + } <nl> + for ( auto & x : criterionNodes ) <nl> + { <nl> + m_NetCriterionNodes . push_back ( dynamic_pointer_cast < ComputationNode < ElemType > > ( x ) ) ; <nl> + } <nl> + for ( auto & x : evaluationNodes ) <nl> + { <nl> + m_NetEvaluationNodes . push_back ( dynamic_pointer_cast < ComputationNode < ElemType > > ( x ) ) ; <nl> + } <nl> + m_NetCriterionAccumulator - > SetValue ( ( ElemType ) 0 ) ; <nl> + m_NetEvaluationAccumulator - > SetValue ( ( ElemType ) 0 ) ; <nl> + <nl> + / / emulate all the nodes , find nodes that have state <nl> + m_NetStatefulNodes = EnumerateStatefulNode ( * net , criterionNodes , evaluationNodes ) ; <nl> + for ( auto x : m_NetStatefulNodes ) <nl> + { <nl> + wstring name = x . first ; <nl> + m_NetStates [ name ] = vector < shared_ptr < INodeState > > ( ) ; <nl> + } <nl> + } <nl> + <nl> + ~ SubminibatchDispatcher ( ) <nl> + { <nl> + / / TODO : remove these by using shared_ptr <nl> + delete m_LatticeCache ; <nl> + delete m_uidCache ; <nl> + delete m_extrauttmapCache ; <nl> + <nl> + for ( auto x : m_inputMatricesCache ) <nl> + { <nl> + delete x . second ; <nl> + } <nl> + <nl> + for ( auto x : m_CachedGraident ) <nl> + { <nl> + delete x . second ; <nl> + } <nl> + } <nl> + size_t GetMinibatchIntoCache ( IDataReader < ElemType > & trainSetDataReader , <nl> + ComputationNetwork & net , <nl> + std : : map < std : : wstring , Matrix < ElemType > * > & inputMatrices , <nl> + size_t requestedSubminibatches ) <nl> + { <nl> + / / first , remember interface to the net <nl> + m_NetMBLayoutPtr = net . GetMBLayoutPtr ( ) ; <nl> + m_NetInputMatrixPtr = inputMatrices ; <nl> + <nl> + / / second , get data from reader , stored it in cache <nl> + / / 1 . for each key , allocate the specific matrix on device <nl> + for ( auto pa : inputMatrices ) <nl> + { <nl> + wstring name = pa . first ; <nl> + Matrix < ElemType > * M = pa . second ; <nl> + if ( m_inputMatricesCache . find ( name ) = = m_inputMatricesCache . end ( ) ) <nl> + { <nl> + m_inputMatricesCache [ name ] = new Matrix < ElemType > ( * M , M - > GetDeviceId ( ) ) ; / / deep copy from M <nl> + } <nl> + else <nl> + { <nl> + m_inputMatricesCache [ name ] - > SetValue ( * M ) ; <nl> + } <nl> + } <nl> + / / 2 . MBlayout <nl> + m_MBLayoutCache - > CopyFrom ( net . GetMBLayoutPtr ( ) ) ; <nl> + size_t nParallelSequences = m_MBLayoutCache - > GetNumParallelSequences ( ) ; <nl> + <nl> + if ( m_NetCriterionNodes [ 0 ] ! = nullptr & & ( m_NetCriterionNodes [ 0 ] - > OperationName ( ) = = L " SequenceWithSoftmax " ) ) <nl> + { <nl> + / / auto node = dynamic_pointer_cast < SequenceWithSoftmaxNode < ElemType > > ( criterionNode ) ; <nl> + NOT_IMPLEMENTED ; <nl> + / / TODO : implement this for Sequence training ! ! ! <nl> + } <nl> + <nl> + / / subminibatches are cutted at the parallel sequence level ; <nl> + / / if # requested subminibatch is larger than # parallel sequence , <nl> + / / we cannot split further ; instead , each subsequence become a subminibatch <nl> + size_t actualnumSubminibatches = requestedSubminibatches > nParallelSequences ? nParallelSequences : requestedSubminibatches ; <nl> + <nl> + / / 3 . third , allocate space for accumulated gradient <nl> + for ( auto & n : m_LearnableNodePtr ) <nl> + { <nl> + auto node = n . second ; <nl> + if ( node - > IsParameterUpdateRequired ( ) ) <nl> + { <nl> + wstring nodeName = node - > GetName ( ) ; <nl> + shared_ptr < ComputationNode < ElemType > > pLearnableNode = node ; <nl> + auto funvalue = pLearnableNode - > FunctionValues ( ) ; / / gradient may not be allocated when this function is first called <nl> + size_t nrow = funvalue . GetNumRows ( ) ; <nl> + size_t ncol = funvalue . GetNumCols ( ) ; <nl> + if ( m_CachedGraident . find ( nodeName ) = = m_CachedGraident . end ( ) ) <nl> + { <nl> + / / not allocated yet <nl> + m_CachedGraident [ nodeName ] = new Matrix < ElemType > ( nrow , ncol , funvalue . GetDeviceId ( ) ) ; <nl> + m_CachedGraident [ nodeName ] - > SetValue ( ( ElemType ) 0 ) ; <nl> + } <nl> + } <nl> + } <nl> + / / 4 . for stateful node <nl> + for ( auto x : m_NetStatefulNodes ) <nl> + { <nl> + wstring name = x . first ; <nl> + if ( m_NetStates [ name ] . empty ( ) ) <nl> + { <nl> + / / this only happens in the first minibatch in an epoch <nl> + m_NetStates [ name ] . resize ( actualnumSubminibatches ) ; <nl> + } <nl> + } <nl> + <nl> + return ( m_numSubminibatches = actualnumSubminibatches ) ; <nl> + } <nl> + <nl> + void GetSubMinibatchToNet ( size_t iSubminibatch ) <nl> + { <nl> + Matrices decimatedMatrices ; <nl> + MBLayoutPtr decimatedLayout ; <nl> + DataReaderHelpers : : DecimateMinibatch ( m_inputMatricesCache , decimatedMatrices , m_MBLayoutCache , decimatedLayout , m_numSubminibatches , iSubminibatch ) ; <nl> + / / NOTE : decimatedMatrices must be released by caller <nl> + <nl> + / / m_NetInputMatrixPtr = decimatedMatrices ; <nl> + for ( auto & x : decimatedMatrices ) <nl> + { <nl> + wstring name = x . first ; <nl> + m_NetInputMatrixPtr [ name ] - > SetValue ( * x . second ) ; <nl> + delete x . second ; / / TODO : is it safe to delete here ? Yes ! SetValue call cuda memcpy so it is a blocking call <nl> + x . second = nullptr ; <nl> + } <nl> + <nl> + m_NetMBLayoutPtr - > CopyFrom ( decimatedLayout ) ; <nl> + <nl> + for ( auto & x : m_NetStatefulNodes ) <nl> + { <nl> + wstring name = x . first ; <nl> + shared_ptr < IStateFulNode > pNode = x . second ; <nl> + if ( m_NetStates [ name ] [ iSubminibatch ] ) <nl> + pNode - > ImportState ( m_NetStates [ name ] [ iSubminibatch ] ) ; <nl> + } <nl> + <nl> + } <nl> + / / TODO : encapsulate it into a destructor ! ! ! Note : Cannot throw exceptions in destructor . <nl> + void DoneWithCurrentSubMinibatch ( size_t iSubminibatch ) <nl> + { <nl> + / / accumulate gradient here <nl> + for ( auto x : m_CachedGraident ) <nl> + { <nl> + wstring nodename = x . first ; <nl> + if ( m_LearnableNodePtr . find ( nodename ) = = m_LearnableNodePtr . end ( ) ) <nl> + { <nl> + RuntimeError ( " ERROR : in DoneWithCurrentSubMinibatch : node % ls not found in LeanrableNode " , nodename . c_str ( ) ) ; <nl> + } <nl> + shared_ptr < ComputationNode < ElemType > > pNode = m_LearnableNodePtr [ nodename ] ; <nl> + m_CachedGraident [ nodename ] - > operator + = ( pNode - > GradientValues ( ) ) ; <nl> + pNode - > GradientValues ( ) . SetValue ( ( ElemType ) 0 ) ; <nl> + } <nl> + / / accumulate criterion value <nl> + Matrix < ElemType > : : AddElementToElement ( <nl> + m_NetCriterionNodes [ 0 ] - > FunctionValues ( ) , 0 , 0 , <nl> + * m_NetCriterionAccumulator , 0 , 0 <nl> + ) ; <nl> + m_NetCriterionNodes [ 0 ] - > FunctionValues ( ) . SetValue ( ( ElemType ) 0 ) ; <nl> + / / accumulate evaluation value <nl> + for ( size_t i = 0 ; i < m_NetEvaluationNodes . size ( ) ; i + + ) <nl> + { <nl> + Matrix < ElemType > : : AddElementToElement ( <nl> + m_NetEvaluationNodes [ i ] - > FunctionValues ( ) , 0 , 0 , <nl> + * m_NetEvaluationAccumulator , 0 , i <nl> + ) ; <nl> + m_NetEvaluationNodes [ i ] - > FunctionValues ( ) . SetValue ( ( ElemType ) 0 ) ; <nl> + } <nl> + <nl> + / / Export node state <nl> + for ( auto & x : m_NetStatefulNodes ) <nl> + { <nl> + wstring name = x . first ; <nl> + m_NetStates [ name ] [ iSubminibatch ] = x . second - > ExportState ( ) ; <nl> + } <nl> + } <nl> + void DoneWithCurrentMinibatch ( ) <nl> + { <nl> + for ( auto & x : m_CachedGraident ) <nl> + { <nl> + wstring name = x . first ; <nl> + Matrix < ElemType > * accumulategrad = x . second ; <nl> + <nl> + if ( m_LearnableNodePtr . find ( name ) = = m_LearnableNodePtr . end ( ) ) <nl> + { <nl> + / / should never happen , remove this code later <nl> + RuntimeError ( " ERROR : in DoneWithCurrentSubMinibatch : node % ls not found in LearnableNode " , name . c_str ( ) ) ; <nl> + } <nl> + m_LearnableNodePtr [ name ] - > GradientValues ( ) . SetValue ( * accumulategrad ) ; <nl> + x . second - > SetValue ( ( ElemType ) 0 ) ; <nl> + } <nl> + / / also revert net . m_MBLayoutPtr <nl> + m_NetMBLayoutPtr - > CopyFrom ( m_MBLayoutCache ) ; <nl> + <nl> + / / m_NetCriterionNodes [ 0 ] - > FunctionValues ( ) . SetValue ( ( ElemType ) 0 ) ; <nl> + Matrix < ElemType > : : AddElementToElement ( <nl> + * m_NetCriterionAccumulator , 0 , 0 , <nl> + m_NetCriterionNodes [ 0 ] - > FunctionValues ( ) , 0 , 0 <nl> + ) ; <nl> + m_NetCriterionAccumulator - > SetValue ( ( ElemType ) 0 ) ; <nl> + <nl> + for ( size_t i = 0 ; i < m_NetEvaluationNodes . size ( ) ; i + + ) <nl> + { <nl> + / / m_NetEvaluationNodes [ i ] - > FunctionValues ( ) . SetValue ( ( ElemType ) 0 ) ; <nl> + Matrix < ElemType > : : AddElementToElement ( <nl> + * m_NetEvaluationAccumulator , 0 , i , <nl> + m_NetEvaluationNodes [ i ] - > FunctionValues ( ) , 0 , 0 <nl> + ) ; <nl> + } <nl> + m_NetEvaluationAccumulator - > SetValue ( ( ElemType ) 0 ) ; <nl> + } <nl> + <nl> + # ifdef SMB_DEBUG <nl> + <nl> + template < class Matrix , class ElemType > <nl> + void WriteMatrix ( const Matrix & mat , string filename ) <nl> + { <nl> + ElemType * pArray = mat . CopyToArray ( ) ; <nl> + size_t nRows = mat . GetNumRows ( ) ; <nl> + size_t nCols = mat . GetNumCols ( ) ; <nl> + FILE * fp = fopenOrDie ( filename , " w " ) ; <nl> + for ( size_t r = 0 ; r < nRows ; r + + ) <nl> + { <nl> + for ( size_t c = 0 ; c < nCols ; c + + ) <nl> + { <nl> + fprintf ( fp , " % . 9f " , pArray [ nRows * c + r ] ) ; <nl> + } <nl> + fprintf ( fp , " \ n " ) ; <nl> + } <nl> + fcloseOrDie ( fp ) ; <nl> + delete [ ] pArray ; <nl> + } <nl> + void WriteMBLayout ( MBLayoutPtr pMBLayout , wstring filename ) <nl> + { <nl> + size_t nT = pMBLayout - > GetNumTimeSteps ( ) ; <nl> + size_t nU = pMBLayout - > GetNumParallelSequences ( ) ; <nl> + <nl> + FILE * fp = fopenOrDie ( filename , L " w " ) ; <nl> + for ( size_t u = 0 ; u < nU ; u + + ) <nl> + { <nl> + for ( size_t t = 0 ; t < nT ; t + + ) <nl> + { <nl> + MinibatchPackingFlags flag = pMBLayout - > Get ( u , t ) ; <nl> + fprintf ( fp , " % d \ t " , ( int ) flag ) ; <nl> + } <nl> + fprintf ( fp , " \ n " ) ; <nl> + } <nl> + fcloseOrDie ( fp ) ; <nl> + } <nl> + void WriteInputMatriceAndMBLayout ( size_t mbID , size_t smbID ) <nl> + { <nl> + wstring node = L " features " ; <nl> + wstring filename = msra : : strfun : : wstrprintf ( L " tmp / % s . % d . % d " , node . c_str ( ) , mbID , smbID ) ; <nl> + if ( m_NetInputMatrixPtr . find ( node ) ! = m_NetInputMatrixPtr . end ( ) ) <nl> + { <nl> + WriteMatrix < Matrix < ElemType > , ElemType > ( * m_NetInputMatrixPtr [ node ] , msra : : strfun : : wcstombs ( filename ) ) ; <nl> + } <nl> + wstring fn = msra : : strfun : : wstrprintf ( L " tmp / Layout . % d . % d " , mbID , smbID ) ; <nl> + WriteMBLayout ( m_NetMBLayoutPtr , fn ) ; <nl> + } <nl> + void WriteInputMatriceAndMBLayout ( Matrices m , MBLayoutPtr pMBLayout , size_t mbID ) <nl> + { <nl> + wstring filename = msra : : strfun : : wstrprintf ( L " tmp / features . % d " , mbID ) ; <nl> + wstring fn = msra : : strfun : : wstrprintf ( L " tmp / layout . % d " , mbID ) ; <nl> + if ( m . find ( L " features " ) ! = m . end ( ) ) <nl> + { <nl> + WriteMatrix < Matrix < ElemType > , ElemType > ( * m [ L " features " ] , msra : : strfun : : wcstombs ( filename ) ) ; <nl> + } <nl> + WriteMBLayout ( pMBLayout , fn ) ; <nl> + } <nl> + <nl> + void WriteGradient ( size_t mbID ) <nl> + { <nl> + wstring node = L " LSTMoutput1 . bias " ; <nl> + wstring filename = msra : : strfun : : wstrprintf ( L " % s . % d " , L " tmp / gradient " , mbID ) ; <nl> + if ( m_CachedGraident . find ( node ) ! = m_CachedGraident . end ( ) ) <nl> + { <nl> + WriteMatrix < Matrix < ElemType > , ElemType > ( * m_CachedGraident [ node ] , msra : : strfun : : wcstombs ( filename ) ) ; <nl> + } <nl> + } <nl> + <nl> + void WriteGradient ( const Matrix < ElemType > & mat , wstring fn ) <nl> + { <nl> + WriteMatrix < Matrix < ElemType > , ElemType > ( mat , msra : : strfun : : wcstombs ( fn ) ) ; <nl> + } <nl> + # endif / / SMB_DEBUG <nl> + } ; <nl> + <nl> } } } <nl> mmm a / MachineLearning / CNTKSGDLib / SGD . cpp <nl> ppp b / MachineLearning / CNTKSGDLib / SGD . cpp <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> / / truncated = truncation length <nl> m_mbSize = configSGD ( L " minibatchSize " , ConfigRecordType : : Array ( intargvector ( vector < int > { 256 } ) ) ) ; <nl> m_truncated = configSGD ( L " truncated " , false ) ; <nl> + m_maxSamplesInRAM = configSGD ( L " maxSamplesInRAM " , ConfigRecordType : : Array ( intargvector ( vector < int > { 0 } ) ) ) ; <nl> <nl> / / the number of samples in each epoch ( 0 means , use all the samples in each epoch ) . <nl> m_epochSize = configSGD ( L " epochSize " , ( size_t ) 0 ) ; <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> refNet - > StartEvaluateMinibatchLoop ( refNode ) ; <nl> } <nl> <nl> + SubminibatchDispatcher < ElemType > smbDisplatcher ; <nl> + size_t samplesInRAM = m_maxSamplesInRAM [ epochNumber ] ; <nl> + / / convert it to SubminibatchRequested <nl> + size_t numSubminibatchRequested = 0 ; <nl> + if ( samplesInRAM > 0 ) / / if samplesInRAM = 0 , we will not use subminibatch dispatcher <nl> + { <nl> + size_t nParallelSequences = trainSetDataReader - > GetNumParallelSequences ( ) ; <nl> + size_t estimatedMBSize = tunedMBSize * nParallelSequences ; <nl> + numSubminibatchRequested = ( size_t ) std : : ceil ( estimatedMBSize / samplesInRAM ) ; <nl> + } <nl> + if ( numSubminibatchRequested > 1 ) / / only use subminibatch dispatcher if more than 1 subminibatch is required <nl> + { <nl> + smbDisplatcher . Init ( net , learnableNodes , criterionNodes , evaluationNodes ) ; <nl> + } <nl> + size_t actualNumSubminibatch = 0 ; <nl> + <nl> / / Attemps to compute the error signal for the whole utterance , which will <nl> / / be fed to the neural network as features . Currently it is a workaround <nl> / / for the two - forward - pass sequence and ctc training , which allows <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> fprintf ( stderr , " , DataParallelSGD training ( MyRank = % d , NumNodes = % d , NumGradientBits = % d ) " , <nl> ( int ) g_mpi - > CurrentNodeRank ( ) , ( int ) g_mpi - > NumNodesInUse ( ) , ( int ) m_numGradientBits ) ; <nl> } <nl> - <nl> if ( useDistributedMBReading ) <nl> { <nl> - fprintf ( stderr , " , Distributed reading is ENABLED " ) ; <nl> + fprintf ( stderr , " , distributed reading is ENABLED " ) ; <nl> + } <nl> + if ( numSubminibatchRequested > 0 ) <nl> + { <nl> + fprintf ( stderr , " , with % d Max Samples in RAM " , ( int ) samplesInRAM ) ; <nl> } <nl> fprintf ( stderr , " . \ n " ) ; <nl> <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> <nl> nSamplesSinceLastModelSync + = actualMBSize ; <nl> <nl> + if ( numSubminibatchRequested > 0 ) <nl> + { <nl> + actualNumSubminibatch = smbDisplatcher . GetMinibatchIntoCache ( * trainSetDataReader , * net , * inputMatrices , numSubminibatchRequested ) ; <nl> + } <nl> + else <nl> + { <nl> + actualNumSubminibatch = 0 ; <nl> + } <nl> + <nl> / / node data was changed <nl> / / TODO : move this to that function as well - - just tired to pass everything as arguments <nl> / / TODO : We should do this right after the GetMinibatch ( ) call , since that ' s where these changed . <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> <nl> / / compute eval node first since when gradient is computed the forward function values <nl> / / may be changed and need to be recomputed when gradient and function value share the same matrix <nl> - net - > Evaluate ( evaluationNodes ) ; <nl> - <nl> - / / only compute gradient when learning rate is large enough <nl> - if ( learnRatePerSample > m_minLearnRate * 0 . 01 ) <nl> + if ( actualNumSubminibatch > 0 ) <nl> { <nl> - / / use only the first criterion . Is there any possibility to use more ? <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / forward prop , back - prop - - this is where the magic happens baby , what we have all be waiting for ! <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - net - > ComputeGradient < ElemType > ( criterionNodes [ 0 ] ) ; <nl> - / / TODO : we should split Evaluate ( ) out from ComputeGradient ( ) , then call them ForwardProp ( ) and BackProp ( ) , for clarity <nl> + for ( size_t ismb = 0 ; ismb < actualNumSubminibatch ; ismb + + ) <nl> + { <nl> + smbDisplatcher . GetSubMinibatchToNet ( ismb ) ; <nl> + # ifdef SMB_DEBUG <nl> + / / smbhelper . WriteInputMatriceAndMBLayout ( numMBsRun , ismb ) ; <nl> + # endif <nl> + ComputationNetwork : : UpdateEvalTimeStamps ( featureNodes ) ; <nl> + ComputationNetwork : : UpdateEvalTimeStamps ( labelNodes ) ; <nl> + ForwardBackward ( * net , evaluationNodes , criterionNodes [ 0 ] , learnRatePerSample > 0 . 01 * m_minLearnRate ) ; <nl> + smbDisplatcher . DoneWithCurrentSubMinibatch ( ismb ) ; <nl> + } <nl> + # ifdef SMB_DEBUG <nl> + / / smbhelper . WriteGradient ( numMBsRun ) ; <nl> + # endif <nl> + smbDisplatcher . DoneWithCurrentMinibatch ( ) ; <nl> + <nl> } <nl> - else <nl> + else <nl> { <nl> - / / use only the first criterion . Is there any possibility to use more ? <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - / / forward prop <nl> - / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - net - > Evaluate ( criterionNodes [ 0 ] ) ; <nl> + ForwardBackward ( * net , evaluationNodes , criterionNodes [ 0 ] , learnRatePerSample > 0 . 01 * m_minLearnRate ) ; <nl> } <nl> + <nl> } / / if ( actualMBSize > 0 ) <nl> <nl> / / Some labels may be missing ( e . g . forced alignment failed , or being gaps due to packing parallel sequences ) . <nl> mmm a / MachineLearning / CNTKSGDLib / SGD . h <nl> ppp b / MachineLearning / CNTKSGDLib / SGD . h <nl> struct SGDParams : public ScriptableObjects : : Object <nl> / / We really should only read it in SGD and pass it ourselves on to the Reader , instead of it being a Reader parameter . <nl> / / BUGBUG : If m_truncated , then m_mbSize is interpreted as truncation length ; the actual MB size is a combination of that and the # parallel sequences specified in the reader . <nl> / / TODO : do not specify ' Truncated ' but ' TruncatedLength ' , set m_truncated so given , and let m_mbSize control how many # parallel sequences the reader is allowed to pack into an MB . <nl> + intargvector m_maxSamplesInRAM ; <nl> + / / This is related with subminibatch implementation <nl> + / / maxSamplesInRAM denotes how many samples we used in forward - backward on net . <nl> + / / Due to the GPU memory limitations , it is sometime not possible to hold the m_mbSize in RAM . <nl> + / / To mitigate this issue , we adopt the sub - minibatch implementation , where <nl> + / / each m_mbSize [ epoch ] is divided by a few sub - minibatch of which size will be no more than m_maxSamplesInRAM [ epoch ] <nl> + / / a forward - backward is performed for each sub - minibathch ; a model update is performed after each minibatch <nl> + <nl> <nl> / / the number of samples in each epoch ( 0 means , use all the samples in each epoch ) . <nl> size_t m_epochSize ; <nl> class SGD : public SGDParams <nl> <nl> private : <nl> int SGDTrace ( FILE * __restrict __stream , const char * __restrict __format , . . . ) ; <nl> + void ForwardBackward ( ComputationNetwork & net , const std : : vector < ComputationNodeBasePtr > & evalNodes , shared_ptr < ComputationNodeBase > criterionNode , bool dobackpropogate = true ) <nl> + { <nl> + net . Evaluate ( evalNodes ) ; <nl> + / / only compute gradient when learning rate is large enough <nl> + if ( dobackpropogate ) <nl> + { <nl> + / / use only the first criterion . Is there any possibility to use more ? <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / forward prop , back - prop - - this is where the magic happens baby , what we have all be waiting for ! <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + net . ComputeGradient < ElemType > ( criterionNode ) ; <nl> + / / TODO : we should split Evaluate ( ) out from ComputeGradient ( ) , then call them ForwardProp ( ) and BackProp ( ) , for clarity <nl> + } <nl> + else <nl> + { <nl> + / / use only the first criterion . Is there any possibility to use more ? <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / forward prop <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + net . Evaluate ( criterionNode ) ; <nl> + } <nl> + } <nl> } ; <nl> <nl> } } } <nl> new file mode 100644 <nl> index 00000000000 . . 5c581efe1f5 <nl> mmm / dev / null <nl> ppp b / Math / CNTKMathTest / CPUMatrixUnitTests . cpp <nl> <nl> + / / <nl> + / / < copyright file = " CPUMatrixUnitTests . cpp " company = " Microsoft " > <nl> + / / Copyright ( c ) Microsoft Corporation . All rights reserved . <nl> + / / < / copyright > <nl> + / / <nl> + # include " stdafx . h " <nl> + # include " CppUnitTest . h " <nl> + # include " . . \ Math \ CPUMatrix . h " <nl> + # define DEBUG_FLAG 1 <nl> + using namespace Microsoft : : MSR : : CNTK ; <nl> + <nl> + # pragma warning ( disable : 4305 ) <nl> + <nl> + using namespace Microsoft : : VisualStudio : : CppUnitTestFramework ; <nl> + <nl> + namespace CNTKMathTest <nl> + { <nl> + TEST_CLASS ( CPUMatrixUnitTest ) <nl> + { <nl> + / / typedef CPUSingleMatrix Matrix ; <nl> + typedef CPUDoubleMatrix Matrix ; <nl> + <nl> + public : <nl> + static void DebugPrint ( FILE * gpuDebugFile , Matrix M , const char * str , const bool colwiseVec = true ) <nl> + { <nl> + fprintf ( gpuDebugFile , " \ n % s \ n " , str ) ; <nl> + const size_t matNumCol = M . GetNumCols ( ) ; <nl> + const size_t elemNum = M . GetNumElements ( ) ; <nl> + Matrix M1 = M . Transpose ( ) ; <nl> + double * pArray = M1 . GetArray ( ) ; <nl> + if ( colwiseVec ) <nl> + { <nl> + for ( size_t i = 0 ; i < elemNum ; i + + ) <nl> + { <nl> + <nl> + fprintf ( gpuDebugFile , " % 3d " , ( int ) pArray [ i ] ) ; <nl> + if ( ( i + 1 ) % matNumCol = = 0 ) <nl> + fprintf ( gpuDebugFile , " \ n " ) ; <nl> + } <nl> + } <nl> + / / const size_t matNumRow = M . GetNumRows ( ) ; <nl> + / / for ( int i = 0 ; i < matNumRow ; i + + ) <nl> + / / { <nl> + / / for ( int j = 0 ; j < matNumCol ; j + + ) <nl> + / / { <nl> + / / fprintf ( gpuDebugFile , " % 3d " , M ( i , j ) ) ; <nl> + / / / / if ( ( j + 1 ) % matNumCol = = 0 ) <nl> + / / } <nl> + / / fprintf ( gpuDebugFile , " \ n " ) ; <nl> + / / } <nl> + } <nl> + TEST_METHOD ( CPUMatrixConsturctors ) <nl> + { <nl> + Matrix M0 ; <nl> + Assert : : IsTrue ( M0 . IsEmpty ( ) ) ; <nl> + <nl> + M0 . Resize ( 2 , 3 ) ; <nl> + Assert : : IsFalse ( M0 . IsEmpty ( ) ) ; <nl> + Assert : : AreEqual < size_t > ( 2 , M0 . GetNumRows ( ) ) ; <nl> + Assert : : AreEqual < size_t > ( 3 , M0 . GetNumCols ( ) ) ; <nl> + Assert : : AreEqual < size_t > ( 6 , M0 . GetNumElements ( ) ) ; <nl> + <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 1 , 2 ) = 2 ; <nl> + Assert : : IsTrue ( M0 ( 0 , 0 ) = = 1 ) ; <nl> + Assert : : IsTrue ( M0 ( 1 , 2 ) = = 2 ) ; <nl> + <nl> + Matrix M1 ( 12 , 53 ) ; <nl> + Assert : : AreEqual < size_t > ( 12 , M1 . GetNumRows ( ) ) ; <nl> + Assert : : AreEqual < size_t > ( 53 , M1 . GetNumCols ( ) ) ; <nl> + <nl> + <nl> + float * fArray = new float [ 6 ] ; <nl> + fArray [ 0 ] = 1 ; fArray [ 1 ] = 2 ; fArray [ 2 ] = 3 ; <nl> + fArray [ 3 ] = 4 ; fArray [ 4 ] = 5 ; fArray [ 5 ] = 6 ; <nl> + CPUMatrix < float > M2 ( 2 , 3 , fArray , matrixFlagNormal ) ; <nl> + Assert : : AreEqual < float > ( M2 ( 0 , 0 ) , 1 ) ; <nl> + Assert : : AreEqual < float > ( M2 ( 0 , 1 ) , 3 ) ; <nl> + Assert : : AreEqual < float > ( M2 ( 0 , 2 ) , 5 ) ; <nl> + Assert : : AreEqual < float > ( M2 ( 1 , 0 ) , 2 ) ; <nl> + Assert : : AreEqual < float > ( M2 ( 1 , 1 ) , 4 ) ; <nl> + Assert : : AreEqual < float > ( M2 ( 1 , 2 ) , 6 ) ; <nl> + <nl> + double * dArray = new double [ 6 ] ; <nl> + dArray [ 0 ] = 1 ; dArray [ 1 ] = 2 ; dArray [ 2 ] = 3 ; <nl> + dArray [ 3 ] = 4 ; dArray [ 4 ] = 5 ; dArray [ 5 ] = 6 ; <nl> + CPUMatrix < double > M3 ( 2 , 3 , dArray , matrixFormatRowMajor ) ; <nl> + Assert : : AreEqual < double > ( M3 ( 0 , 0 ) , 1 ) ; <nl> + Assert : : AreEqual < double > ( M3 ( 0 , 1 ) , 2 ) ; <nl> + Assert : : AreEqual < double > ( M3 ( 0 , 2 ) , 3 ) ; <nl> + Assert : : AreEqual < double > ( M3 ( 1 , 0 ) , 4 ) ; <nl> + Assert : : AreEqual < double > ( M3 ( 1 , 1 ) , 5 ) ; <nl> + Assert : : AreEqual < double > ( M3 ( 1 , 2 ) , 6 ) ; <nl> + <nl> + Matrix M4 ( M0 ) ; <nl> + Assert : : IsTrue ( M4 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + Matrix M5 = M0 ; <nl> + Assert : : IsTrue ( M5 . IsEqualTo ( M0 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixAddAndSub ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 2 ; M0 ( 0 , 2 ) = 3 ; <nl> + M0 ( 1 , 0 ) = 4 ; M0 ( 1 , 1 ) = 5 ; M0 ( 1 , 2 ) = 6 ; <nl> + <nl> + Matrix M1 ( 2 , 3 ) ; <nl> + M1 ( 0 , 0 ) = 11 ; M1 ( 0 , 1 ) = 12 ; M1 ( 0 , 2 ) = 13 ; <nl> + M1 ( 1 , 0 ) = 14 ; M1 ( 1 , 1 ) = 15 ; M1 ( 1 , 2 ) = 16 ; <nl> + <nl> + Matrix M2 ( 2 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 12 ; M2 ( 0 , 1 ) = 14 ; M2 ( 0 , 2 ) = 16 ; <nl> + M2 ( 1 , 0 ) = 18 ; M2 ( 1 , 1 ) = 20 ; M2 ( 1 , 2 ) = 22 ; <nl> + <nl> + Matrix MC ( 2 , 1 ) ; <nl> + MC ( 0 , 0 ) = 10 ; <nl> + MC ( 1 , 0 ) = 10 ; <nl> + <nl> + Matrix MR ( 1 , 3 ) ; <nl> + MR ( 0 , 0 ) = 10 ; MR ( 0 , 1 ) = 10 ; MR ( 0 , 2 ) = 10 ; <nl> + <nl> + Matrix MS ( 1 , 1 ) ; <nl> + MS ( 0 , 0 ) = 10 ; <nl> + <nl> + Matrix M3 = M2 - M0 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 + = M0 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M3 = M0 + 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 - = 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + M3 = M1 + M0 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M3 - = M0 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 = M1 - 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + M3 + = 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 - = MC ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + M3 + = MC ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 - = MR ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + M3 + = MR ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 . AssignDifferenceOf ( M3 , MS ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixMultiAndDiv ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 2 ; M0 ( 0 , 2 ) = 3 ; <nl> + M0 ( 1 , 0 ) = 4 ; M0 ( 1 , 1 ) = 5 ; M0 ( 1 , 2 ) = 6 ; <nl> + <nl> + Matrix M00 ( 2 , 3 ) ; <nl> + M00 ( 0 , 0 ) = 10 ; M00 ( 0 , 1 ) = 20 ; M00 ( 0 , 2 ) = 30 ; <nl> + M00 ( 1 , 0 ) = 40 ; M00 ( 1 , 1 ) = 50 ; M00 ( 1 , 2 ) = 60 ; <nl> + <nl> + Matrix M1 ( 2 , 3 ) ; <nl> + M1 . Reshape ( 3 , 2 ) ; <nl> + M1 ( 0 , 0 ) = 11 ; M1 ( 0 , 1 ) = 15 ; <nl> + M1 ( 1 , 0 ) = 14 ; M1 ( 1 , 1 ) = 13 ; <nl> + M1 ( 2 , 0 ) = 12 ; M1 ( 2 , 1 ) = 16 ; <nl> + <nl> + Matrix M2 ( 2 , 2 ) ; <nl> + M2 ( 0 , 0 ) = 75 ; M2 ( 0 , 1 ) = 89 ; <nl> + M2 ( 1 , 0 ) = 186 ; M2 ( 1 , 1 ) = 221 ; <nl> + <nl> + Matrix M3 = M0 * M1 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M3 = M0 * 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M00 ) ) ; <nl> + <nl> + M3 = M3 / 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + M3 * = 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M00 ) ) ; <nl> + <nl> + M3 / = 10 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 ) ) ; <nl> + <nl> + Matrix : : MultiplyAndWeightedAdd ( 1 , M0 , false , M1 , false , 0 , M3 ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M1 . Reshape ( 2 , 3 ) ; <nl> + Matrix : : MultiplyAndWeightedAdd ( 1 , M0 , false , M1 , true , 0 , M3 ) ; <nl> + M2 ( 0 , 0 ) = 74 ; M2 ( 0 , 1 ) = 92 ; <nl> + M2 ( 1 , 0 ) = 182 ; M2 ( 1 , 1 ) = 227 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + Matrix : : MultiplyAndWeightedAdd ( 10 , M0 , false , M1 , true , 2 , M3 ) ; <nl> + M2 ( 0 , 0 ) = 888 ; M2 ( 0 , 1 ) = 1104 ; <nl> + M2 ( 1 , 0 ) = 2184 ; M2 ( 1 , 1 ) = 2724 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + Matrix : : MultiplyAndWeightedAdd ( 1 , M0 , true , M1 , false , 0 , M3 ) ; <nl> + M2 . Resize ( 3 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 67 ; M2 ( 0 , 1 ) = 72 ; M2 ( 0 , 2 ) = 77 ; <nl> + M2 ( 1 , 0 ) = 92 ; M2 ( 1 , 1 ) = 99 ; M2 ( 1 , 2 ) = 106 ; <nl> + M2 ( 2 , 0 ) = 117 ; M2 ( 2 , 1 ) = 126 ; M2 ( 2 , 2 ) = 135 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixElementOps ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 2 ; M0 ( 0 , 2 ) = 3 ; <nl> + M0 ( 1 , 0 ) = 4 ; M0 ( 1 , 1 ) = 5 ; M0 ( 1 , 2 ) = 6 ; <nl> + <nl> + Matrix M00 ( 2 , 3 ) ; <nl> + M00 ( 0 , 0 ) = 1 . 0 ; M00 ( 0 , 1 ) = 1 / 2 . 0 ; M00 ( 0 , 2 ) = 1 / 3 . 0 ; <nl> + M00 ( 1 , 0 ) = 1 / 4 . 0 ; M00 ( 1 , 1 ) = 1 / 5 . 0 ; M00 ( 1 , 2 ) = 1 / 6 . 0 ; <nl> + <nl> + Matrix M1 ( 2 , 3 ) ; <nl> + M1 ( 0 , 0 ) = 1 ; M1 ( 0 , 1 ) = 1 ; M1 ( 0 , 2 ) = 1 ; <nl> + M1 ( 1 , 0 ) = 1 ; M1 ( 1 , 1 ) = 1 ; M1 ( 1 , 2 ) = 1 ; <nl> + <nl> + Matrix M3 ; <nl> + M3 . AssignElementProductOf ( M0 , M00 ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 , 0 . 0001 ) ) ; <nl> + <nl> + M3 = M0 ^ 4 ; <nl> + Matrix M2 ( 2 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 1 ; M2 ( 0 , 1 ) = 16 ; M2 ( 0 , 2 ) = 81 ; <nl> + M2 ( 1 , 0 ) = 256 ; M2 ( 1 , 1 ) = 625 ; M2 ( 1 , 2 ) = 1296 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 ^ = 4 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . ElementMultiplyWith ( M00 ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M1 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . ElementInverse ( ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M00 ) ) ; <nl> + <nl> + M2 ( 0 , 0 ) = 0 . 7311 ; M2 ( 0 , 1 ) = 0 . 8808 ; M2 ( 0 , 2 ) = 0 . 9526 ; <nl> + M2 ( 1 , 0 ) = 0 . 9820 ; M2 ( 1 , 1 ) = 0 . 9933 ; M2 ( 1 , 2 ) = 0 . 9975 ; <nl> + M3 . AssignElementDivisionOf ( M2 , M0 ) ; <nl> + M2 . ElementMultiplyWith ( M00 ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceSigmoid ( ) ; <nl> + M2 ( 0 , 0 ) = 0 . 7311 ; M2 ( 0 , 1 ) = 0 . 8808 ; M2 ( 0 , 2 ) = 0 . 9526 ; <nl> + M2 ( 1 , 0 ) = 0 . 9820 ; M2 ( 1 , 1 ) = 0 . 9933 ; M2 ( 1 , 2 ) = 0 . 9975 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceTanh ( ) ; <nl> + M2 ( 0 , 0 ) = 0 . 7616 ; M2 ( 0 , 1 ) = 0 . 9640 ; M2 ( 0 , 2 ) = 0 . 9951 ; <nl> + M2 ( 1 , 0 ) = 0 . 9993 ; M2 ( 1 , 1 ) = 0 . 9999 ; M2 ( 1 , 2 ) = 1 . 0000 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceLogSoftmax ( true ) ; <nl> + M3 . InplaceExp ( ) ; <nl> + M2 ( 0 , 0 ) = 0 . 0474 ; M2 ( 0 , 1 ) = 0 . 0474 ; M2 ( 0 , 2 ) = 0 . 0474 ; <nl> + M2 ( 1 , 0 ) = 0 . 9526 ; M2 ( 1 , 1 ) = 0 . 9526 ; M2 ( 1 , 2 ) = 0 . 9526 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceLogSoftmax ( false ) ; <nl> + M3 . InplaceExp ( ) ; <nl> + M2 ( 0 , 0 ) = 0 . 0900 ; M2 ( 0 , 1 ) = 0 . 2447 ; M2 ( 0 , 2 ) = 0 . 6652 ; <nl> + M2 ( 1 , 0 ) = 0 . 0900 ; M2 ( 1 , 1 ) = 0 . 2447 ; M2 ( 1 , 2 ) = 0 . 6652 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceHardmax ( true ) ; <nl> + M2 ( 0 , 0 ) = 0 . 0 ; M2 ( 0 , 1 ) = 0 . 0 ; M2 ( 0 , 2 ) = 0 . 0 ; <nl> + M2 ( 1 , 0 ) = 1 . 0 ; M2 ( 1 , 1 ) = 1 . 0 ; M2 ( 1 , 2 ) = 1 . 0 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceHardmax ( false ) ; <nl> + M2 ( 0 , 0 ) = 0 . 0 ; M2 ( 0 , 1 ) = 0 . 0 ; M2 ( 0 , 2 ) = 1 . 0 ; <nl> + M2 ( 1 , 0 ) = 0 . 0 ; M2 ( 1 , 1 ) = 0 . 0 ; M2 ( 1 , 2 ) = 1 . 0 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceSqrt ( ) ; <nl> + M2 ( 0 , 0 ) = 1 ; M2 ( 0 , 1 ) = 1 . 4142 ; M2 ( 0 , 2 ) = 1 . 7321 ; <nl> + M2 ( 1 , 0 ) = 2 ; M2 ( 1 , 1 ) = 2 . 2361 ; M2 ( 1 , 2 ) = 2 . 4495 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceExp ( ) ; <nl> + M2 ( 0 , 0 ) = 2 . 7183 ; M2 ( 0 , 1 ) = 7 . 3891 ; M2 ( 0 , 2 ) = 20 . 0855 ; <nl> + M2 ( 1 , 0 ) = 54 . 5982 ; M2 ( 1 , 1 ) = 148 . 4132 ; M2 ( 1 , 2 ) = 403 . 4288 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceExp ( ) ; <nl> + M2 ( 0 , 0 ) = 2 . 7183 ; M2 ( 0 , 1 ) = 7 . 3891 ; M2 ( 0 , 2 ) = 20 . 0855 ; <nl> + M2 ( 1 , 0 ) = 54 . 5982 ; M2 ( 1 , 1 ) = 148 . 4132 ; M2 ( 1 , 2 ) = 403 . 4288 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . InplaceLog ( ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceTruncateBottom ( 2 ) ; <nl> + M2 ( 0 , 0 ) = 2 ; M2 ( 0 , 1 ) = 2 ; M2 ( 0 , 2 ) = 3 ; <nl> + M2 ( 1 , 0 ) = 4 ; M2 ( 1 , 1 ) = 5 ; M2 ( 1 , 2 ) = 6 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . InplaceTruncateTop ( 4 ) ; <nl> + M2 ( 0 , 0 ) = 1 ; M2 ( 0 , 1 ) = 2 ; M2 ( 0 , 2 ) = 3 ; <nl> + M2 ( 1 , 0 ) = 4 ; M2 ( 1 , 1 ) = 4 ; M2 ( 1 , 2 ) = 4 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + double pi = 3 . 14159265358979323846264338327950288419716939937510 ; <nl> + <nl> + Matrix M_Trig ( 2 , 3 ) ; <nl> + M_Trig ( 0 , 0 ) = 0 ; M_Trig ( 0 , 1 ) = pi / 2 . 0 ; M_Trig ( 0 , 2 ) = pi ; <nl> + M_Trig ( 1 , 0 ) = 3 . 0 * pi / 2 . 0 ; M_Trig ( 1 , 1 ) = 2 . 0 * pi ; M_Trig ( 1 , 2 ) = 5 . 0 * pi / 2 . 0 ; <nl> + <nl> + Matrix M_Cos ( 2 , 3 ) ; <nl> + M_Cos . SetValue ( M_Trig ) ; <nl> + <nl> + Matrix M_Cos_expected ( 2 , 3 ) ; <nl> + M_Cos_expected ( 0 , 0 ) = 1 ; M_Cos_expected ( 0 , 1 ) = 0 ; M_Cos_expected ( 0 , 2 ) = - 1 ; <nl> + M_Cos_expected ( 1 , 0 ) = 0 ; M_Cos_expected ( 1 , 1 ) = 1 ; M_Cos_expected ( 1 , 2 ) = 0 ; <nl> + <nl> + M_Cos . InplaceCosine ( ) ; <nl> + Assert : : IsTrue ( M_Cos . IsEqualTo ( M_Cos_expected , 0 . 0001 ) ) ; <nl> + <nl> + M_Cos . SetValue ( M_Trig ) ; <nl> + M_Cos . AssignCosineOf ( M_Trig ) ; <nl> + Assert : : IsTrue ( M_Cos . IsEqualTo ( M_Cos_expected , 0 . 0001 ) ) ; <nl> + <nl> + Matrix M_NegSine ( 2 , 3 ) ; <nl> + M_NegSine . SetValue ( M_Trig ) ; <nl> + <nl> + Matrix M_NegSine_expected ( 2 , 3 ) ; <nl> + M_NegSine_expected ( 0 , 0 ) = 0 ; M_NegSine_expected ( 0 , 1 ) = - 1 ; M_NegSine_expected ( 0 , 2 ) = 0 ; <nl> + M_NegSine_expected ( 1 , 0 ) = 1 ; M_NegSine_expected ( 1 , 1 ) = 0 ; M_NegSine_expected ( 1 , 2 ) = - 1 ; <nl> + <nl> + M_NegSine . InplaceNegativeSine ( ) ; <nl> + Assert : : IsTrue ( M_NegSine . IsEqualTo ( M_NegSine_expected , 0 . 0001 ) ) ; <nl> + <nl> + M_NegSine . SetValue ( M_Trig ) ; <nl> + M_NegSine . AssignNegativeSineOf ( M_Trig ) ; <nl> + Assert : : IsTrue ( M_NegSine . IsEqualTo ( M_NegSine_expected , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixNorms ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 2 ; M0 ( 0 , 2 ) = 3 ; <nl> + M0 ( 1 , 0 ) = 4 ; M0 ( 1 , 1 ) = 5 ; M0 ( 1 , 2 ) = 6 ; <nl> + <nl> + Matrix M3 ; <nl> + M0 . VectorNorm1 ( M3 , true ) ; <nl> + Matrix M2 ( 1 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 5 ; M2 ( 0 , 1 ) = 7 ; M2 ( 0 , 2 ) = 9 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M0 . VectorNorm1 ( M3 , false ) ; <nl> + M2 . Resize ( 2 , 1 ) ; <nl> + M2 ( 0 , 0 ) = 6 ; <nl> + M2 ( 1 , 0 ) = 15 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + M0 . VectorNorm2 ( M3 , true ) ; <nl> + M2 . Resize ( 1 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 4 . 1231 ; M2 ( 0 , 1 ) = 5 . 3852 ; M2 ( 0 , 2 ) = 6 . 7082 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M0 . VectorNorm2 ( M3 , false ) ; <nl> + M2 . Resize ( 2 , 1 ) ; <nl> + M2 ( 0 , 0 ) = 3 . 7417 ; <nl> + M2 ( 1 , 0 ) = 8 . 7750 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M0 . VectorNormInf ( M3 , true ) ; <nl> + M2 . Resize ( 1 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 4 ; M2 ( 0 , 1 ) = 5 ; M2 ( 0 , 2 ) = 6 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M0 . VectorNormInf ( M3 , false ) ; <nl> + M2 . Resize ( 2 , 1 ) ; <nl> + M2 ( 0 , 0 ) = 3 ; <nl> + M2 ( 1 , 0 ) = 6 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 ) ) ; <nl> + <nl> + Assert : : IsTrue ( abs ( M0 . FrobeniusNorm ( ) - 9 . 5394 ) < 0 . 0001 ) ; <nl> + Assert : : IsTrue ( abs ( M0 . MatrixNormInf ( ) - 6 ) < 0 . 0001 ) ; <nl> + <nl> + Matrix M1 ; <nl> + M0 . VectorMax ( M1 , M3 , true ) ; <nl> + M2 . Resize ( 1 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 4 ; M2 ( 0 , 1 ) = 5 ; M2 ( 0 , 2 ) = 6 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M0 . VectorMax ( M1 , M3 , false ) ; <nl> + M2 . Resize ( 2 , 1 ) ; <nl> + M2 ( 0 , 0 ) = 3 ; <nl> + M2 ( 1 , 0 ) = 6 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M0 . VectorMin ( M1 , M3 , true ) ; <nl> + M2 . Resize ( 1 , 3 ) ; <nl> + M2 ( 0 , 0 ) = 1 ; M2 ( 0 , 1 ) = 2 ; M2 ( 0 , 2 ) = 3 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + <nl> + M0 . VectorMin ( M1 , M3 , false ) ; <nl> + M2 . Resize ( 2 , 1 ) ; <nl> + M2 ( 0 , 0 ) = 1 ; <nl> + M2 ( 1 , 0 ) = 4 ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M2 , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixSetValues ) <nl> + { <nl> + Matrix M0 ( 3 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 10 ; M0 ( 1 , 1 ) = 10 ; M0 ( 2 , 2 ) = 10 ; <nl> + <nl> + Matrix M1 ( 3 , 3 ) ; <nl> + M1 . SetDiagonalValue ( 10 ) ; <nl> + Assert : : IsTrue ( M1 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + <nl> + Matrix M2 ( 3 , 1 ) ; <nl> + M2 ( 0 , 0 ) = 10 ; M2 ( 1 , 0 ) = 10 ; M2 ( 2 , 0 ) = 10 ; <nl> + M1 . SetDiagonalValue ( M2 ) ; <nl> + Assert : : IsTrue ( M1 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + <nl> + M1 . SetUniformRandomValue ( - 0 . 01 , 0 . 01 ) ; <nl> + for ( int i = 0 ; i < M1 . GetNumRows ( ) ; i + + ) <nl> + for ( int j = 0 ; j < M1 . GetNumCols ( ) ; j + + ) <nl> + Assert : : IsTrue ( M1 ( i , j ) > = - 0 . 01 & & M1 ( i , j ) < 0 . 01 ) ; <nl> + <nl> + M1 . SetGaussianRandomValue ( 0 , 0 . 01 ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixTranspose ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 2 ; M0 ( 0 , 2 ) = 3 ; <nl> + M0 ( 1 , 0 ) = 4 ; M0 ( 1 , 1 ) = 5 ; M0 ( 1 , 2 ) = 6 ; <nl> + <nl> + Matrix M1 ( 3 , 2 ) ; <nl> + M1 ( 0 , 0 ) = 1 ; M1 ( 0 , 1 ) = 4 ; <nl> + M1 ( 1 , 0 ) = 2 ; M1 ( 1 , 1 ) = 5 ; <nl> + M1 ( 2 , 0 ) = 3 ; M1 ( 2 , 1 ) = 6 ; <nl> + <nl> + Matrix M2 = M0 . Transpose ( ) ; <nl> + Assert : : IsTrue ( M2 . IsEqualTo ( M1 , 0 . 0001 ) ) ; <nl> + <nl> + M2 . AssignTransposeOf ( M1 ) ; <nl> + Assert : : IsTrue ( M2 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixColumnSlice ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 2 ; M0 ( 0 , 2 ) = 3 ; <nl> + M0 ( 1 , 0 ) = 4 ; M0 ( 1 , 1 ) = 5 ; M0 ( 1 , 2 ) = 6 ; <nl> + <nl> + Matrix M1 ( 2 , 2 ) ; <nl> + M1 ( 0 , 0 ) = 1 ; M1 ( 0 , 1 ) = 2 ; <nl> + M1 ( 1 , 0 ) = 4 ; M1 ( 1 , 1 ) = 5 ; <nl> + <nl> + Matrix M2 = M0 . ColumnSlice ( 0 , 2 ) ; <nl> + Assert : : IsTrue ( M2 . IsEqualTo ( M1 , 0 . 0001 ) ) ; <nl> + <nl> + M1 ( 0 , 0 ) = 2 ; M1 ( 0 , 1 ) = 3 ; <nl> + M1 ( 1 , 0 ) = 5 ; M1 ( 1 , 1 ) = 6 ; <nl> + <nl> + M2 = M0 . ColumnSlice ( 1 , 2 ) ; <nl> + Assert : : IsTrue ( M2 . IsEqualTo ( M1 , 0 . 0001 ) ) ; <nl> + <nl> + size_t k = 100 , n = 20 , m = 50 ; <nl> + <nl> + Matrix AG ( ( size_t ) k , ( size_t ) n ) ; <nl> + AG . SetUniformRandomValue ( - 1 , 1 ) ; <nl> + <nl> + Matrix BG ( ( size_t ) n , ( size_t ) m ) ; <nl> + BG . SetUniformRandomValue ( - 1 , 1 ) ; <nl> + <nl> + Matrix CG ( ( size_t ) k , ( size_t ) m ) ; <nl> + CG . SetUniformRandomValue ( - 1 , 1 ) ; <nl> + Matrix DG ( ( size_t ) k , ( size_t ) m ) ; <nl> + DG . SetValue ( CG ) ; <nl> + <nl> + Matrix : : MultiplyAndAdd ( AG , false , BG , false , DG ) ; <nl> + <nl> + for ( int i = 0 ; i < m ; i + + ) <nl> + { <nl> + Matrix col_BG = BG . ColumnSlice ( i , 1 ) ; <nl> + Matrix col_CG = CG . ColumnSlice ( i , 1 ) ; <nl> + Matrix : : MultiplyAndAdd ( AG , false , col_BG , false , col_CG ) ; <nl> + } <nl> + Assert : : IsTrue ( CG . IsEqualTo ( DG , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUKhatriRaoProduct ) <nl> + { <nl> + Matrix A ( 3 , 4 ) ; <nl> + A ( 0 , 0 ) = 0 . 8147 ; A ( 0 , 1 ) = 0 . 9134 ; A ( 0 , 2 ) = 0 . 2785 ; A ( 0 , 3 ) = 0 . 9649 ; <nl> + A ( 1 , 0 ) = 0 . 9058 ; A ( 1 , 1 ) = 0 . 6324 ; A ( 1 , 2 ) = 0 . 5469 ; A ( 1 , 3 ) = 0 . 1576 ; <nl> + A ( 2 , 0 ) = 0 . 1270 ; A ( 2 , 1 ) = 0 . 0975 ; A ( 2 , 2 ) = 0 . 9575 ; A ( 2 , 3 ) = 0 . 9706 ; <nl> + <nl> + Matrix B ( 2 , 4 ) ; <nl> + B ( 0 , 0 ) = 0 . 9572 ; B ( 0 , 1 ) = 0 . 8003 ; B ( 0 , 2 ) = 0 . 4218 ; B ( 0 , 3 ) = 0 . 7922 ; <nl> + B ( 1 , 0 ) = 0 . 4854 ; B ( 1 , 1 ) = 0 . 1419 ; B ( 1 , 2 ) = 0 . 9157 ; B ( 1 , 3 ) = 0 . 9595 ; <nl> + <nl> + Matrix D ( 6 , 4 ) ; <nl> + D ( 0 , 0 ) = 0 . 7798 ; D ( 0 , 1 ) = 0 . 7310 ; D ( 0 , 2 ) = 0 . 1175 ; D ( 0 , 3 ) = 0 . 7644 ; <nl> + D ( 1 , 0 ) = 0 . 8670 ; D ( 1 , 1 ) = 0 . 5061 ; D ( 1 , 2 ) = 0 . 2307 ; D ( 1 , 3 ) = 0 . 1249 ; <nl> + D ( 2 , 0 ) = 0 . 1215 ; D ( 2 , 1 ) = 0 . 0781 ; D ( 2 , 2 ) = 0 . 4038 ; D ( 2 , 3 ) = 0 . 7689 ; <nl> + D ( 3 , 0 ) = 0 . 3954 ; D ( 3 , 1 ) = 0 . 1296 ; D ( 3 , 2 ) = 0 . 2550 ; D ( 3 , 3 ) = 0 . 9258 ; <nl> + D ( 4 , 0 ) = 0 . 4396 ; D ( 4 , 1 ) = 0 . 0897 ; D ( 4 , 2 ) = 0 . 5008 ; D ( 4 , 3 ) = 0 . 1512 ; <nl> + D ( 5 , 0 ) = 0 . 0616 ; D ( 5 , 1 ) = 0 . 0138 ; D ( 5 , 2 ) = 0 . 8768 ; D ( 5 , 3 ) = 0 . 9313 ; <nl> + <nl> + Matrix C ; <nl> + C . AssignKhatriRaoProductOf ( A , B ) ; <nl> + Assert : : IsTrue ( C . IsEqualTo ( D , 0 . 0001 ) ) ; <nl> + <nl> + } <nl> + <nl> + TEST_METHOD ( CPUAddColumnReshapeProductOf ) <nl> + { <nl> + Matrix A ( 6 , 2 ) ; <nl> + A ( 0 , 0 ) = 0 . 6557 ; A ( 0 , 1 ) = 0 . 7431 ; <nl> + A ( 1 , 0 ) = 0 . 0357 ; A ( 1 , 1 ) = 0 . 3922 ; <nl> + A ( 2 , 0 ) = 0 . 8491 ; A ( 2 , 1 ) = 0 . 6555 ; <nl> + A ( 3 , 0 ) = 0 . 9340 ; A ( 3 , 1 ) = 0 . 1712 ; <nl> + A ( 4 , 0 ) = 0 . 6787 ; A ( 4 , 1 ) = 0 . 7060 ; <nl> + A ( 5 , 0 ) = 0 . 7577 ; A ( 5 , 1 ) = 0 . 0318 ; <nl> + <nl> + Matrix B ( 3 , 2 ) ; <nl> + B ( 0 , 0 ) = 0 . 2769 ; B ( 0 , 1 ) = 0 . 8235 ; <nl> + B ( 1 , 0 ) = 0 . 0462 ; B ( 1 , 1 ) = 0 . 6948 ; <nl> + B ( 2 , 0 ) = 0 . 0971 ; B ( 2 , 1 ) = 0 . 3171 ; <nl> + <nl> + Matrix D0 ( 2 , 2 ) ; <nl> + D0 ( 0 , 0 ) = 0 . 2867 ; D0 ( 0 , 1 ) = 1 . 2913 ; <nl> + D0 ( 1 , 0 ) = 0 . 1266 ; D0 ( 1 , 1 ) = 0 . 4520 ; <nl> + <nl> + Matrix D1 ( 2 , 2 ) ; <nl> + D1 ( 0 , 0 ) = 0 . 2657 ; D1 ( 0 , 1 ) = 1 . 0923 ; <nl> + D1 ( 1 , 0 ) = 0 . 3636 ; D1 ( 1 , 1 ) = 0 . 6416 ; <nl> + <nl> + Matrix C ( 2 , 2 ) ; <nl> + C . SetValue ( 0 ) ; <nl> + C . AddColumnReshapeProductOf ( A , B , false ) ; <nl> + Assert : : IsTrue ( C . IsEqualTo ( D0 , 0 . 0001 ) ) ; <nl> + <nl> + C . SetValue ( 0 ) ; <nl> + C . AddColumnReshapeProductOf ( A , B , true ) ; <nl> + Assert : : IsTrue ( C . IsEqualTo ( D1 , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUMatrixRowSliceAndStack ) <nl> + { <nl> + Matrix M0 ( 5 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 6 ; M0 ( 0 , 2 ) = 11 ; <nl> + M0 ( 1 , 0 ) = 2 ; M0 ( 1 , 1 ) = 7 ; M0 ( 1 , 2 ) = 12 ; <nl> + M0 ( 2 , 0 ) = 3 ; M0 ( 2 , 1 ) = 8 ; M0 ( 2 , 2 ) = 13 ; <nl> + M0 ( 3 , 0 ) = 4 ; M0 ( 3 , 1 ) = 9 ; M0 ( 3 , 2 ) = 14 ; <nl> + M0 ( 4 , 0 ) = 5 ; M0 ( 4 , 1 ) = 10 ; M0 ( 4 , 2 ) = 15 ; <nl> + <nl> + Matrix M1 ( 2 , 3 ) ; <nl> + M1 ( 0 , 0 ) = 3 ; M1 ( 0 , 1 ) = 8 ; M1 ( 0 , 2 ) = 13 ; <nl> + M1 ( 1 , 0 ) = 4 ; M1 ( 1 , 1 ) = 9 ; M1 ( 1 , 2 ) = 14 ; <nl> + <nl> + Matrix M2 ; <nl> + M2 . AssignRowSliceValuesOf ( M0 , 2 , 2 ) ; <nl> + Assert : : IsTrue ( M2 . IsEqualTo ( M1 , 0 . 0001 ) ) ; <nl> + <nl> + Matrix M3 ( 5 , 3 ) ; <nl> + M3 ( 0 , 0 ) = 0 ; M3 ( 0 , 1 ) = 0 ; M3 ( 0 , 2 ) = 0 ; <nl> + M3 ( 1 , 0 ) = 0 ; M3 ( 1 , 1 ) = 0 ; M3 ( 1 , 2 ) = 0 ; <nl> + M3 ( 2 , 0 ) = 3 ; M3 ( 2 , 1 ) = 8 ; M3 ( 2 , 2 ) = 13 ; <nl> + M3 ( 3 , 0 ) = 4 ; M3 ( 3 , 1 ) = 9 ; M3 ( 3 , 2 ) = 14 ; <nl> + M3 ( 4 , 0 ) = 0 ; M3 ( 4 , 1 ) = 0 ; M3 ( 4 , 2 ) = 0 ; <nl> + <nl> + M3 + = M0 ; <nl> + M0 . AddToRowSliceValuesOf ( M1 , 2 , 2 ) ; <nl> + Assert : : IsTrue ( M3 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + <nl> + M2 . AddWithRowSliceValuesOf ( M1 , 0 , 2 ) ; <nl> + Matrix M4 ( 2 , 3 ) ; <nl> + M4 ( 0 , 0 ) = 6 ; M4 ( 0 , 1 ) = 16 ; M4 ( 0 , 2 ) = 26 ; <nl> + M4 ( 1 , 0 ) = 8 ; M4 ( 1 , 1 ) = 18 ; M4 ( 1 , 2 ) = 28 ; <nl> + Assert : : IsTrue ( M2 . IsEqualTo ( M4 , 0 . 0001 ) ) ; <nl> + <nl> + # if 0 <nl> + Matrix M5 , M6 , M7 , M8 ; <nl> + M5 . AssignRowSliceValuesOf ( M0 , 0 , 2 ) ; <nl> + M6 . AssignRowSliceValuesOf ( M0 , 2 , 1 ) ; <nl> + M7 . AssignRowSliceValuesOf ( M0 , 3 , 2 ) ; <nl> + <nl> + std : : vector < const Matrix * > inputMatrices ; <nl> + inputMatrices . resize ( 3 ) ; <nl> + inputMatrices [ 0 ] = & M5 ; <nl> + inputMatrices [ 1 ] = & M6 ; <nl> + inputMatrices [ 2 ] = & M7 ; <nl> + M8 . AssignRowStackValuesOf ( inputMatrices , 0 , 3 ) ; <nl> + <nl> + Assert : : IsTrue ( M8 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + # endif <nl> + } <nl> + <nl> + TEST_METHOD ( CPUAssignRepeatOf ) <nl> + { <nl> + Matrix M0 ( 2 , 3 ) ; <nl> + M0 ( 0 , 0 ) = 1 ; M0 ( 0 , 1 ) = 6 ; M0 ( 0 , 2 ) = 11 ; <nl> + M0 ( 1 , 0 ) = 2 ; M0 ( 1 , 1 ) = 7 ; M0 ( 1 , 2 ) = 12 ; <nl> + <nl> + Matrix M1 ; <nl> + M1 . AssignRepeatOf ( M0 , 1 , 1 ) ; <nl> + Assert : : IsTrue ( M1 . IsEqualTo ( M0 , 0 . 0001 ) ) ; <nl> + <nl> + Matrix M3 ( 6 , 6 ) ; <nl> + M3 ( 0 , 0 ) = 1 ; M3 ( 0 , 1 ) = 6 ; M3 ( 0 , 2 ) = 11 ; M3 ( 0 , 3 ) = 1 ; M3 ( 0 , 4 ) = 6 ; M3 ( 0 , 5 ) = 11 ; <nl> + M3 ( 1 , 0 ) = 2 ; M3 ( 1 , 1 ) = 7 ; M3 ( 1 , 2 ) = 12 ; M3 ( 1 , 3 ) = 2 ; M3 ( 1 , 4 ) = 7 ; M3 ( 1 , 5 ) = 12 ; <nl> + M3 ( 2 , 0 ) = 1 ; M3 ( 2 , 1 ) = 6 ; M3 ( 2 , 2 ) = 11 ; M3 ( 2 , 3 ) = 1 ; M3 ( 2 , 4 ) = 6 ; M3 ( 2 , 5 ) = 11 ; <nl> + M3 ( 3 , 0 ) = 2 ; M3 ( 3 , 1 ) = 7 ; M3 ( 3 , 2 ) = 12 ; M3 ( 3 , 3 ) = 2 ; M3 ( 3 , 4 ) = 7 ; M3 ( 3 , 5 ) = 12 ; <nl> + M3 ( 4 , 0 ) = 1 ; M3 ( 4 , 1 ) = 6 ; M3 ( 4 , 2 ) = 11 ; M3 ( 4 , 3 ) = 1 ; M3 ( 4 , 4 ) = 6 ; M3 ( 4 , 5 ) = 11 ; <nl> + M3 ( 5 , 0 ) = 2 ; M3 ( 5 , 1 ) = 7 ; M3 ( 5 , 2 ) = 12 ; M3 ( 5 , 3 ) = 2 ; M3 ( 5 , 4 ) = 7 ; M3 ( 5 , 5 ) = 12 ; <nl> + <nl> + M1 . AssignRepeatOf ( M0 , 3 , 2 ) ; <nl> + Assert : : IsTrue ( M1 . IsEqualTo ( M3 , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPURowElementOperations ) <nl> + { <nl> + Matrix M0 = Matrix : : RandomUniform ( 20 , 28 , - 1 , 1 ) ; <nl> + Matrix M1 = Matrix : : RandomUniform ( 1 , 28 , 1 , 2 ) ; <nl> + <nl> + Matrix M3 ; <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . RowElementMultiplyWith ( M1 ) ; <nl> + M3 . RowElementDivideBy ( M1 ) ; <nl> + <nl> + Assert : : IsTrue ( M0 . IsEqualTo ( M3 , 0 . 0001 ) ) ; <nl> + } <nl> + TEST_METHOD ( CPUColumnElementOperations ) <nl> + { <nl> + Matrix M0 = Matrix : : RandomUniform ( 20 , 28 , - 1 , 1 ) ; <nl> + Matrix M1 = Matrix : : RandomUniform ( 20 , 1 , 1 , 2 ) ; <nl> + <nl> + Matrix M3 ; <nl> + M3 . SetValue ( M0 ) ; <nl> + M3 . ColumnElementMultiplyWith ( M1 ) ; <nl> + M3 . ColumnElementDivideBy ( M1 ) ; <nl> + <nl> + Assert : : IsTrue ( M0 . IsEqualTo ( M3 , 0 . 0001 ) ) ; <nl> + } <nl> + <nl> + TEST_METHOD ( CPUAssignMatrixByColumnSlice ) <nl> + { <nl> + printf ( " starts here \ n " ) ; <nl> + Matrix M0 = Matrix : : RandomUniform ( 400 , 50 , - 100 , 100 ) ; <nl> + <nl> + <nl> + vector < size_t > columnrange = { 0 , 3 , 5 , 4 } ; <nl> + Matrix M1 ; <nl> + try <nl> + { <nl> + M1 . AssignMatrixByColumnSlice ( M0 , columnrange ) ; <nl> + } <nl> + catch ( exception & e ) <nl> + { <nl> + printf ( " % s \ n " , e . what ( ) ) ; <nl> + Assert : : Fail ( ) ; <nl> + } <nl> + <nl> + <nl> + for ( size_t des = 0 ; des < columnrange . size ( ) ; des + + ) <nl> + { <nl> + size_t src = columnrange [ des ] ; <nl> + <nl> + double err = 0 ; <nl> + for ( size_t r = 0 ; r < 400 ; r + + ) <nl> + { <nl> + double diff = ( M0 ( r , src ) - M1 ( r , des ) ) ; <nl> + diff * = diff ; <nl> + err + = diff ; <nl> + } <nl> + Assert : : AreEqual ( err , 0 , 1e - 7 ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> + } ; <nl> + } <nl> \ No newline at end of file <nl> mmm a / Math / Math / CPUMatrix . cpp <nl> ppp b / Math / Math / CPUMatrix . cpp <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> return slice ; <nl> } <nl> <nl> + / / BUGBUG : Unlike ColumnSlice ( ) , this does not return a view . Must be renamed . <nl> + template < class ElemType > <nl> + CPUMatrix < ElemType > CPUMatrix < ElemType > : : RowSlice ( size_t startRow , size_t numRows ) const <nl> + { <nl> + if ( startRow + numRows > m_numRows ) <nl> + InvalidArgument ( " The row slice ( % d + % d ) is out of range of the source matrix ( % d ) . " , ( int ) startRow , ( int ) numRows , ( int ) m_numRows ) ; <nl> + <nl> + CPUMatrix < ElemType > slice ; <nl> + slice . AssignRowSliceValuesOf ( * this , startRow , numRows ) ; <nl> + <nl> + return slice ; <nl> + } <nl> + <nl> / / set this ( : , 0 : numCols - 1 ) = fromMatrix ( : , startColumn : startColumn + numCols - 1 ) <nl> / / TODO : why not say * this = ColumnSlice ( ) ? <nl> template < class ElemType > <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> } <nl> } <nl> } <nl> - <nl> + <nl> / / for each column of a , we add all rows of a to this starting from startIndex <nl> template < class ElemType > <nl> CPUMatrix < ElemType > & CPUMatrix < ElemType > : : AssignToRowSliceValuesOf ( const CPUMatrix < ElemType > & a , const size_t startIndex , const size_t numRows ) <nl> mmm a / Math / Math / CPUMatrix . h <nl> ppp b / Math / Math / CPUMatrix . h <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> CPUMatrix < ElemType > ColumnSlice ( size_t startColumn , size_t numCols ) const ; <nl> CPUMatrix < ElemType > & AssignColumnSlice ( const CPUMatrix < ElemType > & fromMatrix , size_t startColumn , size_t numCols ) ; <nl> CPUMatrix < ElemType > & SetColumnSlice ( const CPUMatrix < ElemType > & fromMatrix , size_t startColumn , size_t numCols ) ; <nl> + / / BUGBUG : Unlike ColumnSlice ( ) , this does not return a view . Must be renamed . <nl> + CPUMatrix < ElemType > RowSlice ( size_t startRow , size_t numRows ) const ; <nl> <nl> void CopyColumnsStrided ( const CPUMatrix < ElemType > & fromMatrix , size_t numCols , size_t srcNumColsStride , size_t destNumColsStride ) ; <nl> <nl> mmm a / Math / Math / GPUMatrix . cu <nl> ppp b / Math / Math / GPUMatrix . cu <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> return slice ; <nl> } <nl> <nl> + template < class ElemType > <nl> + GPUMatrix < ElemType > GPUMatrix < ElemType > : : RowSlice ( size_t startRow , size_t numRows ) const <nl> + { <nl> + if ( startRow + numRows > m_numRows ) <nl> + InvalidArgument ( " The row slice ( % d + % d ) is out of range of the source matrix ( % d ) . " , ( int ) startRow , ( int ) numRows , ( int ) m_numRows ) ; <nl> + <nl> + GPUMatrix < ElemType > slice ( GetComputeDeviceId ( ) ) ; <nl> + slice . AssignRowSliceValuesOf ( * this , startRow , numRows ) ; <nl> + return slice ; <nl> + } <nl> + <nl> template < class ElemType > <nl> GPUMatrix < ElemType > & GPUMatrix < ElemType > : : AssignColumnSlice ( const GPUMatrix < ElemType > & fromMatrix , size_t startColumn , size_t numCols ) <nl> { <nl> mmm a / Math / Math / GPUMatrix . h <nl> ppp b / Math / Math / GPUMatrix . h <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> GPUMatrix < ElemType > ColumnSlice ( size_t startColumn , size_t numCols ) const ; <nl> GPUMatrix < ElemType > & AssignColumnSlice ( const GPUMatrix < ElemType > & fromMatrix , size_t startColumn , size_t numCols ) ; <nl> GPUMatrix < ElemType > & SetColumnSlice ( const GPUMatrix < ElemType > & fromMatrix , size_t startColumn , size_t numCols ) ; <nl> + / / BUGBUG : Unlike ColumnSlice ( ) , this does not return a view . Must be renamed . <nl> + GPUMatrix < ElemType > RowSlice ( size_t startRow , size_t numRows ) const ; <nl> <nl> void CopyColumnsStrided ( const GPUMatrix < ElemType > & fromMatrix , size_t numCols , size_t srcNumColsStride , size_t destNumColsStride ) ; <nl> <nl> mmm a / Math / Math / Matrix . cpp <nl> ppp b / Math / Math / Matrix . cpp <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> return slice ; <nl> } <nl> <nl> + / / BUGBUG : Unlike ColumnSlice ( ) , this does not return a view . Must be renamed . <nl> + template < class ElemType > <nl> + Matrix < ElemType > Matrix < ElemType > : : RowSlice ( size_t startRow , size_t numRow ) const <nl> + { <nl> + int devId = GetDeviceId ( ) ; <nl> + Matrix < ElemType > slice ( devId ) ; <nl> + slice . m_preferredDeviceId = m_preferredDeviceId ; <nl> + if ( GetMatrixType ( ) = = MatrixType : : DENSE ) <nl> + { <nl> + if ( devId = = CPUDEVICE ) <nl> + { <nl> + if ( slice . m_CPUMatrix ! = nullptr ) <nl> + slice . m_CPUMatrix - > operator = ( static_cast < CPUMatrix < ElemType > & & > ( m_CPUMatrix - > RowSlice ( startRow , numRow ) ) ) ; <nl> + else <nl> + slice . m_CPUMatrix = new CPUMatrix < ElemType > ( static_cast < CPUMatrix < ElemType > & & > ( m_CPUMatrix - > RowSlice ( startRow , numRow ) ) ) ; <nl> + slice . SetDataLocation ( CPU , DENSE ) ; <nl> + } <nl> + else <nl> + { <nl> + if ( slice . m_GPUMatrix ! = nullptr ) <nl> + slice . m_GPUMatrix - > operator = ( static_cast < GPUMatrix < ElemType > & & > ( m_GPUMatrix - > RowSlice ( startRow , numRow ) ) ) ; <nl> + else <nl> + slice . m_GPUMatrix = new GPUMatrix < ElemType > ( static_cast < GPUMatrix < ElemType > & & > ( m_GPUMatrix - > RowSlice ( startRow , numRow ) ) ) ; <nl> + slice . SetDataLocation ( GPU , DENSE ) ; <nl> + } <nl> + <nl> + } <nl> + else if ( GetMatrixType ( ) = = MatrixType : : SPARSE ) <nl> + { <nl> + NOT_IMPLEMENTED ; <nl> + } <nl> + else <nl> + { <nl> + RuntimeError ( " Unknown matrix type " ) ; <nl> + } <nl> + return slice ; <nl> + } <nl> + <nl> + <nl> + <nl> template < class ElemType > <nl> Matrix < ElemType > & Matrix < ElemType > : : AssignColumnSlice ( const Matrix < ElemType > & fromMatrix , size_t startColumn , size_t numCols ) <nl> { <nl> mmm a / Math / Math / Matrix . h <nl> ppp b / Math / Math / Matrix . h <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> void CopySection ( size_t numRows , size_t numCols , ElemType * dst , size_t colStride ) const ; <nl> <nl> Matrix < ElemType > ColumnSlice ( size_t startColumn , size_t numCols ) const ; <nl> - <nl> + / / BUGBUG : Unlike ColumnSlice ( ) , this does not return a view . Must be renamed . <nl> + Matrix < ElemType > RowSlice ( size_t startRow , size_t numRows ) const ; <nl> <nl> / / difference between AssignColumnSlice and SetColumnSlice <nl> / / AssignColumnSlice : this ( : , startColumn : startColumn + numCols - 1 ) = fromMatrix ( : , startColumn : startColumn + numCols - 1 ) <nl> mmm a / Math / Math / NoGPU . cpp <nl> ppp b / Math / Math / NoGPU . cpp <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> template < class ElemType > GPUMatrix < ElemType > GPUMatrix < ElemType > : : ColumnSlice ( size_t startColumn , size_t numCols ) const <nl> { <nl> GPUMatrix < ElemType > slice ( 0 ) ; <nl> + return slice ; <nl> + } <nl> <nl> + template < class ElemType > GPUMatrix < ElemType > GPUMatrix < ElemType > : : RowSlice ( size_t startRow , size_t numRows ) const <nl> + { <nl> + GPUMatrix < ElemType > slice ( 0 ) ; <nl> return slice ; <nl> } <nl> <nl>
merged with master . One thing not compiling
microsoft/CNTK
59ae7b2c77dd28dcae9ec43715ad87e176a88bcd
2015-12-01T03:44:47Z
mmm a / test / Constraints / bridging . swift <nl> ppp b / test / Constraints / bridging . swift <nl> let d2 : Double = 3 . 14159 <nl> inferDouble2 = d2 <nl> <nl> / / rdar : / / problem / 18269449 <nl> - var i1 : Int = 1 . 5 * 3 . 5 / / expected - error { { cannot convert value of type ' Double ' to expected argument type ' Int ' } } <nl> + var i1 : Int = 1 . 5 * 3 . 5 / / expected - error { { cannot convert value of type ' Double ' to specified type ' Int ' } } <nl> <nl> / / rdar : / / problem / 18330319 <nl> func rdar18330319 ( _ s : String , d : [ String : AnyObject ] ) { <nl> func rdar19770981 ( _ s : String , ns : NSString ) { <nl> <nl> / / < rdar : / / problem / 19831919 > Fixit offers as ! conversions that are known to always fail <nl> func rdar19831919 ( ) { <nl> - var s1 = 1 + " str " ; / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' String ' } } expected - note { { overloads for ' + ' exist with these partially matching parameter lists : ( String , String ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> + var s1 = 1 + " str " ; / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' String ' } } expected - note { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , Int ) , ( String , String ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> } <nl> <nl> / / < rdar : / / problem / 19831698 > Incorrect ' as ' fixits offered for invalid literal expressions <nl> func rdar19831698 ( ) { <nl> - var v70 = true + 1 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Bool ' and ' Int ' } } expected - note { { overloads for ' + ' exist with these partially matching parameter lists : ( UnsafeMutablePointer < Pointee > , Int ) , ( UnsafePointer < Pointee > , Int ) } } <nl> + var v70 = true + 1 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Bool ' and ' Int ' } } expected - note { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , Int ) , ( UnsafeMutablePointer < Pointee > , Int ) , ( UnsafePointer < Pointee > , Int ) } } <nl> var v71 = true + 1 . 0 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Bool ' and ' Double ' } } <nl> / / expected - note @ - 1 { { overloads for ' + ' } } <nl> var v72 = true + true / / expected - error { { binary operator ' + ' cannot be applied to two ' Bool ' operands } } <nl> mmm a / test / Constraints / closures . swift <nl> ppp b / test / Constraints / closures . swift <nl> func f20371273 ( ) { <nl> let x : [ Int ] = [ 1 , 2 , 3 , 4 ] <nl> let y : UInt = 4 <nl> _ = x . filter { ( $ 0 + y ) > 42 } / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' UInt ' } } <nl> - / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> + / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( UInt , UInt ) , ( Int , Int ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> } <nl> <nl> <nl> mmm a / test / Constraints / diagnostics . swift <nl> ppp b / test / Constraints / diagnostics . swift <nl> if AssocTest . one ( 1 ) = = AssocTest . one ( 1 ) { } / / expected - error { { binary operator ' = <nl> func r24251022 ( ) { <nl> var a = 1 <nl> var b : UInt32 = 2 <nl> - a + = a + <nl> - b / / expected - error { { cannot convert value of type ' UInt32 ' to expected argument type ' Int ' } } <nl> + a + = a + / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' UInt32 ' } } expected - note { { overloads for ' + ' exist } } <nl> + b <nl> } <nl> <nl> func overloadSetResultType ( _ a : Int , b : Int ) - > Int { <nl> func nilComparison ( i : Int , o : AnyObject ) { <nl> _ = i ! = nil / / expected - warning { { comparing non - optional value of type ' Int ' to nil always returns true } } <nl> _ = nil ! = i / / expected - warning { { comparing non - optional value of type ' Int ' to nil always returns true } } <nl> <nl> - _ = i < nil / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = nil < i / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = i < = nil / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = nil < = i / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = i > nil / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = nil > i / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = i > = nil / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> - _ = nil > = i / / expected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / FIXME ( integers ) : uncomment these tests once the < is no longer ambiguous <nl> + / / _ = i < nil / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = nil < i / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = i < = nil / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = nil < = i / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = i > nil / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = nil > i / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = i > = nil / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> + / / _ = nil > = i / / _xpected - error { { type ' Int ' is not optional , value can never be nil } } <nl> <nl> _ = o = = = nil / / expected - warning { { comparing non - optional value of type ' AnyObject ' to nil always returns false } } <nl> _ = o ! = = nil / / expected - warning { { comparing non - optional value of type ' AnyObject ' to nil always returns true } } <nl> func rdar27391581 ( _ a : Int , b : Int ) - > Int { <nl> <nl> / / < rdar : / / problem / 22276040 > QoI : not great error message with " withUnsafePointer " sametype constraints <nl> func read2 ( _ p : UnsafeMutableRawPointer , maxLength : Int ) { } <nl> - func read < T : Integer > ( ) - > T ? { <nl> + func read < T : BinaryInteger > ( ) - > T ? { <nl> var buffer : T <nl> let n = withUnsafePointer ( to : & buffer ) { ( p ) in <nl> read2 ( UnsafePointer ( p ) , maxLength : MemoryLayout < T > . size ) / / expected - error { { cannot convert value of type ' UnsafePointer < _ > ' to expected argument type ' UnsafeMutableRawPointer ' } } <nl> let r29850459_a : Int = 0 <nl> let r29850459_b : Int = 1 <nl> func r29850459 ( ) - > Bool { return false } <nl> let _ = ( r29850459_flag ? r29850459_a : r29850459_b ) + 42 . 0 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' Double ' } } <nl> - / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , Int ) , ( Double , Double ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> + / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Double , Double ) , ( Int , Int ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> let _ = ( { true } ( ) ? r29850459_a : r29850459_b ) + 42 . 0 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' Double ' } } <nl> - / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , Int ) , ( Double , Double ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> + / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Double , Double ) , ( Int , Int ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> let _ = ( r29850459 ( ) ? r29850459_a : r29850459_b ) + 42 . 0 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' Double ' } } <nl> - / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , Int ) , ( Double , Double ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> + / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Double , Double ) , ( Int , Int ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> let _ = ( ( r29850459_flag | | r29850459 ( ) ) ? r29850459_a : r29850459_b ) + 42 . 0 / / expected - error { { binary operator ' + ' cannot be applied to operands of type ' Int ' and ' Double ' } } <nl> - / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Int , Int ) , ( Double , Double ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> \ No newline at end of file <nl> + / / expected - note @ - 1 { { overloads for ' + ' exist with these partially matching parameter lists : ( Double , Double ) , ( Int , Int ) , ( Int , UnsafeMutablePointer < Pointee > ) , ( Int , UnsafePointer < Pointee > ) } } <nl> mmm a / test / Constraints / generics . swift <nl> ppp b / test / Constraints / generics . swift <nl> class Whatever < A : Arithmetic , B : Arithmetic > { / / expected - note 2 { { ' A ' declare <nl> static func bar ( ) { } <nl> <nl> } <nl> - Whatever . foo ( a : 23 ) / / expected - error { { generic parameter ' A ' could not be inferred } } expected - note { { explicitly specify the generic arguments to fix this issue } } { { 9 - 9 = < < # A : IntegerArithmetic # > , < # B : IntegerArithmetic # > > } } <nl> + Whatever . foo ( a : 23 ) / / expected - error { { generic parameter ' A ' could not be inferred } } expected - note { { explicitly specify the generic arguments to fix this issue } } { { 9 - 9 = < < # A : Arithmetic # > , < # B : Arithmetic # > > } } <nl> <nl> / / < rdar : / / problem / 21718955 > Swift useless error : cannot invoke ' foo ' with no arguments <nl> - Whatever . bar ( ) / / expected - error { { generic parameter ' A ' could not be inferred } } expected - note { { explicitly specify the generic arguments to fix this issue } } { { 9 - 9 = < < # A : IntegerArithmetic # > , < # B : IntegerArithmetic # > > } } <nl> + Whatever . bar ( ) / / expected - error { { generic parameter ' A ' could not be inferred } } expected - note { { explicitly specify the generic arguments to fix this issue } } { { 9 - 9 = < < # A : Arithmetic # > , < # B : Arithmetic # > > } } <nl> <nl> / / < rdar : / / problem / 27515965 > Type checker doesn ' t enforce same - type constraint if associated type is Any <nl> protocol P27515965 { <nl> mmm a / test / Constraints / lvalues . swift <nl> ppp b / test / Constraints / lvalues . swift <nl> var x : X <nl> var y : Y <nl> <nl> func + = ( lhs : inout X , rhs : X ) { } <nl> - func + = ( lhs : inout Double , rhs : Double ) { } <nl> prefix operator ppp <nl> prefix func ppp ( rhs : inout X ) { } <nl> <nl> mmm a / test / Interpreter / currying_generics . swift <nl> ppp b / test / Interpreter / currying_generics . swift <nl> public func test_compose_closure ( _ x : Int ) - > Int32 { <nl> let insult = curry ( + ) ( " I ' m with stupid ☞ " ) <nl> print ( insult ( " 😡 " ) ) / / CHECK : I ' m with stupid ☞ 😡 <nl> <nl> - let plus1 = curry ( + ) ( 1 ) <nl> + let plus1 = curry ( { $ 0 + $ 1 } ) ( 1 ) <nl> print ( plus1 ( 5 ) ) / / CHECK - NEXT : 6 <nl> <nl> - let plus5 = curry ( + ) ( 5 ) <nl> + let plus5 = curry ( { $ 0 + $ 1 } ) ( 5 ) <nl> print ( plus5 ( 5 ) ) / / CHECK - NEXT : 10 <nl> <nl> print ( insult ( " 😰 " ) ) / / CHECK - NEXT : I ' m with stupid ☞ 😰 <nl> mmm a / test / Interpreter / protocol_extensions . swift <nl> ppp b / test / Interpreter / protocol_extensions . swift <nl> extension Sequence { <nl> } <nl> <nl> / / CHECK : 15 <nl> - print ( [ 1 , 2 , 3 , 4 , 5 ] . myReduce ( 0 , combine : + ) ) <nl> + print ( [ 1 , 2 , 3 , 4 , 5 ] . myReduce ( 0 , combine : { $ 0 + $ 1 } ) ) <nl> <nl> <nl> extension Sequence { <nl> extension MutableCollection <nl> } <nl> <nl> extension RangeReplaceableCollection { <nl> - public final func myJoin < S : Sequence where S . Iterator . Element = = Self > ( <nl> + public final func myJoin < S : Sequence > ( <nl> _ elements : S <nl> - ) - > Self { <nl> + ) - > Self where S . Iterator . Element = = Self { <nl> var result = Self ( ) <nl> var iter = elements . makeIterator ( ) <nl> if let first = iter . next ( ) { <nl>
Fixing tests with artihmetic operators back on concrete types
apple/swift
3522f3c47ccb721ca588aedcd6d59f4101ece4b8
2017-01-23T22:56:29Z
mmm a / lib / Sema / CSSimplify . cpp <nl> ppp b / lib / Sema / CSSimplify . cpp <nl> ConstraintSystem : : simplifyConstraint ( const Constraint & constraint ) { <nl> case ConstraintKind : : OptionalObject : <nl> return simplifyOptionalObjectConstraint ( constraint . getFirstType ( ) , <nl> constraint . getSecondType ( ) , <nl> - TMF_GenerateConstraints , <nl> + / * flags * / None , <nl> constraint . getLocator ( ) ) ; <nl> <nl> case ConstraintKind : : ValueMember : <nl> ConstraintSystem : : simplifyConstraint ( const Constraint & constraint ) { <nl> constraint . getMemberUseDC ( ) , <nl> constraint . getFunctionRefKind ( ) , <nl> / * outerAlternatives = * / { } , <nl> - TMF_GenerateConstraints , <nl> - constraint . getLocator ( ) ) ; <nl> + / * flags * / None , constraint . getLocator ( ) ) ; <nl> <nl> case ConstraintKind : : ValueWitness : <nl> return simplifyValueWitnessConstraint ( constraint . getKind ( ) , <nl> ConstraintSystem : : simplifyConstraint ( const Constraint & constraint ) { <nl> constraint . getSecondType ( ) , <nl> constraint . getMemberUseDC ( ) , <nl> constraint . getFunctionRefKind ( ) , <nl> - TMF_GenerateConstraints , <nl> + / * flags * / None , <nl> constraint . getLocator ( ) ) ; <nl> <nl> case ConstraintKind : : Defaultable : <nl> return simplifyDefaultableConstraint ( constraint . getFirstType ( ) , <nl> constraint . getSecondType ( ) , <nl> - TMF_GenerateConstraints , <nl> + / * flags * / None , <nl> constraint . getLocator ( ) ) ; <nl> <nl> case ConstraintKind : : DefaultClosureType : <nl> return simplifyDefaultClosureTypeConstraint ( constraint . getFirstType ( ) , <nl> constraint . getSecondType ( ) , <nl> constraint . getTypeVariables ( ) , <nl> - TMF_GenerateConstraints , <nl> + / * flags * / None , <nl> constraint . getLocator ( ) ) ; <nl> <nl> case ConstraintKind : : FunctionInput : <nl> ConstraintSystem : : simplifyConstraint ( const Constraint & constraint ) { <nl> return simplifyFunctionComponentConstraint ( constraint . getKind ( ) , <nl> constraint . getFirstType ( ) , <nl> constraint . getSecondType ( ) , <nl> - TMF_GenerateConstraints , <nl> + / * flags * / None , <nl> constraint . getLocator ( ) ) ; <nl> <nl> case ConstraintKind : : Disjunction : <nl> ConstraintSystem : : simplifyConstraint ( const Constraint & constraint ) { <nl> return simplifyOneWayConstraint ( constraint . getKind ( ) , <nl> constraint . getFirstType ( ) , <nl> constraint . getSecondType ( ) , <nl> - TMF_GenerateConstraints , <nl> - constraint . getLocator ( ) ) ; <nl> + / * flags * / None , constraint . getLocator ( ) ) ; <nl> } <nl> <nl> llvm_unreachable ( " Unhandled ConstraintKind in switch . " ) ; <nl>
[ CS ] Don ' t use TMF_GenerateConstraints in simplifyConstraint
apple/swift
dd9e1cf618228226ad52ce76bc6c92bb0db4b1af
2020-08-25T17:16:43Z
mmm a / test / SILOptimizer / constantprop - wrongscope . swift <nl> ppp b / test / SILOptimizer / constantprop - wrongscope . swift <nl> <nl> / / RUN : % S / . . / ClangImporter / Inputs / custom - modules - emit - sil - o / dev / null \ <nl> / / RUN : - primary - file % s - Xllvm - sil - print - debuginfo - module - name patatino \ <nl> / / RUN : - Onone - Xllvm - sil - print - after = diagnostic - constant - propagation \ <nl> - / / RUN : - Xllvm - sil - print - only - functions = $ S8patatino19indexedSubscripting1b3idx1aySo1BC_SiSo1ACtF \ <nl> / / RUN : 2 > & 1 | % FileCheck % s <nl> <nl> / / REQUIRES : objc_interop <nl> <nl> / / Make sure that the destroy_addr instruction has the same scope of the <nl> / / instructions surrounding it . <nl> <nl> - / / CHECK : % 60 = unchecked_take_enum_data_addr % 12 : $ * Optional < Any > , # Optional . some ! enumelt . 1 , loc { { . * } } : 24 : 13 , scope 2 <nl> - / / CHECK : destroy_addr % 7 : $ * Any , loc { { . * } } : 24 : 19 , scope 2 <nl> - / / CHECK : dealloc_stack % 12 : $ * Optional < Any > , loc { { . * } } : 24 : 23 , scope 2 <nl> - / / CHECK : dealloc_stack % 7 : $ * Any , loc { { . * } } : 24 : 23 , scope 2 <nl> - / / CHECK : dealloc_stack % 6 : $ * A , loc { { . * } } : 24 : 7 , scope 2 <nl> + / / CHECK : destroy_addr % 7 : $ * Any , loc { { . * } } : 22 : 19 , scope 2 <nl> + / / CHECK : dealloc_stack % 12 : $ * Optional < Any > , loc { { . * } } : 22 : 23 , scope 2 <nl> + / / CHECK : dealloc_stack % 7 : $ * Any , loc { { . * } } : 22 : 23 , scope 2 <nl> + / / CHECK : dealloc_stack % 6 : $ * A , loc { { . * } } : 22 : 7 , scope 2 <nl> <nl> import Foundation <nl> func indexedSubscripting ( b b : B , idx : Int , a : A ) { <nl>
Merge remote - tracking branch ' origin / master ' into master - llvm - swift5 - transition
apple/swift
477a4ec58fdf99b6cf66d882368a662f4761a7d9
2018-01-12T22:38:57Z
mmm a / src / test / data / script_invalid . json <nl> ppp b / src / test / data / script_invalid . json <nl> <nl> [ <nl> - [ " " , " DEPTH " , " Test the test : we should have an empty stack after scriptSig evaluation " ] , <nl> - [ " " , " DEPTH " , " and multiple spaces should not change that . " ] , <nl> - [ " " , " DEPTH " ] , <nl> - [ " " , " DEPTH " ] , <nl> - <nl> - [ " " , " " ] , <nl> - [ " " , " NOP " ] , <nl> - [ " " , " NOP DEPTH " ] , <nl> - [ " NOP " , " " ] , <nl> - [ " NOP " , " DEPTH " ] , <nl> - [ " NOP " , " NOP " ] , <nl> - [ " NOP " , " NOP DEPTH " ] , <nl> - <nl> - [ " DEPTH " , " " ] , <nl> - <nl> - [ " 0x4c01 " , " 0x01 NOP " , " PUSHDATA1 with not enough bytes " ] , <nl> - [ " 0x4d0200ff " , " 0x01 NOP " , " PUSHDATA2 with not enough bytes " ] , <nl> - [ " 0x4e03000000ffff " , " 0x01 NOP " , " PUSHDATA4 with not enough bytes " ] , <nl> - <nl> - [ " 1 " , " IF 0x50 ENDIF 1 " , " 0x50 is reserved " ] , <nl> - [ " 0x52 " , " 0x5f ADD 0x60 EQUAL " , " 0x51 through 0x60 push 1 through 16 onto stack " ] , <nl> - [ " 0 " , " NOP " ] , <nl> - [ " 1 " , " IF VER ELSE 1 ENDIF " , " VER non - functional " ] , <nl> - [ " 0 " , " IF VERIF ELSE 1 ENDIF " , " VERIF illegal everywhere " ] , <nl> - [ " 0 " , " IF ELSE 1 ELSE VERIF ENDIF " , " VERIF illegal everywhere " ] , <nl> - [ " 0 " , " IF VERNOTIF ELSE 1 ENDIF " , " VERNOTIF illegal everywhere " ] , <nl> - [ " 0 " , " IF ELSE 1 ELSE VERNOTIF ENDIF " , " VERNOTIF illegal everywhere " ] , <nl> - <nl> - [ " 1 IF " , " 1 ENDIF " , " IF / ENDIF can ' t span scriptSig / scriptPubKey " ] , <nl> - [ " 1 IF 0 ENDIF " , " 1 ENDIF " ] , <nl> - [ " 1 ELSE 0 ENDIF " , " 1 " ] , <nl> - [ " 0 NOTIF " , " 123 " ] , <nl> - <nl> - [ " 0 " , " DUP IF ENDIF " ] , <nl> - [ " 0 " , " IF 1 ENDIF " ] , <nl> - [ " 0 " , " DUP IF ELSE ENDIF " ] , <nl> - [ " 0 " , " IF 1 ELSE ENDIF " ] , <nl> - [ " 0 " , " NOTIF ELSE 1 ENDIF " ] , <nl> - <nl> - [ " 0 1 " , " IF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 0 0 " , " IF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 1 0 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - [ " 0 1 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - <nl> - [ " 0 0 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 0 1 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 1 1 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - [ " 0 0 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - <nl> - [ " 1 " , " IF RETURN ELSE ELSE 1 ENDIF " , " Multiple ELSEs " ] , <nl> - [ " 1 " , " IF 1 ELSE ELSE RETURN ENDIF " ] , <nl> - <nl> - [ " 1 " , " ENDIF " , " Malformed IF / ELSE / ENDIF sequence " ] , <nl> - [ " 1 " , " ELSE ENDIF " ] , <nl> - [ " 1 " , " ENDIF ELSE " ] , <nl> - [ " 1 " , " ENDIF ELSE IF " ] , <nl> - [ " 1 " , " IF ELSE ENDIF ELSE " ] , <nl> - [ " 1 " , " IF ELSE ENDIF ELSE ENDIF " ] , <nl> - [ " 1 " , " IF ENDIF ENDIF " ] , <nl> - [ " 1 " , " IF ELSE ELSE ENDIF ENDIF " ] , <nl> - <nl> - [ " 1 " , " RETURN " ] , <nl> - [ " 1 " , " DUP IF RETURN ENDIF " ] , <nl> - <nl> - [ " 1 " , " RETURN ' data ' " , " canonical prunable txout format " ] , <nl> - [ " 0 IF " , " RETURN ENDIF 1 " , " still prunable because IF / ENDIF can ' t span scriptSig / scriptPubKey " ] , <nl> - <nl> - [ " 0 " , " VERIFY 1 " ] , <nl> - [ " 1 " , " VERIFY " ] , <nl> - [ " 1 " , " VERIFY 0 " ] , <nl> - <nl> - [ " 1 TOALTSTACK " , " FROMALTSTACK 1 " , " alt stack not shared between sig / pubkey " ] , <nl> - <nl> - [ " IFDUP " , " DEPTH 0 EQUAL " ] , <nl> - [ " DROP " , " DEPTH 0 EQUAL " ] , <nl> - [ " DUP " , " DEPTH 0 EQUAL " ] , <nl> - [ " 1 " , " DUP 1 ADD 2 EQUALVERIFY 0 EQUAL " ] , <nl> - [ " NOP " , " NIP " ] , <nl> - [ " NOP " , " 1 NIP " ] , <nl> - [ " NOP " , " 1 0 NIP " ] , <nl> - [ " NOP " , " OVER 1 " ] , <nl> - [ " 1 " , " OVER " ] , <nl> - [ " 0 1 " , " OVER DEPTH 3 EQUALVERIFY " ] , <nl> - [ " 19 20 21 " , " PICK 19 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " NOP " , " 0 PICK " ] , <nl> - [ " 1 " , " - 1 PICK " ] , <nl> - [ " 19 20 21 " , " 0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL " ] , <nl> - [ " 19 20 21 " , " 1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL " ] , <nl> - [ " 19 20 21 " , " 2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL " ] , <nl> - [ " NOP " , " 0 ROLL " ] , <nl> - [ " 1 " , " - 1 ROLL " ] , <nl> - [ " 19 20 21 " , " 0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " 19 20 21 " , " 1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " 19 20 21 " , " 2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " NOP " , " ROT 1 " ] , <nl> - [ " NOP " , " 1 ROT 1 " ] , <nl> - [ " NOP " , " 1 2 ROT 1 " ] , <nl> - [ " NOP " , " 0 1 2 ROT " ] , <nl> - [ " NOP " , " SWAP 1 " ] , <nl> - [ " 1 " , " SWAP 1 " ] , <nl> - [ " 0 1 " , " SWAP 1 EQUALVERIFY " ] , <nl> - [ " NOP " , " TUCK 1 " ] , <nl> - [ " 1 " , " TUCK 1 " ] , <nl> - [ " 1 0 " , " TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP " ] , <nl> - [ " NOP " , " 2DUP 1 " ] , <nl> - [ " 1 " , " 2DUP 1 " ] , <nl> - [ " NOP " , " 3DUP 1 " ] , <nl> - [ " 1 " , " 3DUP 1 " ] , <nl> - [ " 1 2 " , " 3DUP 1 " ] , <nl> - [ " NOP " , " 2OVER 1 " ] , <nl> - [ " 1 " , " 2 3 2OVER 1 " ] , <nl> - [ " NOP " , " 2SWAP 1 " ] , <nl> - [ " 1 " , " 2 3 2SWAP 1 " ] , <nl> - <nl> - [ " ' a ' ' b ' " , " CAT " , " CAT disabled " ] , <nl> - [ " ' a ' ' b ' 0 " , " IF CAT ELSE 1 ENDIF " , " CAT disabled " ] , <nl> - [ " ' abc ' 1 1 " , " SUBSTR " , " SUBSTR disabled " ] , <nl> - [ " ' abc ' 1 1 0 " , " IF SUBSTR ELSE 1 ENDIF " , " SUBSTR disabled " ] , <nl> - [ " ' abc ' 2 0 " , " IF LEFT ELSE 1 ENDIF " , " LEFT disabled " ] , <nl> - [ " ' abc ' 2 0 " , " IF RIGHT ELSE 1 ENDIF " , " RIGHT disabled " ] , <nl> - <nl> - [ " NOP " , " SIZE 1 " ] , <nl> - <nl> - [ " ' abc ' " , " IF INVERT ELSE 1 ENDIF " , " INVERT disabled " ] , <nl> - [ " 1 2 0 IF AND ELSE 1 ENDIF " , " NOP " , " AND disabled " ] , <nl> - [ " 1 2 0 IF OR ELSE 1 ENDIF " , " NOP " , " OR disabled " ] , <nl> - [ " 1 2 0 IF XOR ELSE 1 ENDIF " , " NOP " , " XOR disabled " ] , <nl> - [ " 2 0 IF 2MUL ELSE 1 ENDIF " , " NOP " , " 2MUL disabled " ] , <nl> - [ " 2 0 IF 2DIV ELSE 1 ENDIF " , " NOP " , " 2DIV disabled " ] , <nl> - [ " 2 2 0 IF MUL ELSE 1 ENDIF " , " NOP " , " MUL disabled " ] , <nl> - [ " 2 2 0 IF DIV ELSE 1 ENDIF " , " NOP " , " DIV disabled " ] , <nl> - [ " 2 2 0 IF MOD ELSE 1 ENDIF " , " NOP " , " MOD disabled " ] , <nl> - [ " 2 2 0 IF LSHIFT ELSE 1 ENDIF " , " NOP " , " LSHIFT disabled " ] , <nl> - [ " 2 2 0 IF RSHIFT ELSE 1 ENDIF " , " NOP " , " RSHIFT disabled " ] , <nl> - <nl> - [ " 0 1 " , " EQUAL " ] , <nl> - [ " 1 1 ADD " , " 0 EQUAL " ] , <nl> - [ " 11 1 ADD 12 SUB " , " 11 EQUAL " ] , <nl> - <nl> - [ " 2147483648 0 ADD " , " NOP " , " arithmetic operands must be in range [ - 2 ^ 31 . . . 2 ^ 31 ] " ] , <nl> - [ " - 2147483648 0 ADD " , " NOP " , " arithmetic operands must be in range [ - 2 ^ 31 . . . 2 ^ 31 ] " ] , <nl> - [ " 2147483647 DUP ADD " , " 4294967294 NUMEQUAL " , " NUMEQUAL must be in numeric range " ] , <nl> - [ " ' abcdef ' NOT " , " 0 EQUAL " , " NOT is an arithmetic operand " ] , <nl> - <nl> - [ " 2 DUP MUL " , " 4 EQUAL " , " disabled " ] , <nl> - [ " 2 DUP DIV " , " 1 EQUAL " , " disabled " ] , <nl> - [ " 2 2MUL " , " 4 EQUAL " , " disabled " ] , <nl> - [ " 2 2DIV " , " 1 EQUAL " , " disabled " ] , <nl> - [ " 7 3 MOD " , " 1 EQUAL " , " disabled " ] , <nl> - [ " 2 2 LSHIFT " , " 8 EQUAL " , " disabled " ] , <nl> - [ " 2 1 RSHIFT " , " 1 EQUAL " , " disabled " ] , <nl> - <nl> - [ " 1 " , " NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL " ] , <nl> - [ " ' NOP_1_to_10 ' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 " , " ' NOP_1_to_11 ' EQUAL " ] , <nl> - <nl> - [ " 0x50 " , " 1 " , " opcode 0x50 is reserved " ] , <nl> - [ " 1 " , " IF 0xba ELSE 1 ENDIF " , " opcodes above NOP10 invalid if executed " ] , <nl> - [ " 1 " , " IF 0xbb ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xbc ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xbd ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xbe ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xbf ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc0 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc1 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc2 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc3 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc4 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc5 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc6 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc7 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc8 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xc9 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xca ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xcb ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xcc ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xcd ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xce ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xcf ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd0 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd1 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd2 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd3 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd4 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd5 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd6 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd7 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd8 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xd9 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xda ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xdb ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xdc ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xdd ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xde ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xdf ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe0 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe1 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe2 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe3 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe4 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe5 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe6 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe7 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe8 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xe9 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xea ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xeb ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xec ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xed ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xee ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xef ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf0 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf1 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf2 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf3 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf4 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf5 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf6 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf7 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf8 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xf9 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xfa ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xfb ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xfc ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xfd ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xfe ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 0xff ELSE 1 ENDIF " ] , <nl> - <nl> - [ " 1 IF 1 ELSE " , " 0xff ENDIF " , " invalid because scriptSig and scriptPubKey are processed separately " ] , <nl> - <nl> - [ " NOP " , " RIPEMD160 " ] , <nl> - [ " NOP " , " SHA1 " ] , <nl> - [ " NOP " , " SHA256 " ] , <nl> - [ " NOP " , " HASH160 " ] , <nl> - [ " NOP " , " HASH256 " ] , <nl> + [ " " , " DEPTH " , " P2SH , STRICTENC " , " Test the test : we should have an empty stack after scriptSig evaluation " ] , <nl> + [ " " , " DEPTH " , " P2SH , STRICTENC " , " and multiple spaces should not change that . " ] , <nl> + [ " " , " DEPTH " , " P2SH , STRICTENC " ] , <nl> + [ " " , " DEPTH " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " " , " " , " P2SH , STRICTENC " ] , <nl> + [ " " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " " , " NOP DEPTH " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " DEPTH " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP DEPTH " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " DEPTH " , " " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0x4c01 " , " 0x01 NOP " , " P2SH , STRICTENC " , " PUSHDATA1 with not enough bytes " ] , <nl> + [ " 0x4d0200ff " , " 0x01 NOP " , " P2SH , STRICTENC " , " PUSHDATA2 with not enough bytes " ] , <nl> + [ " 0x4e03000000ffff " , " 0x01 NOP " , " P2SH , STRICTENC " , " PUSHDATA4 with not enough bytes " ] , <nl> + <nl> + [ " 1 " , " IF 0x50 ENDIF 1 " , " P2SH , STRICTENC " , " 0x50 is reserved " ] , <nl> + [ " 0x52 " , " 0x5f ADD 0x60 EQUAL " , " P2SH , STRICTENC " , " 0x51 through 0x60 push 1 through 16 onto stack " ] , <nl> + [ " 0 " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF VER ELSE 1 ENDIF " , " P2SH , STRICTENC " , " VER non - functional " ] , <nl> + [ " 0 " , " IF VERIF ELSE 1 ENDIF " , " P2SH , STRICTENC " , " VERIF illegal everywhere " ] , <nl> + [ " 0 " , " IF ELSE 1 ELSE VERIF ENDIF " , " P2SH , STRICTENC " , " VERIF illegal everywhere " ] , <nl> + [ " 0 " , " IF VERNOTIF ELSE 1 ENDIF " , " P2SH , STRICTENC " , " VERNOTIF illegal everywhere " ] , <nl> + [ " 0 " , " IF ELSE 1 ELSE VERNOTIF ENDIF " , " P2SH , STRICTENC " , " VERNOTIF illegal everywhere " ] , <nl> + <nl> + [ " 1 IF " , " 1 ENDIF " , " P2SH , STRICTENC " , " IF / ENDIF can ' t span scriptSig / scriptPubKey " ] , <nl> + [ " 1 IF 0 ENDIF " , " 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 ELSE 0 ENDIF " , " 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 NOTIF " , " 123 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " DUP IF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " DUP IF ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 1 ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " NOTIF ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 1 " , " IF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " IF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 0 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " IF RETURN ELSE ELSE 1 ENDIF " , " P2SH , STRICTENC " , " Multiple ELSEs " ] , <nl> + [ " 1 " , " IF 1 ELSE ELSE RETURN ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " ENDIF " , " P2SH , STRICTENC " , " Malformed IF / ELSE / ENDIF sequence " ] , <nl> + [ " 1 " , " ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " ENDIF ELSE " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " ENDIF ELSE IF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF ELSE ENDIF ELSE " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF ELSE ENDIF ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF ELSE ELSE ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " RETURN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " DUP IF RETURN ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " RETURN ' data ' " , " P2SH , STRICTENC " , " canonical prunable txout format " ] , <nl> + [ " 0 IF " , " RETURN ENDIF 1 " , " P2SH , STRICTENC " , " still prunable because IF / ENDIF can ' t span scriptSig / scriptPubKey " ] , <nl> + <nl> + [ " 0 " , " VERIFY 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " VERIFY " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " VERIFY 0 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 TOALTSTACK " , " FROMALTSTACK 1 " , " P2SH , STRICTENC " , " alt stack not shared between sig / pubkey " ] , <nl> + <nl> + [ " IFDUP " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " DROP " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " DUP " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " DUP 1 ADD 2 EQUALVERIFY 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NIP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 1 NIP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 1 0 NIP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " OVER 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " OVER " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " OVER DEPTH 3 EQUALVERIFY " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " PICK 19 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 0 PICK " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " - 1 PICK " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " 0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " 1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " 2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 0 ROLL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " - 1 ROLL " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " 0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " 1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 19 20 21 " , " 2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " ROT 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 1 ROT 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 1 2 ROT 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 0 1 2 ROT " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " SWAP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " SWAP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " SWAP 1 EQUALVERIFY " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " TUCK 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " TUCK 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 2DUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " 2DUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 3DUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " 3DUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 2 " , " 3DUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 2OVER 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " 2 3 2OVER 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 2SWAP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " 2 3 2SWAP 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " ' a ' ' b ' " , " CAT " , " P2SH , STRICTENC " , " CAT disabled " ] , <nl> + [ " ' a ' ' b ' 0 " , " IF CAT ELSE 1 ENDIF " , " P2SH , STRICTENC " , " CAT disabled " ] , <nl> + [ " ' abc ' 1 1 " , " SUBSTR " , " P2SH , STRICTENC " , " SUBSTR disabled " ] , <nl> + [ " ' abc ' 1 1 0 " , " IF SUBSTR ELSE 1 ENDIF " , " P2SH , STRICTENC " , " SUBSTR disabled " ] , <nl> + [ " ' abc ' 2 0 " , " IF LEFT ELSE 1 ENDIF " , " P2SH , STRICTENC " , " LEFT disabled " ] , <nl> + [ " ' abc ' 2 0 " , " IF RIGHT ELSE 1 ENDIF " , " P2SH , STRICTENC " , " RIGHT disabled " ] , <nl> + <nl> + [ " NOP " , " SIZE 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " ' abc ' " , " IF INVERT ELSE 1 ENDIF " , " P2SH , STRICTENC " , " INVERT disabled " ] , <nl> + [ " 1 2 0 IF AND ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " AND disabled " ] , <nl> + [ " 1 2 0 IF OR ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " OR disabled " ] , <nl> + [ " 1 2 0 IF XOR ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " XOR disabled " ] , <nl> + [ " 2 0 IF 2MUL ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " 2MUL disabled " ] , <nl> + [ " 2 0 IF 2DIV ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " 2DIV disabled " ] , <nl> + [ " 2 2 0 IF MUL ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " MUL disabled " ] , <nl> + [ " 2 2 0 IF DIV ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " DIV disabled " ] , <nl> + [ " 2 2 0 IF MOD ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " MOD disabled " ] , <nl> + [ " 2 2 0 IF LSHIFT ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " LSHIFT disabled " ] , <nl> + [ " 2 2 0 IF RSHIFT ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " RSHIFT disabled " ] , <nl> + <nl> + [ " 0 1 " , " EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 ADD " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 11 1 ADD 12 SUB " , " 11 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 2147483648 0 ADD " , " NOP " , " P2SH , STRICTENC " , " arithmetic operands must be in range [ - 2 ^ 31 . . . 2 ^ 31 ] " ] , <nl> + [ " - 2147483648 0 ADD " , " NOP " , " P2SH , STRICTENC " , " arithmetic operands must be in range [ - 2 ^ 31 . . . 2 ^ 31 ] " ] , <nl> + [ " 2147483647 DUP ADD " , " 4294967294 NUMEQUAL " , " P2SH , STRICTENC " , " NUMEQUAL must be in numeric range " ] , <nl> + [ " ' abcdef ' NOT " , " 0 EQUAL " , " P2SH , STRICTENC " , " NOT is an arithmetic operand " ] , <nl> + <nl> + [ " 2 DUP MUL " , " 4 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + [ " 2 DUP DIV " , " 1 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + [ " 2 2MUL " , " 4 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + [ " 2 2DIV " , " 1 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + [ " 7 3 MOD " , " 1 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + [ " 2 2 LSHIFT " , " 8 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + [ " 2 1 RSHIFT " , " 1 EQUAL " , " P2SH , STRICTENC " , " disabled " ] , <nl> + <nl> + [ " 1 " , " NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' NOP_1_to_10 ' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 " , " ' NOP_1_to_11 ' EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0x50 " , " 1 " , " P2SH , STRICTENC " , " opcode 0x50 is reserved " ] , <nl> + [ " 1 " , " IF 0xba ELSE 1 ENDIF " , " P2SH , STRICTENC " , " opcodes above NOP10 invalid if executed " ] , <nl> + [ " 1 " , " IF 0xbb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xbc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xbd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xbe ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xbf ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xc9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xca ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xcb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xcc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xcd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xce ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xcf ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xd9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xda ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xdb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xdc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xdd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xde ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xdf ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xe9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xea ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xeb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xec ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xed ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xee ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xef ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xf9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xfa ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xfb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xfc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xfd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xfe ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 0xff ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 IF 1 ELSE " , " 0xff ENDIF " , " P2SH , STRICTENC " , " invalid because scriptSig and scriptPubKey are processed separately " ] , <nl> + <nl> + [ " NOP " , " RIPEMD160 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " SHA1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " SHA256 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " HASH160 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " HASH256 " , " P2SH , STRICTENC " ] , <nl> <nl> [ " NOP " , <nl> " ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' " , <nl> + " P2SH , STRICTENC " , <nl> " > 520 byte push " ] , <nl> [ " 0 " , <nl> " IF ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ENDIF 1 " , <nl> + " P2SH , STRICTENC " , <nl> " > 520 byte push in non - executed IF branch " ] , <nl> [ " 1 " , <nl> " 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 " , <nl> + " P2SH , STRICTENC " , <nl> " > 201 opcodes executed . 0x61 is NOP " ] , <nl> [ " 0 " , <nl> " IF 0x6161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 ENDIF 1 " , <nl> + " P2SH , STRICTENC " , <nl> " > 201 opcodes including non - executed IF branch . 0x61 is NOP " ] , <nl> [ " 1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> " 1 2 3 4 5 6 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> + " P2SH , STRICTENC " , <nl> " > 1 , 000 stack size ( 0x6f is 3DUP ) " ] , <nl> [ " 1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> " 1 TOALTSTACK 2 TOALTSTACK 3 4 5 6 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> + " P2SH , STRICTENC " , <nl> " > 1 , 000 stack + altstack size " ] , <nl> [ " NOP " , <nl> " 0 ' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f 2DUP 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 " , <nl> + " P2SH , STRICTENC " , <nl> " 10 , 001 - byte scriptPubKey " ] , <nl> <nl> - [ " NOP1 " , " NOP10 " ] , <nl> - <nl> - [ " 1 " , " VER " , " OP_VER is reserved " ] , <nl> - [ " 1 " , " VERIF " , " OP_VERIF is reserved " ] , <nl> - [ " 1 " , " VERNOTIF " , " OP_VERNOTIF is reserved " ] , <nl> - [ " 1 " , " RESERVED " , " OP_RESERVED is reserved " ] , <nl> - [ " 1 " , " RESERVED1 " , " OP_RESERVED1 is reserved " ] , <nl> - [ " 1 " , " RESERVED2 " , " OP_RESERVED2 is reserved " ] , <nl> - [ " 1 " , " 0xba " , " 0xba = = OP_NOP10 + 1 " ] , <nl> - <nl> - [ " 2147483648 " , " 1ADD 1 " , " We cannot do math on 5 - byte integers " ] , <nl> - [ " 2147483648 " , " NEGATE 1 " , " We cannot do math on 5 - byte integers " ] , <nl> - [ " - 2147483648 " , " 1ADD 1 " , " Because we use a sign bit , - 2147483648 is also 5 bytes " ] , <nl> - [ " 2147483647 " , " 1ADD 1SUB 1 " , " We cannot do math on 5 - byte integers , even if the result is 4 - bytes " ] , <nl> - [ " 2147483648 " , " 1SUB 1 " , " We cannot do math on 5 - byte integers , even if the result is 4 - bytes " ] , <nl> - <nl> - [ " 2147483648 1 " , " BOOLOR 1 " , " We cannot do BOOLOR on 5 - byte integers ( but we can still do IF etc ) " ] , <nl> - [ " 2147483648 1 " , " BOOLAND 1 " , " We cannot do BOOLAND on 5 - byte integers " ] , <nl> - <nl> - [ " 1 " , " 1 ENDIF " , " ENDIF without IF " ] , <nl> - [ " 1 " , " IF 1 " , " IF without ENDIF " ] , <nl> - [ " 1 IF 1 " , " ENDIF " , " IFs don ' t carry over " ] , <nl> - <nl> - [ " NOP " , " IF 1 ENDIF " , " The following tests check the if ( stack . size ( ) < N ) tests in each opcode " ] , <nl> - [ " NOP " , " NOTIF 1 ENDIF " , " They are here to catch copy - and - paste errors " ] , <nl> - [ " NOP " , " VERIFY 1 " , " Most of them are duplicated elsewhere , " ] , <nl> - <nl> - [ " NOP " , " TOALTSTACK 1 " , " but , hey , more is always better , right ? " ] , <nl> - [ " 1 " , " FROMALTSTACK " ] , <nl> - [ " 1 " , " 2DROP 1 " ] , <nl> - [ " 1 " , " 2DUP " ] , <nl> - [ " 1 1 " , " 3DUP " ] , <nl> - [ " 1 1 1 " , " 2OVER " ] , <nl> - [ " 1 1 1 1 1 " , " 2ROT " ] , <nl> - [ " 1 1 1 " , " 2SWAP " ] , <nl> - [ " NOP " , " IFDUP 1 " ] , <nl> - [ " NOP " , " DROP 1 " ] , <nl> - [ " NOP " , " DUP 1 " ] , <nl> - [ " 1 " , " NIP " ] , <nl> - [ " 1 " , " OVER " ] , <nl> - [ " 1 1 1 3 " , " PICK " ] , <nl> - [ " 0 " , " PICK 1 " ] , <nl> - [ " 1 1 1 3 " , " ROLL " ] , <nl> - [ " 0 " , " ROLL 1 " ] , <nl> - [ " 1 1 " , " ROT " ] , <nl> - [ " 1 " , " SWAP " ] , <nl> - [ " 1 " , " TUCK " ] , <nl> - <nl> - [ " NOP " , " SIZE 1 " ] , <nl> - <nl> - [ " 1 " , " EQUAL 1 " ] , <nl> - [ " 1 " , " EQUALVERIFY 1 " ] , <nl> - <nl> - [ " NOP " , " 1ADD 1 " ] , <nl> - [ " NOP " , " 1SUB 1 " ] , <nl> - [ " NOP " , " NEGATE 1 " ] , <nl> - [ " NOP " , " ABS 1 " ] , <nl> - [ " NOP " , " NOT 1 " ] , <nl> - [ " NOP " , " 0NOTEQUAL 1 " ] , <nl> - <nl> - [ " 1 " , " ADD " ] , <nl> - [ " 1 " , " SUB " ] , <nl> - [ " 1 " , " BOOLAND " ] , <nl> - [ " 1 " , " BOOLOR " ] , <nl> - [ " 1 " , " NUMEQUAL " ] , <nl> - [ " 1 " , " NUMEQUALVERIFY 1 " ] , <nl> - [ " 1 " , " NUMNOTEQUAL " ] , <nl> - [ " 1 " , " LESSTHAN " ] , <nl> - [ " 1 " , " GREATERTHAN " ] , <nl> - [ " 1 " , " LESSTHANOREQUAL " ] , <nl> - [ " 1 " , " GREATERTHANOREQUAL " ] , <nl> - [ " 1 " , " MIN " ] , <nl> - [ " 1 " , " MAX " ] , <nl> - [ " 1 1 " , " WITHIN " ] , <nl> - <nl> - [ " NOP " , " RIPEMD160 1 " ] , <nl> - [ " NOP " , " SHA1 1 " ] , <nl> - [ " NOP " , " SHA256 1 " ] , <nl> - [ " NOP " , " HASH160 1 " ] , <nl> - [ " NOP " , " HASH256 1 " ] , <nl> + [ " NOP1 " , " NOP10 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " VER " , " P2SH , STRICTENC " , " OP_VER is reserved " ] , <nl> + [ " 1 " , " VERIF " , " P2SH , STRICTENC " , " OP_VERIF is reserved " ] , <nl> + [ " 1 " , " VERNOTIF " , " P2SH , STRICTENC " , " OP_VERNOTIF is reserved " ] , <nl> + [ " 1 " , " RESERVED " , " P2SH , STRICTENC " , " OP_RESERVED is reserved " ] , <nl> + [ " 1 " , " RESERVED1 " , " P2SH , STRICTENC " , " OP_RESERVED1 is reserved " ] , <nl> + [ " 1 " , " RESERVED2 " , " P2SH , STRICTENC " , " OP_RESERVED2 is reserved " ] , <nl> + [ " 1 " , " 0xba " , " P2SH , STRICTENC " , " 0xba = = OP_NOP10 + 1 " ] , <nl> + <nl> + [ " 2147483648 " , " 1ADD 1 " , " P2SH , STRICTENC " , " We cannot do math on 5 - byte integers " ] , <nl> + [ " 2147483648 " , " NEGATE 1 " , " P2SH , STRICTENC " , " We cannot do math on 5 - byte integers " ] , <nl> + [ " - 2147483648 " , " 1ADD 1 " , " P2SH , STRICTENC " , " Because we use a sign bit , - 2147483648 is also 5 bytes " ] , <nl> + [ " 2147483647 " , " 1ADD 1SUB 1 " , " P2SH , STRICTENC " , " We cannot do math on 5 - byte integers , even if the result is 4 - bytes " ] , <nl> + [ " 2147483648 " , " 1SUB 1 " , " P2SH , STRICTENC " , " We cannot do math on 5 - byte integers , even if the result is 4 - bytes " ] , <nl> + <nl> + [ " 2147483648 1 " , " BOOLOR 1 " , " P2SH , STRICTENC " , " We cannot do BOOLOR on 5 - byte integers ( but we can still do IF etc ) " ] , <nl> + [ " 2147483648 1 " , " BOOLAND 1 " , " P2SH , STRICTENC " , " We cannot do BOOLAND on 5 - byte integers " ] , <nl> + <nl> + [ " 1 " , " 1 ENDIF " , " P2SH , STRICTENC " , " ENDIF without IF " ] , <nl> + [ " 1 " , " IF 1 " , " P2SH , STRICTENC " , " IF without ENDIF " ] , <nl> + [ " 1 IF 1 " , " ENDIF " , " P2SH , STRICTENC " , " IFs don ' t carry over " ] , <nl> + <nl> + [ " NOP " , " IF 1 ENDIF " , " P2SH , STRICTENC " , " The following tests check the if ( stack . size ( ) < N ) tests in each opcode " ] , <nl> + [ " NOP " , " NOTIF 1 ENDIF " , " P2SH , STRICTENC " , " They are here to catch copy - and - paste errors " ] , <nl> + [ " NOP " , " VERIFY 1 " , " P2SH , STRICTENC " , " Most of them are duplicated elsewhere , " ] , <nl> + <nl> + [ " NOP " , " TOALTSTACK 1 " , " P2SH , STRICTENC " , " but , hey , more is always better , right ? " ] , <nl> + [ " 1 " , " FROMALTSTACK " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " 2DROP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " 2DUP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 " , " 3DUP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 1 " , " 2OVER " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 1 1 1 " , " 2ROT " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 1 " , " 2SWAP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " IFDUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " DROP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " DUP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " NIP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " OVER " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 1 3 " , " PICK " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " PICK 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 1 3 " , " ROLL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " ROLL 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 " , " ROT " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " SWAP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " TUCK " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " NOP " , " SIZE 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " EQUAL 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " EQUALVERIFY 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " NOP " , " 1ADD 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 1SUB 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NEGATE 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " ABS 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOT 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " 0NOTEQUAL 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " ADD " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " SUB " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " BOOLAND " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " BOOLOR " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " NUMEQUALVERIFY 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " NUMNOTEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " LESSTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " GREATERTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " LESSTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " GREATERTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " MIN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " MAX " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 " , " WITHIN " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " NOP " , " RIPEMD160 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " SHA1 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " SHA256 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " HASH160 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " HASH256 1 " , " P2SH , STRICTENC " ] , <nl> <nl> [ " " , <nl> " 0 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG " , <nl> + " P2SH , STRICTENC " , <nl> " 202 CHECKMULTISIGS , fails due to 201 op limit " ] , <nl> <nl> [ " 1 " , <nl> - " 0 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY " ] , <nl> + " 0 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY " , <nl> + " P2SH , STRICTENC " ] , <nl> <nl> [ " " , <nl> " NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG " , <nl> + " P2SH , STRICTENC " , <nl> " Fails due to 201 sig op limit " ] , <nl> <nl> [ " 1 " , <nl> - " NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY " ] , <nl> + " NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY " , <nl> + " P2SH , STRICTENC " ] , <nl> <nl> <nl> - [ " 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 " , " 21 CHECKMULTISIG 1 " , " nPubKeys > 20 " ] , <nl> - [ " 0 ' sig ' 1 0 " , " CHECKMULTISIG 1 " , " nSigs > nPubKeys " ] , <nl> + [ " 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 " , " 21 CHECKMULTISIG 1 " , " P2SH , STRICTENC " , " nPubKeys > 20 " ] , <nl> + [ " 0 ' sig ' 1 0 " , " CHECKMULTISIG 1 " , " P2SH , STRICTENC " , " nSigs > nPubKeys " ] , <nl> <nl> <nl> - [ " NOP 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " , " Tests for Script . IsPushOnly ( ) " ] , <nl> - [ " NOP1 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " ] , <nl> + [ " NOP 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " , " P2SH , STRICTENC " , " Tests for Script . IsPushOnly ( ) " ] , <nl> + [ " NOP1 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " , " P2SH , STRICTENC " ] , <nl> <nl> - [ " 0 0x01 0x50 " , " HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL " , " OP_RESERVED in P2SH should fail " ] , <nl> - [ " 0 0x01 VER " , " HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL " , " OP_VER in P2SH should fail " ] , <nl> + [ " 0 0x01 0x50 " , " HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL " , " P2SH , STRICTENC " , " OP_RESERVED in P2SH should fail " ] , <nl> + [ " 0 0x01 VER " , " HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL " , " P2SH , STRICTENC " , " OP_VER in P2SH should fail " ] , <nl> <nl> - [ " 0x00 " , " ' 00 ' EQUAL " , " Basic OP_0 execution " ] <nl> + [ " 0x00 " , " ' 00 ' EQUAL " , " P2SH , STRICTENC " , " Basic OP_0 execution " ] <nl> ] <nl> mmm a / src / test / data / script_valid . json <nl> ppp b / src / test / data / script_valid . json <nl> <nl> [ <nl> - [ " " , " DEPTH 0 EQUAL " , " Test the test : we should have an empty stack after scriptSig evaluation " ] , <nl> - [ " " , " DEPTH 0 EQUAL " , " and multiple spaces should not change that . " ] , <nl> - [ " " , " DEPTH 0 EQUAL " ] , <nl> - [ " " , " DEPTH 0 EQUAL " ] , <nl> - [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " , " Similarly whitespace around and between symbols " ] , <nl> - [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " ] , <nl> - [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " ] , <nl> - [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " ] , <nl> - [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " ] , <nl> - <nl> - [ " 1 " , " " ] , <nl> - [ " 0x02 0x01 0x00 " , " " , " all bytes are significant , not only the last one " ] , <nl> - [ " 0x09 0x00000000 0x00000000 0x10 " , " " , " equals zero when cast to Int64 " ] , <nl> - <nl> - [ " 0x01 0x0b " , " 11 EQUAL " , " push 1 byte " ] , <nl> - [ " 0x02 0x417a " , " ' Az ' EQUAL " ] , <nl> + [ " " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " Test the test : we should have an empty stack after scriptSig evaluation " ] , <nl> + [ " " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " and multiple spaces should not change that . " ] , <nl> + [ " " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " , " P2SH , STRICTENC " , " Similarly whitespace around and between symbols " ] , <nl> + [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 2 " , " 2 EQUALVERIFY 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " " , " P2SH , STRICTENC " ] , <nl> + [ " 0x02 0x01 0x00 " , " " , " P2SH , STRICTENC " , " all bytes are significant , not only the last one " ] , <nl> + [ " 0x09 0x00000000 0x00000000 0x10 " , " " , " P2SH , STRICTENC " , " equals zero when cast to Int64 " ] , <nl> + <nl> + [ " 0x01 0x0b " , " 11 EQUAL " , " P2SH , STRICTENC " , " push 1 byte " ] , <nl> + [ " 0x02 0x417a " , " ' Az ' EQUAL " , " P2SH , STRICTENC " ] , <nl> [ " 0x4b 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a " , <nl> - " ' Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz ' EQUAL " , " push 75 bytes " ] , <nl> - <nl> - [ " 0x4c 0x01 0x07 " , " 7 EQUAL " , " 0x4c is OP_PUSHDATA1 " ] , <nl> - [ " 0x4d 0x0100 0x08 " , " 8 EQUAL " , " 0x4d is OP_PUSHDATA2 " ] , <nl> - [ " 0x4e 0x01000000 0x09 " , " 9 EQUAL " , " 0x4e is OP_PUSHDATA4 " ] , <nl> - <nl> - [ " 0x4c 0x00 " , " 0 EQUAL " ] , <nl> - [ " 0x4d 0x0000 " , " 0 EQUAL " ] , <nl> - [ " 0x4e 0x00000000 " , " 0 EQUAL " ] , <nl> - [ " 0x4f 1000 ADD " , " 999 EQUAL " ] , <nl> - [ " 0 " , " IF 0x50 ENDIF 1 " , " 0x50 is reserved ( ok if not executed ) " ] , <nl> - [ " 0x51 " , " 0x5f ADD 0x60 EQUAL " , " 0x51 through 0x60 push 1 through 16 onto stack " ] , <nl> - [ " 1 " , " NOP " ] , <nl> - [ " 0 " , " IF VER ELSE 1 ENDIF " , " VER non - functional ( ok if not executed ) " ] , <nl> - [ " 0 " , " IF RESERVED RESERVED1 RESERVED2 ELSE 1 ENDIF " , " RESERVED ok in un - executed IF " ] , <nl> - <nl> - [ " 1 " , " DUP IF ENDIF " ] , <nl> - [ " 1 " , " IF 1 ENDIF " ] , <nl> - [ " 1 " , " DUP IF ELSE ENDIF " ] , <nl> - [ " 1 " , " IF 1 ELSE ENDIF " ] , <nl> - [ " 0 " , " IF ELSE 1 ENDIF " ] , <nl> - <nl> - [ " 1 1 " , " IF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 1 0 " , " IF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 1 1 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - [ " 0 0 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - <nl> - [ " 1 0 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 1 1 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " ] , <nl> - [ " 1 0 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - [ " 0 1 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " ] , <nl> - <nl> - [ " 0 " , " IF 0 ELSE 1 ELSE 0 ENDIF " , " Multiple ELSE ' s are valid and executed inverts on each ELSE encountered " ] , <nl> - [ " 1 " , " IF 1 ELSE 0 ELSE ENDIF " ] , <nl> - [ " 1 " , " IF ELSE 0 ELSE 1 ENDIF " ] , <nl> - [ " 1 " , " IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL " ] , <nl> - [ " ' ' 1 " , " IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL " ] , <nl> - <nl> - [ " 1 " , " NOTIF 0 ELSE 1 ELSE 0 ENDIF " , " Multiple ELSE ' s are valid and execution inverts on each ELSE encountered " ] , <nl> - [ " 0 " , " NOTIF 1 ELSE 0 ELSE ENDIF " ] , <nl> - [ " 0 " , " NOTIF ELSE 0 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL " ] , <nl> - [ " ' ' 0 " , " NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL " ] , <nl> - <nl> - [ " 0 " , " IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL " , " Nested ELSE ELSE " ] , <nl> - [ " 1 " , " NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL " ] , <nl> - <nl> - [ " 0 " , " IF RETURN ENDIF 1 " , " RETURN only works if executed " ] , <nl> - <nl> - [ " 1 1 " , " VERIFY " ] , <nl> - [ " 1 0x05 0x01 0x00 0x00 0x00 0x00 " , " VERIFY " , " values > 4 bytes can be cast to boolean " ] , <nl> - <nl> - [ " 10 0 11 TOALTSTACK DROP FROMALTSTACK " , " ADD 21 EQUAL " ] , <nl> - [ " ' gavin_was_here ' TOALTSTACK 11 FROMALTSTACK " , " ' gavin_was_here ' EQUALVERIFY 11 EQUAL " ] , <nl> - <nl> - [ " 0 IFDUP " , " DEPTH 1 EQUALVERIFY 0 EQUAL " ] , <nl> - [ " 1 IFDUP " , " DEPTH 2 EQUALVERIFY 1 EQUALVERIFY 1 EQUAL " ] , <nl> - [ " 0 DROP " , " DEPTH 0 EQUAL " ] , <nl> - [ " 0 " , " DUP 1 ADD 1 EQUALVERIFY 0 EQUAL " ] , <nl> - [ " 0 1 " , " NIP " ] , <nl> - [ " 1 0 " , " OVER DEPTH 3 EQUALVERIFY " ] , <nl> - [ " 22 21 20 " , " 0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL " ] , <nl> - [ " 22 21 20 " , " 1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL " ] , <nl> - [ " 22 21 20 " , " 2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL " ] , <nl> - [ " 22 21 20 " , " 0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " 22 21 20 " , " 1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " 22 21 20 " , " 2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL " ] , <nl> - [ " 22 21 20 " , " ROT 22 EQUAL " ] , <nl> - [ " 22 21 20 " , " ROT DROP 20 EQUAL " ] , <nl> - [ " 22 21 20 " , " ROT DROP DROP 21 EQUAL " ] , <nl> - [ " 22 21 20 " , " ROT ROT 21 EQUAL " ] , <nl> - [ " 22 21 20 " , " ROT ROT ROT 20 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 24 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT DROP 25 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 2DROP 20 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 2DROP DROP 21 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 2DROP 2DROP 22 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 2DROP 2DROP DROP 23 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 2ROT 22 EQUAL " ] , <nl> - [ " 25 24 23 22 21 20 " , " 2ROT 2ROT 2ROT 20 EQUAL " ] , <nl> - [ " 1 0 " , " SWAP 1 EQUALVERIFY 0 EQUAL " ] , <nl> - [ " 0 1 " , " TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP " ] , <nl> - [ " 13 14 " , " 2DUP ROT EQUALVERIFY EQUAL " ] , <nl> - [ " - 1 0 1 2 " , " 3DUP DEPTH 7 EQUALVERIFY ADD ADD 3 EQUALVERIFY 2DROP 0 EQUALVERIFY " ] , <nl> - [ " 1 2 3 5 " , " 2OVER ADD ADD 8 EQUALVERIFY ADD ADD 6 EQUAL " ] , <nl> - [ " 1 3 5 7 " , " 2SWAP ADD 4 EQUALVERIFY ADD 12 EQUAL " ] , <nl> - [ " 0 " , " SIZE 0 EQUAL " ] , <nl> - [ " 1 " , " SIZE 1 EQUAL " ] , <nl> - [ " 127 " , " SIZE 1 EQUAL " ] , <nl> - [ " 128 " , " SIZE 2 EQUAL " ] , <nl> - [ " 32767 " , " SIZE 2 EQUAL " ] , <nl> - [ " 32768 " , " SIZE 3 EQUAL " ] , <nl> - [ " 8388607 " , " SIZE 3 EQUAL " ] , <nl> - [ " 8388608 " , " SIZE 4 EQUAL " ] , <nl> - [ " 2147483647 " , " SIZE 4 EQUAL " ] , <nl> - [ " 2147483648 " , " SIZE 5 EQUAL " ] , <nl> - [ " 549755813887 " , " SIZE 5 EQUAL " ] , <nl> - [ " 549755813888 " , " SIZE 6 EQUAL " ] , <nl> - [ " 9223372036854775807 " , " SIZE 8 EQUAL " ] , <nl> - [ " - 1 " , " SIZE 1 EQUAL " ] , <nl> - [ " - 127 " , " SIZE 1 EQUAL " ] , <nl> - [ " - 128 " , " SIZE 2 EQUAL " ] , <nl> - [ " - 32767 " , " SIZE 2 EQUAL " ] , <nl> - [ " - 32768 " , " SIZE 3 EQUAL " ] , <nl> - [ " - 8388607 " , " SIZE 3 EQUAL " ] , <nl> - [ " - 8388608 " , " SIZE 4 EQUAL " ] , <nl> - [ " - 2147483647 " , " SIZE 4 EQUAL " ] , <nl> - [ " - 2147483648 " , " SIZE 5 EQUAL " ] , <nl> - [ " - 549755813887 " , " SIZE 5 EQUAL " ] , <nl> - [ " - 549755813888 " , " SIZE 6 EQUAL " ] , <nl> - [ " - 9223372036854775807 " , " SIZE 8 EQUAL " ] , <nl> - [ " ' abcdefghijklmnopqrstuvwxyz ' " , " SIZE 26 EQUAL " ] , <nl> - <nl> - [ " 42 " , " SIZE 1 EQUALVERIFY 42 EQUAL " , " SIZE does not consume argument " ] , <nl> - <nl> - [ " 2 - 2 ADD " , " 0 EQUAL " ] , <nl> - [ " 2147483647 - 2147483647 ADD " , " 0 EQUAL " ] , <nl> - [ " - 1 - 1 ADD " , " - 2 EQUAL " ] , <nl> - <nl> - [ " 0 0 " , " EQUAL " ] , <nl> - [ " 1 1 ADD " , " 2 EQUAL " ] , <nl> - [ " 1 1ADD " , " 2 EQUAL " ] , <nl> - [ " 111 1SUB " , " 110 EQUAL " ] , <nl> - [ " 111 1 ADD 12 SUB " , " 100 EQUAL " ] , <nl> - [ " 0 ABS " , " 0 EQUAL " ] , <nl> - [ " 16 ABS " , " 16 EQUAL " ] , <nl> - [ " - 16 ABS " , " - 16 NEGATE EQUAL " ] , <nl> - [ " 0 NOT " , " NOP " ] , <nl> - [ " 1 NOT " , " 0 EQUAL " ] , <nl> - [ " 11 NOT " , " 0 EQUAL " ] , <nl> - [ " 0 0NOTEQUAL " , " 0 EQUAL " ] , <nl> - [ " 1 0NOTEQUAL " , " 1 EQUAL " ] , <nl> - [ " 111 0NOTEQUAL " , " 1 EQUAL " ] , <nl> - [ " - 111 0NOTEQUAL " , " 1 EQUAL " ] , <nl> - [ " 1 1 BOOLAND " , " NOP " ] , <nl> - [ " 1 0 BOOLAND " , " NOT " ] , <nl> - [ " 0 1 BOOLAND " , " NOT " ] , <nl> - [ " 0 0 BOOLAND " , " NOT " ] , <nl> - [ " 16 17 BOOLAND " , " NOP " ] , <nl> - [ " 1 1 BOOLOR " , " NOP " ] , <nl> - [ " 1 0 BOOLOR " , " NOP " ] , <nl> - [ " 0 1 BOOLOR " , " NOP " ] , <nl> - [ " 0 0 BOOLOR " , " NOT " ] , <nl> - [ " 16 17 BOOLOR " , " NOP " ] , <nl> - [ " 11 10 1 ADD " , " NUMEQUAL " ] , <nl> - [ " 11 10 1 ADD " , " NUMEQUALVERIFY 1 " ] , <nl> - [ " 11 10 1 ADD " , " NUMNOTEQUAL NOT " ] , <nl> - [ " 111 10 1 ADD " , " NUMNOTEQUAL " ] , <nl> - [ " 11 10 " , " LESSTHAN NOT " ] , <nl> - [ " 4 4 " , " LESSTHAN NOT " ] , <nl> - [ " 10 11 " , " LESSTHAN " ] , <nl> - [ " - 11 11 " , " LESSTHAN " ] , <nl> - [ " - 11 - 10 " , " LESSTHAN " ] , <nl> - [ " 11 10 " , " GREATERTHAN " ] , <nl> - [ " 4 4 " , " GREATERTHAN NOT " ] , <nl> - [ " 10 11 " , " GREATERTHAN NOT " ] , <nl> - [ " - 11 11 " , " GREATERTHAN NOT " ] , <nl> - [ " - 11 - 10 " , " GREATERTHAN NOT " ] , <nl> - [ " 11 10 " , " LESSTHANOREQUAL NOT " ] , <nl> - [ " 4 4 " , " LESSTHANOREQUAL " ] , <nl> - [ " 10 11 " , " LESSTHANOREQUAL " ] , <nl> - [ " - 11 11 " , " LESSTHANOREQUAL " ] , <nl> - [ " - 11 - 10 " , " LESSTHANOREQUAL " ] , <nl> - [ " 11 10 " , " GREATERTHANOREQUAL " ] , <nl> - [ " 4 4 " , " GREATERTHANOREQUAL " ] , <nl> - [ " 10 11 " , " GREATERTHANOREQUAL NOT " ] , <nl> - [ " - 11 11 " , " GREATERTHANOREQUAL NOT " ] , <nl> - [ " - 11 - 10 " , " GREATERTHANOREQUAL NOT " ] , <nl> - [ " 1 0 MIN " , " 0 NUMEQUAL " ] , <nl> - [ " 0 1 MIN " , " 0 NUMEQUAL " ] , <nl> - [ " - 1 0 MIN " , " - 1 NUMEQUAL " ] , <nl> - [ " 0 - 2147483647 MIN " , " - 2147483647 NUMEQUAL " ] , <nl> - [ " 2147483647 0 MAX " , " 2147483647 NUMEQUAL " ] , <nl> - [ " 0 100 MAX " , " 100 NUMEQUAL " ] , <nl> - [ " - 100 0 MAX " , " 0 NUMEQUAL " ] , <nl> - [ " 0 - 2147483647 MAX " , " 0 NUMEQUAL " ] , <nl> - [ " 0 0 1 " , " WITHIN " ] , <nl> - [ " 1 0 1 " , " WITHIN NOT " ] , <nl> - [ " 0 - 2147483647 2147483647 " , " WITHIN " ] , <nl> - [ " - 1 - 100 100 " , " WITHIN " ] , <nl> - [ " 11 - 100 100 " , " WITHIN " ] , <nl> - [ " - 2147483647 - 100 100 " , " WITHIN NOT " ] , <nl> - [ " 2147483647 - 100 100 " , " WITHIN NOT " ] , <nl> - <nl> - [ " 2147483647 2147483647 SUB " , " 0 EQUAL " ] , <nl> - [ " 2147483647 DUP ADD " , " 4294967294 EQUAL " , " > 32 bit EQUAL is valid " ] , <nl> - [ " 2147483647 NEGATE DUP ADD " , " - 4294967294 EQUAL " ] , <nl> - <nl> - [ " ' ' " , " RIPEMD160 0x14 0x9c1185a5c5e9fc54612808977ee8f548b2258d31 EQUAL " ] , <nl> - [ " ' a ' " , " RIPEMD160 0x14 0x0bdc9d2d256b3ee9daae347be6f4dc835a467ffe EQUAL " ] , <nl> - [ " ' abcdefghijklmnopqrstuvwxyz ' " , " RIPEMD160 0x14 0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc EQUAL " ] , <nl> - [ " ' ' " , " SHA1 0x14 0xda39a3ee5e6b4b0d3255bfef95601890afd80709 EQUAL " ] , <nl> - [ " ' a ' " , " SHA1 0x14 0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 EQUAL " ] , <nl> - [ " ' abcdefghijklmnopqrstuvwxyz ' " , " SHA1 0x14 0x32d10c7b8cf96570ca04ce37f2a19d84240d3a89 EQUAL " ] , <nl> - [ " ' ' " , " SHA256 0x20 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 EQUAL " ] , <nl> - [ " ' a ' " , " SHA256 0x20 0xca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb EQUAL " ] , <nl> - [ " ' abcdefghijklmnopqrstuvwxyz ' " , " SHA256 0x20 0x71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73 EQUAL " ] , <nl> - [ " ' ' " , " DUP HASH160 SWAP SHA256 RIPEMD160 EQUAL " ] , <nl> - [ " ' ' " , " DUP HASH256 SWAP SHA256 SHA256 EQUAL " ] , <nl> - [ " ' ' " , " NOP HASH160 0x14 0xb472a266d0bd89c13706a4132ccfb16f7c3b9fcb EQUAL " ] , <nl> - [ " ' a ' " , " HASH160 NOP 0x14 0x994355199e516ff76c4fa4aab39337b9d84cf12b EQUAL " ] , <nl> - [ " ' abcdefghijklmnopqrstuvwxyz ' " , " HASH160 0x4c 0x14 0xc286a1af0947f58d1ad787385b1c2c4a976f9e71 EQUAL " ] , <nl> - [ " ' ' " , " HASH256 0x20 0x5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456 EQUAL " ] , <nl> - [ " ' a ' " , " HASH256 0x20 0xbf5d3affb73efd2ec6c36ad3112dd933efed63c4e1cbffcfa88e2759c144f2d8 EQUAL " ] , <nl> - [ " ' abcdefghijklmnopqrstuvwxyz ' " , " HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL " ] , <nl> - <nl> - <nl> - [ " 1 " , " NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL " ] , <nl> - [ " ' NOP_1_to_10 ' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 " , " ' NOP_1_to_10 ' EQUAL " ] , <nl> - <nl> - [ " 0 " , " IF 0xba ELSE 1 ENDIF " , " opcodes above NOP10 invalid if executed " ] , <nl> - [ " 0 " , " IF 0xbb ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xbc ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xbd ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xbe ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xbf ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc0 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc1 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc2 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc3 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc4 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc5 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc6 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc7 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc8 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xc9 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xca ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xcb ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xcc ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xcd ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xce ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xcf ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd0 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd1 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd2 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd3 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd4 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd5 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd6 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd7 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd8 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xd9 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xda ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xdb ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xdc ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xdd ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xde ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xdf ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe0 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe1 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe2 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe3 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe4 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe5 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe6 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe7 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe8 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xe9 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xea ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xeb ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xec ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xed ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xee ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xef ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf0 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf1 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf2 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf3 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf4 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf5 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf6 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf7 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf8 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xf9 ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xfa ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xfb ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xfc ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xfd ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xfe ELSE 1 ENDIF " ] , <nl> - [ " 0 " , " IF 0xff ELSE 1 ENDIF " ] , <nl> + " ' Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz ' EQUAL " , " P2SH , STRICTENC " , " push 75 bytes " ] , <nl> + <nl> + [ " 0x4c 0x01 0x07 " , " 7 EQUAL " , " P2SH , STRICTENC " , " 0x4c is OP_PUSHDATA1 " ] , <nl> + [ " 0x4d 0x0100 0x08 " , " 8 EQUAL " , " P2SH , STRICTENC " , " 0x4d is OP_PUSHDATA2 " ] , <nl> + [ " 0x4e 0x01000000 0x09 " , " 9 EQUAL " , " P2SH , STRICTENC " , " 0x4e is OP_PUSHDATA4 " ] , <nl> + <nl> + [ " 0x4c 0x00 " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0x4d 0x0000 " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0x4e 0x00000000 " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0x4f 1000 ADD " , " 999 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0x50 ENDIF 1 " , " P2SH , STRICTENC " , " 0x50 is reserved ( ok if not executed ) " ] , <nl> + [ " 0x51 " , " 0x5f ADD 0x60 EQUAL " , " P2SH , STRICTENC " , " 0x51 through 0x60 push 1 through 16 onto stack " ] , <nl> + [ " 1 " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF VER ELSE 1 ENDIF " , " P2SH , STRICTENC " , " VER non - functional ( ok if not executed ) " ] , <nl> + [ " 0 " , " IF RESERVED RESERVED1 RESERVED2 ELSE 1 ENDIF " , " P2SH , STRICTENC " , " RESERVED ok in un - executed IF " ] , <nl> + <nl> + [ " 1 " , " DUP IF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " DUP IF ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 1 ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 1 " , " IF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " IF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 0 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 " , " NOTIF IF 1 ELSE 0 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " IF 0 ELSE 1 ELSE 0 ENDIF " , " P2SH , STRICTENC " , " Multiple ELSE ' s are valid and executed inverts on each ELSE encountered " ] , <nl> + [ " 1 " , " IF 1 ELSE 0 ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF ELSE 0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' 1 " , " IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " NOTIF 0 ELSE 1 ELSE 0 ENDIF " , " P2SH , STRICTENC " , " Multiple ELSE ' s are valid and execution inverts on each ELSE encountered " ] , <nl> + [ " 0 " , " NOTIF 1 ELSE 0 ELSE ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " NOTIF ELSE 0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' 0 " , " NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL " , " P2SH , STRICTENC " , " Nested ELSE ELSE " ] , <nl> + [ " 1 " , " NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " IF RETURN ENDIF 1 " , " P2SH , STRICTENC " , " RETURN only works if executed " ] , <nl> + <nl> + [ " 1 1 " , " VERIFY " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0x05 0x01 0x00 0x00 0x00 0x00 " , " VERIFY " , " P2SH , STRICTENC " , " values > 4 bytes can be cast to boolean " ] , <nl> + <nl> + [ " 10 0 11 TOALTSTACK DROP FROMALTSTACK " , " ADD 21 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' gavin_was_here ' TOALTSTACK 11 FROMALTSTACK " , " ' gavin_was_here ' EQUALVERIFY 11 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 IFDUP " , " DEPTH 1 EQUALVERIFY 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 IFDUP " , " DEPTH 2 EQUALVERIFY 1 EQUALVERIFY 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 DROP " , " DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " DUP 1 ADD 1 EQUALVERIFY 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " NIP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " OVER DEPTH 3 EQUALVERIFY " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " 0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " 1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " 2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " 0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " 1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " 2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " ROT 22 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " ROT DROP 20 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " ROT DROP DROP 21 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " ROT ROT 21 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 22 21 20 " , " ROT ROT ROT 20 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 24 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT DROP 25 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 2DROP 20 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 2DROP DROP 21 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 2DROP 2DROP 22 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 2DROP 2DROP DROP 23 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 2ROT 22 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 25 24 23 22 21 20 " , " 2ROT 2ROT 2ROT 20 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " SWAP 1 EQUALVERIFY 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP " , " P2SH , STRICTENC " ] , <nl> + [ " 13 14 " , " 2DUP ROT EQUALVERIFY EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 0 1 2 " , " 3DUP DEPTH 7 EQUALVERIFY ADD ADD 3 EQUALVERIFY 2DROP 0 EQUALVERIFY " , " P2SH , STRICTENC " ] , <nl> + [ " 1 2 3 5 " , " 2OVER ADD ADD 8 EQUALVERIFY ADD ADD 6 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 3 5 7 " , " 2SWAP ADD 4 EQUALVERIFY ADD 12 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " SIZE 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " SIZE 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 127 " , " SIZE 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 128 " , " SIZE 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 32767 " , " SIZE 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 32768 " , " SIZE 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 8388607 " , " SIZE 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 8388608 " , " SIZE 4 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483647 " , " SIZE 4 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483648 " , " SIZE 5 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 549755813887 " , " SIZE 5 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 549755813888 " , " SIZE 6 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 9223372036854775807 " , " SIZE 8 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 " , " SIZE 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 127 " , " SIZE 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 128 " , " SIZE 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 32767 " , " SIZE 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 32768 " , " SIZE 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 8388607 " , " SIZE 3 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 8388608 " , " SIZE 4 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 2147483647 " , " SIZE 4 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 2147483648 " , " SIZE 5 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 549755813887 " , " SIZE 5 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 549755813888 " , " SIZE 6 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 9223372036854775807 " , " SIZE 8 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' abcdefghijklmnopqrstuvwxyz ' " , " SIZE 26 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 42 " , " SIZE 1 EQUALVERIFY 42 EQUAL " , " P2SH , STRICTENC " , " SIZE does not consume argument " ] , <nl> + <nl> + [ " 2 - 2 ADD " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483647 - 2147483647 ADD " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 - 1 ADD " , " - 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 0 " , " EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 ADD " , " 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1ADD " , " 2 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 111 1SUB " , " 110 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 111 1 ADD 12 SUB " , " 100 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 ABS " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 16 ABS " , " 16 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 16 ABS " , " - 16 NEGATE EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 NOT " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 NOT " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 11 NOT " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0NOTEQUAL " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0NOTEQUAL " , " 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 111 0NOTEQUAL " , " 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 111 0NOTEQUAL " , " 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 BOOLAND " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 BOOLAND " , " NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 BOOLAND " , " NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 BOOLAND " , " NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 16 17 BOOLAND " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 1 BOOLOR " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 BOOLOR " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 BOOLOR " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 BOOLOR " , " NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 16 17 BOOLOR " , " NOP " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 1 ADD " , " NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 1 ADD " , " NUMEQUALVERIFY 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 1 ADD " , " NUMNOTEQUAL NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 111 10 1 ADD " , " NUMNOTEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 " , " LESSTHAN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 4 4 " , " LESSTHAN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 10 11 " , " LESSTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 11 " , " LESSTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 - 10 " , " LESSTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 " , " GREATERTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " 4 4 " , " GREATERTHAN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 10 11 " , " GREATERTHAN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 11 " , " GREATERTHAN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 - 10 " , " GREATERTHAN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 " , " LESSTHANOREQUAL NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 4 4 " , " LESSTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 10 11 " , " LESSTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 11 " , " LESSTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 - 10 " , " LESSTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 11 10 " , " GREATERTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 4 4 " , " GREATERTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 10 11 " , " GREATERTHANOREQUAL NOT " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 11 " , " GREATERTHANOREQUAL NOT " , " P2SH , STRICTENC " ] , <nl> + [ " - 11 - 10 " , " GREATERTHANOREQUAL NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 MIN " , " 0 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 MIN " , " 0 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 0 MIN " , " - 1 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 - 2147483647 MIN " , " - 2147483647 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483647 0 MAX " , " 2147483647 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 100 MAX " , " 100 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 100 0 MAX " , " 0 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 - 2147483647 MAX " , " 0 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 1 " , " WITHIN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 1 " , " WITHIN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 0 - 2147483647 2147483647 " , " WITHIN " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 - 100 100 " , " WITHIN " , " P2SH , STRICTENC " ] , <nl> + [ " 11 - 100 100 " , " WITHIN " , " P2SH , STRICTENC " ] , <nl> + [ " - 2147483647 - 100 100 " , " WITHIN NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483647 - 100 100 " , " WITHIN NOT " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 2147483647 2147483647 SUB " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483647 DUP ADD " , " 4294967294 EQUAL " , " P2SH , STRICTENC " , " > 32 bit EQUAL is valid " ] , <nl> + [ " 2147483647 NEGATE DUP ADD " , " - 4294967294 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " ' ' " , " RIPEMD160 0x14 0x9c1185a5c5e9fc54612808977ee8f548b2258d31 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' a ' " , " RIPEMD160 0x14 0x0bdc9d2d256b3ee9daae347be6f4dc835a467ffe EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' abcdefghijklmnopqrstuvwxyz ' " , " RIPEMD160 0x14 0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' " , " SHA1 0x14 0xda39a3ee5e6b4b0d3255bfef95601890afd80709 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' a ' " , " SHA1 0x14 0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' abcdefghijklmnopqrstuvwxyz ' " , " SHA1 0x14 0x32d10c7b8cf96570ca04ce37f2a19d84240d3a89 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' " , " SHA256 0x20 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' a ' " , " SHA256 0x20 0xca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' abcdefghijklmnopqrstuvwxyz ' " , " SHA256 0x20 0x71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' " , " DUP HASH160 SWAP SHA256 RIPEMD160 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' " , " DUP HASH256 SWAP SHA256 SHA256 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' " , " NOP HASH160 0x14 0xb472a266d0bd89c13706a4132ccfb16f7c3b9fcb EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' a ' " , " HASH160 NOP 0x14 0x994355199e516ff76c4fa4aab39337b9d84cf12b EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' abcdefghijklmnopqrstuvwxyz ' " , " HASH160 0x4c 0x14 0xc286a1af0947f58d1ad787385b1c2c4a976f9e71 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' ' " , " HASH256 0x20 0x5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' a ' " , " HASH256 0x20 0xbf5d3affb73efd2ec6c36ad3112dd933efed63c4e1cbffcfa88e2759c144f2d8 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' abcdefghijklmnopqrstuvwxyz ' " , " HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + <nl> + [ " 1 " , " NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " ' NOP_1_to_10 ' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 " , " ' NOP_1_to_10 ' EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " IF 0xba ELSE 1 ENDIF " , " P2SH , STRICTENC " , " opcodes above NOP10 invalid if executed " ] , <nl> + [ " 0 " , " IF 0xbb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xbc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xbd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xbe ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xbf ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xc9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xca ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xcb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xcc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xcd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xce ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xcf ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xd9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xda ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xdb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xdc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xdd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xde ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xdf ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xe9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xea ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xeb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xec ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xed ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xee ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xef ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf0 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf1 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf2 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf3 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf4 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf5 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf6 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf7 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf8 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xf9 ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xfa ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xfb ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xfc ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xfd ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xfe ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " IF 0xff ELSE 1 ENDIF " , " P2SH , STRICTENC " ] , <nl> <nl> [ " NOP " , <nl> " ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' " , <nl> + " P2SH , STRICTENC " , <nl> " 520 byte push " ] , <nl> [ " 1 " , <nl> " 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 " , <nl> + " P2SH , STRICTENC " , <nl> " 201 opcodes executed . 0x61 is NOP " ] , <nl> [ " 1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> " 1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> + " P2SH , STRICTENC " , <nl> " 1 , 000 stack size ( 0x6f is 3DUP ) " ] , <nl> [ " 1 TOALTSTACK 2 TOALTSTACK 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> " 1 2 3 4 5 6 7 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> + " P2SH , STRICTENC " , <nl> " 1 , 000 stack size ( altstack cleared between scriptSig / scriptPubKey ) " ] , <nl> [ " ' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f " , <nl> " ' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' ' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f 2DUP 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 " , <nl> + " P2SH , STRICTENC " , <nl> " Max - size ( 10 , 000 - byte ) , max - push ( 520 bytes ) , max - opcodes ( 201 ) , max stack size ( 1 , 000 items ) . 0x6f is 3DUP , 0x61 is NOP " ] , <nl> <nl> [ " 0 " , <nl> " IF 0x5050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050 ENDIF 1 " , <nl> + " P2SH , STRICTENC " , <nl> " > 201 opcodes , but RESERVED ( 0x50 ) doesn ' t count towards opcode limit . " ] , <nl> <nl> - [ " NOP " , " 1 " ] , <nl> - <nl> - [ " 1 " , " 0x01 0x01 EQUAL " , " The following is useful for checking implementations of BN_bn2mpi " ] , <nl> - [ " 127 " , " 0x01 0x7F EQUAL " ] , <nl> - [ " 128 " , " 0x02 0x8000 EQUAL " , " Leave room for the sign bit " ] , <nl> - [ " 32767 " , " 0x02 0xFF7F EQUAL " ] , <nl> - [ " 32768 " , " 0x03 0x008000 EQUAL " ] , <nl> - [ " 8388607 " , " 0x03 0xFFFF7F EQUAL " ] , <nl> - [ " 8388608 " , " 0x04 0x00008000 EQUAL " ] , <nl> - [ " 2147483647 " , " 0x04 0xFFFFFF7F EQUAL " ] , <nl> - [ " 2147483648 " , " 0x05 0x0000008000 EQUAL " ] , <nl> - [ " 549755813887 " , " 0x05 0xFFFFFFFF7F EQUAL " ] , <nl> - [ " 549755813888 " , " 0x06 0xFFFFFFFF7F EQUAL " ] , <nl> - [ " 9223372036854775807 " , " 0x08 0xFFFFFFFFFFFFFF7F EQUAL " ] , <nl> - [ " - 1 " , " 0x01 0x81 EQUAL " , " Numbers are little - endian with the MSB being a sign bit " ] , <nl> - [ " - 127 " , " 0x01 0xFF EQUAL " ] , <nl> - [ " - 128 " , " 0x02 0x8080 EQUAL " ] , <nl> - [ " - 32767 " , " 0x02 0xFFFF EQUAL " ] , <nl> - [ " - 32768 " , " 0x03 0x008080 EQUAL " ] , <nl> - [ " - 8388607 " , " 0x03 0xFFFFFF EQUAL " ] , <nl> - [ " - 8388608 " , " 0x04 0x00008080 EQUAL " ] , <nl> - [ " - 2147483647 " , " 0x04 0xFFFFFFFF EQUAL " ] , <nl> - [ " - 2147483648 " , " 0x05 0x0000008080 EQUAL " ] , <nl> - [ " - 4294967295 " , " 0x05 0xFFFFFFFF80 EQUAL " ] , <nl> - [ " - 549755813887 " , " 0x05 0xFFFFFFFFFF EQUAL " ] , <nl> - [ " - 549755813888 " , " 0x06 0x000000008080 EQUAL " ] , <nl> - [ " - 9223372036854775807 " , " 0x08 0xFFFFFFFFFFFFFFFF EQUAL " ] , <nl> - <nl> - [ " 2147483647 " , " 1ADD 2147483648 EQUAL " , " We can do math on 4 - byte integers , and compare 5 - byte ones " ] , <nl> - [ " 2147483647 " , " 1ADD 1 " ] , <nl> - [ " - 2147483647 " , " 1ADD 1 " ] , <nl> - <nl> - [ " 1 " , " 0x02 0x0100 EQUAL NOT " , " Not the same byte array . . . " ] , <nl> - [ " 1 " , " 0x02 0x0100 NUMEQUAL " , " . . . but they are numerically equal " ] , <nl> - [ " 11 " , " 0x4c 0x03 0x0b0000 NUMEQUAL " ] , <nl> - [ " 0 " , " 0x01 0x80 EQUAL NOT " ] , <nl> - [ " 0 " , " 0x01 0x80 NUMEQUAL " , " Zero numerically equals negative zero " ] , <nl> - [ " 0 " , " 0x02 0x0080 NUMEQUAL " ] , <nl> - [ " 0x03 0x000080 " , " 0x04 0x00000080 NUMEQUAL " ] , <nl> - [ " 0x03 0x100080 " , " 0x04 0x10000080 NUMEQUAL " ] , <nl> - [ " 0x03 0x100000 " , " 0x04 0x10000000 NUMEQUAL " ] , <nl> - <nl> - [ " NOP " , " NOP 1 " , " The following tests check the if ( stack . size ( ) < N ) tests in each opcode " ] , <nl> - [ " 1 " , " IF 1 ENDIF " , " They are here to catch copy - and - paste errors " ] , <nl> - [ " 0 " , " NOTIF 1 ENDIF " , " Most of them are duplicated elsewhere , " ] , <nl> - [ " 1 " , " VERIFY 1 " , " but , hey , more is always better , right ? " ] , <nl> - <nl> - [ " 0 " , " TOALTSTACK 1 " ] , <nl> - [ " 1 " , " TOALTSTACK FROMALTSTACK " ] , <nl> - [ " 0 0 " , " 2DROP 1 " ] , <nl> - [ " 0 1 " , " 2DUP " ] , <nl> - [ " 0 0 1 " , " 3DUP " ] , <nl> - [ " 0 1 0 0 " , " 2OVER " ] , <nl> - [ " 0 1 0 0 0 0 " , " 2ROT " ] , <nl> - [ " 0 1 0 0 " , " 2SWAP " ] , <nl> - [ " 1 " , " IFDUP " ] , <nl> - [ " NOP " , " DEPTH 1 " ] , <nl> - [ " 0 " , " DROP 1 " ] , <nl> - [ " 1 " , " DUP " ] , <nl> - [ " 0 1 " , " NIP " ] , <nl> - [ " 1 0 " , " OVER " ] , <nl> - [ " 1 0 0 0 3 " , " PICK " ] , <nl> - [ " 1 0 " , " PICK " ] , <nl> - [ " 1 0 0 0 3 " , " ROLL " ] , <nl> - [ " 1 0 " , " ROLL " ] , <nl> - [ " 1 0 0 " , " ROT " ] , <nl> - [ " 1 0 " , " SWAP " ] , <nl> - [ " 0 1 " , " TUCK " ] , <nl> - <nl> - [ " 1 " , " SIZE " ] , <nl> - <nl> - [ " 0 0 " , " EQUAL " ] , <nl> - [ " 0 0 " , " EQUALVERIFY 1 " ] , <nl> - <nl> - [ " 0 " , " 1ADD " ] , <nl> - [ " 2 " , " 1SUB " ] , <nl> - [ " - 1 " , " NEGATE " ] , <nl> - [ " - 1 " , " ABS " ] , <nl> - [ " 0 " , " NOT " ] , <nl> - [ " - 1 " , " 0NOTEQUAL " ] , <nl> - <nl> - [ " 1 0 " , " ADD " ] , <nl> - [ " 1 0 " , " SUB " ] , <nl> - [ " - 1 - 1 " , " BOOLAND " ] , <nl> - [ " - 1 0 " , " BOOLOR " ] , <nl> - [ " 0 0 " , " NUMEQUAL " ] , <nl> - [ " 0 0 " , " NUMEQUALVERIFY 1 " ] , <nl> - [ " - 1 0 " , " NUMNOTEQUAL " ] , <nl> - [ " - 1 0 " , " LESSTHAN " ] , <nl> - [ " 1 0 " , " GREATERTHAN " ] , <nl> - [ " 0 0 " , " LESSTHANOREQUAL " ] , <nl> - [ " 0 0 " , " GREATERTHANOREQUAL " ] , <nl> - [ " - 1 0 " , " MIN " ] , <nl> - [ " 1 0 " , " MAX " ] , <nl> - [ " - 1 - 1 0 " , " WITHIN " ] , <nl> - <nl> - [ " 0 " , " RIPEMD160 " ] , <nl> - [ " 0 " , " SHA1 " ] , <nl> - [ " 0 " , " SHA256 " ] , <nl> - [ " 0 " , " HASH160 " ] , <nl> - [ " 0 " , " HASH256 " ] , <nl> - [ " NOP " , " CODESEPARATOR 1 " ] , <nl> - <nl> - [ " NOP " , " NOP1 1 " ] , <nl> - [ " NOP " , " NOP2 1 " ] , <nl> - [ " NOP " , " NOP3 1 " ] , <nl> - [ " NOP " , " NOP4 1 " ] , <nl> - [ " NOP " , " NOP5 1 " ] , <nl> - [ " NOP " , " NOP6 1 " ] , <nl> - [ " NOP " , " NOP7 1 " ] , <nl> - [ " NOP " , " NOP8 1 " ] , <nl> - [ " NOP " , " NOP9 1 " ] , <nl> - [ " NOP " , " NOP10 1 " ] , <nl> - <nl> - [ " " , " 0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " CHECKMULTISIG is allowed to have zero keys and / or sigs " ] , <nl> - [ " " , " 0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " Zero sigs means no sigs are checked " ] , <nl> - [ " " , " 0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - <nl> - [ " " , " 0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " CHECKMULTISIG is allowed to have zero keys and / or sigs " ] , <nl> - [ " " , " 0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " Zero sigs means no sigs are checked " ] , <nl> - [ " " , " 0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - <nl> - [ " " , " 0 0 ' a ' ' b ' 2 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " Test from up to 20 pubkeys , all not checked " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' 3 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' 4 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' 5 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' 6 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' 7 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' 8 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' 9 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' 10 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' 11 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' 12 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' 13 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' 14 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' 15 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' 16 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' 17 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' 18 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' 19 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' 2 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' 3 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' 4 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' 5 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' 6 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' 7 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' 8 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' 9 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' 10 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' 11 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' 12 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' 13 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' 14 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' 15 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' 16 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' 17 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' 18 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' 19 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> - [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " ] , <nl> + [ " NOP " , " 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " 0x01 0x01 EQUAL " , " P2SH , STRICTENC " , " The following is useful for checking implementations of BN_bn2mpi " ] , <nl> + [ " 127 " , " 0x01 0x7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 128 " , " 0x02 0x8000 EQUAL " , " P2SH , STRICTENC " , " Leave room for the sign bit " ] , <nl> + [ " 32767 " , " 0x02 0xFF7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 32768 " , " 0x03 0x008000 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 8388607 " , " 0x03 0xFFFF7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 8388608 " , " 0x04 0x00008000 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483647 " , " 0x04 0xFFFFFF7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 2147483648 " , " 0x05 0x0000008000 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 549755813887 " , " 0x05 0xFFFFFFFF7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 549755813888 " , " 0x06 0xFFFFFFFF7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 9223372036854775807 " , " 0x08 0xFFFFFFFFFFFFFF7F EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 " , " 0x01 0x81 EQUAL " , " P2SH , STRICTENC " , " Numbers are little - endian with the MSB being a sign bit " ] , <nl> + [ " - 127 " , " 0x01 0xFF EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 128 " , " 0x02 0x8080 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 32767 " , " 0x02 0xFFFF EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 32768 " , " 0x03 0x008080 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 8388607 " , " 0x03 0xFFFFFF EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 8388608 " , " 0x04 0x00008080 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 2147483647 " , " 0x04 0xFFFFFFFF EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 2147483648 " , " 0x05 0x0000008080 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 4294967295 " , " 0x05 0xFFFFFFFF80 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 549755813887 " , " 0x05 0xFFFFFFFFFF EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 549755813888 " , " 0x06 0x000000008080 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 9223372036854775807 " , " 0x08 0xFFFFFFFFFFFFFFFF EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 2147483647 " , " 1ADD 2147483648 EQUAL " , " P2SH , STRICTENC " , " We can do math on 4 - byte integers , and compare 5 - byte ones " ] , <nl> + [ " 2147483647 " , " 1ADD 1 " , " P2SH , STRICTENC " ] , <nl> + [ " - 2147483647 " , " 1ADD 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " 0x02 0x0100 EQUAL NOT " , " P2SH , STRICTENC " , " Not the same byte array . . . " ] , <nl> + [ " 1 " , " 0x02 0x0100 NUMEQUAL " , " P2SH , STRICTENC " , " . . . but they are numerically equal " ] , <nl> + [ " 11 " , " 0x4c 0x03 0x0b0000 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " 0x01 0x80 EQUAL NOT " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " 0x01 0x80 NUMEQUAL " , " P2SH , STRICTENC " , " Zero numerically equals negative zero " ] , <nl> + [ " 0 " , " 0x02 0x0080 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0x03 0x000080 " , " 0x04 0x00000080 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0x03 0x100080 " , " 0x04 0x10000080 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0x03 0x100000 " , " 0x04 0x10000000 NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " NOP " , " NOP 1 " , " P2SH , STRICTENC " , " The following tests check the if ( stack . size ( ) < N ) tests in each opcode " ] , <nl> + [ " 1 " , " IF 1 ENDIF " , " P2SH , STRICTENC " , " They are here to catch copy - and - paste errors " ] , <nl> + [ " 0 " , " NOTIF 1 ENDIF " , " P2SH , STRICTENC " , " Most of them are duplicated elsewhere , " ] , <nl> + [ " 1 " , " VERIFY 1 " , " P2SH , STRICTENC " , " but , hey , more is always better , right ? " ] , <nl> + <nl> + [ " 0 " , " TOALTSTACK 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " TOALTSTACK FROMALTSTACK " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " 2DROP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " 2DUP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 1 " , " 3DUP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 0 0 " , " 2OVER " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 0 0 0 0 " , " 2ROT " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 0 0 " , " 2SWAP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " IFDUP " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " DEPTH 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " DROP 1 " , " P2SH , STRICTENC " ] , <nl> + [ " 1 " , " DUP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " NIP " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " OVER " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 0 0 3 " , " PICK " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " PICK " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 0 0 3 " , " ROLL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " ROLL " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 0 " , " ROT " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " SWAP " , " P2SH , STRICTENC " ] , <nl> + [ " 0 1 " , " TUCK " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 " , " SIZE " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 0 " , " EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " EQUALVERIFY 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " 1ADD " , " P2SH , STRICTENC " ] , <nl> + [ " 2 " , " 1SUB " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 " , " NEGATE " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 " , " ABS " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " NOT " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 " , " 0NOTEQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 1 0 " , " ADD " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " SUB " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 - 1 " , " BOOLAND " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 0 " , " BOOLOR " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " NUMEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " NUMEQUALVERIFY 1 " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 0 " , " NUMNOTEQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 0 " , " LESSTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " GREATERTHAN " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " LESSTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " 0 0 " , " GREATERTHANOREQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 0 " , " MIN " , " P2SH , STRICTENC " ] , <nl> + [ " 1 0 " , " MAX " , " P2SH , STRICTENC " ] , <nl> + [ " - 1 - 1 0 " , " WITHIN " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " 0 " , " RIPEMD160 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " SHA1 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " SHA256 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " HASH160 " , " P2SH , STRICTENC " ] , <nl> + [ " 0 " , " HASH256 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " CODESEPARATOR 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " NOP " , " NOP1 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP2 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP3 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP4 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP5 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP6 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP7 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP8 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP9 1 " , " P2SH , STRICTENC " ] , <nl> + [ " NOP " , " NOP10 1 " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " " , " 0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " CHECKMULTISIG is allowed to have zero keys and / or sigs " ] , <nl> + [ " " , " 0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " Zero sigs means no sigs are checked " ] , <nl> + [ " " , " 0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " " , " 0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " CHECKMULTISIG is allowed to have zero keys and / or sigs " ] , <nl> + [ " " , " 0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " Zero sigs means no sigs are checked " ] , <nl> + [ " " , " 0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + <nl> + [ " " , " 0 0 ' a ' ' b ' 2 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " , " Test from up to 20 pubkeys , all not checked " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' 3 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' 4 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' 5 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' 6 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' 7 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' 8 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' 9 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' 10 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' 11 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' 12 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' 13 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' 14 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' 15 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' 16 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' 17 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' 18 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' 19 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG VERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' 2 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' 3 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' 4 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' 5 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' 6 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' 7 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' 8 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' 9 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' 10 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' 11 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' 12 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' 13 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' 14 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' 15 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' 16 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' 17 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' 18 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' 19 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> + [ " " , " 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY DEPTH 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> <nl> [ " " , <nl> " 0 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG " , <nl> + " P2SH , STRICTENC " , <nl> " nOpCount is incremented by the number of keys evaluated in addition to the usual one op per op . In this case we have zero keys , so we can execute 201 CHECKMULTISIGS " ] , <nl> <nl> [ " 1 " , <nl> - " 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY " ] , <nl> + " 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY " , <nl> + " P2SH , STRICTENC " ] , <nl> <nl> [ " " , <nl> " NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIG " , <nl> + " P2SH , STRICTENC " , <nl> " Even though there are no signatures being checked nOpCount is incremented by the number of keys . " ] , <nl> <nl> [ " 1 " , <nl> - " NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY " ] , <nl> + " NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY 0 0 ' a ' ' b ' ' c ' ' d ' ' e ' ' f ' ' g ' ' h ' ' i ' ' j ' ' k ' ' l ' ' m ' ' n ' ' o ' ' p ' ' q ' ' r ' ' s ' ' t ' 20 CHECKMULTISIGVERIFY " , <nl> + " P2SH , STRICTENC " ] , <nl> <nl> - [ " 0 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " , " Very basic P2SH " ] , <nl> - [ " 0x4c 0 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " ] , <nl> + [ " 0 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " , " P2SH , STRICTENC " , " Very basic P2SH " ] , <nl> + [ " 0x4c 0 0x01 1 " , " HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL " , " P2SH , STRICTENC " ] , <nl> <nl> [ " 0x40 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 " , <nl> " 0x4d 0x4000 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 EQUAL " , <nl> + " P2SH , STRICTENC " , <nl> " Basic PUSH signedness check " ] , <nl> <nl> [ " 0x4c 0x40 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 " , <nl> " 0x4d 0x4000 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 EQUAL " , <nl> + " P2SH , STRICTENC " , <nl> " Basic PUSHDATA1 signedness check " ] , <nl> <nl> - [ " 0x00 " , " SIZE 0 EQUAL " , " Basic OP_0 execution " ] <nl> + [ " 0x00 " , " SIZE 0 EQUAL " , " P2SH , STRICTENC " , " Basic OP_0 execution " ] <nl> ] <nl> mmm a / src / test / script_tests . cpp <nl> ppp b / src / test / script_tests . cpp <nl> using namespace boost : : algorithm ; <nl> <nl> static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC ; <nl> <nl> + unsigned int ParseScriptFlags ( string strFlags ) ; <nl> + <nl> Array <nl> read_json ( const std : : string & jsondata ) <nl> { <nl> BOOST_AUTO_TEST_CASE ( script_valid ) <nl> { <nl> / / Read tests from test / data / script_valid . json <nl> / / Format is an array of arrays <nl> - / / Inner arrays are [ " scriptSig " , " scriptPubKey " ] <nl> + / / Inner arrays are [ " scriptSig " , " scriptPubKey " , " flags " ] <nl> / / . . . where scriptSig and scriptPubKey are stringified <nl> / / scripts . <nl> Array tests = read_json ( std : : string ( json_tests : : script_valid , json_tests : : script_valid + sizeof ( json_tests : : script_valid ) ) ) ; <nl> BOOST_AUTO_TEST_CASE ( script_valid ) <nl> { <nl> Array test = tv . get_array ( ) ; <nl> string strTest = write_string ( tv , false ) ; <nl> - if ( test . size ( ) < 2 ) / / Allow size > 2 ; extra stuff ignored ( useful for comments ) <nl> + if ( test . size ( ) < 3 ) / / Allow size > 3 ; extra stuff ignored ( useful for comments ) <nl> { <nl> BOOST_ERROR ( " Bad test : " < < strTest ) ; <nl> continue ; <nl> BOOST_AUTO_TEST_CASE ( script_valid ) <nl> CScript scriptSig = ParseScript ( scriptSigString ) ; <nl> string scriptPubKeyString = test [ 1 ] . get_str ( ) ; <nl> CScript scriptPubKey = ParseScript ( scriptPubKeyString ) ; <nl> + unsigned int scriptflags = ParseScriptFlags ( test [ 2 ] . get_str ( ) ) ; <nl> <nl> CTransaction tx ; <nl> - BOOST_CHECK_MESSAGE ( VerifyScript ( scriptSig , scriptPubKey , tx , 0 , flags , SIGHASH_NONE ) , strTest ) ; <nl> + BOOST_CHECK_MESSAGE ( VerifyScript ( scriptSig , scriptPubKey , tx , 0 , scriptflags , SIGHASH_NONE ) , strTest ) ; <nl> } <nl> } <nl> <nl> BOOST_AUTO_TEST_CASE ( script_invalid ) <nl> CScript scriptSig = ParseScript ( scriptSigString ) ; <nl> string scriptPubKeyString = test [ 1 ] . get_str ( ) ; <nl> CScript scriptPubKey = ParseScript ( scriptPubKeyString ) ; <nl> + unsigned int scriptflags = ParseScriptFlags ( test [ 2 ] . get_str ( ) ) ; <nl> <nl> CTransaction tx ; <nl> - BOOST_CHECK_MESSAGE ( ! VerifyScript ( scriptSig , scriptPubKey , tx , 0 , flags , SIGHASH_NONE ) , strTest ) ; <nl> + BOOST_CHECK_MESSAGE ( ! VerifyScript ( scriptSig , scriptPubKey , tx , 0 , scriptflags , SIGHASH_NONE ) , strTest ) ; <nl> } <nl> } <nl> <nl> mmm a / src / test / transaction_tests . cpp <nl> ppp b / src / test / transaction_tests . cpp <nl> using namespace boost : : algorithm ; <nl> / / In script_tests . cpp <nl> extern Array read_json ( const std : : string & jsondata ) ; <nl> <nl> - unsigned int ParseFlags ( string strFlags ) { <nl> + unsigned int ParseScriptFlags ( string strFlags ) { <nl> unsigned int flags = 0 ; <nl> vector < string > words ; <nl> split ( words , strFlags , is_any_of ( " , " ) ) ; <nl> BOOST_AUTO_TEST_CASE ( tx_valid ) <nl> break ; <nl> } <nl> <nl> - unsigned int verify_flags = ParseFlags ( test [ 2 ] . get_str ( ) ) ; <nl> + unsigned int verify_flags = ParseScriptFlags ( test [ 2 ] . get_str ( ) ) ; <nl> BOOST_CHECK_MESSAGE ( VerifyScript ( tx . vin [ i ] . scriptSig , mapprevOutScriptPubKeys [ tx . vin [ i ] . prevout ] , <nl> tx , i , verify_flags , 0 ) , <nl> strTest ) ; <nl> BOOST_AUTO_TEST_CASE ( tx_invalid ) <nl> break ; <nl> } <nl> <nl> - unsigned int verify_flags = ParseFlags ( test [ 2 ] . get_str ( ) ) ; <nl> + unsigned int verify_flags = ParseScriptFlags ( test [ 2 ] . get_str ( ) ) ; <nl> fValid = VerifyScript ( tx . vin [ i ] . scriptSig , mapprevOutScriptPubKeys [ tx . vin [ i ] . prevout ] , <nl> tx , i , verify_flags , 0 ) ; <nl> } <nl>
Make script_ { valid , invalid } . json validation flags configurable
bitcoin/bitcoin
6022b5dc6ba930797db46e00426923b53d6594b3
2014-09-08T20:38:26Z
mmm a / cocos / scripting / lua - bindings / auto / api / BatchNode . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / BatchNode . lua <nl> <nl> - - @ return BatchNode # BatchNode ret ( return value : ccs . BatchNode ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm overload function : addChild ( cc . Node , int ) <nl> mmm <nl> mmm overload function : addChild ( cc . Node ) <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> - - <nl> - - overload function : addChild ( cc . Node , int , int ) <nl> - - <nl> mmm a / cocos / scripting / lua - bindings / auto / api / Layout . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Layout . lua <nl> <nl> - - @ return Ref # Ref ret ( return value : cc . Ref ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm overload function : addChild ( cc . Node , int ) <nl> mmm <nl> mmm overload function : addChild ( cc . Node ) <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> - - <nl> - - overload function : addChild ( cc . Node , int , int ) <nl> - - <nl> mmm a / cocos / scripting / lua - bindings / auto / api / ListView . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / ListView . lua <nl> <nl> - - @ return Ref # Ref ret ( return value : cc . Ref ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm overload function : addChild ( cc . Node , int ) <nl> mmm <nl> mmm overload function : addChild ( cc . Node ) <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> - - <nl> - - overload function : addChild ( cc . Node , int , int ) <nl> - - <nl> mmm a / cocos / scripting / lua - bindings / auto / api / Menu . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Menu . lua <nl> <nl> - - <nl> - - overload function : addChild ( cc . Node , int , int ) <nl> - - <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> - - @ function [ parent = # Menu ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> mmm @ param # int int <nl> + - - @ param # string str <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # Menu ] isOpacityModifyRGB <nl> mmm a / cocos / scripting / lua - bindings / auto / api / Node . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Node . lua <nl> <nl> - - <nl> - - overload function : addChild ( cc . Node , int , int ) <nl> - - <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> - - @ function [ parent = # Node ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> mmm @ param # int int <nl> + - - @ param # string str <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # Node ] removeComponent <nl> <nl> - - @ param # mat4_table mat4 <nl> - - @ param # unsigned int int <nl> <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + - - @ function [ parent = # Node ] removeChildByName <nl> + - - @ param self <nl> + - - @ param # string str <nl> + - - @ param # bool bool <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # Node ] getGLProgramState <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / api / ParallaxNode . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / ParallaxNode . lua <nl> <nl> - - @ return ParallaxNode # ParallaxNode ret ( return value : cc . ParallaxNode ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm @ function [ parent = # ParallaxNode ] addChild <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> + - - overload function : addChild ( cc . Node , int , int ) <nl> + - - <nl> + - - @ function [ parent = # ParallaxNode ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> - - @ param # int int <nl> - <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # ParallaxNode ] visit <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / api / ParticleBatchNode . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / ParticleBatchNode . lua <nl> <nl> - - @ return ParticleBatchNode # ParticleBatchNode ret ( return value : cc . ParticleBatchNode ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm @ function [ parent = # ParticleBatchNode ] addChild <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> + - - overload function : addChild ( cc . Node , int , int ) <nl> + - - <nl> + - - @ function [ parent = # ParticleBatchNode ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> - - @ param # int int <nl> - <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # ParticleBatchNode ] draw <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / api / Scene . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Scene . lua <nl> <nl> - - @ param # float float <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm @ function [ parent = # Scene ] addChild <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> + - - overload function : addChild ( cc . Node , int , int ) <nl> + - - <nl> + - - @ function [ parent = # Scene ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> - - @ param # int int <nl> - <nl> + <nl> return nil <nl> mmm a / cocos / scripting / lua - bindings / auto / api / ScrollView . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / ScrollView . lua <nl> <nl> - - @ return Ref # Ref ret ( return value : cc . Ref ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm overload function : addChild ( cc . Node , int ) <nl> mmm <nl> mmm overload function : addChild ( cc . Node ) <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> - - <nl> - - overload function : addChild ( cc . Node , int , int ) <nl> - - <nl> mmm a / cocos / scripting / lua - bindings / auto / api / Sprite . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / Sprite . lua <nl> <nl> - - @ param # unsigned int int <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm @ function [ parent = # Sprite ] addChild <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> + - - overload function : addChild ( cc . Node , int , int ) <nl> + - - <nl> + - - @ function [ parent = # Sprite ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> - - @ param # int int <nl> - <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # Sprite ] setScaleY <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / api / SpriteBatchNode . lua <nl> ppp b / cocos / scripting / lua - bindings / auto / api / SpriteBatchNode . lua <nl> <nl> - - @ return SpriteBatchNode # SpriteBatchNode ret ( return value : cc . SpriteBatchNode ) <nl> <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm @ function [ parent = # SpriteBatchNode ] addChild <nl> + - - overload function : addChild ( cc . Node , int , string ) <nl> + - - <nl> + - - overload function : addChild ( cc . Node , int , int ) <nl> + - - <nl> + - - @ function [ parent = # SpriteBatchNode ] addChild <nl> - - @ param self <nl> - - @ param # cc . Node node <nl> - - @ param # int int <nl> - - @ param # int int <nl> - <nl> + <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - - @ function [ parent = # SpriteBatchNode ] draw <nl> - - @ param self <nl> mmm a / cocos / scripting / lua - bindings / auto / lua_cocos2dx_auto . cpp <nl> ppp b / cocos / scripting / lua - bindings / auto / lua_cocos2dx_auto . cpp <nl> int lua_cocos2dx_Node_addChild ( lua_State * tolua_S ) <nl> } <nl> } while ( 0 ) ; <nl> ok = true ; <nl> + do { <nl> + if ( argc = = 3 ) { <nl> + cocos2d : : Node * arg0 ; <nl> + ok & = luaval_to_object < cocos2d : : Node > ( tolua_S , 2 , " cc . Node " , & arg0 ) ; <nl> + <nl> + if ( ! ok ) { break ; } <nl> + int arg1 ; <nl> + ok & = luaval_to_int32 ( tolua_S , 3 , ( int * ) & arg1 ) ; <nl> + <nl> + if ( ! ok ) { break ; } <nl> + std : : string arg2 ; <nl> + ok & = luaval_to_std_string ( tolua_S , 4 , & arg2 ) ; <nl> + <nl> + if ( ! ok ) { break ; } <nl> + cobj - > addChild ( arg0 , arg1 , arg2 ) ; <nl> + return 0 ; <nl> + } <nl> + } while ( 0 ) ; <nl> + ok = true ; <nl> CCLOG ( " % s has wrong number of arguments : % d , was expecting % d \ n " , " addChild " , argc , 3 ) ; <nl> return 0 ; <nl> <nl> int lua_cocos2dx_Node_visit ( lua_State * tolua_S ) <nl> <nl> return 0 ; <nl> } <nl> + int lua_cocos2dx_Node_removeChildByName ( lua_State * tolua_S ) <nl> + { <nl> + int argc = 0 ; <nl> + cocos2d : : Node * cobj = nullptr ; <nl> + bool ok = true ; <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + tolua_Error tolua_err ; <nl> + # endif <nl> + <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + if ( ! tolua_isusertype ( tolua_S , 1 , " cc . Node " , 0 , & tolua_err ) ) goto tolua_lerror ; <nl> + # endif <nl> + <nl> + cobj = ( cocos2d : : Node * ) tolua_tousertype ( tolua_S , 1 , 0 ) ; <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + if ( ! cobj ) <nl> + { <nl> + tolua_error ( tolua_S , " invalid ' cobj ' in function ' lua_cocos2dx_Node_removeChildByName ' " , nullptr ) ; <nl> + return 0 ; <nl> + } <nl> + # endif <nl> + <nl> + argc = lua_gettop ( tolua_S ) - 1 ; <nl> + if ( argc = = 1 ) <nl> + { <nl> + std : : string arg0 ; <nl> + <nl> + ok & = luaval_to_std_string ( tolua_S , 2 , & arg0 ) ; <nl> + if ( ! ok ) <nl> + return 0 ; <nl> + cobj - > removeChildByName ( arg0 ) ; <nl> + return 0 ; <nl> + } <nl> + if ( argc = = 2 ) <nl> + { <nl> + std : : string arg0 ; <nl> + bool arg1 ; <nl> + <nl> + ok & = luaval_to_std_string ( tolua_S , 2 , & arg0 ) ; <nl> + <nl> + ok & = luaval_to_boolean ( tolua_S , 3 , & arg1 ) ; <nl> + if ( ! ok ) <nl> + return 0 ; <nl> + cobj - > removeChildByName ( arg0 , arg1 ) ; <nl> + return 0 ; <nl> + } <nl> + CCLOG ( " % s has wrong number of arguments : % d , was expecting % d \ n " , " removeChildByName " , argc , 1 ) ; <nl> + return 0 ; <nl> + <nl> + # if COCOS2D_DEBUG > = 1 <nl> + tolua_lerror : <nl> + tolua_error ( tolua_S , " # ferror in function ' lua_cocos2dx_Node_removeChildByName ' . " , & tolua_err ) ; <nl> + # endif <nl> + <nl> + return 0 ; <nl> + } <nl> int lua_cocos2dx_Node_getGLProgramState ( lua_State * tolua_S ) <nl> { <nl> int argc = 0 ; <nl> int lua_register_cocos2dx_Node ( lua_State * tolua_S ) <nl> tolua_function ( tolua_S , " getRotation " , lua_cocos2dx_Node_getRotation ) ; <nl> tolua_function ( tolua_S , " getAnchorPointInPoints " , lua_cocos2dx_Node_getAnchorPointInPoints ) ; <nl> tolua_function ( tolua_S , " visit " , lua_cocos2dx_Node_visit ) ; <nl> + tolua_function ( tolua_S , " removeChildByName " , lua_cocos2dx_Node_removeChildByName ) ; <nl> tolua_function ( tolua_S , " getGLProgramState " , lua_cocos2dx_Node_getGLProgramState ) ; <nl> tolua_function ( tolua_S , " setScheduler " , lua_cocos2dx_Node_setScheduler ) ; <nl> tolua_function ( tolua_S , " stopAllActions " , lua_cocos2dx_Node_stopAllActions ) ; <nl> mmm a / cocos / scripting / lua - bindings / auto / lua_cocos2dx_auto . hpp <nl> ppp b / cocos / scripting / lua - bindings / auto / lua_cocos2dx_auto . hpp <nl> int register_all_cocos2dx ( lua_State * tolua_S ) ; <nl> <nl> <nl> <nl> + <nl> <nl> <nl> # endif / / __cocos2dx_h__ <nl>
[ AUTO ] : updating luabinding automatically
cocos2d/cocos2d-x
515f967f96af12674ee6642248d783360dbd1416
2014-06-25T06:17:41Z
mmm a / jvm - packages / xgboost4j - spark / src / main / scala / ml / dmlc / xgboost4j / scala / spark / XGBoost . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / main / scala / ml / dmlc / xgboost4j / scala / spark / XGBoost . scala <nl> package ml . dmlc . xgboost4j . scala . spark <nl> <nl> import scala . collection . mutable <nl> <nl> - import ml . dmlc . xgboost4j . java . { IRabitTracker , Rabit , XGBoostError , DMatrix = > JDMatrix , RabitTracker = > PyRabitTracker } <nl> + import ml . dmlc . xgboost4j . java . { IRabitTracker , Rabit , XGBoostError , RabitTracker = > PyRabitTracker } <nl> import ml . dmlc . xgboost4j . scala . rabit . RabitTracker <nl> import ml . dmlc . xgboost4j . scala . { XGBoost = > SXGBoost , _ } <nl> import org . apache . commons . logging . LogFactory <nl> object XGBoost extends Serializable { <nl> rabitEnv . put ( " DMLC_TASK_ID " , TaskContext . getPartitionId ( ) . toString ) <nl> Rabit . init ( rabitEnv ) <nl> val partitionItr = fromDenseToSparseLabeledPoints ( trainingSamples , missing ) <nl> - val trainingMatrix = new DMatrix ( new JDMatrix ( partitionItr , cacheFileName ) ) <nl> + val trainingMatrix = new DMatrix ( partitionItr , cacheFileName ) <nl> try { <nl> if ( params . contains ( " groupData " ) & & params ( " groupData " ) ! = null ) { <nl> trainingMatrix . setGroup ( params ( " groupData " ) . asInstanceOf [ Seq [ Seq [ Int ] ] ] ( <nl> object XGBoost extends Serializable { <nl> private def overrideParamsAccordingToTaskCPUs ( <nl> params : Map [ String , Any ] , <nl> sc : SparkContext ) : Map [ String , Any ] = { <nl> - val coresPerTask = sc . getConf . get ( " spark . task . cpus " , " 1 " ) . toInt <nl> + val coresPerTask = sc . getConf . getInt ( " spark . task . cpus " , 1 ) <nl> var overridedParams = params <nl> if ( overridedParams . contains ( " nthread " ) ) { <nl> val nThread = overridedParams ( " nthread " ) . toString . toInt <nl> mmm a / jvm - packages / xgboost4j - spark / src / main / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostModel . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / main / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostModel . scala <nl> package ml . dmlc . xgboost4j . scala . spark <nl> <nl> import scala . collection . JavaConverters . _ <nl> <nl> - import ml . dmlc . xgboost4j . java . { Rabit , DMatrix = > JDMatrix } <nl> + import ml . dmlc . xgboost4j . java . Rabit <nl> import ml . dmlc . xgboost4j . scala . spark . params . { BoosterParams , DefaultXGBoostParamsWriter } <nl> import ml . dmlc . xgboost4j . scala . { Booster , DMatrix , EvalTrait } <nl> import org . apache . hadoop . fs . { FSDataOutputStream , Path } <nl> abstract class XGBoostModel ( protected var _booster : Booster ) <nl> val rabitEnv = Map ( " DMLC_TASK_ID " - > TaskContext . getPartitionId ( ) . toString ) <nl> Rabit . init ( rabitEnv . asJava ) <nl> if ( testSamples . nonEmpty ) { <nl> - val dMatrix = new DMatrix ( new JDMatrix ( testSamples , null ) ) <nl> + val dMatrix = new DMatrix ( testSamples ) <nl> try { <nl> broadcastBooster . value . predictLeaf ( dMatrix ) . iterator <nl> } finally { <nl> abstract class XGBoostModel ( protected var _booster : Booster ) <nl> null <nl> } <nl> } <nl> - val dMatrix = new DMatrix ( new JDMatrix ( testSamples , cacheFileName ) ) <nl> + val dMatrix = new DMatrix ( testSamples , cacheFileName ) <nl> try { <nl> broadcastBooster . value . predict ( dMatrix ) . iterator <nl> } finally { <nl> new file mode 100644 <nl> index 0000000000 . . 192fba957f <nl> mmm / dev / null <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / PerTest . scala <nl> <nl> + / * <nl> + Copyright ( c ) 2014 by Contributors <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> + package ml . dmlc . xgboost4j . scala . spark <nl> + <nl> + import java . io . File <nl> + <nl> + import org . apache . spark . SparkContext <nl> + import org . apache . spark . sql . SparkSession <nl> + import org . scalatest . { BeforeAndAfterEach , FunSuite } <nl> + <nl> + trait PerTest extends BeforeAndAfterEach { self : FunSuite = > <nl> + protected val numWorkers : Int = Runtime . getRuntime . availableProcessors ( ) <nl> + <nl> + @ transient private var currentSession : SparkSession = _ <nl> + <nl> + def ss : SparkSession = getOrCreateSession <nl> + implicit def sc : SparkContext = ss . sparkContext <nl> + <nl> + protected def sparkSessionBuilder : SparkSession . Builder = SparkSession . builder ( ) <nl> + . master ( " local [ * ] " ) <nl> + . appName ( " XGBoostSuite " ) <nl> + . config ( " spark . ui . enabled " , false ) <nl> + . config ( " spark . driver . memory " , " 512m " ) <nl> + <nl> + override def beforeEach ( ) : Unit = getOrCreateSession <nl> + <nl> + override def afterEach ( ) { <nl> + synchronized { <nl> + if ( currentSession ! = null ) { <nl> + currentSession . stop ( ) <nl> + cleanExternalCache ( currentSession . sparkContext . appName ) <nl> + currentSession = null <nl> + } <nl> + } <nl> + } <nl> + <nl> + private def getOrCreateSession = synchronized { <nl> + if ( currentSession = = null ) { <nl> + currentSession = sparkSessionBuilder . getOrCreate ( ) <nl> + currentSession . sparkContext . setLogLevel ( " ERROR " ) <nl> + } <nl> + currentSession <nl> + } <nl> + <nl> + private def cleanExternalCache ( prefix : String ) : Unit = { <nl> + val dir = new File ( " . " ) <nl> + for ( file < - dir . listFiles ( ) if file . getName . startsWith ( prefix ) ) { <nl> + file . delete ( ) <nl> + } <nl> + } <nl> + } <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / RabitTrackerRobustnessSuite . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / RabitTrackerRobustnessSuite . scala <nl> import org . apache . spark . { SparkConf , SparkContext } <nl> import org . scalatest . FunSuite <nl> <nl> <nl> - class RabitTrackerRobustnessSuite extends FunSuite with Utils { <nl> + class RabitTrackerRobustnessSuite extends FunSuite with PerTest { <nl> test ( " test Java RabitTracker wrapper ' s exception handling : it should not hang forever . " ) { <nl> / * <nl> Deliberately create new instances of SparkContext in each unit test to avoid reusing the <nl> class RabitTrackerRobustnessSuite extends FunSuite with Utils { <nl> tests on a reentrant thread will crash the entire Spark application , an undesired side - effect <nl> that should be avoided . <nl> * / <nl> - val sparkConf = new SparkConf ( ) . setMaster ( " local [ * ] " ) <nl> - . setAppName ( " XGBoostSuite " ) . set ( " spark . driver . memory " , " 512m " ) <nl> - implicit val sparkContext = new SparkContext ( sparkConf ) <nl> - sparkContext . setLogLevel ( " ERROR " ) <nl> - <nl> - val rdd = sparkContext . parallelize ( 1 to numWorkers , numWorkers ) . cache ( ) <nl> + val rdd = sc . parallelize ( 1 to numWorkers , numWorkers ) . cache ( ) <nl> <nl> val tracker = new PyRabitTracker ( numWorkers ) <nl> tracker . start ( 0 ) <nl> class RabitTrackerRobustnessSuite extends FunSuite with Utils { <nl> sparkThread . setUncaughtExceptionHandler ( tracker ) <nl> sparkThread . start ( ) <nl> assert ( tracker . waitFor ( 0 ) ! = 0 ) <nl> - sparkContext . stop ( ) <nl> } <nl> <nl> test ( " test Scala RabitTracker ' s exception handling : it should not hang forever . " ) { <nl> - val sparkConf = new SparkConf ( ) . setMaster ( " local [ * ] " ) <nl> - . setAppName ( " XGBoostSuite " ) . set ( " spark . driver . memory " , " 512m " ) <nl> - implicit val sparkContext = new SparkContext ( sparkConf ) <nl> - sparkContext . setLogLevel ( " ERROR " ) <nl> - <nl> - val rdd = sparkContext . parallelize ( 1 to numWorkers , numWorkers ) . cache ( ) <nl> + val rdd = sc . parallelize ( 1 to numWorkers , numWorkers ) . cache ( ) <nl> <nl> val tracker = new ScalaRabitTracker ( numWorkers ) <nl> tracker . start ( 0 ) <nl> class RabitTrackerRobustnessSuite extends FunSuite with Utils { <nl> sparkThread . setUncaughtExceptionHandler ( tracker ) <nl> sparkThread . start ( ) <nl> assert ( tracker . waitFor ( 0L ) = = TrackerStatus . FAILURE . getStatusCode ) <nl> - sparkContext . stop ( ) <nl> } <nl> <nl> test ( " test Scala RabitTracker ' s workerConnectionTimeout " ) { <nl> - val sparkConf = new SparkConf ( ) . setMaster ( " local [ * ] " ) <nl> - . setAppName ( " XGBoostSuite " ) . set ( " spark . driver . memory " , " 512m " ) <nl> - implicit val sparkContext = new SparkContext ( sparkConf ) <nl> - sparkContext . setLogLevel ( " ERROR " ) <nl> - <nl> - val rdd = sparkContext . parallelize ( 1 to numWorkers , numWorkers ) . cache ( ) <nl> + val rdd = sc . parallelize ( 1 to numWorkers , numWorkers ) . cache ( ) <nl> <nl> val tracker = new ScalaRabitTracker ( numWorkers ) <nl> tracker . start ( 500 ) <nl> class RabitTrackerRobustnessSuite extends FunSuite with Utils { <nl> sparkThread . start ( ) <nl> / / should fail due to connection timeout <nl> assert ( tracker . waitFor ( 0L ) = = TrackerStatus . FAILURE . getStatusCode ) <nl> - sparkContext . stop ( ) <nl> } <nl> } <nl> deleted file mode 100644 <nl> index 5e46966e10 . . 0000000000 <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / SharedSparkContext . scala <nl> ppp / dev / null <nl> <nl> - / * <nl> - Copyright ( c ) 2014 by Contributors <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> - package ml . dmlc . xgboost4j . scala . spark <nl> - <nl> - import org . apache . spark . { SparkConf , SparkContext } <nl> - import org . scalatest . { BeforeAndAfter , BeforeAndAfterAll , FunSuite } <nl> - <nl> - trait SharedSparkContext extends FunSuite with BeforeAndAfter with BeforeAndAfterAll <nl> - with Serializable { <nl> - <nl> - @ transient protected implicit var sc : SparkContext = _ <nl> - <nl> - override def beforeAll ( ) { <nl> - val sparkConf = new SparkConf ( ) <nl> - . setMaster ( " local [ * ] " ) <nl> - . setAppName ( " XGBoostSuite " ) <nl> - . set ( " spark . driver . memory " , " 512m " ) <nl> - . set ( " spark . ui . enabled " , " false " ) <nl> - <nl> - sc = new SparkContext ( sparkConf ) <nl> - } <nl> - <nl> - override def afterAll ( ) { <nl> - if ( sc ! = null ) { <nl> - sc . stop ( ) <nl> - sc = null <nl> - } <nl> - } <nl> - } <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / TrainTestData . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / TrainTestData . scala <nl> object Classification extends TrainTestData { <nl> val test : Seq [ MLLabeledPoint ] = getLabeledPoints ( " / agaricus . txt . test " , zeroBased = false ) <nl> } <nl> <nl> + object MultiClassification extends TrainTestData { <nl> + val train : Seq [ MLLabeledPoint ] = getLabeledPoints ( " / dermatology . data " ) <nl> + <nl> + private def getLabeledPoints ( resource : String ) : Seq [ MLLabeledPoint ] = { <nl> + getResourceLines ( resource ) . map { line = > <nl> + val featuresAndLabel = line . split ( " , " ) <nl> + val label = featuresAndLabel . last . toDouble - 1 <nl> + val values = new Array [ Double ] ( featuresAndLabel . length - 1 ) <nl> + values ( values . length - 1 ) = <nl> + if ( featuresAndLabel ( featuresAndLabel . length - 2 ) = = " ? " ) 1 else 0 <nl> + for ( i < - 0 until values . length - 2 ) { <nl> + values ( i ) = featuresAndLabel ( i ) . toDouble <nl> + } <nl> + <nl> + MLLabeledPoint ( label , MLVectors . dense ( values . take ( values . length - 1 ) ) ) <nl> + } . toList <nl> + } <nl> + } <nl> + <nl> object Regression extends TrainTestData { <nl> val train : Seq [ MLLabeledPoint ] = getLabeledPoints ( " / machine . txt . train " , zeroBased = true ) <nl> val test : Seq [ MLLabeledPoint ] = getLabeledPoints ( " / machine . txt . test " , zeroBased = true ) <nl> deleted file mode 100644 <nl> index b9d5b0677a . . 0000000000 <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / Utils . scala <nl> ppp / dev / null <nl> <nl> - / * <nl> - Copyright ( c ) 2014 by Contributors <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> - package ml . dmlc . xgboost4j . scala . spark <nl> - <nl> - import java . io . File <nl> - <nl> - trait Utils extends Serializable { <nl> - protected val numWorkers : Int = Runtime . getRuntime . availableProcessors ( ) <nl> - <nl> - protected def cleanExternalCache ( prefix : String ) : Unit = { <nl> - val dir = new File ( " . " ) <nl> - for ( file < - dir . listFiles ( ) if file . getName . startsWith ( prefix ) ) { <nl> - file . delete ( ) <nl> - } <nl> - } <nl> - } <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostConfigureSuite . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostConfigureSuite . scala <nl> <nl> <nl> package ml . dmlc . xgboost4j . scala . spark <nl> <nl> - import ml . dmlc . xgboost4j . java . { DMatrix = > JDMatrix } <nl> import ml . dmlc . xgboost4j . scala . { Booster , DMatrix } <nl> - import org . apache . spark . { SparkConf , SparkContext } <nl> + <nl> + import org . apache . spark . sql . SparkSession <nl> import org . scalatest . FunSuite <nl> <nl> - class XGBoostConfigureSuite extends FunSuite with Utils { <nl> + class XGBoostConfigureSuite extends FunSuite with PerTest { <nl> + override def sparkSessionBuilder : SparkSession . Builder = super . sparkSessionBuilder <nl> + . config ( " spark . serializer " , " org . apache . spark . serializer . KryoSerializer " ) <nl> + . config ( " spark . kryo . classesToRegister " , classOf [ Booster ] . getName ) <nl> <nl> - test ( " nthread configuration must be equal to spark . task . cpus " ) { <nl> - val sparkConf = new SparkConf ( ) . setMaster ( " local [ * ] " ) . setAppName ( " XGBoostSuite " ) . <nl> - set ( " spark . task . cpus " , " 4 " ) <nl> - val customSparkContext = new SparkContext ( sparkConf ) <nl> - customSparkContext . setLogLevel ( " ERROR " ) <nl> - / / start another app <nl> - val trainingRDD = customSparkContext . parallelize ( Classification . train ) <nl> + test ( " nthread configuration must be no larger than spark . task . cpus " ) { <nl> + val trainingRDD = sc . parallelize ( Classification . train ) <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 2 " , " silent " - > " 1 " , <nl> - " objective " - > " binary : logistic " , " nthread " - > 6 ) <nl> + " objective " - > " binary : logistic " , <nl> + " nthread " - > ( sc . getConf . getInt ( " spark . task . cpus " , 1 ) + 1 ) ) <nl> intercept [ IllegalArgumentException ] { <nl> XGBoost . trainWithRDD ( trainingRDD , paramMap , 5 , numWorkers ) <nl> } <nl> - customSparkContext . stop ( ) <nl> } <nl> <nl> test ( " kryoSerializer test " ) { <nl> - val eval = new EvalError ( ) <nl> - val sparkConf = new SparkConf ( ) . setMaster ( " local [ * ] " ) . setAppName ( " XGBoostSuite " ) <nl> - . set ( " spark . serializer " , " org . apache . spark . serializer . KryoSerializer " ) <nl> - sparkConf . registerKryoClasses ( Array ( classOf [ Booster ] ) ) <nl> - val customSparkContext = new SparkContext ( sparkConf ) <nl> - customSparkContext . setLogLevel ( " ERROR " ) <nl> - val trainingRDD = customSparkContext . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + / / TODO write an isolated test for Booster . <nl> + val trainingRDD = sc . parallelize ( Classification . train ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator , null ) <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 2 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " ) <nl> val xgBoostModel = XGBoost . trainWithRDD ( trainingRDD , paramMap , 5 , numWorkers ) <nl> + val eval = new EvalError ( ) <nl> assert ( eval . eval ( xgBoostModel . booster . predict ( testSetDMatrix , outPutMargin = true ) , <nl> testSetDMatrix ) < 0 . 1 ) <nl> - customSparkContext . stop ( ) <nl> } <nl> } <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostDFSuite . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostDFSuite . scala <nl> <nl> <nl> package ml . dmlc . xgboost4j . scala . spark <nl> <nl> - import java . io . File <nl> - <nl> - import scala . collection . mutable <nl> - import scala . collection . mutable . ListBuffer <nl> - import scala . io . Source <nl> - import scala . util . Random <nl> - <nl> - import ml . dmlc . xgboost4j . java . { DMatrix = > JDMatrix } <nl> import ml . dmlc . xgboost4j . scala . { DMatrix , XGBoost = > ScalaXGBoost } <nl> <nl> - import org . apache . spark . SparkContext <nl> - import org . apache . spark . ml . Pipeline <nl> - import org . apache . spark . ml . evaluation . RegressionEvaluator <nl> - import org . apache . spark . ml . feature . { LabeledPoint , VectorAssembler } <nl> + import org . apache . spark . ml . feature . { LabeledPoint = > MLLabeledPoint } <nl> import org . apache . spark . ml . linalg . DenseVector <nl> import org . apache . spark . ml . param . ParamMap <nl> - import org . apache . spark . ml . tuning . { CrossValidator , ParamGridBuilder } <nl> import org . apache . spark . sql . _ <nl> - <nl> - class XGBoostDFSuite extends SharedSparkContext with Utils { <nl> - <nl> - private var trainingDF : DataFrame = null <nl> - <nl> - after { <nl> - cleanExternalCache ( " XGBoostDFSuite " ) <nl> - } <nl> - <nl> - private def buildTrainingDataframe ( sparkContext : Option [ SparkContext ] = None ) : DataFrame = { <nl> - if ( trainingDF = = null ) { <nl> - val labeledPointsRDD = sparkContext . getOrElse ( sc ) <nl> - . parallelize ( Classification . train , numWorkers ) <nl> - val sparkSession = SparkSession . builder ( ) . appName ( " XGBoostDFSuite " ) . getOrCreate ( ) <nl> - import sparkSession . implicits . _ <nl> - trainingDF = sparkSession . createDataset ( labeledPointsRDD ) . toDF <nl> - } <nl> - trainingDF <nl> + import org . scalatest . FunSuite <nl> + <nl> + class XGBoostDFSuite extends FunSuite with PerTest { <nl> + private def buildDataFrame ( <nl> + instances : Seq [ MLLabeledPoint ] , <nl> + numPartitions : Int = numWorkers ) : DataFrame = { <nl> + val it = instances . iterator . zipWithIndex <nl> + . map { case ( instance : MLLabeledPoint , id : Int ) = > <nl> + ( id , instance . label , instance . features ) <nl> + } <nl> + <nl> + ss . createDataFrame ( sc . parallelize ( it . toList , numPartitions ) ) <nl> + . toDF ( " id " , " label " , " features " ) <nl> } <nl> <nl> test ( " test consistency and order preservation of dataframe - based model " ) { <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " ) <nl> val trainingItr = Classification . train . iterator <nl> - val ( testItr , auxTestItr ) = Classification . test . iterator . duplicate <nl> + val testItr = Classification . test . iterator <nl> import DataUtils . _ <nl> val round = 5 <nl> - val trainDMatrix = new DMatrix ( new JDMatrix ( trainingItr , null ) ) <nl> - val testDMatrix = new DMatrix ( new JDMatrix ( testItr , null ) ) <nl> + val trainDMatrix = new DMatrix ( trainingItr ) <nl> + val testDMatrix = new DMatrix ( testItr ) <nl> val xgboostModel = ScalaXGBoost . train ( trainDMatrix , paramMap , round ) <nl> val predResultFromSeq = xgboostModel . predict ( testDMatrix ) <nl> - val testSetItr = auxTestItr . zipWithIndex . map { <nl> - case ( instance : LabeledPoint , id : Int ) = > ( id , instance . features , instance . label ) <nl> - } <nl> - val trainingDF = buildTrainingDataframe ( ) <nl> + val trainingDF = buildDataFrame ( Classification . train ) <nl> val xgBoostModelWithDF = XGBoost . trainWithDataFrame ( trainingDF , paramMap , <nl> round = round , nWorkers = numWorkers ) <nl> - val testDF = trainingDF . sparkSession . createDataFrame ( testSetItr . toList ) . toDF ( <nl> - " id " , " features " , " label " ) <nl> + val testDF = buildDataFrame ( Classification . test ) <nl> val predResultsFromDF = xgBoostModelWithDF . setExternalMemory ( true ) . transform ( testDF ) . <nl> collect ( ) . map ( row = > ( row . getAs [ Int ] ( " id " ) , row . getAs [ DenseVector ] ( " probabilities " ) ) ) . toMap <nl> assert ( testDF . count ( ) = = = predResultsFromDF . size ) <nl> class XGBoostDFSuite extends SharedSparkContext with Utils { <nl> test ( " test transformLeaf " ) { <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " ) <nl> - val testItr = Classification . test . iterator <nl> - val trainingDF = buildTrainingDataframe ( ) <nl> + val trainingDF = buildDataFrame ( Classification . train ) <nl> val xgBoostModelWithDF = XGBoost . trainWithDataFrame ( trainingDF , paramMap , <nl> round = 5 , nWorkers = numWorkers ) <nl> - val testSetItr = testItr . zipWithIndex . map { <nl> - case ( instance : LabeledPoint , id : Int ) = > <nl> - ( id , instance . features , instance . label ) <nl> - } <nl> - val testDF = trainingDF . sparkSession . createDataFrame ( testSetItr . toList ) . toDF ( <nl> - " id " , " features " , " label " ) <nl> + val testDF = buildDataFrame ( Classification . test ) <nl> xgBoostModelWithDF . transformLeaf ( testDF ) . show ( ) <nl> } <nl> <nl> test ( " test schema of XGBoostRegressionModel " ) { <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " reg : linear " ) <nl> - val testItr = Regression . test . iterator . zipWithIndex <nl> - . map { case ( instance : LabeledPoint , id : Int ) = > ( id , instance . features , instance . label ) } <nl> - val trainingDF = { <nl> - val labeledPointsRDD = sc . parallelize ( Regression . train , numWorkers ) <nl> - val sparkSession = SparkSession . builder ( ) . appName ( " XGBoostDFSuite " ) . getOrCreate ( ) <nl> - import sparkSession . implicits . _ <nl> - sparkSession . createDataset ( labeledPointsRDD ) . toDF <nl> - } <nl> + val trainingDF = buildDataFrame ( Regression . train ) <nl> val xgBoostModelWithDF = XGBoost . trainWithDataFrame ( trainingDF , paramMap , <nl> round = 5 , nWorkers = numWorkers , useExternalMemory = true ) <nl> xgBoostModelWithDF . setPredictionCol ( " final_prediction " ) <nl> - val testDF = trainingDF . sparkSession . createDataFrame ( testItr . toList ) . toDF ( <nl> - " id " , " features " , " label " ) <nl> + val testDF = buildDataFrame ( Regression . test ) <nl> val predictionDF = xgBoostModelWithDF . setExternalMemory ( true ) . transform ( testDF ) <nl> - assert ( predictionDF . columns . contains ( " id " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " features " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " label " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " final_prediction " ) = = = true ) <nl> + assert ( predictionDF . columns . contains ( " id " ) ) <nl> + assert ( predictionDF . columns . contains ( " features " ) ) <nl> + assert ( predictionDF . columns . contains ( " label " ) ) <nl> + assert ( predictionDF . columns . contains ( " final_prediction " ) ) <nl> predictionDF . show ( ) <nl> } <nl> <nl> test ( " test schema of XGBoostClassificationModel " ) { <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " ) <nl> - val testItr = Classification . test . iterator . <nl> - zipWithIndex . map { case ( instance : LabeledPoint , id : Int ) = > <nl> - ( id , instance . features , instance . label ) <nl> - } <nl> - val trainingDF = buildTrainingDataframe ( ) <nl> + val trainingDF = buildDataFrame ( Classification . train ) <nl> val xgBoostModelWithDF = XGBoost . trainWithDataFrame ( trainingDF , paramMap , <nl> round = 5 , nWorkers = numWorkers , useExternalMemory = true ) <nl> xgBoostModelWithDF . asInstanceOf [ XGBoostClassificationModel ] . setRawPredictionCol ( <nl> " raw_prediction " ) . setPredictionCol ( " final_prediction " ) <nl> - val testDF = trainingDF . sparkSession . createDataFrame ( testItr . toList ) . toDF ( <nl> - " id " , " features " , " label " ) <nl> + val testDF = buildDataFrame ( Classification . test ) <nl> var predictionDF = xgBoostModelWithDF . setExternalMemory ( true ) . transform ( testDF ) <nl> - assert ( predictionDF . columns . contains ( " id " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " features " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " label " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " raw_prediction " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " final_prediction " ) = = = true ) <nl> + assert ( predictionDF . columns . contains ( " id " ) ) <nl> + assert ( predictionDF . columns . contains ( " features " ) ) <nl> + assert ( predictionDF . columns . contains ( " label " ) ) <nl> + assert ( predictionDF . columns . contains ( " raw_prediction " ) ) <nl> + assert ( predictionDF . columns . contains ( " final_prediction " ) ) <nl> xgBoostModelWithDF . asInstanceOf [ XGBoostClassificationModel ] . setRawPredictionCol ( " " ) . <nl> setPredictionCol ( " final_prediction " ) <nl> predictionDF = xgBoostModelWithDF . transform ( testDF ) <nl> - assert ( predictionDF . columns . contains ( " id " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " features " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " label " ) = = = true ) <nl> + assert ( predictionDF . columns . contains ( " id " ) ) <nl> + assert ( predictionDF . columns . contains ( " features " ) ) <nl> + assert ( predictionDF . columns . contains ( " label " ) ) <nl> assert ( predictionDF . columns . contains ( " raw_prediction " ) = = = false ) <nl> - assert ( predictionDF . columns . contains ( " final_prediction " ) = = = true ) <nl> + assert ( predictionDF . columns . contains ( " final_prediction " ) ) <nl> xgBoostModelWithDF . asInstanceOf [ XGBoostClassificationModel ] . <nl> setRawPredictionCol ( " raw_prediction " ) . setPredictionCol ( " " ) <nl> predictionDF = xgBoostModelWithDF . transform ( testDF ) <nl> - assert ( predictionDF . columns . contains ( " id " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " features " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " label " ) = = = true ) <nl> - assert ( predictionDF . columns . contains ( " raw_prediction " ) = = = true ) <nl> + assert ( predictionDF . columns . contains ( " id " ) ) <nl> + assert ( predictionDF . columns . contains ( " features " ) ) <nl> + assert ( predictionDF . columns . contains ( " label " ) ) <nl> + assert ( predictionDF . columns . contains ( " raw_prediction " ) ) <nl> assert ( predictionDF . columns . contains ( " final_prediction " ) = = = false ) <nl> } <nl> <nl> class XGBoostDFSuite extends SharedSparkContext with Utils { <nl> " grow_policy " - > " depthwise " , " max_depth " - > " 2 " , " max_bin " - > " 2 " , <nl> " eval_metric " - > " error " ) <nl> val testItr = Classification . test . iterator <nl> - val trainingDF = buildTrainingDataframe ( ) <nl> + val trainingDF = buildDataFrame ( Classification . train ) <nl> val xgBoostModelWithDF = XGBoost . trainWithDataFrame ( trainingDF , paramMap , <nl> round = 10 , nWorkers = math . min ( 2 , numWorkers ) ) <nl> val error = new EvalError <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( testItr , null ) ) <nl> + val testSetDMatrix = new DMatrix ( testItr ) <nl> assert ( error . eval ( xgBoostModelWithDF . booster . predict ( testSetDMatrix , outPutMargin = true ) , <nl> testSetDMatrix ) < 0 . 1 ) <nl> } <nl> <nl> - private def convertCSVPointToLabelPoint ( valueArray : Array [ String ] ) : LabeledPoint = { <nl> - val intValueArray = new Array [ Double ] ( valueArray . length ) <nl> - intValueArray ( valueArray . length - 2 ) = { <nl> - if ( valueArray ( valueArray . length - 2 ) = = " ? " ) { <nl> - 1 <nl> - } else { <nl> - 0 <nl> - } <nl> - } <nl> - intValueArray ( valueArray . length - 1 ) = valueArray ( valueArray . length - 1 ) . toDouble - 1 <nl> - for ( i < - 0 until intValueArray . length - 2 ) { <nl> - intValueArray ( i ) = valueArray ( i ) . toDouble <nl> - } <nl> - LabeledPoint ( intValueArray . last , new DenseVector ( intValueArray . take ( intValueArray . length - 1 ) ) ) <nl> - } <nl> - <nl> - private def loadCSVPoints ( filePath : String , zeroBased : Boolean = false ) : Seq [ LabeledPoint ] = { <nl> - val file = Source . fromFile ( new File ( filePath ) ) <nl> - val sampleList = new ListBuffer [ LabeledPoint ] <nl> - for ( sample < - file . getLines ( ) ) { <nl> - sampleList + = convertCSVPointToLabelPoint ( sample . split ( " , " ) ) <nl> - } <nl> - sampleList <nl> - } <nl> - <nl> test ( " multi_class classification test " ) { <nl> val paramMap = Map ( " eta " - > " 0 . 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " multi : softmax " , " num_class " - > " 6 " ) <nl> - val trainingSet = loadCSVPoints ( getClass . getResource ( " / dermatology . data " ) . getFile ) <nl> - val spark = SparkSession . builder ( ) . getOrCreate ( ) <nl> - import spark . implicits . _ <nl> - XGBoost . trainWithDataFrame ( trainingSet . toDF ( ) , paramMap , round = 5 , nWorkers = numWorkers ) <nl> + val trainingDF = buildDataFrame ( MultiClassification . train ) <nl> + XGBoost . trainWithDataFrame ( trainingDF . toDF ( ) , paramMap , round = 5 , nWorkers = numWorkers ) <nl> } <nl> <nl> test ( " test DF use nested groupData " ) { <nl> - val testItr = Ranking . test . iterator . zipWithIndex <nl> - . map { case ( instance : LabeledPoint , id : Int ) = > ( id , instance . features , instance . label ) } <nl> - val trainingDF = { <nl> - val labeledPointsRDD0 = sc . parallelize ( Ranking . train0 , numSlices = 1 ) <nl> - val labeledPointsRDD1 = sc . parallelize ( Ranking . train1 , numSlices = 1 ) <nl> - val labeledPointsRDD = labeledPointsRDD0 . union ( labeledPointsRDD1 ) <nl> - val sparkSession = SparkSession . builder ( ) . appName ( " XGBoostDFSuite " ) . getOrCreate ( ) <nl> - import sparkSession . implicits . _ <nl> - sparkSession . createDataset ( labeledPointsRDD ) . toDF <nl> - } <nl> + val trainingDF = buildDataFrame ( Ranking . train0 , 1 ) <nl> + . union ( buildDataFrame ( Ranking . train1 , 1 ) ) <nl> val trainGroupData : Seq [ Seq [ Int ] ] = Seq ( Ranking . trainGroup0 , Ranking . trainGroup1 ) <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " rank : pairwise " , " groupData " - > trainGroupData ) <nl> <nl> val xgBoostModelWithDF = XGBoost . trainWithDataFrame ( trainingDF , paramMap , <nl> round = 5 , nWorkers = 2 ) <nl> - val testDF = trainingDF . sparkSession . createDataFrame ( testItr . toList ) . toDF ( <nl> - " id " , " features " , " label " ) <nl> + val testDF = buildDataFrame ( Ranking . test ) <nl> val predResultsFromDF = xgBoostModelWithDF . setExternalMemory ( true ) . transform ( testDF ) . <nl> collect ( ) . map ( row = > ( row . getAs [ Int ] ( " id " ) , row . getAs [ DenseVector ] ( " features " ) ) ) . toMap <nl> assert ( testDF . count ( ) = = = predResultsFromDF . size ) <nl> class XGBoostDFSuite extends SharedSparkContext with Utils { <nl> test ( " params of estimator and produced model are coordinated correctly " ) { <nl> val paramMap = Map ( " eta " - > " 0 . 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " multi : softmax " , " num_class " - > " 6 " ) <nl> - val trainingSet = loadCSVPoints ( getClass . getResource ( " / dermatology . data " ) . getFile ) <nl> - val spark = SparkSession . builder ( ) . getOrCreate ( ) <nl> - import spark . implicits . _ <nl> - val model = <nl> - XGBoost . trainWithDataFrame ( trainingSet . toDF ( ) , paramMap , round = 5 , nWorkers = numWorkers ) <nl> + val trainingDF = buildDataFrame ( MultiClassification . train ) <nl> + val model = XGBoost . trainWithDataFrame ( trainingDF , paramMap , round = 5 , nWorkers = numWorkers ) <nl> assert ( model . get [ Double ] ( model . eta ) . get = = 0 . 1 ) <nl> assert ( model . get [ Int ] ( model . maxDepth ) . get = = 6 ) <nl> } <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostGeneralSuite . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostGeneralSuite . scala <nl> import java . util . concurrent . LinkedBlockingDeque <nl> import scala . collection . mutable . ListBuffer <nl> import scala . util . Random <nl> <nl> - import ml . dmlc . xgboost4j . java . { Rabit , DMatrix = > JDMatrix } <nl> + import ml . dmlc . xgboost4j . java . Rabit <nl> import ml . dmlc . xgboost4j . scala . DMatrix <nl> import ml . dmlc . xgboost4j . scala . rabit . RabitTracker <nl> <nl> import org . apache . spark . SparkContext <nl> import org . apache . spark . ml . feature . LabeledPoint <nl> import org . apache . spark . ml . linalg . { Vectors , Vector = > SparkVector } <nl> import org . apache . spark . rdd . RDD <nl> + import org . scalatest . FunSuite <nl> <nl> - class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> + class XGBoostGeneralSuite extends FunSuite with PerTest { <nl> test ( " test Rabit allreduce to validate Scala - implemented Rabit tracker " ) { <nl> val vectorLength = 100 <nl> val rdd = sc . parallelize ( <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> missing = Float . NaN , baseMargin = null ) <nl> val boosterCount = boosterRDD . count ( ) <nl> assert ( boosterCount = = = 2 ) <nl> - cleanExternalCache ( " XGBoostSuite " ) <nl> } <nl> <nl> test ( " training with external memory cache " ) { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = List ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " ) . toMap <nl> val xgBoostModel = XGBoost . trainWithRDD ( trainingRDD , paramMap , round = 5 , <nl> nWorkers = numWorkers , useExternalMemory = true ) <nl> assert ( eval . eval ( xgBoostModel . booster . predict ( testSetDMatrix , outPutMargin = true ) , <nl> testSetDMatrix ) < 0 . 1 ) <nl> - / / clean <nl> - cleanExternalCache ( " XGBoostSuite " ) <nl> } <nl> <nl> test ( " training with Scala - implemented Rabit tracker " ) { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = List ( " eta " - > " 1 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " , <nl> " tracker_conf " - > TrackerConf ( 60 * 60 * 1000 , " scala " ) ) . toMap <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = Map ( " eta " - > " 1 " , " gamma " - > " 0 . 5 " , " max_depth " - > " 6 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " , " tree_method " - > " hist " , <nl> " grow_policy " - > " depthwise " , " eval_metric " - > " error " ) <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = Map ( " eta " - > " 1 " , " gamma " - > " 0 . 5 " , " max_depth " - > " 0 " , " silent " - > " 1 " , <nl> " objective " - > " binary : logistic " , " tree_method " - > " hist " , <nl> " grow_policy " - > " lossguide " , " max_leaves " - > " 8 " , " eval_metric " - > " error " ) <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = Map ( " eta " - > " 1 " , " gamma " - > " 0 . 5 " , " max_depth " - > " 0 " , " silent " - > " 0 " , <nl> " objective " - > " binary : logistic " , " tree_method " - > " hist " , <nl> " grow_policy " - > " lossguide " , " max_leaves " - > " 8 " , " max_bin " - > " 16 " , <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = Map ( " eta " - > " 1 " , " gamma " - > " 0 . 5 " , " max_depth " - > " 0 " , " silent " - > " 0 " , <nl> " objective " - > " binary : logistic " , " tree_method " - > " hist " , <nl> " grow_policy " - > " depthwise " , " max_leaves " - > " 8 " , " max_depth " - > " 2 " , <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val paramMap = Map ( " eta " - > " 1 " , " gamma " - > " 0 . 5 " , " max_depth " - > " 0 " , " silent " - > " 0 " , <nl> " objective " - > " binary : logistic " , " tree_method " - > " hist " , <nl> " grow_policy " - > " depthwise " , " max_depth " - > " 2 " , " max_bin " - > " 2 " , <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> <nl> test ( " test with dense vectors containing missing value " ) { <nl> def buildDenseRDD ( ) : RDD [ LabeledPoint ] = { <nl> - val nrow = 100 <nl> - val ncol = 5 <nl> - val data0 = Array . ofDim [ Double ] ( nrow , ncol ) <nl> - / / put random nums <nl> - for ( r < - 0 until nrow ; c < - 0 until ncol ) { <nl> - data0 ( r ) ( c ) = { <nl> - if ( c = = ncol - 1 ) { <nl> - - 0 . 1 <nl> - } else { <nl> - Random . nextDouble ( ) <nl> - } <nl> + val numRows = 100 <nl> + val numCols = 5 <nl> + <nl> + val labeledPoints = ( 0 until numRows ) . map { _ = > <nl> + val label = Random . nextDouble ( ) <nl> + val values = Array . tabulate [ Double ] ( numCols ) { c = > <nl> + if ( c = = numCols - 1 ) - 0 . 1 else Random . nextDouble ( ) <nl> } <nl> + <nl> + LabeledPoint ( label , Vectors . dense ( values ) ) <nl> } <nl> - / / create label <nl> - val label0 = new Array [ Double ] ( nrow ) <nl> - for ( i < - label0 . indices ) { <nl> - label0 ( i ) = Random . nextDouble ( ) <nl> - } <nl> - val points = new ListBuffer [ LabeledPoint ] <nl> - for ( r < - 0 until nrow ) { <nl> - points + = LabeledPoint ( label0 ( r ) , Vectors . dense ( data0 ( r ) ) ) <nl> - } <nl> - sc . parallelize ( points ) <nl> + <nl> + sc . parallelize ( labeledPoints ) <nl> } <nl> <nl> val trainingRDD = buildDenseRDD ( ) . repartition ( 4 ) <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val xgBoostModel = XGBoost . trainWithRDD ( trainingRDD , paramMap , 5 , numWorkers , <nl> useExternalMemory = true ) <nl> xgBoostModel . predict ( testRDD . map ( _ . features . toDense ) , missingValue = - 0 . 1f ) . collect ( ) <nl> - / / clean <nl> - cleanExternalCache ( " XGBoostSuite " ) <nl> } <nl> <nl> test ( " test consistency of prediction functions with RDD " ) { <nl> class XGBoostGeneralSuite extends SharedSparkContext with Utils { <nl> val eval = new EvalError ( ) <nl> val trainingRDD = sc . parallelize ( Classification . train ) <nl> import DataUtils . _ <nl> - val testSetDMatrix = new DMatrix ( new JDMatrix ( Classification . test . iterator , null ) ) <nl> + val testSetDMatrix = new DMatrix ( Classification . test . iterator ) <nl> val tempDir = Files . createTempDirectory ( " xgboosttest - " ) <nl> val tempFile = Files . createTempFile ( tempDir , " " , " " ) <nl> val paramMap = Map ( " eta " - > " 1 " , " max_depth " - > " 2 " , " silent " - > " 1 " , <nl> mmm a / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostSparkPipelinePersistence . scala <nl> ppp b / jvm - packages / xgboost4j - spark / src / test / scala / ml / dmlc / xgboost4j / scala / spark / XGBoostSparkPipelinePersistence . scala <nl> import org . apache . spark . SparkConf <nl> import org . apache . spark . ml . feature . _ <nl> import org . apache . spark . ml . { Pipeline , PipelineModel } <nl> import org . apache . spark . sql . SparkSession <nl> + import org . scalatest . { BeforeAndAfterAll , FunSuite } <nl> <nl> - class XGBoostSparkPipelinePersistence extends SharedSparkContext with Utils { <nl> + class XGBoostSparkPipelinePersistence extends FunSuite with PerTest <nl> + with BeforeAndAfterAll { <nl> <nl> override def afterAll ( ) : Unit = { <nl> - super . afterAll ( ) <nl> delete ( new File ( " . / testxgbPipe " ) ) <nl> delete ( new File ( " . / testxgbEst " ) ) <nl> delete ( new File ( " . / testxgbModel " ) ) <nl>
[ jvm - packages ] More brooming in tests ( )
dmlc/xgboost
4eb255262fd8a7172815656c9eb3c148aa0d1e68
2017-07-18T20:08:48Z
mmm a / demo / guide - python / basic_walkthrough . py <nl> ppp b / demo / guide - python / basic_walkthrough . py <nl> <nl> # ! / usr / bin / python <nl> import numpy as np <nl> import scipy . sparse <nl> + import pickle <nl> import xgboost as xgb <nl> + import copy <nl> <nl> # # # simple example <nl> # load file from text file , also binary buffer generated by xgboost <nl> <nl> # this is prediction <nl> preds = bst . predict ( dtest ) <nl> labels = dtest . get_label ( ) <nl> - print ( ' error = % f ' % ( sum ( 1 for i in range ( len ( preds ) ) if int ( preds [ i ] > 0 . 5 ) ! = labels [ i ] ) / float ( len ( preds ) ) ) ) <nl> + print ( ' error = % f ' % ( sum ( 1 for i in range ( len ( preds ) ) if int ( preds [ i ] > 0 . 5 ) ! = labels [ i ] ) / float ( len ( preds ) ) ) ) <nl> bst . save_model ( ' 0001 . model ' ) <nl> # dump model <nl> bst . dump_model ( ' dump . raw . txt ' ) <nl> <nl> <nl> # save dmatrix into binary buffer <nl> dtest . save_binary ( ' dtest . buffer ' ) <nl> + # save model <nl> bst . save_model ( ' xgb . model ' ) <nl> # load model and data in <nl> bst2 = xgb . Booster ( model_file = ' xgb . model ' ) <nl> <nl> # assert they are the same <nl> assert np . sum ( np . abs ( preds2 - preds ) ) = = 0 <nl> <nl> + # alternatively , you can pickle the booster <nl> + pks = pickle . dumps ( bst2 ) <nl> + # load model and data in <nl> + bst3 = pickle . loads ( pks ) <nl> + preds3 = bst2 . predict ( dtest2 ) <nl> + # assert they are the same <nl> + assert np . sum ( np . abs ( preds3 - preds ) ) = = 0 <nl> + <nl> # # # <nl> # build dmatrix from scipy . sparse <nl> print ( ' start running example of build DMatrix from scipy . sparse CSR Matrix ' ) <nl> <nl> i = 0 <nl> for l in open ( ' . . / data / agaricus . txt . train ' ) : <nl> arr = l . split ( ) <nl> - labels . append ( int ( arr [ 0 ] ) ) <nl> + labels . append ( int ( arr [ 0 ] ) ) <nl> for it in arr [ 1 : ] : <nl> k , v = it . split ( ' : ' ) <nl> row . append ( i ) ; col . append ( int ( k ) ) ; dat . append ( float ( v ) ) <nl> i + = 1 <nl> - csr = scipy . sparse . csr_matrix ( ( dat , ( row , col ) ) ) <nl> - dtrain = xgb . DMatrix ( csr , label = labels ) <nl> + csr = scipy . sparse . csr_matrix ( ( dat , ( row , col ) ) ) <nl> + dtrain = xgb . DMatrix ( csr , label = labels ) <nl> watchlist = [ ( dtest , ' eval ' ) , ( dtrain , ' train ' ) ] <nl> - bst = xgb . train ( param , dtrain , num_round , watchlist ) <nl> + bst = xgb . train ( param , dtrain , num_round , watchlist ) <nl> <nl> print ( ' start running example of build DMatrix from scipy . sparse CSC Matrix ' ) <nl> # we can also construct from csc matrix <nl> - csc = scipy . sparse . csc_matrix ( ( dat , ( row , col ) ) ) <nl> + csc = scipy . sparse . csc_matrix ( ( dat , ( row , col ) ) ) <nl> dtrain = xgb . DMatrix ( csc , label = labels ) <nl> watchlist = [ ( dtest , ' eval ' ) , ( dtrain , ' train ' ) ] <nl> - bst = xgb . train ( param , dtrain , num_round , watchlist ) <nl> + bst = xgb . train ( param , dtrain , num_round , watchlist ) <nl> <nl> print ( ' start running example of build DMatrix from numpy array ' ) <nl> # NOTE : npymat is numpy array , we will convert it into scipy . sparse . csr_matrix in internal implementation <nl> <nl> npymat = csr . todense ( ) <nl> dtrain = xgb . DMatrix ( npymat , label = labels ) <nl> watchlist = [ ( dtest , ' eval ' ) , ( dtrain , ' train ' ) ] <nl> - bst = xgb . train ( param , dtrain , num_round , watchlist ) <nl> + bst = xgb . train ( param , dtrain , num_round , watchlist ) <nl> <nl> <nl>
allow booster to be pickable , add copy function
dmlc/xgboost
e6b8b23a2c84d38fbef753aea11e8a2d3b6d7260
2015-05-16T19:59:55Z
mmm a / site / source / docs / api_reference / Filesystem - API . rst <nl> ppp b / site / source / docs / api_reference / Filesystem - API . rst <nl> File system API <nl> <nl> . . js : function : : FS . createPreloadedFile ( parent , name , url , canRead , canWrite ) <nl> <nl> - Preloads a file asynchronously . You should call this in ` ` preRun ` ` , ` ` run ( ) ` ` will be delayed until all preloaded files are ready . This is how ` ` - - preload - file ` ` works in * emcc * . <nl> + Preloads a file asynchronously . You should call this in ` ` preRun ` ` , ` ` run ( ) ` ` will be delayed until all preloaded files are ready . This is how the : ref : ` preload - file < emcc - preload - file > ` option works in * emcc * . <nl> <nl> - : param parent : The parent folder , either as a path ( e . g . ` ' / usr / lib ' ` ) or an object previously returned from a ` FS . createFolder ( ) ` or ` FS . createPath ( ) ` call . <nl> + : param parent : The parent folder , either as a path ( e . g . * * ' / usr / lib ' * * ) or an object previously returned from a ` FS . createFolder ( ) ` or ` FS . createPath ( ) ` call . <nl> : type parent : string / object <nl> : param string name : The name of the new file . <nl> : param string url : In the browser , this is the URL whose contents will be returned when the file is accessed . In a command line engine , this will be the local ( real ) file system path the contents will be loaded from . Note that writes to this file are virtual . <nl> mmm a / site / source / docs / porting / emscripten - runtime - environment . rst <nl> ppp b / site / source / docs / porting / emscripten - runtime - environment . rst <nl> <nl> . . _emscripten - runtime - environment : <nl> <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Emscripten Runtime Environment ( wiki - import ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + Emscripten Runtime Environment <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - The browser environment is different than the environment a normal C / C + + application expects . The main differences are how input and output work , and the fact that the main loop must be asynchronous . <nl> + The Emscripten runtime environment is different to that expected by most C / C + + applications . Emscripten works hard to abstract and mitigate these differences , so that in general code can be compiled with little or no change . <nl> <nl> - For input and output , if you use : term : ` SDL ` etc . then everything should basically be taken care of for you . Emscripten implements the familiar SDL API for the browser environment . Typically you should need to refactor nothing or a very small amount of code for this . <nl> + This article expands on some of the differences and the resulting : ref : ` api - limitations ` , and outlines the few changes you may need to make to your C / C + + code . <nl> <nl> - The main loop being asynchronous , however , is trickier . <nl> + Input / output <nl> + = = = = = = = = = = = = <nl> + <nl> + Emscripten implements the Simple DirectMedia Layer API ( : term : ` SDL ` ) for the browser environment , which provides low level access to audio , keyboard , mouse , joystick , and graphics hardware . Applications that use * SDL * typically require no input / output changes to run in the browser . <nl> + <nl> + In addition , we have more limited support for * glut * , * glfw * , * glew * and * xlib * . <nl> + <nl> + Applications that do not use * SDL * or the other APIs can use the Emscripten - specific APIs for input and output : <nl> + <nl> + - : ref : ` html5 - h ` , which defines the Emscripten low - level glue bindings to interact with HTML5 events from native code , including access to keys , mouse , wheel , device orientation , battery levels , vibration , etc . <nl> + - : ref : ` multimedia - and - graphics - index ` APIs , including : ref : ` OpenGL < OpenGL - support > ` and : ref : ` EGL < EGL - Support - in - Emscripten > ` . <nl> + <nl> + <nl> + File Systems <nl> + = = = = = = = = = = = = <nl> + <nl> + A lot of C / C + + code uses the synchronous file system APIs in * libc * and * libcxx * to access code in the local file system . This is problematic because the browser prevents code from directly accessing files on the host system , and because JavaScript only supports asynchronous file access outside of web workers . <nl> + <nl> + Emscripten provides an implementation of * libc * and * libcxx * and a * virtual file system * so that normal C / C + + code can be compiled and run without change . Most developers need only specify the set of files to be : ref : ` packaged < packaging - files > ` for preloading into the virtual file system at runtime . <nl> + <nl> + . . note : : Using a virtual file system bypasses the limitations listed above . The file data is packaged at compile time and downloaded into the file system using * asynchronous * JavaScript APIs before the compiled code is allowed to run . The compiled code then makes " file " calls that are really just calls into program memory . <nl> + <nl> + The default file system ( : ref : ` MEMFS < filesystem - api - memfs > ` ) stores files in - memory , so that any changes are lost when the page is reloaded . If file changes need to be stored more permanently then developers can mount the : ref : ` IDBFS < filesystem - api - idbfs > ` file system , which allows data to be persisted in the browser . When running code in * node . js * , developers can mount : ref : ` NODEFS < filesystem - api - nodefs > ` to give code direct access to the local file system . <nl> + <nl> + Emscripten also has an API to support : ref : ` asynchronous file access < emscripten - h - asynchronous - file - system - api > ` . <nl> + <nl> + For more information and examples see : ref : ` packaging - code - index ` . <nl> + <nl> + <nl> + . . _emscripten - runtime - environment - main - loop : <nl> <nl> Browser main loop <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + = = = = = = = = = = = = = = = = = <nl> + <nl> + The browser event model uses co - operative multitasking — each event has a “ turn ” to run , and must then return control to the browser so that other events can be processed . A common cause of HTML pages hanging is JavaScript that does not complete and return control to the browser . <nl> <nl> - Graphical C + + apps typically have a main loop that is an infinite loop , in which event handling is done , processing and rendering , then a wait ( ` ` SDL_Delay ` ` , for example ) to keep the frame rate right . However , in JavaScript there is no way for something like SDL_Delay to actually return control to the browser event loop , and returning control is important because the browser event model is asynchronous — your JavaScript must finish its " turn " , by completing execution and returning control to the browser itself . The browser will then asynchronously call your JavaScript later according to how you asked it to do that . <nl> + Graphical C + + apps typically run in an infinite loop . Within each iteration of the loop the app performs event handling , processing and rendering , followed by a delay ( " wait " ) to keep the frame rate constant . This infinite loop is a problem in the browser environment because there is no way for control to return to the browser so other code can run . After a period the browser will notify the user that the page is stuck and offer to halt or close it . <nl> <nl> - This is inherent in how browsers work . If you do not finish your turn , the page will ' hang ' and the browser will eventually tell the user the page is stuck and offer to halt it or close it . Also , that things like WebGL will only actually render when your JavaScript " turn " is over - so while a normal C + + GL app would swap buffers manually , in JavaScript you just finish your turn and the browser renders and swaps . <nl> + Similarly , JavaScript APIs like WebGL can only run when the current " turn " is over , and will automatically render and swap buffers at that point . This contrasts with OpenGL C + + apps where you would need to swap the buffers manually . <nl> + <nl> + . . _emscripten - runtime - environment - howto - main - loop : <nl> <nl> Implementing an asynchronous main loop in C / C + + <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + The standard solution for this problem is to define a C function that performs one iteration of your main loop ( not including the " delay " ) . For a native build this function can be called in an infinite loop , leaving the behaviour effectively unchanged . <nl> + <nl> + Within Emscripten compiled code we use : c : func : ` emscripten_set_main_loop ` to get the environment to call this same function at a specified frequency . The iteration is still run " infinitely " but now other code can run between iterations and the browser does not hang . <nl> + <nl> + . . todo : : Check this statement out : ( just call it from JavaScript , all you need is an underscore at the beginning of the name ) , <nl> + <nl> + Typically you will have a small section with ` ` # ifdef EMSCRIPTEN ` ` for the two cases . For example : <nl> <nl> - The standard way to do this is make a C function that runs one iteration of your main loop . Then call it from JavaScript at the proper frequency . This is very simple to do manually ( just call it from JavaScript , all you need is an underscore at the beginning of the name ) , but you can also use : c : func : ` emscripten_set_main_loop ` for something a little more convenient . For a regular native build , you can just call that function in an infinite loop ( likely with ` ` SDL_Delay ` ` etc . ) , so typically you will have a small section with ` ` # ifdef EMSCRIPTEN ` ` for the two cases , for example : <nl> + . . code - block : : cpp <nl> <nl> - : : <nl> + int main ( ) { <nl> + . . . <nl> + # ifdef EMSCRIPTEN <nl> + / / void emscripten_set_main_loop ( em_callback_func func , int fps , int simulate_infinite_loop ) ; <nl> + emscripten_set_main_loop ( one_iter , 60 , 1 ) ; <nl> + # else <nl> + while ( 1 ) { <nl> + one_iter ( ) ; <nl> + / / Delay to keep frame rate constant ( using SDL ) <nl> + SDL_Delay ( time_to_next_frame ( ) ) ; <nl> + } <nl> + # endif <nl> + } <nl> <nl> - int main ( ) { <nl> - . . . <nl> - # ifdef EMSCRIPTEN <nl> - / / void emscripten_set_main_loop ( void ( * func ) ( ) , int fps , int simulate_infinite_loop ) ; <nl> - emscripten_set_main_loop ( one_iter , 60 , 1 ) ; <nl> - # else <nl> - while ( 1 ) { <nl> - one_iter ( ) ; <nl> - SDL_Delay ( time_to_next_frame ( ) ) ; <nl> - } <nl> - # endif <nl> - } <nl> + / / The " main loop " function . <nl> + void one_iter ( ) { <nl> + / / process input <nl> + / / render to screen <nl> + } <nl> <nl> - void one_iter ( ) { <nl> - / / process input <nl> - / / render to screen <nl> - } <nl> + <nl> + . . note : : When using SDL you will probably need to set the main loop . You should also note : <nl> + <nl> + - The current Emscripten implementation of ` ` SDL_QUIT ` ` will work if you use : c : func : ` emscripten_set_main_loop ` . As the page is shut , it will force a final direct call to the main loop , giving it a chance to notice the ` ` SDL_QUIT ` ` event . If you do not use a main loop , your app will close before you have had an opportunity to notice this event . <nl> + - There are limitations to what you can do as the page shuts ( in ` ` onunload ` ` ) . Some actions like showing alerts are banned by browsers at this point . <nl> <nl> - There are also several other useful functions in : ref : ` emscripten - h ` . As mentioned above , we use existing familiar APIs when present , like SDL , so the things in the additional Emscripten API are capabilities specific to the JavaScript or the browser environment , that we couldn ' t find an existing API for . Below is a general overview of some important parts . <nl> <nl> Execution lifecycle <nl> = = = = = = = = = = = = = = = = = = = <nl> <nl> - When an emscripten - compiled application is loaded , it starts by with preparing data in the ` ` preloading ` ` phase . Files you marked for preloading ( ` ` emcc - - preload - file ` ` , or manually from JavaScript using createPreloadedFile ) are set up at this stage . You can add additional operations with : js : func : ` addRunDependency ` ( remember to call : js : func : ` removeRunDependency ` ) , which is a counter of all dependencies preventing run . When all dependencies are met , we will call ` ` run ` ` , which proceeds to call your ` ` main ( ) ` ` function . <nl> + When an Emscripten - compiled application is loaded , it starts by preparing data in the ` ` preloading ` ` phase . Files you marked for : ref : ` preloading < emcc - preload - file > ` ( using ` ` emcc - - preload - file ` ` , or manually from JavaScript with : js : func : ` FS . createPreloadedFile ` ) are set up at this stage . <nl> + <nl> + You can add additional operations with : js : func : ` addRunDependency ` , which is a counter of all dependencies to be executed before compiled code can run . As these are completed you can call : js : func : ` removeRunDependency ` to remove the completed dependencies . <nl> + <nl> + . . note : : Generally it is not necessary to add additional operations — preloading is suitable for almost all use cases . <nl> <nl> - After the application runs , as mentioned above you will typically want to define a main loop . You can affect how the main loop works in several ways : <nl> + When all dependencies are met , Emscripten will call ` ` run ( ) ` ` , which proceeds to call your ` ` main ( ) ` ` function . Often the ` ` main ( ) ` ` function just calls : c : func : ` emscripten_set_main_loop ` ( as : ref : ` described above < emscripten - runtime - environment - howto - main - loop > ` ) and / or does some other initialization . The main loop function will be then be called at the requested frequency . <nl> <nl> - - : c : func : ` emscripten_pause_main_loop ` pauses the main loop , and : c : func : ` emscripten_resume_main_loop ` resumes it . This might be useful if you want to manually freeze the application for some reason . This is fairly low - level , there are more convenient alternatives below for common tasks . <nl> - - : c : func : ` emscripten_push_main_loop_blocker ` adds a function that * * blocks * * the main loop : The main loop will not run until the blocker completes . For example , if when the user finishes a level in your game you want to load the next one , you can push blockers for each action involved in that ( unpack the file , generate the data structures , etc . ) , and when they are done the main loop will resume ( and if things are set up properly , it will run the new level ) . The blockers are a simple FIFO queue . Basically , blockers are a small simplification of manually pausing and resuming the main loop . They also are useful for marking progress : If you all ` ` emscripten_set_main_loop_expected_blockers ( 10 ) ` ` and then push 10 blockers , progress will be shown to the user as the blockers execute . <nl> - - : c : func : ` emscripten_async_call ` lets you call a function after some specific interval ( basically a wrapper around ` ` setTimout / requestAnimationFrame ` ` ) . <nl> - - : c : func : ` emscripten_async_wget ` asynchronously loads a file from the network . Synchronous XHRs cannot load binary data , so an asynchronous function is necessary . It will call a callback that you give it when the file arrives . You can use this to fetch the next level in your game , for example ( note that it will do the same operation we do on preloaded files , setting them up as image or audio elements as necessary for execution later ) . <nl> + You can affect the operation of the main loop in several ways : <nl> <nl> + - <nl> + : c : func : ` emscripten_push_main_loop_blocker ` adds a function that * * blocks * * the main loop until the blocker completes . <nl> <nl> - . . todo : : HamishW : ref : ` Module ` has some functions which affect exectution . Remember to link it here . Some stuff on this in " interacting with code " . <nl> + This is useful , for example , to manage loading new game levels . After a level completes , you can push blockers for each action involved ( unpacking the file , generate the data structures , etc . ) When all the blockers have completed the main loop will resume and the game should run the new level . You can also use this function in conjunction with : c : func : ` emscripten_set_main_loop_expected_blockers ` to keep the user informed of progress . <nl> <nl> - Notes <nl> - = = = = = <nl> + - : c : func : ` emscripten_pause_main_loop ` pauses the main loop , and : c : func : ` emscripten_resume_main_loop ` resumes it . These are low level ( less recommended ) alternatives to the blocker functions . <nl> <nl> - - ` ` SDL_QUIT ` ` is tricky to implement in browsers . The current Emscripten implementation of it will work if you use : c : func : ` emscripten_set_main_loop ` : As the page is shut , it will force a final direct call to the main loop , giving it a chance to notice the ` ` SDL_QUIT ` ` event . So if you do not use a main loop , you will not notice it - your app will close before your next event handling . Note also that there are limitations on what you can do as the page shuts ( in onunload ) , some actions like showing alerts are banned by browsers . <nl> + - : c : func : ` emscripten_async_call ` lets you call a function after some specific interval ( this is basically a wrapper around ` ` setTimout / requestAnimationFrame ` ` ) . <nl> + <nl> + The : ref : ` browser execution environment reference ( emscripten . h ) < emscripten - h - browser - execution - environment > ` describes a number of other methods for controlling execution . <nl> <nl> <nl> . . _emscripten - memory - model : <nl> <nl> - Emscripten memory model <nl> - = = = = = = = = = = = = = = = = = = = = = = = <nl> + Emscripten memory representation <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> Emscripten ' s memory model is known as : term : ` Typed Arrays Mode 2 ` . It represents memory using a single ` typed array < https : / / developer . mozilla . org / en - US / docs / Web / JavaScript / Typed_arrays > ` _ , with different * views * providing access to different types ( : js : data : ` HEAPU32 ` for 32 - bit unsigned integers , etc . ) <nl> <nl> Emscripten ' s memory model is known as : term : ` Typed Arrays Mode 2 ` . It represents <nl> <nl> The model lays out items in memory in the same way as with normal C and C + + , and as a result it uses the same amount of memory . <nl> <nl> - We currently align the stack to 4 - byte boundaries ( this means that reading 8 - byte values is slower as they must be read in two parts and then combined ) . <nl> - <nl> - This model allows you to use code that violates the load - store consistency assumption . Since the different views show the same data , you can ( say ) write a 32 - bit integer , then read a byte from the middle , and it will work just like in C or C + + . <nl> - <nl> + This model allows you to use code that violates the : term : ` load - store consistency ` assumption . Since the different views show the same data , you can ( say ) write a 32 - bit integer , then read a byte from the middle , and it will work just like in a native build of C or C + + on most platforms . <nl> <nl> - . . note : : ` ` SAFE_HEAP ` ` ignores load - store consistency violations , since they don ' t matter . Alignment of reads and writes will be checked , which is important since reading unaligned values can fail . <nl> <nl> mmm a / site / source / docs / porting / guidelines / browser_limitations . rst <nl> ppp b / site / source / docs / porting / guidelines / browser_limitations . rst <nl> <nl> . . _Browser - limitations : <nl> <nl> - = = = = = = = = = = = = = = = = = = = <nl> - Browser limitations <nl> - = = = = = = = = = = = = = = = = = = = <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + Specific Browser Limitations <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> This page lists some of the differences between the latest versions of the major browsers that are relevant to Emscripten - compiled applications and games : <nl> <nl> mmm a / site / source / docs / porting / multimedia_and_graphics / OpenGL - support . rst <nl> ppp b / site / source / docs / porting / multimedia_and_graphics / OpenGL - support . rst <nl> OpenGL support in Emscripten ( ready - for - review ) <nl> Emscripten provides three OpenGL modes : <nl> <nl> - : ref : ` opengl - support - webgl - subset ` ( default ) — supports the set of OpenGL commands that map directly to WebGL . <nl> - - : ref : ` opengl - support - opengl - es2 - 0 - emulation ` — full support for Open GL ES 2 . 0 . <nl> + - : ref : ` opengl - support - opengl - es2 - 0 - emulation ` — full support for OpenGL ES 2 . 0 . <nl> - : ref : ` opengl - support - legacy_and_mobile ` — support for a number of legacy GL 1 . x features and commands . <nl> <nl> This topic provides information about the modes , and how they are enabled . <nl> Emscripten supports the WebGL - friendly subset of OpenGL * by default * . This is th <nl> <nl> This mode is used by default because it is stable , predictable and fast . <nl> <nl> - The files in ` tests / glbook < https : / / github . com / kripken / emscripten / tree / master / tests / glbook > ` _ provide a number of simple examples that use only the WebGL - friendly subset of commands . <nl> + . . todo : : Have removed the following note because ` ` webgl . verbose ` ` is not available in the preferences in current firefox . If this becomes available , attempt to re - integrate : <nl> <nl> - . . todo : : Check this . Can ' t find it . The Firefox ` ` webgl . verbose ` ` option is a very useful tool is the in Firefox . If you compile code that uses client - side arrays , that option will give you a warning when there isn ' t a bound buffer and so forth . It will also warn you of other differences between OpenGL and WebGL . <nl> + The Firefox ` ` webgl . verbose ` ` option is a very useful tool is the in Firefox . If you compile code that uses client - side arrays , that option will give you a warning when there isn ' t a bound buffer and so forth . It will also warn you of other differences between OpenGL and WebGL . <nl> <nl> <nl> . . _opengl - support - opengl - es2 - 0 - emulation : <nl> OpenGL ES 2 . 0 emulation <nl> <nl> This mode provides a full OpenGL ES 2 . 0 environment — specifically it emulates client - side arrays that were missing [ # f1 ] _ from the : ref : ` opengl - support - webgl - subset ` . <nl> <nl> - This allows you use ` glDrawArrays < https : / / www . opengl . org / sdk / docs / man3 / xhtml / glDrawArrays . xml > ` _ etc . without a bound buffer , and Emscripten ' s GL bindings will set up the buffer automatically ( WebGL requires that a buffer be bound ) . <nl> + This allows you to use ` glDrawArrays < https : / / www . opengl . org / sdk / docs / man3 / xhtml / glDrawArrays . xml > ` _ etc . without a bound buffer , and Emscripten ' s GL bindings will set up the buffer automatically ( WebGL requires that a buffer be bound ) . <nl> <nl> This mode is not as efficient as the WebGL - friendly subset , because Emscripten cannot predict the optimal pattern for buffer creation / sizing / etc . We therefore have to make more ( costly ) data uploads from the CPU to the GPU than are actually needed . <nl> <nl> mmm a / site / source / docs / porting / multimedia_and_graphics / index . rst <nl> ppp b / site / source / docs / porting / multimedia_and_graphics / index . rst <nl> <nl> Multimedia and Graphics <nl> = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - This section contains articles about integrating graphics and audio with the Emscripten browser environment . <nl> + This section contains articles about Emscripten ' s support for graphics and audio APIs . <nl> <nl> <nl> . . toctree : : <nl> mmm a / site / source / docs / site / glossary . rst <nl> ppp b / site / source / docs / site / glossary . rst <nl> General <nl> <nl> The original compiler supported a number of other memory models and compilation modes ( see ` Code Generation Modes < https : / / github . com / kripken / emscripten / wiki / Code - Generation - Modes > ` _ ) but * Typed Arrays Mode 2 * proved to have , among other benefits , the greatest support for arbitrary code . <nl> <nl> + <nl> + Load - store consistency <nl> + Load - Store Consistency ( LSC ) , is the requirement that after a value with a specific type is written to a memory location , loads from that memory location will be of the same type . So if a variable contains a 32 - bit floating point number , then both loads and stores to that variable will be of 32 - bit floating point values , and not 16 - bit unsigned integers or anything else . <nl> <nl> + . . note : : This definition is taken from ` Emscripten : An LLVM - to - JavaScript Compiler < https : / / github . com / kripken / emscripten / blob / master / docs / paper . pdf ? raw = true > ` _ ( section 2 . 1 . 1 ) . There is additional detail in that paper . <nl> + <nl> <nl> Emscripten tools and dependencies <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl>
Integrate feedback to Runtime environment and OpenGL docs from ChrisM and Alon
emscripten-core/emscripten
68a37ae89c3511c24bcde2cfa0327b071c2e42e8
2014-09-16T00:03:47Z
mmm a / THCTensorMath . cu <nl> ppp b / THCTensorMath . cu <nl> IMPLEMENT_CUDA_TENSOR_BASIC_FUNC ( sqrt , sqrt ) <nl> IMPLEMENT_CUDA_TENSOR_BASIC_FUNC ( ceil , ceil ) <nl> IMPLEMENT_CUDA_TENSOR_BASIC_FUNC ( floor , floor ) <nl> IMPLEMENT_CUDA_TENSOR_BASIC_FUNC ( abs , fabs ) <nl> + IMPLEMENT_CUDA_TENSOR_BASIC_FUNC ( round , roundf ) <nl> <nl> struct pow_functor <nl> { <nl> mmm a / THCTensorMath . h <nl> ppp b / THCTensorMath . h <nl> THC_API void THCudaTensor_ceil ( THCudaTensor * self , THCudaTensor * src ) ; <nl> THC_API void THCudaTensor_floor ( THCudaTensor * self , THCudaTensor * src ) ; <nl> THC_API void THCudaTensor_abs ( THCudaTensor * self , THCudaTensor * src ) ; <nl> THC_API void THCudaTensor_sign ( THCudaTensor * self , THCudaTensor * src ) ; <nl> + THC_API void THCudaTensor_round ( THCudaTensor * self , THCudaTensor * src ) ; <nl> <nl> THC_API void THCudaTensor_ltValue ( THCudaTensor * self_ , THCudaTensor * src , float value ) ; <nl> THC_API void THCudaTensor_gtValue ( THCudaTensor * self_ , THCudaTensor * src , float value ) ; <nl>
round function , test for cumprod
pytorch/pytorch
3bd605b1f7dfb65efd6a026025cae9154f9f0abe
2014-11-07T18:54:37Z
mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> v8_source_set ( " v8_base_without_compiler " ) { <nl> " src / debug / mips / debug - mips . cc " , <nl> " src / deoptimizer / mips / deoptimizer - mips . cc " , <nl> " src / diagnostics / mips / disasm - mips . cc " , <nl> + " src / diagnostics / mips / unwinder - mips . cc " , <nl> " src / execution / mips / frame - constants - mips . cc " , <nl> " src / execution / mips / frame - constants - mips . h " , <nl> " src / execution / mips / simulator - mips . cc " , <nl> v8_source_set ( " v8_base_without_compiler " ) { <nl> " src / debug / mips64 / debug - mips64 . cc " , <nl> " src / deoptimizer / mips64 / deoptimizer - mips64 . cc " , <nl> " src / diagnostics / mips64 / disasm - mips64 . cc " , <nl> + " src / diagnostics / mips64 / unwinder - mips64 . cc " , <nl> " src / execution / mips64 / frame - constants - mips64 . cc " , <nl> " src / execution / mips64 / frame - constants - mips64 . h " , <nl> " src / execution / mips64 / simulator - mips64 . cc " , <nl> new file mode 100644 <nl> index 00000000000 . . 5a92512a17b <nl> mmm / dev / null <nl> ppp b / src / diagnostics / mips / unwinder - mips . cc <nl> <nl> + / / Copyright 2020 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + # include " src / diagnostics / unwinder . h " <nl> + <nl> + namespace v8 { <nl> + <nl> + void GetCalleeSavedRegistersFromEntryFrame ( void * fp , <nl> + RegisterState * register_state ) { } <nl> + <nl> + } / / namespace v8 <nl> new file mode 100644 <nl> index 00000000000 . . 5a92512a17b <nl> mmm / dev / null <nl> ppp b / src / diagnostics / mips64 / unwinder - mips64 . cc <nl> <nl> + / / Copyright 2020 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + # include " src / diagnostics / unwinder . h " <nl> + <nl> + namespace v8 { <nl> + <nl> + void GetCalleeSavedRegistersFromEntryFrame ( void * fp , <nl> + RegisterState * register_state ) { } <nl> + <nl> + } / / namespace v8 <nl>
[ mips ] [ unwinder ] Restore callee saved registers after unwinding
v8/v8
365948ed6ea90418fea4cbbb689449469c80ce15
2020-10-22T08:59:42Z
mmm a / src / library_fs . js <nl> ppp b / src / library_fs . js <nl> mergeInto ( LibraryManager . library , { <nl> / / to modify the filesystem freely before run ( ) is called . <nl> ignorePermissions : true , <nl> <nl> - ErrnoError : function ( errno ) { <nl> - this . errno = errno ; <nl> - for ( var key in ERRNO_CODES ) { <nl> - if ( ERRNO_CODES [ key ] = = = errno ) { <nl> - this . code = key ; <nl> - break ; <nl> + ErrnoError : ( function ( ) { <nl> + function ErrnoError ( errno ) { <nl> + this . errno = errno ; <nl> + for ( var key in ERRNO_CODES ) { <nl> + if ( ERRNO_CODES [ key ] = = = errno ) { <nl> + this . code = key ; <nl> + break ; <nl> + } <nl> } <nl> - } <nl> - this . message = ERRNO_MESSAGES [ errno ] + ' : ' + new Error ( ) . stack ; <nl> - } , <nl> + this . message = ERRNO_MESSAGES [ errno ] ; <nl> + } ; <nl> + ErrnoError . prototype = new Error ( ) ; <nl> + ErrnoError . prototype . constructor = ErrnoError ; <nl> + return ErrnoError ; <nl> + } ( ) ) , <nl> <nl> handleFSError : function ( e ) { <nl> if ( ! ( e instanceof FS . ErrnoError ) ) throw e + ' : ' + new Error ( ) . stack ; <nl>
make FS . ErrnoError inherit from Error
emscripten-core/emscripten
3b871e28f328c45835f75d29e790bfc808f2f002
2013-08-14T00:34:24Z
mmm a / xbmc / filesystem / FileCache . cpp <nl> ppp b / xbmc / filesystem / FileCache . cpp <nl> <nl> <nl> using namespace XFILE ; <nl> <nl> - # define READ_CACHE_CHUNK_SIZE ( 64 * 1024 ) <nl> + # define READ_CACHE_CHUNK_SIZE ( 128 * 1024 ) <nl> <nl> class CWriteRate <nl> { <nl>
Increase CHUNK_SIZE to 128 KB
xbmc/xbmc
e7435af4142f7fa544af0df858cd864a54bc84a9
2017-04-21T20:56:50Z
deleted file mode 100644 <nl> index 98ce2080c10 . . 00000000000 <nl> mmm a / ports / double - conversion / 001 - fix - arm . patch <nl> ppp / dev / null <nl> <nl> mmmmmm a / double - conversion / utils . h <nl> - ppp " b / double - conversion / utils . h " <nl> - inline void abort_noreturn ( ) { abort ( ) ; } <nl> - / / disabled . ) <nl> - / / On Linux , x86 89255e - 22 ! = Div_double ( 89255 . 0 / 1e22 ) <nl> - # if defined ( _M_X64 ) | | defined ( __x86_64__ ) | | \ <nl> - - defined ( __ARMEL__ ) | | defined ( __avr32__ ) | | \ <nl> - + defined ( __ARMEL__ ) | | defined ( __avr32__ ) | | defined ( _M_ARM ) | | \ <nl> - defined ( __hppa__ ) | | defined ( __ia64__ ) | | \ <nl> - defined ( __mips__ ) | | \ <nl> - defined ( __powerpc__ ) | | defined ( __ppc__ ) | | defined ( __ppc64__ ) | | \ <nl> mmm a / ports / double - conversion / CONTROL <nl> ppp b / ports / double - conversion / CONTROL <nl> <nl> Source : double - conversion <nl> - Version : 3 . 1 . 0 <nl> + Version : 3 . 1 . 0 - 1 <nl> Description : Efficient binary - decimal and decimal - binary conversion routines for IEEE doubles . <nl> mmm a / ports / double - conversion / portfile . cmake <nl> ppp b / ports / double - conversion / portfile . cmake <nl> vcpkg_from_github ( <nl> HEAD_REF master <nl> ) <nl> <nl> - vcpkg_apply_patches ( <nl> - SOURCE_PATH $ { SOURCE_PATH } <nl> - PATCHES $ { CMAKE_CURRENT_LIST_DIR } / 001 - fix - arm . patch <nl> - ) <nl> - <nl> vcpkg_configure_cmake ( <nl> SOURCE_PATH $ { SOURCE_PATH } <nl> PREFER_NINJA <nl> endif ( ) <nl> <nl> vcpkg_copy_pdbs ( ) <nl> <nl> - # Include files should not be duplicated into the / debug / include directory . <nl> file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> <nl> # Handle copyright <nl> - file ( COPY $ { SOURCE_PATH } / LICENSE DESTINATION $ { CURRENT_PACKAGES_DIR } / share / double - conversion ) <nl> - file ( RENAME $ { CURRENT_PACKAGES_DIR } / share / double - conversion / LICENSE $ { CURRENT_PACKAGES_DIR } / share / double - conversion / copyright ) <nl> + configure_file ( $ { SOURCE_PATH } / LICENSE $ { CURRENT_PACKAGES_DIR } / share / double - conversion / copyright COPYONLY ) <nl>
[ double - conversion ] Remove unnecessary patch ( )
microsoft/vcpkg
30d5f959862fbfca1f7907259cb84f5963bb19d5
2018-10-25T22:53:48Z
mmm a / ios / sdk / WeexSDK . podspec <nl> ppp b / ios / sdk / WeexSDK . podspec <nl> Pod : : Spec . new do | s | <nl> <nl> s . user_target_xcconfig = { ' FRAMEWORK_SEARCH_PATHS ' = > " ' $ ( PODS_ROOT ) / WeexSDK ' " } <nl> <nl> - s . frameworks = ' AVKit ' , ' CoreMedia ' , ' MediaPlayer ' , ' AVFoundation ' , ' AVKit ' , ' JavaScriptCore ' , ' GLKit ' <nl> + s . frameworks = CoreMedia ' , ' MediaPlayer ' , ' AVFoundation ' , ' AVKit ' , ' JavaScriptCore ' , ' GLKit ' <nl> <nl> s . dependency ' SocketRocket ' <nl> <nl> mmm a / ios / sdk / WeexSDK . xcodeproj / project . pbxproj <nl> ppp b / ios / sdk / WeexSDK . xcodeproj / project . pbxproj <nl> <nl> DC03ADB91D508719003F76E7 / * WXTextAreaComponent . m in Sources * / = { isa = PBXBuildFile ; fileRef = DC03ADB71D508719003F76E7 / * WXTextAreaComponent . m * / ; } ; <nl> DC03ADBA1D508719003F76E7 / * WXTextAreaComponent . h in Headers * / = { isa = PBXBuildFile ; fileRef = DC03ADB81D508719003F76E7 / * WXTextAreaComponent . h * / ; } ; <nl> DC0F99311D48E5320087C6AF / * WeexSDK . h in Headers * / = { isa = PBXBuildFile ; fileRef = DC0F99301D48E5320087C6AF / * WeexSDK . h * / ; settings = { ATTRIBUTES = ( Public , ) ; } ; } ; <nl> + DC9867441D826D1E000AF388 / * GLKit . framework in Frameworks * / = { isa = PBXBuildFile ; fileRef = DC9867431D826D1E000AF388 / * GLKit . framework * / ; } ; <nl> DC9F46831D61AC8800A88239 / * WXStreamModuleTests . m in Sources * / = { isa = PBXBuildFile ; fileRef = DC9F46821D61AC8800A88239 / * WXStreamModuleTests . m * / ; } ; <nl> DC9F46871D61BA8C00A88239 / * wx_load_error @ 3x . png in Resources * / = { isa = PBXBuildFile ; fileRef = 59AC02501D2A7E6E00355112 / * wx_load_error @ 3x . png * / ; } ; <nl> DC9F46881D61BA8C00A88239 / * main . js in Resources * / = { isa = PBXBuildFile ; fileRef = 74B80E6B1C3FB32C00239FB9 / * main . js * / ; } ; <nl> <nl> DC03ADB71D508719003F76E7 / * WXTextAreaComponent . m * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . objc ; path = WXTextAreaComponent . m ; sourceTree = " < group > " ; } ; <nl> DC03ADB81D508719003F76E7 / * WXTextAreaComponent . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = WXTextAreaComponent . h ; sourceTree = " < group > " ; } ; <nl> DC0F99301D48E5320087C6AF / * WeexSDK . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = WeexSDK . h ; sourceTree = " < group > " ; } ; <nl> + DC9867431D826D1E000AF388 / * GLKit . framework * / = { isa = PBXFileReference ; lastKnownFileType = wrapper . framework ; name = GLKit . framework ; path = System / Library / Frameworks / GLKit . framework ; sourceTree = SDKROOT ; } ; <nl> DC9F46821D61AC8800A88239 / * WXStreamModuleTests . m * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . objc ; path = WXStreamModuleTests . m ; sourceTree = " < group > " ; } ; <nl> DCA0EF621D6EED6F00CB18B9 / * WXGlobalEventModule . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = WXGlobalEventModule . h ; sourceTree = " < group > " ; } ; <nl> DCA0EF631D6EED6F00CB18B9 / * WXGlobalEventModule . m * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . objc ; path = WXGlobalEventModule . m ; sourceTree = " < group > " ; } ; <nl> <nl> isa = PBXFrameworksBuildPhase ; <nl> buildActionMask = 2147483647 ; <nl> files = ( <nl> + DC9867441D826D1E000AF388 / * GLKit . framework in Frameworks * / , <nl> 740938FB1D3D0E1700DBB801 / * AVKit . framework in Frameworks * / , <nl> 740938F91D3D0E0300DBB801 / * MediaPlayer . framework in Frameworks * / , <nl> 740938F71D3D0DFD00DBB801 / * CoreMedia . framework in Frameworks * / , <nl> <nl> A5818E244F9E235722E3B938 / * Frameworks * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> + DC9867431D826D1E000AF388 / * GLKit . framework * / , <nl> 740938FA1D3D0E1700DBB801 / * AVKit . framework * / , <nl> 740938F81D3D0E0300DBB801 / * MediaPlayer . framework * / , <nl> 740938F61D3D0DFD00DBB801 / * CoreMedia . framework * / , <nl>
* [ ios ] add GLKit framework for test target
apache/incubator-weex
cf41058d5e41b80add85e30a50263c31e2c33cda
2016-09-09T04:10:06Z
mmm a / doc / tutorials / kubernetes . rst <nl> ppp b / doc / tutorials / kubernetes . rst <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> - Distributed XGBoost with Kubernetes <nl> + Distributed XGBoost on Kubernetes <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> <nl> - Kubeflow community provides ` XGBoost Operator < https : / / github . com / kubeflow / xgboost - operator > ` _ to support distributed XGBoost training and batch prediction in a Kubernetes cluster . It provides an easy and efficient XGBoost model training and batch prediction in distributed fashion . <nl> + Distributed XGBoost training and batch prediction on ` Kubernetes < https : / / kubernetes . io / > ` _ are supported via ` Kubeflow XGBoost Operator < https : / / github . com / kubeflow / xgboost - operator > ` _ . <nl> <nl> - * * * * * * * * * * <nl> - How to use <nl> - * * * * * * * * * * <nl> - In order to run a XGBoost job in a Kubernetes cluster , carry out the following steps : <nl> + * * * * * * * * * * * * <nl> + Instructions <nl> + * * * * * * * * * * * * <nl> + In order to run a XGBoost job in a Kubernetes cluster , perform the following steps : <nl> <nl> - 1 . Install XGBoost Operator in Kubernetes . <nl> + 1 . Install XGBoost Operator on the Kubernetes cluster . <nl> <nl> - a . XGBoost Operator is designed to manage XGBoost jobs , including job scheduling , monitoring , pods and services recovery etc . Follow the ` installation guide < https : / / github . com / kubeflow / xgboost - operator # installing - xgboost - operator > ` _ to install XGBoost Operator . <nl> + a . XGBoost Operator is designed to manage the scheduling and monitoring of XGBoost jobs . Follow ` this installation guide < https : / / github . com / kubeflow / xgboost - operator # installing - xgboost - operator > ` _ to install XGBoost Operator . <nl> <nl> - 2 . Write application code to interface with the XGBoost operator . <nl> + 2 . Write application code that will be executed by the XGBoost Operator . <nl> <nl> - a . You ' ll need to furnish a few scripts to inteface with the XGBoost operator . Refer to the ` Iris classification example < https : / / github . com / kubeflow / xgboost - operator / tree / master / config / samples / xgboost - dist > ` _ . <nl> - b . Data reader / writer : you need to have your data source reader and writer based on the requirement . For example , if your data is stored in a Hive Table , you have to write your own code to read / write Hive table based on the ID of worker . <nl> - c . Model persistence : in this example , model is stored in the OSS storage . If you want to store your model into Amazon S3 , Google NFS or other storage , you ' ll need to specify the model reader and writer based on the requirement of storage system . <nl> + a . To use XGBoost Operator , you ' ll have to write a couple of Python scripts that implement the distributed training logic for XGBoost . Please refer to the ` Iris classification example < https : / / github . com / kubeflow / xgboost - operator / tree / master / config / samples / xgboost - dist > ` _ . <nl> + b . Data reader / writer : you need to implement the data reader and writer based on the specific requirements of your chosen data source . For example , if your dataset is stored in a Hive table , you have to write the code to read from or write to the Hive table based on the index of the worker . <nl> + c . Model persistence : in the ` Iris classification example < https : / / github . com / kubeflow / xgboost - operator / tree / master / config / samples / xgboost - dist > ` _ , the model is stored in ` Alibaba OSS < https : / / www . alibabacloud . com / product / oss > ` _ . If you want to store your model in other storages such as Amazon S3 or Google NFS , you ' ll need to implement the model persistence logic based on the requirements of the chosen storage system . <nl> <nl> 3 . Configure the XGBoost job using a YAML file . <nl> <nl> - a . YAML file is used to configure the computation resource and environment for your XGBoost job to run , e . g . the number of workers and masters . The template ` YAML template < https : / / github . com / kubeflow / xgboost - operator / blob / master / config / samples / xgboost - dist / xgboostjob_v1alpha1_iris_train . yaml > ` _ is provided for reference . <nl> + a . YAML file is used to configure the computational resources and environment for your XGBoost job to run , e . g . the number of workers / masters and the number of CPU / GPUs . Please refer to this ` YAML template < https : / / github . com / kubeflow / xgboost - operator / blob / master / config / samples / xgboost - dist / xgboostjob_v1alpha1_iris_train . yaml > ` _ for an example . <nl> <nl> - 4 . Submit XGBoost job to Kubernetes cluster . <nl> + 4 . Submit XGBoost job to a Kubernetes cluster . <nl> <nl> - a . ` Kubectl command < https : / / github . com / kubeflow / xgboost - operator # creating - a - xgboost - trainingprediction - job > ` _ is used to submit a XGBoost job , and then you can monitor the job status . <nl> + a . Use ` kubectl < https : / / kubernetes . io / docs / reference / kubectl / overview / > ` _ to submit a distributed XGBoost job as illustrated ` here < https : / / github . com / kubeflow / xgboost - operator # creating - a - xgboost - trainingprediction - job > ` _ . <nl> <nl> - * * * * * * * * * * * * * * * * <nl> - Work in progress <nl> - * * * * * * * * * * * * * * * * <nl> + * * * * * * * <nl> + Support <nl> + * * * * * * * <nl> <nl> - - XGBoost Model serving <nl> - - Distributed data reader / writer from / to HDFS , HBase , Hive etc . <nl> - - Model persistence on Amazon S3 , Google NFS etc . <nl> + Please submit an issue on ` XGBoost Operator repo < https : / / github . com / kubeflow / xgboost - operator > ` _ for any feature requests or problems . <nl>
Edits on tutorial for XGBoost job on Kubernetes ( )
dmlc/xgboost
9097e8f0d90b775eef0666df87cca41f3aae8627
2020-04-05T11:36:33Z
mmm a / Marlin / src / HAL / HAL_STM32 / HAL . cpp <nl> ppp b / Marlin / src / HAL / HAL_STM32 / HAL . cpp <nl> void HAL_init ( ) { <nl> void HAL_clear_reset_source ( ) { __HAL_RCC_CLEAR_RESET_FLAGS ( ) ; } <nl> <nl> uint8_t HAL_get_reset_source ( ) { <nl> - if ( __HAL_RCC_GET_FLAG ( RCC_FLAG_IWDGRST ) ! = RESET ) return RST_WATCHDOG ; <nl> - if ( __HAL_RCC_GET_FLAG ( RCC_FLAG_SFTRST ) ! = RESET ) return RST_SOFTWARE ; <nl> - if ( __HAL_RCC_GET_FLAG ( RCC_FLAG_PINRST ) ! = RESET ) return RST_EXTERNAL ; <nl> - if ( __HAL_RCC_GET_FLAG ( RCC_FLAG_PORRST ) ! = RESET ) return RST_POWER_ON ; <nl> - return 0 ; <nl> + return <nl> + # ifdef RCC_FLAG_IWDGRST / / Some sources may not exist . . . <nl> + RESET ! = __HAL_RCC_GET_FLAG ( RCC_FLAG_IWDGRST ) ? RST_WATCHDOG : <nl> + # endif <nl> + # ifdef RCC_FLAG_IWDG1RST <nl> + RESET ! = __HAL_RCC_GET_FLAG ( RCC_FLAG_IWDG1RST ) ? RST_WATCHDOG : <nl> + # endif <nl> + # ifdef RCC_FLAG_IWDG2RST <nl> + RESET ! = __HAL_RCC_GET_FLAG ( RCC_FLAG_IWDG2RST ) ? RST_WATCHDOG : <nl> + # endif <nl> + # ifdef RCC_FLAG_SFTRST <nl> + RESET ! = __HAL_RCC_GET_FLAG ( RCC_FLAG_SFTRST ) ? RST_SOFTWARE : <nl> + # endif <nl> + # ifdef RCC_FLAG_PINRST <nl> + RESET ! = __HAL_RCC_GET_FLAG ( RCC_FLAG_PINRST ) ? RST_EXTERNAL : <nl> + # endif <nl> + # ifdef RCC_FLAG_PORRST <nl> + RESET ! = __HAL_RCC_GET_FLAG ( RCC_FLAG_PORRST ) ) ? RST_POWER_ON : <nl> + # endif <nl> + 0 <nl> + ; <nl> } <nl> <nl> void _delay_ms ( const int delay_ms ) { delay ( delay_ms ) ; } <nl>
Fix build error with unsupported reset flags ( )
MarlinFirmware/Marlin
ef513ef7fbc0c95ff35c71863f70c51a67bef2ee
2020-01-15T05:19:13Z
mmm a / src / Dictionaries / CacheDictionary . cpp <nl> ppp b / src / Dictionaries / CacheDictionary . cpp <nl> inline size_t CacheDictionary : : getCellIdx ( const Key id ) const <nl> <nl> <nl> CacheDictionary : : CacheDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> DictionaryLifetime dict_lifetime_ , <nl> CacheDictionary : : CacheDictionary ( <nl> size_t update_queue_push_timeout_milliseconds_ , <nl> size_t query_wait_timeout_milliseconds_ , <nl> size_t max_threads_for_updates_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionary ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryCache ( DictionaryFactory & factory ) <nl> ErrorCodes : : BAD_ARGUMENTS } ; <nl> <nl> return std : : make_unique < CacheDictionary > ( <nl> - database , <nl> - name , <nl> + StorageID { database , name } , <nl> dict_struct , <nl> std : : move ( source_ptr ) , <nl> dict_lifetime , <nl> mmm a / src / Dictionaries / CacheDictionary . h <nl> ppp b / src / Dictionaries / CacheDictionary . h <nl> class CacheDictionary final : public IDictionary <nl> { <nl> public : <nl> CacheDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> DictionaryLifetime dict_lifetime_ , <nl> class CacheDictionary final : public IDictionary <nl> <nl> ~ CacheDictionary ( ) override ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " Cache " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return bytes_allocated + ( string_arena ? string_arena - > size ( ) : 0 ) ; } <nl> class CacheDictionary final : public IDictionary <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> return std : : make_shared < CacheDictionary > ( <nl> - database , <nl> - name , <nl> + dict_id , <nl> dict_struct , <nl> source_ptr - > clone ( ) , <nl> dict_lifetime , <nl> class CacheDictionary final : public IDictionary <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> mutable DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / ComplexKeyCacheDictionary . cpp <nl> ppp b / src / Dictionaries / ComplexKeyCacheDictionary . cpp <nl> inline UInt64 ComplexKeyCacheDictionary : : getCellIdx ( const StringRef key ) const <nl> <nl> <nl> ComplexKeyCacheDictionary : : ComplexKeyCacheDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> const size_t size_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryComplexKeyCache ( DictionaryFactory & factory ) <nl> const String database = config . getString ( config_prefix + " . database " , " " ) ; <nl> const String name = config . getString ( config_prefix + " . name " ) ; <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> - return std : : make_unique < ComplexKeyCacheDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , size ) ; <nl> + return std : : make_unique < ComplexKeyCacheDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , size ) ; <nl> } ; <nl> factory . registerLayout ( " complex_key_cache " , create_layout , true ) ; <nl> } <nl> mmm a / src / Dictionaries / ComplexKeyCacheDictionary . h <nl> ppp b / src / Dictionaries / ComplexKeyCacheDictionary . h <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> { <nl> public : <nl> ComplexKeyCacheDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> <nl> std : : string getKeyDescription ( ) const { return key_description ; } <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " ComplexKeyCache " ; } <nl> <nl> size_t getBytesAllocated ( ) const override <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < ComplexKeyCacheDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , size ) ; <nl> + return std : : make_shared < ComplexKeyCacheDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , size ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class ComplexKeyCacheDictionary final : public IDictionaryBase <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / ComplexKeyDirectDictionary . cpp <nl> ppp b / src / Dictionaries / ComplexKeyDirectDictionary . cpp <nl> namespace ErrorCodes <nl> <nl> <nl> ComplexKeyDirectDictionary : : ComplexKeyDirectDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> BlockPtr saved_block_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , saved_block { std : : move ( saved_block_ ) } <nl> void registerDictionaryComplexKeyDirect ( DictionaryFactory & factory ) <nl> throw Exception { " ' lifetime ' parameter is redundant for the dictionary ' of layout ' direct ' " , ErrorCodes : : BAD_ARGUMENTS } ; <nl> <nl> <nl> - return std : : make_unique < ComplexKeyDirectDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) ) ; <nl> + return std : : make_unique < ComplexKeyDirectDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) ) ; <nl> } ; <nl> factory . registerLayout ( " complex_key_direct " , create_layout , false ) ; <nl> } <nl> mmm a / src / Dictionaries / ComplexKeyDirectDictionary . h <nl> ppp b / src / Dictionaries / ComplexKeyDirectDictionary . h <nl> class ComplexKeyDirectDictionary final : public IDictionaryBase <nl> { <nl> public : <nl> ComplexKeyDirectDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> BlockPtr saved_block_ = nullptr ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " ComplexKeyDirect " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return 0 ; } <nl> class ComplexKeyDirectDictionary final : public IDictionaryBase <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < ComplexKeyDirectDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , saved_block ) ; <nl> + return std : : make_shared < ComplexKeyDirectDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , saved_block ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class ComplexKeyDirectDictionary final : public IDictionaryBase <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / ComplexKeyHashedDictionary . cpp <nl> ppp b / src / Dictionaries / ComplexKeyHashedDictionary . cpp <nl> namespace ErrorCodes <nl> } <nl> <nl> ComplexKeyHashedDictionary : : ComplexKeyHashedDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ , <nl> BlockPtr saved_block_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryComplexKeyHashed ( DictionaryFactory & factory ) <nl> const String name = config . getString ( config_prefix + " . name " ) ; <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> const bool require_nonempty = config . getBool ( config_prefix + " . require_nonempty " , false ) ; <nl> - return std : : make_unique < ComplexKeyHashedDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> + return std : : make_unique < ComplexKeyHashedDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> } ; <nl> factory . registerLayout ( " complex_key_hashed " , create_layout , true ) ; <nl> } <nl> mmm a / src / Dictionaries / ComplexKeyHashedDictionary . h <nl> ppp b / src / Dictionaries / ComplexKeyHashedDictionary . h <nl> class ComplexKeyHashedDictionary final : public IDictionaryBase <nl> { <nl> public : <nl> ComplexKeyHashedDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> class ComplexKeyHashedDictionary final : public IDictionaryBase <nl> <nl> std : : string getKeyDescription ( ) const { return key_description ; } <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " ComplexKeyHashed " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return bytes_allocated ; } <nl> class ComplexKeyHashedDictionary final : public IDictionaryBase <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < ComplexKeyHashedDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty , saved_block ) ; <nl> + return std : : make_shared < ComplexKeyHashedDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty , saved_block ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class ComplexKeyHashedDictionary final : public IDictionaryBase <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / DirectDictionary . cpp <nl> ppp b / src / Dictionaries / DirectDictionary . cpp <nl> namespace ErrorCodes <nl> <nl> <nl> DirectDictionary : : DirectDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> BlockPtr saved_block_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionary ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , saved_block { std : : move ( saved_block_ ) } <nl> void registerDictionaryDirect ( DictionaryFactory & factory ) <nl> throw Exception { " ' lifetime ' parameter is redundant for the dictionary ' of layout ' direct ' " , ErrorCodes : : BAD_ARGUMENTS } ; <nl> <nl> <nl> - return std : : make_unique < DirectDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) ) ; <nl> + return std : : make_unique < DirectDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) ) ; <nl> } ; <nl> factory . registerLayout ( " direct " , create_layout , false ) ; <nl> } <nl> mmm a / src / Dictionaries / DirectDictionary . h <nl> ppp b / src / Dictionaries / DirectDictionary . h <nl> class DirectDictionary final : public IDictionary <nl> { <nl> public : <nl> DirectDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> BlockPtr saved_block_ = nullptr ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " Direct " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return 0 ; } <nl> class DirectDictionary final : public IDictionary <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < DirectDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , saved_block ) ; <nl> + return std : : make_shared < DirectDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , saved_block ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class DirectDictionary final : public IDictionary <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / FlatDictionary . cpp <nl> ppp b / src / Dictionaries / FlatDictionary . cpp <nl> static const auto max_array_size = 500000 ; <nl> <nl> <nl> FlatDictionary : : FlatDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ , <nl> BlockPtr saved_block_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionary ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryFlat ( DictionaryFactory & factory ) <nl> const String name = config . getString ( config_prefix + " . name " ) ; <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> const bool require_nonempty = config . getBool ( config_prefix + " . require_nonempty " , false ) ; <nl> - return std : : make_unique < FlatDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> + return std : : make_unique < FlatDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> } ; <nl> factory . registerLayout ( " flat " , create_layout , false ) ; <nl> } <nl> mmm a / src / Dictionaries / FlatDictionary . h <nl> ppp b / src / Dictionaries / FlatDictionary . h <nl> class FlatDictionary final : public IDictionary <nl> { <nl> public : <nl> FlatDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ , <nl> BlockPtr saved_block_ = nullptr ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " Flat " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return bytes_allocated ; } <nl> class FlatDictionary final : public IDictionary <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < FlatDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty , saved_block ) ; <nl> + return std : : make_shared < FlatDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty , saved_block ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class FlatDictionary final : public IDictionary <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / HashedDictionary . cpp <nl> ppp b / src / Dictionaries / HashedDictionary . cpp <nl> namespace ErrorCodes <nl> <nl> <nl> HashedDictionary : : HashedDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ , <nl> bool sparse_ , <nl> BlockPtr saved_block_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionary ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryHashed ( DictionaryFactory & factory ) <nl> const String name = config . getString ( config_prefix + " . name " ) ; <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> const bool require_nonempty = config . getBool ( config_prefix + " . require_nonempty " , false ) ; <nl> - return std : : make_unique < HashedDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty , sparse ) ; <nl> + return std : : make_unique < HashedDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty , sparse ) ; <nl> } ; <nl> using namespace std : : placeholders ; <nl> factory . registerLayout ( " hashed " , <nl> mmm a / src / Dictionaries / HashedDictionary . h <nl> ppp b / src / Dictionaries / HashedDictionary . h <nl> class HashedDictionary final : public IDictionary <nl> { <nl> public : <nl> HashedDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> class HashedDictionary final : public IDictionary <nl> bool sparse_ , <nl> BlockPtr saved_block_ = nullptr ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return sparse ? " SparseHashed " : " Hashed " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return bytes_allocated ; } <nl> class HashedDictionary final : public IDictionary <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < HashedDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty , sparse , saved_block ) ; <nl> + return std : : make_shared < HashedDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty , sparse , saved_block ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class HashedDictionary final : public IDictionary <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / IDictionary . h <nl> ppp b / src / Dictionaries / IDictionary . h <nl> <nl> # include < Core / Names . h > <nl> # include < DataStreams / IBlockStream_fwd . h > <nl> # include < Interpreters / IExternalLoadable . h > <nl> + # include < Interpreters / StorageID . h > <nl> # include < Poco / Util / XMLConfiguration . h > <nl> # include < Common / PODArray . h > <nl> # include < common / StringRef . h > <nl> struct IDictionaryBase : public IExternalLoadable <nl> { <nl> using Key = UInt64 ; <nl> <nl> - virtual const std : : string & getDatabase ( ) const = 0 ; <nl> - virtual const std : : string & getName ( ) const = 0 ; <nl> - virtual const std : : string & getFullName ( ) const = 0 ; <nl> + IDictionaryBase ( const StorageID & dict_id_ ) <nl> + : dict_id ( dict_id_ ) <nl> + , full_name ( dict_id . database_name . empty ( ) ? dict_id . getTableName ( ) : dict_id . getFullTableName ( ) ) <nl> + { <nl> + } <nl> + <nl> + virtual const std : : string & getDatabase ( ) const { return dict_id . database_name ; } <nl> + virtual const std : : string & getName ( ) const { return dict_id . table_name ; } <nl> + virtual const std : : string & getFullName ( ) const { return full_name ; } <nl> <nl> const std : : string & getLoadableName ( ) const override { return getFullName ( ) ; } <nl> <nl> struct IDictionaryBase : public IExternalLoadable <nl> { <nl> return std : : static_pointer_cast < const IDictionaryBase > ( IExternalLoadable : : shared_from_this ( ) ) ; <nl> } <nl> + <nl> + protected : <nl> + StorageID dict_id ; <nl> + const String full_name ; <nl> } ; <nl> <nl> <nl> struct IDictionary : IDictionaryBase <nl> { <nl> + IDictionary ( const StorageID & dict_id_ ) : IDictionaryBase ( dict_id_ ) { } <nl> + <nl> virtual bool hasHierarchy ( ) const = 0 ; <nl> <nl> virtual void toParent ( const PaddedPODArray < Key > & ids , PaddedPODArray < Key > & out ) const = 0 ; <nl> mmm a / src / Dictionaries / PolygonDictionary . cpp <nl> ppp b / src / Dictionaries / PolygonDictionary . cpp <nl> namespace ErrorCodes <nl> <nl> <nl> IPolygonDictionary : : IPolygonDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> InputType input_type_ , <nl> PointType point_type_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr ( std : : move ( source_ptr_ ) ) <nl> , dict_lifetime ( dict_lifetime_ ) <nl> IPolygonDictionary : : IPolygonDictionary ( <nl> loadData ( ) ; <nl> } <nl> <nl> - const std : : string & IPolygonDictionary : : getDatabase ( ) const <nl> - { <nl> - return database ; <nl> - } <nl> - <nl> - const std : : string & IPolygonDictionary : : getName ( ) const <nl> - { <nl> - return name ; <nl> - } <nl> - <nl> - const std : : string & IPolygonDictionary : : getFullName ( ) const <nl> - { <nl> - return full_name ; <nl> - } <nl> - <nl> std : : string IPolygonDictionary : : getTypeName ( ) const <nl> { <nl> return " Polygon " ; <nl> void IPolygonDictionary : : extractPolygons ( const ColumnPtr & column ) <nl> } <nl> <nl> SimplePolygonDictionary : : SimplePolygonDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> InputType input_type_ , <nl> PointType point_type_ ) <nl> - : IPolygonDictionary ( database_ , name_ , dict_struct_ , std : : move ( source_ptr_ ) , dict_lifetime_ , input_type_ , point_type_ ) <nl> + : IPolygonDictionary ( dict_id_ , dict_struct_ , std : : move ( source_ptr_ ) , dict_lifetime_ , input_type_ , point_type_ ) <nl> { <nl> } <nl> <nl> std : : shared_ptr < const IExternalLoadable > SimplePolygonDictionary : : clone ( ) const <nl> { <nl> return std : : make_shared < SimplePolygonDictionary > ( <nl> - this - > database , <nl> - this - > name , <nl> + this - > dict_id , <nl> this - > dict_struct , <nl> this - > source_ptr - > clone ( ) , <nl> this - > dict_lifetime , <nl> void registerDictionaryPolygon ( DictionaryFactory & factory ) <nl> ErrorCodes : : BAD_ARGUMENTS } ; <nl> <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> - return std : : make_unique < SimplePolygonDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , input_type , point_type ) ; <nl> + return std : : make_unique < SimplePolygonDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , input_type , point_type ) ; <nl> } ; <nl> factory . registerLayout ( " polygon " , create_layout , true ) ; <nl> } <nl> mmm a / src / Dictionaries / PolygonDictionary . h <nl> ppp b / src / Dictionaries / PolygonDictionary . h <nl> class IPolygonDictionary : public IDictionaryBase <nl> Tuple , <nl> } ; <nl> IPolygonDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> DictionaryLifetime dict_lifetime_ , <nl> InputType input_type_ , <nl> PointType point_type_ ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override ; <nl> - const std : : string & getName ( ) const override ; <nl> - const std : : string & getFullName ( ) const override ; <nl> - <nl> std : : string getTypeName ( ) const override ; <nl> <nl> std : : string getKeyDescription ( ) const ; <nl> class IPolygonDictionary : public IDictionaryBase <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> class SimplePolygonDictionary : public IPolygonDictionary <nl> { <nl> public : <nl> SimplePolygonDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> DictionaryLifetime dict_lifetime_ , <nl> mmm a / src / Dictionaries / RangeHashedDictionary . cpp <nl> ppp b / src / Dictionaries / RangeHashedDictionary . cpp <nl> static bool operator < ( const RangeHashedDictionary : : Range & left , const RangeHash <nl> <nl> <nl> RangeHashedDictionary : : RangeHashedDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryRangeHashed ( DictionaryFactory & factory ) <nl> const String name = config . getString ( config_prefix + " . name " ) ; <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> const bool require_nonempty = config . getBool ( config_prefix + " . require_nonempty " , false ) ; <nl> - return std : : make_unique < RangeHashedDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> + return std : : make_unique < RangeHashedDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> } ; <nl> factory . registerLayout ( " range_hashed " , create_layout , false ) ; <nl> } <nl> mmm a / src / Dictionaries / RangeHashedDictionary . h <nl> ppp b / src / Dictionaries / RangeHashedDictionary . h <nl> class RangeHashedDictionary final : public IDictionaryBase <nl> { <nl> public : <nl> RangeHashedDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " RangeHashed " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return bytes_allocated ; } <nl> class RangeHashedDictionary final : public IDictionaryBase <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < RangeHashedDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty ) ; <nl> + return std : : make_shared < RangeHashedDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class RangeHashedDictionary final : public IDictionaryBase <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl> mmm a / src / Dictionaries / SSDCacheDictionary . cpp <nl> ppp b / src / Dictionaries / SSDCacheDictionary . cpp <nl> void SSDCacheStorage : : collectGarbage ( ) <nl> } <nl> <nl> SSDCacheDictionary : : SSDCacheDictionary ( <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> SSDCacheDictionary : : SSDCacheDictionary ( <nl> const size_t read_buffer_size_ , <nl> const size_t write_buffer_size_ , <nl> const size_t max_stored_keys_ ) <nl> - : name ( name_ ) <nl> + : IDictionary ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr ( std : : move ( source_ptr_ ) ) <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionarySSDCache ( DictionaryFactory & factory ) <nl> <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> return std : : make_unique < SSDCacheDictionary > ( <nl> - name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , path , <nl> + StorageID { " " , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , path , <nl> max_partitions_count , file_size / block_size , block_size , <nl> read_buffer_size / block_size , write_buffer_size / block_size , <nl> max_stored_keys ) ; <nl> mmm a / src / Dictionaries / SSDCacheDictionary . h <nl> ppp b / src / Dictionaries / SSDCacheDictionary . h <nl> class SSDCacheDictionary final : public IDictionary <nl> { <nl> public : <nl> SSDCacheDictionary ( <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> DictionaryLifetime dict_lifetime_ , <nl> class SSDCacheDictionary final : public IDictionary <nl> size_t write_buffer_size_ , <nl> size_t max_stored_keys_ ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return name ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return getName ( ) ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " SSDCache " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return storage . getBytesAllocated ( ) ; } <nl> class SSDCacheDictionary final : public IDictionary <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < SSDCacheDictionary > ( name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , path , <nl> + return std : : make_shared < SSDCacheDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , path , <nl> max_partitions_count , file_size , block_size , read_buffer_size , write_buffer_size , max_stored_keys ) ; <nl> } <nl> <nl> mmm a / src / Dictionaries / SSDComplexKeyCacheDictionary . cpp <nl> ppp b / src / Dictionaries / SSDComplexKeyCacheDictionary . cpp <nl> void SSDComplexKeyCacheStorage : : collectGarbage ( ) <nl> } <nl> <nl> SSDComplexKeyCacheDictionary : : SSDComplexKeyCacheDictionary ( <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> SSDComplexKeyCacheDictionary : : SSDComplexKeyCacheDictionary ( <nl> const size_t read_buffer_size_ , <nl> const size_t write_buffer_size_ , <nl> const size_t max_stored_keys_ ) <nl> - : name ( name_ ) <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr ( std : : move ( source_ptr_ ) ) <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionarySSDComplexKeyCache ( DictionaryFactory & factory ) <nl> <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> return std : : make_unique < SSDComplexKeyCacheDictionary > ( <nl> - name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , path , <nl> + StorageID { " " , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , path , <nl> max_partitions_count , file_size / block_size , block_size , <nl> read_buffer_size / block_size , write_buffer_size / block_size , <nl> max_stored_keys ) ; <nl> mmm a / src / Dictionaries / SSDComplexKeyCacheDictionary . h <nl> ppp b / src / Dictionaries / SSDComplexKeyCacheDictionary . h <nl> class SSDComplexKeyCacheDictionary final : public IDictionaryBase <nl> { <nl> public : <nl> SSDComplexKeyCacheDictionary ( <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> class SSDComplexKeyCacheDictionary final : public IDictionaryBase <nl> const size_t write_buffer_size_ , <nl> const size_t max_stored_keys_ ) ; <nl> <nl> - const std : : string & getDatabase ( ) const override { return name ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return getName ( ) ; } <nl> - <nl> std : : string getKeyDescription ( ) const { return dict_struct . getKeyDescription ( ) ; } <nl> <nl> std : : string getTypeName ( ) const override { return " SSDComplexKeyCache " ; } <nl> class SSDComplexKeyCacheDictionary final : public IDictionaryBase <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < SSDComplexKeyCacheDictionary > ( name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , path , <nl> + return std : : make_shared < SSDComplexKeyCacheDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , path , <nl> max_partitions_count , file_size , block_size , read_buffer_size , write_buffer_size , max_stored_keys ) ; <nl> } <nl> <nl> mmm a / src / Dictionaries / TrieDictionary . cpp <nl> ppp b / src / Dictionaries / TrieDictionary . cpp <nl> static void validateKeyTypes ( const DataTypes & key_types ) <nl> <nl> <nl> TrieDictionary : : TrieDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> bool require_nonempty_ ) <nl> - : database ( database_ ) <nl> - , name ( name_ ) <nl> - , full_name { database_ . empty ( ) ? name_ : ( database_ + " . " + name_ ) } <nl> + : IDictionaryBase ( dict_id_ ) <nl> , dict_struct ( dict_struct_ ) <nl> , source_ptr { std : : move ( source_ptr_ ) } <nl> , dict_lifetime ( dict_lifetime_ ) <nl> void registerDictionaryTrie ( DictionaryFactory & factory ) <nl> const DictionaryLifetime dict_lifetime { config , config_prefix + " . lifetime " } ; <nl> const bool require_nonempty = config . getBool ( config_prefix + " . require_nonempty " , false ) ; <nl> / / This is specialised trie for storing IPv4 and IPv6 prefixes . <nl> - return std : : make_unique < TrieDictionary > ( database , name , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> + return std : : make_unique < TrieDictionary > ( StorageID { database , name } , dict_struct , std : : move ( source_ptr ) , dict_lifetime , require_nonempty ) ; <nl> } ; <nl> factory . registerLayout ( " ip_trie " , create_layout , true ) ; <nl> } <nl> mmm a / src / Dictionaries / TrieDictionary . h <nl> ppp b / src / Dictionaries / TrieDictionary . h <nl> class TrieDictionary final : public IDictionaryBase <nl> { <nl> public : <nl> TrieDictionary ( <nl> - const std : : string & database_ , <nl> - const std : : string & name_ , <nl> + const StorageID & dict_id_ , <nl> const DictionaryStructure & dict_struct_ , <nl> DictionarySourcePtr source_ptr_ , <nl> const DictionaryLifetime dict_lifetime_ , <nl> class TrieDictionary final : public IDictionaryBase <nl> <nl> std : : string getKeyDescription ( ) const { return key_description ; } <nl> <nl> - const std : : string & getDatabase ( ) const override { return database ; } <nl> - const std : : string & getName ( ) const override { return name ; } <nl> - const std : : string & getFullName ( ) const override { return full_name ; } <nl> - <nl> std : : string getTypeName ( ) const override { return " Trie " ; } <nl> <nl> size_t getBytesAllocated ( ) const override { return bytes_allocated ; } <nl> class TrieDictionary final : public IDictionaryBase <nl> <nl> std : : shared_ptr < const IExternalLoadable > clone ( ) const override <nl> { <nl> - return std : : make_shared < TrieDictionary > ( database , name , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty ) ; <nl> + return std : : make_shared < TrieDictionary > ( dict_id , dict_struct , source_ptr - > clone ( ) , dict_lifetime , require_nonempty ) ; <nl> } <nl> <nl> const IDictionarySource * getSource ( ) const override { return source_ptr . get ( ) ; } <nl> class TrieDictionary final : public IDictionaryBase <nl> <nl> const std : : string database ; <nl> const std : : string name ; <nl> - const std : : string full_name ; <nl> const DictionaryStructure dict_struct ; <nl> const DictionarySourcePtr source_ptr ; <nl> const DictionaryLifetime dict_lifetime ; <nl>
add StorageID to IDictionaryBase 1
ClickHouse/ClickHouse
1f6ffb08e465f1e224d389065f5d23bb738ee575
2020-07-14T18:46:29Z
mmm a / . bazelrc <nl> ppp b / . bazelrc <nl> build : rbe_cpu_linux - - host_platform = " @ org_tensorflow / / third_party / toolchains : rbe <nl> build : rbe_cpu_linux - - platforms = " @ org_tensorflow / / third_party / toolchains : rbe_ubuntu16 . 04 - manylinux2010 " <nl> <nl> build : rbe_linux_cuda_nvcc - - config = rbe_linux <nl> - build : rbe_linux_cuda_nvcc - - crosstool_top = " / / third_party / toolchains / preconfig / ubuntu16 . 04 / gcc7_manylinux2010 - nvcc - cuda10 . 1 : toolchain " <nl> - build : rbe_linux_cuda_nvcc - - extra_toolchains = " / / third_party / toolchains / preconfig / ubuntu16 . 04 / gcc7_manylinux2010 - nvcc - cuda10 . 1 : toolchain - linux - x86_64 " <nl> - build : rbe_linux_cuda_nvcc - - extra_execution_platforms = " @ org_tensorflow / / third_party / toolchains : rbe_cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 , @ org_tensorflow / / third_party / toolchains : rbe_cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 " <nl> - build : rbe_linux_cuda_nvcc - - host_platform = " @ org_tensorflow / / third_party / toolchains : rbe_cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 " <nl> - build : rbe_linux_cuda_nvcc - - platforms = " @ org_tensorflow / / third_party / toolchains : rbe_cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 " <nl> - build : rbe_linux_cuda_nvcc - - repo_env = TF_CUDA_CONFIG_REPO = " @ org_tensorflow / / third_party / toolchains / preconfig / ubuntu16 . 04 / cuda10 . 1 - cudnn7 " <nl> - build : rbe_linux_cuda_nvcc - - repo_env = TF_TENSORRT_CONFIG_REPO = " @ org_tensorflow / / third_party / toolchains / preconfig / ubuntu16 . 04 / tensorrt6 . 0 " <nl> + build : rbe_linux_cuda_nvcc - - crosstool_top = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_cuda / / crosstool : toolchain " <nl> + build : rbe_linux_cuda_nvcc - - extra_toolchains = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_cuda / / crosstool : toolchain - linux - x86_64 " <nl> + build : rbe_linux_cuda_nvcc - - extra_execution_platforms = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_platform / / : platform " <nl> + build : rbe_linux_cuda_nvcc - - host_platform = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_platform / / : platform " <nl> + build : rbe_linux_cuda_nvcc - - platforms = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_platform / / : platform " <nl> + build : rbe_linux_cuda_nvcc - - repo_env = TF_CUDA_CONFIG_REPO = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_cuda " <nl> + build : rbe_linux_cuda_nvcc - - repo_env = TF_TENSORRT_CONFIG_REPO = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_tensorrt " <nl> + build : rbe_linux_cuda_nvcc - - repo_env = TF_NCCL_CONFIG_REPO = " @ ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0_config_nccl " <nl> build : rbe_linux_cuda_nvcc - - repo_env = TF_NEED_TENSORRT = 1 <nl> build : rbe_linux_cuda_nvcc - - repo_env = TF_CUDA_VERSION = 10 <nl> build : rbe_linux_cuda_nvcc - - repo_env = TF_CUDNN_VERSION = 7 <nl> mmm a / third_party / toolchains / remote_config / configs . bzl <nl> ppp b / third_party / toolchains / remote_config / configs . bzl <nl> def initialize_rbe_configs ( ) : <nl> tensorrt_version = " 5 . 1 " , <nl> ) <nl> <nl> + tensorflow_rbe_config ( <nl> + name = " ubuntu16 . 04 - py3 - gcc7_manylinux2010 - cuda10 . 1 - cudnn7 - tensorrt6 . 0 " , <nl> + compiler = " / dt7 / usr / bin / gcc " , <nl> + compiler_prefix = " / usr / bin " , <nl> + cuda_version = " 10 . 1 " , <nl> + cudnn_version = " 7 " , <nl> + os = " ubuntu16 . 04 - manylinux2010 " , <nl> + python_version = " 3 " , <nl> + tensorrt_install_path = " / usr " , <nl> + tensorrt_version = " 6 . 0 " , <nl> + ) <nl> + <nl> tensorflow_rbe_config ( <nl> name = " ubuntu16 . 04 - py3_opt - gcc5 - rocm " , <nl> compiler = " gcc " , <nl> mmm a / third_party / toolchains / remote_config / containers . bzl <nl> ppp b / third_party / toolchains / remote_config / containers . bzl <nl> containers = { <nl> " digest " : container_digests [ " cuda10 . 0 - cudnn7 - ubuntu16 . 04 - manylinux2010 " ] , <nl> } , <nl> <nl> + # Built with / / tensorflow / tools / ci_build / Dockerfile . rbe . cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 . <nl> + " cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 " : { <nl> + " registry " : " gcr . io " , <nl> + " repository " : " tensorflow - testing / nosla - cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 " , <nl> + " digest " : container_digests [ " cuda10 . 1 - cudnn7 - ubuntu16 . 04 - manylinux2010 " ] , <nl> + } , <nl> + <nl> # Built with / / tensorflow / tools / ci_build / Dockerfile . rbe . rocm - ubuntu16 . 04 <nl> " rocm - ubuntu16 . 04 " : { <nl> " registry " : " gcr . io " , <nl>
Fix bazelrc configuration that still uses preconfig instead of remote config .
tensorflow/tensorflow
24d5cb4edc52f267834d3f73b035d1820cec22b4
2020-02-26T18:22:50Z