diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / src / csharp / Grpc . Microbenchmarks / UnaryCallOverheadBenchmark . cs <nl> ppp b / src / csharp / Grpc . Microbenchmarks / UnaryCallOverheadBenchmark . cs <nl> namespace Grpc . Microbenchmarks <nl> public class UnaryCallOverheadBenchmark <nl> { <nl> private static readonly Task < string > CompletedString = Task . FromResult ( " " ) ; <nl> - private static readonly byte [ ] EmptyBlob = new byte [ 0 ] ; <nl> - private static readonly Marshaller < string > EmptyMarshaller = new Marshaller < string > ( _ = > EmptyBlob , _ = > " " ) ; <nl> - private static readonly Method < string , string > PingMethod = new Method < string , string > ( MethodType . Unary , nameof ( PingBenchmark ) , " Ping " , EmptyMarshaller , EmptyMarshaller ) ; <nl> + private static readonly Marshaller < byte [ ] > IdentityMarshaller = new Marshaller < byte [ ] > ( msg = > msg , payload = > payload ) ; <nl> + private static readonly Method < byte [ ] , byte [ ] > PingMethod = new Method < byte [ ] , byte [ ] > ( MethodType . Unary , nameof ( PingBenchmark ) , " Ping " , IdentityMarshaller , IdentityMarshaller ) ; <nl> + <nl> + private int payloadSize ; <nl> + private byte [ ] payload ; <nl> + <nl> + / / size of payload that is sent as request and received as response . <nl> + [ Params ( 0 , 1 , 10 , 100 , 1000 ) ] <nl> + public int PayloadSize <nl> + { <nl> + get { return payloadSize ; } <nl> + set <nl> + { <nl> + payloadSize = value ; <nl> + payload = new byte [ value ] ; <nl> + } <nl> + } <nl> <nl> [ Benchmark ] <nl> - public string SyncUnaryCallOverhead ( ) <nl> + public byte [ ] SyncUnaryCallOverhead ( ) <nl> { <nl> - return client . Ping ( " " , new CallOptions ( ) ) ; <nl> + return client . Ping ( payload , new CallOptions ( ) ) ; <nl> } <nl> <nl> Channel channel ; <nl> class PingClient : LiteClientBase <nl> { <nl> public PingClient ( CallInvoker callInvoker ) : base ( callInvoker ) { } <nl> <nl> - public string Ping ( string request , CallOptions options ) <nl> + public byte [ ] Ping ( byte [ ] request , CallOptions options ) <nl> { <nl> return CallInvoker . BlockingUnaryCall ( PingMethod , null , options , request ) ; <nl> } <nl>
Merge pull request from jtattermusch / parametrized_unary_call_overhead
grpc/grpc
139a556431c7ce8a25158d5a5b15aabd28e3f020
2019-07-31T14:10:51Z
mmm a / modules / common / vehicle_state / vehicle_state_provider . cc <nl> ppp b / modules / common / vehicle_state / vehicle_state_provider . cc <nl> const VehicleState & VehicleStateProvider : : vehicle_state ( ) const { <nl> math : : Vec2d VehicleStateProvider : : EstimateFuturePosition ( const double t ) const { <nl> Eigen : : Vector3d vec_distance ( 0 . 0 , 0 . 0 , 0 . 0 ) ; <nl> double v = vehicle_state_ . linear_velocity ( ) ; <nl> - if ( vehicle_state_ . gear ( ) = = canbus : : Chassis : : GEAR_REVERSE ) { <nl> - v = - vehicle_state_ . linear_velocity ( ) ; <nl> - } <nl> / / Predict distance travel vector <nl> if ( std : : fabs ( vehicle_state_ . angular_velocity ( ) ) < 0 . 0001 ) { <nl> vec_distance [ 0 ] = 0 . 0 ; <nl>
Common : keep consistent with reverse speed change in vehicle_state
ApolloAuto/apollo
df661bdbdaac7afcda9d6721a902a62e0ba653f0
2018-12-19T19:41:14Z
mmm a / lib / IDE / CodeCompletion . cpp <nl> ppp b / lib / IDE / CodeCompletion . cpp <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> } <nl> } <nl> <nl> - bool isModuleLoaded ( ASTContext & Ctx , clang : : Module * M ) { <nl> - return Ctx . getLoadedModule ( llvm : : makeArrayRef ( <nl> - std : : make_pair ( Ctx . getIdentifier ( M - > getTopLevelModuleName ( ) ) , <nl> - SourceLoc ( ) ) ) ) ; <nl> + void collectImportedModules ( llvm : : StringSet < > & ImportedModules ) { <nl> + SmallVector < Module : : ImportedModule , 16 > Imported ; <nl> + SmallVector < Module : : ImportedModule , 16 > FurtherImported ; <nl> + CurrDeclContext - > getParentSourceFile ( ) - > getImportedModules ( Imported , <nl> + Module : : ImportFilter : : All ) ; <nl> + while ( ! Imported . empty ( ) ) { <nl> + ModuleDecl * MD = Imported . front ( ) . second ; <nl> + Imported . erase ( Imported . begin ( ) ) ; <nl> + ImportedModules . insert ( MD - > getNameStr ( ) ) ; <nl> + FurtherImported . clear ( ) ; <nl> + MD - > getImportedModules ( FurtherImported , Module : : ImportFilter : : Public ) ; <nl> + for ( auto SubMod : FurtherImported ) { <nl> + Imported . push_back ( SubMod ) ; <nl> + } <nl> + } <nl> } <nl> <nl> void addImportModuleNames ( ) { <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> return LHS - > getTopLevelModuleName ( ) . compare_lower ( <nl> RHS - > getTopLevelModuleName ( ) ) < 0 ; <nl> } ) ; <nl> + llvm : : StringSet < > ImportedModules ; <nl> + collectImportedModules ( ImportedModules ) ; <nl> for ( auto * M : Modules ) { <nl> if ( M - > isAvailable ( ) & & <nl> ! M - > getTopLevelModuleName ( ) . startswith ( " _ " ) & & <nl> class CompletionLookup final : public swift : : VisibleDeclConsumer { <nl> Builder . addTypeAnnotation ( " Module " ) ; <nl> <nl> / / Imported modules are not recommended . <nl> - Builder . setNotRecommended ( isModuleLoaded ( CurrDeclContext - > <nl> - getASTContext ( ) , M ) ) ; <nl> + Builder . setNotRecommended ( ImportedModules . count ( MD - > getNameStr ( ) ) ! = 0 ) ; <nl> } <nl> } <nl> } <nl> new file mode 100644 <nl> index 000000000000 . . a8249d2b7061 <nl> mmm / dev / null <nl> ppp b / test / IDE / Inputs / complete_import_multifile2 . swift <nl> <nl> + <nl> + import Foo <nl> + import Foo . FooSub <nl> new file mode 100644 <nl> index 000000000000 . . 4f7f26e860cd <nl> mmm / dev / null <nl> ppp b / test / IDE / complete_import_multifile1 . swift <nl> <nl> + / / RUN : % target - swift - ide - test - code - completion - source - filename % s - F % S / Inputs / mock - sdk - code - completion - token = CLANG_IMPORT1 | FileCheck % s - check - prefix = CLANG_IMPORT1 <nl> + / / RUN : % target - swift - ide - test - code - completion - source - filename % s - second - source - filename % S / Inputs / complete_import_multifile2 . swift - F % S / Inputs / mock - sdk - code - completion - token = CLANG_IMPORT1 | FileCheck % s - check - prefix = CLANG_IMPORT1 <nl> + / / REQUIRES : objc_interop <nl> + <nl> + import # ^ CLANG_IMPORT1 ^ # <nl> + <nl> + / / CLANG_IMPORT1 : Begin completions <nl> + / / CLANG_IMPORT1 - DAG : Decl [ Module ] / OtherModule [ Foo ] : Foo [ # Module # ] ; name = Foo <nl> + / / CLANG_IMPORT1 - DAG : Decl [ Module ] / OtherModule [ FooHelper ] : FooHelper [ # Module # ] ; name = FooHelper <nl> + / / CLANG_IMPORT1 - DAG : Decl [ Module ] / OtherModule [ Bar ] : Bar [ # Module # ] ; name = Bar <nl> + / / CLANG_IMPORT1 - NOT : SwiftShims <nl>
[ CodeCompletion ] Check the module visibility properly to handle the multi - file case . rdar : / / 24818863
apple/swift
218010afb94bcb120b9648440c35708c536cb301
2016-03-25T00:44:46Z
mmm a / third - party <nl> ppp b / third - party <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 201798688461884097fff48d2c36d75c31d649d5 <nl> + Subproject commit dff6479636358acb3c1c9045c8880a2fea1aaaa4 <nl>
Fix build on Debian - ish systems
facebook/hhvm
1760c55c5b203a58449306654ac0db006ef9780e
2015-04-07T21:30:37Z
mmm a / atom / browser / api / atom_api_web_contents . cc <nl> ppp b / atom / browser / api / atom_api_web_contents . cc <nl> void OnCapturePageDone ( util : : Promise promise , const SkBitmap & bitmap ) { <nl> <nl> } / / namespace <nl> <nl> - struct WebContents : : FrameDispatchHelper { <nl> - WebContents * api_web_contents ; <nl> - content : : RenderFrameHost * rfh ; <nl> - <nl> - bool Send ( IPC : : Message * msg ) { return rfh - > Send ( msg ) ; } <nl> - <nl> - void OnSetTemporaryZoomLevel ( double level , IPC : : Message * reply_msg ) { <nl> - api_web_contents - > OnSetTemporaryZoomLevel ( rfh , level , reply_msg ) ; <nl> - } <nl> - <nl> - void OnGetZoomLevel ( IPC : : Message * reply_msg ) { <nl> - api_web_contents - > OnGetZoomLevel ( rfh , reply_msg ) ; <nl> - } <nl> - } ; <nl> - <nl> WebContents : : WebContents ( v8 : : Isolate * isolate , <nl> content : : WebContents * web_contents ) <nl> : content : : WebContentsObserver ( web_contents ) , type_ ( Type : : REMOTE ) { <nl> bool WebContents : : OnMessageReceived ( const IPC : : Message & message ) { <nl> bool WebContents : : OnMessageReceived ( const IPC : : Message & message , <nl> content : : RenderFrameHost * frame_host ) { <nl> bool handled = true ; <nl> - FrameDispatchHelper helper = { this , frame_host } ; <nl> IPC_BEGIN_MESSAGE_MAP_WITH_PARAM ( WebContents , message , frame_host ) <nl> - IPC_MESSAGE_FORWARD_DELAY_REPLY ( <nl> - AtomFrameHostMsg_SetTemporaryZoomLevel , & helper , <nl> - FrameDispatchHelper : : OnSetTemporaryZoomLevel ) <nl> - IPC_MESSAGE_FORWARD_DELAY_REPLY ( AtomFrameHostMsg_GetZoomLevel , & helper , <nl> - FrameDispatchHelper : : OnGetZoomLevel ) <nl> # if defined ( TOOLKIT_VIEWS ) <nl> IPC_MESSAGE_HANDLER ( AtomAutofillFrameHostMsg_ShowPopup , ShowAutofillPopup ) <nl> IPC_MESSAGE_HANDLER ( AtomAutofillFrameHostMsg_HidePopup , HideAutofillPopup ) <nl> double WebContents : : GetZoomFactor ( ) const { <nl> return content : : ZoomLevelToZoomFactor ( level ) ; <nl> } <nl> <nl> - void WebContents : : OnSetTemporaryZoomLevel ( content : : RenderFrameHost * rfh , <nl> - double level , <nl> - IPC : : Message * reply_msg ) { <nl> + void WebContents : : SetTemporaryZoomLevel ( double level ) { <nl> zoom_controller_ - > SetTemporaryZoomLevel ( level ) ; <nl> - double new_level = zoom_controller_ - > GetZoomLevel ( ) ; <nl> - AtomFrameHostMsg_SetTemporaryZoomLevel : : WriteReplyParams ( reply_msg , <nl> - new_level ) ; <nl> - rfh - > Send ( reply_msg ) ; <nl> } <nl> <nl> - void WebContents : : OnGetZoomLevel ( content : : RenderFrameHost * rfh , <nl> - IPC : : Message * reply_msg ) { <nl> - AtomFrameHostMsg_GetZoomLevel : : WriteReplyParams ( reply_msg , GetZoomLevel ( ) ) ; <nl> - rfh - > Send ( reply_msg ) ; <nl> + void WebContents : : DoGetZoomLevel ( DoGetZoomLevelCallback callback ) { <nl> + std : : move ( callback ) . Run ( GetZoomLevel ( ) ) ; <nl> } <nl> <nl> v8 : : Local < v8 : : Value > WebContents : : GetPreloadPath ( v8 : : Isolate * isolate ) const { <nl> mmm a / atom / browser / api / atom_api_web_contents . h <nl> ppp b / atom / browser / api / atom_api_web_contents . h <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> # endif <nl> <nl> private : <nl> - struct FrameDispatchHelper ; <nl> AtomBrowserContext * GetBrowserContext ( ) const ; <nl> <nl> / / Binds the given request for the ElectronBrowser API . When the <nl> class WebContents : public mate : : TrackableObject < WebContents > , <nl> void MessageHost ( const std : : string & channel , base : : Value arguments ) override ; <nl> void UpdateDraggableRegions ( <nl> std : : vector < mojom : : DraggableRegionPtr > regions ) override ; <nl> + void SetTemporaryZoomLevel ( double level ) override ; <nl> + void DoGetZoomLevel ( DoGetZoomLevelCallback callback ) override ; <nl> <nl> / / Called when we receive a CursorChange message from chromium . <nl> void OnCursorChange ( const content : : WebCursor & cursor ) ; <nl> <nl> - / / Called when received a synchronous message from renderer to <nl> - / / set temporary zoom level . <nl> - void OnSetTemporaryZoomLevel ( content : : RenderFrameHost * frame_host , <nl> - double level , <nl> - IPC : : Message * reply_msg ) ; <nl> - <nl> / / Called when received a synchronous message from renderer to <nl> / / get the zoom level . <nl> void OnGetZoomLevel ( content : : RenderFrameHost * frame_host , <nl> mmm a / atom / common / api / api . mojom <nl> ppp b / atom / common / api / api . mojom <nl> interface ElectronBrowser { <nl> <nl> UpdateDraggableRegions ( <nl> array < DraggableRegion > regions ) ; <nl> + <nl> + SetTemporaryZoomLevel ( double zoom_level ) ; <nl> + <nl> + [ Sync ] <nl> + DoGetZoomLevel ( ) = > ( double result ) ; <nl> } ; <nl> mmm a / atom / common / api / api_messages . h <nl> ppp b / atom / common / api / api_messages . h <nl> <nl> # include " base / strings / string16 . h " <nl> # include " base / values . h " <nl> # include " content / public / common / common_param_traits . h " <nl> - # include " content / public / common / referrer . h " <nl> # include " ipc / ipc_message_macros . h " <nl> - # include " ipc / ipc_platform_file . h " <nl> # include " ui / gfx / geometry / rect_f . h " <nl> # include " ui / gfx / ipc / gfx_param_traits . h " <nl> - # include " url / gurl . h " <nl> - <nl> - / / The message starter should be declared in ipc / ipc_message_start . h . Since <nl> - / / we don ' t want to patch Chromium , we just pretend to be Content Shell . <nl> <nl> # define IPC_MESSAGE_START ElectronMsgStart <nl> <nl> IPC_MESSAGE_ROUTED1 ( AtomAutofillFrameMsg_AcceptSuggestion , <nl> <nl> / / Update renderer process preferences . <nl> IPC_MESSAGE_CONTROL1 ( AtomMsg_UpdatePreferences , base : : ListValue ) <nl> - <nl> - / / Sent by renderer to set the temporary zoom level . <nl> - IPC_SYNC_MESSAGE_ROUTED1_1 ( AtomFrameHostMsg_SetTemporaryZoomLevel , <nl> - double / * zoom level * / , <nl> - double / * result * / ) <nl> - <nl> - / / Sent by renderer to get the zoom level . <nl> - IPC_SYNC_MESSAGE_ROUTED0_1 ( AtomFrameHostMsg_GetZoomLevel , double / * result * / ) <nl> mmm a / atom / renderer / api / atom_api_web_frame . cc <nl> ppp b / atom / renderer / api / atom_api_web_frame . cc <nl> <nl> # include < utility > <nl> # include < vector > <nl> <nl> + # include " atom / common / api / api . mojom . h " <nl> # include " atom / common / api / api_messages . h " <nl> # include " atom / common / api / event_emitter_caller . h " <nl> # include " atom / common / native_mate_converters / blink_converter . h " <nl> <nl> # include " content / public / renderer / render_view . h " <nl> # include " native_mate / dictionary . h " <nl> # include " native_mate / object_template_builder . h " <nl> + # include " services / service_manager / public / cpp / interface_provider . h " <nl> # include " third_party / blink / public / platform / web_cache . h " <nl> # include " third_party / blink / public / platform / web_isolated_world_info . h " <nl> # include " third_party / blink / public / web / web_custom_element . h " <nl> void SetName ( v8 : : Local < v8 : : Value > window , const std : : string & name ) { <nl> blink : : WebString : : FromUTF8 ( name ) ) ; <nl> } <nl> <nl> - double SetZoomLevel ( v8 : : Local < v8 : : Value > window , double level ) { <nl> - double result = 0 . 0 ; <nl> + void SetZoomLevel ( v8 : : Local < v8 : : Value > window , double level ) { <nl> content : : RenderFrame * render_frame = GetRenderFrame ( window ) ; <nl> - render_frame - > Send ( new AtomFrameHostMsg_SetTemporaryZoomLevel ( <nl> - render_frame - > GetRoutingID ( ) , level , & result ) ) ; <nl> - return result ; <nl> + mojom : : ElectronBrowserPtr browser_ptr ; <nl> + render_frame - > GetRemoteInterfaces ( ) - > GetInterface ( <nl> + mojo : : MakeRequest ( & browser_ptr ) ) ; <nl> + browser_ptr - > SetTemporaryZoomLevel ( level ) ; <nl> } <nl> <nl> double GetZoomLevel ( v8 : : Local < v8 : : Value > window ) { <nl> double result = 0 . 0 ; <nl> content : : RenderFrame * render_frame = GetRenderFrame ( window ) ; <nl> - render_frame - > Send ( <nl> - new AtomFrameHostMsg_GetZoomLevel ( render_frame - > GetRoutingID ( ) , & result ) ) ; <nl> + mojom : : ElectronBrowserPtr browser_ptr ; <nl> + render_frame - > GetRemoteInterfaces ( ) - > GetInterface ( <nl> + mojo : : MakeRequest ( & browser_ptr ) ) ; <nl> + browser_ptr - > DoGetZoomLevel ( & result ) ; <nl> return result ; <nl> } <nl> <nl> - double SetZoomFactor ( v8 : : Local < v8 : : Value > window , double factor ) { <nl> - return blink : : WebView : : ZoomLevelToZoomFactor ( <nl> - SetZoomLevel ( window , blink : : WebView : : ZoomFactorToZoomLevel ( factor ) ) ) ; <nl> + void SetZoomFactor ( v8 : : Local < v8 : : Value > window , double factor ) { <nl> + SetZoomLevel ( window , blink : : WebView : : ZoomFactorToZoomLevel ( factor ) ) ; <nl> } <nl> <nl> double GetZoomFactor ( v8 : : Local < v8 : : Value > window ) { <nl>
refactor : mojofy zoom api ( )
electron/electron
d1371c5dd07cda307f9963e1e87a317dc7ef4040
2019-06-04T01:18:22Z
mmm a / platform / linuxbsd / display_server_x11 . cpp <nl> ppp b / platform / linuxbsd / display_server_x11 . cpp <nl> void DisplayServerX11 : : _send_window_event ( const WindowData & wd , WindowEvent p_ev <nl> void DisplayServerX11 : : process_events ( ) { <nl> _THREAD_SAFE_METHOD_ <nl> <nl> + if ( app_focused ) { <nl> + / / verify that one of the windows has focus , else send focus out notification <nl> + bool focus_found = false ; <nl> + for ( Map < WindowID , WindowData > : : Element * E = windows . front ( ) ; E ; E = E - > next ( ) ) { <nl> + if ( E - > get ( ) . focused ) { <nl> + focus_found = true ; <nl> + } <nl> + } <nl> + <nl> + if ( ! focus_found ) { <nl> + if ( OS : : get_singleton ( ) - > get_main_loop ( ) ) { <nl> + OS : : get_singleton ( ) - > get_main_loop ( ) - > notification ( MainLoop : : NOTIFICATION_APPLICATION_FOCUS_OUT ) ; <nl> + } <nl> + <nl> + app_focused = false ; <nl> + } <nl> + } <nl> + <nl> do_mouse_warp = false ; <nl> <nl> / / Is the current mouse mode one where it needs to be grabbed . <nl> void DisplayServerX11 : : process_events ( ) { <nl> break ; <nl> <nl> case NoExpose : <nl> - minimized = true ; <nl> + windows [ window_id ] . minimized = true ; <nl> break ; <nl> <nl> case VisibilityNotify : { <nl> XVisibilityEvent * visibility = ( XVisibilityEvent * ) & event ; <nl> - minimized = ( visibility - > state = = VisibilityFullyObscured ) ; <nl> + windows [ window_id ] . minimized = ( visibility - > state = = VisibilityFullyObscured ) ; <nl> } break ; <nl> case LeaveNotify : { <nl> if ( ! mouse_mode_grab ) { <nl> void DisplayServerX11 : : process_events ( ) { <nl> } <nl> } break ; <nl> case FocusIn : <nl> - minimized = false ; <nl> - window_has_focus = true ; <nl> + windows [ window_id ] . focused = true ; <nl> _send_window_event ( windows [ window_id ] , WINDOW_EVENT_FOCUS_IN ) ; <nl> - window_focused = true ; <nl> <nl> if ( mouse_mode_grab ) { <nl> / / Show and update the cursor if confined and the window regained focus . <nl> void DisplayServerX11 : : process_events ( ) { <nl> if ( windows [ window_id ] . xic ) { <nl> XSetICFocus ( windows [ window_id ] . xic ) ; <nl> } <nl> + <nl> + if ( ! app_focused ) { <nl> + if ( OS : : get_singleton ( ) - > get_main_loop ( ) ) { <nl> + OS : : get_singleton ( ) - > get_main_loop ( ) - > notification ( MainLoop : : NOTIFICATION_APPLICATION_FOCUS_IN ) ; <nl> + } <nl> + app_focused = true ; <nl> + } <nl> break ; <nl> <nl> case FocusOut : <nl> - window_has_focus = false ; <nl> + windows [ window_id ] . focused = false ; <nl> Input : : get_singleton ( ) - > release_pressed_events ( ) ; <nl> _send_window_event ( windows [ window_id ] , WINDOW_EVENT_FOCUS_OUT ) ; <nl> - window_focused = false ; <nl> <nl> if ( mouse_mode_grab ) { <nl> for ( Map < WindowID , WindowData > : : Element * E = windows . front ( ) ; E ; E = E - > next ( ) ) { <nl> void DisplayServerX11 : : process_events ( ) { <nl> Point2i new_center = pos ; <nl> pos = last_mouse_pos + xi . relative_motion ; <nl> center = new_center ; <nl> - do_mouse_warp = window_has_focus ; / / warp the cursor if we ' re focused in <nl> + do_mouse_warp = windows [ window_id ] . focused ; / / warp the cursor if we ' re focused in <nl> } <nl> <nl> if ( ! last_mouse_pos_valid ) { <nl> void DisplayServerX11 : : process_events ( ) { <nl> / / Don ' t propagate the motion event unless we have focus <nl> / / this is so that the relative motion doesn ' t get messed up <nl> / / after we regain focus . <nl> - if ( window_has_focus | | ! mouse_mode_grab ) { <nl> + if ( windows [ window_id ] . focused | | ! mouse_mode_grab ) { <nl> Input : : get_singleton ( ) - > accumulate_input_event ( mm ) ; <nl> } <nl> <nl> DisplayServerX11 : : DisplayServerX11 ( const String & p_rendering_driver , WindowMode <nl> <nl> requested = None ; <nl> <nl> - window_has_focus = true ; / / Set focus to true at init <nl> - <nl> / * if ( p_desired . layered ) { <nl> set_window_per_pixel_transparency_enabled ( true ) ; <nl> } * / <nl> mmm a / platform / linuxbsd / display_server_x11 . h <nl> ppp b / platform / linuxbsd / display_server_x11 . h <nl> class DisplayServerX11 : public DisplayServer { <nl> bool borderless = false ; <nl> bool resize_disabled = false ; <nl> Vector2i last_position_before_fs ; <nl> + bool focused = false ; <nl> + bool minimized = false ; <nl> } ; <nl> <nl> Map < WindowID , WindowData > windows ; <nl> class DisplayServerX11 : public DisplayServer { <nl> uint64_t last_click_ms ; <nl> int last_click_button_index ; <nl> uint32_t last_button_state ; <nl> + bool app_focused = false ; <nl> <nl> struct { <nl> int opcode ; <nl> class DisplayServerX11 : public DisplayServer { <nl> <nl> void _handle_key_event ( WindowID p_window , XKeyEvent * p_event , bool p_echo = false ) ; <nl> <nl> - bool minimized ; <nl> - bool window_has_focus ; <nl> + / / bool minimized ; <nl> + / / bool window_has_focus ; <nl> bool do_mouse_warp ; <nl> <nl> const char * cursor_theme ; <nl> class DisplayServerX11 : public DisplayServer { <nl> bool layered_window ; <nl> <nl> String rendering_driver ; <nl> - bool window_focused ; <nl> + / / bool window_focused ; <nl> / / void set_wm_border ( bool p_enabled ) ; <nl> void set_wm_fullscreen ( bool p_enabled ) ; <nl> void set_wm_above ( bool p_enabled ) ; <nl> mmm a / scene / main / viewport . cpp <nl> ppp b / scene / main / viewport . cpp <nl> void Viewport : : input ( const Ref < InputEvent > & p_event , bool p_local_coords ) { <nl> return ; <nl> } <nl> <nl> + if ( ! _can_consume_input_events ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> if ( ! is_input_handled ( ) ) { <nl> get_tree ( ) - > _call_input_pause ( input_group , " _input " , ev , this ) ; / / not a bug , must happen before GUI , order is _input - > gui input - > _unhandled input <nl> } <nl> void Viewport : : input ( const Ref < InputEvent > & p_event , bool p_local_coords ) { <nl> void Viewport : : unhandled_input ( const Ref < InputEvent > & p_event , bool p_local_coords ) { <nl> ERR_FAIL_COND ( ! is_inside_tree ( ) ) ; <nl> <nl> - if ( disable_input ) { <nl> + if ( disable_input | | ! _can_consume_input_events ( ) ) { <nl> return ; <nl> } <nl> <nl> mmm a / scene / main / viewport . h <nl> ppp b / scene / main / viewport . h <nl> class Viewport : public Node { <nl> bool _sub_windows_forward_input ( const Ref < InputEvent > & p_event ) ; <nl> SubWindowResize _sub_window_get_resize_margin ( Window * p_subwindow , const Point2 & p_point ) ; <nl> <nl> + virtual bool _can_consume_input_events ( ) const { return true ; } <nl> + <nl> protected : <nl> void _set_size ( const Size2i & p_size , const Size2i & p_size_2d_override , const Rect2i & p_to_screen_rect , const Transform2D & p_stretch_transform , bool p_allocated ) ; <nl> <nl> mmm a / scene / main / window . cpp <nl> ppp b / scene / main / window . cpp <nl> void Window : : child_controls_changed ( ) { <nl> call_deferred ( " _update_child_controls " ) ; <nl> } <nl> <nl> + bool Window : : _can_consume_input_events ( ) const { <nl> + return exclusive_child = = nullptr ; <nl> + } <nl> + <nl> void Window : : _window_input ( const Ref < InputEvent > & p_ev ) { <nl> if ( Engine : : get_singleton ( ) - > is_editor_hint ( ) & & ( Object : : cast_to < InputEventJoypadButton > ( p_ev . ptr ( ) ) | | Object : : cast_to < InputEventJoypadMotion > ( * p_ev ) ) ) { <nl> return ; / / avoid joy input on editor <nl> void Window : : _window_input ( const Ref < InputEvent > & p_ev ) { <nl> if ( exclusive_child ! = nullptr ) { <nl> exclusive_child - > grab_focus ( ) ; <nl> <nl> - return ; / / has an exclusive child , can ' t get events until child is closed <nl> + if ( ! is_embedding_subwindows ( ) ) { / / not embedding , no need for event <nl> + return ; <nl> + } <nl> } <nl> <nl> emit_signal ( SceneStringNames : : get_singleton ( ) - > window_input , p_ev ) ; <nl> + <nl> input ( p_ev ) ; <nl> if ( ! is_input_handled ( ) ) { <nl> unhandled_input ( p_ev ) ; <nl> mmm a / scene / main / window . h <nl> ppp b / scene / main / window . h <nl> class Window : public Viewport { <nl> void _window_drop_files ( const Vector < String > & p_files ) ; <nl> void _rect_changed_callback ( const Rect2i & p_callback ) ; <nl> void _event_callback ( DisplayServer : : WindowEvent p_event ) ; <nl> + virtual bool _can_consume_input_events ( ) const ; <nl> <nl> protected : <nl> Viewport * _get_embedder ( ) const ; <nl>
Ensure embedded mode works again
godotengine/godot
239942cfefc51a907b3fe7eff72818b4a7732726
2020-07-01T12:27:43Z
mmm a / lib / ClangImporter / ImportDecl . cpp <nl> ppp b / lib / ClangImporter / ImportDecl . cpp <nl> getSwiftStdlibType ( const clang : : TypedefNameDecl * D , <nl> case clang : : TargetInfo : : VoidPtrBuiltinVaList : <nl> case clang : : TargetInfo : : PowerABIBuiltinVaList : <nl> case clang : : TargetInfo : : AAPCSABIBuiltinVaList : <nl> + case clang : : TargetInfo : : HexagonBuiltinVaList : <nl> assert ( ClangCtx . getTypeSize ( ClangCtx . VoidPtrTy ) = = ClangTypeSize & & <nl> " expected va_list type to be sizeof ( void * ) " ) ; <nl> break ; <nl> mmm a / lib / Serialization / ModuleFile . cpp <nl> ppp b / lib / Serialization / ModuleFile . cpp <nl> class ModuleFile : : DerivativeFunctionConfigTableInfo { <nl> while ( data < limit ) { <nl> DeclID genSigId = endian : : readNext < uint32_t , little , unaligned > ( data ) ; <nl> int32_t nameLength = endian : : readNext < int32_t , little , unaligned > ( data ) ; <nl> - StringRef mangledName ( reinterpret_cast < const char * > ( data ) , nameLength ) ; <nl> + std : : string mangledName ( reinterpret_cast < const char * > ( data ) , nameLength ) ; <nl> data + = nameLength ; <nl> result . push_back ( { mangledName , genSigId } ) ; <nl> } <nl> mmm a / lib / Serialization / Serialization . cpp <nl> ppp b / lib / Serialization / Serialization . cpp <nl> void Serializer : : writeAST ( ModuleOrSourceFile DC ) { <nl> DerivativeFunctionConfigTable derivativeConfigs ; <nl> for ( auto entry : uniquedDerivativeConfigs ) { <nl> for ( auto config : entry . second ) { <nl> - auto paramIndices = config . first . str ( ) ; <nl> + std : : string paramIndices = config . first . str ( ) . str ( ) ; <nl> auto genSigID = addGenericSignatureRef ( config . second ) ; <nl> derivativeConfigs [ entry . first ] . push_back ( { paramIndices , genSigID } ) ; <nl> } <nl>
Merge pull request from xiaobai / fix - master - next
apple/swift
a00a1e4488e84e45f1cbb80b3d8c1abfa1af5430
2020-03-28T00:32:28Z
new file mode 100644 <nl> index 000000000000 . . b2d9f8a84acd <nl> mmm / dev / null <nl> ppp b / include / swift / Frontend / BackDeploymentLibs . def <nl> <nl> + / / = = = mmmmmm BackDeploymentLibs . def - Backward Deployment Libraries mmmmmm - - = = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2018 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Enumerates the backward deployment libraries that need to be linked <nl> + / / into Swift targets . Clients of this file must define the macro <nl> + / / <nl> + / / BACK_DEPLOYMENT_LIB ( Version , Filter , LibraryName ) <nl> + / / <nl> + / / where : <nl> + / / Version is a maximum Swift version written like a tuple , e . g . , ( 5 , 1 ) <nl> + / / Filter is one of executable or all . <nl> + / / LibraryName is the name of the library , e . g . , " swiftCompatibility51 " <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef BACK_DEPLOYMENT_LIB <nl> + # error " Must define BACK_DEPLOYMENT_LIB ( Version , Filter , Library ) " <nl> + # endif <nl> + <nl> + BACK_DEPLOYMENT_LIB ( ( 5 , 0 ) , all , " swiftCompatibility50 " ) <nl> + BACK_DEPLOYMENT_LIB ( ( 5 , 1 ) , all , " swiftCompatibility51 " ) <nl> + BACK_DEPLOYMENT_LIB ( ( 5 , 0 ) , executable , " swiftCompatibilityDynamicReplacements " ) <nl> + <nl> + # undef BACK_DEPLOYMENT_LIB <nl> mmm a / lib / Driver / DarwinToolChains . cpp <nl> ppp b / lib / Driver / DarwinToolChains . cpp <nl> toolchains : : Darwin : : addSanitizerArgs ( ArgStringList & Arguments , <nl> / * shared = * / false ) ; <nl> } <nl> <nl> + namespace { <nl> + <nl> + enum class BackDeployLibFilter { <nl> + executable , <nl> + all <nl> + } ; <nl> + <nl> + / / Whether the given job matches the backward - deployment library filter . <nl> + bool jobMatchesFilter ( LinkKind jobKind , BackDeployLibFilter filter ) { <nl> + switch ( filter ) { <nl> + case BackDeployLibFilter : : executable : <nl> + return jobKind = = LinkKind : : Executable ; <nl> + <nl> + case BackDeployLibFilter : : all : <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + } <nl> + <nl> void <nl> toolchains : : Darwin : : addArgsToLinkStdlib ( ArgStringList & Arguments , <nl> const DynamicLinkJobAction & job , <nl> toolchains : : Darwin : : addArgsToLinkStdlib ( ArgStringList & Arguments , <nl> } <nl> <nl> if ( runtimeCompatibilityVersion ) { <nl> - if ( * runtimeCompatibilityVersion < = llvm : : VersionTuple ( 5 , 0 ) ) { <nl> - / / Swift 5 . 0 compatibility library <nl> - SmallString < 128 > BackDeployLib ; <nl> - BackDeployLib . append ( SharedResourceDirPath ) ; <nl> - llvm : : sys : : path : : append ( BackDeployLib , " libswiftCompatibility50 . a " ) ; <nl> - <nl> - if ( llvm : : sys : : fs : : exists ( BackDeployLib ) ) { <nl> - Arguments . push_back ( " - force_load " ) ; <nl> - Arguments . push_back ( context . Args . MakeArgString ( BackDeployLib ) ) ; <nl> - } <nl> - } <nl> + auto addBackDeployLib = [ & ] ( llvm : : VersionTuple version , <nl> + BackDeployLibFilter filter , <nl> + StringRef libraryName ) { <nl> + if ( * runtimeCompatibilityVersion > version ) <nl> + return ; <nl> <nl> - if ( * runtimeCompatibilityVersion < = llvm : : VersionTuple ( 5 , 1 ) ) { <nl> - / / Swift 5 . 1 compatibility library <nl> + if ( ! jobMatchesFilter ( job . getKind ( ) , filter ) ) <nl> + return ; <nl> + <nl> SmallString < 128 > BackDeployLib ; <nl> BackDeployLib . append ( SharedResourceDirPath ) ; <nl> - llvm : : sys : : path : : append ( BackDeployLib , " libswiftCompatibility51 . a " ) ; <nl> + llvm : : sys : : path : : append ( BackDeployLib , " lib " + libraryName + " . a " ) ; <nl> <nl> if ( llvm : : sys : : fs : : exists ( BackDeployLib ) ) { <nl> Arguments . push_back ( " - force_load " ) ; <nl> Arguments . push_back ( context . Args . MakeArgString ( BackDeployLib ) ) ; <nl> } <nl> - } <nl> + } ; <nl> + <nl> + # define BACK_DEPLOYMENT_LIB ( Version , Filter , LibraryName ) \ <nl> + addBackDeployLib ( \ <nl> + llvm : : VersionTuple Version , BackDeployLibFilter : : Filter , LibraryName ) ; <nl> + # include " swift / Frontend / BackDeploymentLibs . def " <nl> } <nl> <nl> - if ( job . getKind ( ) = = LinkKind : : Executable ) { <nl> - if ( runtimeCompatibilityVersion ) <nl> - if ( * runtimeCompatibilityVersion < = llvm : : VersionTuple ( 5 , 0 ) ) { <nl> - / / Swift 5 . 0 dynamic replacement compatibility library . <nl> - SmallString < 128 > BackDeployLib ; <nl> - BackDeployLib . append ( SharedResourceDirPath ) ; <nl> - llvm : : sys : : path : : append ( BackDeployLib , <nl> - " libswiftCompatibilityDynamicReplacements . a " ) ; <nl> - <nl> - if ( llvm : : sys : : fs : : exists ( BackDeployLib ) ) { <nl> - Arguments . push_back ( " - force_load " ) ; <nl> - Arguments . push_back ( context . Args . MakeArgString ( BackDeployLib ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> / / Add the runtime library link path , which is platform - specific and found <nl> / / relative to the compiler . <nl> SmallVector < std : : string , 4 > RuntimeLibPaths ; <nl> mmm a / lib / FrontendTool / FrontendTool . cpp <nl> ppp b / lib / FrontendTool / FrontendTool . cpp <nl> createJSONFixItDiagnosticConsumerIfNeeded ( <nl> } ) ; <nl> } <nl> <nl> + / / / Print information about a <nl> + static void printCompatibilityLibrary ( <nl> + llvm : : VersionTuple runtimeVersion , llvm : : VersionTuple maxVersion , <nl> + StringRef filter , StringRef libraryName , bool & printedAny , <nl> + llvm : : raw_ostream & out ) { <nl> + if ( runtimeVersion > maxVersion ) <nl> + return ; <nl> + <nl> + if ( printedAny ) { <nl> + out < < " , " ; <nl> + } <nl> + <nl> + out < < " \ n " ; <nl> + out < < " { \ n " ; <nl> + <nl> + out < < " \ " libraryName \ " : \ " " ; <nl> + out . write_escaped ( libraryName ) ; <nl> + out < < " \ " , \ n " ; <nl> + <nl> + out < < " \ " filter \ " : \ " " ; <nl> + out . write_escaped ( filter ) ; <nl> + out < < " \ " \ n " ; <nl> + out < < " } " ; <nl> + <nl> + printedAny = true ; <nl> + } <nl> + <nl> / / / Print information about the target triple in JSON . <nl> static void printTripleInfo ( const llvm : : Triple & triple , <nl> + llvm : : Optional < llvm : : VersionTuple > runtimeVersion , <nl> llvm : : raw_ostream & out ) { <nl> out < < " { \ n " ; <nl> <nl> static void printTripleInfo ( const llvm : : Triple & triple , <nl> out . write_escaped ( getTargetSpecificModuleTriple ( triple ) . getTriple ( ) ) ; <nl> out < < " \ " , \ n " ; <nl> <nl> - if ( auto runtimeVersion = getSwiftRuntimeCompatibilityVersionForTarget ( <nl> - triple ) ) { <nl> + if ( runtimeVersion ) { <nl> out < < " \ " swiftRuntimeCompatibilityVersion \ " : \ " " ; <nl> out . write_escaped ( runtimeVersion - > getAsString ( ) ) ; <nl> out < < " \ " , \ n " ; <nl> + <nl> + / / Compatibility libraries that need to be linked . <nl> + out < < " \ " compatibilityLibraries \ " : [ " ; <nl> + bool printedAnyCompatibilityLibrary = false ; <nl> + # define BACK_DEPLOYMENT_LIB ( Version , Filter , LibraryName ) \ <nl> + printCompatibilityLibrary ( \ <nl> + * runtimeVersion , llvm : : VersionTuple Version , # Filter , LibraryName , \ <nl> + printedAnyCompatibilityLibrary , out ) ; <nl> + # include " swift / Frontend / BackDeploymentLibs . def " <nl> + <nl> + if ( printedAnyCompatibilityLibrary ) { <nl> + out < < " \ n " ; <nl> + } <nl> + out < < " ] , \ n " ; <nl> + } else { <nl> + out < < " \ " compatibilityLibraries \ " : [ ] , \ n " ; <nl> } <nl> <nl> out < < " \ " librariesRequireRPath \ " : " <nl> static void printTargetInfo ( const CompilerInvocation & invocation , <nl> llvm : : raw_ostream & out ) { <nl> out < < " { \ n " ; <nl> <nl> + / / Compiler version , as produced by - - version . <nl> + out < < " \ " compilerVersion \ " : \ " " ; <nl> + out . write_escaped ( version : : getSwiftFullVersion ( <nl> + version : : Version : : getCurrentLanguageVersion ( ) ) ) ; <nl> + out < < " \ " , \ n " ; <nl> + <nl> / / Target triple and target variant triple . <nl> + auto runtimeVersion = <nl> + invocation . getIRGenOptions ( ) . AutolinkRuntimeCompatibilityLibraryVersion ; <nl> auto & langOpts = invocation . getLangOptions ( ) ; <nl> out < < " \ " target \ " : " ; <nl> - printTripleInfo ( langOpts . Target , out ) ; <nl> + printTripleInfo ( langOpts . Target , runtimeVersion , out ) ; <nl> out < < " , \ n " ; <nl> <nl> if ( auto & variant = langOpts . TargetVariant ) { <nl> out < < " \ " targetVariant \ " : " ; <nl> - printTripleInfo ( * variant , out ) ; <nl> + printTripleInfo ( * variant , runtimeVersion , out ) ; <nl> out < < " , \ n " ; <nl> } <nl> <nl> mmm a / lib / IRGen / GenDecl . cpp <nl> ppp b / lib / IRGen / GenDecl . cpp <nl> void IRGenModule : : emitSourceFile ( SourceFile & SF ) { <nl> / / situations where it isn ' t useful , such as for dylibs , though this is <nl> / / harmless aside from code size . <nl> if ( ! IRGen . Opts . UseJIT ) { <nl> - if ( auto compatibilityVersion <nl> - = IRGen . Opts . AutolinkRuntimeCompatibilityLibraryVersion ) { <nl> - if ( * compatibilityVersion < = llvm : : VersionTuple ( 5 , 0 ) ) { <nl> - this - > addLinkLibrary ( LinkLibrary ( " swiftCompatibility50 " , <nl> - LibraryKind : : Library , <nl> - / * forceLoad * / true ) ) ; <nl> - } <nl> - if ( * compatibilityVersion < = llvm : : VersionTuple ( 5 , 1 ) ) { <nl> - this - > addLinkLibrary ( LinkLibrary ( " swiftCompatibility51 " , <nl> - LibraryKind : : Library , <nl> - / * forceLoad * / true ) ) ; <nl> + auto addBackDeployLib = [ & ] ( llvm : : VersionTuple version , <nl> + StringRef libraryName ) { <nl> + Optional < llvm : : VersionTuple > compatibilityVersion ; <nl> + if ( libraryName = = " swiftCompatibilityDynamicReplacements " ) { <nl> + compatibilityVersion = IRGen . Opts . <nl> + AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion ; <nl> + } else { <nl> + compatibilityVersion = IRGen . Opts . <nl> + AutolinkRuntimeCompatibilityLibraryVersion ; <nl> } <nl> - } <nl> <nl> - if ( auto compatibilityVersion = <nl> - IRGen . Opts . AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion ) { <nl> - if ( * compatibilityVersion < = llvm : : VersionTuple ( 5 , 0 ) ) { <nl> - this - > addLinkLibrary ( LinkLibrary ( " swiftCompatibilityDynamicReplacements " , <nl> - LibraryKind : : Library , <nl> - / * forceLoad * / true ) ) ; <nl> - } <nl> - } <nl> + if ( ! compatibilityVersion ) <nl> + return ; <nl> + <nl> + if ( * compatibilityVersion > version ) <nl> + return ; <nl> + <nl> + this - > addLinkLibrary ( LinkLibrary ( libraryName , <nl> + LibraryKind : : Library , <nl> + / * forceLoad * / true ) ) ; <nl> + } ; <nl> + <nl> + # define BACK_DEPLOYMENT_LIB ( Version , Filter , LibraryName ) \ <nl> + addBackDeployLib ( llvm : : VersionTuple Version , LibraryName ) ; <nl> + # include " swift / Frontend / BackDeploymentLibs . def " <nl> } <nl> } <nl> <nl> mmm a / test / Driver / print_target_info . swift <nl> ppp b / test / Driver / print_target_info . swift <nl> <nl> <nl> / / RUN : % swift_driver - print - target - info - target x86_64 - apple - ios12 . 0 | % FileCheck - check - prefix CHECK - IOS - SIM % s <nl> <nl> + / / CHECK - IOS : " compilerVersion " : " { { . * } } Swift version <nl> + <nl> / / CHECK - IOS : " target " : { <nl> / / CHECK - IOS : " triple " : " arm64 - apple - ios12 . 0 " , <nl> / / CHECK - IOS : " unversionedTriple " : " arm64 - apple - ios " , <nl> / / CHECK - IOS : " moduleTriple " : " arm64 - apple - ios " , <nl> / / CHECK - IOS : " swiftRuntimeCompatibilityVersion " : " 5 . 0 " , <nl> + / / CHECK - IOS : " compatibilityLibraries " : [ <nl> + / / CHECK - IOS : " libraryName " : " swiftCompatibility50 " , <nl> + / / CHECK - IOS : " libraryName " : " swiftCompatibility51 " , <nl> + / / CHECK - IOS : " libraryName " : " swiftCompatibilityDynamicReplacements " <nl> + / / CHECK - IOS : " filter " : " executable " <nl> + / / CHECK - IOS : ] , <nl> / / CHECK - IOS : " librariesRequireRPath " : true <nl> / / CHECK - IOS : } <nl> <nl> <nl> / / CHECK - IOS : } <nl> <nl> <nl> + / / CHECK - LINUX : " compilerVersion " : " { { . * } } Swift version <nl> + <nl> / / CHECK - LINUX : " target " : { <nl> / / CHECK - LINUX : " triple " : " x86_64 - unknown - linux " , <nl> / / CHECK - LINUX : " moduleTriple " : " x86_64 - unknown - linux " , <nl>
Merge pull request from DougGregor / enhanced - print - target - info
apple/swift
cee75bd285313bdc1c9f8f17603c1f84b1ae4c41
2020-07-09T05:36:31Z
mmm a / src / wasm / function - body - decoder - impl . h <nl> ppp b / src / wasm / function - body - decoder - impl . h <nl> ValueType read_value_type ( Decoder * decoder , const byte * pc , <nl> } <nl> HeapType heap_type = read_heap_type < validate > ( <nl> decoder , pc + depth_length + 1 , length , enabled ) ; <nl> - / / TODO ( 7748 ) : Support RTTs for generic types . <nl> - if ( heap_type . is_generic ( ) ) { <nl> - decoder - > error ( pc , " UNIMPLEMENTED " ) ; <nl> - return kWasmBottom ; <nl> - } <nl> * length + = depth_length + 1 ; <nl> return heap_type . is_bottom ( ) ? kWasmBottom <nl> : ValueType : : Rtt ( heap_type , depth ) ; <nl> mmm a / src / wasm / module - decoder . cc <nl> ppp b / src / wasm / module - decoder . cc <nl> class ModuleDecoderImpl : public Decoder { <nl> return true ; <nl> } <nl> <nl> + / / TODO ( manoskouk ) : This is copy - modified from function - body - decoder - impl . h . <nl> + / / We should find a way to share this code . <nl> + V8_INLINE bool Validate ( const byte * pc , HeapTypeImmediate < kValidate > & imm ) { <nl> + if ( V8_UNLIKELY ( imm . type . is_bottom ( ) ) ) { <nl> + error ( pc , " invalid heap type " ) ; <nl> + return false ; <nl> + } <nl> + if ( V8_UNLIKELY ( ! ( imm . type . is_generic ( ) | | <nl> + module_ - > has_array ( imm . type . ref_index ( ) ) | | <nl> + module_ - > has_struct ( imm . type . ref_index ( ) ) ) ) ) { <nl> + errorf ( <nl> + pc , <nl> + " Type index % u does not refer to a struct or array type definition " , <nl> + imm . type . ref_index ( ) ) ; <nl> + return false ; <nl> + } <nl> + return true ; <nl> + } <nl> + <nl> WasmInitExpr consume_init_expr ( WasmModule * module , ValueType expected ) { <nl> constexpr Decoder : : ValidateFlag validate = Decoder : : kValidate ; <nl> WasmOpcode opcode = kExprNop ; <nl> class ModuleDecoderImpl : public Decoder { <nl> } <nl> HeapTypeImmediate < Decoder : : kValidate > imm ( enabled_features_ , this , <nl> pc ( ) + 1 ) ; <nl> + len = 1 + imm . length ; <nl> + if ( ! Validate ( pc ( ) + 1 , imm ) ) break ; <nl> stack . push_back ( <nl> WasmInitExpr : : RefNullConst ( imm . type . representation ( ) ) ) ; <nl> - len = 1 + imm . length ; <nl> break ; <nl> } <nl> case kExprRefFunc : { <nl> mmm a / src / wasm / value - type . h <nl> ppp b / src / wasm / value - type . h <nl> class ValueType { <nl> } <nl> break ; <nl> case kRtt : <nl> - buf < < " ( rtt " < < depth ( ) < < " " < < heap_type ( ) . name ( ) + " ) " ; <nl> + buf < < " ( rtt " < < static_cast < uint32_t > ( depth ( ) ) < < " " <nl> + < < heap_type ( ) . name ( ) + " ) " ; <nl> break ; <nl> default : <nl> buf < < kind_name ( ) ; <nl> mmm a / src / wasm / wasm - module - builder . cc <nl> ppp b / src / wasm / wasm - module - builder . cc <nl> void WriteValueType ( ZoneBuffer * buffer , const ValueType & type ) { <nl> } <nl> } <nl> <nl> + void WriteGlobalInitializer ( ZoneBuffer * buffer , const WasmInitExpr & init , <nl> + ValueType type ) { <nl> + switch ( init . kind ( ) ) { <nl> + case WasmInitExpr : : kI32Const : <nl> + buffer - > write_u8 ( kExprI32Const ) ; <nl> + buffer - > write_i32v ( init . immediate ( ) . i32_const ) ; <nl> + break ; <nl> + case WasmInitExpr : : kI64Const : <nl> + buffer - > write_u8 ( kExprI64Const ) ; <nl> + buffer - > write_i64v ( init . immediate ( ) . i64_const ) ; <nl> + break ; <nl> + case WasmInitExpr : : kF32Const : <nl> + buffer - > write_u8 ( kExprF32Const ) ; <nl> + buffer - > write_f32 ( init . immediate ( ) . f32_const ) ; <nl> + break ; <nl> + case WasmInitExpr : : kF64Const : <nl> + buffer - > write_u8 ( kExprF64Const ) ; <nl> + buffer - > write_f64 ( init . immediate ( ) . f64_const ) ; <nl> + break ; <nl> + case WasmInitExpr : : kGlobalGet : <nl> + buffer - > write_u8 ( kExprGlobalGet ) ; <nl> + buffer - > write_u32v ( init . immediate ( ) . index ) ; <nl> + break ; <nl> + case WasmInitExpr : : kRefNullConst : <nl> + buffer - > write_u8 ( kExprRefNull ) ; <nl> + buffer - > write_i32v ( HeapType ( init . immediate ( ) . heap_type ) . code ( ) ) ; <nl> + break ; <nl> + case WasmInitExpr : : kRefFuncConst : <nl> + buffer - > write_u8 ( kExprRefFunc ) ; <nl> + buffer - > write_u32v ( init . immediate ( ) . index ) ; <nl> + break ; <nl> + case WasmInitExpr : : kNone : { <nl> + / / No initializer , emit a default value . <nl> + switch ( type . kind ( ) ) { <nl> + case ValueType : : kI32 : <nl> + buffer - > write_u8 ( kExprI32Const ) ; <nl> + / / LEB encoding of 0 . <nl> + buffer - > write_u8 ( 0 ) ; <nl> + break ; <nl> + case ValueType : : kI64 : <nl> + buffer - > write_u8 ( kExprI64Const ) ; <nl> + / / LEB encoding of 0 . <nl> + buffer - > write_u8 ( 0 ) ; <nl> + break ; <nl> + case ValueType : : kF32 : <nl> + buffer - > write_u8 ( kExprF32Const ) ; <nl> + buffer - > write_f32 ( 0 . f ) ; <nl> + break ; <nl> + case ValueType : : kF64 : <nl> + buffer - > write_u8 ( kExprF64Const ) ; <nl> + buffer - > write_f64 ( 0 . ) ; <nl> + break ; <nl> + case ValueType : : kOptRef : <nl> + buffer - > write_u8 ( kExprRefNull ) ; <nl> + break ; <nl> + case ValueType : : kI8 : <nl> + case ValueType : : kI16 : <nl> + case ValueType : : kStmt : <nl> + case ValueType : : kS128 : <nl> + case ValueType : : kBottom : <nl> + case ValueType : : kRef : <nl> + case ValueType : : kRtt : <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> } / / namespace <nl> <nl> void WasmModuleBuilder : : WriteTo ( ZoneBuffer * buffer ) const { <nl> void WasmModuleBuilder : : WriteTo ( ZoneBuffer * buffer ) const { <nl> for ( const WasmGlobal & global : globals_ ) { <nl> WriteValueType ( buffer , global . type ) ; <nl> buffer - > write_u8 ( global . mutability ? 1 : 0 ) ; <nl> - switch ( global . init . kind ( ) ) { <nl> - case WasmInitExpr : : kI32Const : <nl> - DCHECK_EQ ( kWasmI32 , global . type ) ; <nl> - buffer - > write_u8 ( kExprI32Const ) ; <nl> - buffer - > write_i32v ( global . init . immediate ( ) . i32_const ) ; <nl> - break ; <nl> - case WasmInitExpr : : kI64Const : <nl> - DCHECK_EQ ( kWasmI64 , global . type ) ; <nl> - buffer - > write_u8 ( kExprI64Const ) ; <nl> - buffer - > write_i64v ( global . init . immediate ( ) . i64_const ) ; <nl> - break ; <nl> - case WasmInitExpr : : kF32Const : <nl> - DCHECK_EQ ( kWasmF32 , global . type ) ; <nl> - buffer - > write_u8 ( kExprF32Const ) ; <nl> - buffer - > write_f32 ( global . init . immediate ( ) . f32_const ) ; <nl> - break ; <nl> - case WasmInitExpr : : kF64Const : <nl> - DCHECK_EQ ( kWasmF64 , global . type ) ; <nl> - buffer - > write_u8 ( kExprF64Const ) ; <nl> - buffer - > write_f64 ( global . init . immediate ( ) . f64_const ) ; <nl> - break ; <nl> - case WasmInitExpr : : kGlobalGet : <nl> - buffer - > write_u8 ( kExprGlobalGet ) ; <nl> - buffer - > write_u32v ( global . init . immediate ( ) . index ) ; <nl> - break ; <nl> - case WasmInitExpr : : kRefNullConst : <nl> - buffer - > write_u8 ( kExprRefNull ) ; <nl> - buffer - > write_i32v ( <nl> - HeapType ( global . init . immediate ( ) . heap_type ) . code ( ) ) ; <nl> - break ; <nl> - case WasmInitExpr : : kRefFuncConst : <nl> - UNIMPLEMENTED ( ) ; <nl> - break ; <nl> - case WasmInitExpr : : kNone : { <nl> - / / No initializer , emit a default value . <nl> - switch ( global . type . kind ( ) ) { <nl> - case ValueType : : kI32 : <nl> - buffer - > write_u8 ( kExprI32Const ) ; <nl> - / / LEB encoding of 0 . <nl> - buffer - > write_u8 ( 0 ) ; <nl> - break ; <nl> - case ValueType : : kI64 : <nl> - buffer - > write_u8 ( kExprI64Const ) ; <nl> - / / LEB encoding of 0 . <nl> - buffer - > write_u8 ( 0 ) ; <nl> - break ; <nl> - case ValueType : : kF32 : <nl> - buffer - > write_u8 ( kExprF32Const ) ; <nl> - buffer - > write_f32 ( 0 . f ) ; <nl> - break ; <nl> - case ValueType : : kF64 : <nl> - buffer - > write_u8 ( kExprF64Const ) ; <nl> - buffer - > write_f64 ( 0 . ) ; <nl> - break ; <nl> - case ValueType : : kOptRef : <nl> - buffer - > write_u8 ( kExprRefNull ) ; <nl> - break ; <nl> - case ValueType : : kI8 : <nl> - case ValueType : : kI16 : <nl> - case ValueType : : kStmt : <nl> - case ValueType : : kS128 : <nl> - case ValueType : : kBottom : <nl> - case ValueType : : kRef : <nl> - case ValueType : : kRtt : <nl> - UNREACHABLE ( ) ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> + WriteGlobalInitializer ( buffer , global . init , global . type ) ; <nl> buffer - > write_u8 ( kExprEnd ) ; <nl> } <nl> FixupSection ( buffer , start ) ; <nl> mmm a / test / unittests / wasm / module - decoder - unittest . cc <nl> ppp b / test / unittests / wasm / module - decoder - unittest . cc <nl> TEST_F ( WasmModuleVerifyTest , TwoGlobals ) { <nl> EXPECT_OFF_END_FAILURE ( data , 1 ) ; <nl> } <nl> <nl> + TEST_F ( WasmModuleVerifyTest , RefNullGlobal ) { <nl> + WASM_FEATURE_SCOPE ( reftypes ) ; <nl> + static const byte data [ ] = { SECTION ( Global , ENTRY_COUNT ( 1 ) , kLocalFuncRef , 1 , <nl> + WASM_REF_NULL ( kLocalFuncRef ) , kExprEnd ) } ; <nl> + ModuleResult result = DecodeModule ( data , data + sizeof ( data ) ) ; <nl> + EXPECT_OK ( result ) ; <nl> + } <nl> + <nl> + TEST_F ( WasmModuleVerifyTest , RefNullGlobalInvalid1 ) { <nl> + WASM_FEATURE_SCOPE ( reftypes ) ; <nl> + WASM_FEATURE_SCOPE ( typed_funcref ) ; <nl> + static const byte data [ ] = { SECTION ( Global , ENTRY_COUNT ( 1 ) , kLocalOptRef , 0 , <nl> + 1 , WASM_REF_NULL ( 0 ) , kExprEnd ) } ; <nl> + ModuleResult result = DecodeModule ( data , data + sizeof ( data ) ) ; <nl> + EXPECT_NOT_OK ( <nl> + result , <nl> + " Type index 0 does not refer to a struct or array type definition " ) ; <nl> + } <nl> + <nl> + TEST_F ( WasmModuleVerifyTest , RefNullGlobalInvalid2 ) { <nl> + WASM_FEATURE_SCOPE ( reftypes ) ; <nl> + WASM_FEATURE_SCOPE ( typed_funcref ) ; <nl> + static const byte data [ ] = { SECTION ( Global , ENTRY_COUNT ( 1 ) , kLocalFuncRef , 1 , <nl> + kExprRefNull , U32V_5 ( 1000001 ) , kExprEnd ) } ; <nl> + ModuleResult result = DecodeModule ( data , data + sizeof ( data ) ) ; <nl> + EXPECT_NOT_OK ( result , <nl> + " Type index 1000001 is greater than the maximum number 1000000 " <nl> + " of type definitions supported by V8 " ) ; <nl> + } <nl> + <nl> TEST_F ( WasmModuleVerifyTest , ZeroExceptions ) { <nl> static const byte data [ ] = { SECTION ( Exception , ENTRY_COUNT ( 0 ) ) } ; <nl> FAIL_IF_NO_EXPERIMENTAL_EH ( data ) ; <nl>
[ wasm - gc ] Preparation for rtt global initializers
v8/v8
8b9c2ac3c693066183ff6f9b41ed5c07ad968d63
2020-07-09T18:33:38Z
new file mode 100644 <nl> index 00000000000 . . a241bf6dbfa <nl> mmm / dev / null <nl> ppp b / src / concurrency / os_signal . cc <nl> <nl> + # include " concurrency / os_signal . hpp " <nl> + # include " arch / arch . hpp " <nl> + <nl> + void wait_for_sigint ( ) { <nl> + static struct : public thread_message_t , public cond_t { <nl> + void on_thread_switch ( ) { pulse ( ) ; } <nl> + } interrupt_cond ; <nl> + thread_pool_t : : set_interrupt_message ( & interrupt_cond ) ; <nl> + interrupt_cond . wait ( ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 225bd0fe69d <nl> mmm / dev / null <nl> ppp b / src / concurrency / os_signal . hpp <nl> <nl> + # ifndef __OS_SIGNAL__ <nl> + # define __OS_SIGNAL__ <nl> + <nl> + # include " concurrency / cond_var . hpp " <nl> + # include " arch / core . hpp " <nl> + <nl> + void wait_for_sigint ( ) ; <nl> + <nl> + class sigint_indicator_t { <nl> + private : <nl> + bool _sigint_has_happened ; <nl> + public : <nl> + sigint_indicator_t ( ) <nl> + : _sigint_has_happened ( false ) / / this has to be constructed before sigints <nl> + { <nl> + coro_t : : spawn ( boost : : bind ( & sigint_indicator_t : : watch_for_sigint , this ) ) ; <nl> + } <nl> + bool sigint_has_happened ( ) { return _sigint_has_happened ; } <nl> + private : <nl> + void watch_for_sigint ( ) { <nl> + wait_for_sigint ( ) ; <nl> + _sigint_has_happened = true ; <nl> + } <nl> + } ; <nl> + <nl> + # endif <nl> mmm a / src / import / import . cc <nl> ppp b / src / import / import . cc <nl> void usage ( ) { <nl> return cmd_config_t ( ) <nl> } * / <nl> <nl> - void import_main ( cmd_config_t * cmd_config , thread_pool_t * thread_pool ) { <nl> - { <nl> - / * Start logger * / <nl> - log_controller_t log_controller ; <nl> + / / eventually import should have its own main function . Right n <nl> <nl> - / * Copy database filenames from private serializer configurations into a single vector of strings * / <nl> - std : : vector < std : : string > db_filenames ; <nl> - std : : vector < log_serializer_private_dynamic_config_t > & serializer_private = cmd_config - > store_dynamic_config . serializer_private ; <nl> - std : : vector < log_serializer_private_dynamic_config_t > : : iterator it ; <nl> - <nl> - for ( it = serializer_private . begin ( ) ; it ! = serializer_private . end ( ) ; + + it ) { <nl> - db_filenames . push_back ( ( * it ) . db_filename ) ; <nl> - } <nl> - <nl> - / * Check to see if there is an existing database * / <nl> - struct : public btree_key_value_store_t : : check_callback_t , public promise_t < bool > { <nl> - void on_store_check ( bool ok ) { pulse ( ok ) ; } <nl> - } check_cb ; <nl> - btree_key_value_store_t : : check_existing ( db_filenames , & check_cb ) ; <nl> - bool existing = check_cb . wait ( ) ; <nl> - if ( ! existing ) { <nl> - logINF ( " Creating database . . . \ n " ) ; <nl> - btree_key_value_store_t : : create ( & cmd_config - > store_dynamic_config , <nl> - & cmd_config - > store_static_config ) ; <nl> - logINF ( " Done creating . \ n " ) ; <nl> - } <nl> - <nl> - <nl> - order_source_pigeoncoop_t pigeoncoop ( MEMCACHE_START_BUCKET ) ; <nl> - <nl> - / * Start key - value store * / <nl> - logINF ( " Loading database . . . \ n " ) ; <nl> - btree_key_value_store_t store ( & cmd_config - > store_dynamic_config ) ; <nl> - <nl> - logINF ( " Importing memcached commands . . \ n " ) ; <nl> - order_source_t order_source ( & pigeoncoop ) ; <nl> - import_memcache ( cmd_config - > memcached_file , & store , & order_source ) ; <nl> - <nl> - logINF ( " Waiting for running operations to finish . . . \ n " ) ; <nl> - <nl> - logINF ( " Waiting for changes to flush to disk . . . \ n " ) ; <nl> - / / Store destructor called here <nl> - } <nl> - <nl> - <nl> - / * The penultimate step of shutting down is to make sure that all messages <nl> - have reached their destinations so that they can be freed . The way we do this <nl> - is to send one final message to each core ; when those messages all get back <nl> - we know that all messages have been processed properly . Otherwise , logger <nl> - shutdown messages would get " stuck " in the message hub when it shut down , <nl> - leading to memory leaks . * / <nl> - for ( int i = 0 ; i < get_num_threads ( ) ; i + + ) { <nl> - on_thread_t thread_switcher ( i ) ; <nl> - } <nl> - <nl> - / * Finally tell the thread pool to stop . TODO : Eventually , the thread pool should stop <nl> - automatically when server_main ( ) returns . * / <nl> - thread_pool - > shutdown ( ) ; <nl> - } <nl> + / * void import_main ( cmd_config_t * cmd_config , thread_pool_t * thread_pool ) { <nl> + } * / <nl> <nl> } / / namespace import <nl> <nl> mmm a / src / memcached / memcached . cc <nl> ppp b / src / memcached / memcached . cc <nl> <nl> # include " store . hpp " <nl> # include " logger . hpp " <nl> # include " progress / progress . hpp " <nl> + # include " concurrency / os_signal . hpp " <nl> <nl> / * txt_memcached_handler_t is basically defunct ; it only exists as a convenient thing to pass <nl> around to do_get ( ) , do_storage ( ) , and the like . * / <nl> void handle_memcache ( txt_memcached_handler_if * rh , UNUSED order_source_t * order_ <nl> / * Declared outside the while - loop so it doesn ' t repeatedly reallocate its buffer * / <nl> std : : vector < char > line ; <nl> <nl> - while ( true ) { <nl> + sigint_indicator_t sigint_indicator ; <nl> + <nl> + while ( ! sigint_indicator . sigint_has_happened ( ) ) { <nl> / * Flush if necessary ( no reason to do this the first time around , but it ' s easier <nl> to put it here than after every thing that could need to flush * / <nl> block_pm_duration flush_timer ( & pm_conns_writing ) ; <nl> mmm a / src / progress / progress . cc <nl> ppp b / src / progress / progress . cc <nl> <nl> # include " progress . hpp " <nl> + # include " errors . hpp " <nl> <nl> progress_bar_t : : progress_bar_t ( std : : string activity , int redraw_interval_ms = 100 ) <nl> : repeating_timer_t ( redraw_interval_ms , <nl> void progress_bar_t : : draw_bar ( int percent_done , int eta ) { <nl> } <nl> <nl> if ( eta = = - 1 ) printf ( " ETA : - " ) ; <nl> - else printf ( " ETA : % d : % 02d " , eta / 60 , eta % 60 ) ; <nl> + else printf ( " ETA : % 01d : % 02d : % 02d " , ( eta / 3600 ) , ( eta / 60 ) % 60 , eta % 60 ) ; <nl> + <nl> + printf ( " " ) ; / / make sure we don ' t leave an characters behind <nl> fflush ( stdin ) ; <nl> } <nl> <nl> mmm a / src / progress / progress . hpp <nl> ppp b / src / progress / progress . hpp <nl> class progress_bar_t : repeating_timer_t { <nl> void refresh ( ) ; <nl> virtual void draw ( ) = 0 ; <nl> virtual void reset_bar ( ) ; <nl> - void draw_bar ( int , int ete = - 1 ) ; <nl> + void draw_bar ( int , int eta = - 1 ) ; <nl> } ; <nl> <nl> class counter_progress_bar_t : public progress_bar_t { <nl> mmm a / src / server / server . cc <nl> ppp b / src / server / server . cc <nl> <nl> # include " control . hpp " <nl> # include " gated_store . hpp " <nl> # include " concurrency / promise . hpp " <nl> + # include " concurrency / os_signal . hpp " <nl> <nl> int run_server ( int argc , char * argv [ ] ) { <nl> <nl> struct periodic_checker_t { <nl> } <nl> # endif <nl> <nl> - void wait_for_sigint ( ) { <nl> + / * void wait_for_sigint ( ) { <nl> <nl> struct : public thread_message_t , public cond_t { <nl> void on_thread_switch ( ) { pulse ( ) ; } <nl> } interrupt_cond ; <nl> thread_pool_t : : set_interrupt_message ( & interrupt_cond ) ; <nl> interrupt_cond . wait ( ) ; <nl> - } <nl> + } * / <nl> <nl> struct memcache_conn_handler_t : public conn_handler_with_special_lifetime_t { <nl> memcache_conn_handler_t ( get_store_t * get_store , set_store_interface_t * set_store , order_source_pigeoncoop_t * pigeoncoop ) <nl>
Rearranges how we do wait_for_sigint .
rethinkdb/rethinkdb
38119e97724e2e1d43938a20bb50f4096e3712d1
2011-05-23T18:32:20Z
deleted file mode 100644 <nl> index 3faa22a1bdae . . 000000000000 <nl> mmm a / cocos2dx / platform / third_party / bada / src / libjpeg / manifest . xml <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> - < Manifest > <nl> - < Id > 93bt1p123e < / Id > <nl> - < Secret > 9C645DDBA19C71BAD1204DA4DAA7A0B9 < / Secret > <nl> - < AppVersion > 1 . 0 . 0 < / AppVersion > <nl> - < ManifestVersion > 1 . 2 < / ManifestVersion > <nl> - < Privileges > <nl> - < Privilege > <nl> - < Name > SYSTEM_SERVICE < / Name > <nl> - < / Privilege > <nl> - < Privilege > <nl> - < Name > WEB_SERVICE < / Name > <nl> - < / Privilege > <nl> - < / Privileges > <nl> - < DeviceProfile > <nl> - < APIVersion > 1 . 2 < / APIVersion > <nl> - < CPU > Cortex8 < / CPU > <nl> - < ScreenSize > 480x800 < / ScreenSize > <nl> - < Connectivity > Bluetooth < / Connectivity > <nl> - < Connectivity > Wi - Fi < / Connectivity > <nl> - < Sensor > GPS < / Sensor > <nl> - < Sensor > Accelerometer < / Sensor > <nl> - < Sensor > Proximity < / Sensor > <nl> - < InputDevice > Touch < / InputDevice > <nl> - < SoundMixing > Enable < / SoundMixing > <nl> - < UserInteraction > Vibration - effects < / UserInteraction > <nl> - < / DeviceProfile > <nl> - < / Manifest > <nl> similarity index 100 % <nl> rename from cocos2dx / platform / third_party / bada / src / libjpeg / . badaprj <nl> rename to cocos2dx / platform / third_party / bada / src / libjpeg / sdk1 . 2 / . badaprj <nl> similarity index 51 % <nl> rename from cocos2dx / platform / third_party / bada / src / libjpeg / . cproject <nl> rename to cocos2dx / platform / third_party / bada / src / libjpeg / sdk1 . 2 / . cproject <nl> mmm a / cocos2dx / platform / third_party / bada / src / libjpeg / . cproject <nl> ppp b / cocos2dx / platform / third_party / bada / src / libjpeg / sdk1 . 2 / . cproject <nl> <nl> < externalSetting > <nl> < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libjpeg " / > <nl> < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libjpeg / . Simulator - Debug " / > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libjpeg " / > <nl> < / externalSetting > <nl> < / externalSettings > <nl> < extensions > <nl> <nl> < / sourceEntries > <nl> < / configuration > <nl> < / storageModule > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> < storageModule moduleId = " scannerConfiguration " > <nl> < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> <nl> < parser enabled = " true " / > <nl> < / scannerInfoProvider > <nl> < / profile > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 ; cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 . ; cdt . managedbuild . tool . osp . gnu . simul . c . compiler . lib . simul . 434291871 ; cdt . managedbuild . tool . osp . gnu . c . compiler . input . 1197553287 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 ; cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 . ; cdt . managedbuild . tool . osp . gnu . simul . cpp . compiler . lib . simul . 1016860388 ; cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1527153350 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> < / cconfiguration > <nl> < cconfiguration id = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 " > <nl> < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 " moduleId = " org . eclipse . cdt . core . settings " name = " Target - Debug " > <nl> <nl> < / sourceEntries > <nl> < / configuration > <nl> < / storageModule > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> < storageModule moduleId = " scannerConfiguration " > <nl> < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> <nl> < parser enabled = " true " / > <nl> < / scannerInfoProvider > <nl> < / profile > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 ; cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 . ; cdt . managedbuild . tool . osp . gnu . simul . c . compiler . lib . simul . 434291871 ; cdt . managedbuild . tool . osp . gnu . c . compiler . input . 1197553287 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 ; cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 . ; cdt . managedbuild . tool . osp . gnu . simul . cpp . compiler . lib . simul . 1016860388 ; cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1527153350 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> < / cconfiguration > <nl> < cconfiguration id = " cdt . managedbuild . config . osp . gnu . target . lib . release . 1974955275 " > <nl> < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . osp . gnu . target . lib . release . 1974955275 " moduleId = " org . eclipse . cdt . core . settings " name = " Target - Release " > <nl> <nl> < / sourceEntries > <nl> < / configuration > <nl> < / storageModule > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> < storageModule moduleId = " scannerConfiguration " > <nl> < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> <nl> < parser enabled = " true " / > <nl> < / scannerInfoProvider > <nl> < / profile > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 ; cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 . ; cdt . managedbuild . tool . osp . gnu . simul . c . compiler . lib . simul . 434291871 ; cdt . managedbuild . tool . osp . gnu . c . compiler . input . 1197553287 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 ; cdt . managedbuild . config . osp . gnu . arm . lib . simul . 837804052 . ; cdt . managedbuild . tool . osp . gnu . simul . cpp . compiler . lib . simul . 1016860388 ; cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1527153350 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> < / storageModule > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> - < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> < / cconfiguration > <nl> < / storageModule > <nl> < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> similarity index 89 % <nl> rename from cocos2dx / platform / third_party / bada / src / libjpeg / . project <nl> rename to cocos2dx / platform / third_party / bada / src / libjpeg / sdk1 . 2 / . project <nl> mmm a / cocos2dx / platform / third_party / bada / src / libjpeg / . project <nl> ppp b / cocos2dx / platform / third_party / bada / src / libjpeg / sdk1 . 2 / . project <nl> <nl> < nature > org . eclipse . cdt . managedbuilder . core . ScannerConfigNature < / nature > <nl> < nature > com . osp . ide . badaNature < / nature > <nl> < / natures > <nl> + < linkedResources > <nl> + < link > <nl> + < name > src < / name > <nl> + < type > 2 < / type > <nl> + < locationURI > cocos2dx_root / cocos2dx / platform / third_party / bada / src / libjpeg / src < / locationURI > <nl> + < / link > <nl> + < / linkedResources > <nl> < / projectDescription > <nl> new file mode 100644 <nl> index 000000000000 . . b9d152e134a2 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / bada / src / libjpeg / sdk2 . 0 / . badaprj <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " standalone = " no " ? > <nl> + < bada > <nl> + < type > 2 < / type > <nl> + < sdk > D : \ bada \ 2 . 0 . 0b1 < / sdk > <nl> + < model > WaveHVGA < / model > <nl> + < apiversioncheck > true < / apiversioncheck > <nl> + < priviligecheck > false < / priviligecheck > <nl> + < properties > <nl> + < data0 key = " PT CmdArgs Target - Release " value = " " / > <nl> + < data1 key = " PT CertFile Simulator - Debug " value = " $ { project_loc } \ . Simulator - Debug \ cert . cer " / > <nl> + < data2 key = " PT Output Simulator - Debug " value = " $ { project_loc } \ . Simulator - Debug " / > <nl> + < data3 key = " PT CertFile Target - Release " value = " $ { project_loc } \ . Target - Release \ cert . cer " / > <nl> + < data4 key = " PT CertFile Target - Debug " value = " $ { project_loc } \ . Target - Debug \ cert . cer " / > <nl> + < data5 key = " PT CmdArgs Target - Debug " value = " " / > <nl> + < data6 key = " PT CmdArgs Simulator - Debug " value = " " / > <nl> + < data7 key = " PT Output Target - Release " value = " $ { project_loc } \ . Target - Release " / > <nl> + < data8 key = " PT Output Target - Debug " value = " $ { project_loc } \ . Target - Debug " / > <nl> + < / properties > <nl> + < / bada > <nl> new file mode 100644 <nl> index 000000000000 . . 3777444c63f7 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / bada / src / libjpeg / sdk2 . 0 / . cproject <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " standalone = " no " ? > <nl> + < ? fileVersion 4 . 0 . 0 ? > <nl> + <nl> + < cproject storage_type_id = " org . eclipse . cdt . core . XmlProjectDescriptionStorage " > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . settings " > <nl> + < cconfiguration id = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 " > <nl> + < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 " moduleId = " org . eclipse . cdt . core . settings " name = " Target - Debug " > <nl> + < externalSettings > <nl> + < externalSetting > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libjpeg " / > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libjpeg / . Target - Debug " / > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libjpeg " / > <nl> + < entry flags = " RESOLVED " kind = " libraryFile " name = " jpeg " / > <nl> + < / externalSetting > <nl> + < / externalSettings > <nl> + < extensions > <nl> + < extension id = " org . eclipse . cdt . core . ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GNU_ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> + < extension id = " org . eclipse . cdt . core . Cygwin_PE " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> + < extension id = " org . eclipse . cdt . core . MakeErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GCCErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GASErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GLDErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < / extensions > <nl> + < / storageModule > <nl> + < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> + < configuration artifactExtension = " a " artifactName = " jpeg " buildArtefactType = " org . eclipse . cdt . build . core . buildArtefactType . staticLib " buildProperties = " org . eclipse . cdt . build . core . buildType = org . eclipse . cdt . build . core . buildType . debug , org . eclipse . cdt . build . core . buildArtefactType = org . eclipse . cdt . build . core . buildArtefactType . staticLib " cleanCommand = " rm - rf " description = " " errorParsers = " org . eclipse . cdt . core . MakeErrorParser ; org . eclipse . cdt . core . GCCErrorParser ; org . eclipse . cdt . core . GLDErrorParser ; org . eclipse . cdt . core . GASErrorParser " id = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 " name = " Target - Debug " parent = " cdt . managedbuild . config . osp . gnu . target . lib . debug " > <nl> + < folderInfo id = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 . " name = " / " resourcePath = " " > <nl> + < toolChain id = " cdt . managedbuild . toolchain . osp . gnu . target . lib . debug . 424108108 " name = " bada GCC ToolChain " superClass = " cdt . managedbuild . toolchain . osp . gnu . target . lib . debug " > <nl> + < targetPlatform archList = " all " binaryParser = " org . eclipse . cdt . core . Cygwin_PE ; org . eclipse . cdt . core . GNU_ELF ; org . eclipse . cdt . core . ELF " id = " cdt . managedbuild . target . osp . gnu . target . platform . lib . debug . 530287103 " name = " Debug Platform " osList = " osp " superClass = " cdt . managedbuild . target . osp . gnu . target . platform . lib . debug " / > <nl> + < builder buildPath = " $ { workspace_loc : / libjpeg / . Target - Debug } " command = " cs - make " id = " cdt . managedbuild . target . osp . gnu . target . builder . lib . debug . 1113371971 " keepEnvironmentInBuildfile = " false " managedBuildOn = " true " name = " bada Builder " superClass = " cdt . managedbuild . target . osp . gnu . target . builder . lib . debug " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . arm . archiver . lib . debug . 480495029 " name = " bada Archiver " superClass = " cdt . managedbuild . tool . osp . gnu . arm . archiver . lib . debug " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . cpp . compiler . lib . debug . 1383778979 " name = " bada C + + Compiler " superClass = " cdt . managedbuild . tool . osp . gnu . target . cpp . compiler . lib . debug " > <nl> + < inputType id = " cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1094647355 " superClass = " cdt . managedbuild . tool . osp . gnu . cpp . compiler . input " / > <nl> + < / tool > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . c . compiler . lib . debug . 494983528 " name = " bada C Compiler " superClass = " cdt . managedbuild . tool . osp . gnu . target . c . compiler . lib . debug " > <nl> + < inputType id = " cdt . managedbuild . tool . osp . gnu . c . compiler . input . 867319883 " superClass = " cdt . managedbuild . tool . osp . gnu . c . compiler . input " / > <nl> + < / tool > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . arm . c . linker . base . 91819967 " name = " bada C Linker " superClass = " cdt . managedbuild . tool . osp . gnu . arm . c . linker . base " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . arm . cpp . linker . base . 609563850 " name = " bada C + + Linker " superClass = " cdt . managedbuild . tool . osp . gnu . arm . cpp . linker . base " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . assembler . lib . debug . 837980931 " name = " bada Assembler " superClass = " cdt . managedbuild . tool . osp . gnu . target . assembler . lib . debug " > <nl> + < inputType id = " cdt . managedbuild . tool . osp . gnu . assembler . input . 527987996 " superClass = " cdt . managedbuild . tool . osp . gnu . assembler . input " / > <nl> + < / tool > <nl> + < / toolChain > <nl> + < / folderInfo > <nl> + < sourceEntries > <nl> + < entry flags = " VALUE_WORKSPACE_PATH | RESOLVED " kind = " sourcePath " name = " src " / > <nl> + < / sourceEntries > <nl> + < / configuration > <nl> + < / storageModule > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> + < storageModule moduleId = " scannerConfiguration " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 ; cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 . ; cdt . managedbuild . tool . osp . gnu . target . c . compiler . lib . debug . 494983528 ; cdt . managedbuild . tool . osp . gnu . c . compiler . input . 867319883 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 ; cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 . ; cdt . managedbuild . tool . osp . gnu . target . cpp . compiler . lib . debug . 1383778979 ; cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1094647355 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < / storageModule > <nl> + < / cconfiguration > <nl> + < cconfiguration id = " cdt . managedbuild . config . osp . gnu . target . lib . release . 1974955275 " > <nl> + < storageModule buildSystemId = " org . eclipse . cdt . managedbuilder . core . configurationDataProvider " id = " cdt . managedbuild . config . osp . gnu . target . lib . release . 1974955275 " moduleId = " org . eclipse . cdt . core . settings " name = " Target - Release " > <nl> + < externalSettings > <nl> + < externalSetting > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " includePath " name = " / libjpeg " / > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libjpeg / . Target - Release " / > <nl> + < entry flags = " VALUE_WORKSPACE_PATH " kind = " libraryPath " name = " / libjpeg " / > <nl> + < entry flags = " RESOLVED " kind = " libraryFile " name = " jpeg " / > <nl> + < / externalSetting > <nl> + < / externalSettings > <nl> + < extensions > <nl> + < extension id = " org . eclipse . cdt . core . ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GNU_ELF " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> + < extension id = " org . eclipse . cdt . core . Cygwin_PE " point = " org . eclipse . cdt . core . BinaryParser " / > <nl> + < extension id = " org . eclipse . cdt . core . MakeErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GCCErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GASErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < extension id = " org . eclipse . cdt . core . GLDErrorParser " point = " org . eclipse . cdt . core . ErrorParser " / > <nl> + < / extensions > <nl> + < / storageModule > <nl> + < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> + < configuration artifactExtension = " a " artifactName = " jpeg " buildArtefactType = " org . eclipse . cdt . build . core . buildArtefactType . staticLib " buildProperties = " org . eclipse . cdt . build . core . buildType = org . eclipse . cdt . build . core . buildType . release , org . eclipse . cdt . build . core . buildArtefactType = org . eclipse . cdt . build . core . buildArtefactType . staticLib " cleanCommand = " rm - rf " description = " " errorParsers = " org . eclipse . cdt . core . MakeErrorParser ; org . eclipse . cdt . core . GCCErrorParser ; org . eclipse . cdt . core . GLDErrorParser ; org . eclipse . cdt . core . GASErrorParser " id = " cdt . managedbuild . config . osp . gnu . target . lib . release . 1974955275 " name = " Target - Release " parent = " cdt . managedbuild . config . osp . gnu . target . lib . release " > <nl> + < folderInfo id = " cdt . managedbuild . config . osp . gnu . target . lib . release . 1974955275 . " name = " / " resourcePath = " " > <nl> + < toolChain id = " cdt . managedbuild . toolchain . osp . gnu . target . lib . release . 1852576356 " name = " bada GCC ToolChain " superClass = " cdt . managedbuild . toolchain . osp . gnu . target . lib . release " > <nl> + < targetPlatform archList = " all " binaryParser = " org . eclipse . cdt . core . Cygwin_PE ; org . eclipse . cdt . core . GNU_ELF ; org . eclipse . cdt . core . ELF " id = " cdt . managedbuild . target . osp . gnu . target . platform . lib . release . 1752701988 " name = " Debug Platform " osList = " osp " superClass = " cdt . managedbuild . target . osp . gnu . target . platform . lib . release " / > <nl> + < builder buildPath = " $ { workspace_loc : / libjpeg / . Target - Release } " command = " cs - make " id = " cdt . managedbuild . target . osp . gnu . target . builder . lib . release . 413551716 " keepEnvironmentInBuildfile = " false " managedBuildOn = " true " name = " bada Builder " superClass = " cdt . managedbuild . target . osp . gnu . target . builder . lib . release " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . archiver . lib . release . 760999039 " name = " bada Archiver " superClass = " cdt . managedbuild . tool . osp . gnu . target . archiver . lib . release " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . cpp . compiler . lib . release . 1029694859 " name = " bada C + + Compiler " superClass = " cdt . managedbuild . tool . osp . gnu . target . cpp . compiler . lib . release " > <nl> + < inputType id = " cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1324381640 " superClass = " cdt . managedbuild . tool . osp . gnu . cpp . compiler . input " / > <nl> + < / tool > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . c . compiler . lib . release . 2057122348 " name = " bada C Compiler " superClass = " cdt . managedbuild . tool . osp . gnu . target . c . compiler . lib . release " > <nl> + < inputType id = " cdt . managedbuild . tool . osp . gnu . c . compiler . input . 2066479298 " superClass = " cdt . managedbuild . tool . osp . gnu . c . compiler . input " / > <nl> + < / tool > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . arm . c . linker . base . 871200190 " name = " bada C Linker " superClass = " cdt . managedbuild . tool . osp . gnu . arm . c . linker . base " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . arm . cpp . linker . base . 49635202 " name = " bada C + + Linker " superClass = " cdt . managedbuild . tool . osp . gnu . arm . cpp . linker . base " / > <nl> + < tool id = " cdt . managedbuild . tool . osp . gnu . target . assembler . lib . release . 2033720402 " name = " bada Assembler " superClass = " cdt . managedbuild . tool . osp . gnu . target . assembler . lib . release " > <nl> + < inputType id = " cdt . managedbuild . tool . osp . gnu . assembler . input . 94002818 " superClass = " cdt . managedbuild . tool . osp . gnu . assembler . input " / > <nl> + < / tool > <nl> + < / toolChain > <nl> + < / folderInfo > <nl> + < sourceEntries > <nl> + < entry flags = " VALUE_WORKSPACE_PATH | RESOLVED " kind = " sourcePath " name = " " / > <nl> + < / sourceEntries > <nl> + < / configuration > <nl> + < / storageModule > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . externalSettings " / > <nl> + < storageModule moduleId = " org . eclipse . cdt . core . language . mapping " / > <nl> + < storageModule moduleId = " scannerConfiguration " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 ; cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 . ; cdt . managedbuild . tool . osp . gnu . target . c . compiler . lib . debug . 494983528 ; cdt . managedbuild . tool . osp . gnu . c . compiler . input . 867319883 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < scannerConfigBuildInfo instanceId = " cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 ; cdt . managedbuild . config . osp . gnu . target . lib . debug . 1963573653 . ; cdt . managedbuild . tool . osp . gnu . target . cpp . compiler . lib . debug . 1383778979 ; cdt . managedbuild . tool . osp . gnu . cpp . compiler . input . 1094647355 " > <nl> + < autodiscovery enabled = " true " problemReportingEnabled = " true " selectedProfileId = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " / > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . make . core . GCCStandardMakePerFileProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " makefileGenerator " > <nl> + < runAction arguments = " - f $ { project_name } _scd . mk " command = " make " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / $ { specs_file } " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . cpp " command = " g + + " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - E - P - v - dD $ { plugin_state_location } / specs . c " command = " gcc " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfile " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / $ { specs_file } & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileCPP " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' g + + - E - P - v - dD & quot ; $ { plugin_state_location } / specs . cpp & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < profile id = " org . eclipse . cdt . managedbuilder . core . GCCWinManagedMakePerProjectProfileC " > <nl> + < buildOutputProvider > <nl> + < openAction enabled = " true " filePath = " " / > <nl> + < parser enabled = " true " / > <nl> + < / buildOutputProvider > <nl> + < scannerInfoProvider id = " specsFile " > <nl> + < runAction arguments = " - c ' gcc - E - P - v - dD & quot ; $ { plugin_state_location } / specs . c & quot ; ' " command = " sh " useDefault = " true " / > <nl> + < parser enabled = " true " / > <nl> + < / scannerInfoProvider > <nl> + < / profile > <nl> + < / scannerConfigBuildInfo > <nl> + < / storageModule > <nl> + < / cconfiguration > <nl> + < / storageModule > <nl> + < storageModule moduleId = " cdtBuildSystem " version = " 4 . 0 . 0 " > <nl> + < project id = " libjpeg . cdt . managedbuild . target . osp . gnu . arm . lib . 279951349 " name = " Static Library " projectType = " cdt . managedbuild . target . osp . gnu . arm . lib " / > <nl> + < / storageModule > <nl> + < / cproject > <nl> new file mode 100644 <nl> index 000000000000 . . 27c1f08b8246 <nl> mmm / dev / null <nl> ppp b / cocos2dx / platform / third_party / bada / src / libjpeg / sdk2 . 0 / . project <nl> <nl> + < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> + < projectDescription > <nl> + < name > libjpeg < / name > <nl> + < comment > < / comment > <nl> + < projects > <nl> + < / projects > <nl> + < buildSpec > <nl> + < buildCommand > <nl> + < name > com . osp . ide . ospmakebuilder < / name > <nl> + < triggers > clean , full , incremental , < / triggers > <nl> + < arguments > <nl> + < dictionary > <nl> + < key > ? name ? < / key > <nl> + < value > < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . append_environment < / key > <nl> + < value > true < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . autoBuildTarget < / key > <nl> + < value > all < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . buildArguments < / key > <nl> + < value > < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . buildCommand < / key > <nl> + < value > cs - make < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . buildLocation < / key > <nl> + < value > $ { workspace_loc : / libjpeg / . Simulator - Debug } < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . cleanBuildTarget < / key > <nl> + < value > clean < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . contents < / key > <nl> + < value > org . eclipse . cdt . make . core . activeConfigSettings < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . enableAutoBuild < / key > <nl> + < value > false < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . enableCleanBuild < / key > <nl> + < value > true < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . enableFullBuild < / key > <nl> + < value > true < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . fullBuildTarget < / key > <nl> + < value > all < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . stopOnError < / key > <nl> + < value > true < / value > <nl> + < / dictionary > <nl> + < dictionary > <nl> + < key > org . eclipse . cdt . make . core . useDefaultBuildCmd < / key > <nl> + < value > false < / value > <nl> + < / dictionary > <nl> + < / arguments > <nl> + < / buildCommand > <nl> + < buildCommand > <nl> + < name > org . eclipse . cdt . managedbuilder . core . ScannerConfigBuilder < / name > <nl> + < arguments > <nl> + < / arguments > <nl> + < / buildCommand > <nl> + < / buildSpec > <nl> + < natures > <nl> + < nature > org . eclipse . cdt . core . cnature < / nature > <nl> + < nature > org . eclipse . cdt . core . ccnature < / nature > <nl> + < nature > org . eclipse . cdt . managedbuilder . core . managedBuildNature < / nature > <nl> + < nature > org . eclipse . cdt . managedbuilder . core . ScannerConfigNature < / nature > <nl> + < nature > com . osp . ide . badaNature < / nature > <nl> + < / natures > <nl> + < linkedResources > <nl> + < link > <nl> + < name > src < / name > <nl> + < type > 2 < / type > <nl> + < locationURI > cocos2dx_root / cocos2dx / platform / third_party / bada / src / libjpeg / src < / locationURI > <nl> + < / link > <nl> + < / linkedResources > <nl> + < variableList > <nl> + < variable > <nl> + < name > cocos2dx_root < / name > <nl> + < value > file : / F : / cjh / project / Github / dumganhar / cocos2d - x < / value > <nl> + < / variable > <nl> + < / variableList > <nl> + < / projectDescription > <nl>
add bada 2 . 0 project
cocos2d/cocos2d-x
a54ab3c2935ecbb75fe1bcdccddedf208e94c2f9
2011-09-27T09:09:14Z
mmm a / . gitignore <nl> ppp b / . gitignore <nl> <nl> # Build Artifacts <nl> . provision <nl> build / <nl> + * . bottle . tar . gz <nl> <nl> # Run Artifacts <nl> * . log <nl> mmm a / tools / provision / formula / aws - sdk - cpp . rb <nl> ppp b / tools / provision / formula / aws - sdk - cpp . rb <nl> class AwsSdkCpp < AbstractOsqueryFormula <nl> desc " AWS SDK for C + + " <nl> homepage " https : / / github . com / aws / aws - sdk - cpp " <nl> url " https : / / github . com / aws / aws - sdk - cpp / archive / 0 . 13 . 8 . tar . gz " <nl> - revision 1 <nl> sha256 " ea3e618980f41dedfc2a6b187846a2bd747d9b6d9b95f733e04bec76cbeb1a46 " <nl> + revision 1 <nl> <nl> bottle do <nl> root_url " https : / / osquery - packages . s3 . amazonaws . com / bottles " <nl> cellar : any_skip_relocation <nl> - sha256 " 8b1c8b4b0f70972375696aa1f9b83ab3c644ee6706360878de99a6cf841217cf " = > : el_capitan <nl> - sha256 " d7aa36435c0b95752e96bc1a8459af94cc208a87846473e7043e4c9989cf8a3c " = > : x86_64_linux <nl> + sha256 " 953567c55e5ca1873d80acf33408db74079b9d4dfd2cd34ac582af0543b138ee " = > : el_capitan <nl> + sha256 " bfcf604046d739a7bde2285010fdd797e844ab1b1c2ec0e6b2d66db72f97cc65 " = > : x86_64_linux <nl> end <nl> <nl> depends_on " cmake " = > : build <nl>
Add AWS - SDK - CPP r1 hashes ( )
osquery/osquery
86363bc60a932cd73f5a86fb75510da56162f02c
2016-08-16T00:56:48Z
mmm a / modules / planning / proxy / BUILD <nl> ppp b / modules / planning / proxy / BUILD <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> load ( " / / tools : cpplint . bzl " , " cpplint " ) <nl> <nl> cc_library ( <nl> - name = " proxy " , <nl> + name = " perception_proxy " , <nl> + srcs = [ <nl> + " perception_proxy . cc " , <nl> + ] , <nl> + hdrs = [ <nl> + " perception_proxy . h " , <nl> + ] , <nl> + deps = [ <nl> + " / / external : gflags " , <nl> + " / / modules / common / math " , <nl> + " / / modules / common / status " , <nl> + " / / modules / common / util " , <nl> + " / / modules / map / proto : map_proto " , <nl> + " / / modules / perception / proto : perception_proto " , <nl> + " / / modules / planning / common : planning_gflags " , <nl> + ] , <nl> + ) <nl> + <nl> + cc_library ( <nl> + name = " routing_proxy " , <nl> srcs = [ <nl> " routing_proxy . cc " , <nl> ] , <nl> - hdrs = glob ( [ <nl> - " * . h " , <nl> - ] ) , <nl> + hdrs = [ <nl> + " routing_proxy . h " , <nl> + ] , <nl> data = [ " / / modules / map : map_data " ] , <nl> deps = [ <nl> " / / external : gflags " , <nl> new file mode 100644 <nl> index 00000000000 . . 89514f3c04e <nl> mmm / dev / null <nl> ppp b / modules / planning / proxy / perception_proxy . cc <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * <nl> + * @ file perception_proxy . cc <nl> + * * / <nl> + <nl> + # include " modules / planning / proxy / perception_proxy . h " <nl> + <nl> + # include " modules / planning / common / planning_gflags . h " <nl> + <nl> + namespace apollo { <nl> + namespace planning { <nl> + <nl> + void PerceptionProxy : : add_perception_obstacles ( <nl> + const apollo : : perception : : PerceptionObstacles & perception_obstacles ) { <nl> + if ( _perception_frame . size ( ) > <nl> + static_cast < std : : size_t > ( FLAGS_max_frame_size ) ) { <nl> + _perception_frame . pop_front ( ) ; <nl> + } <nl> + _perception_frame . emplace_back ( std : : move ( perception_obstacles ) ) ; <nl> + return ; <nl> + } <nl> + <nl> + apollo : : perception : : PerceptionObstacles * <nl> + PerceptionProxy : : get_latest_perception_frame ( ) { <nl> + if ( _perception_frame . size ( ) = = 0 ) { <nl> + return nullptr ; <nl> + } <nl> + return & ( * ( _perception_frame . rbegin ( ) ) ) ; <nl> + } <nl> + <nl> + const std : : list < apollo : : perception : : PerceptionObstacles > & <nl> + PerceptionProxy : : perception_frame ( ) const { <nl> + return _perception_frame ; <nl> + } <nl> + <nl> + } / / namespace planning <nl> + } / / namespace apollo <nl> new file mode 100644 <nl> index 00000000000 . . d8512d4b144 <nl> mmm / dev / null <nl> ppp b / modules / planning / proxy / perception_proxy . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + * Copyright 2017 The Apollo Authors . All Rights Reserved . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + / * * <nl> + * @ file perception_proxy . h <nl> + * * / <nl> + <nl> + # ifndef MODULES_PLANNING_PROXY_PERCEPTION_PROXY_H_ <nl> + # define MODULES_PLANNING_PROXY_PERCEPTION_PROXY_H_ <nl> + <nl> + # include < list > <nl> + <nl> + # include " modules / common / proto / error_code . pb . h " <nl> + # include " modules / perception / proto / perception_obstacle . pb . h " <nl> + <nl> + namespace apollo { <nl> + namespace planning { <nl> + <nl> + class PerceptionProxy { <nl> + public : <nl> + PerceptionProxy ( ) = default ; <nl> + void add_perception_obstacles ( <nl> + const apollo : : perception : : PerceptionObstacles & perception_obstacles ) ; <nl> + apollo : : perception : : PerceptionObstacles * get_latest_perception_frame ( ) ; <nl> + const std : : list < apollo : : perception : : PerceptionObstacles > & perception_frame ( ) <nl> + const ; <nl> + <nl> + private : <nl> + std : : list < apollo : : perception : : PerceptionObstacles > _perception_frame ; <nl> + } ; <nl> + <nl> + } / / namespace planning <nl> + } / / namespace apollo <nl> + <nl> + # endif / / MODULES_PLANNING_PROXY_PERCEPTION_PROXY_H_ <nl>
added perception_proxy .
ApolloAuto/apollo
e632d3abec077e5b32ff66b46de0e482f94f53d8
2017-07-20T21:57:54Z
mmm a / lib / SILOptimizer / Utils / Local . cpp <nl> ppp b / lib / SILOptimizer / Utils / Local . cpp <nl> void ValueLifetimeAnalysis : : dump ( ) const { <nl> / / Casts Optimization and Simplification <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - / / / \ brief Get a substitution corresponding to the type witness . <nl> - / / / Inspired by ProtocolConformance : : getTypeWitnessByName . <nl> - static const Substitution * <nl> - getTypeWitnessByName ( ProtocolConformance * conformance , Identifier name ) { <nl> - / / Find the named requirement . <nl> - AssociatedTypeDecl * assocType = nullptr ; <nl> - assert ( conformance & & " Missing conformance information " ) ; <nl> - auto members = conformance - > getProtocol ( ) - > lookupDirect ( name ) ; <nl> - for ( auto member : members ) { <nl> - assocType = dyn_cast < AssociatedTypeDecl > ( member ) ; <nl> - if ( assocType ) <nl> - break ; <nl> - } <nl> - <nl> - if ( ! assocType ) <nl> - return nullptr ; <nl> - <nl> - if ( ! conformance - > hasTypeWitness ( assocType , nullptr ) ) { <nl> - return nullptr ; <nl> - } <nl> - return & conformance - > getTypeWitness ( assocType , nullptr ) ; <nl> - } <nl> <nl> / / / Check if is a bridging cast , i . e . one of the sides is <nl> / / / a bridged type . <nl>
[ SIL Optimizer ] Remove now - unused static function . NFC
apple/swift
eacf223f650800d09b3b32066126dc6a827c1893
2016-11-09T00:11:30Z
mmm a / src / core / hle / kernel / object . cpp <nl> ppp b / src / core / hle / kernel / object . cpp <nl> bool Object : : IsWaitable ( ) const { <nl> case HandleType : : Process : <nl> case HandleType : : AddressArbiter : <nl> case HandleType : : ResourceLimit : <nl> - case HandleType : : CodeSet : <nl> case HandleType : : ClientPort : <nl> case HandleType : : ClientSession : <nl> return false ; <nl> mmm a / src / core / hle / kernel / object . h <nl> ppp b / src / core / hle / kernel / object . h <nl> enum class HandleType : u32 { <nl> AddressArbiter , <nl> Timer , <nl> ResourceLimit , <nl> - CodeSet , <nl> ClientPort , <nl> ServerPort , <nl> ClientSession , <nl> mmm a / src / core / hle / kernel / process . cpp <nl> ppp b / src / core / hle / kernel / process . cpp <nl> <nl> <nl> namespace Kernel { <nl> <nl> - SharedPtr < CodeSet > CodeSet : : Create ( KernelCore & kernel , std : : string name ) { <nl> - SharedPtr < CodeSet > codeset ( new CodeSet ( kernel ) ) ; <nl> - codeset - > name = std : : move ( name ) ; <nl> - return codeset ; <nl> - } <nl> - <nl> - CodeSet : : CodeSet ( KernelCore & kernel ) : Object { kernel } { } <nl> + CodeSet : : CodeSet ( ) = default ; <nl> CodeSet : : ~ CodeSet ( ) = default ; <nl> <nl> SharedPtr < Process > Process : : Create ( KernelCore & kernel , std : : string & & name ) { <nl> void Process : : FreeTLSSlot ( VAddr tls_address ) { <nl> tls_slots [ tls_page ] . reset ( tls_slot ) ; <nl> } <nl> <nl> - void Process : : LoadModule ( SharedPtr < CodeSet > module_ , VAddr base_addr ) { <nl> + void Process : : LoadModule ( CodeSet module_ , VAddr base_addr ) { <nl> const auto MapSegment = [ & ] ( CodeSet : : Segment & segment , VMAPermission permissions , <nl> MemoryState memory_state ) { <nl> - auto vma = vm_manager <nl> - . MapMemoryBlock ( segment . addr + base_addr , module_ - > memory , segment . offset , <nl> - segment . size , memory_state ) <nl> - . Unwrap ( ) ; <nl> + const auto vma = vm_manager <nl> + . MapMemoryBlock ( segment . addr + base_addr , module_ . memory , <nl> + segment . offset , segment . size , memory_state ) <nl> + . Unwrap ( ) ; <nl> vm_manager . Reprotect ( vma , permissions ) ; <nl> } ; <nl> <nl> / / Map CodeSet segments <nl> - MapSegment ( module_ - > CodeSegment ( ) , VMAPermission : : ReadExecute , MemoryState : : CodeStatic ) ; <nl> - MapSegment ( module_ - > RODataSegment ( ) , VMAPermission : : Read , MemoryState : : CodeMutable ) ; <nl> - MapSegment ( module_ - > DataSegment ( ) , VMAPermission : : ReadWrite , MemoryState : : CodeMutable ) ; <nl> + MapSegment ( module_ . CodeSegment ( ) , VMAPermission : : ReadExecute , MemoryState : : CodeStatic ) ; <nl> + MapSegment ( module_ . RODataSegment ( ) , VMAPermission : : Read , MemoryState : : CodeMutable ) ; <nl> + MapSegment ( module_ . DataSegment ( ) , VMAPermission : : ReadWrite , MemoryState : : CodeMutable ) ; <nl> } <nl> <nl> ResultVal < VAddr > Process : : HeapAllocate ( VAddr target , u64 size , VMAPermission perms ) { <nl> mmm a / src / core / hle / kernel / process . h <nl> ppp b / src / core / hle / kernel / process . h <nl> enum class ProcessStatus { Created , Running , Exited } ; <nl> <nl> class ResourceLimit ; <nl> <nl> - struct CodeSet final : public Object { <nl> + struct CodeSet final { <nl> struct Segment { <nl> std : : size_t offset = 0 ; <nl> VAddr addr = 0 ; <nl> u32 size = 0 ; <nl> } ; <nl> <nl> - static SharedPtr < CodeSet > Create ( KernelCore & kernel , std : : string name ) ; <nl> - <nl> - std : : string GetTypeName ( ) const override { <nl> - return " CodeSet " ; <nl> - } <nl> - std : : string GetName ( ) const override { <nl> - return name ; <nl> - } <nl> - <nl> - static const HandleType HANDLE_TYPE = HandleType : : CodeSet ; <nl> - HandleType GetHandleType ( ) const override { <nl> - return HANDLE_TYPE ; <nl> - } <nl> + explicit CodeSet ( ) ; <nl> + ~ CodeSet ( ) ; <nl> <nl> Segment & CodeSegment ( ) { <nl> return segments [ 0 ] ; <nl> struct CodeSet final : public Object { <nl> std : : shared_ptr < std : : vector < u8 > > memory ; <nl> <nl> std : : array < Segment , 3 > segments ; <nl> - VAddr entrypoint ; <nl> - <nl> - / / / Name of the process <nl> - std : : string name ; <nl> - <nl> - private : <nl> - explicit CodeSet ( KernelCore & kernel ) ; <nl> - ~ CodeSet ( ) override ; <nl> + VAddr entrypoint = 0 ; <nl> } ; <nl> <nl> class Process final : public Object { <nl> class Process final : public Object { <nl> * / <nl> void PrepareForTermination ( ) ; <nl> <nl> - void LoadModule ( SharedPtr < CodeSet > module_ , VAddr base_addr ) ; <nl> + void LoadModule ( CodeSet module_ , VAddr base_addr ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Memory Management <nl> mmm a / src / core / loader / elf . cpp <nl> ppp b / src / core / loader / elf . cpp <nl> <nl> # include " common / common_types . h " <nl> # include " common / file_util . h " <nl> # include " common / logging / log . h " <nl> - # include " core / core . h " <nl> - # include " core / hle / kernel / kernel . h " <nl> # include " core / hle / kernel / process . h " <nl> # include " core / hle / kernel / vm_manager . h " <nl> # include " core / loader / elf . h " <nl> # include " core / memory . h " <nl> <nl> - using Kernel : : CodeSet ; <nl> - using Kernel : : SharedPtr ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / ELF Header Constants <nl> <nl> class ElfReader { <nl> u32 GetFlags ( ) const { <nl> return ( u32 ) ( header - > e_flags ) ; <nl> } <nl> - SharedPtr < CodeSet > LoadInto ( VAddr vaddr ) ; <nl> + Kernel : : CodeSet LoadInto ( VAddr vaddr ) ; <nl> <nl> int GetNumSegments ( ) const { <nl> return ( int ) ( header - > e_phnum ) ; <nl> const char * ElfReader : : GetSectionName ( int section ) const { <nl> return nullptr ; <nl> } <nl> <nl> - SharedPtr < CodeSet > ElfReader : : LoadInto ( VAddr vaddr ) { <nl> + Kernel : : CodeSet ElfReader : : LoadInto ( VAddr vaddr ) { <nl> LOG_DEBUG ( Loader , " String section : { } " , header - > e_shstrndx ) ; <nl> <nl> / / Should we relocate ? <nl> SharedPtr < CodeSet > ElfReader : : LoadInto ( VAddr vaddr ) { <nl> std : : vector < u8 > program_image ( total_image_size ) ; <nl> std : : size_t current_image_position = 0 ; <nl> <nl> - auto & kernel = Core : : System : : GetInstance ( ) . Kernel ( ) ; <nl> - SharedPtr < CodeSet > codeset = CodeSet : : Create ( kernel , " " ) ; <nl> + Kernel : : CodeSet codeset ; <nl> <nl> for ( unsigned int i = 0 ; i < header - > e_phnum ; + + i ) { <nl> const Elf32_Phdr * p = & segments [ i ] ; <nl> SharedPtr < CodeSet > ElfReader : : LoadInto ( VAddr vaddr ) { <nl> p - > p_vaddr , p - > p_filesz , p - > p_memsz ) ; <nl> <nl> if ( p - > p_type = = PT_LOAD ) { <nl> - CodeSet : : Segment * codeset_segment ; <nl> + Kernel : : CodeSet : : Segment * codeset_segment ; <nl> u32 permission_flags = p - > p_flags & ( PF_R | PF_W | PF_X ) ; <nl> if ( permission_flags = = ( PF_R | PF_X ) ) { <nl> - codeset_segment = & codeset - > CodeSegment ( ) ; <nl> + codeset_segment = & codeset . CodeSegment ( ) ; <nl> } else if ( permission_flags = = ( PF_R ) ) { <nl> - codeset_segment = & codeset - > RODataSegment ( ) ; <nl> + codeset_segment = & codeset . RODataSegment ( ) ; <nl> } else if ( permission_flags = = ( PF_R | PF_W ) ) { <nl> - codeset_segment = & codeset - > DataSegment ( ) ; <nl> + codeset_segment = & codeset . DataSegment ( ) ; <nl> } else { <nl> LOG_ERROR ( Loader , " Unexpected ELF PT_LOAD segment id { } with flags { : X } " , i , <nl> p - > p_flags ) ; <nl> SharedPtr < CodeSet > ElfReader : : LoadInto ( VAddr vaddr ) { <nl> } <nl> } <nl> <nl> - codeset - > entrypoint = base_addr + header - > e_entry ; <nl> - codeset - > memory = std : : make_shared < std : : vector < u8 > > ( std : : move ( program_image ) ) ; <nl> + codeset . entrypoint = base_addr + header - > e_entry ; <nl> + codeset . memory = std : : make_shared < std : : vector < u8 > > ( std : : move ( program_image ) ) ; <nl> <nl> LOG_DEBUG ( Loader , " Done loading . " ) ; <nl> <nl> ResultStatus AppLoader_ELF : : Load ( Kernel : : Process & process ) { <nl> <nl> const VAddr base_address = process . VMManager ( ) . GetCodeRegionBaseAddress ( ) ; <nl> ElfReader elf_reader ( & buffer [ 0 ] ) ; <nl> - SharedPtr < CodeSet > codeset = elf_reader . LoadInto ( base_address ) ; <nl> - codeset - > name = file - > GetName ( ) ; <nl> + Kernel : : CodeSet codeset = elf_reader . LoadInto ( base_address ) ; <nl> + const VAddr entry_point = codeset . entrypoint ; <nl> <nl> - process . LoadModule ( codeset , codeset - > entrypoint ) ; <nl> - process . Run ( codeset - > entrypoint , 48 , Memory : : DEFAULT_STACK_SIZE ) ; <nl> + process . LoadModule ( std : : move ( codeset ) , entry_point ) ; <nl> + process . Run ( entry_point , 48 , Memory : : DEFAULT_STACK_SIZE ) ; <nl> <nl> is_loaded = true ; <nl> return ResultStatus : : Success ; <nl> mmm a / src / core / loader / nro . cpp <nl> ppp b / src / core / loader / nro . cpp <nl> <nl> # include " core / file_sys / control_metadata . h " <nl> # include " core / file_sys / vfs_offset . h " <nl> # include " core / gdbstub / gdbstub . h " <nl> - # include " core / hle / kernel / kernel . h " <nl> # include " core / hle / kernel / process . h " <nl> # include " core / hle / kernel / vm_manager . h " <nl> # include " core / loader / nro . h " <nl> bool AppLoader_NRO : : LoadNro ( FileSys : : VirtualFile file , VAddr load_base ) { <nl> } <nl> <nl> / / Build program image <nl> - auto & kernel = Core : : System : : GetInstance ( ) . Kernel ( ) ; <nl> - Kernel : : SharedPtr < Kernel : : CodeSet > codeset = Kernel : : CodeSet : : Create ( kernel , " " ) ; <nl> std : : vector < u8 > program_image = file - > ReadBytes ( PageAlignSize ( nro_header . file_size ) ) ; <nl> if ( program_image . size ( ) ! = PageAlignSize ( nro_header . file_size ) ) { <nl> return { } ; <nl> } <nl> <nl> + Kernel : : CodeSet codeset ; <nl> for ( std : : size_t i = 0 ; i < nro_header . segments . size ( ) ; + + i ) { <nl> - codeset - > segments [ i ] . addr = nro_header . segments [ i ] . offset ; <nl> - codeset - > segments [ i ] . offset = nro_header . segments [ i ] . offset ; <nl> - codeset - > segments [ i ] . size = PageAlignSize ( nro_header . segments [ i ] . size ) ; <nl> + codeset . segments [ i ] . addr = nro_header . segments [ i ] . offset ; <nl> + codeset . segments [ i ] . offset = nro_header . segments [ i ] . offset ; <nl> + codeset . segments [ i ] . size = PageAlignSize ( nro_header . segments [ i ] . size ) ; <nl> } <nl> <nl> if ( ! Settings : : values . program_args . empty ( ) ) { <nl> const auto arg_data = Settings : : values . program_args ; <nl> - codeset - > DataSegment ( ) . size + = NSO_ARGUMENT_DATA_ALLOCATION_SIZE ; <nl> + codeset . DataSegment ( ) . size + = NSO_ARGUMENT_DATA_ALLOCATION_SIZE ; <nl> NSOArgumentHeader args_header { <nl> NSO_ARGUMENT_DATA_ALLOCATION_SIZE , static_cast < u32_le > ( arg_data . size ( ) ) , { } } ; <nl> const auto end_offset = program_image . size ( ) ; <nl> bool AppLoader_NRO : : LoadNro ( FileSys : : VirtualFile file , VAddr load_base ) { <nl> / / Resize program image to include . bss section and page align each section <nl> bss_size = PageAlignSize ( mod_header . bss_end_offset - mod_header . bss_start_offset ) ; <nl> } <nl> - codeset - > DataSegment ( ) . size + = bss_size ; <nl> + codeset . DataSegment ( ) . size + = bss_size ; <nl> program_image . resize ( static_cast < u32 > ( program_image . size ( ) ) + bss_size ) ; <nl> <nl> / / Load codeset for current process <nl> - codeset - > name = file - > GetName ( ) ; <nl> - codeset - > memory = std : : make_shared < std : : vector < u8 > > ( std : : move ( program_image ) ) ; <nl> - Core : : CurrentProcess ( ) - > LoadModule ( codeset , load_base ) ; <nl> + codeset . memory = std : : make_shared < std : : vector < u8 > > ( std : : move ( program_image ) ) ; <nl> + Core : : CurrentProcess ( ) - > LoadModule ( std : : move ( codeset ) , load_base ) ; <nl> <nl> / / Register module with GDBStub <nl> - GDBStub : : RegisterModule ( codeset - > name , load_base , load_base ) ; <nl> + GDBStub : : RegisterModule ( file - > GetName ( ) , load_base , load_base ) ; <nl> <nl> return true ; <nl> } <nl> mmm a / src / core / loader / nso . cpp <nl> ppp b / src / core / loader / nso . cpp <nl> <nl> # include " core / core . h " <nl> # include " core / file_sys / patch_manager . h " <nl> # include " core / gdbstub / gdbstub . h " <nl> - # include " core / hle / kernel / kernel . h " <nl> # include " core / hle / kernel / process . h " <nl> # include " core / hle / kernel / vm_manager . h " <nl> # include " core / loader / nso . h " <nl> VAddr AppLoader_NSO : : LoadModule ( FileSys : : VirtualFile file , VAddr load_base , <nl> return { } ; <nl> <nl> / / Build program image <nl> - auto & kernel = Core : : System : : GetInstance ( ) . Kernel ( ) ; <nl> - Kernel : : SharedPtr < Kernel : : CodeSet > codeset = Kernel : : CodeSet : : Create ( kernel , " " ) ; <nl> + Kernel : : CodeSet codeset ; <nl> std : : vector < u8 > program_image ; <nl> for ( std : : size_t i = 0 ; i < nso_header . segments . size ( ) ; + + i ) { <nl> std : : vector < u8 > data = <nl> VAddr AppLoader_NSO : : LoadModule ( FileSys : : VirtualFile file , VAddr load_base , <nl> } <nl> program_image . resize ( nso_header . segments [ i ] . location ) ; <nl> program_image . insert ( program_image . end ( ) , data . begin ( ) , data . end ( ) ) ; <nl> - codeset - > segments [ i ] . addr = nso_header . segments [ i ] . location ; <nl> - codeset - > segments [ i ] . offset = nso_header . segments [ i ] . location ; <nl> - codeset - > segments [ i ] . size = PageAlignSize ( static_cast < u32 > ( data . size ( ) ) ) ; <nl> + codeset . segments [ i ] . addr = nso_header . segments [ i ] . location ; <nl> + codeset . segments [ i ] . offset = nso_header . segments [ i ] . location ; <nl> + codeset . segments [ i ] . size = PageAlignSize ( static_cast < u32 > ( data . size ( ) ) ) ; <nl> } <nl> <nl> if ( should_pass_arguments & & ! Settings : : values . program_args . empty ( ) ) { <nl> const auto arg_data = Settings : : values . program_args ; <nl> - codeset - > DataSegment ( ) . size + = NSO_ARGUMENT_DATA_ALLOCATION_SIZE ; <nl> + codeset . DataSegment ( ) . size + = NSO_ARGUMENT_DATA_ALLOCATION_SIZE ; <nl> NSOArgumentHeader args_header { <nl> NSO_ARGUMENT_DATA_ALLOCATION_SIZE , static_cast < u32_le > ( arg_data . size ( ) ) , { } } ; <nl> const auto end_offset = program_image . size ( ) ; <nl> VAddr AppLoader_NSO : : LoadModule ( FileSys : : VirtualFile file , VAddr load_base , <nl> / / Resize program image to include . bss section and page align each section <nl> bss_size = PageAlignSize ( mod_header . bss_end_offset - mod_header . bss_start_offset ) ; <nl> } <nl> - codeset - > DataSegment ( ) . size + = bss_size ; <nl> + codeset . DataSegment ( ) . size + = bss_size ; <nl> const u32 image_size { PageAlignSize ( static_cast < u32 > ( program_image . size ( ) ) + bss_size ) } ; <nl> program_image . resize ( image_size ) ; <nl> <nl> VAddr AppLoader_NSO : : LoadModule ( FileSys : : VirtualFile file , VAddr load_base , <nl> } <nl> <nl> / / Load codeset for current process <nl> - codeset - > name = file - > GetName ( ) ; <nl> - codeset - > memory = std : : make_shared < std : : vector < u8 > > ( std : : move ( program_image ) ) ; <nl> - Core : : CurrentProcess ( ) - > LoadModule ( codeset , load_base ) ; <nl> + codeset . memory = std : : make_shared < std : : vector < u8 > > ( std : : move ( program_image ) ) ; <nl> + Core : : CurrentProcess ( ) - > LoadModule ( std : : move ( codeset ) , load_base ) ; <nl> <nl> / / Register module with GDBStub <nl> - GDBStub : : RegisterModule ( codeset - > name , load_base , load_base ) ; <nl> + GDBStub : : RegisterModule ( file - > GetName ( ) , load_base , load_base ) ; <nl> <nl> return load_base + image_size ; <nl> } <nl>
kernel / process : Make CodeSet a regular non - inherited object
yuzu-emu/yuzu
1abed2f4c42c7a389cb0e019f183d3ec94971af1
2018-10-12T16:07:32Z
mmm a / include / grpc / census . h <nl> ppp b / include / grpc / census . h <nl> typedef enum { <nl> the results it provides . The following structures allow us to use a generic <nl> type for each of those . <nl> <nl> - Types referenced ( one for each stat type in census_stat_type ) : <nl> - * / <nl> + Types referenced ( one for each stat type in census_stat_type , by creation <nl> + arguments , output blob , and object representation . * / <nl> <nl> typedef struct census_stat_scalar_create_arg census_stat_scalar_create_arg ; <nl> typedef struct census_stat_distribution_create_arg <nl>
nc
grpc/grpc
6723cc8cf751d137745b304594caa8d124619bce
2015-08-25T22:03:03Z
mmm a / include / v8 - profiler . h <nl> ppp b / include / v8 - profiler . h <nl> namespace v8 { <nl> <nl> / * * <nl> * TracingCpuProfiler monitors tracing being enabled / disabled <nl> - * and emits CpuProfile trace events once v8 . cpu_profile2 tracing category <nl> + * and emits CpuProfile trace events once v8 . cpu_profiler tracing category <nl> * is enabled . It has no overhead unless the category is enabled . <nl> * / <nl> class V8_EXPORT TracingCpuProfiler { <nl> mmm a / src / profiler / cpu - profiler . cc <nl> ppp b / src / profiler / cpu - profiler . cc <nl> void CpuProfiler : : StartProcessorIfNotStarted ( ) { <nl> processor_ - > StartSynchronously ( ) ; <nl> } <nl> <nl> - <nl> CpuProfile * CpuProfiler : : StopProfiling ( const char * title ) { <nl> if ( ! is_profiling_ ) return nullptr ; <nl> StopProcessorIfLastProfile ( title ) ; <nl> - CpuProfile * result = profiles_ - > StopProfiling ( title ) ; <nl> - if ( result ) { <nl> - result - > Print ( ) ; <nl> - } <nl> - return result ; <nl> + return profiles_ - > StopProfiling ( title ) ; <nl> } <nl> <nl> - <nl> CpuProfile * CpuProfiler : : StopProfiling ( String * title ) { <nl> - if ( ! is_profiling_ ) return nullptr ; <nl> - const char * profile_title = profiles_ - > GetName ( title ) ; <nl> - StopProcessorIfLastProfile ( profile_title ) ; <nl> - return profiles_ - > StopProfiling ( profile_title ) ; <nl> + return StopProfiling ( profiles_ - > GetName ( title ) ) ; <nl> } <nl> <nl> - <nl> void CpuProfiler : : StopProcessorIfLastProfile ( const char * title ) { <nl> - if ( profiles_ - > IsLastProfile ( title ) ) { <nl> - StopProcessor ( ) ; <nl> - } <nl> + if ( ! profiles_ - > IsLastProfile ( title ) ) return ; <nl> + StopProcessor ( ) ; <nl> } <nl> <nl> - <nl> void CpuProfiler : : StopProcessor ( ) { <nl> Logger * logger = isolate_ - > logger ( ) ; <nl> is_profiling_ = false ; <nl> mmm a / src / profiler / profile - generator - inl . h <nl> ppp b / src / profiler / profile - generator - inl . h <nl> CodeEntry : : CodeEntry ( CodeEventListener : : LogEventsAndTags tag , const char * name , <nl> line_info_ ( line_info ) , <nl> instruction_start_ ( instruction_start ) { } <nl> <nl> - ProfileNode : : ProfileNode ( ProfileTree * tree , CodeEntry * entry ) <nl> + ProfileNode : : ProfileNode ( ProfileTree * tree , CodeEntry * entry , <nl> + ProfileNode * parent ) <nl> : tree_ ( tree ) , <nl> entry_ ( entry ) , <nl> self_ticks_ ( 0 ) , <nl> children_ ( CodeEntriesMatch ) , <nl> + parent_ ( parent ) , <nl> id_ ( tree - > next_node_id ( ) ) , <nl> - line_ticks_ ( LineTickMatch ) { } <nl> - <nl> + line_ticks_ ( LineTickMatch ) { <nl> + tree_ - > EnqueueNode ( this ) ; <nl> + } <nl> <nl> inline unsigned ProfileNode : : function_id ( ) const { <nl> return tree_ - > GetFunctionId ( this ) ; <nl> } <nl> <nl> - <nl> inline Isolate * ProfileNode : : isolate ( ) const { return tree_ - > isolate ( ) ; } <nl> <nl> } / / namespace internal <nl> mmm a / src / profiler / profile - generator . cc <nl> ppp b / src / profiler / profile - generator . cc <nl> <nl> # include " src / global - handles . h " <nl> # include " src / profiler / cpu - profiler . h " <nl> # include " src / profiler / profile - generator - inl . h " <nl> + # include " src / tracing / trace - event . h " <nl> + # include " src / tracing / traced - value . h " <nl> # include " src / unicode . h " <nl> <nl> namespace v8 { <nl> ProfileNode * ProfileNode : : FindOrAddChild ( CodeEntry * entry ) { <nl> base : : HashMap : : Entry * map_entry = <nl> children_ . LookupOrInsert ( entry , CodeEntryHash ( entry ) ) ; <nl> ProfileNode * node = reinterpret_cast < ProfileNode * > ( map_entry - > value ) ; <nl> - if ( node = = NULL ) { <nl> - / / New node added . <nl> - node = new ProfileNode ( tree_ , entry ) ; <nl> + if ( ! node ) { <nl> + node = new ProfileNode ( tree_ , entry , this ) ; <nl> map_entry - > value = node ; <nl> children_list_ . Add ( node ) ; <nl> } <nl> class DeleteNodesCallback { <nl> ProfileTree : : ProfileTree ( Isolate * isolate ) <nl> : root_entry_ ( CodeEventListener : : FUNCTION_TAG , " ( root ) " ) , <nl> next_node_id_ ( 1 ) , <nl> - root_ ( new ProfileNode ( this , & root_entry_ ) ) , <nl> + root_ ( new ProfileNode ( this , & root_entry_ , nullptr ) ) , <nl> isolate_ ( isolate ) , <nl> next_function_id_ ( 1 ) , <nl> function_ids_ ( ProfileNode : : CodeEntriesMatch ) { } <nl> void ProfileTree : : TraverseDepthFirst ( Callback * callback ) { <nl> } <nl> } <nl> <nl> + using v8 : : tracing : : TracedValue ; <nl> + <nl> CpuProfile : : CpuProfile ( CpuProfiler * profiler , const char * title , <nl> bool record_samples ) <nl> : title_ ( title ) , <nl> record_samples_ ( record_samples ) , <nl> start_time_ ( base : : TimeTicks : : HighResolutionNow ( ) ) , <nl> top_down_ ( profiler - > isolate ( ) ) , <nl> - profiler_ ( profiler ) { } <nl> + profiler_ ( profiler ) , <nl> + streaming_next_sample_ ( 0 ) { <nl> + auto value = TracedValue : : Create ( ) ; <nl> + value - > SetDouble ( " startTime " , <nl> + ( start_time_ - base : : TimeTicks ( ) ) . InMicroseconds ( ) ) ; <nl> + TRACE_EVENT_SAMPLE_WITH_ID1 ( TRACE_DISABLED_BY_DEFAULT ( " v8 . cpu_profiler " ) , <nl> + " CpuProfile " , this , " data " , std : : move ( value ) ) ; <nl> + } <nl> <nl> void CpuProfile : : AddPath ( base : : TimeTicks timestamp , <nl> const std : : vector < CodeEntry * > & path , int src_line , <nl> void CpuProfile : : AddPath ( base : : TimeTicks timestamp , <nl> timestamps_ . Add ( timestamp ) ; <nl> samples_ . Add ( top_frame_node ) ; <nl> } <nl> + const int kSamplesFlushCount = 100 ; <nl> + const int kNodesFlushCount = 10 ; <nl> + if ( samples_ . length ( ) - streaming_next_sample_ > = kSamplesFlushCount | | <nl> + top_down_ . pending_nodes_count ( ) > = kNodesFlushCount ) { <nl> + StreamPendingTraceEvents ( ) ; <nl> + } <nl> + } <nl> + <nl> + namespace { <nl> + <nl> + void BuildNodeValue ( const ProfileNode * node , TracedValue * value ) { <nl> + const CodeEntry * entry = node - > entry ( ) ; <nl> + value - > BeginDictionary ( " callFrame " ) ; <nl> + value - > SetString ( " functionName " , entry - > name ( ) ) ; <nl> + if ( * entry - > resource_name ( ) ) { <nl> + value - > SetString ( " url " , entry - > resource_name ( ) ) ; <nl> + } <nl> + value - > SetInteger ( " scriptId " , entry - > script_id ( ) ) ; <nl> + if ( entry - > line_number ( ) ) { <nl> + value - > SetInteger ( " lineNumber " , entry - > line_number ( ) - 1 ) ; <nl> + } <nl> + if ( entry - > column_number ( ) ) { <nl> + value - > SetInteger ( " columnNumber " , entry - > column_number ( ) - 1 ) ; <nl> + } <nl> + value - > EndDictionary ( ) ; <nl> + value - > SetInteger ( " id " , node - > id ( ) ) ; <nl> + if ( node - > parent ( ) ) { <nl> + value - > SetInteger ( " parent " , node - > parent ( ) - > id ( ) ) ; <nl> + } <nl> + const char * deopt_reason = entry - > bailout_reason ( ) ; <nl> + if ( deopt_reason & & deopt_reason [ 0 ] & & strcmp ( deopt_reason , " no reason " ) ) { <nl> + value - > SetString ( " deoptReason " , deopt_reason ) ; <nl> + } <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + void CpuProfile : : StreamPendingTraceEvents ( ) { <nl> + std : : vector < const ProfileNode * > pending_nodes = top_down_ . TakePendingNodes ( ) ; <nl> + if ( pending_nodes . empty ( ) & & ! samples_ . length ( ) ) return ; <nl> + auto value = TracedValue : : Create ( ) ; <nl> + <nl> + if ( ! pending_nodes . empty ( ) ) { <nl> + value - > BeginArray ( " nodes " ) ; <nl> + for ( auto node : pending_nodes ) { <nl> + value - > BeginDictionary ( ) ; <nl> + BuildNodeValue ( node , value . get ( ) ) ; <nl> + value - > EndDictionary ( ) ; <nl> + } <nl> + value - > EndArray ( ) ; <nl> + } <nl> + <nl> + if ( streaming_next_sample_ ! = samples_ . length ( ) ) { <nl> + value - > BeginArray ( " samples " ) ; <nl> + for ( int i = streaming_next_sample_ ; i < samples_ . length ( ) ; + + i ) { <nl> + value - > AppendInteger ( samples_ [ i ] - > id ( ) ) ; <nl> + } <nl> + value - > EndArray ( ) ; <nl> + value - > BeginArray ( " timeDeltas " ) ; <nl> + base : : TimeTicks lastTimestamp = <nl> + streaming_next_sample_ ? timestamps_ [ streaming_next_sample_ - 1 ] <nl> + : start_time ( ) ; <nl> + for ( int i = streaming_next_sample_ ; i < timestamps_ . length ( ) ; + + i ) { <nl> + value - > AppendInteger ( <nl> + static_cast < int > ( ( timestamps_ [ i ] - lastTimestamp ) . InMicroseconds ( ) ) ) ; <nl> + lastTimestamp = timestamps_ [ i ] ; <nl> + } <nl> + value - > EndArray ( ) ; <nl> + DCHECK ( samples_ . length ( ) = = timestamps_ . length ( ) ) ; <nl> + streaming_next_sample_ = samples_ . length ( ) ; <nl> + } <nl> + <nl> + TRACE_EVENT_SAMPLE_WITH_ID1 ( TRACE_DISABLED_BY_DEFAULT ( " v8 . cpu_profiler " ) , <nl> + " CpuProfileChunk " , this , " data " , <nl> + std : : move ( value ) ) ; <nl> } <nl> <nl> - void CpuProfile : : CalculateTotalTicksAndSamplingRate ( ) { <nl> + void CpuProfile : : FinishProfile ( ) { <nl> end_time_ = base : : TimeTicks : : HighResolutionNow ( ) ; <nl> + StreamPendingTraceEvents ( ) ; <nl> + auto value = TracedValue : : Create ( ) ; <nl> + value - > SetDouble ( " endTime " , ( end_time_ - base : : TimeTicks ( ) ) . InMicroseconds ( ) ) ; <nl> + TRACE_EVENT_SAMPLE_WITH_ID1 ( TRACE_DISABLED_BY_DEFAULT ( " v8 . cpu_profiler " ) , <nl> + " CpuProfileChunk " , this , " data " , <nl> + std : : move ( value ) ) ; <nl> } <nl> <nl> void CpuProfile : : Print ( ) { <nl> bool CpuProfilesCollection : : StartProfiling ( const char * title , <nl> <nl> CpuProfile * CpuProfilesCollection : : StopProfiling ( const char * title ) { <nl> const int title_len = StrLength ( title ) ; <nl> - CpuProfile * profile = NULL ; <nl> + CpuProfile * profile = nullptr ; <nl> current_profiles_semaphore_ . Wait ( ) ; <nl> for ( int i = current_profiles_ . length ( ) - 1 ; i > = 0 ; - - i ) { <nl> if ( title_len = = 0 | | strcmp ( current_profiles_ [ i ] - > title ( ) , title ) = = 0 ) { <nl> CpuProfile * CpuProfilesCollection : : StopProfiling ( const char * title ) { <nl> } <nl> current_profiles_semaphore_ . Signal ( ) ; <nl> <nl> - if ( profile = = NULL ) return NULL ; <nl> - profile - > CalculateTotalTicksAndSamplingRate ( ) ; <nl> + if ( ! profile ) return nullptr ; <nl> + profile - > FinishProfile ( ) ; <nl> finished_profiles_ . Add ( profile ) ; <nl> return profile ; <nl> } <nl> mmm a / src / profiler / profile - generator . h <nl> ppp b / src / profiler / profile - generator . h <nl> class ProfileTree ; <nl> <nl> class ProfileNode { <nl> public : <nl> - inline ProfileNode ( ProfileTree * tree , CodeEntry * entry ) ; <nl> + inline ProfileNode ( ProfileTree * tree , CodeEntry * entry , ProfileNode * parent ) ; <nl> <nl> ProfileNode * FindChild ( CodeEntry * entry ) ; <nl> ProfileNode * FindOrAddChild ( CodeEntry * entry ) ; <nl> class ProfileNode { <nl> const List < ProfileNode * > * children ( ) const { return & children_list_ ; } <nl> unsigned id ( ) const { return id_ ; } <nl> unsigned function_id ( ) const ; <nl> + ProfileNode * parent ( ) const { return parent_ ; } <nl> unsigned int GetHitLineCount ( ) const { return line_ticks_ . occupancy ( ) ; } <nl> bool GetLineTicks ( v8 : : CpuProfileNode : : LineTick * entries , <nl> unsigned int length ) const ; <nl> class ProfileNode { <nl> / / Mapping from CodeEntry * to ProfileNode * <nl> base : : CustomMatcherHashMap children_ ; <nl> List < ProfileNode * > children_list_ ; <nl> + ProfileNode * parent_ ; <nl> unsigned id_ ; <nl> base : : CustomMatcherHashMap line_ticks_ ; <nl> <nl> class ProfileTree { <nl> <nl> Isolate * isolate ( ) const { return isolate_ ; } <nl> <nl> + void EnqueueNode ( const ProfileNode * node ) { pending_nodes_ . push_back ( node ) ; } <nl> + size_t pending_nodes_count ( ) const { return pending_nodes_ . size ( ) ; } <nl> + std : : vector < const ProfileNode * > TakePendingNodes ( ) { <nl> + return std : : move ( pending_nodes_ ) ; <nl> + } <nl> + <nl> private : <nl> template < typename Callback > <nl> void TraverseDepthFirst ( Callback * callback ) ; <nl> <nl> + std : : vector < const ProfileNode * > pending_nodes_ ; <nl> + <nl> CodeEntry root_entry_ ; <nl> unsigned next_node_id_ ; <nl> ProfileNode * root_ ; <nl> class CpuProfile { <nl> / / Add pc - > . . . - > main ( ) call path to the profile . <nl> void AddPath ( base : : TimeTicks timestamp , const std : : vector < CodeEntry * > & path , <nl> int src_line , bool update_stats ) ; <nl> - void CalculateTotalTicksAndSamplingRate ( ) ; <nl> + void FinishProfile ( ) ; <nl> <nl> const char * title ( ) const { return title_ ; } <nl> const ProfileTree * top_down ( ) const { return & top_down_ ; } <nl> class CpuProfile { <nl> void Print ( ) ; <nl> <nl> private : <nl> + void StreamPendingTraceEvents ( ) ; <nl> + <nl> const char * title_ ; <nl> bool record_samples_ ; <nl> base : : TimeTicks start_time_ ; <nl> class CpuProfile { <nl> List < base : : TimeTicks > timestamps_ ; <nl> ProfileTree top_down_ ; <nl> CpuProfiler * const profiler_ ; <nl> + int streaming_next_sample_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( CpuProfile ) ; <nl> } ; <nl> mmm a / src / profiler / tracing - cpu - profiler . cc <nl> ppp b / src / profiler / tracing - cpu - profiler . cc <nl> <nl> <nl> # include " src / profiler / tracing - cpu - profiler . h " <nl> <nl> + # include " src / profiler / cpu - profiler . h " <nl> + # include " src / tracing / trace - event . h " <nl> # include " src / v8 . h " <nl> <nl> + # define PROFILER_TRACE_CATEGORY_ENABLED ( cat ) \ <nl> + ( * TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED ( TRACE_DISABLED_BY_DEFAULT ( cat ) ) ) <nl> + <nl> namespace v8 { <nl> <nl> std : : unique_ptr < TracingCpuProfiler > TracingCpuProfiler : : Create ( <nl> std : : unique_ptr < TracingCpuProfiler > TracingCpuProfiler : : Create ( <nl> <nl> namespace internal { <nl> <nl> - TracingCpuProfilerImpl : : TracingCpuProfilerImpl ( Isolate * isolate ) { } <nl> + TracingCpuProfilerImpl : : TracingCpuProfilerImpl ( Isolate * isolate ) <nl> + : isolate_ ( isolate ) , profiling_enabled_ ( false ) { <nl> + / / Make sure tracing system notices profiler categories . <nl> + PROFILER_TRACE_CATEGORY_ENABLED ( " v8 . cpu_profiler " ) ; <nl> + PROFILER_TRACE_CATEGORY_ENABLED ( " v8 . cpu_profiler . hires " ) ; <nl> + V8 : : GetCurrentPlatform ( ) - > AddTraceStateObserver ( this ) ; <nl> + } <nl> + <nl> + TracingCpuProfilerImpl : : ~ TracingCpuProfilerImpl ( ) { <nl> + StopProfiling ( ) ; <nl> + V8 : : GetCurrentPlatform ( ) - > RemoveTraceStateObserver ( this ) ; <nl> + } <nl> + <nl> + void TracingCpuProfilerImpl : : OnTraceEnabled ( ) { <nl> + if ( ! PROFILER_TRACE_CATEGORY_ENABLED ( " v8 . cpu_profiler " ) ) return ; <nl> + profiling_enabled_ = true ; <nl> + isolate_ - > RequestInterrupt ( <nl> + [ ] ( v8 : : Isolate * , void * data ) { <nl> + reinterpret_cast < TracingCpuProfilerImpl * > ( data ) - > StartProfiling ( ) ; <nl> + } , <nl> + this ) ; <nl> + } <nl> <nl> - TracingCpuProfilerImpl : : ~ TracingCpuProfilerImpl ( ) { } <nl> + void TracingCpuProfilerImpl : : OnTraceDisabled ( ) { <nl> + base : : LockGuard < base : : Mutex > lock ( & mutex_ ) ; <nl> + if ( ! profiling_enabled_ ) return ; <nl> + profiling_enabled_ = false ; <nl> + isolate_ - > RequestInterrupt ( <nl> + [ ] ( v8 : : Isolate * , void * data ) { <nl> + reinterpret_cast < TracingCpuProfilerImpl * > ( data ) - > StopProfiling ( ) ; <nl> + } , <nl> + this ) ; <nl> + } <nl> + <nl> + void TracingCpuProfilerImpl : : StartProfiling ( ) { <nl> + base : : LockGuard < base : : Mutex > lock ( & mutex_ ) ; <nl> + if ( ! profiling_enabled_ | | profiler_ ) return ; <nl> + int sampling_interval_us = <nl> + PROFILER_TRACE_CATEGORY_ENABLED ( " v8 . cpu_profiler . hires " ) ? 100 : 1000 ; <nl> + profiler_ . reset ( new CpuProfiler ( isolate_ ) ) ; <nl> + profiler_ - > set_sampling_interval ( <nl> + base : : TimeDelta : : FromMicroseconds ( sampling_interval_us ) ) ; <nl> + profiler_ - > StartProfiling ( " " , true ) ; <nl> + } <nl> + <nl> + void TracingCpuProfilerImpl : : StopProfiling ( ) { <nl> + base : : LockGuard < base : : Mutex > lock ( & mutex_ ) ; <nl> + if ( ! profiler_ ) return ; <nl> + profiler_ - > StopProfiling ( " " ) ; <nl> + profiler_ . reset ( ) ; <nl> + } <nl> <nl> } / / namespace internal <nl> } / / namespace v8 <nl> mmm a / src / profiler / tracing - cpu - profiler . h <nl> ppp b / src / profiler / tracing - cpu - profiler . h <nl> <nl> # ifndef V8_PROFILER_TRACING_CPU_PROFILER_H <nl> # define V8_PROFILER_TRACING_CPU_PROFILER_H <nl> <nl> + # include " include / v8 - platform . h " <nl> # include " include / v8 - profiler . h " <nl> + # include " src / base / atomic - utils . h " <nl> # include " src / base / macros . h " <nl> + # include " src / base / platform / mutex . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> - class TracingCpuProfilerImpl final : public TracingCpuProfiler { <nl> + class CpuProfiler ; <nl> + class Isolate ; <nl> + <nl> + class TracingCpuProfilerImpl final : public TracingCpuProfiler , <nl> + private v8 : : Platform : : TraceStateObserver { <nl> public : <nl> explicit TracingCpuProfilerImpl ( Isolate * ) ; <nl> ~ TracingCpuProfilerImpl ( ) ; <nl> <nl> + / / v8 : : Platform : : TraceStateObserver <nl> + void OnTraceEnabled ( ) final ; <nl> + void OnTraceDisabled ( ) final ; <nl> + <nl> private : <nl> + void StartProfiling ( ) ; <nl> + void StopProfiling ( ) ; <nl> + <nl> + Isolate * isolate_ ; <nl> + std : : unique_ptr < CpuProfiler > profiler_ ; <nl> + bool profiling_enabled_ ; <nl> + base : : Mutex mutex_ ; <nl> + <nl> DISALLOW_COPY_AND_ASSIGN ( TracingCpuProfilerImpl ) ; <nl> } ; <nl> <nl> mmm a / test / cctest / test - cpu - profiler . cc <nl> ppp b / test / cctest / test - cpu - profiler . cc <nl> <nl> # include " test / cctest / cctest . h " <nl> # include " test / cctest / profiler - extension . h " <nl> <nl> + # include " include / libplatform / v8 - tracing . h " <nl> + # include " src / tracing / trace - event . h " <nl> + <nl> using i : : CodeEntry ; <nl> using i : : CpuProfile ; <nl> using i : : CpuProfiler ; <nl> TEST ( DeoptUntrackedFunction ) { <nl> <nl> iprofiler - > DeleteProfile ( iprofile ) ; <nl> } <nl> + <nl> + using v8 : : platform : : tracing : : TraceBuffer ; <nl> + using v8 : : platform : : tracing : : TraceConfig ; <nl> + using v8 : : platform : : tracing : : TraceObject ; <nl> + <nl> + namespace { <nl> + <nl> + class CpuProfileEventChecker : public v8 : : platform : : tracing : : TraceWriter { <nl> + public : <nl> + void AppendTraceEvent ( TraceObject * trace_event ) override { <nl> + if ( trace_event - > name ( ) ! = std : : string ( " CpuProfile " ) & & <nl> + trace_event - > name ( ) ! = std : : string ( " CpuProfileChunk " ) ) <nl> + return ; <nl> + CHECK ( ! profile_id_ | | trace_event - > id ( ) = = profile_id_ ) ; <nl> + CHECK_EQ ( 1 , trace_event - > num_args ( ) ) ; <nl> + CHECK_EQ ( TRACE_VALUE_TYPE_CONVERTABLE , trace_event - > arg_types ( ) [ 0 ] ) ; <nl> + profile_id_ = trace_event - > id ( ) ; <nl> + v8 : : ConvertableToTraceFormat * arg = <nl> + trace_event - > arg_convertables ( ) [ 0 ] . get ( ) ; <nl> + arg - > AppendAsTraceFormat ( & result_json_ ) ; <nl> + } <nl> + void Flush ( ) override { } <nl> + <nl> + std : : string result_json ( ) const { return result_json_ ; } <nl> + <nl> + private : <nl> + std : : string result_json_ ; <nl> + uint64_t profile_id_ = 0 ; <nl> + } ; <nl> + <nl> + } / / namespace <nl> + <nl> + TEST ( TracingCpuProfiler ) { <nl> + v8 : : Platform * old_platform = i : : V8 : : GetCurrentPlatform ( ) ; <nl> + v8 : : Platform * default_platform = v8 : : platform : : CreateDefaultPlatform ( ) ; <nl> + i : : V8 : : SetPlatformForTesting ( default_platform ) ; <nl> + <nl> + v8 : : platform : : tracing : : TracingController tracing_controller ; <nl> + v8 : : platform : : SetTracingController ( default_platform , & tracing_controller ) ; <nl> + <nl> + CpuProfileEventChecker * event_checker = new CpuProfileEventChecker ( ) ; <nl> + TraceBuffer * ring_buffer = <nl> + TraceBuffer : : CreateTraceBufferRingBuffer ( 1 , event_checker ) ; <nl> + tracing_controller . Initialize ( ring_buffer ) ; <nl> + TraceConfig * trace_config = new TraceConfig ( ) ; <nl> + trace_config - > AddIncludedCategory ( <nl> + TRACE_DISABLED_BY_DEFAULT ( " v8 . cpu_profiler " ) ) ; <nl> + <nl> + LocalContext env ; <nl> + v8 : : HandleScope scope ( env - > GetIsolate ( ) ) ; <nl> + { <nl> + tracing_controller . StartTracing ( trace_config ) ; <nl> + auto profiler = v8 : : TracingCpuProfiler : : Create ( env - > GetIsolate ( ) ) ; <nl> + CompileRun ( " function foo ( ) { } foo ( ) ; " ) ; <nl> + tracing_controller . StopTracing ( ) ; <nl> + CompileRun ( " function bar ( ) { } bar ( ) ; " ) ; <nl> + } <nl> + <nl> + const char * profile_checker = <nl> + " function checkProfile ( profile ) { \ n " <nl> + " if ( typeof profile [ ' startTime ' ] ! = = ' number ' ) return ' startTime ' ; \ n " <nl> + " return ' ' ; \ n " <nl> + " } \ n " <nl> + " checkProfile ( " ; <nl> + std : : string profile_json = event_checker - > result_json ( ) ; <nl> + CHECK_LT ( 0u , profile_json . length ( ) ) ; <nl> + printf ( " Profile JSON : % s \ n " , profile_json . c_str ( ) ) ; <nl> + std : : string code = profile_checker + profile_json + " ) " ; <nl> + v8 : : Local < v8 : : Value > result = <nl> + CompileRunChecked ( CcTest : : isolate ( ) , code . c_str ( ) ) ; <nl> + v8 : : String : : Utf8Value value ( result ) ; <nl> + printf ( " Check result : % * s \ n " , value . length ( ) , * value ) ; <nl> + CHECK_EQ ( 0 , value . length ( ) ) ; <nl> + <nl> + i : : V8 : : SetPlatformForTesting ( old_platform ) ; <nl> + } <nl>
[ profiler ] Tracing - based CPU profiler .
v8/v8
4b575dfceff4575ddd5ba0c74089c127d9b68c4f
2016-10-06T18:14:24Z
mmm a / R - package / src / im2rec . h <nl> ppp b / R - package / src / im2rec . h <nl> <nl> <nl> # include < Rcpp . h > <nl> # include < string > <nl> + # include < opencv2 / core / version . hpp > <nl> + # if CV_VERSION_MAJOR > = 4 <nl> + # include < opencv2 / opencv . hpp > <nl> + # define CV_IMWRITE_PNG_COMPRESSION cv : : IMWRITE_PNG_COMPRESSION <nl> + # define CV_IMWRITE_JPEG_QUALITY cv : : IMWRITE_JPEG_QUALITY <nl> + # endif / / CV_VERSION_MAJOR > = 4 <nl> <nl> namespace mxnet { <nl> namespace R { <nl>
[ R package ] Make R package compilation support opencv 4 . 0 ( )
apache/incubator-mxnet
34e71163b1863558b2d17636385dfa05fcabf4f9
2019-12-05T10:27:52Z
mmm a / examples / pizza . coffee <nl> ppp b / examples / pizza . coffee <nl> <nl> - # Find pizza in New York using Google Local <nl> + # Find pizza in Mountain View using Yelp <nl> <nl> page = new WebPage ( ) <nl> + url = ' http : / / lite . yelp . com / search ? find_desc = pizza & find_loc = 94040 & find_submit = Search ' <nl> <nl> - page . open ' http : / / www . google . com / m / local ? site = local & q = pizza + in + new + york ' , <nl> + page . open url , <nl> ( status ) - > <nl> if status isnt ' success ' <nl> console . log ' Unable to access network ' <nl> else <nl> results = page . evaluate - > <nl> pizza = [ ] <nl> - list = document . querySelectorAll ' div . bf ' <nl> + list = document . querySelectorAll ' span . address ' <nl> for item in list <nl> pizza . push ( item . innerText ) <nl> return pizza <nl> mmm a / examples / pizza . js <nl> ppp b / examples / pizza . js <nl> <nl> - / / Find pizza in New York using Google Local <nl> + / / Find pizza in Mountain View using Yelp <nl> <nl> - var page = new WebPage ( ) ; <nl> + var page = new WebPage ( ) , <nl> + url = ' http : / / lite . yelp . com / search ? find_desc = pizza & find_loc = 94040 & find_submit = Search ' ; <nl> <nl> - page . open ( ' http : / / www . google . com / m / local ? site = local & q = pizza + in + new + york ' , function ( status ) { <nl> + page . open ( url , function ( status ) { <nl> if ( status ! = = ' success ' ) { <nl> console . log ( ' Unable to access network ' ) ; <nl> } else { <nl> var results = page . evaluate ( function ( ) { <nl> - var list = document . querySelectorAll ( ' div . bf ' ) , pizza = [ ] , i ; <nl> + var list = document . querySelectorAll ( ' span . address ' ) , pizza = [ ] , i ; <nl> for ( i = 0 ; i < list . length ; i + + ) { <nl> pizza . push ( list [ i ] . innerText ) ; <nl> } <nl>
examples / pizza : Switch to use Yelp .
ariya/phantomjs
051f3ea839ce8bff7a2f95c4bd3acbbd4f5ae635
2011-08-24T06:34:50Z
mmm a / docs / install_osx . md <nl> ppp b / docs / install_osx . md <nl> If using Anaconda Python , HDF5 is bundled and the ` hdf5 ` formula can be skipped . <nl> <nl> # with Python pycaffe needs dependencies built from source <nl> brew install - - build - from - source - - with - python - - fresh - vd protobuf <nl> - brew install - - build - from - source - - fresh - vd boost <nl> + brew install - - build - from - source - - fresh - vd boost boost - python <nl> # without Python the usual installation suffices <nl> brew install protobuf boost <nl> <nl>
[ docs ] include boost - python in OSX pycaffe install
BVLC/caffe
65d84a595d187b39b7299f457967d7f91acf3cd9
2015-03-05T21:55:01Z
mmm a / build_tools / rocksdb - lego - determinator <nl> ppp b / build_tools / rocksdb - lego - determinator <nl> STRESS_CRASH_TEST_COMMANDS = " [ <nl> } <nl> ] " <nl> <nl> + # RocksDB write stress test . <nl> + # We run on disk device on purpose ( i . e . no $ SHM ) <nl> + # because we want to add some randomness to fsync commands <nl> + WRITE_STRESS_COMMANDS = " [ <nl> + { <nl> + ' name ' : ' Rocksdb Write Stress Test ' , <nl> + ' oncall ' : ' $ ONCALL ' , <nl> + ' steps ' : [ <nl> + $ CLEANUP_ENV , <nl> + { <nl> + ' name ' : ' Build and run RocksDB write stress tests ' , <nl> + ' shell ' : ' make write_stress & & python tools / write_stress_runner . py - - runtime_sec = 3600 - - db = / tmp / rocksdb_write_stress ' , <nl> + ' user ' : ' root ' , <nl> + $ PARSER <nl> + } <nl> + ] , <nl> + ' artifacts ' : [ { ' name ' : ' database ' , ' paths ' : [ ' / tmp / rocksdb_write_stress ' ] } ] , <nl> + $ REPORT <nl> + } <nl> + ] " <nl> + <nl> + <nl> # <nl> # RocksDB test under address sanitizer <nl> # <nl> case $ 1 in <nl> stress_crash ) <nl> echo $ STRESS_CRASH_TEST_COMMANDS <nl> ; ; <nl> + write_stress ) <nl> + echo $ WRITE_STRESS_COMMANDS <nl> + ; ; <nl> asan ) <nl> echo $ ASAN_TEST_COMMANDS <nl> ; ; <nl>
Add write_stress to RocksDB Legocastle runs
facebook/rocksdb
14c6e1a04c4bece57ca1e4842f357325892f3208
2015-11-05T20:07:39Z
mmm a / examples / directx11_example / main . cpp <nl> ppp b / examples / directx11_example / main . cpp <nl> int WINAPI wWinMain ( HINSTANCE hInst , HINSTANCE , LPWSTR , int ) <nl> ImGui : : ColorEdit3 ( " clear color " , ( float * ) & clear_col ) ; <nl> if ( ImGui : : Button ( " Test Window " ) ) show_test_window ^ = 1 ; <nl> if ( ImGui : : Button ( " Another Window " ) ) show_another_window ^ = 1 ; <nl> - <nl> - / / Calculate and show frame rate <nl> - static int ms_per_frame_idx = 0 ; <nl> - static float ms_per_frame [ 60 ] = { 0 } ; <nl> - static float ms_per_frame_accum = 0 . 0f ; <nl> - ms_per_frame_accum - = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame [ ms_per_frame_idx ] = ImGui : : GetIO ( ) . DeltaTime * 1000 . 0f ; <nl> - ms_per_frame_accum + = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame_idx = ( ms_per_frame_idx + 1 ) % 60 ; <nl> - const float ms_per_frame_avg = ms_per_frame_accum / 60 ; <nl> - ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , ms_per_frame_avg , 1000 . 0f / ms_per_frame_avg ) ; <nl> + ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , 1000 . 0f / ImGui : : GetIO ( ) . Framerate , ImGui : : GetIO ( ) . Framerate ) ; <nl> } <nl> <nl> / / 2 . Show another simple window , this time using an explicit Begin / End pair <nl> mmm a / examples / directx9_example / main . cpp <nl> ppp b / examples / directx9_example / main . cpp <nl> int WINAPI wWinMain ( HINSTANCE hInst , HINSTANCE , LPWSTR , int ) <nl> ImGui : : ColorEdit3 ( " clear color " , ( float * ) & clear_col ) ; <nl> if ( ImGui : : Button ( " Test Window " ) ) show_test_window ^ = 1 ; <nl> if ( ImGui : : Button ( " Another Window " ) ) show_another_window ^ = 1 ; <nl> - <nl> - / / Calculate and show frame rate <nl> - static int ms_per_frame_idx = 0 ; <nl> - static float ms_per_frame [ 60 ] = { 0 } ; <nl> - static float ms_per_frame_accum = 0 . 0f ; <nl> - ms_per_frame_accum - = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame [ ms_per_frame_idx ] = ImGui : : GetIO ( ) . DeltaTime * 1000 . 0f ; <nl> - ms_per_frame_accum + = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame_idx = ( ms_per_frame_idx + 1 ) % 60 ; <nl> - const float ms_per_frame_avg = ms_per_frame_accum / 60 ; <nl> - ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , ms_per_frame_avg , 1000 . 0f / ms_per_frame_avg ) ; <nl> + ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , 1000 . 0f / ImGui : : GetIO ( ) . Framerate , ImGui : : GetIO ( ) . Framerate ) ; <nl> } <nl> <nl> / / 2 . Show another simple window , this time using an explicit Begin / End pair <nl> mmm a / examples / opengl3_example / main . cpp <nl> ppp b / examples / opengl3_example / main . cpp <nl> int main ( int argc , char * * argv ) <nl> ImGui : : ColorEdit3 ( " clear color " , ( float * ) & clear_col ) ; <nl> if ( ImGui : : Button ( " Test Window " ) ) show_test_window ^ = 1 ; <nl> if ( ImGui : : Button ( " Another Window " ) ) show_another_window ^ = 1 ; <nl> - <nl> - / / Calculate and show frame rate <nl> - static int ms_per_frame_idx = 0 ; <nl> - static float ms_per_frame [ 60 ] = { 0 } ; <nl> - static float ms_per_frame_accum = 0 . 0f ; <nl> - ms_per_frame_accum - = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame [ ms_per_frame_idx ] = ImGui : : GetIO ( ) . DeltaTime * 1000 . 0f ; <nl> - ms_per_frame_accum + = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame_idx = ( ms_per_frame_idx + 1 ) % 60 ; <nl> - const float ms_per_frame_avg = ms_per_frame_accum / 60 ; <nl> - ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , ms_per_frame_avg , 1000 . 0f / ms_per_frame_avg ) ; <nl> + ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , 1000 . 0f / ImGui : : GetIO ( ) . Framerate , ImGui : : GetIO ( ) . Framerate ) ; <nl> } <nl> <nl> / / 2 . Show another simple window , this time using an explicit Begin / End pair <nl> mmm a / examples / opengl_example / main . cpp <nl> ppp b / examples / opengl_example / main . cpp <nl> int main ( int argc , char * * argv ) <nl> ImGui : : ColorEdit3 ( " clear color " , ( float * ) & clear_col ) ; <nl> if ( ImGui : : Button ( " Test Window " ) ) show_test_window ^ = 1 ; <nl> if ( ImGui : : Button ( " Another Window " ) ) show_another_window ^ = 1 ; <nl> - <nl> - / / Calculate and show frame rate <nl> - static int ms_per_frame_idx = 0 ; <nl> - static float ms_per_frame [ 60 ] = { 0 } ; <nl> - static float ms_per_frame_accum = 0 . 0f ; <nl> - ms_per_frame_accum - = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame [ ms_per_frame_idx ] = ImGui : : GetIO ( ) . DeltaTime * 1000 . 0f ; <nl> - ms_per_frame_accum + = ms_per_frame [ ms_per_frame_idx ] ; <nl> - ms_per_frame_idx = ( ms_per_frame_idx + 1 ) % 60 ; <nl> - const float ms_per_frame_avg = ms_per_frame_accum / 60 ; <nl> - ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , ms_per_frame_avg , 1000 . 0f / ms_per_frame_avg ) ; <nl> + ImGui : : Text ( " Application average % . 3f ms / frame ( % . 1f FPS ) " , 1000 . 0f / ImGui : : GetIO ( ) . Framerate , ImGui : : GetIO ( ) . Framerate ) ; <nl> } <nl> <nl> / / 2 . Show another simple window , this time using an explicit Begin / End pair <nl> mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> struct ImGuiState <nl> int LogStartDepth ; <nl> int LogAutoExpandMaxDepth ; <nl> <nl> + / / Misc <nl> + float FramerateSecPerFrame [ 120 ] ; / / calculate estimate of framerate for user <nl> + int FramerateSecPerFrameIdx ; <nl> + float FramerateSecPerFrameAccum ; <nl> + <nl> ImGuiState ( ) <nl> { <nl> Initialized = false ; <nl> void ImGui : : NewFrame ( ) <nl> for ( size_t i = 0 ; i < IM_ARRAYSIZE ( g . IO . KeysDown ) ; i + + ) <nl> g . IO . KeysDownTime [ i ] = g . IO . KeysDown [ i ] ? ( g . IO . KeysDownTime [ i ] < 0 . 0f ? 0 . 0f : g . IO . KeysDownTime [ i ] + g . IO . DeltaTime ) : - 1 . 0f ; <nl> <nl> + / / Calculate frame - rate for the user , as a purely luxurious feature <nl> + g . FramerateSecPerFrameAccum + = g . IO . DeltaTime - g . FramerateSecPerFrame [ g . FramerateSecPerFrameIdx ] ; <nl> + g . FramerateSecPerFrame [ g . FramerateSecPerFrameIdx ] = g . IO . DeltaTime ; <nl> + g . FramerateSecPerFrameIdx = ( g . FramerateSecPerFrameIdx + 1 ) % IM_ARRAYSIZE ( g . FramerateSecPerFrame ) ; <nl> + g . IO . Framerate = 1 . 0f / ( g . FramerateSecPerFrameAccum / ( float ) IM_ARRAYSIZE ( g . FramerateSecPerFrame ) ) ; <nl> + <nl> / / Clear reference to active widget if the widget isn ' t alive anymore <nl> g . HoveredId = 0 ; <nl> if ( ! g . ActiveIdIsAlive & & g . ActiveIdPreviousFrame = = g . ActiveId & & g . ActiveId ! = 0 ) <nl> mmm a / imgui . h <nl> ppp b / imgui . h <nl> struct ImGuiIO <nl> <nl> bool WantCaptureMouse ; / / Mouse is hovering a window or widget is active ( = ImGui will use your mouse input ) <nl> bool WantCaptureKeyboard ; / / Widget is active ( = ImGui will use your keyboard input ) <nl> + float Framerate ; / / Framerate estimation , in frame per second . Rolling average estimation based on IO . DeltaTime over 120 frames <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / [ Internal ] ImGui will maintain those fields for you <nl>
Calculate frame - rate for the user , as a purely luxurious feature
ocornut/imgui
cb0a4db0481cccf7185f12bf1bfccfdacbdfcd0e
2015-02-11T18:28:17Z
mmm a / tensorflow / core / kernels / resize_nearest_neighbor_op . cc <nl> ppp b / tensorflow / core / kernels / resize_nearest_neighbor_op . cc <nl> class ResizeNearestNeighborGPUOp : public OpKernel { <nl> . HostMemory ( " size " ) , \ <nl> ResizeNearestNeighborGPUOp < T > ) ; <nl> <nl> - REGISTER_KERNEL ( float ) ; <nl> - / / TODO ( panmari ) : Fix kernel for double . <nl> - / / REGISTER_KERNEL ( double ) ; <nl> + TF_CALL_GPU_NUMBER_TYPES ( REGISTER_KERNEL ) ; <nl> <nl> # undef REGISTER_KERNEL <nl> <nl> mmm a / tensorflow / core / kernels / resize_nearest_neighbor_op_gpu . cu . cc <nl> ppp b / tensorflow / core / kernels / resize_nearest_neighbor_op_gpu . cu . cc <nl> namespace { <nl> template < typename T > <nl> __global__ void ResizeNearestNeighborNHWC ( const int nthreads , const T * bottom_data , <nl> const int in_height , const int in_width , <nl> - const int channels , const float height_scale , <nl> - const float width_scale , const int out_height , <nl> - const int out_width , T * top_data ) { <nl> + const int channels , const int out_height , <nl> + const int out_width , const float height_scale , <nl> + const float width_scale , T * top_data ) { <nl> CUDA_1D_KERNEL_LOOP ( index , nthreads ) { <nl> int n = index ; <nl> int c = n % channels ; <nl> __global__ void ResizeNearestNeighborNHWC ( const int nthreads , const T * bottom_da <nl> const T * bottom_data_n = bottom_data + n * channels * in_height * in_width ; <nl> const int in_x = min ( static_cast < int > ( floorf ( out_x * width_scale ) ) , in_width - 1 ) ; <nl> const int in_y = min ( static_cast < int > ( floorf ( out_y * height_scale ) ) , in_height - 1 ) ; <nl> - const int idx = ( in_y * in_height + in_x ) * channels + c ; <nl> - top_data [ index ] = bottom_data_n [ idx ] ; <nl> + const int idx = ( in_y * in_width + in_x ) * channels + c ; <nl> + top_data [ index ] = ldg ( bottom_data_n + idx ) ; <nl> } <nl> } <nl> <nl> bool ResizeNearestNeighbor ( const T * bottom_data , const int batch , <nl> const float width_scale , T * top_data , \ <nl> const Eigen : : GpuDevice & d ) ; <nl> <nl> - DECLARE_GPU_SPEC ( float ) ; <nl> + TF_CALL_GPU_NUMBER_TYPES ( DECLARE_GPU_SPEC ) ; <nl> <nl> # undef DECLARE_GPU_SPEC <nl> } / / end namespace tensorflow <nl> mmm a / tensorflow / python / ops / image_ops_test . py <nl> ppp b / tensorflow / python / ops / image_ops_test . py <nl> class ResizeImagesTest ( test_util . TensorFlowTestCase ) : <nl> image_ops . ResizeMethod . AREA ] <nl> <nl> TYPES = [ np . uint8 , np . int8 , np . int16 , np . int32 , np . int64 , <nl> - np . float , np . double ] <nl> + np . float32 , np . float64 ] <nl> <nl> - def availableGPUModes ( self , opt ) : <nl> - if opt = = image_ops . ResizeMethod . NEAREST_NEIGHBOR : <nl> + def availableGPUModes ( self , opt , nptype ) : <nl> + if opt = = image_ops . ResizeMethod . NEAREST_NEIGHBOR \ <nl> + and nptype in [ np . float32 , np . float64 ] : <nl> return [ True , False ] <nl> else : <nl> return [ False ] <nl> def testNoOp ( self ) : <nl> img_np = np . array ( data , dtype = nptype ) . reshape ( img_shape ) <nl> <nl> for opt in self . OPTIONS : <nl> - for use_gpu in self . availableGPUModes ( opt ) : <nl> + for use_gpu in self . availableGPUModes ( opt , nptype ) : <nl> with self . test_session ( use_gpu = use_gpu ) as sess : <nl> image = constant_op . constant ( img_np , shape = img_shape ) <nl> y = image_ops . resize_images ( image , target_height , target_width , opt ) <nl> def testResizeDown ( self ) : <nl> img_np = np . array ( data , dtype = nptype ) . reshape ( img_shape ) <nl> <nl> for opt in self . OPTIONS : <nl> - for use_gpu in self . availableGPUModes ( opt ) : <nl> + for use_gpu in self . availableGPUModes ( opt , nptype ) : <nl> with self . test_session ( use_gpu = use_gpu ) : <nl> image = constant_op . constant ( img_np , shape = img_shape ) <nl> y = image_ops . resize_images ( image , target_height , target_width , opt ) <nl> def testResizeUp ( self ) : <nl> image_ops . ResizeMethod . BILINEAR , <nl> image_ops . ResizeMethod . NEAREST_NEIGHBOR , <nl> image_ops . ResizeMethod . AREA ] : <nl> - for use_gpu in self . availableGPUModes ( opt ) : <nl> + for use_gpu in self . availableGPUModes ( opt , nptype ) : <nl> with self . test_session ( use_gpu = use_gpu ) : <nl> img_np = np . array ( data , dtype = nptype ) . reshape ( img_shape ) <nl> image = constant_op . constant ( img_np , shape = img_shape ) <nl> def testResizeDownArea ( self ) : <nl> <nl> <nl> def testCompareNearestNeighbor ( self ) : <nl> - input_shape = [ 1 , 5 , 5 , 3 ] <nl> - target_height = target_width = 10 <nl> - for nptype in [ np . float ] : <nl> + input_shape = [ 1 , 5 , 6 , 3 ] <nl> + target_height = 8 <nl> + target_width = 12 <nl> + for nptype in [ np . float32 , np . float64 ] : <nl> for align_corners in [ True , False ] : <nl> img_np = np . arange ( 0 , np . prod ( input_shape ) , dtype = nptype ) . reshape ( input_shape ) <nl> with self . test_session ( use_gpu = True ) : <nl>
Merge pull request from panmari / fix_types_image_ops_tests .
tensorflow/tensorflow
88a6f775338a6ab57e5c6c1bd249259d46b2bc2d
2016-03-07T20:07:21Z
new file mode 100644 <nl> index 00000000000 . . efe98d84ffb <nl> mmm / dev / null <nl> ppp b / src / node / examples / stock . proto <nl> <nl> + / / Copyright 2015 , Google Inc . <nl> + / / All rights reserved . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without <nl> + / / modification , are permitted provided that the following conditions are <nl> + / / met : <nl> + / / <nl> + / / * Redistributions of source code must retain the above copyright <nl> + / / notice , this list of conditions and the following disclaimer . <nl> + / / * Redistributions in binary form must reproduce the above <nl> + / / copyright notice , this list of conditions and the following disclaimer <nl> + / / in the documentation and / or other materials provided with the <nl> + / / distribution . <nl> + / / * Neither the name of Google Inc . nor the names of its <nl> + / / contributors may be used to endorse or promote products derived from <nl> + / / this software without specific prior written permission . <nl> + / / <nl> + / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + / / " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + / / LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + / / A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + / / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + / / SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + / / LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + / / DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + / / THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + / / ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + / / OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + syntax = " proto3 " ; <nl> + <nl> + package examples ; <nl> + <nl> + / / Protocol type definitions <nl> + message StockRequest { <nl> + optional string symbol = 1 ; <nl> + optional int32 num_trades_to_watch = 2 [ default = 0 ] ; <nl> + } ; <nl> + <nl> + message StockReply { <nl> + optional float price = 1 ; <nl> + optional string symbol = 2 ; <nl> + } ; <nl> + <nl> + <nl> + / / Interface exported by the server <nl> + service Stock { <nl> + / / Simple blocking RPC <nl> + rpc GetLastTradePrice ( StockRequest ) returns ( StockReply ) { <nl> + } ; <nl> + / / Bidirectional streaming RPC <nl> + rpc GetLastTradePriceMultiple ( stream StockRequest ) returns <nl> + ( stream StockReply ) { <nl> + } ; <nl> + / / Unidirectional server - to - client streaming RPC <nl> + rpc WatchFutureTrades ( StockRequest ) returns ( stream StockReply ) { <nl> + } ; <nl> + / / Unidirectional client - to - server streaming RPC <nl> + rpc GetHighestTradePrice ( stream StockRequest ) returns ( StockReply ) { <nl> + } ; <nl> + <nl> + } ; <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 8e99090f350 <nl> mmm / dev / null <nl> ppp b / src / node / examples / stock_client . js <nl> <nl> + / * <nl> + * <nl> + * Copyright 2015 , Google Inc . <nl> + * All rights reserved . <nl> + * <nl> + * Redistribution and use in source and binary forms , with or without <nl> + * modification , are permitted provided that the following conditions are <nl> + * met : <nl> + * <nl> + * * Redistributions of source code must retain the above copyright <nl> + * notice , this list of conditions and the following disclaimer . <nl> + * * Redistributions in binary form must reproduce the above <nl> + * copyright notice , this list of conditions and the following disclaimer <nl> + * in the documentation and / or other materials provided with the <nl> + * distribution . <nl> + * * Neither the name of Google Inc . nor the names of its <nl> + * contributors may be used to endorse or promote products derived from <nl> + * this software without specific prior written permission . <nl> + * <nl> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + * " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + * <nl> + * / <nl> + <nl> + var grpc = require ( ' . . ' ) ; <nl> + var examples = grpc . load ( __dirname + ' / stock . proto ' ) . examples ; <nl> + <nl> + / * * <nl> + * This exports a client constructor for the Stock service . The usage looks like <nl> + * <nl> + * var StockClient = require ( ' stock_client . js ' ) ; <nl> + * var stockClient = new StockClient ( server_address ) ; <nl> + * / <nl> + module . exports = examples . Stock ; <nl> new file mode 100644 <nl> index 00000000000 . . c188181b779 <nl> mmm / dev / null <nl> ppp b / src / node / examples / stock_server . js <nl> <nl> + / * <nl> + * <nl> + * Copyright 2015 , Google Inc . <nl> + * All rights reserved . <nl> + * <nl> + * Redistribution and use in source and binary forms , with or without <nl> + * modification , are permitted provided that the following conditions are <nl> + * met : <nl> + * <nl> + * * Redistributions of source code must retain the above copyright <nl> + * notice , this list of conditions and the following disclaimer . <nl> + * * Redistributions in binary form must reproduce the above <nl> + * copyright notice , this list of conditions and the following disclaimer <nl> + * in the documentation and / or other materials provided with the <nl> + * distribution . <nl> + * * Neither the name of Google Inc . nor the names of its <nl> + * contributors may be used to endorse or promote products derived from <nl> + * this software without specific prior written permission . <nl> + * <nl> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + * " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + * <nl> + * / <nl> + <nl> + var _ = require ( ' underscore ' ) ; <nl> + var grpc = require ( ' . . ' ) ; <nl> + var examples = grpc . load ( __dirname + ' / stock . proto ' ) . examples ; <nl> + <nl> + var StockServer = grpc . makeServerConstructor ( [ examples . Stock . service ] ) ; <nl> + <nl> + function getLastTradePrice ( call , callback ) { <nl> + callback ( null , { price : 88 } ) ; <nl> + } <nl> + <nl> + function watchFutureTrades ( call ) { <nl> + for ( var i = 0 ; i < call . request . num_trades_to_watch ; i + + ) { <nl> + call . write ( { price : 88 . 00 + i * 10 . 00 } ) ; <nl> + } <nl> + call . end ( ) ; <nl> + } <nl> + <nl> + function getHighestTradePrice ( call , callback ) { <nl> + var trades = [ ] ; <nl> + call . on ( ' data ' , function ( data ) { <nl> + trades . push ( { symbol : data . symbol , price : _ . random ( 0 , 100 ) } ) ; <nl> + } ) ; <nl> + call . on ( ' end ' , function ( ) { <nl> + if ( _ . isEmpty ( trades ) ) { <nl> + callback ( null , { } ) ; <nl> + } else { <nl> + callback ( null , _ . max ( trades , function ( trade ) { return trade . price ; } ) ) ; <nl> + } <nl> + } ) ; <nl> + } <nl> + <nl> + function getLastTradePriceMultiple ( call ) { <nl> + call . on ( ' data ' , function ( data ) { <nl> + call . write ( { price : 88 } ) ; <nl> + } ) ; <nl> + call . on ( ' end ' , function ( ) { <nl> + call . end ( ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + var stockServer = new StockServer ( { <nl> + ' examples . Stock ' : { <nl> + getLastTradePrice : getLastTradePrice , <nl> + getLastTradePriceMultiple : getLastTradePriceMultiple , <nl> + watchFutureTrades : watchFutureTrades , <nl> + getHighestTradePrice : getHighestTradePrice <nl> + } <nl> + } ) ; <nl> + <nl> + exports . module = stockServer ; <nl>
Merge pull request from murgatroid99 / node_stock_service
grpc/grpc
be9154711682d5f5c55405f1678aea7a28f1d691
2015-01-31T03:16:19Z
mmm a / modules / videoio / include / opencv2 / videoio / cap_ios . h <nl> ppp b / modules / videoio / include / opencv2 / videoio / cap_ios . h <nl> <nl> int imageHeight ; <nl> } <nl> <nl> - @ property ( nonatomic , retain ) AVCaptureSession * captureSession ; <nl> - @ property ( nonatomic , retain ) AVCaptureConnection * videoCaptureConnection ; <nl> + @ property ( nonatomic , strong ) AVCaptureSession * captureSession ; <nl> + @ property ( nonatomic , strong ) AVCaptureConnection * videoCaptureConnection ; <nl> <nl> @ property ( nonatomic , readonly ) BOOL running ; <nl> @ property ( nonatomic , readonly ) BOOL captureSessionLoaded ; <nl> <nl> @ property ( nonatomic , assign ) int imageWidth ; <nl> @ property ( nonatomic , assign ) int imageHeight ; <nl> <nl> - @ property ( nonatomic , retain ) UIView * parentView ; <nl> + @ property ( nonatomic , strong ) UIView * parentView ; <nl> <nl> - ( void ) start ; <nl> - ( void ) stop ; <nl> <nl> <nl> @ property ( nonatomic , assign ) BOOL recordVideo ; <nl> @ property ( nonatomic , assign ) BOOL rotateVideo ; <nl> - @ property ( nonatomic , retain ) AVAssetWriterInput * recordAssetWriterInput ; <nl> - @ property ( nonatomic , retain ) AVAssetWriterInputPixelBufferAdaptor * recordPixelBufferAdaptor ; <nl> - @ property ( nonatomic , retain ) AVAssetWriter * recordAssetWriter ; <nl> + @ property ( nonatomic , strong ) AVAssetWriterInput * recordAssetWriterInput ; <nl> + @ property ( nonatomic , strong ) AVAssetWriterInputPixelBufferAdaptor * recordPixelBufferAdaptor ; <nl> + @ property ( nonatomic , strong ) AVAssetWriter * recordAssetWriter ; <nl> <nl> - ( void ) adjustLayoutToInterfaceOrientation : ( UIInterfaceOrientation ) interfaceOrientation ; <nl> - ( void ) layoutPreviewLayer ; <nl> mmm a / modules / videoio / src / cap_ios_abstract_camera . mm <nl> ppp b / modules / videoio / src / cap_ios_abstract_camera . mm <nl> <nl> <nl> @ interface CvAbstractCamera ( ) <nl> <nl> - @ property ( nonatomic , retain ) AVCaptureVideoPreviewLayer * captureVideoPreviewLayer ; <nl> + @ property ( nonatomic , strong ) AVCaptureVideoPreviewLayer * captureVideoPreviewLayer ; <nl> <nl> - ( void ) deviceOrientationDidChange : ( NSNotification * ) notification ; <nl> - ( void ) startCaptureSession ; <nl> mmm a / modules / videoio / src / cap_ios_photo_camera . mm <nl> ppp b / modules / videoio / src / cap_ios_photo_camera . mm <nl> <nl> <nl> @ interface CvPhotoCamera ( ) <nl> <nl> - @ property ( nonatomic , retain ) AVCaptureStillImageOutput * stillImageOutput ; <nl> + @ property ( nonatomic , strong ) AVCaptureStillImageOutput * stillImageOutput ; <nl> <nl> @ end <nl> <nl> mmm a / modules / videoio / src / cap_ios_video_camera . mm <nl> ppp b / modules / videoio / src / cap_ios_video_camera . mm <nl> - ( void ) createVideoDataOutput ; <nl> - ( void ) createVideoFileOutput ; <nl> <nl> <nl> - @ property ( nonatomic , retain ) CALayer * customPreviewLayer ; <nl> - @ property ( nonatomic , retain ) AVCaptureVideoDataOutput * videoDataOutput ; <nl> + @ property ( nonatomic , strong ) CALayer * customPreviewLayer ; <nl> + @ property ( nonatomic , strong ) AVCaptureVideoDataOutput * videoDataOutput ; <nl> <nl> @ end <nl> <nl>
Merge pull request from valeriyvan : iosfixes
opencv/opencv
e21fed3c4f2af6efa1ee05d6dcc94d323ab81e8e
2016-08-26T11:11:49Z
mmm a / hphp / runtime / vm / bytecode . cpp <nl> ppp b / hphp / runtime / vm / bytecode . cpp <nl> OPTBLD_INLINE void iopUnwind ( ) { <nl> throw VMPrepareUnwind ( ) ; <nl> } <nl> <nl> - OPTBLD_INLINE void iopThrow ( ) { <nl> + OPTBLD_INLINE void iopThrow ( PC & ) { <nl> Cell * c1 = vmStack ( ) . topC ( ) ; <nl> if ( c1 - > m_type ! = KindOfObject | | <nl> ! c1 - > m_data . pobj - > instanceof ( SystemLib : : s_ThrowableClass ) ) { <nl> OPTBLD_INLINE void iopContEnter ( PC & pc ) { <nl> <nl> OPTBLD_INLINE void iopContRaise ( PC & pc ) { <nl> contEnterImpl < true > ( pc ) ; <nl> - iopThrow ( ) ; <nl> + iopThrow ( pc ) ; <nl> } <nl> <nl> OPTBLD_INLINE void moveProgramCounterToCaller ( PC & pc , <nl> mmm a / hphp / runtime / vm / hhbc . cpp <nl> ppp b / hphp / runtime / vm / hhbc . cpp <nl> <nl> # include " hphp / runtime / vm / hhbc - codec . h " <nl> # include " hphp / runtime / vm / repo - global - data . h " <nl> # include " hphp / runtime / vm / unit . h " <nl> + # include " hphp / runtime / vm / unwind . h " <nl> # include " hphp / util / text - util . h " <nl> <nl> namespace HPHP { <nl> Offset instrJumpTarget ( PC instrs , Offset pos ) { <nl> return offset ! = kInvalidOffset ? offset + pos : InvalidAbsoluteOffset ; <nl> } <nl> <nl> - OffsetSet instrSuccOffsets ( PC opc , const Unit * unit ) { <nl> + OffsetSet instrSuccOffsets ( PC opc , const Func * func ) { <nl> OffsetSet succBcOffs ; <nl> - auto const bcStart = unit - > entry ( ) ; <nl> + auto const bcStart = func - > unit ( ) - > entry ( ) ; <nl> auto const op = peek_op ( opc ) ; <nl> <nl> if ( ! instrIsControlFlow ( op ) ) { <nl> OffsetSet instrSuccOffsets ( PC opc , const Unit * unit ) { <nl> foreachSwitchTarget ( opc , [ & ] ( Offset offset ) { <nl> succBcOffs . insert ( offset + opc - bcStart ) ; <nl> } ) ; <nl> + } else if ( op = = Op : : Await | | op = = Op : : Throw ) { <nl> + Offset target = findCatchHandler ( func , opc - bcStart ) ; <nl> + if ( target ! = InvalidAbsoluteOffset ) { <nl> + succBcOffs . insert ( target ) ; <nl> + } <nl> } else { <nl> Offset target = instrJumpTarget ( bcStart , opc - bcStart ) ; <nl> if ( target ! = InvalidAbsoluteOffset ) { <nl> mmm a / hphp / runtime / vm / hhbc . h <nl> ppp b / hphp / runtime / vm / hhbc . h <nl> constexpr uint32_t kMaxConcatN = 4 ; <nl> O ( RetV , NA , ONE ( VV ) , NOV , CF_TF ) \ <nl> O ( RetM , ONE ( IVA ) , CMANY , NOV , CF_TF ) \ <nl> O ( Unwind , NA , NOV , NOV , TF ) \ <nl> - O ( Throw , NA , ONE ( CV ) , NOV , TF ) \ <nl> + O ( Throw , NA , ONE ( CV ) , NOV , CF_TF ) \ <nl> O ( CGetL , ONE ( LA ) , NOV , ONE ( CV ) , NF ) \ <nl> O ( CGetQuietL , ONE ( LA ) , NOV , ONE ( CV ) , NF ) \ <nl> O ( CUGetL , ONE ( LA ) , NOV , ONE ( CUV ) , NF ) \ <nl> Offset instrJumpTarget ( PC instrs , Offset pos ) ; <nl> * be executed immediately after opc . <nl> * / <nl> using OffsetSet = hphp_hash_set < Offset > ; <nl> - OffsetSet instrSuccOffsets ( PC opc , const Unit * unit ) ; <nl> + OffsetSet instrSuccOffsets ( PC opc , const Func * func ) ; <nl> <nl> struct StackTransInfo { <nl> enum class Kind { <nl> mmm a / hphp / runtime / vm / jit / irgen - control . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - control . cpp <nl> <nl> # include " hphp / runtime / vm / jit / irgen - control . h " <nl> <nl> # include " hphp / runtime / vm / resumable . h " <nl> + # include " hphp / runtime / vm / unwind . h " <nl> <nl> # include " hphp / runtime / vm / jit / normalized - instruction . h " <nl> # include " hphp / runtime / vm / jit / switch - profile . h " <nl> void emitSelect ( IRGS & env ) { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> + void emitThrow ( IRGS & env ) { <nl> + auto const stackEmpty = spOffBCFromFP ( env ) = = spOffEmpty ( env ) + 1 ; <nl> + auto const offset = findCatchHandler ( curFunc ( env ) , bcOff ( env ) ) ; <nl> + auto const srcTy = topC ( env ) - > type ( ) ; <nl> + auto const maybeThrowable = <nl> + srcTy . maybe ( Type : : SubObj ( SystemLib : : s_ExceptionClass ) ) | | <nl> + srcTy . maybe ( Type : : SubObj ( SystemLib : : s_ErrorClass ) ) ; <nl> + if ( ! stackEmpty | | offset = = InvalidAbsoluteOffset | | ! maybeThrowable | | <nl> + ! ( srcTy < = TObj ) ) { <nl> + return interpOne ( env , * env . currentNormalizedInstruction ) ; <nl> + } <nl> + <nl> + if ( srcTy < = Type : : SubObj ( SystemLib : : s_ThrowableClass ) ) { <nl> + return jmpImpl ( env , offset ) ; <nl> + } <nl> + <nl> + ifThenElse ( env , <nl> + [ & ] ( Block * taken ) { <nl> + assertx ( srcTy < = TObj ) ; <nl> + auto const srcClass = gen ( env , LdObjClass , topC ( env ) ) ; <nl> + auto const ecdExc = ExtendsClassData { SystemLib : : s_ExceptionClass } ; <nl> + auto const isException = gen ( env , ExtendsClass , ecdExc , srcClass ) ; <nl> + gen ( env , JmpNZero , taken , isException ) ; <nl> + auto const ecdErr = ExtendsClassData { SystemLib : : s_ErrorClass } ; <nl> + auto const isError = gen ( env , ExtendsClass , ecdErr , srcClass ) ; <nl> + gen ( env , JmpNZero , taken , isError ) ; <nl> + } , <nl> + [ & ] { gen ( env , Jmp , makeExitSlow ( env ) ) ; } , <nl> + [ & ] { jmpImpl ( env , offset ) ; } <nl> + ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> } } } <nl> mmm a / hphp / runtime / vm / jit / irgen - internal . h <nl> ppp b / hphp / runtime / vm / jit / irgen - internal . h <nl> inline IRSPRelOffset spOffBCFromIRSP ( const IRGS & env ) { <nl> return offsetFromIRSP ( env , BCSPRelOffset { 0 } ) ; <nl> } <nl> <nl> + / * <nl> + * Offset of empty evaluation stack . <nl> + * / <nl> + inline FPInvOffset spOffEmpty ( const IRGS & env ) { <nl> + return FPInvOffset { <nl> + resumeMode ( env ) = = ResumeMode : : None ? curFunc ( env ) - > numSlotsInFrame ( ) : 0 <nl> + } ; <nl> + } <nl> + <nl> inline SSATmp * pop ( IRGS & env , GuardConstraint gc = DataTypeSpecific ) { <nl> auto const offset = offsetFromIRSP ( env , BCSPRelOffset { 0 } ) ; <nl> auto const knownType = env . irb - > stack ( offset , gc ) . type ; <nl> mmm a / hphp / runtime / vm / jit / irgen - interpone . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - interpone . cpp <nl> void emitAddNewElemV ( IRGS & env ) { INTERP } <nl> void emitExit ( IRGS & env ) { INTERP } <nl> void emitFatal ( IRGS & env , FatalOp ) { INTERP } <nl> void emitUnwind ( IRGS & env ) { INTERP } <nl> - void emitThrow ( IRGS & env ) { INTERP } <nl> void emitCGetN ( IRGS & env ) { INTERP } <nl> void emitCGetQuietN ( IRGS & env ) { INTERP } <nl> void emitVGetN ( IRGS & env ) { INTERP } <nl> mmm a / hphp / runtime / vm / jit / irgen - resumable . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - resumable . cpp <nl> <nl> <nl> # include " hphp / runtime / vm / hhbc - codec . h " <nl> # include " hphp / runtime / vm / resumable . h " <nl> + # include " hphp / runtime / vm / unwind . h " <nl> <nl> # include " hphp / runtime / vm / jit / analysis . h " <nl> # include " hphp / runtime / vm / jit / irgen - call . h " <nl> + # include " hphp / runtime / vm / jit / irgen - control . h " <nl> # include " hphp / runtime / vm / jit / irgen - exit . h " <nl> # include " hphp / runtime / vm / jit / irgen - inlining . h " <nl> # include " hphp / runtime / vm / jit / irgen - ret . h " <nl> void emitWHResult ( IRGS & env ) { <nl> void emitAwait ( IRGS & env ) { <nl> auto const resumeOffset = nextBcOff ( env ) ; <nl> assertx ( curFunc ( env ) - > isAsync ( ) ) ; <nl> + assertx ( spOffBCFromFP ( env ) = = spOffEmpty ( env ) + 1 ) ; <nl> <nl> if ( curFunc ( env ) - > isAsyncGenerator ( ) & & <nl> resumeMode ( env ) = = ResumeMode : : Async ) PUNT ( Await - AsyncGenerator ) ; <nl> void emitAwait ( IRGS & env ) { <nl> push ( env , res ) ; <nl> } ; <nl> auto const handleFailed = [ & ] { <nl> - gen ( env , Jmp , exitSlow ) ; <nl> + auto const offset = findCatchHandler ( curFunc ( env ) , bcOff ( env ) ) ; <nl> + if ( offset ! = InvalidAbsoluteOffset ) { <nl> + auto const exception = gen ( env , LdWHResult , TObj , child ) ; <nl> + gen ( env , IncRef , exception ) ; <nl> + decRef ( env , child ) ; <nl> + push ( env , exception ) ; <nl> + jmpImpl ( env , offset ) ; <nl> + } else { <nl> + gen ( env , Jmp , exitSlow ) ; <nl> + } <nl> } ; <nl> auto const handleNotFinished = [ & ] { <nl> if ( childIsSWH ) { <nl> void emitAwait ( IRGS & env ) { <nl> void emitAwaitAll ( IRGS & env , LocalRange locals ) { <nl> auto const resumeOffset = nextBcOff ( env ) ; <nl> assertx ( curFunc ( env ) - > isAsync ( ) ) ; <nl> + assertx ( spOffBCFromFP ( env ) = = spOffEmpty ( env ) ) ; <nl> <nl> if ( curFunc ( env ) - > isAsyncGenerator ( ) & & <nl> resumeMode ( env ) = = ResumeMode : : Async ) PUNT ( Await - AsyncGenerator ) ; <nl> mmm a / hphp / runtime / vm / jit / translator . cpp <nl> ppp b / hphp / runtime / vm / jit / translator . cpp <nl> bool dontGuardAnyInputs ( const NormalizedInstruction & ni ) { <nl> case Op : : StaticLocInit : <nl> case Op : : String : <nl> case Op : : This : <nl> + case Op : : Throw : <nl> case Op : : True : <nl> case Op : : Unbox : <nl> case Op : : UnboxR : <nl> bool dontGuardAnyInputs ( const NormalizedInstruction & ni ) { <nl> case Op : : Exit : <nl> case Op : : Fatal : <nl> case Op : : Unwind : <nl> - case Op : : Throw : <nl> case Op : : CGetN : <nl> case Op : : CGetQuietN : <nl> case Op : : VGetN : <nl> mmm a / hphp / runtime / vm / srckey - inl . h <nl> ppp b / hphp / runtime / vm / srckey - inl . h <nl> inline void SrcKey : : setOffset ( Offset o ) { <nl> } <nl> <nl> inline OffsetSet SrcKey : : succOffsets ( ) const { <nl> - return instrSuccOffsets ( pc ( ) , unit ( ) ) ; <nl> + return instrSuccOffsets ( pc ( ) , func ( ) ) ; <nl> } <nl> <nl> inline void SrcKey : : advance ( const Unit * u ) { <nl> mmm a / hphp / runtime / vm / unwind . cpp <nl> ppp b / hphp / runtime / vm / unwind . cpp <nl> const StaticString s_xdebug_start_code_coverage ( " xdebug_start_code_coverage " ) ; <nl> <nl> } <nl> <nl> + Offset findCatchHandler ( const Func * func , Offset raiseOffset ) { <nl> + auto const eh = func - > findEH ( raiseOffset ) ; <nl> + if ( eh = = nullptr ) return InvalidAbsoluteOffset ; <nl> + if ( eh - > m_type ! = EHEnt : : Type : : Catch ) return InvalidAbsoluteOffset ; <nl> + auto pc = func - > unit ( ) - > at ( eh - > m_handler ) ; <nl> + UNUSED auto const op = decode_op ( pc ) ; <nl> + assertx ( op = = Op : : Catch ) ; <nl> + return func - > unit ( ) - > offsetOf ( pc ) ; <nl> + } <nl> + <nl> void chainFaultObjects ( ObjectData * top , ObjectData * prev ) { <nl> assertx ( throwable_has_expected_props ( ) ) ; <nl> <nl> mmm a / hphp / runtime / vm / unwind . h <nl> ppp b / hphp / runtime / vm / unwind . h <nl> <nl> # include " hphp / runtime / base / object - data . h " <nl> # include " hphp / runtime / base / type - object . h " <nl> # include " hphp / runtime / vm / class . h " <nl> + # include " hphp / runtime / vm / func . h " <nl> # include " hphp / runtime / vm / vm - regs . h " <nl> # include " hphp / util / trace . h " <nl> <nl> namespace HPHP { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> + / * <nl> + * Find a catch exception handler for a given raise location . Return the offset <nl> + * following the Catch opcode if the handler was found or InvalidAbsoluteOffset . <nl> + * / <nl> + Offset findCatchHandler ( const Func * func , Offset raiseOffset ) ; <nl> + <nl> / * <nl> * Unwind the PHP exception on the top of the fault stack . <nl> * / <nl> mmm a / hphp / test / slow / async / await_failure . php <nl> ppp b / hphp / test / slow / async / await_failure . php <nl> class Blah extends Exception { } <nl> } <nl> <nl> async function bar ( ) { <nl> - $ x = await foo ( ) ; <nl> - var_dump ( $ x ) ; <nl> + try { <nl> + $ x = await foo ( ) ; <nl> + var_dump ( $ x ) ; <nl> + } catch ( Exception $ e ) { <nl> + echo " rethrowing \ n " ; <nl> + throw $ e ; <nl> + } <nl> } <nl> <nl> function main ( ) { <nl> mmm a / hphp / test / slow / async / await_failure . php . expect <nl> ppp b / hphp / test / slow / async / await_failure . php . expect <nl> <nl> + rethrowing <nl> caught exception ( join ) <nl> + rethrowing <nl> caught exception ( result ) <nl> done <nl> new file mode 100644 <nl> index 00000000000 . . 4d07612b721 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / exceptions / throwables_dynamic . php <nl> <nl> + < ? hh <nl> + <nl> + class NonThrowable { } <nl> + <nl> + function raise ( $ what ) { <nl> + try { <nl> + throw $ what ; <nl> + } catch ( Throwable $ t ) { <nl> + echo " caught [ good ] : " . get_class ( $ t ) . " \ n " ; <nl> + } catch ( NonThrowable $ nt ) { <nl> + echo " caught [ bad ] : " . get_class ( $ nt ) . " \ n " ; <nl> + } <nl> + } <nl> + <nl> + < < __EntryPoint > > <nl> + function main ( ) { <nl> + raise ( new Exception ( ) ) ; <nl> + raise ( new InvalidOperationException ( ) ) ; <nl> + raise ( new Error ( ) ) ; <nl> + raise ( new AssertionError ( ) ) ; <nl> + raise ( new NonThrowable ( ) ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . abb919ccb5b <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / exceptions / throwables_dynamic . php . expectf <nl> <nl> + caught [ good ] : Exception <nl> + caught [ good ] : InvalidOperationException <nl> + caught [ good ] : Error <nl> + caught [ good ] : AssertionError <nl> + <nl> + Fatal error : Exceptions must implement the Throwable interface . in % s on line 7 <nl> new file mode 100644 <nl> index 00000000000 . . 3007b56fee1 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / exceptions / throwables_static . php <nl> <nl> + < ? hh <nl> + <nl> + class NonThrowable { } <nl> + <nl> + < < __EntryPoint > > <nl> + function main ( ) { <nl> + try { <nl> + throw new Exception ( ) ; <nl> + } catch ( Throwable $ t ) { <nl> + echo " caught [ good ] : " . get_class ( $ t ) . " \ n " ; <nl> + } <nl> + <nl> + try { <nl> + throw new InvalidOperationException ( ) ; <nl> + } catch ( Throwable $ t ) { <nl> + echo " caught [ good ] : " . get_class ( $ t ) . " \ n " ; <nl> + } <nl> + <nl> + try { <nl> + throw new Error ( ) ; <nl> + } catch ( Throwable $ t ) { <nl> + echo " caught [ good ] : " . get_class ( $ t ) . " \ n " ; <nl> + } <nl> + <nl> + try { <nl> + throw new AssertionError ( ) ; <nl> + } catch ( Throwable $ t ) { <nl> + echo " caught [ good ] : " . get_class ( $ t ) . " \ n " ; <nl> + } <nl> + <nl> + try { <nl> + throw new NonThrowable ( ) ; <nl> + } catch ( NonThrowable $ nt ) { <nl> + echo " caught [ bad ] : " . get_class ( $ nt ) . " \ n " ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 315c1413299 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / exceptions / throwables_static . php . expectf <nl> <nl> + caught [ good ] : Exception <nl> + caught [ good ] : InvalidOperationException <nl> + caught [ good ] : Error <nl> + caught [ good ] : AssertionError <nl> + <nl> + Fatal error : Exceptions must implement the Throwable interface . in % s on line 32 <nl>
Jump to the EH catch handler directly if possible
facebook/hhvm
d6aea18a4b8267ee0f474a8729c4e354d212be12
2018-11-01T17:02:45Z
mmm a / Code / CryEngine / CrySystem / Serialization / XmlIArchive . cpp <nl> ppp b / Code / CryEngine / CrySystem / Serialization / XmlIArchive . cpp <nl> bool Serialization : : CXmlIArchive : : operator ( ) ( IContainer & ser , const char * name , <nl> CRY_ASSERT ( name ) ; <nl> CRY_ASSERT ( name [ 0 ] ) ; <nl> <nl> - bool serializeSuccess = true ; <nl> - <nl> XmlNodeRef pChild = XmlUtil : : FindChildNode ( m_pRootNode , m_childIndexOverride , m_childIndexHint , name ) ; <nl> if ( pChild ) <nl> { <nl> + bool serializeSuccess = true ; <nl> + <nl> const int elementCount = pChild - > getChildCount ( ) ; <nl> ser . resize ( elementCount ) ; <nl> <nl> bool Serialization : : CXmlIArchive : : operator ( ) ( IContainer & ser , const char * name , <nl> ser . next ( ) ; <nl> } <nl> } <nl> - } <nl> <nl> - return serializeSuccess ; <nl> + return serializeSuccess ; <nl> + } <nl> + return false ; <nl> } <nl> <nl> void Serialization : : CXmlIArchive : : validatorMessage ( bool error , const void * handle , const TypeID & type , const char * message ) <nl>
! B ( Serialization ) Fix CXmlIArchive : : operator ( ) return value in case of containers missing from xml file . ( Approved by achim )
CRYTEK/CRYENGINE
d06857daa64e3944a744e92854dacc817220f292
2016-06-01T12:38:20Z
mmm a / docs / ABI / Mangling . rst <nl> ppp b / docs / ABI / Mangling . rst <nl> Globals <nl> global : : = type protocol - conformance ' Wl ' / / lazy protocol witness table accessor <nl> global : : = type ' WV ' / / value witness table <nl> global : : = entity ' Wv ' DIRECTNESS / / field offset <nl> + global : : = entity ' WC ' / / resilient enum tag index <nl> <nl> global : : = type ' Wy ' / / Outlined Copy Function Type <nl> global : : = type ' We ' / / Outlined Consume Function Type <nl> mmm a / include / swift / Demangling / DemangleNodes . def <nl> ppp b / include / swift / Demangling / DemangleNodes . def <nl> NODE ( DynamicAttribute ) <nl> NODE ( DirectMethodReferenceAttribute ) <nl> NODE ( DynamicSelf ) <nl> CONTEXT_NODE ( Enum ) <nl> + NODE ( EnumCase ) <nl> NODE ( ErrorType ) <nl> NODE ( EscapingAutoClosureType ) <nl> NODE ( NoEscapeFunctionType ) <nl> mmm a / include / swift / IRGen / Linking . h <nl> ppp b / include / swift / IRGen / Linking . h <nl> class LinkEntity { <nl> / / / ConstructorDecl * inside a protocol or a class . <nl> DispatchThunkAllocator , <nl> <nl> + / / / A resilient enum tag index . The pointer is a EnumElementDecl * . <nl> + EnumCase , <nl> + <nl> / / / A field offset . The pointer is a VarDecl * . <nl> FieldOffset , <nl> <nl> class LinkEntity { <nl> return entity ; <nl> } <nl> <nl> + static LinkEntity forEnumCase ( EnumElementDecl * decl ) { <nl> + LinkEntity entity ; <nl> + entity . setForDecl ( Kind : : EnumCase , decl ) ; <nl> + return entity ; <nl> + } <nl> + <nl> static LinkEntity forObjCClassRef ( ClassDecl * decl ) { <nl> LinkEntity entity ; <nl> entity . setForDecl ( Kind : : ObjCClassRef , decl ) ; <nl> mmm a / lib / Demangling / Demangler . cpp <nl> ppp b / lib / Demangling / Demangler . cpp <nl> NodePointer Demangler : : demangleSpecAttributes ( Node : : Kind SpecKind , <nl> <nl> NodePointer Demangler : : demangleWitness ( ) { <nl> switch ( nextChar ( ) ) { <nl> + case ' C ' : <nl> + return createWithChild ( Node : : Kind : : EnumCase , <nl> + popNode ( isEntity ) ) ; <nl> case ' V ' : <nl> return createWithChild ( Node : : Kind : : ValueWitnessTable , <nl> popNode ( Node : : Kind : : Type ) ) ; <nl> mmm a / lib / Demangling / NodePrinter . cpp <nl> ppp b / lib / Demangling / NodePrinter . cpp <nl> class NodePrinter { <nl> case Node : : Kind : : NoEscapeFunctionType : <nl> case Node : : Kind : : ExplicitClosure : <nl> case Node : : Kind : : Extension : <nl> + case Node : : Kind : : EnumCase : <nl> case Node : : Kind : : FieldOffset : <nl> case Node : : Kind : : FullTypeMetadata : <nl> case Node : : Kind : : Function : <nl> NodePointer NodePrinter : : print ( NodePointer Node , bool asPrefixContext ) { <nl> print ( entity , / * asContext * / false ) ; <nl> return nullptr ; <nl> } <nl> + case Node : : Kind : : EnumCase : { <nl> + Printer < < " enum case for " ; <nl> + auto entity = Node - > getChild ( 0 ) ; <nl> + print ( entity , / * asContext * / false ) ; <nl> + return nullptr ; <nl> + } <nl> case Node : : Kind : : ReabstractionThunk : <nl> case Node : : Kind : : ReabstractionThunkHelper : { <nl> if ( Options . ShortenThunk ) { <nl> mmm a / lib / Demangling / OldRemangler . cpp <nl> ppp b / lib / Demangling / OldRemangler . cpp <nl> void Remangler : : mangleFieldOffset ( Node * node ) { <nl> mangleChildNodes ( node ) ; / / directness , entity <nl> } <nl> <nl> + void Remangler : : mangleEnumCase ( Node * node ) { <nl> + Out < < " WC " ; <nl> + mangleSingleChildNode ( node ) ; / / enum case <nl> + } <nl> + <nl> void Remangler : : mangleProtocolWitnessTable ( Node * node ) { <nl> Out < < " WP " ; <nl> mangleSingleChildNode ( node ) ; / / protocol conformance <nl> mmm a / lib / Demangling / Remangler . cpp <nl> ppp b / lib / Demangling / Remangler . cpp <nl> void Remangler : : mangleFieldOffset ( Node * node ) { <nl> mangleChildNode ( node , 0 ) ; / / directness <nl> } <nl> <nl> + void Remangler : : mangleEnumCase ( Node * node ) { <nl> + mangleSingleChildNode ( node ) ; / / enum case <nl> + Buffer < < " WC " ; <nl> + } <nl> + <nl> void Remangler : : mangleFullTypeMetadata ( Node * node ) { <nl> mangleSingleChildNode ( node ) ; <nl> Buffer < < " Mf " ; <nl> mmm a / lib / IRGen / GenDecl . cpp <nl> ppp b / lib / IRGen / GenDecl . cpp <nl> SILLinkage LinkEntity : : getLinkage ( ForDefinition_t forDefinition ) const { <nl> case Kind : : CoroutineContinuationPrototype : <nl> return SILLinkage : : PublicExternal ; <nl> <nl> + <nl> + case Kind : : EnumCase : { <nl> + auto * elementDecl = cast < EnumElementDecl > ( getDecl ( ) ) ; <nl> + return getSILLinkage ( getDeclLinkage ( elementDecl ) , forDefinition ) ; <nl> + } <nl> + <nl> case Kind : : FieldOffset : { <nl> auto * varDecl = cast < VarDecl > ( getDecl ( ) ) ; <nl> <nl> bool LinkEntity : : isAvailableExternally ( IRGenModule & IGM ) const { <nl> case Kind : : ProtocolDescriptor : <nl> return : : isAvailableExternally ( IGM , getDecl ( ) ) ; <nl> <nl> + case Kind : : EnumCase : <nl> + return : : isAvailableExternally ( IGM , getDecl ( ) ) ; <nl> + <nl> case Kind : : DirectProtocolWitnessTable : <nl> case Kind : : ProtocolConformanceDescriptor : <nl> return : : isAvailableExternally ( IGM , getProtocolConformance ( ) - > getDeclContext ( ) ) ; <nl> Address IRGenModule : : getAddrOfFieldOffset ( VarDecl * var , <nl> forDefinition ) ; <nl> } <nl> <nl> + Address IRGenModule : : getAddrOfEnumCase ( EnumElementDecl * Case , <nl> + ForDefinition_t forDefinition ) { <nl> + LinkEntity entity = LinkEntity : : forEnumCase ( Case ) ; <nl> + return getAddrOfSimpleVariable ( * this , GlobalVars , entity , Int32Ty , <nl> + getPointerAlignment ( ) , forDefinition ) ; <nl> + } <nl> + <nl> void IRGenModule : : emitNestedTypeDecls ( DeclRange members ) { <nl> for ( Decl * member : members ) { <nl> switch ( member - > getKind ( ) ) { <nl> mmm a / lib / IRGen / GenEnum . cpp <nl> ppp b / lib / IRGen / GenEnum . cpp <nl> <nl> # include " swift / AST / Decl . h " <nl> # include " swift / AST / Expr . h " <nl> # include " swift / AST / IRGenOptions . h " <nl> + # include " swift / IRGen / Linking . h " <nl> # include " swift / SIL / SILModule . h " <nl> # include " llvm / IR / Function . h " <nl> # include " llvm / IR / GlobalVariable . h " <nl> irgen : : EnumImplStrategy : : getResilientTagIndex ( EnumElementDecl * Case ) const { <nl> return getTagIndex ( Case ) - ElementsWithPayload . size ( ) ; <nl> } <nl> <nl> + static void emitResilientTagIndex ( IRGenModule & IGM , <nl> + const EnumImplStrategy * strategy , <nl> + EnumElementDecl * Case ) { <nl> + auto resilientIdx = strategy - > getResilientTagIndex ( Case ) ; <nl> + auto global = IGM . getAddrOfEnumCase ( Case , ForDefinition ) ; <nl> + cast < llvm : : GlobalVariable > ( global . getAddress ( ) ) <nl> + - > setInitializer ( llvm : : ConstantInt : : get ( IGM . Int32Ty , resilientIdx ) ) ; <nl> + } <nl> + <nl> + void <nl> + irgen : : EnumImplStrategy : : emitResilientTagIndices ( IRGenModule & IGM ) const { <nl> + for ( auto & payload : ElementsWithPayload ) { <nl> + emitResilientTagIndex ( IGM , this , payload . decl ) ; <nl> + } <nl> + for ( auto & noPayload : ElementsWithNoPayload ) { <nl> + emitResilientTagIndex ( IGM , this , noPayload . decl ) ; <nl> + } <nl> + } <nl> + <nl> namespace { <nl> / / / Implementation strategy for singleton enums , with zero or one cases . <nl> class SingletonEnumImplStrategy final : public EnumImplStrategy { <nl> namespace { <nl> std : : move ( WithNoPayload ) ) <nl> { } <nl> <nl> + int getResilientTagIndex ( EnumElementDecl * ) const override { <nl> + / / Resilient enum ' s should load the tag index from a global . <nl> + llvm_unreachable ( " Use loadResilientTagIndex instead " ) ; <nl> + } <nl> + <nl> + llvm : : Value * loadResilientTagIndex ( IRGenFunction & IGF , <nl> + EnumElementDecl * Case ) const { <nl> + auto address = IGF . IGM . getAddrOfEnumCase ( Case , NotForDefinition ) ; <nl> + return IGF . Builder . CreateLoad ( address ) ; <nl> + } <nl> + <nl> TypeInfo * completeEnumTypeLayout ( TypeConverter & TC , <nl> SILType Type , <nl> EnumDecl * theEnum , <nl> namespace { <nl> SILType T , <nl> Address enumAddr , <nl> EnumElementDecl * Case ) const override { <nl> - emitDestructiveInjectEnumTagCall ( IGF , T , <nl> - getResilientTagIndex ( Case ) , <nl> + emitDestructiveInjectEnumTagCall ( IGF , T , loadResilientTagIndex ( IGF , Case ) , <nl> enumAddr ) ; <nl> } <nl> <nl> namespace { <nl> Address enumAddr , <nl> EnumElementDecl * Case ) const override { <nl> llvm : : Value * tag = emitGetEnumTagCall ( IGF , T , enumAddr ) ; <nl> - llvm : : Value * expectedTag = <nl> - llvm : : ConstantInt : : get ( IGF . IGM . Int32Ty , <nl> - getResilientTagIndex ( Case ) ) ; <nl> + llvm : : Value * expectedTag = loadResilientTagIndex ( IGF , Case ) ; <nl> return IGF . Builder . CreateICmpEQ ( tag , expectedTag ) ; <nl> } <nl> <nl> namespace { <nl> if ( ! defaultDest ) <nl> defaultDest = unreachableBB ; <nl> <nl> - auto tagSwitch = SwitchBuilder : : create ( IGF , tag , <nl> - SwitchDefaultDest ( defaultDest , <nl> - defaultDest = = unreachableBB <nl> - ? IsUnreachable <nl> - : IsNotUnreachable ) , <nl> - dests . size ( ) ) ; <nl> + llvm : : BasicBlock * continuationBB = nullptr ; <nl> + <nl> + unsigned numCasesEmitted = 0 ; <nl> <nl> auto emitCase = [ & ] ( Element elt ) { <nl> - auto tagVal = <nl> - llvm : : ConstantInt : : get ( IGF . IGM . Int32Ty , <nl> - getResilientTagIndex ( elt . decl ) ) ; <nl> auto found = destMap . find ( elt . decl ) ; <nl> - if ( found ! = destMap . end ( ) ) <nl> - tagSwitch - > addCase ( tagVal , found - > second ) ; <nl> + if ( found ! = destMap . end ( ) ) { <nl> + if ( continuationBB ) <nl> + IGF . Builder . emitBlock ( continuationBB ) ; <nl> + <nl> + auto tagVal = loadResilientTagIndex ( IGF , elt . decl ) ; <nl> + auto matchesTag = IGF . Builder . CreateICmpEQ ( tag , tagVal ) ; <nl> + <nl> + / / If we are not the last block create a continuation block . <nl> + if ( + + numCasesEmitted < dests . size ( ) ) <nl> + continuationBB = llvm : : BasicBlock : : Create ( C ) ; <nl> + / / Otherwise , our continuation is the default destination . <nl> + else <nl> + continuationBB = defaultDest ; <nl> + IGF . Builder . CreateCondBr ( matchesTag , found - > second , continuationBB ) ; <nl> + } <nl> } ; <nl> <nl> for ( auto & elt : ElementsWithPayload ) <nl> namespace { <nl> for ( auto & elt : ElementsWithNoPayload ) <nl> emitCase ( elt ) ; <nl> <nl> + / / If we have not emitted any cases jump to the default destination . <nl> + if ( numCasesEmitted = = 0 ) { <nl> + IGF . Builder . CreateBr ( defaultDest ) ; <nl> + } <nl> + <nl> / / Delete the unreachable default block if we didn ' t use it , or emit it <nl> / / if we did . <nl> if ( unreachableBB - > use_empty ( ) ) { <nl> void IRGenModule : : emitEnumDecl ( EnumDecl * theEnum ) { <nl> } <nl> <nl> emitFieldMetadataRecord ( theEnum ) ; <nl> + <nl> + if ( isResilient ( theEnum , ResilienceExpansion : : Maximal ) ) <nl> + return ; <nl> + <nl> + / / Emit resilient tag indices . <nl> + auto & strategy = getEnumImplStrategy ( <nl> + * this , <nl> + theEnum - > DeclContext : : getDeclaredTypeInContext ( ) - > getCanonicalType ( ) ) ; <nl> + strategy . emitResilientTagIndices ( * this ) ; <nl> } <nl> <nl> void irgen : : emitSwitchAddressOnlyEnumDispatch ( IRGenFunction & IGF , <nl> mmm a / lib / IRGen / GenEnum . h <nl> ppp b / lib / IRGen / GenEnum . h <nl> class EnumImplStrategy { <nl> <nl> / / / Return a tag index in the range <nl> / / / [ - ElementsWithPayload . . ElementsWithNoPayload - 1 ] . <nl> - int getResilientTagIndex ( EnumElementDecl * Case ) const ; <nl> + virtual int getResilientTagIndex ( EnumElementDecl * Case ) const ; <nl> <nl> / / / Map the given element to the appropriate index in the <nl> / / / discriminator type . <nl> class EnumImplStrategy { <nl> ReferenceCounting * rc ) const { <nl> return false ; <nl> } <nl> - <nl> + <nl> + void emitResilientTagIndices ( IRGenModule & IGM ) const ; <nl> + <nl> private : <nl> EnumImplStrategy ( const EnumImplStrategy & ) = delete ; <nl> EnumImplStrategy & operator = ( const EnumImplStrategy & ) = delete ; <nl> mmm a / lib / IRGen / GenOpaque . cpp <nl> ppp b / lib / IRGen / GenOpaque . cpp <nl> void irgen : : emitDestructiveProjectEnumDataCall ( IRGenFunction & IGF , <nl> / / / The type must be dynamically known to have enum witnesses . <nl> void irgen : : emitDestructiveInjectEnumTagCall ( IRGenFunction & IGF , <nl> SILType T , <nl> - unsigned tag , <nl> + llvm : : Value * tagValue , <nl> Address srcObject ) { <nl> llvm : : Value * metadata ; <nl> auto fn = IGF . emitValueWitnessFunctionRef ( T , metadata , <nl> ValueWitness : : DestructiveInjectEnumTag ) ; <nl> - llvm : : Value * tagValue = <nl> - llvm : : ConstantInt : : get ( IGF . IGM . Int32Ty , tag ) ; <nl> IGF . Builder . CreateCall ( fn , { srcObject . getAddress ( ) , tagValue , metadata } ) ; <nl> } <nl> <nl> mmm a / lib / IRGen / GenOpaque . h <nl> ppp b / lib / IRGen / GenOpaque . h <nl> namespace irgen { <nl> / / / The type must be dynamically known to have enum witnesses . <nl> void emitDestructiveInjectEnumTagCall ( IRGenFunction & IGF , <nl> SILType T , <nl> - unsigned tag , <nl> + llvm : : Value * tag , <nl> Address srcObject ) ; <nl> <nl> / / / Emit a load of the ' size ' value witness . <nl> mmm a / lib / IRGen / IRGenMangler . h <nl> ppp b / lib / IRGen / IRGenMangler . h <nl> class IRGenMangler : public Mangle : : ASTMangler { <nl> return finalize ( ) ; <nl> } <nl> <nl> + std : : string mangleEnumCase ( const ValueDecl * Decl ) { <nl> + beginMangling ( ) ; <nl> + appendEntity ( Decl ) ; <nl> + appendOperator ( " WC " ) ; <nl> + return finalize ( ) ; <nl> + } <nl> + <nl> std : : string mangleDirectProtocolWitnessTable ( const ProtocolConformance * C ) { <nl> return mangleConformanceSymbol ( Type ( ) , C , " WP " ) ; <nl> } <nl> mmm a / lib / IRGen / IRGenModule . h <nl> ppp b / lib / IRGen / IRGenModule . h <nl> private : \ <nl> ForDefinition_t forDefinition ) ; <nl> <nl> llvm : : Function * emitDispatchThunk ( SILDeclRef declRef ) ; <nl> - <nl> + Address getAddrOfEnumCase ( EnumElementDecl * Case , <nl> + ForDefinition_t forDefinition ) ; <nl> Address getAddrOfFieldOffset ( VarDecl * D , ForDefinition_t forDefinition ) ; <nl> llvm : : Function * getAddrOfValueWitness ( CanType concreteType , <nl> ValueWitness index , <nl> mmm a / lib / IRGen / Linking . cpp <nl> ppp b / lib / IRGen / Linking . cpp <nl> std : : string LinkEntity : : mangleAsString ( ) const { <nl> return mangler . mangleProtocolConformanceDescriptor ( <nl> cast < NormalProtocolConformance > ( getProtocolConformance ( ) ) ) ; <nl> <nl> + case Kind : : EnumCase : <nl> + return mangler . mangleEnumCase ( getDecl ( ) ) ; <nl> + <nl> case Kind : : FieldOffset : <nl> return mangler . mangleFieldOffset ( getDecl ( ) ) ; <nl> <nl> mmm a / test / IRGen / enum_resilience . swift <nl> ppp b / test / IRGen / enum_resilience . swift <nl> public func functionWithIndirectResilientEnum ( _ ia : IndirectApproach ) - > Indirec <nl> <nl> / / CHECK - LABEL : define { { ( protected ) ? } } swiftcc void @ " $ S15enum_resilience31constructResilientEnumNoPayload010resilient_A06MediumOyF " <nl> public func constructResilientEnumNoPayload ( ) - > Medium { <nl> + / / CHECK : [ [ TAG : % . * ] ] = load i32 , i32 * @ " $ S14resilient_enum6MediumO5PaperyA2CmFWC " <nl> / / CHECK : [ [ T0 : % . * ] ] = call swiftcc % swift . metadata_response @ " $ S14resilient_enum6MediumOMa " ( [ [ INT ] ] 0 ) <nl> / / CHECK - NEXT : [ [ METADATA : % . * ] ] = extractvalue % swift . metadata_response [ [ T0 ] ] , 0 <nl> / / CHECK - NEXT : [ [ METADATA_ADDR : % . * ] ] = bitcast % swift . type * [ [ METADATA ] ] to i8 * * * <nl> public func constructResilientEnumNoPayload ( ) - > Medium { <nl> / / CHECK - NEXT : [ [ WITNESS_ADDR : % . * ] ] = getelementptr inbounds i8 * , i8 * * [ [ VWT ] ] , i32 17 <nl> / / CHECK - NEXT : [ [ WITNESS : % . * ] ] = load i8 * , i8 * * [ [ WITNESS_ADDR ] ] <nl> / / CHECK - NEXT : [ [ WITNESS_FN : % . * ] ] = bitcast i8 * [ [ WITNESS ] ] <nl> - / / CHECK - NEXT : call void [ [ WITNESS_FN ] ] ( % swift . opaque * noalias % 0 , i32 0 , % swift . type * [ [ METADATA ] ] ) <nl> + / / CHECK - NEXT : call void [ [ WITNESS_FN ] ] ( % swift . opaque * noalias % 0 , i32 [ [ TAG ] ] , % swift . type * [ [ METADATA ] ] ) <nl> <nl> / / CHECK - NEXT : ret void <nl> return Medium . Paper <nl> public func constructResilientEnumPayload ( _ s : Size ) - > Medium { <nl> / / CHECK - NEXT : [ [ WITNESS_FN : % initializeWithCopy ] ] = bitcast i8 * [ [ WITNESS ] ] <nl> / / CHECK - NEXT : [ [ COPY : % . * ] ] = call % swift . opaque * [ [ WITNESS_FN ] ] ( % swift . opaque * noalias % 0 , % swift . opaque * noalias % 1 , % swift . type * [ [ METADATA ] ] ) <nl> <nl> + / / CHECK - NEXT : [ [ TAG : % . * ] ] = load i32 , i32 * @ " $ S14resilient_enum6MediumO8PostcardyAC0A7_struct4SizeVcACmFWC " <nl> / / CHECK - NEXT : [ [ T0 : % . * ] ] = call swiftcc % swift . metadata_response @ " $ S14resilient_enum6MediumOMa " ( [ [ INT ] ] 0 ) <nl> / / CHECK - NEXT : [ [ METADATA2 : % . * ] ] = extractvalue % swift . metadata_response [ [ T0 ] ] , 0 <nl> / / CHECK - NEXT : [ [ METADATA_ADDR2 : % . * ] ] = bitcast % swift . type * [ [ METADATA2 ] ] to i8 * * * <nl> public func constructResilientEnumPayload ( _ s : Size ) - > Medium { <nl> / / CHECK - NEXT : [ [ WITNESS_ADDR : % . * ] ] = getelementptr inbounds i8 * , i8 * * [ [ VWT2 ] ] , i32 17 <nl> / / CHECK - NEXT : [ [ WITNESS : % . * ] ] = load i8 * , i8 * * [ [ WITNESS_ADDR ] ] <nl> / / CHECK - NEXT : [ [ WITNESS_FN : % destructiveInjectEnumTag ] ] = bitcast i8 * [ [ WITNESS ] ] <nl> - / / CHECK - NEXT : call void [ [ WITNESS_FN ] ] ( % swift . opaque * noalias % 0 , i32 - 2 , % swift . type * [ [ METADATA2 ] ] ) <nl> + / / CHECK - NEXT : call void [ [ WITNESS_FN ] ] ( % swift . opaque * noalias % 0 , i32 [ [ TAG ] ] , % swift . type * [ [ METADATA2 ] ] ) <nl> + <nl> + / / CHECK - NEXT : [ [ WITNESS_ADDR : % . * ] ] = getelementptr inbounds i8 * , i8 * * [ [ VWT ] ] , i32 1 <nl> + / / CHECK - NEXT : [ [ WITNESS : % . * ] ] = load i8 * , i8 * * [ [ WITNESS_ADDR ] ] <nl> + / / CHECK - NEXT : [ [ WITNESS_FN : % . * ] ] = bitcast i8 * [ [ WITNESS ] ] <nl> + / / CHECK - NEXT : call void [ [ WITNESS_FN ] ] ( % swift . opaque * noalias % 1 , % swift . type * [ [ METADATA ] ] ) <nl> + <nl> / / CHECK - NEXT : ret void <nl> <nl> return Medium . Postcard ( s ) <nl> public func constructResilientEnumPayload ( _ s : Size ) - > Medium { <nl> / / CHECK : [ [ WITNESS_FN : % getEnumTag ] ] = bitcast i8 * [ [ WITNESS ] ] <nl> / / CHECK : [ [ TAG : % . * ] ] = call i32 [ [ WITNESS_FN ] ] ( % swift . opaque * noalias [ [ ENUM_STORAGE ] ] , % swift . type * [ [ METADATA ] ] ) <nl> <nl> - / / CHECK : switch i32 [ [ TAG ] ] , label % [ [ DEFAULT_CASE : . * ] ] [ <nl> - / / CHECK : i32 - 1 , label % [ [ PAMPHLET_CASE : . * ] ] <nl> - / / CHECK : i32 0 , label % [ [ PAPER_CASE : . * ] ] <nl> - / / CHECK : i32 1 , label % [ [ CANVAS_CASE : . * ] ] <nl> - / / CHECK : ] <nl> + / / CHECK : [ [ PAMPHLET_CASE_TAG : % . * ] ] = load i32 , i32 * @ " $ S14resilient_enum6MediumO8PamphletyA2CcACmFWC " <nl> + / / CHECK : [ [ PAMPHLET_CASE : % . * ] ] = icmp eq i32 [ [ TAG ] ] , [ [ PAMPHLET_CASE_TAG ] ] <nl> + / / CHECK : br i1 [ [ PAMPHLET_CASE ] ] , label % [ [ PAMPHLET_CASE_LABEL : . * ] ] , label % [ [ PAPER_CHECK : . * ] ] <nl> <nl> - / / CHECK : ; < label > : [ [ PAPER_CASE ] ] <nl> + / / CHECK : < label > : [ [ PAPER_CHECK ] ] : <nl> + / / CHECK : [ [ PAPER_CASE_TAG : % . * ] ] = load i32 , i32 * @ " $ S14resilient_enum6MediumO5PaperyA2CmFWC " <nl> + / / CHECK : [ [ PAPER_CASE : % . * ] ] = icmp eq i32 [ [ TAG ] ] , [ [ PAPER_CASE_TAG ] ] <nl> + / / CHECK : br i1 [ [ PAPER_CASE ] ] , label % [ [ PAPER_CASE_LABEL : . * ] ] , label % [ [ CANVAS_CHECK : . * ] ] <nl> + <nl> + / / CHECK : < label > : [ [ CANVAS_CHECK ] ] : <nl> + / / CHECK : [ [ CANVAS_CASE_TAG : % . * ] ] = load i32 , i32 * @ " $ S14resilient_enum6MediumO6CanvasyA2CmFWC " <nl> + / / CHECK : [ [ CANVAS_CASE : % . * ] ] = icmp eq i32 [ [ TAG ] ] , [ [ CANVAS_CASE_TAG ] ] <nl> + / / CHECK : br i1 [ [ CANVAS_CASE ] ] , label % [ [ CANVAS_CASE_LABEL : . * ] ] , label % [ [ DEFAULT_CASE : . * ] ] <nl> + <nl> + / / CHECK : ; < label > : [ [ PAPER_CASE_LABEL ] ] <nl> / / CHECK : br label % [ [ END : . * ] ] <nl> <nl> - / / CHECK : ; < label > : [ [ CANVAS_CASE ] ] <nl> + / / CHECK : ; < label > : [ [ CANVAS_CASE_LABEL ] ] <nl> / / CHECK : br label % [ [ END ] ] <nl> <nl> - / / CHECK : ; < label > : [ [ PAMPHLET_CASE ] ] <nl> + / / CHECK : ; < label > : [ [ PAMPHLET_CASE_LABEL ] ] <nl> + / / CHECK : swift_projectBox <nl> / / CHECK : br label % [ [ END ] ] <nl> <nl> / / CHECK : ; < label > : [ [ DEFAULT_CASE ] ] <nl> + / / CHECK : br label % [ [ DEFAULT_CASE_DESTROY : . * ] ] <nl> + <nl> + / / CHECK : < label > : [ [ DEFAULT_CASE_DESTROY ] ] <nl> + / / CHeCK : call void % destroy <nl> / / CHECK : br label % [ [ END ] ] <nl> <nl> / / CHECK : ; < label > : [ [ END ] ] <nl> + / / CHECK : = phi i64 [ 3 , % [ [ DEFAULT_CASE_DESTROY ] ] ] , [ { { . * } } , % [ [ PAMPHLET_CASE_LABEL ] ] ] , [ 2 , % [ [ CANVAS_CASE_LABEL ] ] ] , [ 1 , % [ [ PAPER_CASE_LABEL ] ] ] <nl> / / CHECK : ret <nl> <nl> public func resilientSwitchTest ( _ m : Medium ) - > Int { <nl>
IRGen : Make resilient enum ' s tag indices resilient
apple/swift
ce7608a7ce4d2b741ac1e5a00850330f88143f87
2018-03-20T20:19:56Z
mmm a / python - package / . pylintrc <nl> ppp b / python - package / . pylintrc <nl> <nl> <nl> ignore = tests <nl> <nl> - disable = invalid - name , wildcard - import , too - many - arguments , attribute - defined - outside - init , no - member , too - many - instance - attributes , too - few - public - methods , import - error , super - on - old - class , fixme <nl> + disable = invalid - name , wildcard - import , too - many - arguments , attribute - defined - outside - init , no - member , too - many - instance - attributes , too - few - public - methods , import - error , super - on - old - class , fixme , too - many - nested - blocks <nl> <nl> dummy - variables - rgx = ( unused | ) _ . * <nl> <nl>
ignore nested blocks
dmlc/xgboost
7be496a051df5a845d514bc7928ab46b9affd77c
2015-12-12T00:20:35Z
mmm a / src / mongo / db / pipeline / SConscript <nl> ppp b / src / mongo / db / pipeline / SConscript <nl> env . Library ( <nl> ] , <nl> LIBDEPS = [ <nl> ' $ BUILD_DIR / mongo / db / transaction ' , <nl> + ' $ BUILD_DIR / mongo / db / write_ops ' , <nl> ' $ BUILD_DIR / mongo / s / sharding_api ' , <nl> ' process_interface_standalone ' , <nl> ' sharded_agg_helpers ' , <nl> mmm a / src / mongo / db / pipeline / document_source_merge . cpp <nl> ppp b / src / mongo / db / pipeline / document_source_merge . cpp <nl> MergeStrategy makeUpdateStrategy ( bool upsert , BatchTransform transform ) { <nl> } <nl> <nl> constexpr auto multi = false ; <nl> - expCtx - > mongoProcessInterface - > update ( <nl> - expCtx , ns , std : : move ( batch ) , wc , upsert , multi , epoch ) ; <nl> + uassertStatusOK ( expCtx - > mongoProcessInterface - > update ( <nl> + expCtx , ns , std : : move ( batch ) , wc , upsert , multi , epoch ) ) ; <nl> } ; <nl> } <nl> <nl> MergeStrategy makeStrictUpdateStrategy ( bool upsert , BatchTransform transform ) { <nl> transform ( batch ) ; <nl> } <nl> <nl> - const auto batchSize = batch . size ( ) ; <nl> + const int64_t batchSize = batch . size ( ) ; <nl> constexpr auto multi = false ; <nl> - auto writeResult = expCtx - > mongoProcessInterface - > updateWithResult ( <nl> - expCtx , ns , std : : move ( batch ) , wc , upsert , multi , epoch ) ; <nl> - constexpr auto initValue = 0ULL ; <nl> - auto nMatched = <nl> - std : : accumulate ( writeResult . results . begin ( ) , <nl> - writeResult . results . end ( ) , <nl> - initValue , <nl> - [ ] ( auto total , const auto & opRes ) { <nl> - return total + ( opRes . isOK ( ) ? opRes . getValue ( ) . getN ( ) : 0 ) ; <nl> - } ) ; <nl> + auto updateResult = uassertStatusOK ( expCtx - > mongoProcessInterface - > update ( <nl> + expCtx , ns , std : : move ( batch ) , wc , upsert , multi , epoch ) ) ; <nl> uassert ( ErrorCodes : : MergeStageNoMatchingDocument , <nl> " { } could not find a matching document in the target collection " <nl> " for at least one document in the source collection " _format ( kStageName ) , <nl> - nMatched = = batchSize ) ; <nl> + updateResult . nMatched = = batchSize ) ; <nl> } ; <nl> } <nl> <nl> MergeStrategy makeInsertStrategy ( ) { <nl> std : : transform ( batch . begin ( ) , batch . end ( ) , objectsToInsert . begin ( ) , [ ] ( const auto & obj ) { <nl> return std : : get < UpdateModification > ( obj ) . getUpdateClassic ( ) ; <nl> } ) ; <nl> - expCtx - > mongoProcessInterface - > insert ( expCtx , ns , std : : move ( objectsToInsert ) , wc , epoch ) ; <nl> + uassertStatusOK ( expCtx - > mongoProcessInterface - > insert ( <nl> + expCtx , ns , std : : move ( objectsToInsert ) , wc , epoch ) ) ; <nl> } ; <nl> } <nl> <nl> mmm a / src / mongo / db / pipeline / document_source_out . h <nl> ppp b / src / mongo / db / pipeline / document_source_out . h <nl> class DocumentSourceOut final : public DocumentSourceWriter < BSONObj > { <nl> DocumentSourceWriteBlock writeBlock ( pExpCtx - > opCtx ) ; <nl> <nl> auto targetEpoch = boost : : none ; <nl> - pExpCtx - > mongoProcessInterface - > insert ( <nl> - pExpCtx , _tempNs , std : : move ( batch ) , _writeConcern , targetEpoch ) ; <nl> + uassertStatusOK ( pExpCtx - > mongoProcessInterface - > insert ( <nl> + pExpCtx , _tempNs , std : : move ( batch ) , _writeConcern , targetEpoch ) ) ; <nl> } <nl> <nl> std : : pair < BSONObj , int > makeBatchObject ( Document & & doc ) const override { <nl> mmm a / src / mongo / db / pipeline / mongo_process_interface . h <nl> ppp b / src / mongo / db / pipeline / mongo_process_interface . h <nl> class MongoProcessInterface { <nl> bool attachCursorSource = true ; <nl> } ; <nl> <nl> + / * * <nl> + * This structure holds the result of a batched update operation , such as the number of <nl> + * documents that matched the query predicate , and the number of documents modified by the <nl> + * update operation . <nl> + * / <nl> + struct UpdateResult { <nl> + int64_t nMatched { 0 } ; <nl> + int64_t nModified { 0 } ; <nl> + } ; <nl> + <nl> virtual ~ MongoProcessInterface ( ) { } ; <nl> <nl> / * * <nl> class MongoProcessInterface { <nl> virtual bool isSharded ( OperationContext * opCtx , const NamespaceString & ns ) = 0 ; <nl> <nl> / * * <nl> - * Inserts ' objs ' into ' ns ' and throws a UserException if the insert fails . If ' targetEpoch ' is <nl> + * Inserts ' objs ' into ' ns ' and returns an error Status if the insert fails . If ' targetEpoch ' is <nl> * set , throws ErrorCodes : : StaleEpoch if the targeted collection does not have the same epoch or <nl> * the epoch changes during the course of the insert . <nl> * / <nl> - virtual void insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > targetEpoch ) = 0 ; <nl> - <nl> - / * * <nl> - * Updates the documents matching ' queries ' with the objects ' updates ' . Throws a UserException <nl> - * if any of the updates fail . If ' targetEpoch ' is set , throws ErrorCodes : : StaleEpoch if the <nl> - * targeted collection does not have the same epoch , or if the epoch changes during the update . <nl> - * / <nl> - virtual void update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) = 0 ; <nl> + virtual Status insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > targetEpoch ) = 0 ; <nl> <nl> / * * <nl> - * Updates the documents matching ' queries ' with the objects ' updates ' . Throws a UserException <nl> - * if any of the updates fail . If ' targetEpoch ' is set , throws ErrorCodes : : StaleEpoch if the <nl> - * targeted collection does not have the same epoch , or if the epoch changes during the update . <nl> - * Returns a ' WriteResult ' object with information about the write operation . <nl> + * Updates the documents matching ' queries ' with the objects ' updates ' . Returns an error Status <nl> + * if any of the updates fail , otherwise returns an ' UpdateResult ' objects with the details of <nl> + * the update operation . If ' targetEpoch ' is set , throws ErrorCodes : : StaleEpoch if the targeted <nl> + * collection does not have the same epoch , or if the epoch changes during the update . <nl> * / <nl> - virtual WriteResult updateWithResult ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) = 0 ; <nl> + virtual StatusWith < UpdateResult > update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + BatchedObjects & & batch , <nl> + const WriteConcernOptions & wc , <nl> + bool upsert , <nl> + bool multi , <nl> + boost : : optional < OID > targetEpoch ) = 0 ; <nl> <nl> virtual CollectionIndexUsageMap getIndexStats ( OperationContext * opCtx , <nl> const NamespaceString & ns ) = 0 ; <nl> mmm a / src / mongo / db / pipeline / mongos_process_interface . h <nl> ppp b / src / mongo / db / pipeline / mongos_process_interface . h <nl> class MongoSInterface : public MongoProcessCommon { <nl> <nl> bool isSharded ( OperationContext * opCtx , const NamespaceString & nss ) final ; <nl> <nl> - void insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > ) final { <nl> + Status insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > ) final { <nl> MONGO_UNREACHABLE ; <nl> } <nl> <nl> - void update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > ) final { <nl> - MONGO_UNREACHABLE ; <nl> - } <nl> - <nl> - WriteResult updateWithResult ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) final override { <nl> + StatusWith < UpdateResult > update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + BatchedObjects & & batch , <nl> + const WriteConcernOptions & wc , <nl> + bool upsert , <nl> + bool multi , <nl> + boost : : optional < OID > ) final { <nl> MONGO_UNREACHABLE ; <nl> } <nl> <nl> mmm a / src / mongo / db / pipeline / process_interface_shardsvr . cpp <nl> ppp b / src / mongo / db / pipeline / process_interface_shardsvr . cpp <nl> MongoInterfaceShardServer : : collectDocumentKeyFieldsForHostedCollection ( Operation <nl> return { _shardKeyToDocumentKeyFields ( metadata - > getKeyPatternFields ( ) ) , true } ; <nl> } <nl> <nl> - void MongoInterfaceShardServer : : insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > targetEpoch ) { <nl> + Status MongoInterfaceShardServer : : insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > targetEpoch ) { <nl> BatchedCommandResponse response ; <nl> BatchWriteExecStats stats ; <nl> <nl> void MongoInterfaceShardServer : : insert ( const boost : : intrusive_ptr < ExpressionCont <nl> <nl> ClusterWriter : : write ( expCtx - > opCtx , insertCommand , & stats , & response , targetEpoch ) ; <nl> <nl> - / / TODO SERVER - 35403 : Add more context for which shard produced the error . <nl> - uassertStatusOKWithContext ( response . toStatus ( ) , " Insert failed : " ) ; <nl> + return response . toStatus ( ) ; <nl> } <nl> <nl> - void MongoInterfaceShardServer : : update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) { <nl> + StatusWith < MongoProcessInterface : : UpdateResult > MongoInterfaceShardServer : : update ( <nl> + const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + BatchedObjects & & batch , <nl> + const WriteConcernOptions & wc , <nl> + bool upsert , <nl> + bool multi , <nl> + boost : : optional < OID > targetEpoch ) { <nl> BatchedCommandResponse response ; <nl> BatchWriteExecStats stats ; <nl> <nl> void MongoInterfaceShardServer : : update ( const boost : : intrusive_ptr < ExpressionCont <nl> <nl> ClusterWriter : : write ( expCtx - > opCtx , updateCommand , & stats , & response , targetEpoch ) ; <nl> <nl> - / / TODO SERVER - 35403 : Add more context for which shard produced the error . <nl> - uassertStatusOKWithContext ( response . toStatus ( ) , " Update failed : " ) ; <nl> + if ( auto status = response . toStatus ( ) ; status ! = Status : : OK ( ) ) { <nl> + return status ; <nl> + } <nl> + return { { response . getN ( ) , response . getNModified ( ) } } ; <nl> } <nl> <nl> unique_ptr < Pipeline , PipelineDeleter > MongoInterfaceShardServer : : attachCursorSourceToPipeline ( <nl> mmm a / src / mongo / db / pipeline / process_interface_shardsvr . h <nl> ppp b / src / mongo / db / pipeline / process_interface_shardsvr . h <nl> class MongoInterfaceShardServer final : public MongoInterfaceStandalone { <nl> * Inserts the documents ' objs ' into the namespace ' ns ' using the ClusterWriter for locking , <nl> * routing , stale config handling , etc . <nl> * / <nl> - void insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > targetEpoch ) final ; <nl> + Status insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > targetEpoch ) final ; <nl> <nl> / * * <nl> * Replaces the documents matching ' queries ' with ' updates ' using the ClusterWriter for locking , <nl> * routing , stale config handling , etc . <nl> * / <nl> - void update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) final ; <nl> + StatusWith < UpdateResult > update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + BatchedObjects & & batch , <nl> + const WriteConcernOptions & wc , <nl> + bool upsert , <nl> + bool multi , <nl> + boost : : optional < OID > targetEpoch ) final ; <nl> <nl> std : : unique_ptr < Pipeline , PipelineDeleter > attachCursorSourceToPipeline ( <nl> const boost : : intrusive_ptr < ExpressionContext > & expCtx , Pipeline * pipeline ) final ; <nl> mmm a / src / mongo / db / pipeline / process_interface_standalone . cpp <nl> ppp b / src / mongo / db / pipeline / process_interface_standalone . cpp <nl> Update MongoInterfaceStandalone : : buildUpdateOp ( <nl> return updateOp ; <nl> } <nl> <nl> - void MongoInterfaceStandalone : : insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > targetEpoch ) { <nl> + Status MongoInterfaceStandalone : : insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > targetEpoch ) { <nl> auto writeResults = performInserts ( <nl> expCtx - > opCtx , buildInsertOp ( ns , std : : move ( objs ) , expCtx - > bypassDocumentValidation ) ) ; <nl> <nl> / / Need to check each result in the batch since the writes are unordered . <nl> - uassertStatusOKWithContext ( <nl> - [ & writeResults ] ( ) { <nl> - for ( const auto & result : writeResults . results ) { <nl> - if ( result . getStatus ( ) ! = Status : : OK ( ) ) { <nl> - return result . getStatus ( ) ; <nl> - } <nl> - } <nl> - return Status : : OK ( ) ; <nl> - } ( ) , <nl> - " Insert failed : " ) ; <nl> + for ( const auto & result : writeResults . results ) { <nl> + if ( result . getStatus ( ) ! = Status : : OK ( ) ) { <nl> + return result . getStatus ( ) ; <nl> + } <nl> + } <nl> + return Status : : OK ( ) ; <nl> } <nl> <nl> - WriteResult MongoInterfaceStandalone : : updateWithResult ( <nl> + StatusWith < MongoProcessInterface : : UpdateResult > MongoInterfaceStandalone : : update ( <nl> const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> const NamespaceString & ns , <nl> BatchedObjects & & batch , <nl> WriteResult MongoInterfaceStandalone : : updateWithResult ( <nl> boost : : optional < OID > targetEpoch ) { <nl> auto writeResults = <nl> performUpdates ( expCtx - > opCtx , buildUpdateOp ( expCtx , ns , std : : move ( batch ) , upsert , multi ) ) ; <nl> + <nl> / / Need to check each result in the batch since the writes are unordered . <nl> - uassertStatusOKWithContext ( <nl> - [ & writeResults ] ( ) { <nl> - for ( const auto & result : writeResults . results ) { <nl> - if ( result . getStatus ( ) ! = Status : : OK ( ) ) { <nl> - return result . getStatus ( ) ; <nl> - } <nl> - } <nl> - return Status : : OK ( ) ; <nl> - } ( ) , <nl> - " Update failed : " ) ; <nl> - <nl> - return writeResults ; <nl> - } <nl> - <nl> - void MongoInterfaceStandalone : : update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) { <nl> - [ [ maybe_unused ] ] auto writeResult = <nl> - updateWithResult ( expCtx , ns , std : : move ( batch ) , wc , upsert , multi , targetEpoch ) ; <nl> + UpdateResult updateResult ; <nl> + for ( const auto & result : writeResults . results ) { <nl> + if ( result . getStatus ( ) ! = Status : : OK ( ) ) { <nl> + return result . getStatus ( ) ; <nl> + } <nl> + <nl> + updateResult . nMatched + = result . getValue ( ) . getN ( ) ; <nl> + updateResult . nModified + = result . getValue ( ) . getNModified ( ) ; <nl> + } <nl> + return updateResult ; <nl> } <nl> <nl> CollectionIndexUsageMap MongoInterfaceStandalone : : getIndexStats ( OperationContext * opCtx , <nl> mmm a / src / mongo / db / pipeline / process_interface_standalone . h <nl> ppp b / src / mongo / db / pipeline / process_interface_standalone . h <nl> class MongoInterfaceStandalone : public MongoProcessCommon { <nl> std : : unique_ptr < TransactionHistoryIteratorBase > createTransactionHistoryIterator ( <nl> repl : : OpTime time ) const final ; <nl> bool isSharded ( OperationContext * opCtx , const NamespaceString & nss ) final ; <nl> - void insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > targetEpoch ) override ; <nl> - void update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) override ; <nl> - WriteResult updateWithResult ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) override ; <nl> + Status insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > targetEpoch ) override ; <nl> + StatusWith < UpdateResult > update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + BatchedObjects & & batch , <nl> + const WriteConcernOptions & wc , <nl> + bool upsert , <nl> + bool multi , <nl> + boost : : optional < OID > targetEpoch ) override ; <nl> <nl> CollectionIndexUsageMap getIndexStats ( OperationContext * opCtx , const NamespaceString & ns ) final ; <nl> void appendLatencyStats ( OperationContext * opCtx , <nl> mmm a / src / mongo / db / pipeline / stub_mongo_process_interface . h <nl> ppp b / src / mongo / db / pipeline / stub_mongo_process_interface . h <nl> class StubMongoProcessInterface : public MongoProcessInterface { <nl> return false ; <nl> } <nl> <nl> - void insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - std : : vector < BSONObj > & & objs , <nl> - const WriteConcernOptions & wc , <nl> - boost : : optional < OID > ) override { <nl> + Status insert ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + std : : vector < BSONObj > & & objs , <nl> + const WriteConcernOptions & wc , <nl> + boost : : optional < OID > ) override { <nl> MONGO_UNREACHABLE ; <nl> } <nl> <nl> - void update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > ) final { <nl> - MONGO_UNREACHABLE ; <nl> - } <nl> - <nl> - WriteResult updateWithResult ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> - const NamespaceString & ns , <nl> - BatchedObjects & & batch , <nl> - const WriteConcernOptions & wc , <nl> - bool upsert , <nl> - bool multi , <nl> - boost : : optional < OID > targetEpoch ) final override { <nl> + StatusWith < UpdateResult > update ( const boost : : intrusive_ptr < ExpressionContext > & expCtx , <nl> + const NamespaceString & ns , <nl> + BatchedObjects & & batch , <nl> + const WriteConcernOptions & wc , <nl> + bool upsert , <nl> + bool multi , <nl> + boost : : optional < OID > ) final { <nl> MONGO_UNREACHABLE ; <nl> } <nl> <nl>
SERVER - 41487 Fix $ merge mode whenNotMatched : fail to send updates to mongos
mongodb/mongo
fceb78e0af803b1d16b3b66ee7264d1d7f716773
2019-06-06T14:15:47Z
mmm a / javascript / i18n / phonenumbers / phonenumberutil . js <nl> ppp b / javascript / i18n / phonenumbers / phonenumberutil . js <nl> i18n . phonenumbers . PhoneNumberUtil . prototype . buildNationalNumberForParsing_ = <nl> * <nl> * @ param { i18n . phonenumbers . PhoneNumber } numberIn number that we want to copy <nl> * fields from . <nl> - * @ return { i18n . phonenumbers . PhoneNumber } number with core fields only . <nl> + * @ return { ! i18n . phonenumbers . PhoneNumber } number with core fields only . <nl> * @ private <nl> * / <nl> i18n . phonenumbers . PhoneNumberUtil . copyCoreFieldsOnly_ = function ( numberIn ) { <nl> mmm a / javascript / i18n / phonenumbers / phonenumberutil_test . js <nl> ppp b / javascript / i18n / phonenumbers / phonenumberutil_test . js <nl> goog . require ( ' i18n . phonenumbers . PhoneNumberUtil ' ) ; <nl> goog . require ( ' i18n . phonenumbers . RegionCode ' ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumberUtil } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumberUtil } * / <nl> var phoneUtil = i18n . phonenumbers . PhoneNumberUtil . getInstance ( ) ; <nl> <nl> <nl> var phoneUtil = i18n . phonenumbers . PhoneNumberUtil . getInstance ( ) ; <nl> / / TODO : Rewrite this as static functions that return new numbers each time to <nl> / / avoid any risk of accidental changes to mutable static state affecting many <nl> / / tests . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var ALPHA_NUMERIC_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> ALPHA_NUMERIC_NUMBER . setCountryCode ( 1 ) ; <nl> ALPHA_NUMERIC_NUMBER . setNationalNumber ( 80074935247 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var AE_UAN = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> AE_UAN . setCountryCode ( 971 ) ; <nl> AE_UAN . setNationalNumber ( 600123456 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var AR_MOBILE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> AR_MOBILE . setCountryCode ( 54 ) ; <nl> AR_MOBILE . setNationalNumber ( 91187654321 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var AR_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> AR_NUMBER . setCountryCode ( 54 ) ; <nl> AR_NUMBER . setNationalNumber ( 1187654321 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var AU_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> AU_NUMBER . setCountryCode ( 61 ) ; <nl> AU_NUMBER . setNationalNumber ( 236618300 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var BS_MOBILE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> BS_MOBILE . setCountryCode ( 1 ) ; <nl> BS_MOBILE . setNationalNumber ( 2423570000 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var BS_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> BS_NUMBER . setCountryCode ( 1 ) ; <nl> BS_NUMBER . setNationalNumber ( 2423651234 ) ; <nl> <nl> <nl> / / Note that this is the same as the example number for DE in the metadata . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var DE_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> DE_NUMBER . setCountryCode ( 49 ) ; <nl> DE_NUMBER . setNationalNumber ( 30123456 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var DE_SHORT_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> DE_SHORT_NUMBER . setCountryCode ( 49 ) ; <nl> DE_SHORT_NUMBER . setNationalNumber ( 1234 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var GB_MOBILE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> GB_MOBILE . setCountryCode ( 44 ) ; <nl> GB_MOBILE . setNationalNumber ( 7912345678 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var GB_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> GB_NUMBER . setCountryCode ( 44 ) ; <nl> GB_NUMBER . setNationalNumber ( 2070313000 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var IT_MOBILE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> IT_MOBILE . setCountryCode ( 39 ) ; <nl> IT_MOBILE . setNationalNumber ( 345678901 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var IT_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> IT_NUMBER . setCountryCode ( 39 ) ; <nl> IT_NUMBER . setNationalNumber ( 236618300 ) ; <nl> IT_NUMBER . setItalianLeadingZero ( true ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var JP_STAR_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> JP_STAR_NUMBER . setCountryCode ( 81 ) ; <nl> JP_STAR_NUMBER . setNationalNumber ( 2345 ) ; <nl> <nl> <nl> / / Numbers to test the formatting rules from Mexico . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var MX_MOBILE1 = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> MX_MOBILE1 . setCountryCode ( 52 ) ; <nl> MX_MOBILE1 . setNationalNumber ( 12345678900 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var MX_MOBILE2 = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> MX_MOBILE2 . setCountryCode ( 52 ) ; <nl> MX_MOBILE2 . setNationalNumber ( 15512345678 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var MX_NUMBER1 = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> MX_NUMBER1 . setCountryCode ( 52 ) ; <nl> MX_NUMBER1 . setNationalNumber ( 3312345678 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var MX_NUMBER2 = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> MX_NUMBER2 . setCountryCode ( 52 ) ; <nl> MX_NUMBER2 . setNationalNumber ( 8211234567 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var NZ_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> NZ_NUMBER . setCountryCode ( 64 ) ; <nl> NZ_NUMBER . setNationalNumber ( 33316005 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var SG_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> SG_NUMBER . setCountryCode ( 65 ) ; <nl> SG_NUMBER . setNationalNumber ( 65218000 ) ; <nl> <nl> <nl> / / A too - long and hence invalid US number . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_LONG_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_LONG_NUMBER . setCountryCode ( 1 ) ; <nl> US_LONG_NUMBER . setNationalNumber ( 65025300001 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_NUMBER . setCountryCode ( 1 ) ; <nl> US_NUMBER . setNationalNumber ( 6502530000 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_PREMIUM = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_PREMIUM . setCountryCode ( 1 ) ; <nl> US_PREMIUM . setNationalNumber ( 9002530000 ) ; <nl> <nl> <nl> / / Too short , but still possible US numbers . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_LOCAL_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_LOCAL_NUMBER . setCountryCode ( 1 ) ; <nl> US_LOCAL_NUMBER . setNationalNumber ( 2530000 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_SHORT_BY_ONE_NUMBER = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_SHORT_BY_ONE_NUMBER . setCountryCode ( 1 ) ; <nl> US_SHORT_BY_ONE_NUMBER . setNationalNumber ( 650253000 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_TOLLFREE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_TOLLFREE . setCountryCode ( 1 ) ; <nl> US_TOLLFREE . setNationalNumber ( 8002530000 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_SPOOF = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_SPOOF . setCountryCode ( 1 ) ; <nl> US_SPOOF . setNationalNumber ( 0 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var US_SPOOF_WITH_RAW_INPUT = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> US_SPOOF_WITH_RAW_INPUT . setCountryCode ( 1 ) ; <nl> US_SPOOF_WITH_RAW_INPUT . setNationalNumber ( 0 ) ; <nl> US_SPOOF_WITH_RAW_INPUT . setRawInput ( ' 000 - 000 - 0000 ' ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var UZ_FIXED_LINE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> UZ_FIXED_LINE . setCountryCode ( 998 ) ; <nl> UZ_FIXED_LINE . setNationalNumber ( 612201234 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var UZ_MOBILE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> UZ_MOBILE . setCountryCode ( 998 ) ; <nl> UZ_MOBILE . setNationalNumber ( 950123456 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var INTERNATIONAL_TOLL_FREE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> INTERNATIONAL_TOLL_FREE . setCountryCode ( 800 ) ; <nl> INTERNATIONAL_TOLL_FREE . setNationalNumber ( 12345678 ) ; <nl> INTERNATIONAL_TOLL_FREE . setNationalNumber ( 12345678 ) ; <nl> / / We set this to be the same length as numbers for the other non - geographical <nl> / / country prefix that we have in our test metadata . However , this is not <nl> / / considered valid because they differ in their country calling code . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var INTERNATIONAL_TOLL_FREE_TOO_LONG = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> INTERNATIONAL_TOLL_FREE_TOO_LONG . setCountryCode ( 800 ) ; <nl> INTERNATIONAL_TOLL_FREE_TOO_LONG . setNationalNumber ( 123456789 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var UNIVERSAL_PREMIUM_RATE = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> UNIVERSAL_PREMIUM_RATE . setCountryCode ( 979 ) ; <nl> UNIVERSAL_PREMIUM_RATE . setNationalNumber ( 123456789 ) ; <nl> <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT . setCountryCode ( 2 ) ; <nl> UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT . setNationalNumber ( 12345 ) ; <nl> function testGetLengthOfNationalDestinationCode ( ) { <nl> <nl> / / A number containing an invalid country calling code , which shouldn ' t have <nl> / / any NDC . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> number . setCountryCode ( 123 ) ; <nl> number . setNationalNumber ( 6502530000 ) ; <nl> function testGetNationalSignificantNumber ( ) { <nl> phoneUtil . getNationalSignificantNumber ( INTERNATIONAL_TOLL_FREE ) ) ; <nl> <nl> / / An empty number . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var emptyNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> assertEquals ( ' ' , phoneUtil . getNationalSignificantNumber ( emptyNumber ) ) ; <nl> } <nl> <nl> function testGetNationalSignificantNumber_ManyLeadingZeros ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> number . setCountryCode ( 1 ) ; <nl> number . setNationalNumber ( 650 ) ; <nl> function testFormatGBNumber ( ) { <nl> <nl> function testFormatDENumber ( ) { <nl> var PNF = i18n . phonenumbers . PhoneNumberFormat ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var deNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> deNumber . setCountryCode ( 49 ) ; <nl> deNumber . setNationalNumber ( 301234 ) ; <nl> function testFormatAUNumber ( ) { <nl> assertEquals ( ' + 61236618300 ' , <nl> phoneUtil . format ( AU_NUMBER , PNF . E164 ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var auNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> auNumber . setCountryCode ( 61 ) ; <nl> auNumber . setNationalNumber ( 1800123456 ) ; <nl> function testFormatOutOfCountryCallingNumber ( ) { <nl> phoneUtil . formatOutOfCountryCallingNumber ( INTERNATIONAL_TOLL_FREE , <nl> RegionCode . US ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var arNumberWithExtn = AR_MOBILE . clone ( ) ; <nl> arNumberWithExtn . setExtension ( ' 1234 ' ) ; <nl> assertEquals ( ' 011 54 9 11 8765 4321 ext . 1234 ' , <nl> function testFormatOutOfCountryWithPreferredIntlPrefix ( ) { <nl> } <nl> <nl> function testFormatOutOfCountryKeepingAlphaChars ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var alphaNumericNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> alphaNumericNumber . setCountryCode ( 1 ) ; <nl> alphaNumericNumber . setNationalNumber ( 8007493524 ) ; <nl> function testFormatWithCarrierCode ( ) { <nl> var PNF = i18n . phonenumbers . PhoneNumberFormat ; <nl> / / We only support this for AR in our test metadata , and only for mobile <nl> / / numbers starting with certain values . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var arMobile = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> arMobile . setCountryCode ( 54 ) ; <nl> arMobile . setNationalNumber ( 92234654321 ) ; <nl> function testFormatWithCarrierCode ( ) { <nl> function testFormatWithPreferredCarrierCode ( ) { <nl> var PNF = i18n . phonenumbers . PhoneNumberFormat ; <nl> / / We only support this for AR in our test metadata . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var arNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> arNumber . setCountryCode ( 54 ) ; <nl> arNumber . setNationalNumber ( 91234125678 ) ; <nl> function testFormatWithPreferredCarrierCode ( ) { <nl> assertEquals ( ' 01234 15 12 - 5678 ' , <nl> phoneUtil . formatNationalNumberWithPreferredCarrierCode ( arNumber , ' 15 ' ) ) ; <nl> / / We don ' t support this for the US so there should be no change . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var usNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> usNumber . setCountryCode ( 1 ) ; <nl> usNumber . setNationalNumber ( 4241231234 ) ; <nl> function testFormatNumberForMobileDialing ( ) { <nl> phoneUtil . formatNumberForMobileDialing ( US_TOLLFREE , RegionCode . CN , true ) ) ; <nl> assertEquals ( ' + 1 650 253 0000 ' , <nl> phoneUtil . formatNumberForMobileDialing ( US_NUMBER , RegionCode . US , true ) ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var usNumberWithExtn = US_NUMBER . clone ( ) ; <nl> usNumberWithExtn . setExtension ( ' 1234 ' ) ; <nl> assertEquals ( ' + 1 650 253 0000 ' , <nl> function testFormatNumberForMobileDialing ( ) { <nl> <nl> function testFormatByPattern ( ) { <nl> var PNF = i18n . phonenumbers . PhoneNumberFormat ; <nl> - / * * @ type { i18n . phonenumbers . NumberFormat } * / <nl> + / * * @ type { ! i18n . phonenumbers . NumberFormat } * / <nl> var newNumFormat = new i18n . phonenumbers . NumberFormat ( ) ; <nl> newNumFormat . setPattern ( ' ( \ \ d { 3 } ) ( \ \ d { 3 } ) ( \ \ d { 4 } ) ' ) ; <nl> newNumFormat . setFormat ( ' ( $ 1 ) $ 2 - $ 3 ' ) ; <nl> function testFormatE164Number ( ) { <nl> <nl> function testFormatNumberWithExtension ( ) { <nl> var PNF = i18n . phonenumbers . PhoneNumberFormat ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumber = NZ_NUMBER . clone ( ) ; <nl> nzNumber . setExtension ( ' 1234 ' ) ; <nl> / / Uses default extension prefix : <nl> function testFormatNumberWithExtension ( ) { <nl> assertEquals ( ' tel : + 64 - 3 - 331 - 6005 ; ext = 1234 ' , <nl> phoneUtil . format ( nzNumber , PNF . RFC3966 ) ) ; <nl> / / Extension prefix overridden in the territory information for the US : <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var usNumberWithExtension = US_NUMBER . clone ( ) ; <nl> usNumberWithExtension . setExtension ( ' 4567 ' ) ; <nl> assertEquals ( ' 650 253 0000 extn . 4567 ' , <nl> function testFormatNumberWithExtension ( ) { <nl> } <nl> <nl> function testFormatInOriginalFormat ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number1 = phoneUtil . parseAndKeepRawInput ( ' + 442087654321 ' , RegionCode . GB ) ; <nl> assertEquals ( ' + 44 20 8765 4321 ' , <nl> phoneUtil . formatInOriginalFormat ( number1 , RegionCode . GB ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number2 = phoneUtil . parseAndKeepRawInput ( ' 02087654321 ' , RegionCode . GB ) ; <nl> assertEquals ( ' ( 020 ) 8765 4321 ' , <nl> phoneUtil . formatInOriginalFormat ( number2 , RegionCode . GB ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number3 = phoneUtil . parseAndKeepRawInput ( ' 011442087654321 ' , <nl> RegionCode . US ) ; <nl> assertEquals ( ' 011 44 20 8765 4321 ' , <nl> phoneUtil . formatInOriginalFormat ( number3 , RegionCode . US ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number4 = phoneUtil . parseAndKeepRawInput ( ' 442087654321 ' , RegionCode . GB ) ; <nl> assertEquals ( ' 44 20 8765 4321 ' , <nl> phoneUtil . formatInOriginalFormat ( number4 , RegionCode . GB ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number5 = phoneUtil . parse ( ' + 442087654321 ' , RegionCode . GB ) ; <nl> assertEquals ( ' ( 020 ) 8765 4321 ' , <nl> phoneUtil . formatInOriginalFormat ( number5 , RegionCode . GB ) ) ; <nl> function testFormatInOriginalFormat ( ) { <nl> / / Invalid numbers that we have a formatting pattern for should be formatted <nl> / / properly . Note area codes starting with 7 are intentionally excluded in <nl> / / the test metadata for testing purposes . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number6 = phoneUtil . parseAndKeepRawInput ( ' 7345678901 ' , RegionCode . US ) ; <nl> assertEquals ( ' 734 567 8901 ' , <nl> phoneUtil . formatInOriginalFormat ( number6 , RegionCode . US ) ) ; <nl> <nl> / / US is not a leading zero country , and the presence of the leading zero <nl> / / leads us to format the number using raw_input . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number7 = phoneUtil . parseAndKeepRawInput ( ' 0734567 8901 ' , RegionCode . US ) ; <nl> assertEquals ( ' 0734567 8901 ' , <nl> phoneUtil . formatInOriginalFormat ( number7 , RegionCode . US ) ) ; <nl> <nl> / / This number is valid , but we don ' t have a formatting pattern for it . <nl> / / Fall back to the raw input . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number8 = phoneUtil . parseAndKeepRawInput ( ' 02 - 4567 - 8900 ' , RegionCode . KR ) ; <nl> assertEquals ( ' 02 - 4567 - 8900 ' , <nl> phoneUtil . formatInOriginalFormat ( number8 , RegionCode . KR ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number9 = phoneUtil . parseAndKeepRawInput ( ' 01180012345678 ' , RegionCode . US ) ; <nl> assertEquals ( ' 011 800 1234 5678 ' , <nl> phoneUtil . formatInOriginalFormat ( number9 , RegionCode . US ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number10 = phoneUtil . parseAndKeepRawInput ( ' + 80012345678 ' , RegionCode . KR ) ; <nl> assertEquals ( ' + 800 1234 5678 ' , <nl> phoneUtil . formatInOriginalFormat ( number10 , RegionCode . KR ) ) ; <nl> <nl> / / US local numbers are formatted correctly , as we have formatting patterns <nl> / / for them . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var localNumberUS = phoneUtil . parseAndKeepRawInput ( ' 2530000 ' , RegionCode . US ) ; <nl> assertEquals ( ' 253 0000 ' , <nl> phoneUtil . formatInOriginalFormat ( localNumberUS , RegionCode . US ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithNationalPrefixUS = <nl> phoneUtil . parseAndKeepRawInput ( ' 18003456789 ' , RegionCode . US ) ; <nl> assertEquals ( ' 1 800 345 6789 ' , <nl> phoneUtil . formatInOriginalFormat ( numberWithNationalPrefixUS , <nl> RegionCode . US ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithoutNationalPrefixGB = <nl> phoneUtil . parseAndKeepRawInput ( ' 2087654321 ' , RegionCode . GB ) ; <nl> assertEquals ( ' 20 8765 4321 ' , <nl> function testFormatInOriginalFormat ( ) { <nl> assertEquals ( ' ( 020 ) 8765 4321 ' , <nl> phoneUtil . formatInOriginalFormat ( number5 , RegionCode . GB ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithNationalPrefixMX = <nl> phoneUtil . parseAndKeepRawInput ( ' 013312345678 ' , RegionCode . MX ) ; <nl> assertEquals ( ' 01 33 1234 5678 ' , <nl> phoneUtil . formatInOriginalFormat ( numberWithNationalPrefixMX , <nl> RegionCode . MX ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithoutNationalPrefixMX = <nl> phoneUtil . parseAndKeepRawInput ( ' 3312345678 ' , RegionCode . MX ) ; <nl> assertEquals ( ' 33 1234 5678 ' , <nl> phoneUtil . formatInOriginalFormat ( numberWithoutNationalPrefixMX , <nl> RegionCode . MX ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var italianFixedLineNumber = <nl> phoneUtil . parseAndKeepRawInput ( ' 0212345678 ' , RegionCode . IT ) ; <nl> assertEquals ( ' 02 1234 5678 ' , <nl> phoneUtil . formatInOriginalFormat ( italianFixedLineNumber , RegionCode . IT ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithNationalPrefixJP = <nl> phoneUtil . parseAndKeepRawInput ( ' 00777012 ' , RegionCode . JP ) ; <nl> assertEquals ( ' 0077 - 7012 ' , <nl> phoneUtil . formatInOriginalFormat ( numberWithNationalPrefixJP , <nl> RegionCode . JP ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithoutNationalPrefixJP = <nl> phoneUtil . parseAndKeepRawInput ( ' 0777012 ' , RegionCode . JP ) ; <nl> assertEquals ( ' 0777012 ' , <nl> phoneUtil . formatInOriginalFormat ( numberWithoutNationalPrefixJP , <nl> RegionCode . JP ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithCarrierCodeBR = <nl> phoneUtil . parseAndKeepRawInput ( ' 012 3121286979 ' , RegionCode . BR ) ; <nl> assertEquals ( ' 012 3121286979 ' , <nl> function testFormatInOriginalFormat ( ) { <nl> / / The default national prefix used in this case is 045 . When a number with <nl> / / national prefix 044 is entered , we return the raw input as we don ' t want to <nl> / / change the number entered . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithNationalPrefixMX1 = <nl> phoneUtil . parseAndKeepRawInput ( ' 044 ( 33 ) 1234 - 5678 ' , RegionCode . MX ) ; <nl> assertEquals ( ' 044 ( 33 ) 1234 - 5678 ' , <nl> phoneUtil . formatInOriginalFormat ( numberWithNationalPrefixMX1 , <nl> RegionCode . MX ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithNationalPrefixMX2 = <nl> phoneUtil . parseAndKeepRawInput ( ' 045 ( 33 ) 1234 - 5678 ' , RegionCode . MX ) ; <nl> assertEquals ( ' 045 33 1234 5678 ' , <nl> function testFormatInOriginalFormat ( ) { <nl> / / The default international prefix used in this case is 0011 . When a number <nl> / / with international prefix 0012 is entered , we return the raw input as we <nl> / / don ' t want to change the number entered . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var outOfCountryNumberFromAU1 = <nl> phoneUtil . parseAndKeepRawInput ( ' 0012 16502530000 ' , RegionCode . AU ) ; <nl> assertEquals ( ' 0012 16502530000 ' , <nl> phoneUtil . formatInOriginalFormat ( outOfCountryNumberFromAU1 , <nl> RegionCode . AU ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var outOfCountryNumberFromAU2 = <nl> phoneUtil . parseAndKeepRawInput ( ' 0011 16502530000 ' , RegionCode . AU ) ; <nl> assertEquals ( ' 0011 1 650 253 0000 ' , <nl> function testFormatInOriginalFormat ( ) { <nl> <nl> / / Test the star sign is not removed from or added to the original input by <nl> / / this method . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var starNumber = <nl> phoneUtil . parseAndKeepRawInput ( ' * 1234 ' , RegionCode . JP ) ; <nl> assertEquals ( ' * 1234 ' , phoneUtil . formatInOriginalFormat ( starNumber , <nl> RegionCode . JP ) ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithoutStar = phoneUtil . parseAndKeepRawInput ( ' 1234 ' , RegionCode . JP ) ; <nl> assertEquals ( ' 1234 ' , phoneUtil . formatInOriginalFormat ( numberWithoutStar , <nl> RegionCode . JP ) ) ; <nl> function testIsPremiumRate ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> assertEquals ( PNT . PREMIUM_RATE , phoneUtil . getNumberType ( US_PREMIUM ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var premiumRateNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> premiumRateNumber . setCountryCode ( 39 ) ; <nl> premiumRateNumber . setNationalNumber ( 892123 ) ; <nl> function testIsPremiumRate ( ) { <nl> <nl> function testIsTollFree ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var tollFreeNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> <nl> tollFreeNumber . setCountryCode ( 1 ) ; <nl> function testIsMobile ( ) { <nl> assertEquals ( PNT . MOBILE , phoneUtil . getNumberType ( IT_MOBILE ) ) ; <nl> assertEquals ( PNT . MOBILE , phoneUtil . getNumberType ( AR_MOBILE ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var mobileNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> mobileNumber . setCountryCode ( 49 ) ; <nl> mobileNumber . setNationalNumber ( 15123456789 ) ; <nl> function testIsFixedLineAndMobile ( ) { <nl> assertEquals ( PNT . FIXED_LINE_OR_MOBILE , <nl> phoneUtil . getNumberType ( US_NUMBER ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var fixedLineAndMobileNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> fixedLineAndMobileNumber . setCountryCode ( 54 ) ; <nl> fixedLineAndMobileNumber . setNationalNumber ( 1987654321 ) ; <nl> function testIsFixedLineAndMobile ( ) { <nl> <nl> function testIsSharedCost ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var gbNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> gbNumber . setCountryCode ( 44 ) ; <nl> gbNumber . setNationalNumber ( 8431231234 ) ; <nl> function testIsSharedCost ( ) { <nl> <nl> function testIsVoip ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var gbNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> gbNumber . setCountryCode ( 44 ) ; <nl> gbNumber . setNationalNumber ( 5631231234 ) ; <nl> function testIsVoip ( ) { <nl> <nl> function testIsPersonalNumber ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var gbNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> gbNumber . setCountryCode ( 44 ) ; <nl> gbNumber . setNationalNumber ( 7031231234 ) ; <nl> function testIsValidNumber ( ) { <nl> assertTrue ( phoneUtil . isValidNumber ( INTERNATIONAL_TOLL_FREE ) ) ; <nl> assertTrue ( phoneUtil . isValidNumber ( UNIVERSAL_PREMIUM_RATE ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> nzNumber . setCountryCode ( 64 ) ; <nl> nzNumber . setNationalNumber ( 21387835 ) ; <nl> function testIsValidForRegion ( ) { <nl> assertTrue ( phoneUtil . isValidNumber ( BS_NUMBER ) ) ; <nl> assertTrue ( phoneUtil . isValidNumberForRegion ( BS_NUMBER , RegionCode . BS ) ) ; <nl> assertFalse ( phoneUtil . isValidNumberForRegion ( BS_NUMBER , RegionCode . US ) ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var bsInvalidNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> bsInvalidNumber . setCountryCode ( 1 ) ; <nl> bsInvalidNumber . setNationalNumber ( 2421232345 ) ; <nl> function testIsValidForRegion ( ) { <nl> assertFalse ( phoneUtil . isValidNumber ( bsInvalidNumber ) ) ; <nl> <nl> / / La Mayotte and Reunion use ' leadingDigits ' to differentiate them . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var reNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> reNumber . setCountryCode ( 262 ) ; <nl> reNumber . setNationalNumber ( 262123456 ) ; <nl> function testIsValidForRegion ( ) { <nl> assertFalse ( phoneUtil . isValidNumberForRegion ( INTERNATIONAL_TOLL_FREE , <nl> RegionCode . ZZ ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var invalidNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / Invalid country calling codes . <nl> invalidNumber . setCountryCode ( 3923 ) ; <nl> function testIsValidForRegion ( ) { <nl> function testIsNotValidNumber ( ) { <nl> assertFalse ( phoneUtil . isValidNumber ( US_LOCAL_NUMBER ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var invalidNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> invalidNumber . setCountryCode ( 39 ) ; <nl> invalidNumber . setNationalNumber ( 23661830000 ) ; <nl> function testGetRegionCodeForNumber ( ) { <nl> } <nl> <nl> function testGetRegionCodesForCountryCode ( ) { <nl> - / * * @ type { Array . < string > } * / <nl> + / * * @ type { ! Array . < string > } * / <nl> var regionCodesForNANPA = phoneUtil . getRegionCodesForCountryCode ( 1 ) ; <nl> assertTrue ( goog . array . contains ( regionCodesForNANPA , RegionCode . US ) ) ; <nl> assertTrue ( goog . array . contains ( regionCodesForNANPA , RegionCode . BS ) ) ; <nl> function testIsPossibleNumberForType_DifferentTypeLengths ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> / / We use Argentinian numbers since they have different possible lengths for <nl> / / different types . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> number . setCountryCode ( 54 ) ; <nl> number . setNationalNumber ( 12345 ) ; <nl> function testIsPossibleNumberForType_DifferentTypeLengths ( ) { <nl> <nl> function testIsPossibleNumberForType_LocalOnly ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / Here we test a number length which matches a local - only length . <nl> number . setCountryCode ( 49 ) ; <nl> function testIsPossibleNumberForType_LocalOnly ( ) { <nl> <nl> function testIsPossibleNumberForType_DataMissingForSizeReasons ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / Here we test something where the possible lengths match the possible <nl> / / lengths of the country as a whole , and hence aren ' t present in the . js file <nl> function testIsPossibleNumberForType_DataMissingForSizeReasons ( ) { <nl> <nl> function testIsPossibleNumberForType_NumberTypeNotSupportedForRegion ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / There are * no * mobile numbers for this region at all , so we return false . <nl> number . setCountryCode ( 55 ) ; <nl> function testIsPossibleNumberWithReason ( ) { <nl> assertEquals ( VR . TOO_LONG , <nl> phoneUtil . isPossibleNumberWithReason ( US_LONG_NUMBER ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> number . setCountryCode ( 0 ) ; <nl> number . setNationalNumber ( 2530000 ) ; <nl> function testIsPossibleNumberWithReason ( ) { <nl> function testIsPossibleNumberForTypeWithReason_DifferentTypeLengths ( ) { <nl> var VR = i18n . phonenumbers . PhoneNumberUtil . ValidationResult ; <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / We use Argentinian numbers since they have different possible lengths for <nl> / / different types . <nl> function testIsPossibleNumberForTypeWithReason_DifferentTypeLengths ( ) { <nl> function testIsPossibleNumberForTypeWithReason_LocalOnly ( ) { <nl> var VR = i18n . phonenumbers . PhoneNumberUtil . ValidationResult ; <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / Here we test a number length which matches a local - only length . <nl> number . setCountryCode ( 49 ) ; <nl> function testIsPossibleNumberForTypeWithReason_LocalOnly ( ) { <nl> function testIsPossibleNumberForTypeWithReason_DataMissingForSizeReasons ( ) { <nl> var VR = i18n . phonenumbers . PhoneNumberUtil . ValidationResult ; <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / Here we test something where the possible lengths match the possible <nl> / / lengths of the country as a whole , and hence aren ' t present in the binary <nl> function testIsPossibleNumberForTypeWithReason_DataMissingForSizeReasons ( ) { <nl> function testIsPossibleNumberForTypeWithReason_NumberTypeNotSupportedForRegion ( ) { <nl> var VR = i18n . phonenumbers . PhoneNumberUtil . ValidationResult ; <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / There are * no * mobile numbers for this region at all , so we return <nl> / / INVALID_LENGTH . <nl> function testIsPossibleNumberForTypeWithReason_NumberTypeNotSupportedForRegion ( ) <nl> function testIsPossibleNumberForTypeWithReason_FixedLineOrMobile ( ) { <nl> var VR = i18n . phonenumbers . PhoneNumberUtil . ValidationResult ; <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / For FIXED_LINE_OR_MOBILE , a number should be considered valid if it matches <nl> / / the possible lengths for mobile * or * fixed - line numbers . <nl> function testIsNotPossibleNumber ( ) { <nl> assertFalse ( phoneUtil . isPossibleNumber ( US_LONG_NUMBER ) ) ; <nl> assertFalse ( phoneUtil . isPossibleNumber ( INTERNATIONAL_TOLL_FREE_TOO_LONG ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> number . setCountryCode ( 1 ) ; <nl> number . setNationalNumber ( 253000 ) ; <nl> function testIsNotPossibleNumber ( ) { <nl> <nl> function testTruncateTooLongNumber ( ) { <nl> / / GB number 080 1234 5678 , but entered with 4 extra digits at the end . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var tooLongNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> tooLongNumber . setCountryCode ( 44 ) ; <nl> tooLongNumber . setNationalNumber ( 80123456780123 ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var validNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> validNumber . setCountryCode ( 44 ) ; <nl> validNumber . setNationalNumber ( 8012345678 ) ; <nl> function testTruncateTooLongNumber ( ) { <nl> assertTrue ( INTERNATIONAL_TOLL_FREE . equals ( tooLongNumber ) ) ; <nl> <nl> / / Tests what happens when a valid number is passed in . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var validNumberCopy = validNumber . clone ( ) ; <nl> assertTrue ( phoneUtil . truncateTooLongNumber ( validNumber ) ) ; <nl> / / Tests the number is not modified . <nl> assertTrue ( validNumber . equals ( validNumberCopy ) ) ; <nl> <nl> / / Tests what happens when a number with invalid prefix is passed in . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var numberWithInvalidPrefix = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / The test metadata says US numbers cannot have prefix 240 . <nl> numberWithInvalidPrefix . setCountryCode ( 1 ) ; <nl> numberWithInvalidPrefix . setNationalNumber ( 2401234567 ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var invalidNumberCopy = numberWithInvalidPrefix . clone ( ) ; <nl> assertFalse ( phoneUtil . truncateTooLongNumber ( numberWithInvalidPrefix ) ) ; <nl> / / Tests the number is not modified . <nl> assertTrue ( numberWithInvalidPrefix . equals ( invalidNumberCopy ) ) ; <nl> <nl> / / Tests what happens when a too short number is passed in . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var tooShortNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> tooShortNumber . setCountryCode ( 1 ) ; <nl> tooShortNumber . setNationalNumber ( 1234 ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var tooShortNumberCopy = tooShortNumber . clone ( ) ; <nl> assertFalse ( phoneUtil . truncateTooLongNumber ( tooShortNumber ) ) ; <nl> / / Tests the number is not modified . <nl> function testExtractPossibleNumber ( ) { <nl> } <nl> <nl> function testMaybeStripNationalPrefix ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneMetadata } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneMetadata } * / <nl> var metadata = new i18n . phonenumbers . PhoneMetadata ( ) ; <nl> metadata . setNationalPrefixForParsing ( ' 34 ' ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumberDesc } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumberDesc } * / <nl> var generalDesc = new i18n . phonenumbers . PhoneNumberDesc ( ) ; <nl> generalDesc . setNationalNumberPattern ( ' \ \ d { 4 , 8 } ' ) ; <nl> metadata . setGeneralDesc ( generalDesc ) ; <nl> function testMaybeStripInternationalPrefix ( ) { <nl> <nl> function testMaybeExtractCountryCode ( ) { <nl> var CCS = i18n . phonenumbers . PhoneNumber . CountryCodeSource ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var number = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / * * @ type { i18n . phonenumbers . PhoneMetadata } * / <nl> var metadata = phoneUtil . getMetadataForRegion ( RegionCode . US ) ; <nl> function testParseNationalNumber ( ) { <nl> phoneUtil . parse ( ' tel : 2530000 ; isub = 12345 ; phone - context = 1234 . com ' , <nl> RegionCode . US ) ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> nzNumber . setCountryCode ( 64 ) ; <nl> nzNumber . setNationalNumber ( 64123456 ) ; <nl> function testParseNationalNumber ( ) { <nl> / / Check that using a ' / ' is fine in a phone number . <nl> assertTrue ( DE_NUMBER . equals ( phoneUtil . parse ( ' 301 / 23456 ' , RegionCode . DE ) ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var usNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> / / Check it doesn ' t use the ' 1 ' as a country calling code when parsing if the <nl> / / phone number was already possible . <nl> function testParseNationalNumber ( ) { <nl> assertTrue ( <nl> JP_STAR_NUMBER . equals ( phoneUtil . parse ( ' + 81 * 2345 ' , RegionCode . JP ) ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var shortNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> shortNumber . setCountryCode ( 64 ) ; <nl> shortNumber . setNationalNumber ( 12 ) ; <nl> function testParseNationalNumber ( ) { <nl> <nl> function testParseNumberWithAlphaCharacters ( ) { <nl> / / Test case with alpha characters . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var tollfreeNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> tollfreeNumber . setCountryCode ( 64 ) ; <nl> tollfreeNumber . setNationalNumber ( 800332005 ) ; <nl> assertTrue ( tollfreeNumber . equals ( <nl> phoneUtil . parse ( ' 0800 DDA 005 ' , RegionCode . NZ ) ) ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var premiumNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> premiumNumber . setCountryCode ( 64 ) ; <nl> premiumNumber . setNationalNumber ( 9003326005 ) ; <nl> function testParseWithLeadingZero ( ) { <nl> <nl> function testParseNationalNumberArgentina ( ) { <nl> / / Test parsing mobile numbers of Argentina . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var arNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> arNumber . setCountryCode ( 54 ) ; <nl> arNumber . setNationalNumber ( 93435551212 ) ; <nl> function testParseWithXInNumber ( ) { <nl> AR_NUMBER . equals ( phoneUtil . parse ( ' 0 1187654321 ' , RegionCode . AR ) ) ) ; <nl> assertTrue ( <nl> AR_NUMBER . equals ( phoneUtil . parse ( ' ( 0xx ) 1187654321 ' , RegionCode . AR ) ) ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var arFromUs = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> arFromUs . setCountryCode ( 54 ) ; <nl> arFromUs . setNationalNumber ( 81429712 ) ; <nl> function testParseWithXInNumber ( ) { <nl> <nl> function testParseNumbersMexico ( ) { <nl> / / Test parsing fixed - line numbers of Mexico . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var mxNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> mxNumber . setCountryCode ( 52 ) ; <nl> mxNumber . setNationalNumber ( 4499780001 ) ; <nl> function testParseNumbersWithPlusWithNoRegion ( ) { <nl> phoneUtil . parse ( ' tel : 03 - 331 - 6005 ; isub = 12345 ; phone - context = + 64 ' , <nl> RegionCode . ZZ ) ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberWithRawInput = NZ_NUMBER . clone ( ) ; <nl> nzNumberWithRawInput . setRawInput ( ' + 64 3 331 6005 ' ) ; <nl> nzNumberWithRawInput . setCountryCodeSource ( i18n . phonenumbers . PhoneNumber <nl> function testParseNumberTooShortIfNationalPrefixStripped ( ) { <nl> / / Test that a number whose first digits happen to coincide with the national <nl> / / prefix does not get them stripped if doing so would result in a number too <nl> / / short to be a possible ( regular length ) phone number for that region . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var byNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> byNumber . setCountryCode ( 375 ) ; <nl> byNumber . setNationalNumber ( 8123 ) ; <nl> function testParseNumberTooShortIfNationalPrefixStripped ( ) { <nl> } <nl> <nl> function testParseExtensions ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> nzNumber . setCountryCode ( 64 ) ; <nl> nzNumber . setNationalNumber ( 33316005 ) ; <nl> function testParseExtensions ( ) { <nl> phoneUtil . parse ( ' ( 1800 ) 7493 . 5247 ' , RegionCode . US ) ) ) ; <nl> <nl> / / Check that the last instance of an extension token is matched . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var extnNumber = ALPHA_NUMERIC_NUMBER . clone ( ) ; <nl> extnNumber . setExtension ( ' 1234 ' ) ; <nl> assertTrue ( extnNumber . equals ( <nl> function testParseExtensions ( ) { <nl> / / Verifying bug - fix where the last digit of a number was previously omitted <nl> / / if it was a 0 when extracting the extension . Also verifying a few different <nl> / / cases of extensions . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var ukNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> ukNumber . setCountryCode ( 44 ) ; <nl> ukNumber . setNationalNumber ( 2034567890 ) ; <nl> function testParseExtensions ( ) { <nl> assertTrue ( ukNumber . equals ( <nl> phoneUtil . parse ( ' + 442034567890 \ uFF58 \ uFF54456 ' , RegionCode . GB ) ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var usWithExtension = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> usWithExtension . setCountryCode ( 1 ) ; <nl> usWithExtension . setNationalNumber ( 8009013355 ) ; <nl> function testParseExtensions ( ) { <nl> phoneUtil . parse ( ' 8 ( 423 ) 202 - 25 - 11 \ u0414 \ u041E \ u0411100 ' , RegionCode . RU ) ) ) ; <nl> <nl> / / Test that if a number has two extensions specified , we ignore the second . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var usWithTwoExtensionsNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> usWithTwoExtensionsNumber . setCountryCode ( 1 ) ; <nl> usWithTwoExtensionsNumber . setNationalNumber ( 2121231234 ) ; <nl> function testParseExtensions ( ) { <nl> <nl> function testParseAndKeepRaw ( ) { <nl> var CCS = i18n . phonenumbers . PhoneNumber . CountryCodeSource ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var alphaNumericNumber = ALPHA_NUMERIC_NUMBER . clone ( ) ; <nl> alphaNumericNumber . setRawInput ( ' 800 six - flags ' ) ; <nl> alphaNumericNumber . setCountryCodeSource ( CCS . FROM_DEFAULT_COUNTRY ) ; <nl> assertTrue ( alphaNumericNumber . equals ( <nl> phoneUtil . parseAndKeepRawInput ( ' 800 six - flags ' , RegionCode . US ) ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var shorterAlphaNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> shorterAlphaNumber . setCountryCode ( 1 ) ; <nl> shorterAlphaNumber . setNationalNumber ( 8007493524 ) ; <nl> function testParseAndKeepRaw ( ) { <nl> e . message ) ; <nl> } <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var koreanNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> koreanNumber . setCountryCode ( 82 ) ; <nl> koreanNumber . setNationalNumber ( 22123456 ) ; <nl> function testParseAndKeepRaw ( ) { <nl> <nl> function testParseItalianLeadingZeros ( ) { <nl> / / Test the number " 011 " . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var oneZero = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> oneZero . setCountryCode ( 61 ) ; <nl> oneZero . setNationalNumber ( 11 ) ; <nl> function testParseItalianLeadingZeros ( ) { <nl> assertTrue ( oneZero . equals ( phoneUtil . parse ( ' 011 ' , RegionCode . AU ) ) ) ; <nl> <nl> / / Test the number " 001 " . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var twoZeros = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> twoZeros . setCountryCode ( 61 ) ; <nl> twoZeros . setNationalNumber ( 1 ) ; <nl> function testParseItalianLeadingZeros ( ) { <nl> assertTrue ( twoZeros . equals ( phoneUtil . parse ( ' 001 ' , RegionCode . AU ) ) ) ; <nl> <nl> / / Test the number " 000 " . This number has 2 leading zeros . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var stillTwoZeros = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> stillTwoZeros . setCountryCode ( 61 ) ; <nl> stillTwoZeros . setNationalNumber ( 0 ) ; <nl> function testParseItalianLeadingZeros ( ) { <nl> assertTrue ( stillTwoZeros . equals ( phoneUtil . parse ( ' 000 ' , RegionCode . AU ) ) ) ; <nl> <nl> / / Test the number " 0000 " . This number has 3 leading zeros . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var threeZeros = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> threeZeros . setCountryCode ( 61 ) ; <nl> threeZeros . setNationalNumber ( 0 ) ; <nl> function testCountryWithNoNumberDesc ( ) { <nl> var PNT = i18n . phonenumbers . PhoneNumberType ; <nl> / / Andorra is a country where we don ' t have PhoneNumberDesc info in the <nl> / / metadata . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var adNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> adNumber . setCountryCode ( 376 ) ; <nl> adNumber . setNationalNumber ( 12345 ) ; <nl> function testUnknownCountryCallingCode ( ) { <nl> function testIsNumberMatchMatches ( ) { <nl> / / Test simple matches where formatting is different , or leading zeros , or <nl> / / country calling code has been specified . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var num1 = phoneUtil . parse ( ' + 64 3 331 6005 ' , RegionCode . NZ ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var num2 = phoneUtil . parse ( ' + 64 03 331 6005 ' , RegionCode . NZ ) ; <nl> assertEquals ( i18n . phonenumbers . PhoneNumberUtil . MatchType . EXACT_MATCH , <nl> phoneUtil . isNumberMatch ( num1 , num2 ) ) ; <nl> function testIsNumberMatchMatches ( ) { <nl> assertEquals ( i18n . phonenumbers . PhoneNumberUtil . MatchType . EXACT_MATCH , <nl> phoneUtil . isNumberMatch ( NZ_NUMBER , ' + 6403 331 6005 ' ) ) ; <nl> <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumber = NZ_NUMBER . clone ( ) ; <nl> nzNumber . setExtension ( ' 3456 ' ) ; <nl> assertEquals ( i18n . phonenumbers . PhoneNumberUtil . MatchType . EXACT_MATCH , <nl> function testIsNumberMatchMatches ( ) { <nl> } <nl> <nl> function testIsNumberMatchShortMatchIfDiffNumLeadingZeros ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberOne = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberTwo = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> <nl> nzNumberOne . setCountryCode ( 64 ) ; <nl> function testIsNumberMatchShortMatchIfDiffNumLeadingZeros ( ) { <nl> } <nl> <nl> function testIsNumberMatchAcceptsProtoDefaultsAsMatch ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberOne = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberTwo = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> <nl> nzNumberOne . setCountryCode ( 64 ) ; <nl> function testIsNumberMatchAcceptsProtoDefaultsAsMatch ( ) { <nl> } <nl> <nl> function testIsNumberMatchMatchesDiffLeadingZerosIfItalianLeadingZeroFalse ( ) { <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberOne = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var nzNumberTwo = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> <nl> nzNumberOne . setCountryCode ( 64 ) ; <nl> function testIsNumberMatchIgnoresSomeFields ( ) { <nl> var CCS = i18n . phonenumbers . PhoneNumber . CountryCodeSource ; <nl> / / Check raw_input , country_code_source and preferred_domestic_carrier_code <nl> / / are ignored . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var brNumberOne = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var brNumberTwo = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> brNumberOne . setCountryCode ( 55 ) ; <nl> brNumberOne . setNationalNumber ( 3121286979 ) ; <nl> function testIsNumberMatchNsnMatches ( ) { <nl> phoneUtil . isNumberMatch ( NZ_NUMBER , ' 03 331 6005 ' ) ) ; <nl> / / Here the second number possibly starts with the country calling code for <nl> / / New Zealand , although we are unsure . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var unchangedNzNumber = NZ_NUMBER . clone ( ) ; <nl> assertEquals ( i18n . phonenumbers . PhoneNumberUtil . MatchType . NSN_MATCH , <nl> phoneUtil . isNumberMatch ( unchangedNzNumber , ' ( 64 - 3 ) 331 6005 ' ) ) ; <nl> function testIsNumberMatchNsnMatches ( ) { <nl> / / For this case , the match will be a short NSN match , because we cannot <nl> / / assume that the 1 might be a national prefix , so don ' t remove it when <nl> / / parsing . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var randomNumber = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> randomNumber . setCountryCode ( 41 ) ; <nl> randomNumber . setNationalNumber ( 6502530000 ) ; <nl> function testIsNumberMatchShortNsnMatches ( ) { <nl> assertEquals ( i18n . phonenumbers . PhoneNumberUtil . MatchType . SHORT_NSN_MATCH , <nl> phoneUtil . isNumberMatch ( ' + 64 3 331 - 6005 ' , ' 3 331 6005 # 1234 ' ) ) ; <nl> / / One has Italian leading zero , one does not . <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var italianNumberOne = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> italianNumberOne . setCountryCode ( 39 ) ; <nl> italianNumberOne . setNationalNumber ( 1234 ) ; <nl> italianNumberOne . setItalianLeadingZero ( true ) ; <nl> - / * * @ type { i18n . phonenumbers . PhoneNumber } * / <nl> + / * * @ type { ! i18n . phonenumbers . PhoneNumber } * / <nl> var italianNumberTwo = new i18n . phonenumbers . PhoneNumber ( ) ; <nl> italianNumberTwo . setCountryCode ( 39 ) ; <nl> italianNumberTwo . setNationalNumber ( 1234 ) ; <nl> mmm a / javascript / i18n / phonenumbers / shortnumberinfo . js <nl> ppp b / javascript / i18n / phonenumbers / shortnumberinfo . js <nl> i18n . phonenumbers . ShortNumberInfo . prototype . getRegionCodeForShortNumberFromRegio <nl> <nl> / * * <nl> * Convenience method to get a list of what regions the library has metadata for <nl> - * @ return { Array < string > } the list of region codes <nl> + * @ return { ! Array < string > } the list of region codes <nl> * @ package <nl> * / <nl> i18n . phonenumbers . ShortNumberInfo . prototype . getSupportedRegions = function ( ) { <nl>
Make JS util test changes to reflect the annotation updates . ( )
google/libphonenumber
2e739a9cb560663c1c345a4db343b8b20ce708c6
2020-03-18T09:02:22Z
mmm a / aten / src / ATen / native / cuda / CuFFTPlanCache . h <nl> ppp b / aten / src / ATen / native / cuda / CuFFTPlanCache . h <nl> static bool is_pow_of_two ( int64_t x ) { <nl> / / 2 . whether to clone input before executing the plan <nl> / / 3 . the workspace size needed <nl> / / <nl> - / / Its constructor also guarantees that if ` input ` is contiguous in all <nl> - / / dimensions , e . g . , from cloning , clone_input will be false . <nl> - / / <nl> / / This class will be the * * value * * in the plan cache . <nl> / / It * * owns * * the raw plan via a unique_ptr . <nl> class CuFFTConfig { <nl> class CuFFTConfig { <nl> # if CUDA_VERSION < 10000 <nl> / / Note that the max plan number for CUDA version < 10 has to be 1023 <nl> / / due to a bug that fails on the 1024th plan <nl> - constexpr int64_t CUFFT_MAX_PLAN_NUM = 1023 ; <nl> + constexpr size_t CUFFT_MAX_PLAN_NUM = 1023 ; <nl> + constexpr size_t CUFFT_DEFAULT_CACHE_SIZE = CUFFT_MAX_PLAN_NUM ; <nl> # else <nl> - / / The max plan number chosen for CUDA version > 10 is arbitrary . <nl> - / / This number puts a limit on how big of a plan cache should we maintain . <nl> - / / Without this number , the plan cache can grow unconditionally . <nl> - constexpr int64_t CUFFT_MAX_PLAN_NUM = 4096 ; <nl> + constexpr size_t CUFFT_MAX_PLAN_NUM = std : : numeric_limits < size_t > : : max ( ) ; <nl> + / / The default max cache size chosen for CUDA version > 10 is arbitrary . <nl> + / / This number puts a limit on how big of a plan cache should we maintain by <nl> + / / default . Users can always configure it via cufft_set_plan_cache_max_size . <nl> + constexpr size_t CUFFT_DEFAULT_CACHE_SIZE = 4096 ; <nl> # endif <nl> static_assert ( CUFFT_MAX_PLAN_NUM > = 0 & & CUFFT_MAX_PLAN_NUM < = std : : numeric_limits < size_t > : : max ( ) , <nl> " CUFFT_MAX_PLAN_NUM not in size_t range " ) ; <nl> + static_assert ( CUFFT_DEFAULT_CACHE_SIZE > = 0 & & CUFFT_DEFAULT_CACHE_SIZE < = CUFFT_MAX_PLAN_NUM , <nl> + " CUFFT_DEFAULT_CACHE_SIZE not in [ 0 , CUFFT_MAX_PLAN_NUM ] range " ) ; <nl> <nl> / / This cache assumes that the mapping from key to value never changes . <nl> / / This is * * NOT * * thread - safe . Please use a mutex when using it * * AND * * the <nl> class CuFFTParamsLRUCache { <nl> using map_kkv_iter_t = typename map_t : : iterator ; <nl> <nl> <nl> - CuFFTParamsLRUCache ( ) : CuFFTParamsLRUCache ( CUFFT_MAX_PLAN_NUM ) { } <nl> + CuFFTParamsLRUCache ( ) : CuFFTParamsLRUCache ( CUFFT_DEFAULT_CACHE_SIZE ) { } <nl> <nl> CuFFTParamsLRUCache ( int64_t max_size ) { <nl> _set_max_size ( max_size ) ; <nl> class CuFFTParamsLRUCache { <nl> private : <nl> / / Only sets size and does value check . Does not resize the data structures . <nl> void _set_max_size ( int64_t new_size ) { <nl> - AT_CHECK ( new_size < = CUFFT_MAX_PLAN_NUM , <nl> - " cuFFT plan cache size can not be larger than " , CUFFT_MAX_PLAN_NUM , " , but got " , new_size ) ; <nl> + / / We check that 0 < = new_size < = CUFFT_MAX_PLAN_NUM here . Since <nl> + / / CUFFT_MAX_PLAN_NUM is of type size_t , we need to do non - negativity check <nl> + / / first . <nl> AT_CHECK ( new_size > = 0 , <nl> " cuFFT plan cache size must be non - negative , but got " , new_size ) ; <nl> + AT_CHECK ( new_size < = CUFFT_MAX_PLAN_NUM , <nl> + " cuFFT plan cache size can not be larger than " , CUFFT_MAX_PLAN_NUM , " , but got " , new_size ) ; <nl> _max_size = static_cast < size_t > ( new_size ) ; <nl> } <nl> <nl> mmm a / aten / src / ATen / native / cuda / SpectralOps . cu <nl> ppp b / aten / src / ATen / native / cuda / SpectralOps . cu <nl> Tensor _fft_cufft ( const Tensor & self , int64_t signal_ndim , <nl> } <nl> <nl> / / cuFFT requires input and output data pointers to complex type aligned . <nl> - / / Our allocated output tensor is always 256 bytes aligned so it is fine , but <nl> - / / we need to check input tensor to make sure that it is not unaligned , e . g . , <nl> + / / Our newly allocated output tensor is always 512 bytes aligned so it is fine <nl> + / / ( see kRoundSmall and kRoundLarge in THCCachingAllocator . cpp ) , but we do <nl> + / / need to check input tensor to make sure that it is not unaligned , e . g . , <nl> / / from a slicing . <nl> auto complex_size_bytes = 2 * input . type ( ) . elementSizeInBytes ( ) ; <nl> if ( reinterpret_cast < std : : uintptr_t > ( input . data_ptr ( ) ) % complex_size_bytes ! = 0 ) { <nl>
Fix cuFFT plan cache size on CUDA 10 cannot be set to > 4096 ( )
pytorch/pytorch
d2861230f3ea9aadc3444caa1c22c87d961b7853
2019-01-31T14:56:39Z
mmm a / Telegram / SourceFiles / data / data_sparse_ids . cpp <nl> ppp b / Telegram / SourceFiles / data / data_sparse_ids . cpp <nl> base : : optional < int > SparseIdsMergedSlice : : distance ( <nl> } <nl> <nl> auto SparseIdsMergedSlice : : nearest ( <nl> - UniversalMsgId id ) const - > base : : optional < UniversalMsgId > { <nl> - auto convertFromMigratedNearest = [ ] ( MsgId result ) { <nl> - return result - ServerMaxMsgId ; <nl> + UniversalMsgId id ) const - > base : : optional < FullMsgId > { <nl> + auto convertFromPartNearest = [ & ] ( MsgId result ) { <nl> + return ComputeId ( _key . peerId , result ) ; <nl> + } ; <nl> + auto convertFromMigratedNearest = [ & ] ( MsgId result ) { <nl> + return ComputeId ( _key . migratedPeerId , result ) ; <nl> } ; <nl> if ( IsServerMsgId ( id ) ) { <nl> if ( auto partNearestId = _part . nearest ( id ) ) { <nl> - return partNearestId ; <nl> + return partNearestId <nl> + | convertFromPartNearest ; <nl> } else if ( isolatedInPart ( ) ) { <nl> return base : : none ; <nl> } <nl> auto SparseIdsMergedSlice : : nearest ( <nl> } else if ( isolatedInMigrated ( ) ) { <nl> return base : : none ; <nl> } <nl> - return _part . nearest ( 0 ) ; <nl> + return _part . nearest ( 0 ) <nl> + | convertFromPartNearest ; <nl> } <nl> <nl> SparseIdsSliceBuilder : : SparseIdsSliceBuilder ( <nl> mmm a / Telegram / SourceFiles / data / data_sparse_ids . h <nl> ppp b / Telegram / SourceFiles / data / data_sparse_ids . h <nl> class SparseIdsMergedSlice { <nl> int size ( ) const ; <nl> FullMsgId operator [ ] ( int index ) const ; <nl> base : : optional < int > distance ( const Key & a , const Key & b ) const ; <nl> - base : : optional < UniversalMsgId > nearest ( UniversalMsgId id ) const ; <nl> + base : : optional < FullMsgId > nearest ( UniversalMsgId id ) const ; <nl> <nl> using SimpleViewerFunction = rpl : : producer < SparseIdsSlice > ( <nl> PeerId peerId , <nl> mmm a / Telegram / SourceFiles / info / media / info_media_list_widget . cpp <nl> ppp b / Telegram / SourceFiles / info / media / info_media_list_widget . cpp <nl> SparseIdsMergedSlice : : Key ListWidget : : sliceKey ( <nl> <nl> void ListWidget : : refreshViewer ( ) { <nl> _viewerLifetime . destroy ( ) ; <nl> + auto idForViewer = sliceKey ( _universalAroundId ) . universalId ; <nl> _controller - > mediaSource ( <nl> - sliceKey ( _universalAroundId ) . universalId , <nl> + idForViewer , <nl> _idsLimit , <nl> _idsLimit ) <nl> - | rpl : : start_with_next ( [ this ] ( <nl> + | rpl : : start_with_next ( [ = ] ( <nl> SparseIdsMergedSlice & & slice ) { <nl> _slice = std : : move ( slice ) ; <nl> - if ( auto nearest = _slice . nearest ( _universalAroundId ) ) { <nl> - _universalAroundId = * nearest ; <nl> + if ( auto nearest = _slice . nearest ( idForViewer ) ) { <nl> + _universalAroundId = GetUniversalId ( * nearest ) ; <nl> } <nl> refreshRows ( ) ; <nl> } , _viewerLifetime ) ; <nl> mmm a / Telegram / SourceFiles / window / window . style <nl> ppp b / Telegram / SourceFiles / window / window . style <nl> windowShadowShift : 1px ; <nl> <nl> columnMinimalWidthLeft : 260px ; <nl> columnMinimalWidthMain : 380px ; <nl> - columnMinimalWidthThird : 292px ; / / 345px ; <nl> + columnMinimalWidthThird : 345px ; / / 292px ; / / 345px ; <nl> <nl> adaptiveChatWideWidth : 880px ; <nl> <nl>
Fix restoring shared media state .
telegramdesktop/tdesktop
3a25313e610fb038a97edf004792e5610228797c
2017-11-16T03:59:11Z
mmm a / src / utilstrencodings . cpp <nl> ppp b / src / utilstrencodings . cpp <nl> using namespace std ; <nl> <nl> / / safeChars chosen to allow simple messages / URLs / email addresses , but avoid anything <nl> / / even possibly remotely dangerous like & or > <nl> - static string safeChars ( " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 . , ; _ / : ? @ " ) ; <nl> + static string safeChars ( " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 . , ; _ / : ? @ ( ) " ) ; <nl> string SanitizeString ( const string & str ) <nl> { <nl> string strResult ; <nl>
Merge pull request
bitcoin/bitcoin
610a3d3a1bd171b963600c55fab715ca2aa30da3
2014-09-26T17:36:08Z
mmm a / src / compiler / node - matchers . h <nl> ppp b / src / compiler / node - matchers . h <nl> typedef FloatMatcher < double , IrOpcode : : kFloat64Constant > Float64Matcher ; <nl> typedef FloatMatcher < double , IrOpcode : : kNumberConstant > NumberMatcher ; <nl> <nl> <nl> + / / A pattern matcher for any numberic constant . <nl> + struct NumericValueMatcher : public NodeMatcher { <nl> + explicit NumericValueMatcher ( Node * const node ) : NodeMatcher ( node ) { <nl> + switch ( opcode ( ) ) { <nl> + case IrOpcode : : kInt32Constant : <nl> + has_value_ = true ; <nl> + value_ = OpParameter < int32_t > ( node ) ; <nl> + break ; <nl> + case IrOpcode : : kFloat32Constant : <nl> + has_value_ = true ; <nl> + value_ = OpParameter < float > ( node ) ; <nl> + break ; <nl> + case IrOpcode : : kFloat64Constant : <nl> + case IrOpcode : : kNumberConstant : <nl> + has_value_ = true ; <nl> + value_ = OpParameter < double > ( node ) ; <nl> + break ; <nl> + default : <nl> + has_value_ = false ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + bool HasValue ( ) const { return has_value_ ; } <nl> + double Value ( ) const { <nl> + DCHECK ( HasValue ( ) ) ; <nl> + return value_ ; <nl> + } <nl> + <nl> + private : <nl> + double value_ ; <nl> + bool has_value_ ; <nl> + } ; <nl> + <nl> + <nl> / / A pattern matcher for heap object constants . <nl> template < typename T > <nl> struct HeapObjectMatcher FINAL <nl> mmm a / src / compiler / pipeline . cc <nl> ppp b / src / compiler / pipeline . cc <nl> Handle < Code > Pipeline : : GenerateCode ( ) { <nl> " typed lowering " ) ; <nl> SourcePositionTable : : Scope pos ( & source_positions , <nl> SourcePosition : : Unknown ( ) ) ; <nl> + ValueNumberingReducer vn_reducer ( zone ( ) ) ; <nl> JSTypedLowering lowering ( & jsgraph ) ; <nl> + SimplifiedOperatorReducer simple_reducer ( & jsgraph ) ; <nl> GraphReducer graph_reducer ( & graph ) ; <nl> + graph_reducer . AddReducer ( & vn_reducer ) ; <nl> graph_reducer . AddReducer ( & lowering ) ; <nl> + graph_reducer . AddReducer ( & simple_reducer ) ; <nl> graph_reducer . ReduceGraph ( ) ; <nl> <nl> VerifyAndPrintGraph ( & graph , " Lowered typed " ) ; <nl> mmm a / src / compiler / simplified - operator - reducer . cc <nl> ppp b / src / compiler / simplified - operator - reducer . cc <nl> namespace v8 { <nl> namespace internal { <nl> namespace compiler { <nl> <nl> + SimplifiedOperatorReducer : : SimplifiedOperatorReducer ( JSGraph * jsgraph ) <nl> + : jsgraph_ ( jsgraph ) , simplified_ ( jsgraph - > zone ( ) ) { } <nl> + <nl> + <nl> SimplifiedOperatorReducer : : ~ SimplifiedOperatorReducer ( ) { } <nl> <nl> <nl> Reduction SimplifiedOperatorReducer : : Reduce ( Node * node ) { <nl> if ( m . HasValue ( ) ) return ReplaceNumber ( FastUI2D ( m . Value ( ) ) ) ; <nl> break ; <nl> } <nl> + case IrOpcode : : kLoadElement : { <nl> + ElementAccess access = ElementAccessOf ( node - > op ( ) ) ; <nl> + if ( access . bounds_check = = kTypedArrayBoundsCheck ) { <nl> + NumericValueMatcher mkey ( node - > InputAt ( 1 ) ) ; <nl> + NumericValueMatcher mlength ( node - > InputAt ( 2 ) ) ; <nl> + if ( mkey . HasValue ( ) & & mlength . HasValue ( ) ) { <nl> + / / Skip the typed array bounds check if key and length are constant . <nl> + if ( mkey . Value ( ) < mlength . Value ( ) ) { <nl> + access . bounds_check = kNoBoundsCheck ; <nl> + node - > set_op ( simplified ( ) - > LoadElement ( access ) ) ; <nl> + return Changed ( node ) ; <nl> + } <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case IrOpcode : : kStoreElement : { <nl> + ElementAccess access = ElementAccessOf ( node - > op ( ) ) ; <nl> + if ( access . bounds_check = = kTypedArrayBoundsCheck ) { <nl> + NumericValueMatcher mkey ( node - > InputAt ( 1 ) ) ; <nl> + NumericValueMatcher mlength ( node - > InputAt ( 2 ) ) ; <nl> + if ( mkey . HasValue ( ) & & mlength . HasValue ( ) ) { <nl> + / / Skip the typed array bounds check if key and length are constant . <nl> + if ( mkey . Value ( ) < mlength . Value ( ) ) { <nl> + access . bounds_check = kNoBoundsCheck ; <nl> + node - > set_op ( simplified ( ) - > StoreElement ( access ) ) ; <nl> + return Changed ( node ) ; <nl> + } <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> default : <nl> break ; <nl> } <nl> mmm a / src / compiler / simplified - operator - reducer . h <nl> ppp b / src / compiler / simplified - operator - reducer . h <nl> <nl> # define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_ <nl> <nl> # include " src / compiler / graph - reducer . h " <nl> + # include " src / compiler / simplified - operator . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> class MachineOperatorBuilder ; <nl> <nl> class SimplifiedOperatorReducer FINAL : public Reducer { <nl> public : <nl> - explicit SimplifiedOperatorReducer ( JSGraph * jsgraph ) : jsgraph_ ( jsgraph ) { } <nl> + explicit SimplifiedOperatorReducer ( JSGraph * jsgraph ) ; <nl> virtual ~ SimplifiedOperatorReducer ( ) ; <nl> <nl> virtual Reduction Reduce ( Node * node ) OVERRIDE ; <nl> class SimplifiedOperatorReducer FINAL : public Reducer { <nl> Factory * factory ( ) const ; <nl> JSGraph * jsgraph ( ) const { return jsgraph_ ; } <nl> MachineOperatorBuilder * machine ( ) const ; <nl> + SimplifiedOperatorBuilder * simplified ( ) { return & simplified_ ; } <nl> <nl> JSGraph * jsgraph_ ; <nl> + SimplifiedOperatorBuilder simplified_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( SimplifiedOperatorReducer ) ; <nl> } ; <nl> new file mode 100644 <nl> index 00000000000 . . b1fbd26da2f <nl> mmm / dev / null <nl> ppp b / test / mjsunit / asm / int32array - constant - key . js <nl> <nl> + / / Copyright 2014 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> + function Module ( stdlib , foreign , heap ) { <nl> + " use asm " ; <nl> + var MEM32 = new stdlib . Int32Array ( heap ) ; <nl> + function load0 ( ) { <nl> + return MEM32 [ 0 ] ; <nl> + } <nl> + function load4 ( ) { <nl> + return MEM32 [ 4 ] ; <nl> + } <nl> + function store0 ( v ) { <nl> + MEM32 [ 0 ] = v ; <nl> + } <nl> + function store4 ( v ) { <nl> + MEM32 [ 4 ] = v ; <nl> + } <nl> + return { load0 : load0 , store0 : store0 , load4 : load4 , store4 : store4 } ; <nl> + } <nl> + <nl> + var m = Module ( this , { } , new ArrayBuffer ( 4 ) ) ; <nl> + <nl> + assertEquals ( 0 , m . load0 ( ) ) ; <nl> + assertEquals ( undefined , m . load4 ( ) ) ; <nl> + m . store0 ( 0x12345678 ) ; <nl> + assertEquals ( 0x12345678 , m . load0 ( ) ) ; <nl> + assertEquals ( undefined , m . load4 ( ) ) ; <nl> + m . store4 ( 43 ) ; <nl> + assertEquals ( 0x12345678 , m . load0 ( ) ) ; <nl> + assertEquals ( undefined , m . load4 ( ) ) ; <nl> mmm a / test / unittests / compiler / simplified - operator - reducer - unittest . cc <nl> ppp b / test / unittests / compiler / simplified - operator - reducer - unittest . cc <nl> <nl> # include " src / compiler / simplified - operator . h " <nl> # include " src / compiler / simplified - operator - reducer . h " <nl> # include " src / conversions . h " <nl> + # include " src / types . h " <nl> # include " test / unittests / compiler / graph - unittest . h " <nl> <nl> namespace v8 { <nl> TEST_F ( SimplifiedOperatorReducerTest , ChangeUint32ToTagged ) { <nl> } <nl> } <nl> <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / LoadElement <nl> + <nl> + <nl> + TEST_F ( SimplifiedOperatorReducerTest , LoadElementWithConstantKeyAndLength ) { <nl> + ElementAccess const access = { kTypedArrayBoundsCheck , kUntaggedBase , 0 , <nl> + Type : : Any ( ) , kMachAnyTagged } ; <nl> + ElementAccess access_nocheck = access ; <nl> + access_nocheck . bounds_check = kNoBoundsCheck ; <nl> + Node * const base = Parameter ( 0 ) ; <nl> + Node * const effect = graph ( ) - > start ( ) ; <nl> + Node * const control = graph ( ) - > start ( ) ; <nl> + TRACED_FOREACH ( double , key , kFloat64Values ) { <nl> + TRACED_FOREACH ( int32_t , length , kInt32Values ) { <nl> + if ( key < length ) { <nl> + Reduction r = Reduce ( graph ( ) - > NewNode ( <nl> + simplified ( ) - > LoadElement ( access ) , base , NumberConstant ( key ) , <nl> + Int32Constant ( length ) , effect , control ) ) ; <nl> + ASSERT_TRUE ( r . Changed ( ) ) ; <nl> + EXPECT_THAT ( r . replacement ( ) , <nl> + IsLoadElement ( access_nocheck , base , IsNumberConstant ( key ) , <nl> + IsInt32Constant ( length ) , effect , control ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / StoreElement <nl> + <nl> + <nl> + TEST_F ( SimplifiedOperatorReducerTest , StoreElementWithConstantKeyAndLength ) { <nl> + ElementAccess const access = { kTypedArrayBoundsCheck , kUntaggedBase , 0 , <nl> + Type : : Any ( ) , kMachAnyTagged } ; <nl> + ElementAccess access_nocheck = access ; <nl> + access_nocheck . bounds_check = kNoBoundsCheck ; <nl> + Node * const base = Parameter ( 0 ) ; <nl> + Node * const value = Parameter ( 1 ) ; <nl> + Node * const effect = graph ( ) - > start ( ) ; <nl> + Node * const control = graph ( ) - > start ( ) ; <nl> + TRACED_FOREACH ( int32_t , key , kInt32Values ) { <nl> + TRACED_FOREACH ( double , length , kFloat64Values ) { <nl> + if ( key < length ) { <nl> + Reduction r = Reduce ( graph ( ) - > NewNode ( <nl> + simplified ( ) - > StoreElement ( access ) , base , Int32Constant ( key ) , <nl> + NumberConstant ( length ) , value , effect , control ) ) ; <nl> + ASSERT_TRUE ( r . Changed ( ) ) ; <nl> + EXPECT_THAT ( <nl> + r . replacement ( ) , <nl> + IsStoreElement ( access_nocheck , base , IsInt32Constant ( key ) , <nl> + IsNumberConstant ( length ) , value , effect , control ) ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> } / / namespace compiler <nl> } / / namespace internal <nl> } / / namespace v8 <nl>
[ turbofan ] Eliminate typed array bounds checks if both key and length are constant .
v8/v8
a77915026062ce48cf02c046092c761fbf83356c
2014-10-17T09:35:45Z
new file mode 100644 <nl> index 00000000000 . . 7cb647dc73f <nl> mmm / dev / null <nl> ppp b / js / actions / api - open . js <nl> <nl> + / * jslint indent : 2 , nomen : true , maxlen : 100 , sloppy : true , vars : true , white : true , plusplus : true , evil : true * / <nl> + / * global require , exports , module , ArangoServerState * / <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief open actions <nl> + / / / <nl> + / / / @ file <nl> + / / / Actions that are mapped under the " _open " path . Allowing to execute the <nl> + / / / actions without authorization . <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Dr . Frank Celler <nl> + / / / @ author Copyright 2014 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + var actions = require ( " org / arangodb / actions " ) ; <nl> + var console = require ( " console " ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - public functions <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief ceberus password manager <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + actions . defineHttp ( { <nl> + url : " _open / cerberus " , <nl> + context : " admin " , <nl> + prefix : true , <nl> + <nl> + callback : function ( req , res ) { <nl> + req . user = null ; <nl> + req . database = " _system " ; <nl> + <nl> + var suffix = " system / cerberus " ; <nl> + suffix = suffix . split ( " / " ) ; <nl> + suffix = suffix . concat ( req . suffix ) ; <nl> + <nl> + req . suffix = suffix ; <nl> + <nl> + actions . routeRequest ( req , res ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - END - OF - FILE <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " / / / @ brief \ \ | / / / @ addtogroup \ \ | / / - - SECTION - - \ \ | / / / @ page \ \ | / / / @ \ \ } " <nl> + / / End : <nl> mmm a / js / actions / api - system . js <nl> ppp b / js / actions / api - system . js <nl> var internal = require ( " internal " ) ; <nl> var console = require ( " console " ) ; <nl> var users = require ( " org / arangodb / users " ) ; <nl> <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / - - SECTION - - private functions <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief routing function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - function routing ( req , res ) { <nl> - var action ; <nl> - var execute ; <nl> - var next ; <nl> - var path = req . suffix . join ( " / " ) ; <nl> - <nl> - action = actions . firstRouting ( req . requestType , req . suffix ) ; <nl> - <nl> - execute = function ( ) { <nl> - if ( action . route = = = undefined ) { <nl> - actions . resultNotFound ( req , res , arangodb . ERROR_HTTP_NOT_FOUND , <nl> - " unknown path ' " + path + " ' " ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( action . route . path ! = = undefined ) { <nl> - req . path = action . route . path ; <nl> - } <nl> - else { <nl> - delete req . path ; <nl> - } <nl> - <nl> - if ( action . prefix ! = = undefined ) { <nl> - req . prefix = action . prefix ; <nl> - } <nl> - else { <nl> - delete req . prefix ; <nl> - } <nl> - <nl> - if ( action . suffix ! = = undefined ) { <nl> - req . suffix = action . suffix ; <nl> - } <nl> - else { <nl> - delete req . suffix ; <nl> - } <nl> - <nl> - if ( action . urlParameters ! = = undefined ) { <nl> - req . urlParameters = action . urlParameters ; <nl> - } <nl> - else { <nl> - req . urlParameters = { } ; <nl> - } <nl> - <nl> - var func = action . route . callback . controller ; <nl> - <nl> - if ( func = = = null | | typeof func ! = = ' function ' ) { <nl> - func = actions . errorFunction ( action . route , <nl> - ' Invalid callback definition found for route ' <nl> - + JSON . stringify ( action . route ) ) ; <nl> - } <nl> - <nl> - try { <nl> - func ( req , res , action . route . callback . options , next ) ; <nl> - } <nl> - catch ( err ) { <nl> - if ( err instanceof internal . SleepAndRequeue ) { <nl> - throw err ; <nl> - } <nl> - <nl> - var msg = ' A runtime error occurred while executing an action : ' <nl> - + String ( err ) + " " + String ( err . stack ) + " " + ( typeof err ) ; <nl> - <nl> - actions . errorFunction ( action . route , msg ) ( req , res , action . route . callback . options , next ) ; <nl> - } <nl> - } ; <nl> - <nl> - next = function ( ) { <nl> - action = actions . nextRouting ( action ) ; <nl> - execute ( ) ; <nl> - } ; <nl> - <nl> - execute ( ) ; <nl> - } <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - public functions <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> actions . defineHttp ( { <nl> prefix : true , <nl> context : " admin " , <nl> <nl> - callback : routing <nl> + callback : actions . routeRequest <nl> } ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / js / apps / system / cerberus / cerberus . js <nl> ppp b / js / apps / system / cerberus / cerberus . js <nl> <nl> <nl> var Foxx = require ( " org / arangodb / foxx " ) , <nl> users = require ( " org / arangodb / users " ) , <nl> - controller = new Foxx . Controller ( applicationContext ) <nl> + controller = new Foxx . Controller ( applicationContext ) , <nl> + url = require ( " url " ) ; <nl> <nl> controller . get ( " / initpwd / : token " , function ( req , res ) { <nl> var token = req . params ( " token " ) , <nl> <nl> / / check token <nl> username = users . userByToken ( token ) ; <nl> <nl> - / / token = users . setPasswordToken ( username ) ; <nl> - <nl> if ( username ) { <nl> + var path = url . parse ( req . url ) . pathname . split ( " / " ) ; <nl> + path = path . slice ( 0 , path . length - 2 ) . join ( " / " ) + " / changePassword . html " ; <nl> + <nl> res . status ( 307 ) ; <nl> - res . set ( " Location " , " / system / cerberus / changePassword . html ? n = " + username + " & t = " + token ) ; <nl> + res . set ( " Location " , path + " ? n = " + username + " & t = " + token ) ; <nl> } else { <nl> res . set ( " Content - Type " , " text / plain " ) ; <nl> res . body = ' The token was not valid . Plaese ensure , that the url you entered was valid ( no linebreaks etc . ) ' ; <nl> <nl> var password = params [ 0 ] . split ( " = " ) [ 1 ] ; <nl> var confirmPassword = params [ 1 ] . split ( " = " ) [ 1 ] ; <nl> var token = params [ 2 ] . split ( " = " ) [ 1 ] ; <nl> + <nl> / / check , if passwords are equal <nl> if ( password ! = = confirmPassword ) { <nl> + var path = url . parse ( req . url ) . pathname . split ( " / " ) ; <nl> + path = path . slice ( 0 , path . length - 2 ) . join ( " / " ) + " / changePassword . html " ; <nl> + <nl> res . status ( 307 ) ; <nl> - res . set ( " Location " , " / system / cerberus / changePassword . html ? n = " + name + " & t = " + token ) ; <nl> + res . set ( " Location " , path + " ? n = " + name + " & t = " + token ) ; <nl> return ; <nl> } <nl> + <nl> if ( users . changePassword ( token , password ) ) { <nl> res . set ( " Content - Type " , " text / html " ) ; <nl> res . body = ' Password sucessfully changed . Press < a href = " / " > here < / a > to proceed . ' ; <nl> <nl> res . body = ' The token was not valid . Plaese ensure , that the url you entered was valid ( no linebreaks etc . ) ' ; <nl> } <nl> } ) ; <nl> - <nl> } ( ) ) ; <nl> \ No newline at end of file <nl> mmm a / js / apps / system / cerberus / html / changePassword . html <nl> ppp b / js / apps / system / cerberus / html / changePassword . html <nl> <nl> < body > <nl> < h1 id = " headerId " > < / h1 > <nl> < p id = " textId " > < / p > <nl> - < form name = " Formular " action = " _open / checkpwd " method = " post " > <nl> + < form name = " Formular " action = " checkpwd " method = " post " > <nl> < table > <nl> < tr > <nl> < td > New password : < / td > <nl> mmm a / js / apps / system / cerberus / manifest . json <nl> ppp b / js / apps / system / cerberus / manifest . json <nl> <nl> " author " : " gschwab " , <nl> " isSystem " : true , <nl> " controllers " : { <nl> - " / _open / " : " cerberus . js " <nl> + " / " : " cerberus . js " <nl> } , <nl> " assets " : { <nl> " changePassword . html " : { <nl> mmm a / js / server / modules / org / arangodb / actions . js <nl> ppp b / js / server / modules / org / arangodb / actions . js <nl> function flattenRouting ( routes , path , urlParameters , depth , prefix ) { <nl> / / - - SECTION - - public functions <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief routing function <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function routeRequest ( req , res ) { <nl> + var action ; <nl> + var execute ; <nl> + var next ; <nl> + var path = req . suffix . join ( " / " ) ; <nl> + <nl> + action = exports . firstRouting ( req . requestType , req . suffix ) ; <nl> + <nl> + execute = function ( ) { <nl> + if ( action . route = = = undefined ) { <nl> + exports . resultNotFound ( req , res , arangodb . ERROR_HTTP_NOT_FOUND , <nl> + " unknown path ' " + path + " ' " ) ; <nl> + return ; <nl> + } <nl> + <nl> + if ( action . route . path ! = = undefined ) { <nl> + req . path = action . route . path ; <nl> + } <nl> + else { <nl> + delete req . path ; <nl> + } <nl> + <nl> + if ( action . prefix ! = = undefined ) { <nl> + req . prefix = action . prefix ; <nl> + } <nl> + else { <nl> + delete req . prefix ; <nl> + } <nl> + <nl> + if ( action . suffix ! = = undefined ) { <nl> + req . suffix = action . suffix ; <nl> + } <nl> + else { <nl> + delete req . suffix ; <nl> + } <nl> + <nl> + if ( action . urlParameters ! = = undefined ) { <nl> + req . urlParameters = action . urlParameters ; <nl> + } <nl> + else { <nl> + req . urlParameters = { } ; <nl> + } <nl> + <nl> + var func = action . route . callback . controller ; <nl> + <nl> + if ( func = = = null | | typeof func ! = = ' function ' ) { <nl> + func = exports . errorFunction ( action . route , <nl> + ' Invalid callback definition found for route ' <nl> + + JSON . stringify ( action . route ) ) ; <nl> + } <nl> + <nl> + try { <nl> + func ( req , res , action . route . callback . options , next ) ; <nl> + } <nl> + catch ( err ) { <nl> + if ( err instanceof internal . SleepAndRequeue ) { <nl> + throw err ; <nl> + } <nl> + <nl> + var msg = ' A runtime error occurred while executing an action : ' <nl> + + String ( err ) + " " + String ( err . stack ) + " " + ( typeof err ) ; <nl> + <nl> + exports . errorFunction ( action . route , msg ) ( req , res , action . route . callback . options , next ) ; <nl> + } <nl> + } ; <nl> + <nl> + next = function ( ) { <nl> + action = exports . nextRouting ( action ) ; <nl> + execute ( ) ; <nl> + } ; <nl> + <nl> + execute ( ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief returns a result of a query as documents <nl> / / / <nl> function stringifyRequestAddress ( req ) { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> / / public functions <nl> + exports . routeRequest = routeRequest ; <nl> exports . defineHttp = defineHttp ; <nl> exports . getErrorMessage = getErrorMessage ; <nl> exports . getJsonBody = getJsonBody ; <nl>
fixed path
arangodb/arangodb
e30414b839b9a08f8acd3f2aabe619e3b51f6b52
2014-04-10T15:32:08Z
mmm a / scene / 2d / collision_object_2d . cpp <nl> ppp b / scene / 2d / collision_object_2d . cpp <nl> String CollisionObject2D : : get_configuration_warning ( ) const { <nl> if ( warning = = String ( ) ) { <nl> warning + = " \ n " ; <nl> } <nl> - warning + = TTR ( " This node has no children shapes , so it can ' t interact with the space . \ nConsider adding CollisionShape2D or CollisionPolygon2D children nodes to define it ' s shape . " ) ; <nl> + warning + = TTR ( " This node has no children shapes , so it can ' t interact with the space . \ nConsider adding CollisionShape2D or CollisionPolygon2D children nodes to define its shape . " ) ; <nl> } <nl> <nl> return warning ; <nl>
Merge pull request from yurchor / patch - 1
godotengine/godot
00387cbe1b05c6093baea76d6852af18842c0f65
2018-01-20T18:27:49Z
mmm a / arangod / Aql / CollectionScanner . cpp <nl> ppp b / arangod / Aql / CollectionScanner . cpp <nl> CollectionScanner : : CollectionScanner ( arangodb : : AqlTransaction * trx , <nl> : _cursor ( trx - > indexScan ( collection , <nl> ( readRandom ? Transaction : : CursorType : : ANY <nl> : Transaction : : CursorType : : ALL ) , <nl> - " " , VPackSlice ( ) , 0 , UINT64_MAX , 1000 , false ) ) { <nl> + Transaction : : IndexHandle ( ) , VPackSlice ( ) , 0 , <nl> + UINT64_MAX , 1000 , false ) ) { <nl> TRI_ASSERT ( _cursor - > successful ( ) ) ; <nl> } <nl> <nl> mmm a / arangod / Aql / Condition . cpp <nl> ppp b / arangod / Aql / Condition . cpp <nl> void Condition : : andCombine ( AstNode const * node ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : pair < bool , bool > Condition : : findIndexes ( <nl> - EnumerateCollectionNode const * node , std : : vector < std : : string > & usedIndexes , <nl> + EnumerateCollectionNode const * node , <nl> + std : : vector < Transaction : : IndexHandle > & usedIndexes , <nl> SortCondition const * sortCondition ) { <nl> TRI_ASSERT ( usedIndexes . empty ( ) ) ; <nl> Variable const * reference = node - > outVariable ( ) ; <nl> std : : pair < bool , bool > Condition : : findIndexes ( <nl> <nl> size_t const itemsInIndex = node - > collection ( ) - > count ( ) ; <nl> if ( _root = = nullptr ) { <nl> + size_t dummy ; <nl> return trx - > getIndexForSortCondition ( collectionName , sortCondition , <nl> - reference , itemsInIndex , usedIndexes ) ; <nl> + reference , itemsInIndex , usedIndexes , <nl> + dummy ) ; <nl> } <nl> <nl> return trx - > getBestIndexHandlesForFilterCondition ( <nl> mmm a / arangod / Aql / Condition . h <nl> ppp b / arangod / Aql / Condition . h <nl> <nl> # include " Aql / AstNode . h " <nl> # include " Basics / AttributeNameParser . h " <nl> # include " Basics / JsonHelper . h " <nl> + # include " Utils / Transaction . h " <nl> <nl> namespace arangodb { <nl> namespace aql { <nl> class Condition { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : pair < bool , bool > findIndexes ( EnumerateCollectionNode const * , <nl> - std : : vector < std : : string > & , <nl> + std : : vector < Transaction : : IndexHandle > & , <nl> SortCondition const * ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Aql / ConditionFinder . cpp <nl> ppp b / arangod / Aql / ConditionFinder . cpp <nl> bool ConditionFinder : : before ( ExecutionNode * en ) { <nl> break ; <nl> } <nl> <nl> - std : : vector < std : : string > usedIndexes ; <nl> + std : : vector < Transaction : : IndexHandle > usedIndexes ; <nl> auto canUseIndex = <nl> condition - > findIndexes ( node , usedIndexes , sortCondition . get ( ) ) ; <nl> <nl> mmm a / arangod / Aql / Functions . cpp <nl> ppp b / arangod / Aql / Functions . cpp <nl> static bool SortNumberList ( arangodb : : AqlTransaction * trx , <nl> static void RequestEdges ( VPackSlice const & vertexSlice , <nl> arangodb : : AqlTransaction * trx , <nl> std : : string const & collectionName , <nl> - std : : string const & indexId , <nl> + Transaction : : IndexHandle const & indexId , <nl> TRI_edge_direction_e direction , <nl> arangodb : : ExampleMatcher const * matcher , <nl> bool includeVertices , VPackBuilder & result ) { <nl> AqlValue Functions : : Edges ( arangodb : : aql : : Query * query , <nl> <nl> std : : unique_ptr < arangodb : : ExampleMatcher > matcher ; <nl> <nl> - TRI_document_collection_t * documentCollection = trx - > documentCollection ( cid ) ; <nl> - arangodb : : EdgeIndex * edgeIndex = documentCollection - > edgeIndex ( ) ; <nl> - TRI_ASSERT ( edgeIndex ! = nullptr ) ; / / Checked because collection is edge Collection . <nl> - std : : string indexId = arangodb : : basics : : StringUtils : : itoa ( edgeIndex - > id ( ) ) ; <nl> + Transaction : : IndexHandle indexId = trx - > edgeIndexHandle ( collectionName ) ; <nl> <nl> size_t const n = parameters . size ( ) ; <nl> if ( n > 3 ) { <nl> mmm a / arangod / Aql / Index . cpp <nl> ppp b / arangod / Aql / Index . cpp <nl> bool Index : : supportsSortCondition ( <nl> arangodb : : aql : : SortCondition const * sortCondition , <nl> arangodb : : aql : : Variable const * reference , size_t itemsInIndex , <nl> double & estimatedCost ) const { <nl> + size_t coveredAttributes ; <nl> if ( ! hasInternals ( ) ) { <nl> return false ; <nl> } <nl> return getInternals ( ) - > supportsSortCondition ( sortCondition , reference , <nl> - itemsInIndex , estimatedCost ) ; <nl> + itemsInIndex , estimatedCost , <nl> + coveredAttributes ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Aql / IndexBlock . cpp <nl> ppp b / arangod / Aql / IndexBlock . cpp <nl> arangodb : : aql : : AstNode * IndexBlock : : makeUnique ( <nl> auto trx = ast - > query ( ) - > trx ( ) ; <nl> bool isSorted = false ; <nl> bool isSparse = false ; <nl> - auto unused = trx - > getIndexFeatures ( _collection - > getName ( ) , _indexes [ _currentIndex ] , isSorted , isSparse ) ; <nl> + auto unused = trx - > getIndexFeatures ( _indexes [ _currentIndex ] , isSorted , isSparse ) ; <nl> if ( isSparse ) { <nl> / / the index is sorted . we need to use SORTED_UNIQUE to get the <nl> / / result back in index order <nl> mmm a / arangod / Aql / IndexBlock . h <nl> ppp b / arangod / Aql / IndexBlock . h <nl> class IndexBlock : public ExecutionBlock { <nl> / / / @ brief _indexes holds all Indexes used in this block <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : vector < std : : string > _indexes ; <nl> + std : : vector < Transaction : : IndexHandle > _indexes ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief _nonConstExpressions , list of all non const expressions , mapped <nl> mmm a / arangod / Aql / IndexNode . cpp <nl> ppp b / arangod / Aql / IndexNode . cpp <nl> using namespace arangodb : : aql ; <nl> <nl> using JsonHelper = arangodb : : basics : : JsonHelper ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief constructor <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + IndexNode : : IndexNode ( ExecutionPlan * plan , size_t id , TRI_vocbase_t * vocbase , <nl> + Collection const * collection , Variable const * outVariable , <nl> + std : : vector < Transaction : : IndexHandle > const & indexes , <nl> + Condition * condition , bool reverse ) <nl> + : ExecutionNode ( plan , id ) , <nl> + _vocbase ( vocbase ) , <nl> + _collection ( collection ) , <nl> + _outVariable ( outVariable ) , <nl> + _indexes ( indexes ) , <nl> + _condition ( condition ) , <nl> + _reverse ( reverse ) { <nl> + TRI_ASSERT ( _vocbase ! = nullptr ) ; <nl> + TRI_ASSERT ( _collection ! = nullptr ) ; <nl> + TRI_ASSERT ( _outVariable ! = nullptr ) ; <nl> + TRI_ASSERT ( _condition ! = nullptr ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief return the transaction for the node <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void IndexNode : : toVelocyPackHelper ( VPackBuilder & nodes , bool verbose ) const { <nl> { <nl> VPackArrayBuilder guard ( & nodes ) ; <nl> for ( auto & index : _indexes ) { <nl> - arangodb : : Index * idx = trx ( ) - > getIndexByIdentifier ( _collection - > name , index ) ; <nl> nodes . openObject ( ) ; <nl> - idx - > toVelocyPack ( nodes , false ) ; <nl> + index . toVelocyPack ( nodes , false ) ; <nl> nodes . close ( ) ; <nl> } <nl> } <nl> IndexNode : : IndexNode ( ExecutionPlan * plan , arangodb : : basics : : Json const & json ) <nl> size_t length = TRI_LengthArrayJson ( indexes ) ; <nl> _indexes . reserve ( length ) ; <nl> <nl> + auto trx = plan - > getAst ( ) - > query ( ) - > trx ( ) ; <nl> for ( size_t i = 0 ; i < length ; + + i ) { <nl> auto entry = TRI_LookupArrayJson ( indexes , i ) ; <nl> std : : string iid = JsonHelper : : checkAndGetStringValue ( entry , " id " ) ; <nl> - _indexes . emplace_back ( iid ) ; <nl> + _indexes . emplace_back ( trx - > getIndexByIdentifier ( _collection - > getName ( ) , iid ) ) ; <nl> } <nl> <nl> TRI_json_t const * condition = <nl> double IndexNode : : estimateCost ( size_t & nrItems ) const { <nl> <nl> auto root = _condition - > root ( ) ; <nl> auto transaction = trx ( ) ; <nl> - std : : string const collectionName = _collection - > getName ( ) ; <nl> <nl> for ( size_t i = 0 ; i < _indexes . size ( ) ; + + i ) { <nl> double estimatedCost = 0 . 0 ; <nl> double IndexNode : : estimateCost ( size_t & nrItems ) const { <nl> } <nl> <nl> if ( condition ! = nullptr & & <nl> - transaction - > supportsFilterCondition ( collectionName , _indexes [ i ] , condition , <nl> + transaction - > supportsFilterCondition ( _indexes [ i ] , condition , <nl> _outVariable , itemsInCollection , <nl> estimatedItems , estimatedCost ) ) { <nl> totalItems + = estimatedItems ; <nl> mmm a / arangod / Aql / IndexNode . h <nl> ppp b / arangod / Aql / IndexNode . h <nl> <nl> # include " Basics / JsonHelper . h " <nl> # include " VocBase / voc - types . h " <nl> # include " VocBase / vocbase . h " <nl> + # include " Utils / Transaction . h " <nl> <nl> namespace arangodb { <nl> - class Transaction ; <nl> <nl> namespace aql { <nl> struct Collection ; <nl> class IndexNode : public ExecutionNode { <nl> public : <nl> IndexNode ( ExecutionPlan * plan , size_t id , TRI_vocbase_t * vocbase , <nl> Collection const * collection , Variable const * outVariable , <nl> - std : : vector < std : : string > const & indexes , Condition * condition , <nl> - bool reverse ) <nl> - : ExecutionNode ( plan , id ) , <nl> - _vocbase ( vocbase ) , <nl> - _collection ( collection ) , <nl> - _outVariable ( outVariable ) , <nl> - _indexes ( indexes ) , <nl> - _condition ( condition ) , <nl> - _reverse ( reverse ) { <nl> - TRI_ASSERT ( _vocbase ! = nullptr ) ; <nl> - TRI_ASSERT ( _collection ! = nullptr ) ; <nl> - TRI_ASSERT ( _outVariable ! = nullptr ) ; <nl> - TRI_ASSERT ( _condition ! = nullptr ) ; <nl> - } <nl> + std : : vector < Transaction : : IndexHandle > const & indexes , <nl> + Condition * condition , bool reverse ) ; <nl> <nl> IndexNode ( ExecutionPlan * , arangodb : : basics : : Json const & base ) ; <nl> <nl> class IndexNode : public ExecutionNode { <nl> / / / @ brief getIndexes , hand out the indexes used <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : vector < std : : string > getIndexes ( ) const { return _indexes ; } <nl> + std : : vector < Transaction : : IndexHandle > const & getIndexes ( ) const { return _indexes ; } <nl> <nl> private : <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class IndexNode : public ExecutionNode { <nl> / / / @ brief the index <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : vector < std : : string > _indexes ; <nl> + std : : vector < Transaction : : IndexHandle > _indexes ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief the index ( es ) condition <nl> mmm a / arangod / Aql / OptimizerRules . cpp <nl> ppp b / arangod / Aql / OptimizerRules . cpp <nl> <nl> # include " Aql / types . h " <nl> # include " Basics / AttributeNameParser . h " <nl> # include " Basics / json - utilities . h " <nl> + # include " Utils / Transaction . h " <nl> <nl> using namespace arangodb : : aql ; <nl> using Json = arangodb : : basics : : Json ; <nl> struct SortToIndexNode final : public WalkerWorker < ExecutionNode > { <nl> / / now check if any of the collection ' s indexes covers it <nl> <nl> Variable const * outVariable = enumerateCollectionNode - > outVariable ( ) ; <nl> - auto const & indexes = enumerateCollectionNode - > collection ( ) - > getIndexes ( ) ; <nl> - arangodb : : aql : : Index const * bestIndex = nullptr ; <nl> - double bestCost = 0 . 0 ; <nl> - size_t bestNumCovered = 0 ; <nl> - <nl> - for ( auto & index : indexes ) { <nl> - if ( ! index - > isSorted ( ) | | index - > sparse ) { <nl> - / / can only use a sorted index <nl> - / / cannot use a sparse index for sorting <nl> - continue ; <nl> - } <nl> - <nl> - size_t const numCovered = <nl> - sortCondition . coveredAttributes ( outVariable , index - > fields ) ; <nl> - <nl> - if ( numCovered = = 0 ) { <nl> - continue ; <nl> - } <nl> - <nl> - double estimatedCost = 0 . 0 ; <nl> - if ( ! index - > supportsSortCondition ( <nl> - & sortCondition , <nl> - outVariable , <nl> - enumerateCollectionNode - > collection ( ) - > count ( ) , <nl> - estimatedCost ) ) { <nl> - / / should never happen <nl> - TRI_ASSERT ( false ) ; <nl> - continue ; <nl> - } <nl> - <nl> - if ( bestIndex = = nullptr | | estimatedCost < bestCost ) { <nl> - bestIndex = index ; <nl> - bestCost = estimatedCost ; <nl> - bestNumCovered = numCovered ; <nl> - } <nl> - } <nl> - <nl> - if ( bestIndex ! = nullptr ) { <nl> + std : : vector < arangodb : : Transaction : : IndexHandle > usedIndexes ; <nl> + auto trx = _plan - > getAst ( ) - > query ( ) - > trx ( ) ; <nl> + size_t coveredAttributes = 0 ; <nl> + auto resultPair = trx - > getIndexForSortCondition ( <nl> + enumerateCollectionNode - > collection ( ) - > getName ( ) , <nl> + & sortCondition , outVariable , <nl> + enumerateCollectionNode - > collection ( ) - > count ( ) , <nl> + usedIndexes , coveredAttributes ) ; <nl> + if ( resultPair . second ) { <nl> + / / If this bit is set , then usedIndexes has length exactly one <nl> + / / and contains the best index found . <nl> auto condition = std : : make_unique < Condition > ( _plan - > getAst ( ) ) ; <nl> condition - > normalize ( _plan ) ; <nl> <nl> std : : unique_ptr < ExecutionNode > newNode ( new IndexNode ( <nl> _plan , _plan - > nextId ( ) , enumerateCollectionNode - > vocbase ( ) , <nl> enumerateCollectionNode - > collection ( ) , outVariable , <nl> - std : : vector < std : : string > { arangodb : : basics : : StringUtils : : itoa ( bestIndex - > id ) } , condition . get ( ) , <nl> - sortCondition . isDescending ( ) ) ) ; <nl> + usedIndexes , condition . get ( ) , sortCondition . isDescending ( ) ) ) ; <nl> <nl> condition . release ( ) ; <nl> <nl> struct SortToIndexNode final : public WalkerWorker < ExecutionNode > { <nl> _plan - > replaceNode ( enumerateCollectionNode , n ) ; <nl> _modified = true ; <nl> <nl> - if ( bestNumCovered = = sortCondition . numAttributes ( ) ) { <nl> + if ( coveredAttributes = = sortCondition . numAttributes ( ) ) { <nl> / / if the index covers the complete sort condition , we can also remove <nl> / / the sort node <nl> _plan - > unlinkNode ( _plan - > getNodeById ( _sortNode - > id ( ) ) ) ; <nl> struct SortToIndexNode final : public WalkerWorker < ExecutionNode > { <nl> TRI_ASSERT ( outVariable ! = nullptr ) ; <nl> <nl> auto index = indexes [ 0 ] ; <nl> - std : : string collectionName = indexNode - > collection ( ) - > getName ( ) ; <nl> arangodb : : Transaction * trx = indexNode - > trx ( ) ; <nl> bool isSorted = false ; <nl> bool isSparse = false ; <nl> std : : vector < std : : vector < arangodb : : basics : : AttributeName > > fields = <nl> - trx - > getIndexFeatures ( collectionName , index , isSorted , isSparse ) ; <nl> + trx - > getIndexFeatures ( index , isSorted , isSparse ) ; <nl> if ( indexes . size ( ) ! = 1 ) { <nl> / / can only use this index node if it uses exactly one index or multiple <nl> / / indexes on exactly the same attributes <nl> mmm a / arangod / Indexes / Index . cpp <nl> ppp b / arangod / Indexes / Index . cpp <nl> bool Index : : supportsFilterCondition ( arangodb : : aql : : AstNode const * , <nl> bool Index : : supportsSortCondition ( arangodb : : aql : : SortCondition const * , <nl> arangodb : : aql : : Variable const * , <nl> size_t itemsInIndex , <nl> - double & estimatedCost ) const { <nl> + double & estimatedCost , <nl> + size_t & coveredAttributes ) const { <nl> / / by default , no sort conditions are supported <nl> + coveredAttributes = 0 ; <nl> if ( itemsInIndex > 0 ) { <nl> estimatedCost = itemsInIndex * std : : log2 ( itemsInIndex ) ; <nl> } else { <nl> mmm a / arangod / Indexes / Index . h <nl> ppp b / arangod / Indexes / Index . h <nl> class Index { <nl> <nl> virtual bool supportsSortCondition ( arangodb : : aql : : SortCondition const * , <nl> arangodb : : aql : : Variable const * , size_t , <nl> - double & ) const ; <nl> + double & , size_t & ) const ; <nl> <nl> virtual IndexIterator * iteratorForCondition ( arangodb : : Transaction * , <nl> IndexIteratorContext * , <nl> mmm a / arangod / Indexes / SkiplistIndex . cpp <nl> ppp b / arangod / Indexes / SkiplistIndex . cpp <nl> bool SkiplistIndex : : supportsFilterCondition ( <nl> bool SkiplistIndex : : supportsSortCondition ( <nl> arangodb : : aql : : SortCondition const * sortCondition , <nl> arangodb : : aql : : Variable const * reference , size_t itemsInIndex , <nl> - double & estimatedCost ) const { <nl> + double & estimatedCost , size_t & coveredAttributes ) const { <nl> TRI_ASSERT ( sortCondition ! = nullptr ) ; <nl> <nl> if ( ! _sparse ) { <nl> / / only non - sparse indexes can be used for sorting <nl> if ( ! _useExpansion & & sortCondition - > isUnidirectional ( ) & & <nl> sortCondition - > isOnlyAttributeAccess ( ) ) { <nl> - size_t const coveredAttributes = <nl> - sortCondition - > coveredAttributes ( reference , _fields ) ; <nl> + coveredAttributes = sortCondition - > coveredAttributes ( reference , _fields ) ; <nl> <nl> if ( coveredAttributes > = sortCondition - > numAttributes ( ) ) { <nl> / / sort is fully covered by index . no additional sort costs ! <nl> bool SkiplistIndex : : supportsSortCondition ( <nl> } <nl> } <nl> <nl> + coveredAttributes = 0 ; <nl> / / by default no sort conditions are supported <nl> if ( itemsInIndex > 0 ) { <nl> estimatedCost = itemsInIndex * std : : log2 ( static_cast < double > ( itemsInIndex ) ) ; <nl> mmm a / arangod / Indexes / SkiplistIndex . h <nl> ppp b / arangod / Indexes / SkiplistIndex . h <nl> class SkiplistIndex final : public PathBasedIndex { <nl> <nl> bool supportsSortCondition ( arangodb : : aql : : SortCondition const * , <nl> arangodb : : aql : : Variable const * , size_t , <nl> - double & ) const override ; <nl> + double & , size_t & ) const override ; <nl> <nl> IndexIterator * iteratorForCondition ( arangodb : : Transaction * , <nl> IndexIteratorContext * , <nl> mmm a / arangod / RestHandler / RestEdgesHandler . cpp <nl> ppp b / arangod / RestHandler / RestEdgesHandler . cpp <nl> bool RestEdgesHandler : : getEdgesForVertex ( <nl> <nl> trx . orderDitch ( trx . cid ( ) ) ; / / will throw when it fails <nl> <nl> - std : : string const collectionName = trx . resolver ( ) - > getCollectionName ( trx . cid ( ) ) ; <nl> - <nl> - arangodb : : EdgeIndex * edgeIndex = trx . documentCollection ( ) - > edgeIndex ( ) ; <nl> - std : : string indexId = arangodb : : basics : : StringUtils : : itoa ( edgeIndex - > id ( ) ) ; <nl> + std : : string const collectionName <nl> + = trx . resolver ( ) - > getCollectionName ( trx . cid ( ) ) ; <nl> + Transaction : : IndexHandle indexId = trx . edgeIndexHandle ( collectionName ) ; <nl> <nl> VPackBuilder searchValueBuilder ; <nl> EdgeIndex : : buildSearchValue ( direction , id , searchValueBuilder ) ; <nl> mmm a / arangod / Utils / Transaction . cpp <nl> ppp b / arangod / Utils / Transaction . cpp <nl> <nl> <nl> using namespace arangodb ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief IndexHandle getter method <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + std : : shared_ptr < arangodb : : Index > Transaction : : IndexHandle : : getIndex ( ) const { <nl> + return _index ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief IndexHandle toVelocyPack method passthrough <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void Transaction : : IndexHandle : : toVelocyPack ( <nl> + arangodb : : velocypack : : Builder & builder , <nl> + bool withFigures ) const { <nl> + _index - > toVelocyPack ( builder , withFigures ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief tests if the given index supports the sort condition <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> using namespace arangodb ; <nl> static bool indexSupportsSort ( Index const * idx , arangodb : : aql : : Variable const * reference , <nl> arangodb : : aql : : SortCondition const * sortCondition , <nl> size_t itemsInIndex , <nl> - double & estimatedCost ) { <nl> + double & estimatedCost , <nl> + size_t & coveredAttributes ) { <nl> if ( idx - > isSorted ( ) & & <nl> idx - > supportsSortCondition ( sortCondition , reference , itemsInIndex , <nl> - estimatedCost ) ) { <nl> + estimatedCost , coveredAttributes ) ) { <nl> / / index supports the sort condition <nl> return true ; <nl> } <nl> static bool indexSupportsSort ( Index const * idx , arangodb : : aql : : Variable const * r <nl> / / / the usedIndexes vector may also be re - sorted <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static bool sortOrs ( arangodb : : aql : : Ast * ast , <nl> + bool Transaction : : sortOrs ( arangodb : : aql : : Ast * ast , <nl> arangodb : : aql : : AstNode * root , <nl> arangodb : : aql : : Variable const * variable , <nl> - std : : vector < std : : string > & usedIndexes ) { <nl> + std : : vector < arangodb : : Transaction : : IndexHandle > & usedIndexes ) const { <nl> if ( root = = nullptr ) { <nl> return true ; <nl> } <nl> static bool sortOrs ( arangodb : : aql : : Ast * ast , <nl> return false ; <nl> } <nl> <nl> - typedef std : : pair < arangodb : : aql : : AstNode * , std : : string > ConditionData ; <nl> + typedef std : : pair < arangodb : : aql : : AstNode * , arangodb : : Transaction : : IndexHandle > ConditionData ; <nl> std : : vector < ConditionData * > conditionData ; <nl> <nl> auto cleanup = [ & conditionData ] ( ) - > void { <nl> static bool sortOrs ( arangodb : : aql : : Ast * ast , <nl> return true ; <nl> } <nl> <nl> - <nl> - <nl> - static std : : pair < bool , bool > findIndexHandleForAndNode ( <nl> + std : : pair < bool , bool > Transaction : : findIndexHandleForAndNode ( <nl> std : : vector < std : : shared_ptr < Index > > indexes , arangodb : : aql : : AstNode * node , <nl> arangodb : : aql : : Variable const * reference , <nl> arangodb : : aql : : SortCondition const * sortCondition , <nl> size_t itemsInCollection , <nl> - std : : vector < std : : string > & usedIndexes , <nl> + std : : vector < Transaction : : IndexHandle > & usedIndexes , <nl> arangodb : : aql : : AstNode * & specializedCondition , <nl> - bool & isSparse ) { <nl> - Index const * bestIndex = nullptr ; <nl> + bool & isSparse ) const { <nl> + std : : shared_ptr < Index > bestIndex ; <nl> double bestCost = 0 . 0 ; <nl> bool bestSupportsFilter = false ; <nl> bool bestSupportsSort = false ; <nl> + size_t coveredAttributes = 0 ; <nl> <nl> for ( auto const & idx : indexes ) { <nl> double filterCost = 0 . 0 ; <nl> static std : : pair < bool , bool > findIndexHandleForAndNode ( <nl> / / be empty , must consist only of attribute access , and all attributes <nl> / / must be sorted in the direction <nl> if ( indexSupportsSort ( idx . get ( ) , reference , sortCondition , itemsInIndex , <nl> - sortCost ) ) { <nl> + sortCost , coveredAttributes ) ) { <nl> supportsSort = true ; <nl> } <nl> } <nl> static std : : pair < bool , bool > findIndexHandleForAndNode ( <nl> <nl> double const totalCost = filterCost + sortCost ; <nl> if ( bestIndex = = nullptr | | totalCost < bestCost ) { <nl> - bestIndex = idx . get ( ) ; <nl> + bestIndex = idx ; <nl> bestCost = totalCost ; <nl> bestSupportsFilter = supportsFilter ; <nl> bestSupportsSort = supportsSort ; <nl> static std : : pair < bool , bool > findIndexHandleForAndNode ( <nl> <nl> specializedCondition = bestIndex - > specializeCondition ( node , reference ) ; <nl> <nl> - usedIndexes . emplace_back ( <nl> - arangodb : : basics : : StringUtils : : itoa ( bestIndex - > id ( ) ) ) ; <nl> + usedIndexes . emplace_back ( bestIndex ) ; <nl> isSparse = bestIndex - > sparse ( ) ; <nl> <nl> return std : : make_pair ( bestSupportsFilter , bestSupportsSort ) ; <nl> OperationResult Transaction : : anyLocal ( std : : string const & collectionName , <nl> resultBuilder . openArray ( ) ; <nl> <nl> std : : shared_ptr < OperationCursor > cursor = <nl> - indexScan ( collectionName , Transaction : : CursorType : : ANY , " " , { } , skip , <nl> - limit , 1000 , false ) ; <nl> + indexScan ( collectionName , Transaction : : CursorType : : ANY , IndexHandle ( ) , <nl> + { } , skip , limit , 1000 , false ) ; <nl> <nl> auto result = std : : make_shared < OperationResult > ( TRI_ERROR_NO_ERROR ) ; <nl> while ( cursor - > hasMore ( ) ) { <nl> std : : string Transaction : : collectionName ( TRI_voc_cid_t cid ) { <nl> / / / @ brief return the edge index handle of collection <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : string Transaction : : edgeIndexHandle ( std : : string const & collectionName ) { <nl> + Transaction : : IndexHandle Transaction : : edgeIndexHandle ( std : : string const & collectionName ) { <nl> if ( ! isEdgeCollection ( collectionName ) ) { <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID ) ; <nl> } <nl> auto indexes = indexesForCollection ( collectionName ) ; <nl> for ( auto idx : indexes ) { <nl> if ( idx - > type ( ) = = Index : : TRI_IDX_TYPE_EDGE_INDEX ) { <nl> - return arangodb : : basics : : StringUtils : : itoa ( idx - > id ( ) ) ; <nl> + return IndexHandle ( idx ) ; <nl> } <nl> } <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID ) ; <nl> OperationResult Transaction : : allKeysLocal ( std : : string const & collectionName , <nl> resultBuilder . add ( " documents " , VPackValue ( VPackValueType : : Array ) ) ; <nl> <nl> std : : shared_ptr < OperationCursor > cursor = <nl> - indexScan ( collectionName , Transaction : : CursorType : : ALL , " " , { } , 0 , <nl> - UINT64_MAX , 1000 , false ) ; <nl> + indexScan ( collectionName , Transaction : : CursorType : : ALL , IndexHandle ( ) , <nl> + { } , 0 , UINT64_MAX , 1000 , false ) ; <nl> <nl> auto result = std : : make_shared < OperationResult > ( TRI_ERROR_NO_ERROR ) ; <nl> while ( cursor - > hasMore ( ) ) { <nl> OperationResult Transaction : : allLocal ( std : : string const & collectionName , <nl> resultBuilder . openArray ( ) ; <nl> <nl> std : : shared_ptr < OperationCursor > cursor = <nl> - indexScan ( collectionName , Transaction : : CursorType : : ALL , " " , { } , skip , <nl> - limit , 1000 , false ) ; <nl> + indexScan ( collectionName , Transaction : : CursorType : : ALL , IndexHandle ( ) , <nl> + { } , skip , limit , 1000 , false ) ; <nl> <nl> auto result = std : : make_shared < OperationResult > ( TRI_ERROR_NO_ERROR ) ; <nl> while ( cursor - > hasMore ( ) ) { <nl> std : : pair < bool , bool > Transaction : : getBestIndexHandlesForFilterCondition ( <nl> arangodb : : aql : : Variable const * reference , <nl> arangodb : : aql : : SortCondition const * sortCondition , <nl> size_t itemsInCollection , <nl> - std : : vector < std : : string > & usedIndexes , <nl> + std : : vector < IndexHandle > & usedIndexes , <nl> bool & isSorted ) const { <nl> / / We can only start after DNF transformation <nl> TRI_ASSERT ( root - > type = = <nl> std : : pair < bool , bool > Transaction : : getBestIndexHandlesForFilterCondition ( <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> bool Transaction : : supportsFilterCondition ( <nl> - std : : string const & collectionName , std : : string const & indexHandle , <nl> + IndexHandle const & indexHandle , <nl> arangodb : : aql : : AstNode const * condition , <nl> arangodb : : aql : : Variable const * reference , size_t itemsInIndex , <nl> size_t & estimatedItems , double & estimatedCost ) { <nl> - if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> - / / The supportsFilterCondition is only available on DBServers and Single Server . <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_CLUSTER_ONLY_ON_DBSERVER ) ; <nl> - } <nl> - <nl> - arangodb : : Index * idx = getIndexByIdentifier ( collectionName , indexHandle ) ; <nl> <nl> - return idx - > supportsFilterCondition ( condition , reference , itemsInIndex , <nl> - estimatedItems , estimatedCost ) ; <nl> + return indexHandle . getIndex ( ) - > supportsFilterCondition ( <nl> + condition , reference , itemsInIndex , estimatedItems , estimatedCost ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> bool Transaction : : supportsFilterCondition ( <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : vector < std : : vector < arangodb : : basics : : AttributeName > > <nl> - Transaction : : getIndexFeatures ( std : : string const & collectionName , <nl> - std : : string const & indexHandle , bool & isSorted , <nl> + Transaction : : getIndexFeatures ( IndexHandle const & indexHandle , bool & isSorted , <nl> bool & isSparse ) { <nl> <nl> - if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> - / / The index is sorted check is only available on DBServers and Single Server . <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_CLUSTER_ONLY_ON_DBSERVER ) ; <nl> - } <nl> - <nl> - arangodb : : Index * idx = getIndexByIdentifier ( collectionName , indexHandle ) ; <nl> + std : : shared_ptr < arangodb : : Index > idx = indexHandle . getIndex ( ) ; <nl> isSorted = idx - > isSorted ( ) ; <nl> isSparse = idx - > sparse ( ) ; <nl> return idx - > fields ( ) ; <nl> Transaction : : getIndexFeatures ( std : : string const & collectionName , <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : pair < bool , bool > Transaction : : getIndexForSortCondition ( <nl> - std : : string const & collectionName , arangodb : : aql : : SortCondition const * sortCondition , <nl> + std : : string const & collectionName , <nl> + arangodb : : aql : : SortCondition const * sortCondition , <nl> arangodb : : aql : : Variable const * reference , size_t itemsInIndex , <nl> - std : : vector < std : : string > & usedIndexes ) const { <nl> + std : : vector < IndexHandle > & usedIndexes , <nl> + size_t & coveredAttributes ) const { <nl> / / We do not have a condition . But we have a sort ! <nl> if ( ! sortCondition - > isEmpty ( ) & & sortCondition - > isOnlyAttributeAccess ( ) & & <nl> sortCondition - > isUnidirectional ( ) ) { <nl> double bestCost = 0 . 0 ; <nl> - Index const * bestIndex = nullptr ; <nl> + std : : shared_ptr < Index > bestIndex ; <nl> <nl> auto indexes = indexesForCollection ( collectionName ) ; <nl> <nl> std : : pair < bool , bool > Transaction : : getIndexForSortCondition ( <nl> continue ; <nl> } <nl> double sortCost = 0 . 0 ; <nl> + size_t covered = 0 ; <nl> if ( indexSupportsSort ( idx . get ( ) , reference , sortCondition , itemsInIndex , <nl> - sortCost ) ) { <nl> + sortCost , covered ) ) { <nl> if ( bestIndex = = nullptr | | sortCost < bestCost ) { <nl> bestCost = sortCost ; <nl> - bestIndex = idx . get ( ) ; <nl> + bestIndex = idx ; <nl> + coveredAttributes = covered ; <nl> } <nl> } <nl> } <nl> <nl> if ( bestIndex ! = nullptr ) { <nl> - usedIndexes . emplace_back ( arangodb : : basics : : StringUtils : : itoa ( bestIndex - > id ( ) ) ) ; <nl> + usedIndexes . emplace_back ( bestIndex ) ; <nl> } <nl> <nl> return std : : make_pair ( false , bestIndex ! = nullptr ) ; <nl> std : : pair < bool , bool > Transaction : : getIndexForSortCondition ( <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScanForCondition ( <nl> - std : : string const & collectionName , std : : string const & indexId , <nl> + std : : string const & collectionName , IndexHandle const & indexId , <nl> arangodb : : aql : : Ast * ast , arangodb : : aql : : AstNode const * condition , <nl> arangodb : : aql : : Variable const * var , uint64_t limit , uint64_t batchSize , <nl> bool reverse ) { <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScanForCondition ( <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_CLUSTER_ONLY_ON_DBSERVER ) ; <nl> } <nl> <nl> - arangodb : : Index * idx = getIndexByIdentifier ( collectionName , indexId ) ; <nl> - <nl> if ( limit = = 0 ) { <nl> / / nothing to do <nl> return std : : make_shared < OperationCursor > ( TRI_ERROR_NO_ERROR ) ; <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScanForCondition ( <nl> / / Now collect the Iterator <nl> IndexIteratorContext ctxt ( _vocbase , resolver ( ) ) ; <nl> <nl> + auto idx = indexId . getIndex ( ) ; <nl> + <nl> std : : unique_ptr < IndexIterator > iterator ( idx - > iteratorForCondition ( this , & ctxt , ast , condition , var , reverse ) ) ; <nl> <nl> if ( iterator = = nullptr ) { <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScanForCondition ( <nl> batchSize ) ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief get the index by it ' s identifier . Will either throw or <nl> - / / / return a valid index . nullptr is impossible . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - arangodb : : Index * Transaction : : getIndexByIdentifier ( <nl> - std : : string const & collectionName , std : : string const & indexHandle ) { <nl> - TRI_voc_cid_t cid = resolver ( ) - > getCollectionId ( collectionName ) ; <nl> - <nl> - if ( cid = = 0 ) { <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND ) ; <nl> - } <nl> - <nl> - TRI_document_collection_t * document = documentCollection ( trxCollection ( cid ) ) ; <nl> - <nl> - if ( indexHandle . empty ( ) ) { <nl> - THROW_ARANGO_EXCEPTION_MESSAGE ( TRI_ERROR_BAD_PARAMETER , <nl> - " The index id cannot be empty . " ) ; <nl> - } <nl> - <nl> - if ( ! arangodb : : Index : : validateId ( indexHandle . c_str ( ) ) ) { <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_INDEX_HANDLE_BAD ) ; <nl> - } <nl> - TRI_idx_iid_t iid = arangodb : : basics : : StringUtils : : uint64 ( indexHandle ) ; <nl> - arangodb : : Index * idx = document - > lookupIndex ( iid ) ; <nl> - <nl> - if ( idx = = nullptr ) { <nl> - THROW_ARANGO_EXCEPTION_MESSAGE ( TRI_ERROR_ARANGO_INDEX_NOT_FOUND , <nl> - " Could not find index ' " + indexHandle + <nl> - " ' in collection ' " + <nl> - collectionName + " ' . " ) ; <nl> - } <nl> - <nl> - / / We have successfully found an index with the requested id . <nl> - return idx ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief factory for OperationCursor objects <nl> / / / note : the caller must have read - locked the underlying collection when <nl> arangodb : : Index * Transaction : : getIndexByIdentifier ( <nl> <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScan ( <nl> std : : string const & collectionName , CursorType cursorType , <nl> - std : : string const & indexId , VPackSlice const search , uint64_t skip , <nl> + IndexHandle const & indexId , VPackSlice const search , uint64_t skip , <nl> uint64_t limit , uint64_t batchSize , bool reverse ) { <nl> # warning TODO Who checks if indexId is valid and is used for this collection ? <nl> / / For now we assume indexId is the iid part of the index . <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScan ( <nl> / / We do not need search values <nl> TRI_ASSERT ( search . isNone ( ) ) ; <nl> / / We do not need an index either <nl> - TRI_ASSERT ( indexId . empty ( ) ) ; <nl> + TRI_ASSERT ( nullptr = = indexId . getIndex ( ) ) ; <nl> <nl> arangodb : : PrimaryIndex * idx = document - > primaryIndex ( ) ; <nl> <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScan ( <nl> / / We do not need search values <nl> TRI_ASSERT ( search . isNone ( ) ) ; <nl> / / We do not need an index either <nl> - TRI_ASSERT ( indexId . empty ( ) ) ; <nl> + TRI_ASSERT ( nullptr = = indexId . getIndex ( ) ) ; <nl> <nl> arangodb : : PrimaryIndex * idx = document - > primaryIndex ( ) ; <nl> <nl> std : : shared_ptr < OperationCursor > Transaction : : indexScan ( <nl> break ; <nl> } <nl> case CursorType : : INDEX : { <nl> - if ( indexId . empty ( ) ) { <nl> + auto idx = indexId . getIndex ( ) ; <nl> + if ( nullptr = = idx ) { <nl> THROW_ARANGO_EXCEPTION_MESSAGE ( TRI_ERROR_BAD_PARAMETER , <nl> " The index id cannot be empty . " ) ; <nl> } <nl> - arangodb : : Index * idx = getIndexByIdentifier ( collectionName , indexId ) ; <nl> / / Normalize the search values <nl> VPackBuilder expander ; <nl> idx - > expandInSearchValues ( search , expander ) ; <nl> std : : vector < std : : shared_ptr < Index > > Transaction : : indexesForCollectionCoordinator <nl> return indexes ; <nl> } <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief get the index by it ' s identifier . Will either throw or <nl> + / / / return a valid index . nullptr is impossible . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + Transaction : : IndexHandle Transaction : : getIndexByIdentifier ( <nl> + std : : string const & collectionName , std : : string const & indexHandle ) { <nl> + <nl> + if ( ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> + THROW_ARANGO_EXCEPTION ( TRI_ERROR_NOT_IMPLEMENTED ) ; <nl> + } <nl> + <nl> + TRI_voc_cid_t cid = resolver ( ) - > getCollectionId ( collectionName ) ; <nl> + <nl> + if ( cid = = 0 ) { <nl> + THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND ) ; <nl> + } <nl> + <nl> + TRI_document_collection_t * document = documentCollection ( trxCollection ( cid ) ) ; <nl> + <nl> + if ( indexHandle . empty ( ) ) { <nl> + THROW_ARANGO_EXCEPTION_MESSAGE ( TRI_ERROR_BAD_PARAMETER , <nl> + " The index id cannot be empty . " ) ; <nl> + } <nl> + <nl> + if ( ! arangodb : : Index : : validateId ( indexHandle . c_str ( ) ) ) { <nl> + THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_INDEX_HANDLE_BAD ) ; <nl> + } <nl> + TRI_idx_iid_t iid = arangodb : : basics : : StringUtils : : uint64 ( indexHandle ) ; <nl> + arangodb : : Index * idx = document - > lookupIndex ( iid ) ; <nl> + <nl> + if ( idx = = nullptr ) { <nl> + THROW_ARANGO_EXCEPTION_MESSAGE ( TRI_ERROR_ARANGO_INDEX_NOT_FOUND , <nl> + " Could not find index ' " + indexHandle + <nl> + " ' in collection ' " + <nl> + collectionName + " ' . " ) ; <nl> + } <nl> + <nl> + / / We have successfully found an index with the requested id . <nl> + std : : shared_ptr < arangodb : : Index > dummy ; <nl> + return IndexHandle ( std : : shared_ptr < arangodb : : Index > ( dummy , idx ) ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief add a collection to an embedded transaction <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Utils / Transaction . h <nl> ppp b / arangod / Utils / Transaction . h <nl> struct OperationCursor ; <nl> class TransactionContext ; <nl> <nl> class Transaction { <nl> + public : <nl> + <nl> + class IndexHandle { <nl> + friend class Transaction ; <nl> + std : : shared_ptr < arangodb : : Index > _index ; <nl> + public : <nl> + IndexHandle ( ) { <nl> + } <nl> + void toVelocyPack ( arangodb : : velocypack : : Builder & builder , <nl> + bool withFigures ) const ; <nl> + bool operator = = ( IndexHandle const & other ) const { <nl> + return other . _index . get ( ) = = _index . get ( ) ; <nl> + } <nl> + bool operator ! = ( IndexHandle const & other ) const { <nl> + return other . _index . get ( ) ! = _index . get ( ) ; <nl> + } <nl> + IndexHandle ( std : : shared_ptr < arangodb : : Index > idx ) : _index ( idx ) { <nl> + } <nl> + private : <nl> + std : : shared_ptr < arangodb : : Index > getIndex ( ) const ; <nl> + } ; <nl> + <nl> using VPackBuilder = arangodb : : velocypack : : Builder ; <nl> using VPackSlice = arangodb : : velocypack : : Slice ; <nl> <nl> class Transaction { <nl> / / / @ brief return the edge index handle of collection <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : string edgeIndexHandle ( std : : string const & ) ; <nl> + IndexHandle edgeIndexHandle ( std : : string const & ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Iterate over all elements of the collection . <nl> class Transaction { <nl> std : : pair < bool , bool > getBestIndexHandlesForFilterCondition ( <nl> std : : string const & , arangodb : : aql : : Ast * , arangodb : : aql : : AstNode * , <nl> arangodb : : aql : : Variable const * , arangodb : : aql : : SortCondition const * , <nl> - size_t , std : : vector < std : : string > & , bool & ) const ; <nl> + size_t , std : : vector < IndexHandle > & , bool & ) const ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Checks if the index supports the filter condition . <nl> class Transaction { <nl> / / / calling this method <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - bool supportsFilterCondition ( std : : string const & , std : : string const & , <nl> + bool supportsFilterCondition ( IndexHandle const & , <nl> arangodb : : aql : : AstNode const * , <nl> arangodb : : aql : : Variable const * , size_t , size_t & , <nl> double & ) ; <nl> class Transaction { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : vector < std : : vector < arangodb : : basics : : AttributeName > > getIndexFeatures ( <nl> - std : : string const & , std : : string const & , bool & , bool & ) ; <nl> + IndexHandle const & , bool & , bool & ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Gets the best fitting index for an AQL sort condition <nl> class Transaction { <nl> std : : pair < bool , bool > getIndexForSortCondition ( <nl> std : : string const & , arangodb : : aql : : SortCondition const * , <nl> arangodb : : aql : : Variable const * , size_t , <nl> - std : : vector < std : : string > & ) const ; <nl> + std : : vector < IndexHandle > & , <nl> + size_t & coveredAttributes ) const ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief factory for OperationCursor objects from AQL <nl> class Transaction { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : shared_ptr < OperationCursor > indexScanForCondition ( <nl> - std : : string const & collectionName , std : : string const & indexId , <nl> + std : : string const & collectionName , IndexHandle const & indexId , <nl> arangodb : : aql : : Ast * , arangodb : : aql : : AstNode const * , <nl> arangodb : : aql : : Variable const * , uint64_t , uint64_t , bool ) ; <nl> <nl> class Transaction { <nl> <nl> std : : shared_ptr < OperationCursor > indexScan ( std : : string const & collectionName , <nl> CursorType cursorType , <nl> - std : : string const & indexId , <nl> + IndexHandle const & indexId , <nl> VPackSlice const search , <nl> uint64_t skip , uint64_t limit , <nl> uint64_t batchSize , bool reverse ) ; <nl> class Transaction { <nl> <nl> TRI_document_collection_t * documentCollection ( TRI_voc_cid_t ) const ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief get the index by its identifier . Will either throw or <nl> - / / / return a valid index . nullptr is impossible . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief get the index by it ' s identifier . Will either throw or <nl> + / / / return a valid index . nullptr is impossible . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - arangodb : : Index * getIndexByIdentifier ( std : : string const & collectionName , <nl> - std : : string const & indexId ) ; <nl> + IndexHandle getIndexByIdentifier ( <nl> + std : : string const & collectionName , std : : string const & indexHandle ) ; <nl> <nl> private : <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief build a VPack object with _id , _key and _rev and possibly <nl> / / / oldRef ( if given ) , the result is added to the builder in the <nl> class Transaction { <nl> <nl> private : <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief sort ORs for the same attribute so they are in ascending value <nl> + / / / order . this will only work if the condition is for a single attribute <nl> + / / / the usedIndexes vector may also be re - sorted <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool sortOrs ( arangodb : : aql : : Ast * ast , <nl> + arangodb : : aql : : AstNode * root , <nl> + arangodb : : aql : : Variable const * variable , <nl> + std : : vector < arangodb : : Transaction : : IndexHandle > & usedIndexes ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief findIndexHandleForAndNode <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + std : : pair < bool , bool > findIndexHandleForAndNode ( <nl> + std : : vector < std : : shared_ptr < Index > > indexes , arangodb : : aql : : AstNode * node , <nl> + arangodb : : aql : : Variable const * reference , <nl> + arangodb : : aql : : SortCondition const * sortCondition , <nl> + size_t itemsInCollection , <nl> + std : : vector < Transaction : : IndexHandle > & usedIndexes , <nl> + arangodb : : aql : : AstNode * & specializedCondition , <nl> + bool & isSparse ) const ; <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Get all indexes for a collection name , coordinator case <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / V8Server / V8Traverser . cpp <nl> ppp b / arangod / V8Server / V8Traverser . cpp <nl> bool DepthFirstTraverser : : EdgeGetter : : nextCursor ( std : : string const & startVertex , <nl> VPackValueLength * & last ) { <nl> while ( true ) { <nl> std : : string eColName ; <nl> - std : : string indexHandle ; <nl> + arangodb : : Transaction : : IndexHandle indexHandle ; <nl> if ( last ! = nullptr ) { <nl> / / The cursor is empty clean up <nl> last = nullptr ; <nl> mmm a / arangod / V8Server / V8Traverser . h <nl> ppp b / arangod / V8Server / V8Traverser . h <nl> struct OperationCursor ; <nl> namespace velocypack { <nl> class Slice ; <nl> } <nl> - <nl> - class Transaction ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class EdgeCollectionInfo { <nl> / / / @ brief index id <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - std : : string _indexId ; <nl> + arangodb : : Transaction : : IndexHandle _indexId ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Temporary builder for index search values <nl> mmm a / arangod / V8Server / v8 - query . cpp <nl> ppp b / arangod / V8Server / v8 - query . cpp <nl> static void JS_AllQuery ( v8 : : FunctionCallbackInfo < v8 : : Value > const & args ) { <nl> <nl> / / We directly read the entire cursor . so batchsize = = limit <nl> std : : shared_ptr < OperationCursor > opCursor = <nl> - trx . indexScan ( collectionName , Transaction : : CursorType : : ALL , " " , { } , skip , <nl> - limit , limit , false ) ; <nl> + trx . indexScan ( collectionName , Transaction : : CursorType : : ALL , <nl> + Transaction : : IndexHandle ( ) , { } , skip , limit , limit , false ) ; <nl> <nl> if ( opCursor - > failed ( ) ) { <nl> TRI_V8_THROW_EXCEPTION ( opCursor - > code ) ; <nl> mmm a / arangod / VocBase / Traverser . cpp <nl> ppp b / arangod / VocBase / Traverser . cpp <nl> bool arangodb : : traverser : : TraverserOptions : : getCollection ( <nl> <nl> bool arangodb : : traverser : : TraverserOptions : : getCollectionAndSearchValue ( <nl> size_t index , std : : string const & vertexId , std : : string & name , <nl> - std : : string & indexHandle , VPackBuilder & builder ) { <nl> + Transaction : : IndexHandle & indexHandle , VPackBuilder & builder ) { <nl> if ( index > = _collections . size ( ) ) { <nl> / / No more collections stop now <nl> return false ; <nl> mmm a / arangod / VocBase / Traverser . h <nl> ppp b / arangod / VocBase / Traverser . h <nl> struct TraverserOptions { <nl> arangodb : : Transaction * _trx ; <nl> std : : vector < std : : string > _collections ; <nl> std : : vector < TRI_edge_direction_e > _directions ; <nl> - std : : vector < std : : string > _indexHandles ; <nl> + std : : vector < arangodb : : Transaction : : IndexHandle > _indexHandles ; <nl> arangodb : : velocypack : : Builder _builder ; <nl> <nl> public : <nl> struct TraverserOptions { <nl> bool getCollection ( size_t const , std : : string & , TRI_edge_direction_e & ) const ; <nl> <nl> bool getCollectionAndSearchValue ( size_t , std : : string const & , std : : string & , <nl> - std : : string & , <nl> + arangodb : : Transaction : : IndexHandle & , <nl> arangodb : : velocypack : : Builder & ) ; <nl> } ; <nl> <nl>
Switch to IndexHandles .
arangodb/arangodb
c2049b8ee1fed53fa86278ccdac648d3fcfa7c8f
2016-03-23T07:57:00Z
mmm a / shell / utils . js <nl> ppp b / shell / utils . js <nl> if ( typeof _threadInject ! = " undefined " ) { <nl> " jstests / evalb . js " , <nl> " jstests / evald . js " , <nl> " jstests / evalf . js " , <nl> - " jstests / killop . js " , <nl> - " jstests / run_program1 . js " ] ) ; <nl> + " jstests / killop . js " , <nl> + " jstests / run_program1 . js " , <nl> + " jstests / notablescan . js " ] ) ; <nl> <nl> / / some tests can ' t be run in parallel with each other <nl> var serialTestsArr = [ " jstests / fsync . js " , <nl>
don ' t run notablescan tests in parallel suite
mongodb/mongo
3b7152d81bc6b30fa15bfd301d28924a33ac5dfe
2010-12-28T06:36:01Z
mmm a / src / lookup - inl . h <nl> ppp b / src / lookup - inl . h <nl> LookupIterator : : State LookupIterator : : LookupInHolder ( Map * const map , <nl> number_ = dict - > FindEntry ( name_ ) ; <nl> if ( number_ = = NameDictionary : : kNotFound ) return NOT_FOUND ; <nl> if ( holder - > IsGlobalObject ( ) ) { <nl> + DCHECK ( dict - > ValueAt ( number_ ) - > IsPropertyCell ( ) ) ; <nl> PropertyCell * cell = PropertyCell : : cast ( dict - > ValueAt ( number_ ) ) ; <nl> if ( cell - > value ( ) - > IsTheHole ( ) ) return NOT_FOUND ; <nl> } <nl> mmm a / src / lookup . cc <nl> ppp b / src / lookup . cc <nl> Handle < Object > LookupIterator : : FetchValue ( ) const { <nl> if ( holder_map_ - > is_dictionary_map ( ) ) { <nl> result = holder - > property_dictionary ( ) - > ValueAt ( number_ ) ; <nl> if ( holder_map_ - > IsGlobalObjectMap ( ) ) { <nl> + DCHECK ( result - > IsPropertyCell ( ) ) ; <nl> result = PropertyCell : : cast ( result ) - > value ( ) ; <nl> } <nl> } else if ( property_details_ . type ( ) = = v8 : : internal : : DATA ) { <nl> Handle < PropertyCell > LookupIterator : : GetPropertyCell ( ) const { <nl> Handle < JSObject > holder = GetHolder < JSObject > ( ) ; <nl> Handle < GlobalObject > global = Handle < GlobalObject > : : cast ( holder ) ; <nl> Object * value = global - > property_dictionary ( ) - > ValueAt ( dictionary_entry ( ) ) ; <nl> + DCHECK ( value - > IsPropertyCell ( ) ) ; <nl> return Handle < PropertyCell > ( PropertyCell : : cast ( value ) ) ; <nl> } <nl> <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> Handle < PropertyCell > GlobalObject : : EnsurePropertyCell ( <nl> PropertyCellType : : kUninitialized | | <nl> dictionary - > DetailsAt ( entry ) . cell_type ( ) = = <nl> PropertyCellType : : kDeleted ) ; <nl> + DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> cell = handle ( PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ) ; <nl> DCHECK ( cell - > value ( ) - > IsTheHole ( ) ) ; <nl> return cell ; <nl> static inline bool IsDeleted ( D d , int i ) { <nl> case DictionaryEntryType : : kObjects : <nl> return false ; <nl> case DictionaryEntryType : : kCells : <nl> + DCHECK ( d - > ValueAt ( i ) - > IsPropertyCell ( ) ) ; <nl> return PropertyCell : : cast ( d - > ValueAt ( i ) ) - > value ( ) - > IsTheHole ( ) ; <nl> } <nl> UNREACHABLE ( ) ; <nl> Handle < PropertyCell > PropertyCell : : InvalidateEntry ( <nl> Handle < NameDictionary > dictionary , int entry ) { <nl> Isolate * isolate = dictionary - > GetIsolate ( ) ; <nl> / / Swap with a copy . <nl> + DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> Handle < PropertyCell > cell ( PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ) ; <nl> auto new_cell = isolate - > factory ( ) - > NewPropertyCell ( ) ; <nl> new_cell - > set_value ( cell - > value ( ) ) ; <nl> Handle < Object > PropertyCell : : UpdateCell ( Handle < NameDictionary > dictionary , <nl> int entry , Handle < Object > value , <nl> PropertyDetails details ) { <nl> DCHECK ( ! value - > IsTheHole ( ) ) ; <nl> + DCHECK ( dictionary - > ValueAt ( entry ) - > IsPropertyCell ( ) ) ; <nl> Handle < PropertyCell > cell ( PropertyCell : : cast ( dictionary - > ValueAt ( entry ) ) ) ; <nl> const PropertyDetails original_details = dictionary - > DetailsAt ( entry ) ; <nl> / / Data accesses could be cached in ics or optimized code . <nl> mmm a / src / runtime / runtime - object . cc <nl> ppp b / src / runtime / runtime - object . cc <nl> RUNTIME_FUNCTION ( Runtime_KeyedGetProperty ) { <nl> ( dictionary - > DetailsAt ( entry ) . type ( ) = = DATA ) ) { <nl> Object * value = dictionary - > ValueAt ( entry ) ; <nl> if ( ! receiver - > IsGlobalObject ( ) ) return value ; <nl> + DCHECK ( value - > IsPropertyCell ( ) ) ; <nl> value = PropertyCell : : cast ( value ) - > value ( ) ; <nl> if ( ! value - > IsTheHole ( ) ) return value ; <nl> / / If value is the hole ( meaning , absent ) do the general lookup . <nl>
Add debug checks to catch PropertyCell : : cast failures .
v8/v8
87af6018249a085ec99b54990ffb93c7a1148dbd
2015-03-19T13:59:17Z
mmm a / api / tesseractmain . cpp <nl> ppp b / api / tesseractmain . cpp <nl> void PrintLangsList ( tesseract : : TessBaseAPI * api ) { <nl> api - > End ( ) ; <nl> } <nl> <nl> + void PrintBanner ( ) { <nl> + tprintf ( " Tesseract Open Source OCR Engine v % s with Leptonica \ n " , <nl> + tesseract : : TessBaseAPI : : Version ( ) ) ; <nl> + } <nl> + <nl> / * * <nl> * We have 2 possible sources of pagesegmode : a config file and <nl> * the command line . For backwards compatibility reasons , the <nl> void ParseArgs ( const int argc , char * * argv , <nl> PrintHelpMessage ( argv [ 0 ] ) ; <nl> exit ( 1 ) ; <nl> } <nl> - <nl> - if ( * outputbase ! = NULL & & strcmp ( * outputbase , " - " ) & & <nl> - strcmp ( * outputbase , " stdout " ) ) { <nl> - tprintf ( " Tesseract Open Source OCR Engine v % s with Leptonica \ n " , <nl> - tesseract : : TessBaseAPI : : Version ( ) ) ; <nl> - } <nl> } <nl> <nl> void PreloadRenderers ( tesseract : : TessBaseAPI * api , <nl> int main ( int argc , char * * argv ) { <nl> & list_langs , & print_parameters , <nl> & vars_vec , & vars_values , & arg_i , & pagesegmode ) ; <nl> <nl> + bool banner = false ; <nl> + if ( outputbase ! = NULL & & strcmp ( outputbase , " - " ) & & <nl> + strcmp ( outputbase , " stdout " ) ) { <nl> + banner = true ; <nl> + } <nl> + <nl> PERF_COUNT_START ( " Tesseract : main " ) <nl> tesseract : : TessBaseAPI api ; <nl> <nl> int main ( int argc , char * * argv ) { <nl> } <nl> <nl> if ( ! renderers . empty ( ) ) { <nl> + if ( banner ) PrintBanner ( ) ; <nl> bool succeed = api . ProcessPages ( image , NULL , 0 , renderers [ 0 ] ) ; <nl> if ( ! succeed ) { <nl> fprintf ( stderr , " Error during processing . \ n " ) ; <nl>
Merge pull request from amitdo / no - banner
tesseract-ocr/tesseract
976433820ccc37708ca6f9dbd0219329d2cb7607
2016-03-08T07:28:24Z
mmm a / toolsrc / src / vcpkg / base / system . cpp <nl> ppp b / toolsrc / src / vcpkg / base / system . cpp <nl> namespace vcpkg : : System <nl> L " USERPROFILE " , <nl> L " windir " , <nl> / / Enables proxy information to be passed to Curl , the underlying download library in cmake . exe <nl> - L " HTTP_PROXY " , <nl> - L " HTTPS_PROXY " , <nl> + L " http_proxy " , <nl> + L " https_proxy " , <nl> / / Enables find_package ( CUDA ) in CMake <nl> L " CUDA_PATH " , <nl> / / Environmental variable generated automatically by CUDA after installation <nl>
[ vcpkg ] http_proxy and https_proxy should be lowercase ( )
microsoft/vcpkg
bfac7b57161168b8b54ea159bbf2c88794098c1c
2018-02-16T12:25:12Z
mmm a / lib / IRGen / GenClass . cpp <nl> ppp b / lib / IRGen / GenClass . cpp <nl> namespace { <nl> IGM . getPointerAlignment ( ) , <nl> / * constant * / true , <nl> llvm : : GlobalVariable : : PrivateLinkage ) ; <nl> + <nl> switch ( IGM . TargetInfo . OutputObjectFormat ) { <nl> case llvm : : Triple : : MachO : <nl> var - > setSection ( " __DATA , __objc_const " ) ; <nl> break ; <nl> + case llvm : : Triple : : COFF : <nl> + var - > setSection ( " . data " ) ; <nl> + break ; <nl> case llvm : : Triple : : ELF : <nl> var - > setSection ( " . data " ) ; <nl> break ; <nl> mmm a / lib / IRGen / GenDecl . cpp <nl> ppp b / lib / IRGen / GenDecl . cpp <nl> void IRGenModule : : addLazyConformances ( NominalTypeDecl * Nominal ) { <nl> } <nl> } <nl> <nl> + std : : string IRGenModule : : GetObjCSectionName ( StringRef Section , <nl> + StringRef MachOAttributes ) { <nl> + assert ( Section . substr ( 0 , 2 ) = = " __ " & & " expected the name to begin with __ " ) ; <nl> + <nl> + switch ( TargetInfo . OutputObjectFormat ) { <nl> + case llvm : : Triple : : UnknownObjectFormat : <nl> + llvm_unreachable ( " must know the object file format " ) ; <nl> + case llvm : : Triple : : MachO : <nl> + return MachOAttributes . empty ( ) <nl> + ? ( " __DATA , " + Section ) . str ( ) <nl> + : ( " __DATA , " + Section + " , " + MachOAttributes ) . str ( ) ; <nl> + case llvm : : Triple : : ELF : <nl> + return Section . substr ( 2 ) . str ( ) ; <nl> + case llvm : : Triple : : COFF : <nl> + return ( " . " + Section . substr ( 2 ) + " $ B " ) . str ( ) ; <nl> + case llvm : : Triple : : Wasm : <nl> + error ( SourceLoc ( ) , " wasm is not a supported object file format " ) ; <nl> + } <nl> + <nl> + llvm_unreachable ( " unexpected object file format " ) ; <nl> + } <nl> + <nl> + void IRGenModule : : SetCStringLiteralSection ( llvm : : GlobalVariable * GV , <nl> + ObjCLabelType Type ) { <nl> + switch ( TargetInfo . OutputObjectFormat ) { <nl> + case llvm : : Triple : : UnknownObjectFormat : <nl> + llvm_unreachable ( " must know the object file format " ) ; <nl> + case llvm : : Triple : : MachO : <nl> + switch ( Type ) { <nl> + case ObjCLabelType : : ClassName : <nl> + GV - > setSection ( " __TEXT , __objc_classname , cstring_literals " ) ; <nl> + return ; <nl> + case ObjCLabelType : : MethodVarName : <nl> + GV - > setSection ( " __TEXT , __objc_methname , cstring_literals " ) ; <nl> + return ; <nl> + case ObjCLabelType : : MethodVarType : <nl> + GV - > setSection ( " __TEXT , __objc_methtype , cstring_literals " ) ; <nl> + return ; <nl> + case ObjCLabelType : : PropertyName : <nl> + GV - > setSection ( " __TEXT , __cstring , cstring_literals " ) ; <nl> + return ; <nl> + } <nl> + case llvm : : Triple : : ELF : <nl> + return ; <nl> + case llvm : : Triple : : COFF : <nl> + return ; <nl> + case llvm : : Triple : : Wasm : <nl> + error ( SourceLoc ( ) , " wasm is not a supported object file format " ) ; <nl> + return ; <nl> + } <nl> + <nl> + llvm_unreachable ( " unexpected object file format " ) ; <nl> + } <nl> + <nl> void IRGenModule : : emitGlobalLists ( ) { <nl> if ( ObjCInterop ) { <nl> - assert ( TargetInfo . OutputObjectFormat = = llvm : : Triple : : MachO ) ; <nl> / / Objective - C class references go in a variable with a meaningless <nl> / / name but a magic section . <nl> emitGlobalList ( * this , ObjCClasses , " objc_classes " , <nl> - " __DATA , __objc_classlist , regular , no_dead_strip " , <nl> - llvm : : GlobalValue : : InternalLinkage , <nl> - Int8PtrTy , <nl> - false ) ; <nl> + GetObjCSectionName ( " __objc_classlist " , <nl> + " regular , no_dead_strip " ) , <nl> + llvm : : GlobalValue : : InternalLinkage , Int8PtrTy , false ) ; <nl> + <nl> / / So do categories . <nl> emitGlobalList ( * this , ObjCCategories , " objc_categories " , <nl> - " __DATA , __objc_catlist , regular , no_dead_strip " , <nl> - llvm : : GlobalValue : : InternalLinkage , <nl> - Int8PtrTy , <nl> - false ) ; <nl> + GetObjCSectionName ( " __objc_catlist " , <nl> + " regular , no_dead_strip " ) , <nl> + llvm : : GlobalValue : : InternalLinkage , Int8PtrTy , false ) ; <nl> <nl> / / Emit nonlazily realized class references in a second magic section to make <nl> / / sure they are realized by the Objective - C runtime before any instances <nl> / / are allocated . <nl> emitGlobalList ( * this , ObjCNonLazyClasses , " objc_non_lazy_classes " , <nl> - " __DATA , __objc_nlclslist , regular , no_dead_strip " , <nl> - llvm : : GlobalValue : : InternalLinkage , <nl> - Int8PtrTy , <nl> - false ) ; <nl> + GetObjCSectionName ( " __objc_nlclslist " , <nl> + " regular , no_dead_strip " ) , <nl> + llvm : : GlobalValue : : InternalLinkage , Int8PtrTy , false ) ; <nl> } <nl> <nl> / / @ llvm . used <nl> Address IRGenModule : : getAddrOfObjCClassRef ( ClassDecl * theClass ) { <nl> / / Define it lazily . <nl> if ( auto global = dyn_cast < llvm : : GlobalVariable > ( addr ) ) { <nl> if ( global - > isDeclaration ( ) ) { <nl> - global - > setSection ( " __DATA , __objc_classrefs , regular , no_dead_strip " ) ; <nl> + global - > setSection ( GetObjCSectionName ( " __objc_classrefs " , <nl> + " regular , no_dead_strip " ) ) ; <nl> global - > setLinkage ( llvm : : GlobalVariable : : PrivateLinkage ) ; <nl> global - > setExternallyInitialized ( true ) ; <nl> global - > setInitializer ( getAddrOfObjCClass ( theClass , NotForDefinition ) ) ; <nl> mmm a / lib / IRGen / GenMeta . cpp <nl> ppp b / lib / IRGen / GenMeta . cpp <nl> void irgen : : emitClassMetadata ( IRGenModule & IGM , ClassDecl * classDecl , <nl> bool isIndirect = false ; <nl> <nl> StringRef section { } ; <nl> - if ( classDecl - > isObjC ( ) ) <nl> + if ( classDecl - > isObjC ( ) & & <nl> + IGM . TargetInfo . OutputObjectFormat = = llvm : : Triple : : MachO ) <nl> section = " __DATA , __objc_data , regular " ; <nl> <nl> auto var = IGM . defineTypeMetadata ( declaredType , isIndirect , isPattern , <nl> mmm a / lib / IRGen / GenObjC . cpp <nl> ppp b / lib / IRGen / GenObjC . cpp <nl> llvm : : Constant * IRGenModule : : getAddrOfObjCMethodName ( StringRef selector ) { <nl> llvm : : GlobalValue : : PrivateLinkage , <nl> init , <nl> llvm : : Twine ( " \ 01L_selector_data ( " ) + selector + " ) " ) ; <nl> - global - > setSection ( " __TEXT , __objc_methname , cstring_literals " ) ; <nl> + SetCStringLiteralSection ( global , ObjCLabelType : : MethodVarName ) ; <nl> global - > setAlignment ( 1 ) ; <nl> addCompilerUsedGlobal ( global ) ; <nl> <nl> llvm : : Constant * IRGenModule : : getAddrOfObjCSelectorRef ( StringRef selector ) { <nl> global - > setAlignment ( getPointerAlignment ( ) . getValue ( ) ) ; <nl> <nl> / / This section name is magical for the Darwin static and dynamic linkers . <nl> - global - > setSection ( " __DATA , __objc_selrefs , literal_pointers , no_dead_strip " ) ; <nl> + global - > setSection ( GetObjCSectionName ( " __objc_selrefs " , <nl> + " literal_pointers , no_dead_strip " ) ) ; <nl> <nl> / / Make sure that this reference does not get optimized away . <nl> addCompilerUsedGlobal ( global ) ; <nl> IRGenModule : : getObjCProtocolGlobalVars ( ProtocolDecl * proto ) { <nl> + protocolName ) ; <nl> protocolLabel - > setAlignment ( getPointerAlignment ( ) . getValue ( ) ) ; <nl> protocolLabel - > setVisibility ( llvm : : GlobalValue : : HiddenVisibility ) ; <nl> - protocolLabel - > setSection ( " __DATA , __objc_protolist , coalesced , no_dead_strip " ) ; <nl> - <nl> + protocolLabel - > setSection ( GetObjCSectionName ( " __objc_protolist " , <nl> + " coalesced , no_dead_strip " ) ) ; <nl> + <nl> / / Introduce a variable to reference the protocol . <nl> - auto * protocolRef <nl> - = new llvm : : GlobalVariable ( Module , Int8PtrTy , <nl> - / * constant * / false , <nl> + auto * protocolRef = <nl> + new llvm : : GlobalVariable ( Module , Int8PtrTy , / * constant * / false , <nl> llvm : : GlobalValue : : WeakAnyLinkage , <nl> protocolRecord , <nl> - llvm : : Twine ( " \ 01l_OBJC_PROTOCOL_REFERENCE_ $ _ " ) <nl> - + protocolName ) ; <nl> + llvm : : Twine ( " \ 01l_OBJC_PROTOCOL_REFERENCE_ $ _ " ) + protocolName ) ; <nl> protocolRef - > setAlignment ( getPointerAlignment ( ) . getValue ( ) ) ; <nl> protocolRef - > setVisibility ( llvm : : GlobalValue : : HiddenVisibility ) ; <nl> - protocolRef - > setSection ( " __DATA , __objc_protorefs , coalesced , no_dead_strip " ) ; <nl> + protocolRef - > setSection ( GetObjCSectionName ( " __objc_protorefs " , <nl> + " coalesced , no_dead_strip " ) ) ; <nl> <nl> ObjCProtocolPair pair { protocolRecord , protocolRef } ; <nl> ObjCProtocols . insert ( { proto , pair } ) ; <nl> mmm a / lib / IRGen / IRGenModule . h <nl> ppp b / lib / IRGen / IRGenModule . h <nl> class IRGenModule { <nl> Size getAtomicBoolSize ( ) const { return AtomicBoolSize ; } <nl> Alignment getAtomicBoolAlignment ( ) const { return AtomicBoolAlign ; } <nl> <nl> + enum class ObjCLabelType { <nl> + ClassName , <nl> + MethodVarName , <nl> + MethodVarType , <nl> + PropertyName , <nl> + } ; <nl> + <nl> + std : : string GetObjCSectionName ( StringRef Section , StringRef MachOAttributes ) ; <nl> + void SetCStringLiteralSection ( llvm : : GlobalVariable * GV , ObjCLabelType Type ) ; <nl> + <nl> private : <nl> Size PtrSize ; <nl> Size AtomicBoolSize ; <nl> new file mode 100644 <nl> index 000000000000 . . 40c04e277ccd <nl> mmm / dev / null <nl> ppp b / test / IRGen / Inputs / usr / include / ObjCInterop . h <nl> <nl> + <nl> + @ protocol P <nl> + @ optional <nl> + - ( void ) method ; <nl> + @ end <nl> + <nl> + @ interface I <nl> + - ( instancetype _Nonnull ) init ; <nl> + @ end <nl> + <nl> + I * _Nonnull f ( I * _Nonnull ) ; <nl> + <nl> mmm a / test / IRGen / Inputs / usr / include / module . map <nl> ppp b / test / IRGen / Inputs / usr / include / module . map <nl> module Foundation { <nl> module CoreFoundation { <nl> header " BridgeTestCoreFoundation . h " <nl> } <nl> + <nl> + module ObjCInterop { <nl> + header " ObjCInterop . h " <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 77107aaf10d3 <nl> mmm / dev / null <nl> ppp b / test / IRGen / objc - sections . swift <nl> <nl> + / / RUN : % swift - target x86_64 - unknown - windows - msvc - parse - stdlib - enable - objc - interop - disable - objc - attr - requires - foundation - module - I % S / Inputs / usr / include - emit - ir % s - o - | % FileCheck % s - check - prefix CHECK - COFF <nl> + / / RUN : % swift - target x86_64 - unknown - linux - gnu - parse - stdlib - enable - objc - interop - disable - objc - attr - requires - foundation - module - I % S / Inputs / usr / include - Xcc - - sysroot = / var / empty - emit - ir % s - o - | % FileCheck % s - check - prefix CHECK - ELF <nl> + / / RUN : % swift - target x86_64 - apple - ios - parse - stdlib - enable - objc - interop - disable - objc - attr - requires - foundation - module - I % S / Inputs / usr / include - emit - ir % s - o - | % FileCheck % s - check - prefix CHECK - MACHO <nl> + <nl> + import ObjCInterop <nl> + <nl> + @ objc <nl> + class C { <nl> + } <nl> + <nl> + extension C : P { <nl> + public func method ( ) { <nl> + f ( I ( ) ) <nl> + } <nl> + } <nl> + <nl> + @ objc_non_lazy_realization <nl> + class D { <nl> + } <nl> + <nl> + / / CHECK - COFF - NOT : @ _T04main1CCMf = { { . * } } , section " __DATA , __objc_data , regular " <nl> + / / CHECK - COFF : @ " \ 01l_OBJC_LABEL_PROTOCOL_ $ _P " = { { . * } } , section " . objc_protolist $ B " <nl> + / / CHECK - COFF : @ " \ 01l_OBJC_PROTOCOL_REFERENCE_ $ _P " = { { . * } } , section " . objc_protorefs $ B " <nl> + / / CHECK - COFF : @ " OBJC_CLASS_REF_ $ _I " = { { . * } } , section " . objc_classrefs $ B " <nl> + / / CHECK - COFF : @ " \ 01L_selector ( init ) " = { { . * } } , section " . objc_selrefs $ B " <nl> + / / CHECK - COFF : @ objc_classes = { { . * } } , section " . objc_classlist $ B " <nl> + / / CHECK - COFF : @ objc_categories = { { . * } } , section " . objc_catlist $ B " <nl> + / / CHECK - COFF : @ objc_non_lazy_classes = { { . * } } , section " . objc_nlclslist $ B " <nl> + <nl> + / / CHECK - ELF - NOT : @ _T04main1CCMf = { { . * } } , section " __DATA , __objc_data , regular " <nl> + / / CHECK - ELF : @ " \ 01l_OBJC_LABEL_PROTOCOL_ $ _P " = { { . * } } , section " objc_protolist " <nl> + / / CHECK - ELF : @ " \ 01l_OBJC_PROTOCOL_REFERENCE_ $ _P " = { { . * } } , section " objc_protorefs " , align 8 <nl> + / / CHECK - ELF : @ " OBJC_CLASS_REF_ $ _I " = { { . * } } , section " objc_classrefs " , align 8 <nl> + / / CHECK - ELF : @ " \ 01L_selector ( init ) " = { { . * } } , section " objc_selrefs " <nl> + / / CHECK - ELF : @ objc_classes = { { . * } } , section " objc_classlist " <nl> + / / CHECK - ELF : @ objc_categories = { { . * } } , section " objc_catlist " <nl> + / / CHECK - ELF : @ objc_non_lazy_classes = { { . * } } , section " objc_nlclslist " , align 8 <nl> + <nl> + / / CHECK - MACHO : @ _T04main1CCMf = { { . * } } , section " __DATA , __objc_data , regular " <nl> + / / CHECK - MACHO : @ " \ 01l_OBJC_LABEL_PROTOCOL_ $ _P " = { { . * } } , section " __DATA , __objc_protolist , coalesced , no_dead_strip " <nl> + / / CHECK - MACHO : @ " \ 01l_OBJC_PROTOCOL_REFERENCE_ $ _P " = { { . * } } , section " __DATA , __objc_protorefs , coalesced , no_dead_strip " <nl> + / / CHECK - MACHO : @ " OBJC_CLASS_REF_ $ _I " = { { . * } } , section " __DATA , __objc_classrefs , regular , no_dead_strip " <nl> + / / CHECK - MACHO : @ " \ 01L_selector ( init ) " = { { . * } } , section " __DATA , __objc_selrefs , literal_pointers , no_dead_strip " <nl> + / / CHECK - MACHO : @ objc_classes = { { . * } } , section " __DATA , __objc_classlist , regular , no_dead_strip " <nl> + / / CHECK - MACHO : @ objc_categories = { { . * } } , section " __DATA , __objc_catlist , regular , no_dead_strip " <nl> + / / CHECK - MACHO : @ objc_non_lazy_classes = { { . * } } , section " __DATA , __objc_nlclslist , regular , no_dead_strip " <nl> + <nl> mmm a / test / IRGen / objc_subclass . swift <nl> ppp b / test / IRGen / objc_subclass . swift <nl> <nl> / / CHECK - 64 : ] } <nl> <nl> <nl> - / / CHECK : @ objc_classes = internal global [ 2 x i8 * ] [ i8 * bitcast ( % swift . type * @ _T013objc_subclass10SwiftGizmoCN to i8 * ) , i8 * bitcast ( % swift . type * @ _T013objc_subclass11SwiftGizmo2CN to i8 * ) ] , section " __DATA , __objc_classlist , regular , no_dead_strip " , align [ [ WORD_SIZE_IN_BYTES ] ] <nl> + / / CHECK : @ objc_classes = internal global [ 2 x i8 * ] [ i8 * bitcast ( % swift . type * @ _T013objc_subclass10SwiftGizmoCN to i8 * ) , i8 * bitcast ( % swift . type * @ _T013objc_subclass11SwiftGizmo2CN to i8 * ) ] , section " __DATA , __objc_classlist , regular , no_dead_strip " , align [ [ WORD_SIZE_IN_BYTES ] ] <nl> <nl> - / / CHECK : @ objc_non_lazy_classes = internal global [ 1 x i8 * ] [ i8 * bitcast ( % swift . type * @ _T013objc_subclass11SwiftGizmo2CN to i8 * ) ] , section " __DATA , __objc_nlclslist , regular , no_dead_strip " , align [ [ WORD_SIZE_IN_BYTES ] ] <nl> + / / CHECK : @ objc_non_lazy_classes = internal global [ 1 x i8 * ] [ i8 * bitcast ( % swift . type * @ _T013objc_subclass11SwiftGizmo2CN to i8 * ) ] , section " __DATA , __objc_nlclslist , regular , no_dead_strip " , align [ [ WORD_SIZE_IN_BYTES ] ] <nl> <nl> import Foundation <nl> import gizmo <nl> mmm a / test / IRGen / subclass . swift <nl> ppp b / test / IRGen / subclass . swift <nl> <nl> / / CHECK : i64 ( [ [ B ] ] * ) * @ _T08subclass1BC1fSiyF , <nl> / / CHECK : [ [ A ] ] * ( [ [ TYPE ] ] * ) * @ _T08subclass1AC1gACyFZ <nl> / / CHECK : } > <nl> - / / CHECK : @ objc_classes = internal global [ 2 x i8 * ] [ i8 * { { . * } } @ _T08subclass1ACN { { . * } } , i8 * { { . * } } @ _T08subclass1BCN { { . * } } ] , section " __DATA , __objc_classlist , regular , no_dead_strip " , align 8 <nl> + / / CHECK : @ objc_classes = internal global [ 2 x i8 * ] [ i8 * { { . * } } @ _T08subclass1ACN { { . * } } , i8 * { { . * } } @ _T08subclass1BCN { { . * } } ] , section " __DATA , __objc_classlist , regular , no_dead_strip " , align 8 <nl> <nl> class A { <nl> var x = 0 <nl>
Merge pull request from compnerd / objc - irgen
apple/swift
d9ce520bb8e906b04fbf817deab2444c9aed5f93
2017-12-04T00:47:50Z
mmm a / modules / bridge / common / BUILD <nl> ppp b / modules / bridge / common / BUILD <nl> cc_library ( <nl> name = " bridge_gflags " , <nl> srcs = [ " bridge_gflags . cc " ] , <nl> hdrs = [ " bridge_gflags . h " ] , <nl> + deps = [ <nl> + " @ com_github_gflags_gflags / / : gflags " , <nl> + ] , <nl> ) <nl> <nl> cc_library ( <nl> mmm a / modules / perception / fusion / base / BUILD <nl> ppp b / modules / perception / fusion / base / BUILD <nl> cc_library ( <nl> " / / modules / perception / base : frame " , <nl> " / / modules / perception / common / sensor_manager " , <nl> " / / modules / perception / lib / thread " , <nl> + " @ com_google_googletest / / : gtest " , <nl> ] , <nl> ) <nl> <nl> cc_library ( <nl> hdrs = [ " track . h " ] , <nl> deps = [ <nl> " : sensor " , <nl> + " @ com_google_googletest / / : gtest " , <nl> ] , <nl> ) <nl> <nl> mmm a / modules / perception / lidar / common / BUILD <nl> ppp b / modules / perception / lidar / common / BUILD <nl> cc_library ( <nl> " / / cyber " , <nl> " / / modules / perception / base : object " , <nl> " / / modules / perception / lidar / common " , <nl> + " @ com_google_googletest / / : gtest " , <nl> ] , <nl> ) <nl> <nl> mmm a / modules / perception / lidar / lib / segmentation / cnnseg / BUILD <nl> ppp b / modules / perception / lidar / lib / segmentation / cnnseg / BUILD <nl> cc_library ( <nl> " : util " , <nl> " / / modules / perception / base " , <nl> " / / modules / perception / lidar / lib / segmentation / cnnseg / proto : cnnseg_param_proto " , <nl> + " @ com_google_googletest / / : gtest " , <nl> " @ eigen " , <nl> ] , <nl> ) <nl> mmm a / modules / planning / open_space / coarse_trajectory_generator / BUILD <nl> ppp b / modules / planning / open_space / coarse_trajectory_generator / BUILD <nl> cc_library ( <nl> hdrs = [ " hybrid_a_star . h " ] , <nl> copts = [ " - DMODULE_NAME = \ \ \ " planning \ \ \ " " ] , <nl> deps = [ <nl> - " open_space_utils " , <nl> + " : open_space_utils " , <nl> " / / cyber / common : log " , <nl> " / / modules / common / configs : vehicle_config_helper " , <nl> " / / modules / planning / common : obstacle " , <nl> cc_test ( <nl> size = " small " , <nl> srcs = [ " reeds_shepp_path_test . cc " ] , <nl> deps = [ <nl> - " open_space_utils " , <nl> + " : open_space_utils " , <nl> " / / cyber / common : log " , <nl> " / / modules / common / configs : vehicle_config_helper " , <nl> " / / modules / common / math " , <nl> cc_test ( <nl> size = " small " , <nl> srcs = [ " node3d_test . cc " ] , <nl> deps = [ <nl> - " open_space_utils " , <nl> + " : open_space_utils " , <nl> " / / cyber / common : log " , <nl> " @ com_google_googletest / / : gtest_main " , <nl> ] , <nl> cc_test ( <nl> size = " small " , <nl> srcs = [ " hybrid_a_star_test . cc " ] , <nl> deps = [ <nl> - " hybrid_a_star " , <nl> + " : hybrid_a_star " , <nl> " @ com_google_googletest / / : gtest_main " , <nl> ] , <nl> ) <nl> mmm a / modules / prediction / common / BUILD <nl> ppp b / modules / prediction / common / BUILD <nl> cc_library ( <nl> name = " prediction_gflags " , <nl> srcs = [ " prediction_gflags . cc " ] , <nl> hdrs = [ " prediction_gflags . h " ] , <nl> + deps = [ <nl> + " @ com_github_gflags_gflags / / : gflags " , <nl> + ] , <nl> ) <nl> <nl> cc_library ( <nl> name = " prediction_system_gflags " , <nl> srcs = [ " prediction_system_gflags . cc " ] , <nl> hdrs = [ " prediction_system_gflags . h " ] , <nl> + deps = [ <nl> + " @ com_github_gflags_gflags / / : gflags " , <nl> + ] , <nl> ) <nl> <nl> cc_library ( <nl>
Bazel : Fix implicit dependencies .
ApolloAuto/apollo
46bd0c7d77cfa8e5768b9a761b652f814c470034
2020-01-31T19:43:15Z
mmm a / code / data_structures / src / queue / queue_using_stack / queue_using_stack . c <nl> ppp b / code / data_structures / src / queue / queue_using_stack / queue_using_stack . c <nl> pop ( stack * S ) <nl> return ( S - > A [ S - > top - - ] ) ; <nl> } <nl> <nl> + void <nl> + deleteStack ( stack * S ) <nl> + { <nl> + free ( S - > A ) ; <nl> + free ( S ) ; <nl> + } <nl> + <nl> + void <nl> + deleteQueue ( queue * Q ) <nl> + { <nl> + free ( Q - > S1 ) ; <nl> + free ( Q - > S2 ) ; <nl> + free ( Q ) ; <nl> + } <nl> + <nl> / * QUEUE * / <nl> queue * <nl> createQueue ( stack * S1 , stack * S2 ) <nl> dequeue ( queue * Q ) <nl> } <nl> <nl> <nl> - <nl> / * driver program * / <nl> int <nl> main ( ) <nl> main ( ) <nl> printf ( " % d \ n " , dequeue ( Q ) ) ; <nl> printf ( " % d \ n " , dequeue ( Q ) ) ; <nl> / * Current appearance of Q : | 8 | * / <nl> + deleteQueue ( Q ) ; <nl> return 0 ; <nl> } <nl>
deleteQueue function
OpenGenus/cosmos
73a90feb9d1886730556f8f889d95106fbc1ab5c
2019-03-01T17:59:15Z
new file mode 100644 <nl> index 000000000000 . . 2b5acc82aa47 <nl> mmm / dev / null <nl> ppp b / contrib / gitian - keys / sjors - key . pgp <nl> <nl> + mmm - - BEGIN PGP PUBLIC KEY BLOCKmmm - - <nl> + <nl> + mQINBFWSwMoBEADG31O8 + ex + xpgzVKQgF4iVRE5uBPT0 + GM6FnwqIIhXVKiBLQh8 <nl> + YDhhgk6joh + vsLrFzKZ9kXwoiHN8y / AiNCQ0xjAUdpznD5xvHAaGIAlT / sodRNT + <nl> + 869WgT9G1uiVp0P4ucEeilmhCn9o51LqkS3roXkj0ec52b1pslUl2WKdu1ZD + Bj4 <nl> + 3 / oVZm7mmjkDwl0RHJQmqlK0bunq0jlVlgH5sdQfmLbCZaq3LhVPf73zt5qHH + J6 <nl> + ZbU7A4cqm2eN5SyH + Nno + cq3 + vXmvVI + x / jPe / dPDCXaGWf5fWI / Lbk / mMP7JAl1 <nl> + 6X44CN + hZHUnNuzeZt2 / ROWZ0s0JJcjQkSe9noUQedjBAHX82s886vsFzOHvDtul <nl> + EuV / XAjUlkhMbhZkZaIq9ucqHmUBI4 + OcFEIbbKc9TrKtJe + CYuWTNlomVk / iFr8 <nl> + zSm / S64NiqKi / BeQGgcsDZIaJDYfDP83esOOaaxFswHnJNtHnU1PwntrJtXft0dK <nl> + ydtlQZ6r96SYxLDTeGfC2SNk0zbnKAGvjj04vzQeN + JSRZ75tNKmgdbJdNL8wvPh <nl> + 879TpCwMhNDvSRG + YqCe6whaJV76a + Doxg48HCJYaj6bnRn41 / QGJEyL31I8l / 7S <nl> + YsLLmAEbqwG7erYi7WZS3cRrGJI8RwohGMZf7yraqoaOgMKmtE / Sq0tLtwARAQAB <nl> + tCNTam9ycyBQcm92b29zdCA8c2pvcnNAc3Byb3Zvb3N0Lm5sPokCQAQTAQoAKgIb <nl> + AwUJB4YfgAULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAUCWWXcoAIZAQAKCRBX / 5vb <nl> + zDAQCeYJD / 47XDMfEMg4g4spo7k92XsNkvjlAhWvvxd + kxow / V8c64WQXody32FZ <nl> + HRSmK8dVjf9mIJMKkX4lpKpim7cQxsdTcorcdu + yk4TK + Wah61vsMhbSSllfHs1U <nl> + + q8jYMGnXTD + CY0aeTMrTfJcR2yN98jmNSWIL1qWmJ51RSTL6BQKb6eYtR7pWRkW <nl> + uMR6oFC09Db4fiKa4zhH81 + / t0g + 6pMY391gSluaS + OfNqGORCo + / IdG5IDzh5Vp <nl> + f19qXjd5oMsZQf6 / P4b4XUktgl8RVRcNzdYGoXpcd8LpeHtEOh5I93ODmCwqd67b <nl> + YDlhDNN7iGhPndPEF6P4CNO / rXLPCZyMhRyt1dflu0KPCr + 0AgR31cdhH / p7eCyj <nl> + FTE9gUgUHOG9OHdRoVXrwHYXwAiDBr2pp2giLpBsAwa4d2hXNDJ6wfMMCSOXKQlS <nl> + lHq06y / v / 049DammkqW0XnEsU4qvsdteZ0jQu7Ob3LyGoytBIj8fn1OioT21W7wc <nl> + ns3 / Tt4cQsn2ICBYB4PzqwkvGUp7fDwwHYw7rq6kvCEVDUDWMtVgQ8kjsh2OoU75 <nl> + eeteM1Q1fV06Wfn2Qct9bn0NKRGrA8mm3lrCWYCeGqJeBvC6kna1QgV53vYRLJod <nl> + w3Ql4 + M9tUIi9uiGLvVaGZWO9wU1EwL + EAO + 6D85h6QiJN7H8gcwUokCPQQTAQoA <nl> + JwUCVZLAygIbAwUJB4YfgAULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRBX / 5vb <nl> + zDAQCauuD / 9IDWhf / fTseA1Rt5i4gwK + 8dCQjTlRS2cZtGc2aMX8w5XruDWnna1P <nl> + Mj / aVUncDrprRx9rxgEqIDyPheuJ6r7v6D8GjrpAjcG / BPNFtPaxQccbZbAYdzoj <nl> + Rrs + ttVIqS + wO7qLmQkKA4oGRMmgYh3VX8EBZNcvxaGCcJx0PfoqS8cPXTnCRHcg <nl> + Wx6kaFyuWtrTX + kCpDraB1KGtxedR4rzuOtUOLoqFOOfsQuOxPlKNNr9Zjc8x2o4 <nl> + 5TtwbuoEog8FIEttY6NOywpsSsvYvNB4gq1fxO49H0pQopmJlOMatMH6IRT7BJJZ <nl> + cOoHOh4X / zItOJZtuCOT4u + Y2XOuyLcW83X5ymIR3ZCxedsLzjyiCWm61 / znJVON <nl> + Ws8I + gShbvauahBCB9rOHqwM0QioJMc36hUPB21KghQS8RJpGwmtk1WhFFMtAsSJ <nl> + w + wRfy2d6u + lSGdlA + 2hEyKVm / DNQMDCQVFx3lQ6YBwAwkSiLMylrPKvs56fUjRr <nl> + 74qoPyDxuRMC + q + TThHsy5O9r31G + Dc3 + H5k4iTk354Jshjltx / k2O732e9Vxyar <nl> + / U5P7UZqHHuJKXDihUFrcJZq + gk8sGEWzGG / wocce7ezrTnHqR8YA04BTA4PXQqZ <nl> + 4N42f422YYGIH / 3Nm6drQkbigekLw6wx + NrxtTsYg4eCtSsaUd / RjLQhU2pvcnMg <nl> + UHJvdm9vc3QgPHNqb3JzQGZyZWVkb20ubmw + iQI9BBMBCgAnBQJZZdyfAhsDBQkH <nl> + hh + ABQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJEFf / m9vMMBAJEsIQAK4ihgRB <nl> + 05QqETpWNeV / XSGBHQINuwwEDz / k8dAJ5Uo6OoSpDULa16fs / EgAV46wTSxfWuci <nl> + n2Fc1AWLeLDWOax / NlycL00VDHEwT2PCjcc5uMuwR4RUTciKyByT1u7BFToZ6PyL <nl> + mbU6u6whcQejl6Ci2kw0Mu4n4bKTS7OL4 / w / EbdfMSpRi8wWmTPMB / aMjtS2Mxi / <nl> + N + yQhJ9pReHADeCBoAjq0cUy + QbzvBwDCK4XWRzF7kiFuA7UW2r7 / dX6l31mPfi / <nl> + GLA5 + ftPxJ6EH8cxToF70OWiSfhOTleaqZaHUOG0V7wV2lr / bwAYzpVlxeZSCIta <nl> + lAA9ZLzUD2hiHYcei6kc / YjIhmlml7O0FK1eBk7 + bt5wr0nvWt4Lbha4y5LxBX8C <nl> + d7InvB3xUYHz + S5Ul4vp0Rzx97MBL4oX2ltBEDpc1CcOgzv4dcWMG9bbh9 / SaI / G <nl> + RehAzwkbpVUl9AEUNKO0dNlZUdu8CkehHdPdz5sJyS / 9zE0A7yIECDFP9Nrht0nK <nl> + MahBijm4K + jOiLOZ2xyfOX1pVWLqIXGQHKjfcD3oI3qvGrQYtxB5Dffb9ACFMpZO <nl> + z3jM8h2UAa2 / KqA4MZiZG9N6uWHKkIAMMuXWs1s439WePvbQ + 5aw / qPUAMyqA3XZ <nl> + dkfn8QWaJPR4nRM + McYBYuS4fKK9HRJWQgcQuQINBFWSwMoBEACzmkabZ8oHWJUE <nl> + beU7rJF / TMbwV1IFtFxJ / QlY8rE4VnHekPMvkLi / gjx3WY5nmMe + d4JYoK / uPNdt <nl> + y5u0QYgH2MB / jebk4gYXCAHIPpU38h9UgHRb6qV8OaqHhmoXvKwyz + 1QPzyJpmgg <nl> + oCUN + OAroNjl7zhunE7w7EEddFQftfPoGKEUnTjv84QOCuAb46JsYyiNAc3h6okq <nl> + 74hY7PKCv8IRGclMPjemhBT2LEenn1t4yi7a8W / hjIe44PmQiqQEXR17keqcP / ls <nl> + EH9xSST1v / 70ieiPqb6zbHGWzjQxqpFUJxRU6OluBCy5pHVd8wfFGYrrbTpoxaUC <nl> + jyA2SLr1oZZ9gaGprt6X7FC5gpE5LV9essq3O5wwvoPbyMe1F5uFaxIPhlt55oEu <nl> + rwVWecFJ8tSjniF / WSkTcILrOmiQZ4mylXfOP9Wk38seZReCs799KEfKFlXHk89a <nl> + Sj3ZvaJQxwVCnvsAsbVKmmHZ5wPt + G2KfhOkkv2A1I / UyeTT7aXvt2vxDqGuG0su <nl> + Eo6QknM / 2Sr5Uv7BwBeSIQ6llH5ZnqKz34 + HjriP8YPWzvsC959GXsxS01dCSvUM <nl> + 92j5PvTZzf5dt1CWHMeufAY5XIH + nftkRniuScRhJ7xK3tJ7wngg7UvdeZwJWqmK <nl> + lJ7GI38V8HIMnd2x28yiGpj1ue6T + QARAQABiQIlBBgBCgAPBQJVksDKAhsMBQkH <nl> + hh + AAAoJEFf / m9vMMBAJjeIP / 1UBCi6gSXzpGJBLD2u4PcZJjXBJAImZdf1aCqfS <nl> + YZBCaA65UrM3uaVa7h8MGAJc9kDjpqHurjDmG3YWf33KvHWYmReQvX43pZmfF12s <nl> + X7FZgcCfgZJKKj + ri6oHQonZzUMrecEcAJLLaQoD3Du3iZpETiyRLL7sJ1lZSaCJ <nl> + gYKnN4WV5GypvdFvb8vSUBST2h0D6AewGKMNh8ruRlkIxI + YSlywgYIH + O0qNKqW <nl> + wBlZc / 5f + JZ3hu + cjx / + Zn + w + saIb6SgySg0UzN35b2WM2YzrfQep4ah3NIxuC7e <nl> + qzmfV6GnRtuUrBLVJ8qyjif1JSM9tZfinnmAB4 / U5Qfc + YYViIXMTljmHWvbokas <nl> + tTBfVAw74yWnkv4ZuXf5SkTmGwEMJUOat0TSr085Ck5y394bRepdI1Y + 1cdqpwMQ <nl> + QmkKyvcBlREQ7Xk1UnDDR3o / 2ieVuGGHRp8jmoWBWGq4Cm43fYOlVe + PcaX0tDns <nl> + Tmmh2uwEU / TXe5qGil51OlSM7qhAMqhWUIYphSOcdvApNXuiWMfnTdjsNygE4HVh <nl> + Jq4efJ / nlx5N + PNAK2GpzeUJQGyxiVsXybq + h8UlvytBsdz1X6ZYzBv1yYwANThU <nl> + rMB1s4tMaEugX0aNByLcsxuS4ixd2qzwkYVz25Aeko / U1v2 / j2cIRtrTNgja3BKE <nl> + N5Ug <nl> + = 80Es <nl> + mmm - - END PGP PUBLIC KEY BLOCKmmm - - <nl>
Add sjors gitian key
bitcoin/bitcoin
41b15cfc9e6e25c63696c002bfdfec78882419cf
2017-11-04T19:35:06Z
mmm a / xbmc / interfaces / json - rpc / ServiceDescription . h <nl> ppp b / xbmc / interfaces / json - rpc / ServiceDescription . h <nl> namespace JSONRPC <nl> " ] , " <nl> " \ " returns \ " : null " <nl> " } " , <nl> + " \ " AudioLibrary . OnScanStarted \ " : { " <nl> + " \ " type \ " : \ " notification \ " , " <nl> + " \ " description \ " : \ " An audio library scan has started . \ " , " <nl> + " \ " params \ " : [ " <nl> + " { \ " name \ " : \ " sender \ " , \ " type \ " : \ " string \ " , \ " required \ " : true } , " <nl> + " { \ " name \ " : \ " data \ " , \ " type \ " : \ " null \ " , \ " required \ " : true } " <nl> + " ] , " <nl> + " \ " returns \ " : null " <nl> + " } " , <nl> " \ " AudioLibrary . OnScanFinished \ " : { " <nl> " \ " type \ " : \ " notification \ " , " <nl> " \ " description \ " : \ " Scanning the audio library has been finished . \ " , " <nl> namespace JSONRPC <nl> " ] , " <nl> " \ " returns \ " : null " <nl> " } " , <nl> + " \ " VideoLibrary . OnScanStarted \ " : { " <nl> + " \ " type \ " : \ " notification \ " , " <nl> + " \ " description \ " : \ " A video library scan has started . \ " , " <nl> + " \ " params \ " : [ " <nl> + " { \ " name \ " : \ " sender \ " , \ " type \ " : \ " string \ " , \ " required \ " : true } , " <nl> + " { \ " name \ " : \ " data \ " , \ " type \ " : \ " null \ " , \ " required \ " : true } " <nl> + " ] , " <nl> + " \ " returns \ " : null " <nl> + " } " , <nl> " \ " VideoLibrary . OnScanFinished \ " : { " <nl> " \ " type \ " : \ " notification \ " , " <nl> " \ " description \ " : \ " Scanning the video library has been finished . \ " , " <nl> mmm a / xbmc / interfaces / json - rpc / notifications . json <nl> ppp b / xbmc / interfaces / json - rpc / notifications . json <nl> <nl> ] , <nl> " returns " : null <nl> } , <nl> + " AudioLibrary . OnScanStarted " : { <nl> + " type " : " notification " , <nl> + " description " : " An audio library scan has started . " , <nl> + " params " : [ <nl> + { " name " : " sender " , " type " : " string " , " required " : true } , <nl> + { " name " : " data " , " type " : " null " , " required " : true } <nl> + ] , <nl> + " returns " : null <nl> + } , <nl> " AudioLibrary . OnScanFinished " : { <nl> " type " : " notification " , <nl> " description " : " Scanning the audio library has been finished . " , <nl> <nl> ] , <nl> " returns " : null <nl> } , <nl> + " VideoLibrary . OnScanStarted " : { <nl> + " type " : " notification " , <nl> + " description " : " A video library scan has started . " , <nl> + " params " : [ <nl> + { " name " : " sender " , " type " : " string " , " required " : true } , <nl> + { " name " : " data " , " type " : " null " , " required " : true } <nl> + ] , <nl> + " returns " : null <nl> + } , <nl> " VideoLibrary . OnScanFinished " : { <nl> " type " : " notification " , <nl> " description " : " Scanning the video library has been finished . " , <nl> mmm a / xbmc / music / infoscanner / MusicInfoScanner . cpp <nl> ppp b / xbmc / music / infoscanner / MusicInfoScanner . cpp <nl> CMusicInfoScanner : : ~ CMusicInfoScanner ( ) <nl> <nl> void CMusicInfoScanner : : Process ( ) <nl> { <nl> + ANNOUNCEMENT : : CAnnouncementManager : : Announce ( ANNOUNCEMENT : : AudioLibrary , " xbmc " , " OnScanStarted " ) ; <nl> try <nl> { <nl> unsigned int tick = XbmcThreads : : SystemClockMillis ( ) ; <nl> mmm a / xbmc / video / VideoInfoScanner . cpp <nl> ppp b / xbmc / video / VideoInfoScanner . cpp <nl> namespace VIDEO <nl> m_bCanInterrupt = true ; <nl> <nl> CLog : : Log ( LOGNOTICE , " VideoInfoScanner : Starting scan . . " ) ; <nl> + ANNOUNCEMENT : : CAnnouncementManager : : Announce ( ANNOUNCEMENT : : VideoLibrary , " xbmc " , " OnScanStarted " ) ; <nl> <nl> / / Reset progress vars <nl> m_currentItem = 0 ; <nl>
Merge pull request from alcoheca / rpc - scanstart
xbmc/xbmc
ef7f03ee93acdef40b34a8fafc92dc4895a6b6e9
2012-10-01T13:50:53Z
mmm a / js / apps / system / aardvark / frontend / css / documentsView . css <nl> ppp b / js / apps / system / aardvark / frontend / css / documentsView . css <nl> <nl> margin - top : - 54px ! important ; <nl> } <nl> <nl> - . arangoDropdown { <nl> - margin - bottom : - 10px ; <nl> - } <nl> - <nl> # filterHeader , . arangoDropdownIn , # indexHeaderContent { <nl> margin - left : 5px ; <nl> margin - right : 5px ; <nl> <nl> font - size : 1 . 4em ; <nl> } <nl> <nl> - # documentsDiv { <nl> - margin - top : 10px ! important ; <nl> - } <nl> - <nl> # documentsTableID_length , # documentsTableID_filter { <nl> display : none ; <nl> } <nl> mmm a / js / apps / system / aardvark / frontend / css / general . css <nl> ppp b / js / apps / system / aardvark / frontend / css / general . css <nl> documentsView . css <nl> height : 56px ; <nl> } <nl> <nl> - . arangoDropdown { <nl> - margin - bottom : - 10px ; <nl> - } <nl> - <nl> # documentsDiv { <nl> margin - top : 10px ! important ; <nl> } <nl>
Fixed Documents and Graph Management view
arangodb/arangodb
cd40fe8328f737051ce11a41bcd20b9916625cbe
2014-01-25T09:14:29Z
mmm a / hphp / hhbbc / interp - internal . h <nl> ppp b / hphp / hhbbc / interp - internal . h <nl> bool thisAvailable ( ISS & env ) { return env . state . thisAvailable ; } <nl> / / Returns the type $ this would have if it ' s not null . Generally <nl> / / you have to check thisIsAvailable ( ) before assuming it can ' t be <nl> / / null . <nl> - folly : : Optional < Type > thisType ( ISS & env ) { <nl> - if ( ! env . ctx . cls ) return folly : : none ; <nl> + folly : : Optional < Type > thisTypeHelper ( const Index & index , Context ctx ) { <nl> + if ( ! ctx . cls ) return folly : : none ; <nl> <nl> / / Due to ` bindTo ` , we can ' t conclude the type of $ this . <nl> - if ( RuntimeOption : : EvalAllowScopeBinding & & env . ctx . func - > isClosureBody ) { <nl> + if ( RuntimeOption : : EvalAllowScopeBinding & & ctx . func - > isClosureBody ) { <nl> return folly : : none ; <nl> } <nl> <nl> / / Due to unflattened traits in non - repo mode , we can ' t conclude $ this type . <nl> - if ( ! RuntimeOption : : RepoAuthoritative & & env . ctx . cls - > attrs & AttrTrait ) { <nl> + if ( ! RuntimeOption : : RepoAuthoritative & & ctx . cls - > attrs & AttrTrait ) { <nl> return folly : : none ; <nl> } <nl> <nl> - return subObj ( env . index . resolve_class ( env . ctx . cls ) ) ; <nl> + return subObj ( index . resolve_class ( ctx . cls ) ) ; <nl> + } <nl> + <nl> + folly : : Optional < Type > thisType ( ISS & env ) { <nl> + return thisTypeHelper ( env . index , env . ctx ) ; <nl> } <nl> <nl> folly : : Optional < Type > selfCls ( ISS & env ) { <nl> mmm a / hphp / hhbbc / interp . cpp <nl> ppp b / hphp / hhbbc / interp . cpp <nl> void default_dispatch ( ISS & env , const Bytecode & op ) { <nl> dispatch ( env , op ) ; <nl> } <nl> <nl> + folly : : Optional < Type > thisType ( const Interp & interp ) { <nl> + return thisTypeHelper ( interp . index , interp . ctx ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> } } <nl> mmm a / hphp / hhbbc / interp . h <nl> ppp b / hphp / hhbbc / interp . h <nl> bool handle_function_exists ( ISS & env , int numArgs , bool allowConstProp ) ; <nl> folly : : Optional < Type > <nl> const_fold ( ISS & env , uint32_t nArgs , const res : : Func & rfunc ) ; <nl> <nl> + folly : : Optional < Type > thisType ( const Interp & interp ) ; <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> } } <nl> mmm a / hphp / hhbbc / optimize . cpp <nl> ppp b / hphp / hhbbc / optimize . cpp <nl> void insert_assertions_step ( ArrayTypeTable : : Builder & arrTable , <nl> * bools or objects , etc . We might consider making stack flavors have <nl> * subtypes and adding this to the opcode table . <nl> * / <nl> - bool hasObviousStackOutput ( const Bytecode & op , const State & state ) { <nl> + bool hasObviousStackOutput ( const Bytecode & op , const Interp & interp ) { <nl> / / Generally consider CGetL obvious because if we knew the type of the local , <nl> / / we ' ll assert that right before the CGetL . <nl> auto cgetlObvious = [ & ] ( LocalId l , int idx ) { <nl> - return ! state . locals [ l ] . couldBe ( TRef ) | | <nl> - ! state . stack [ state . stack . size ( ) - idx - 1 ] . <nl> + return ! interp . state . locals [ l ] . couldBe ( TRef ) | | <nl> + ! interp . state . stack [ interp . state . stack . size ( ) - idx - 1 ] . <nl> type . strictSubtypeOf ( TInitCell ) ; <nl> } ; <nl> switch ( op . op ) { <nl> bool hasObviousStackOutput ( const Bytecode & op , const State & state ) { <nl> case Op : : IsUninit : <nl> case Op : : OODeclExists : <nl> case Op : : AliasCls : <nl> + case Op : : FPassC : <nl> + return true ; <nl> + <nl> + case Op : : This : <nl> + case Op : : BareThis : <nl> + if ( auto tt = thisType ( interp ) ) { <nl> + auto t = interp . state . stack . back ( ) . type ; <nl> + if ( is_opt ( t ) ) t = unopt ( std : : move ( t ) ) ; <nl> + return ! t . strictSubtypeOf ( * tt ) ; <nl> + } <nl> return true ; <nl> <nl> case Op : : CGetL : <nl> void insert_assertions ( const Index & index , <nl> <nl> if ( op . op = = Op : : CGetL2 ) { <nl> obviousStackOutputs . emplace ( obviousStackOutputs . end ( ) - 1 , <nl> - hasObviousStackOutput ( op , state ) ) ; <nl> + hasObviousStackOutput ( op , interp ) ) ; <nl> } else { <nl> for ( int i = 0 ; i < op . numPop ( ) ; i + + ) { <nl> obviousStackOutputs . pop_back ( ) ; <nl> } <nl> for ( auto i = op . numPush ( ) ; i - - ; ) { <nl> - obviousStackOutputs . emplace_back ( hasObviousStackOutput ( op , state ) ) ; <nl> + obviousStackOutputs . emplace_back ( hasObviousStackOutput ( op , interp ) ) ; <nl> } <nl> } <nl> <nl>
Add some more obvious stack outputs
facebook/hhvm
c2f44a0c5d1539a29a2e2485bf61b63424f0d918
2017-10-03T04:10:48Z
mmm a / modules / perception / lidar / lib / detection / lidar_point_pillars / point_pillars_detection . cc <nl> ppp b / modules / perception / lidar / lib / detection / lidar_point_pillars / point_pillars_detection . cc <nl> <nl> * See the License for the specific language governing permissions and <nl> * limitations under the License . <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + # include " modules / perception / lidar / lib / detection / lidar_point_pillars / point_pillars_detection . h " <nl> + <nl> # include < cuda_runtime_api . h > <nl> + # include < algorithm > <nl> + # include < cstring > <nl> + # include < numeric > <nl> + # include < random > <nl> # include < vector > <nl> <nl> # include " cyber / common / log . h " <nl> <nl> # include " modules / perception / base / object_pool_types . h " <nl> # include " modules / perception / common / perception_gflags . h " <nl> # include " modules / perception / lidar / common / lidar_timer . h " <nl> - # include " modules / perception / lidar / lib / detection / lidar_point_pillars / point_pillars_detection . h " <nl> <nl> namespace apollo { <nl> namespace perception { <nl> bool PointPillarsDetection : : Detect ( const DetectionOptions & options , <nl> } <nl> <nl> / / transform point cloud into an array <nl> - float * points_array = new float [ original_cloud_ - > size ( ) * 4 ] ; <nl> - PclToArray ( original_cloud_ , points_array , kNormalizingFactor ) ; <nl> + float * points_array ; <nl> + int num_points = original_cloud_ - > size ( ) ; <nl> + int num_indexes ; <nl> + std : : vector < int > indexes ; <nl> + if ( kFuseFrames & & kNumFuseFrames > 1 ) { <nl> + / / before fusing <nl> + while ( ! prev_point_clouds_ . empty ( ) & & <nl> + frame - > timestamp - prev_point_clouds_ . front ( ) . second > kTimeInterval ) { <nl> + prev_point_clouds_ . pop_front ( ) ; <nl> + } <nl> + <nl> + / / fusing <nl> + for ( auto & pc_timestamp : prev_point_clouds_ ) { <nl> + num_points + = pc_timestamp . first - > size ( ) ; <nl> + } <nl> + num_indexes = num_points ; <nl> + indexes = GenerateIndexes ( 0 , num_indexes , kShufflePoints ) ; <nl> + num_points = std : : min ( num_points , kMaxNumPoints ) ; <nl> + points_array = new float [ num_points * kNumPointFeature ] ; <nl> + memset ( points_array , 0 , num_points * kNumPointFeature * sizeof ( float ) ) ; <nl> + FusePointCloudToArray ( original_cloud_ , points_array , indexes , <nl> + kNormalizingFactor ) ; <nl> + <nl> + / / after fusing <nl> + while ( static_cast < int > ( prev_point_clouds_ . size ( ) ) > = kNumFuseFrames - 1 ) { <nl> + prev_point_clouds_ . pop_front ( ) ; <nl> + } <nl> + prev_point_clouds_ . emplace_back ( <nl> + std : : make_pair ( original_world_cloud_ , frame - > timestamp ) ) ; <nl> + } else { <nl> + num_indexes = num_points ; <nl> + indexes = GenerateIndexes ( 0 , num_indexes , kShufflePoints ) ; <nl> + num_points = std : : min ( num_points , kMaxNumPoints ) ; <nl> + points_array = new float [ num_points * kNumPointFeature ] ; <nl> + memset ( points_array , 0 , num_points * kNumPointFeature * sizeof ( float ) ) ; <nl> + PclToArray ( original_cloud_ , points_array , indexes , kNormalizingFactor ) ; <nl> + } <nl> + pcl_to_array_time_ = timer . toc ( true ) ; <nl> <nl> / / inference <nl> std : : vector < float > out_detections ; <nl> std : : vector < int > out_labels ; <nl> - point_pillars_ptr_ - > DoInference ( points_array , original_cloud_ - > size ( ) , <nl> + point_pillars_ptr_ - > DoInference ( points_array , num_points , <nl> & out_detections , & out_labels ) ; <nl> inference_time_ = timer . toc ( true ) ; <nl> <nl> - / / transfer output bounding boxs to objects <nl> + / / transfer output bounding boxes to objects <nl> GetObjects ( & frame - > segmented_objects , frame - > lidar2world_pose , <nl> & out_detections , & out_labels ) ; <nl> + collect_time_ = timer . toc ( true ) ; <nl> <nl> - AINFO < < " PointPillars : inference : " < < inference_time_ < < " \ t " <nl> + AINFO < < " PointPillars : " < < " pcl_to_array : " < < pcl_to_array_time_ < < " \ t " <nl> + < < " inference : " < < inference_time_ < < " \ t " <nl> < < " collect : " < < collect_time_ ; <nl> + <nl> + delete [ ] points_array ; <nl> return true ; <nl> } <nl> <nl> void PointPillarsDetection : : PclToArray ( const base : : PointFCloudPtr & pc_ptr , <nl> float * out_points_array , <nl> + const std : : vector < int > & indexes , <nl> const float normalizing_factor ) { <nl> for ( size_t i = 0 ; i < pc_ptr - > size ( ) ; + + i ) { <nl> + int index = indexes . at ( i ) ; <nl> + if ( index > = kMaxNumPoints ) continue ; <nl> const auto & point = pc_ptr - > at ( i ) ; <nl> - out_points_array [ i * 4 + 0 ] = point . x ; <nl> - out_points_array [ i * 4 + 1 ] = point . y ; <nl> - out_points_array [ i * 4 + 2 ] = point . z ; <nl> - out_points_array [ i * 4 + 3 ] = <nl> - static_cast < float > ( point . intensity / normalizing_factor ) ; <nl> + out_points_array [ index * kNumPointFeature + 0 ] = point . x ; <nl> + out_points_array [ index * kNumPointFeature + 1 ] = point . y ; <nl> + out_points_array [ index * kNumPointFeature + 2 ] = point . z ; <nl> + / / delta of timestamp between prev and cur frames <nl> + out_points_array [ index * kNumPointFeature + 3 ] = 0 ; <nl> } <nl> } <nl> <nl> + / / TODO ( chenjiahao ) : write a cuda version to accelerate <nl> + void PointPillarsDetection : : FusePointCloudToArray ( <nl> + const base : : PointFCloudPtr & pc_ptr , float * out_points_array , <nl> + const std : : vector < int > & indexes , const float normalizing_factor ) { <nl> + PclToArray ( pc_ptr , out_points_array , indexes , normalizing_factor ) ; <nl> + <nl> + int index_counter = pc_ptr - > size ( ) ; <nl> + for ( auto iter = prev_point_clouds_ . rbegin ( ) ; <nl> + iter ! = prev_point_clouds_ . rend ( ) ; + + iter ) { <nl> + base : : PointDCloudPtr & prev_pc_ptr = iter - > first ; <nl> + / / transform prev world point cloud to current sensor ' s coordinates <nl> + for ( size_t i = 0 ; i < prev_pc_ptr - > size ( ) ; + + i ) { <nl> + int index = indexes . at ( index_counter ) ; <nl> + if ( index > = kMaxNumPoints ) continue ; <nl> + const auto & point = prev_pc_ptr - > at ( i ) ; <nl> + Eigen : : Vector3d trans_point ( point . x , point . y , point . z ) ; <nl> + trans_point = lidar_frame_ref_ - > lidar2world_pose . inverse ( ) * trans_point ; <nl> + out_points_array [ index * kNumPointFeature + 0 ] = <nl> + static_cast < float > ( trans_point ( 0 ) ) ; <nl> + out_points_array [ index * kNumPointFeature + 1 ] = <nl> + static_cast < float > ( trans_point ( 1 ) ) ; <nl> + out_points_array [ index * kNumPointFeature + 2 ] = <nl> + static_cast < float > ( trans_point ( 2 ) ) ; <nl> + out_points_array [ index * kNumPointFeature + 3 ] = <nl> + static_cast < float > ( lidar_frame_ref_ - > timestamp - iter - > second ) ; <nl> + index_counter + + ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + std : : vector < int > PointPillarsDetection : : GenerateIndexes ( int start_index , <nl> + int size , <nl> + bool shuffle ) { <nl> + / / create a range number array <nl> + std : : vector < int > indexes ( size ) ; <nl> + std : : iota ( indexes . begin ( ) , indexes . end ( ) , start_index ) ; <nl> + <nl> + / / shuffle the index array <nl> + if ( shuffle ) { <nl> + unsigned seed = 0 ; <nl> + std : : shuffle ( indexes . begin ( ) , indexes . end ( ) , <nl> + std : : default_random_engine ( seed ) ) ; <nl> + } <nl> + return indexes ; <nl> + } <nl> + <nl> void PointPillarsDetection : : GetObjects ( <nl> std : : vector < std : : shared_ptr < Object > > * objects , const Eigen : : Affine3d & pose , <nl> std : : vector < float > * detections , std : : vector < int > * labels ) { <nl> - Timer timer ; <nl> int num_objects = detections - > size ( ) / kOutputNumBoxFeature ; <nl> <nl> objects - > clear ( ) ; <nl> void PointPillarsDetection : : GetObjects ( <nl> object - > type_probs . assign ( object - > lidar_supplement . raw_probs . back ( ) . begin ( ) , <nl> object - > lidar_supplement . raw_probs . back ( ) . end ( ) ) ; <nl> } <nl> - <nl> - collect_time_ = timer . toc ( true ) ; <nl> } <nl> <nl> / / TODO ( chenjiahao ) : update the base ObjectSubType with more fine - grained types <nl> mmm a / modules / perception / lidar / lib / detection / lidar_point_pillars / point_pillars_detection . h <nl> ppp b / modules / perception / lidar / lib / detection / lidar_point_pillars / point_pillars_detection . h <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> # pragma once <nl> <nl> + # include < deque > <nl> # include < memory > <nl> # include < string > <nl> + # include < utility > <nl> # include < vector > <nl> <nl> # include " modules / perception / base / object . h " <nl> class PointPillarsDetection { <nl> <nl> private : <nl> void PclToArray ( const base : : PointFCloudPtr & pc_ptr , float * out_points_array , <nl> - const float normalizing_factor ) ; <nl> + const std : : vector < int > & indexes , float normalizing_factor ) ; <nl> + <nl> + void FusePointCloudToArray ( const base : : PointFCloudPtr & pc_ptr , <nl> + float * out_points_array , <nl> + const std : : vector < int > & indexes , <nl> + float normalizing_factor ) ; <nl> + <nl> + std : : vector < int > GenerateIndexes ( int start_index , int size , bool shuffle ) ; <nl> <nl> void GetObjects ( std : : vector < std : : shared_ptr < base : : Object > > * objects , <nl> const Eigen : : Affine3d & pose , <nl> std : : vector < float > * detections , <nl> std : : vector < int > * labels ) ; <nl> <nl> - base : : ObjectSubType GetObjectSubType ( const int label ) ; <nl> + base : : ObjectSubType GetObjectSubType ( int label ) ; <nl> <nl> / / reference pointer of lidar frame <nl> LidarFrame * lidar_frame_ref_ = nullptr ; <nl> class PointPillarsDetection { <nl> <nl> / / PointPillars <nl> std : : unique_ptr < PointPillars > point_pillars_ptr_ ; <nl> + std : : deque < std : : pair < base : : PointDCloudPtr , double > > prev_point_clouds_ ; <nl> <nl> / / time statistics <nl> + double pcl_to_array_time_ = 0 . 0 ; <nl> double inference_time_ = 0 . 0 ; <nl> double collect_time_ = 0 . 0 ; <nl> <nl> / / constants <nl> const float kNormalizingFactor = 255 . 0f ; <nl> + const int kNumPointFeature = 4 ; <nl> const int kOutputNumBoxFeature = 7 ; <nl> + const int kNumFuseFrames = 5 ; <nl> + const bool kFuseFrames = false ; <nl> const bool kReproduceResultMode = false ; <nl> + const bool kShufflePoints = true ; <nl> const float kScoreThreshold = 0 . 5 ; <nl> const float kNmsOverlapThreshold = 0 . 5 ; <nl> + const float kTimeInterval = 0 . 5 ; <nl> + const int kMaxNumPoints = INT_MAX ; <nl> } ; / / class PointPillarsDetection <nl> <nl> } / / namespace lidar <nl>
Perception : allow fusing frames and shuffling points
ApolloAuto/apollo
49f4a9b6ebaffd186dd7bb07a2bb3e033f2ac7bd
2020-06-16T15:52:59Z
mmm a / xbmc / addons / GUIDialogAddonSettings . cpp <nl> ppp b / xbmc / addons / GUIDialogAddonSettings . cpp <nl> void CGUIDialogAddonSettings : : CreateControls ( ) <nl> int iAdd = i ; <nl> if ( entryVec . size ( ) > i ) <nl> iAdd = atoi ( entryVec [ i ] . c_str ( ) ) ; <nl> - if ( ! lvalues . empty ( ) ) <nl> + std : : string replace ; <nl> + if ( std : : all_of ( valuesVec [ i ] . begin ( ) , valuesVec [ i ] . end ( ) , : : isdigit ) ) <nl> { <nl> - std : : string replace = g_localizeStrings . GetAddonString ( m_addon - > ID ( ) , atoi ( valuesVec [ i ] . c_str ( ) ) ) ; <nl> + replace = g_localizeStrings . GetAddonString ( m_addon - > ID ( ) , atoi ( valuesVec [ i ] . c_str ( ) ) ) ; <nl> if ( replace . empty ( ) ) <nl> replace = g_localizeStrings . Get ( atoi ( valuesVec [ i ] . c_str ( ) ) ) ; <nl> - ( ( CGUISpinControlEx * ) pControl ) - > AddLabel ( replace , iAdd ) ; <nl> + if ( replace . empty ( ) ) <nl> + replace = valuesVec [ i ] ; <nl> } <nl> else <nl> - ( ( CGUISpinControlEx * ) pControl ) - > AddLabel ( valuesVec [ i ] , iAdd ) ; <nl> + replace = valuesVec [ i ] ; <nl> + ( ( CGUISpinControlEx * ) pControl ) - > AddLabel ( replace , iAdd ) ; <nl> } <nl> if ( type = = " labelenum " ) <nl> { / / need to run through all our settings and find the one that matches <nl>
[ addons ] Preserve strings which are not string ids in enum lvalues
xbmc/xbmc
c2bd593649ed2493e3502ba15e62c62b1bdbe73f
2016-06-19T06:26:12Z
mmm a / src / core / ext / transport / chttp2 / transport / frame_rst_stream . c <nl> ppp b / src / core / ext / transport / chttp2 / transport / frame_rst_stream . c <nl> grpc_error * grpc_chttp2_rst_stream_parser_parse ( grpc_exec_ctx * exec_ctx , <nl> grpc_error * error = GRPC_ERROR_NONE ; <nl> if ( reason ! = GRPC_CHTTP2_NO_ERROR ) { <nl> error = grpc_error_set_int ( GRPC_ERROR_CREATE ( " RST_STREAM " ) , <nl> - GRPC_ERROR_INT_HTTP2_ERROR , reason ) ; <nl> + GRPC_ERROR_INT_HTTP2_ERROR , ( intptr_t ) reason ) ; <nl> grpc_status_code status_code = grpc_chttp2_http2_error_to_grpc_status ( <nl> ( grpc_chttp2_error_code ) reason , s - > deadline ) ; <nl> char * status_details ; <nl>
Fix 32 - bit linux build
grpc/grpc
dd25ccbd93fd01dacbe18cab2410b9f8a15e7107
2016-10-13T17:34:02Z
mmm a / 3rdparty / mshadow <nl> ppp b / 3rdparty / mshadow <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 6e94643bdf1d51a505b147f28c358fb71070b8fd <nl> + Subproject commit 1d79ecfdb4c9234537e1bf5148f44a1af54501ec <nl> mmm a / ci / build_windows . py <nl> ppp b / ci / build_windows . py <nl> <nl> class BuildFlavour ( Enum ) : <nl> WIN_CPU = ' WIN_CPU ' <nl> WIN_CPU_MKLDNN = ' WIN_CPU_MKLDNN ' <nl> + WIN_CPU_MKLDNN_MKL = ' WIN_CPU_MKLDNN_MKL ' <nl> + WIN_CPU_MKL = ' WIN_CPU_MKL ' <nl> WIN_GPU = ' WIN_GPU ' <nl> WIN_GPU_MKLDNN = ' WIN_GPU_MKLDNN ' <nl> <nl> class BuildFlavour ( Enum ) : <nl> ' - DUSE_LAPACK = 1 ' <nl> ' - DUSE_DIST_KVSTORE = 0 ' <nl> ' - DUSE_MKL_IF_AVAILABLE = 1 ' <nl> + ' - DUSE_MKLDNN = 1 ' <nl> ' - DCMAKE_BUILD_TYPE = Release ' ) <nl> <nl> + , ' WIN_CPU_MKLDNN_MKL ' : ( ' - DUSE_CUDA = 0 ' <nl> + ' - DUSE_CUDNN = 0 ' <nl> + ' - DUSE_NVRTC = 0 ' <nl> + ' - DUSE_OPENCV = 1 ' <nl> + ' - DUSE_OPENMP = 1 ' <nl> + ' - DUSE_PROFILER = 1 ' <nl> + ' - DUSE_BLAS = mkl ' <nl> + ' - DUSE_LAPACK = 1 ' <nl> + ' - DUSE_DIST_KVSTORE = 0 ' <nl> + ' - DUSE_MKL_IF_AVAILABLE = 1 ' <nl> + ' - DUSE_MKLDNN = 1 ' <nl> + ' - DCMAKE_BUILD_TYPE = Release ' ) <nl> + <nl> + , ' WIN_CPU_MKL ' : ( ' - DUSE_CUDA = 0 ' <nl> + ' - DUSE_CUDNN = 0 ' <nl> + ' - DUSE_NVRTC = 0 ' <nl> + ' - DUSE_OPENCV = 1 ' <nl> + ' - DUSE_OPENMP = 1 ' <nl> + ' - DUSE_PROFILER = 1 ' <nl> + ' - DUSE_BLAS = mkl ' <nl> + ' - DUSE_LAPACK = 1 ' <nl> + ' - DUSE_DIST_KVSTORE = 0 ' <nl> + ' - DUSE_MKL_IF_AVAILABLE = 1 ' <nl> + ' - DUSE_MKLDNN = 0 ' <nl> + ' - DCMAKE_BUILD_TYPE = Release ' ) <nl> , ' WIN_GPU ' : ( ' - DUSE_CUDA = 1 ' <nl> ' - DUSE_CUDNN = 1 ' <nl> ' - DUSE_NVRTC = 1 ' <nl> def main ( ) : <nl> os . environ [ " OpenCV_DIR " ] = " C : \ \ Program Files \ \ OpenCV - v3 . 4 . 1 \ \ build " <nl> if ' CUDA_PATH ' not in os . environ : <nl> os . environ [ " CUDA_PATH " ] = " C : \ \ Program Files \ \ NVIDIA GPU Computing Toolkit \ \ CUDA \ \ v9 . 2 " <nl> + if ' MKL_ROOT ' not in os . environ : <nl> + os . environ [ " MKL_ROOT " ] = " C : \ \ Program Files ( x86 ) \ \ IntelSWTools \ \ compilers_and_libraries \ \ windows \ \ mkl " <nl> windows_build ( args ) <nl> <nl> elif system = = ' Linux ' or system = = ' Darwin ' : <nl> mmm a / ci / jenkins / Jenkins_steps . groovy <nl> ppp b / ci / jenkins / Jenkins_steps . groovy <nl> def compile_windows_cpu ( ) { <nl> } ] <nl> } <nl> <nl> + def compile_windows_cpu_mkldnn ( ) { <nl> + return [ ' Build CPU MKLDNN windows ' : { <nl> + node ( NODE_WINDOWS_CPU ) { <nl> + ws ( ' workspace / build - cpu - mkldnn ' ) { <nl> + timeout ( time : max_time , unit : ' MINUTES ' ) { <nl> + utils . init_git_win ( ) <nl> + powershell ' py - 3 ci / build_windows . py - f WIN_CPU_MKLDNN ' <nl> + stash includes : ' windows_package . 7z ' , name : ' windows_package_cpu_mkldnn ' <nl> + } <nl> + } <nl> + } <nl> + } ] <nl> + } <nl> + <nl> + def compile_windows_cpu_mkldnn_mkl ( ) { <nl> + return [ ' Build CPU MKLDNN MKL windows ' : { <nl> + node ( NODE_WINDOWS_CPU ) { <nl> + ws ( ' workspace / build - cpu - mkldnn - mkl ' ) { <nl> + timeout ( time : max_time , unit : ' MINUTES ' ) { <nl> + utils . init_git_win ( ) <nl> + powershell ' py - 3 ci / build_windows . py - f WIN_CPU_MKLDNN_MKL ' <nl> + stash includes : ' windows_package . 7z ' , name : ' windows_package_cpu_mkldnn_mkl ' <nl> + } <nl> + } <nl> + } <nl> + } ] <nl> + } <nl> + <nl> + def compile_windows_cpu_mkl ( ) { <nl> + return [ ' Build CPU MKL windows ' : { <nl> + node ( NODE_WINDOWS_CPU ) { <nl> + ws ( ' workspace / build - cpu - mkl ' ) { <nl> + timeout ( time : max_time , unit : ' MINUTES ' ) { <nl> + utils . init_git_win ( ) <nl> + powershell ' py - 3 ci / build_windows . py - f WIN_CPU_MKL ' <nl> + stash includes : ' windows_package . 7z ' , name : ' windows_package_cpu_mkl ' <nl> + } <nl> + } <nl> + } <nl> + } ] <nl> + } <nl> + <nl> def compile_windows_gpu ( ) { <nl> return [ ' Build GPU windows ' : { <nl> node ( NODE_WINDOWS_CPU ) { <nl> mmm a / ci / jenkins / Jenkinsfile_windows_cpu <nl> ppp b / ci / jenkins / Jenkinsfile_windows_cpu <nl> utils . assign_node_labels ( utility : ' utility ' , windows_cpu : ' mxnetwindows - cpu ' ) <nl> utils . main_wrapper ( <nl> core_logic : { <nl> utils . parallel_stage ( ' Build ' , [ <nl> - custom_steps . compile_windows_cpu ( ) <nl> + custom_steps . compile_windows_cpu ( ) , <nl> + custom_steps . compile_windows_cpu_mkldnn ( ) , <nl> + custom_steps . compile_windows_cpu_mkldnn_mkl ( ) , <nl> + custom_steps . compile_windows_cpu_mkl ( ) <nl> ] ) <nl> <nl> utils . parallel_stage ( ' Tests ' , [ <nl> mmm a / cmake / ChooseBlas . cmake <nl> ppp b / cmake / ChooseBlas . cmake <nl> <nl> set ( BLAS " Open " CACHE STRING " Selected BLAS library " ) <nl> set_property ( CACHE BLAS PROPERTY STRINGS " Atlas ; Open ; MKL " ) <nl> <nl> - if ( USE_MKL_IF_AVAILABLE ) <nl> - if ( NOT MKL_FOUND ) <nl> - find_package ( MKL ) <nl> - endif ( ) <nl> - if ( MKL_FOUND ) <nl> - if ( USE_MKLDNN ) <nl> - set ( BLAS " open " ) <nl> - else ( ) <nl> + if ( DEFINED USE_BLAS ) <nl> + set ( BLAS " $ { USE_BLAS } " ) <nl> + else ( ) <nl> + if ( USE_MKL_IF_AVAILABLE ) <nl> + if ( NOT MKL_FOUND ) <nl> + find_package ( MKL ) <nl> + endif ( ) <nl> + if ( MKL_FOUND ) <nl> set ( BLAS " MKL " ) <nl> endif ( ) <nl> endif ( ) <nl> mmm a / cmake / Modules / FindMKL . cmake <nl> ppp b / cmake / Modules / FindMKL . cmake <nl> endif ( ) <nl> # mmm [ Root folders <nl> set ( INTEL_ROOT " / opt / intel " CACHE PATH " Folder contains intel libs " ) <nl> <nl> - if ( USE_MKLDNN ) <nl> - <nl> - find_path ( MKL_ROOT include / mkl_blas . h <nl> - PATHS $ ENV { MKL_ROOT } <nl> - $ { INTEL_ROOT } / mklml <nl> - $ { DIRECT_DEPENDENCY_ROOTS } <nl> - DOC " Folder contains MKL " <nl> - ) <nl> - <nl> - # mmm [ Find include dir <nl> - find_path ( MKL_INCLUDE_DIR mkl_blas . h PATHS $ { MKL_ROOT } PATH_SUFFIXES include ) <nl> - set ( __looked_for MKL_INCLUDE_DIR ) <nl> - <nl> - # mmm [ Find libraries <nl> - if ( CMAKE_SIZEOF_VOID_P EQUAL 4 ) <nl> - set ( __path_suffixes lib lib / ia32 ) <nl> - else ( ) <nl> - set ( __path_suffixes lib lib / intel64 ) <nl> - endif ( ) <nl> - <nl> - set ( __mkl_libs " " ) <nl> - <nl> - if ( WIN32 ) <nl> - list ( APPEND __mkl_libs mklml_intel ) <nl> - else ( ) <nl> - list ( APPEND __mkl_libs mklml_gnu ) <nl> - endif ( ) <nl> - list ( APPEND __mkl_libs mkldnn ) <nl> - <nl> - foreach ( __lib $ { __mkl_libs } ) <nl> - set ( __mkl_lib " $ { __lib } " ) <nl> - string ( TOUPPER $ { __mkl_lib } __mkl_lib_upper ) <nl> - <nl> - if ( MKL_USE_STATIC_LIBS ) <nl> - set ( __mkl_lib " lib $ { __mkl_lib } . a " ) <nl> - endif ( ) <nl> - <nl> - find_library ( $ { __mkl_lib_upper } _LIBRARY <nl> - NAMES $ { __mkl_lib } <nl> - PATHS $ { MKL_ROOT } " $ { MKL_INCLUDE_DIR } / . . " <nl> - PATH_SUFFIXES $ { __path_suffixes } <nl> - DOC " The path to Intel ( R ) MKL $ { __mkl_lib } library " ) <nl> - mark_as_advanced ( $ { __mkl_lib_upper } _LIBRARY ) <nl> - <nl> - list ( APPEND __looked_for $ { __mkl_lib_upper } _LIBRARY ) <nl> - list ( APPEND MKL_LIBRARIES $ { $ { __mkl_lib_upper } _LIBRARY } ) <nl> - endforeach ( ) <nl> - <nl> - else ( USE_MKLDNN ) <nl> <nl> # mmm [ Options <nl> mxnet_option ( MKL_USE_SINGLE_DYNAMIC_LIBRARY " Use single dynamic library interface " ON ) <nl> else ( USE_MKLDNN ) <nl> list ( APPEND MKL_LIBRARIES $ { MKL_RTL_LIBRARY } ) <nl> endif ( ) <nl> <nl> - endif ( USE_MKLDNN ) <nl> + <nl> <nl> include ( FindPackageHandleStandardArgs ) <nl> find_package_handle_standard_args ( MKL DEFAULT_MSG $ { __looked_for } ) <nl>
Fix the incorrect MKLDNN / MKL logic in cmake ( )
apache/incubator-mxnet
d87bd2aba1043d1f3c9e998d6ecd4bee2e342bae
2019-05-16T13:27:29Z
mmm a / fdbserver / workloads / DifferentClustersSameRV . actor . cpp <nl> ppp b / fdbserver / workloads / DifferentClustersSameRV . actor . cpp <nl> struct DifferentClustersSameRVWorkload : TestWorkload { <nl> state UID lockUid = g_random - > randomUniqueID ( ) ; <nl> wait ( delay ( self - > switchAfter ) ) ; <nl> state Future < Void > watchFuture ; <nl> - wait ( runRYWTransaction ( cx , [ = ] ( Reference < ReadYourWritesTransaction > tr ) - > Future < Void > { <nl> + wait ( runRYWTransaction ( cx , [ = ] ( Reference < ReadYourWritesTransaction > tr ) mutable - > Future < Void > { <nl> watchFuture = tr - > watch ( self - > keyToWatch ) ; <nl> return Void ( ) ; <nl> } ) ) ; <nl>
Fix OPEN_FOR_IDE error
apple/foundationdb
b1c82e9779d61addf5644318cc7aae5a8fb41a9b
2019-06-11T20:58:22Z
mmm a / THCTensorMath . cu <nl> ppp b / THCTensorMath . cu <nl> void <nl> THCudaTensor_mean ( THCudaTensor * self , THCudaTensor * src , long dim ) <nl> { <nl> THCudaTensor_sum ( self , src , dim ) ; <nl> - THCudaTensor_div ( self , THCudaTensor_nElement ( src ) / THCudaTensor_size ( src , dim ) ) ; <nl> + THCudaTensor_div ( self , THCudaTensor_size ( src , dim ) ) ; <nl> } <nl> <nl> struct square_functor <nl>
CUDA fixes
pytorch/pytorch
86f522d0c9662e41838ef5e44ee57c24768123ef
2013-12-24T12:19:47Z
mmm a / libraries / chain / wasm_interface . cpp <nl> ppp b / libraries / chain / wasm_interface . cpp <nl> namespace eosio { namespace chain { <nl> char * memstart = & memoryRef < char > ( getDefaultMemory ( entry . instance ) , 0 ) ; <nl> memset ( memstart + info . mem_end , 0 , ( ( 1 < < 16 ) - info . mem_end ) ) ; <nl> memcpy ( memstart , info . mem_image . data ( ) , info . mem_end ) ; <nl> + resetGlobalInstances ( entry . instance ) ; <nl> <nl> / / under a lock , put this entry back in the available instances side of the instances vector <nl> with_lock ( [ & , this ] ( ) { <nl> mmm a / libraries / wasm - jit / Include / Runtime / Runtime . h <nl> ppp b / libraries / wasm - jit / Include / Runtime / Runtime . h <nl> namespace Runtime <nl> RUNTIME_API TableInstance * getDefaultTable ( ModuleInstance * moduleInstance ) ; <nl> <nl> RUNTIME_API void runInstanceStartFunc ( ModuleInstance * moduleInstance ) ; <nl> + RUNTIME_API void resetGlobalInstances ( ModuleInstance * moduleInstance ) ; <nl> <nl> / / Gets an object exported by a ModuleInstance by name . <nl> RUNTIME_API ObjectInstance * getInstanceExport ( ModuleInstance * moduleInstance , const std : : string & name ) ; <nl> mmm a / libraries / wasm - jit / Source / Runtime / ModuleInstance . cpp <nl> ppp b / libraries / wasm - jit / Source / Runtime / ModuleInstance . cpp <nl> namespace Runtime <nl> if ( moduleInstance - > startFunctionIndex ! = UINTPTR_MAX ) <nl> invokeFunction ( moduleInstance - > functions [ moduleInstance - > startFunctionIndex ] , { } ) ; <nl> } <nl> + <nl> + void resetGlobalInstances ( ModuleInstance * moduleInstance ) { <nl> + for ( GlobalInstance * & gi : moduleInstance - > globals ) <nl> + memcpy ( & gi - > value , & gi - > initialValue , sizeof ( gi - > value ) ) ; <nl> + } <nl> <nl> ObjectInstance * getInstanceExport ( ModuleInstance * moduleInstance , const std : : string & name ) <nl> { <nl> mmm a / libraries / wasm - jit / Source / Runtime / RuntimePrivate . h <nl> ppp b / libraries / wasm - jit / Source / Runtime / RuntimePrivate . h <nl> namespace Runtime <nl> { <nl> GlobalType type ; <nl> UntaggedValue value ; <nl> + UntaggedValue initialValue ; <nl> <nl> - GlobalInstance ( GlobalType inType , UntaggedValue inValue ) : GCObject ( ObjectKind : : global ) , type ( inType ) , value ( inValue ) { } <nl> + GlobalInstance ( GlobalType inType , UntaggedValue inValue ) : GCObject ( ObjectKind : : global ) , type ( inType ) , value ( inValue ) , initialValue ( value ) { } <nl> } ; <nl> <nl> / / An instance of a WebAssembly module . <nl> mmm a / tests / wasm_tests / test_wasts . hpp <nl> ppp b / tests / wasm_tests / test_wasts . hpp <nl> static const char entry_wast [ ] = R " = = = = = ( <nl> ) <nl> ( start $ entry ) <nl> ) <nl> + ) = = = = = " ; <nl> + <nl> + static const char mutable_global_wast [ ] = R " = = = = = ( <nl> + ( module <nl> + ( import " env " " assert " ( func $ assert ( param i32 i32 ) ) ) <nl> + ( table 0 anyfunc ) <nl> + ( memory $ 0 1 ) <nl> + ( export " memory " ( memory $ 0 ) ) <nl> + ( export " init " ( func $ init ) ) <nl> + ( export " apply " ( func $ apply ) ) <nl> + ( func $ init <nl> + ( set_global $ g0 <nl> + ( i32 . const 444 ) <nl> + ) <nl> + ) <nl> + ( func $ apply ( param $ 0 i64 ) ( param $ 1 i64 ) <nl> + ( call $ assert <nl> + ( i32 . eq <nl> + ( get_global $ g0 ) <nl> + ( i32 . const 2 ) <nl> + ) <nl> + ( i32 . const 0 ) <nl> + ) <nl> + ) <nl> + ( global $ g0 ( mut i32 ) ( i32 . const 2 ) ) <nl> + ) <nl> ) = = = = = " ; <nl> \ No newline at end of file <nl> mmm a / tests / wasm_tests / wasm_tests . cpp <nl> ppp b / tests / wasm_tests / wasm_tests . cpp <nl> BOOST_FIXTURE_TEST_CASE ( check_entry_behavior , tester ) try { <nl> BOOST_CHECK_EQUAL ( transaction_receipt : : executed , receipt . status ) ; <nl> } FC_LOG_AND_RETHROW ( ) / / / prove_mem_reset <nl> <nl> + / / Make sure globals are all reset to their inital values <nl> + BOOST_FIXTURE_TEST_CASE ( check_global_reset , tester ) try { <nl> + produce_blocks ( 2 ) ; <nl> + <nl> + create_accounts ( { N ( globalreset ) } , asset : : from_string ( " 1000 . 0000 EOS " ) ) ; <nl> + transfer ( N ( inita ) , N ( globalreset ) , " 10 . 0000 EOS " , " memo " ) ; <nl> + produce_block ( ) ; <nl> + <nl> + set_code ( N ( globalreset ) , mutable_global_wast ) ; <nl> + produce_blocks ( 1 ) ; <nl> + <nl> + signed_transaction trx ; <nl> + action act ; <nl> + act . scope = N ( globalreset ) ; <nl> + act . name = N ( ) ; <nl> + act . authorization = vector < permission_level > { { N ( globalreset ) , config : : active_name } } ; <nl> + trx . actions . push_back ( act ) ; <nl> + <nl> + set_tapos ( trx ) ; <nl> + trx . sign ( get_private_key ( N ( globalreset ) , " active " ) , chain_id_type ( ) ) ; <nl> + control - > push_transaction ( trx ) ; <nl> + produce_blocks ( 1 ) ; <nl> + BOOST_REQUIRE_EQUAL ( true , chain_has_transaction ( trx . id ( ) ) ) ; <nl> + const auto & receipt = get_transaction_receipt ( trx . id ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( transaction_receipt : : executed , receipt . status ) ; <nl> + } FC_LOG_AND_RETHROW ( ) <nl> + <nl> <nl> BOOST_AUTO_TEST_SUITE_END ( ) <nl>
Reset WASM globals on each invocation
EOSIO/eos
42d703abc732ab6f51c991c264dabfe82cbc487f
2018-01-12T21:47:36Z
mmm a / src / compiler . cc <nl> ppp b / src / compiler . cc <nl> bool CompilationInfo : : ShouldSelfOptimize ( ) { <nl> <nl> <nl> void CompilationInfo : : EnsureFeedbackVector ( ) { <nl> - if ( feedback_vector_ . is_null ( ) | | <nl> - feedback_vector_ - > SpecDiffersFrom ( function ( ) - > feedback_vector_spec ( ) ) ) { <nl> + if ( feedback_vector_ . is_null ( ) ) { <nl> feedback_vector_ = isolate ( ) - > factory ( ) - > NewTypeFeedbackVector ( <nl> function ( ) - > feedback_vector_spec ( ) ) ; <nl> } <nl> + <nl> + / / It ' s very important that recompiles do not alter the structure of the <nl> + / / type feedback vector . <nl> + CHECK ( ! feedback_vector_ - > SpecDiffersFrom ( function ( ) - > feedback_vector_spec ( ) ) ) ; <nl> } <nl> <nl> <nl>
[ compiler ] Verify that type feedback vector structure is the same on recompile .
v8/v8
99a53f73235c73f04035e960750e3f1b3ece60f7
2015-08-03T08:14:49Z
mmm a / src / apps / EventViewer / Resources / Info . plist . in <nl> ppp b / src / apps / EventViewer / Resources / Info . plist . in <nl> <nl> < string > MainMenu < / string > <nl> < key > NSPrincipalClass < / key > <nl> < string > NSApplication < / string > <nl> - < key > NSSupportsAutomaticTermination < / key > <nl> - < false / > <nl> - < key > NSSupportsSuddenTermination < / key > <nl> - < false / > <nl> < / dict > <nl> < / plist > <nl> mmm a / src / apps / EventViewer / src / AppDelegate . swift <nl> ppp b / src / apps / EventViewer / src / AppDelegate . swift <nl> public class AppDelegate : NSObject , NSApplicationDelegate { <nl> var inputMonitoringAlertWindow : NSWindow ? <nl> <nl> public func applicationDidFinishLaunching ( _ : Notification ) { <nl> + ProcessInfo . processInfo . enableSuddenTermination ( ) <nl> + <nl> libkrbn_initialize ( ) <nl> <nl> setKeyResponder ( ) <nl> public class AppDelegate : NSObject , NSApplicationDelegate { <nl> } <nl> } <nl> <nl> - / / Note : <nl> - / / We have to set NSSupportsSuddenTermination ` NO ` to use ` applicationWillTerminate ` . <nl> public func applicationWillTerminate ( _ : Notification ) { <nl> libkrbn_terminate ( ) <nl> } <nl>
Enable sudden termination @ EventViewer
pqrs-org/Karabiner-Elements
619dfad6dbc64214d54114a754d770523139e85f
2020-12-27T13:08:48Z
mmm a / caffe2 / operators / filler_op . cc <nl> ppp b / caffe2 / operators / filler_op . cc <nl> REGISTER_CPU_OPERATOR ( RangeFill , RangeFillOp < float , CPUContext > ) ; <nl> REGISTER_CPU_OPERATOR ( LengthsRangeFill , LengthsRangeFillOp < CPUContext > ) ; <nl> <nl> OPERATOR_SCHEMA ( ConstantFill ) <nl> - . NumInputs ( 0 , 1 ) <nl> + . NumInputs ( 0 , 2 ) <nl> . NumOutputs ( 1 ) <nl> . AllowInplace ( { { 0 , 0 } } ) <nl> . TensorInferenceFunction ( FillerTensorInference < > ) <nl> provided , a shape argument should not be set ) <nl> containing the desired output shape ( the dimensions specified in ` extra_shape ` <nl> will also be appended ) <nl> <nl> + - If a second input V is passed , fill the output with the first element of V <nl> + <nl> When specifying ` dtype ` argument , use the integer keys from the * DataType * enum <nl> in TensorProto : <nl> <nl> mmm a / caffe2 / operators / filler_op . h <nl> ppp b / caffe2 / operators / filler_op . h <nl> class FillerOp : public Operator < Context > { <nl> " data type int64_t " ) ; <nl> CAFFE_ENFORCE ( input . numel ( ) > 0 ) ; <nl> auto * shape_data = input . template data < int64_t > ( ) ; <nl> - std : : unique_ptr < int64_t [ ] > shape_data_copy = std : : make_unique < int64_t [ ] > ( input . dim32 ( 0 ) ) ; <nl> - context_ . template CopyToCPU < int64_t > ( input . dim32 ( 0 ) , shape_data , shape_data_copy . get ( ) ) ; <nl> - shape . insert ( shape . end ( ) , shape_data_copy . get ( ) , shape_data_copy . get ( ) + input . dim32 ( 0 ) ) ; <nl> + std : : unique_ptr < int64_t [ ] > shape_data_copy = <nl> + std : : make_unique < int64_t [ ] > ( input . dim32 ( 0 ) ) ; <nl> + context_ . template CopyToCPU < int64_t > ( <nl> + input . dim32 ( 0 ) , shape_data , shape_data_copy . get ( ) ) ; <nl> + shape . insert ( <nl> + shape . end ( ) , <nl> + shape_data_copy . get ( ) , <nl> + shape_data_copy . get ( ) + input . dim32 ( 0 ) ) ; <nl> } <nl> } else { <nl> auto & input = Input ( 0 ) ; <nl> class ConstantFillOp final : public FillerOp < Context > { <nl> template < typename T > <nl> bool FillWithType ( Tensor * output ) { <nl> T value = this - > template GetSingleArgument < T > ( " value " , 0 ) ; <nl> + if ( InputSize ( ) = = 2 ) { <nl> + auto & value_vec = Input ( 1 ) ; <nl> + if ( value_vec ) { <nl> + CAFFE_ENFORCE_EQ ( <nl> + value_vec . size ( ) , 1 , " value vector must have 1 element " ) ; <nl> + value = value_vec . template data < T > ( ) [ 0 ] ; <nl> + } <nl> + } <nl> + <nl> auto * data = output - > template mutable_data < T > ( ) ; <nl> if ( output - > numel ( ) ) { <nl> math : : Set < T , Context > ( output - > numel ( ) , value , data , & context_ ) ; <nl> class ConstantFillOp final : public FillerOp < Context > { <nl> } <nl> <nl> bool FillWithString ( Tensor * output ) { <nl> + CAFFE_ENFORCE_LT ( <nl> + InputSize ( ) , 2 , " constant fill string from tensor is not supported " ) ; <nl> auto value = this - > template GetSingleArgument < std : : string > ( " value " , " " ) ; <nl> auto * data = output - > template mutable_data < std : : string > ( ) ; <nl> for ( int i = 0 ; i < output - > numel ( ) ; + + i ) { <nl> mmm a / caffe2 / python / hypothesis_test . py <nl> ppp b / caffe2 / python / hypothesis_test . py <nl> def ref ( inputs = None ) : <nl> out , = self . assertReferenceChecks ( gc , op , inputs , ref ) <nl> self . assertEqual ( dtype , out . dtype ) <nl> <nl> + @ given ( data = _dtypes ( dtypes = [ np . int32 , np . int64 , np . float32 , np . bool ] ) . <nl> + flatmap ( lambda dtype : hu . tensor ( <nl> + min_dim = 1 , dtype = dtype , elements = hu . elements_of_type ( dtype ) ) ) , <nl> + * * hu . gcs ) <nl> + def test_constant_fill_from_tensor ( self , data , gc , dc ) : <nl> + dtype = data . dtype . type <nl> + if data . dtype = = np . dtype ( np . bool ) : <nl> + dtype = np . bool <nl> + <nl> + value = np . array ( [ data . item ( 0 ) ] , dtype = dtype ) <nl> + inputs = [ data , value ] <nl> + enum_type = _NUMPY_TYPE_TO_ENUM [ dtype ] <nl> + <nl> + op = core . CreateOperator ( <nl> + ' ConstantFill ' , <nl> + [ " X " , " V " ] , <nl> + [ " Y " ] , <nl> + dtype = enum_type , <nl> + ) <nl> + <nl> + def ref ( x , v ) : <nl> + outputs = np . full ( shape = data . shape , fill_value = value [ 0 ] , dtype = dtype ) <nl> + return [ outputs ] <nl> + <nl> + self . assertDeviceChecks ( dc , op , inputs , [ 0 ] ) <nl> + out , = self . assertReferenceChecks ( gc , op , inputs , ref ) <nl> + self . assertEqual ( dtype , out . dtype ) <nl> + <nl> @ given ( t = st . integers ( 1 , 5 ) , <nl> n = st . integers ( 1 , 5 ) , <nl> d = st . integers ( 1 , 5 ) ) <nl>
topk tensor k support ( )
pytorch/pytorch
f6b0fbe2c5f355190113c362e9e263df8903c88e
2020-06-15T20:10:20Z
mmm a / docs / rql / src / control / error . yaml <nl> ppp b / docs / rql / src / control / error . yaml <nl> commands : <nl> - tag : error <nl> section : control <nl> order : 3 <nl> - description : Throw a runtime error . <nl> + description : Throw a runtime error . If called with no arguments inside the second argument to ` default ` , re - throw the current error . <nl> <nl> body : message <nl> parent : r <nl> commands : <nl> can_try : true <nl> dataset : marvel <nl> <nl> + - tag : default <nl> + section : control <nl> + order : 4 <nl> + description : Handle non - existence errors . Tries to evaluate and return its first argument . If an error related to the absence of a value is thrown in the process , or if its first argument returns null , returns its second argument . ( Alternatively , the second argument may be a function which will be called with either the text of the non - existence error or null . ) <nl> + <nl> + body : query , default_case <nl> + parent : r <nl> + returns : query <nl> + <nl> + examples : <nl> + - description : ' Stark Industries made the mistake of trusting an intern with data entry , and now a bunch of fields are missing from some of their documents . Iron Man takes a break from fighting Mandarin to write some safe analytics queries . ' <nl> + code : <nl> + js : | - <nl> + r . table ( ' projects ' ) . map ( function ( p ) { <nl> + return p ( ' staff ' ) . default ( 0 ) . add ( p ( ' management ' ) . default ( 0 ) ) <nl> + } ) . run ( conn , callback ) <nl> + py : | - <nl> + r . table ( ' projects ' ) . map ( <nl> + lambda p : p [ ' staff ' ] . default ( 0 ) + p [ ' management ' ] . default ( 0 ) <nl> + ) . run ( conn ) <nl> + rb : | - <nl> + r . table ( ' projects ' ) . map { | p | <nl> + p [ : staff ] . default ( 0 ) + p [ : management ] . default ( 0 ) <nl> + ) . run ( conn ) <nl> + <nl> + js : <nl> + examples : <nl> + 0 : <nl> + can_try : true <nl> + dataset : marvel <nl> + <nl> <nl> mmm a / docs / rql / src / select . yaml <nl> ppp b / docs / rql / src / select . yaml <nl> commands : <nl> - tag : filter <nl> section : select <nl> description : | <nl> - Get all the documents for which the given predicate is true . < br / > < br / > <nl> - < code > filter < / code > can be called on a sequence , selection , or a <nl> - field containing an array of elements . The return type is the <nl> - same as the type on which the function was called on . <nl> + Get all the documents for which the given predicate is true . < br <nl> + / > < br / > < code > filter < / code > can be called on a sequence , <nl> + selection , or a field containing an array of elements . The <nl> + return type is the same as the type on which the function was <nl> + called on . The body of every filter is wrapped in an implicit <nl> + ` . default ( false ) ` , and the default value can be changed by <nl> + passing the optional argument ` default ` . Setting this optional <nl> + argument to ` r . error ( ) ` will cause any non - existence errors to <nl> + abort the filter . <nl> <nl> body : predicate <nl> parent : selection <nl> commands : <nl> r . row [ ' powers ' ] . filter ( lambda el : el = = 10 ) . count ( ) > 0 <nl> ) . run ( conn ) <nl> rb : | <nl> - r . table ( ' marvel ' ) . filter { | hero | <nl> + r . table ( ' marvel ' ) . filter { | hero | <nl> hero [ : powers ] . filter { | power_rank | power_rank . eq ( 10 ) } . count ( ) > 0 <nl> } . run ( conn ) <nl> <nl> mmm a / drivers / javascript / src / ast . coffee <nl> ppp b / drivers / javascript / src / ast . coffee <nl> class RDBVal extends TermBase <nl> between : aropt ( left , right , opts ) - > new Between opts , @ , left , right <nl> reduce : aropt ( func , base ) - > new Reduce { base : base } , @ , funcWrap ( func ) <nl> map : ar ( func ) - > new Map { } , @ , funcWrap ( func ) <nl> - filter : ar ( predicate ) - > new Filter { } , @ , funcWrap ( predicate ) <nl> + filter : aropt ( predicate , opts ) - > new Filter opts , @ , funcWrap ( predicate ) <nl> concatMap : ar ( func ) - > new ConcatMap { } , @ , funcWrap ( func ) <nl> orderBy : varar ( 1 , null , ( fields . . . ) - > new OrderBy { } , @ , fields . . . ) <nl> distinct : ar ( ) - > new Distinct { } , @ <nl> class RDBVal extends TermBase <nl> delete : aropt ( opts ) - > new Delete opts , @ <nl> replace : aropt ( func , opts ) - > new Replace opts , @ , funcWrap ( func ) <nl> do : ar ( func ) - > new FunCall { } , funcWrap ( func ) , @ <nl> + default : ar ( x ) - > new Default { } , @ , x <nl> <nl> or : varar ( 1 , null , ( others . . . ) - > new Any { } , @ , others . . . ) <nl> and : varar ( 1 , null , ( others . . . ) - > new All { } , @ , others . . . ) <nl> class FunCall extends RDBOp <nl> args [ 1 ] = [ ' r ( ' , args [ 1 ] , ' ) ' ] <nl> [ args [ 1 ] , ' . do ( ' , args [ 0 ] , ' ) ' ] <nl> <nl> + class Default extends RDBOp <nl> + tt : Term . TermType . DEFAULT <nl> + mt : ' default ' <nl> + <nl> class Branch extends RDBOp <nl> tt : Term . TermType . BRANCH <nl> st : ' branch ' <nl> mmm a / drivers / javascript / src / query . coffee <nl> ppp b / drivers / javascript / src / query . coffee <nl> rethinkdb . expr = ar ( val ) - > <nl> <nl> rethinkdb . js = aropt ( jssrc , opts ) - > new JavaScript opts , jssrc <nl> <nl> - rethinkdb . error = ar ( errstr ) - > new UserError { } , errstr <nl> + rethinkdb . error = varar 0 , 1 , ( args . . . ) - > new UserError { } , args . . . <nl> <nl> rethinkdb . row = new ImplicitVar { } <nl> <nl> mmm a / drivers / python / rethinkdb / ast . py <nl> ppp b / drivers / python / rethinkdb / ast . py <nl> def without ( self , * attrs ) : <nl> def do ( self , func ) : <nl> return FunCall ( func_wrap ( func ) , self ) <nl> <nl> + def default ( self , handler ) : <nl> + return Default ( self , handler ) <nl> + <nl> def update ( self , func , non_atomic = ( ) , durability = ( ) ) : <nl> return Update ( self , func_wrap ( func ) , non_atomic = non_atomic , durability = durability ) <nl> <nl> def reduce ( self , func , base = ( ) ) : <nl> def map ( self , func ) : <nl> return Map ( self , func_wrap ( func ) ) <nl> <nl> - def filter ( self , func ) : <nl> - return Filter ( self , func_wrap ( func ) ) <nl> + def filter ( self , func , default = ( ) ) : <nl> + return Filter ( self , func_wrap ( func ) , default = default ) <nl> <nl> def concat_map ( self , func ) : <nl> return ConcatMap ( self , func_wrap ( func ) ) <nl> class UserError ( RqlTopLevelQuery ) : <nl> tt = p . Term . ERROR <nl> st = " error " <nl> <nl> + class Default ( RqlQuery ) : <nl> + tt = p . Term . DEFAULT <nl> + st = " default " <nl> + <nl> class ImplicitVar ( RqlQuery ) : <nl> tt = p . Term . IMPLICIT_VAR <nl> <nl> mmm a / drivers / python / rethinkdb / query . py <nl> ppp b / drivers / python / rethinkdb / query . py <nl> <nl> def js ( js_str , timeout = ( ) ) : <nl> return JavaScript ( js_str , timeout = timeout ) <nl> <nl> - def error ( msg ) : <nl> - return UserError ( msg ) <nl> + def error ( * msg ) : <nl> + return UserError ( * msg ) <nl> <nl> def do ( arg0 , * args ) : <nl> args = [ arg0 ] + [ x for x in args ] <nl> mmm a / drivers / ruby / lib / func . rb <nl> ppp b / drivers / ruby / lib / func . rb <nl> def new_func ( & b ) <nl> # if it ' s a Hash . A positive value is necessary for functions <nl> # that can take a hash for the last non - optarg argument . <nl> @ @ optarg_offsets = { <nl> - : replace = > { : with_block = > 0 , : without = > 1 } , <nl> - : update = > { : with_block = > 0 , : without = > 1 } , <nl> + : replace = > { : with_block = > 0 , : without = > 1 } , <nl> + : update = > { : with_block = > 0 , : without = > 1 } , <nl> : insert = > 1 , <nl> : delete = > - 1 , <nl> : reduce = > - 1 , : between = > - 1 , : grouped_map_reduce = > - 1 , <nl> : table = > - 1 , : table_create = > - 1 , <nl> : get_all = > - 1 , : eq_join = > - 1 , <nl> - : javascript = > - 1 <nl> + : javascript = > - 1 , : filter = > { : with_block = > 0 , : without = > 1 } <nl> } <nl> @ @ rewrites = { <nl> : < = > : lt , : < = = > : le , : > = > : gt , : > = = > : ge , <nl> mmm a / src / rdb_protocol / btree . cc <nl> ppp b / src / rdb_protocol / btree . cc <nl> void rdb_replace_and_return_superblock ( <nl> } else if ( new_val - > get_type ( ) = = ql : : datum_t : : R_OBJECT ) { <nl> ended_empty = false ; <nl> rcheck_target ( <nl> - new_val , new_val - > get ( primary_key , ql : : NOTHROW ) . has ( ) , <nl> + new_val , ql : : base_exc_t : : GENERIC , <nl> + new_val - > get ( primary_key , ql : : NOTHROW ) . has ( ) , <nl> strprintf ( " Inserted object must have primary key ` % s ` : \ n % s " , <nl> primary_key . c_str ( ) , new_val - > print ( ) . c_str ( ) ) ) ; <nl> } else { <nl> - rfail_target ( new_val , " Inserted value must be an OBJECT ( got % s ) : \ n % s " , <nl> - new_val - > get_type_name ( ) , new_val - > print ( ) . c_str ( ) ) ; <nl> + rfail_typed_target ( new_val , " Inserted value must be an OBJECT ( got % s ) : \ n % s " , <nl> + new_val - > get_type_name ( ) , new_val - > print ( ) . c_str ( ) ) ; <nl> } <nl> <nl> / / We use ` conflict ` below to store whether or not there was a key <nl> void rdb_replace_and_return_superblock ( <nl> } else { <nl> rfail_target ( <nl> new_val , <nl> + ql : : base_exc_t : : GENERIC , <nl> " Primary key ` % s ` cannot be changed ( % s - > % s ) " , <nl> primary_key . c_str ( ) , <nl> old_val - > print ( ) . c_str ( ) , new_val - > print ( ) . c_str ( ) ) ; <nl> mmm a / src / rdb_protocol / datum . cc <nl> ppp b / src / rdb_protocol / datum . cc <nl> datum_t : : datum_t ( type_t _type , bool _bool ) : type ( _type ) , r_bool ( _bool ) { <nl> r_sanity_check ( _type = = R_BOOL ) ; <nl> } <nl> datum_t : : datum_t ( double _num ) : type ( R_NUM ) , r_num ( _num ) { <nl> - / / so we can use ` isfinite ` in a GCC 4 . 4 . 3 - compatible way <nl> - using namespace std ; / / NOLINT ( build / namespaces ) <nl> - rcheck ( isfinite ( r_num ) , strprintf ( " Non - finite number : " DBLPRI , r_num ) ) ; <nl> + using namespace std ; / / so we can use ` isfinite ` in a GCC 4 . 4 . 3 - compatible way <nl> + rcheck ( isfinite ( r_num ) , base_exc_t : : GENERIC , <nl> + strprintf ( " Non - finite number : " DBLPRI , r_num ) ) ; <nl> } <nl> datum_t : : datum_t ( const std : : string & _str ) <nl> : type ( R_STR ) , r_str ( new std : : string ( _str ) ) { <nl> void datum_t : : init_json ( cJSON * json , env_t * env ) { <nl> void datum_t : : check_str_validity ( const std : : string & str ) { <nl> size_t null_offset = str . find ( ' \ 0 ' ) ; <nl> rcheck ( null_offset = = std : : string : : npos , <nl> + base_exc_t : : GENERIC , <nl> / / We truncate because lots of other places can call ` c_str ` on the <nl> / / error message . <nl> strprintf ( " String ` % . 20s ` ( truncated ) contains NULL byte at offset % zu . " , <nl> void datum_t : : array_to_str_key ( std : : string * str_out ) const { <nl> } else if ( item - > type = = R_ARRAY ) { <nl> item - > array_to_str_key ( str_out ) ; <nl> } else { <nl> - rfail ( " Secondary keys must be a number , string , bool , or array ( got % s of type % s ) . " , <nl> - item - > print ( ) . c_str ( ) , datum_type_name ( item - > type ) ) ; <nl> + item - > type_error ( <nl> + strprintf ( " Secondary keys must be a number , string , bool , or array " <nl> + " ( got % s of type % s ) . " , item - > print ( ) . c_str ( ) , <nl> + datum_type_name ( item - > type ) ) ) ; <nl> } <nl> <nl> str_out - > append ( std : : string ( 1 , ' \ 0 ' ) ) ; <nl> std : : string datum_t : : print_primary ( ) const { <nl> } else if ( type = = R_BOOL ) { <nl> bool_to_str_key ( & s ) ; <nl> } else { <nl> - rfail ( " Primary keys must be either a number , bool , or string ( got % s of type % s ) . " , <nl> - print ( ) . c_str ( ) , datum_type_name ( type ) ) ; <nl> + type_error ( strprintf ( <nl> + " Primary keys must be either a number , bool , or string ( got % s of type % s ) . " , <nl> + print ( ) . c_str ( ) , datum_type_name ( type ) ) ) ; <nl> } <nl> if ( s . size ( ) > rdb_protocol_t : : MAX_PRIMARY_KEY_SIZE ) { <nl> - rfail ( " Primary key too long ( max % zu characters ) : % s " , <nl> + rfail ( base_exc_t : : GENERIC , <nl> + " Primary key too long ( max % zu characters ) : % s " , <nl> rdb_protocol_t : : MAX_PRIMARY_KEY_SIZE - 1 , print ( ) . c_str ( ) ) ; <nl> } <nl> return s ; <nl> std : : string datum_t : : print_secondary ( const store_key_t & primary_key ) const { <nl> std : : string primary_key_string = key_to_unescaped_str ( primary_key ) ; <nl> <nl> if ( primary_key_string . length ( ) > rdb_protocol_t : : MAX_PRIMARY_KEY_SIZE ) { <nl> - rfail ( " Primary key too long ( max % zu characters ) : % s " , <nl> - rdb_protocol_t : : MAX_PRIMARY_KEY_SIZE - 1 , key_to_debug_str ( primary_key ) . c_str ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , <nl> + " Primary key too long ( max % zu characters ) : % s " , <nl> + rdb_protocol_t : : MAX_PRIMARY_KEY_SIZE - 1 , <nl> + key_to_debug_str ( primary_key ) . c_str ( ) ) ; <nl> } <nl> <nl> if ( type = = R_NUM ) { <nl> std : : string datum_t : : print_secondary ( const store_key_t & primary_key ) const { <nl> } else if ( type = = R_ARRAY ) { <nl> array_to_str_key ( & s ) ; <nl> } else { <nl> - rfail ( " Secondary keys must be a number , string , bool , or array ( got % s of type % s ) . " , <nl> - print ( ) . c_str ( ) , datum_type_name ( type ) ) ; <nl> + type_error ( strprintf ( <nl> + " Secondary keys must be a number , string , bool , or array " <nl> + " ( got % s of type % s ) . " , <nl> + print ( ) . c_str ( ) , datum_type_name ( type ) ) ) ; <nl> } <nl> <nl> s = s . substr ( 0 , MAX_KEY_SIZE - primary_key_string . length ( ) - 1 ) + <nl> store_key_t datum_t : : truncated_secondary ( ) const { <nl> } else if ( type = = R_ARRAY ) { <nl> array_to_str_key ( & s ) ; <nl> } else { <nl> - rfail ( " Secondary keys must be a number , string , bool , or array ( got % s of type % s ) . " , <nl> - print ( ) . c_str ( ) , datum_type_name ( type ) ) ; <nl> + type_error ( strprintf ( <nl> + " Secondary keys must be a number , string , bool , or array " <nl> + " ( got % s of type % s ) . " , <nl> + print ( ) . c_str ( ) , datum_type_name ( type ) ) ) ; <nl> } <nl> <nl> const size_t max_trunc_size = MAX_KEY_SIZE - rdb_protocol_t : : MAX_PRIMARY_KEY_SIZE - 1 ; <nl> store_key_t datum_t : : truncated_secondary ( ) const { <nl> return store_key_t ( s ) ; <nl> } <nl> <nl> - void datum_t : : check_type ( type_t desired ) const { <nl> - rcheck ( get_type ( ) = = desired , <nl> - strprintf ( " Expected type % s but found % s . " , <nl> - datum_type_name ( desired ) , datum_type_name ( get_type ( ) ) ) ) ; <nl> + void datum_t : : check_type ( type_t desired , const char * msg ) const { <nl> + rcheck_typed_target ( <nl> + this , get_type ( ) = = desired , <nl> + ( msg ! = NULL ) <nl> + ? std : : string ( msg ) <nl> + : strprintf ( " Expected type % s but found % s . " , <nl> + datum_type_name ( desired ) , datum_type_name ( get_type ( ) ) ) ) ; <nl> + } <nl> + void datum_t : : type_error ( const std : : string & msg ) const { <nl> + rfail_typed_target ( this , " % s " , msg . c_str ( ) ) ; <nl> } <nl> <nl> bool datum_t : : as_bool ( ) const { <nl> static const double min_dbl_int = max_dbl_int * - 1 ; <nl> int64_t datum_t : : as_int ( ) const { <nl> static_assert ( DBL_MANT_DIG = = 53 , " ERROR : Doubles are wrong size . " ) ; <nl> double d = as_num ( ) ; <nl> - rcheck ( d < = max_dbl_int , strprintf ( " Number not an integer ( > 2 ^ 53 ) : " DBLPRI , d ) ) ; <nl> - rcheck ( d > = min_dbl_int , strprintf ( " Number not an integer ( < - 2 ^ 53 ) : " DBLPRI , d ) ) ; <nl> + rcheck ( d < = max_dbl_int , base_exc_t : : GENERIC , <nl> + strprintf ( " Number not an integer ( > 2 ^ 53 ) : " DBLPRI , d ) ) ; <nl> + rcheck ( d > = min_dbl_int , base_exc_t : : GENERIC , <nl> + strprintf ( " Number not an integer ( < - 2 ^ 53 ) : " DBLPRI , d ) ) ; <nl> int64_t i = d ; <nl> - rcheck ( static_cast < double > ( i ) = = d , strprintf ( " Number not an integer : " DBLPRI , d ) ) ; <nl> + rcheck ( static_cast < double > ( i ) = = d , base_exc_t : : GENERIC , <nl> + strprintf ( " Number not an integer : " DBLPRI , d ) ) ; <nl> return i ; <nl> } <nl> <nl> size_t datum_t : : size ( ) const { <nl> } <nl> <nl> counted_t < const datum_t > datum_t : : get ( size_t index , throw_bool_t throw_bool ) const { <nl> - if ( index < size ( ) ) return as_array ( ) [ index ] ; <nl> - if ( throw_bool = = THROW ) rfail ( " Index out of bounds : % zu " , index ) ; <nl> - return counted_t < const datum_t > ( ) ; <nl> + if ( index < size ( ) ) { <nl> + return as_array ( ) [ index ] ; <nl> + } else if ( throw_bool = = THROW ) { <nl> + rfail ( base_exc_t : : NON_EXISTENCE , " Index out of bounds : % zu " , index ) ; <nl> + } else { <nl> + return counted_t < const datum_t > ( ) ; <nl> + } <nl> } <nl> <nl> counted_t < const datum_t > datum_t : : get ( const std : : string & key , <nl> counted_t < const datum_t > datum_t : : get ( const std : : string & key , <nl> = as_object ( ) . find ( key ) ; <nl> if ( it ! = as_object ( ) . end ( ) ) return it - > second ; <nl> if ( throw_bool = = THROW ) { <nl> - rfail ( " No attribute ` % s ` in object : \ n % s " , key . c_str ( ) , print ( ) . c_str ( ) ) ; <nl> + rfail ( base_exc_t : : NON_EXISTENCE , <nl> + " No attribute ` % s ` in object : \ n % s " , key . c_str ( ) , print ( ) . c_str ( ) ) ; <nl> } <nl> return counted_t < const datum_t > ( ) ; <nl> } <nl> datum_t : : as_datum_stream ( env_t * env , <nl> case R_BOOL : / / fallthru <nl> case R_NUM : / / fallthru <nl> case R_STR : / / fallthru <nl> - case R_OBJECT : rfail ( " Cannot convert % s to SEQUENCE " , datum_type_name ( get_type ( ) ) ) ; <nl> + case R_OBJECT : <nl> + type_error ( strprintf ( " Cannot convert % s to SEQUENCE " , <nl> + datum_type_name ( get_type ( ) ) ) ) ; <nl> case R_ARRAY : <nl> return make_counted < array_datum_stream_t > ( env , <nl> this - > counted_from_this ( ) , <nl> datum_t : : datum_t ( const Datum * d , env_t * env ) { <nl> / / so we can use ` isfinite ` in a GCC 4 . 4 . 3 - compatible way <nl> using namespace std ; / / NOLINT ( build / namespaces ) <nl> rcheck ( isfinite ( r_num ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Illegal non - finite number ` " DBLPRI " ` . " , r_num ) ) ; <nl> } break ; <nl> case Datum_DatumType_R_STR : { <nl> datum_t : : datum_t ( const Datum * d , env_t * env ) { <nl> const std : : string & key = ap - > key ( ) ; <nl> check_str_validity ( key ) ; <nl> rcheck ( r_object - > count ( key ) = = 0 , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Duplicate key % s in object . " , key . c_str ( ) ) ) ; <nl> ( * r_object ) [ key ] = make_counted < datum_t > ( & ap - > val ( ) , env ) ; <nl> } <nl> mmm a / src / rdb_protocol / datum . hpp <nl> ppp b / src / rdb_protocol / datum . hpp <nl> class datum_t : public slow_atomic_countable_t < datum_t > , public rcheckable_t { <nl> / * An inverse to print_secondary . Returns the primary key . * / <nl> static std : : string unprint_secondary ( const std : : string & secondary_and_primary ) ; <nl> store_key_t truncated_secondary ( ) const ; <nl> - void check_type ( type_t desired ) const ; <nl> + void check_type ( type_t desired , const char * msg = NULL ) const ; <nl> + void type_error ( const std : : string & msg ) const NORETURN ; <nl> <nl> bool as_bool ( ) const ; <nl> double as_num ( ) const ; <nl> class datum_t : public slow_atomic_countable_t < datum_t > , public rcheckable_t { <nl> bool operator > ( const datum_t & rhs ) const ; <nl> bool operator > = ( const datum_t & rhs ) const ; <nl> <nl> - virtual void runtime_check ( const char * test , const char * file , int line , <nl> + virtual void runtime_check ( base_exc_t : : type_t exc_type , <nl> + const char * test , const char * file , int line , <nl> bool pred , std : : string msg ) const { <nl> - ql : : runtime_check ( test , file , line , pred , msg ) ; <nl> + ql : : runtime_check ( exc_type , test , file , line , pred , msg ) ; <nl> } <nl> <nl> private : <nl> mmm a / src / rdb_protocol / datum_stream . cc <nl> ppp b / src / rdb_protocol / datum_stream . cc <nl> counted_t < const datum_t > datum_stream_t : : next ( ) { <nl> try { <nl> return next_impl ( ) ; <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> std : : vector < counted_t < const datum_t > > datum_stream_t : : next_batch ( ) { <nl> } <nl> } <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> counted_t < const datum_t > eager_datum_stream_t : : count ( ) { <nl> counted_t < const datum_t > eager_datum_stream_t : : reduce ( counted_t < val_t > base_val , <nl> counted_t < func_t > f ) { <nl> counted_t < const datum_t > base = base_val . has ( ) ? base_val - > as_datum ( ) : next ( ) ; <nl> - rcheck ( base . has ( ) , " Cannot reduce over an empty stream with no base . " ) ; <nl> + rcheck ( base . has ( ) , base_exc_t : : NON_EXISTENCE , <nl> + " Cannot reduce over an empty stream with no base . " ) ; <nl> <nl> while ( counted_t < const datum_t > rhs = next ( ) ) { <nl> base = f - > call ( base , rhs ) - > as_datum ( ) ; <nl> counted_t < const datum_t > lazy_datum_stream_t : : reduce ( counted_t < val_t > base_val , <nl> if ( base_val . has ( ) ) { <nl> return base_val - > as_datum ( ) ; <nl> } else { <nl> - rfail ( " Cannot reduce over an empty stream with no base . " ) ; <nl> + rfail ( base_exc_t : : NON_EXISTENCE , <nl> + " Cannot reduce over an empty stream with no base . " ) ; <nl> } <nl> } <nl> } <nl> counted_t < const datum_t > zip_datum_stream_t : : next_impl ( ) { <nl> <nl> counted_t < const datum_t > left = datum - > get ( " left " , NOTHROW ) ; <nl> counted_t < const datum_t > right = datum - > get ( " right " , NOTHROW ) ; <nl> - rcheck ( left . has ( ) , " ZIP can only be called on the result of a join . " ) ; <nl> + rcheck ( left . has ( ) , base_exc_t : : GENERIC , <nl> + " ZIP can only be called on the result of a join . " ) ; <nl> return right . has ( ) ? left - > merge ( right ) : left ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / datum_stream . hpp <nl> ppp b / src / rdb_protocol / datum_stream . hpp <nl> class sort_datum_stream_t : public eager_datum_stream_t { <nl> if ( counted_t < const datum_t > arr = src - > as_array ( ) ) { <nl> is_arr_ = true ; <nl> rcheck ( arr - > size ( ) < = sort_el_limit , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Can only sort at most % zu elements . " , <nl> sort_el_limit ) ) ; <nl> for ( size_t i = 0 ; i < arr - > size ( ) ; + + i ) { <nl> class sort_datum_stream_t : public eager_datum_stream_t { <nl> size_t sort_els = 0 ; <nl> while ( counted_t < const datum_t > d = src - > next ( ) ) { <nl> rcheck ( + + sort_els < = sort_el_limit , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Can only sort at most % zu elements . " , <nl> sort_el_limit ) ) ; <nl> data . push_back ( d ) ; <nl> mmm a / src / rdb_protocol / env . cc <nl> ppp b / src / rdb_protocol / env . cc <nl> void env_t : : push_implicit ( counted_t < const datum_t > * val ) { <nl> implicit_var . push ( val ) ; <nl> } <nl> counted_t < const datum_t > * env_t : : top_implicit ( const rcheckable_t * caller ) { <nl> - rcheck_target ( caller , ! implicit_var . empty ( ) , <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , ! implicit_var . empty ( ) , <nl> " r . row is not defined in this context . " ) ; <nl> - rcheck_target ( caller , implicit_var . size ( ) = = 1 , <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , implicit_var . size ( ) = = 1 , <nl> " Cannot use r . row in nested queries . Use functions instead . " ) ; <nl> return implicit_var . top ( ) ; <nl> } <nl> env_t : : special_var_shadower_t : : ~ special_var_shadower_t ( ) { <nl> } <nl> <nl> counted_t < const datum_t > * env_t : : top_var ( int var , const rcheckable_t * caller ) { <nl> - rcheck_target ( caller , ! vars [ var ] . empty ( ) , <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , ! vars [ var ] . empty ( ) , <nl> strprintf ( " Unrecognized variabled % d " , var ) ) ; <nl> counted_t < const datum_t > * var_val = vars [ var ] . top ( ) ; <nl> - rcheck_target ( caller , var_val ! = & sindex_error_dummy_datum , <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , <nl> + var_val ! = & sindex_error_dummy_datum , <nl> " Cannot reference external variables from inside an index . " ) ; <nl> return var_val ; <nl> } <nl> mmm a / src / rdb_protocol / error . cc <nl> ppp b / src / rdb_protocol / error . cc <nl> <nl> # include " rdb_protocol / error . hpp " <nl> <nl> # include " backtrace . hpp " <nl> + # include " rdb_protocol / datum . hpp " <nl> # include " rdb_protocol / term_walker . hpp " <nl> + # include " rdb_protocol / val . hpp " <nl> <nl> namespace ql { <nl> - void runtime_check ( DEBUG_VAR const char * test , DEBUG_VAR const char * file , <nl> + void runtime_check ( base_exc_t : : type_t type , <nl> + DEBUG_VAR const char * test , DEBUG_VAR const char * file , <nl> DEBUG_VAR int line , bool pred , <nl> std : : string msg , const Backtrace * bt_src , <nl> int dummy_frames ) { <nl> void runtime_check ( DEBUG_VAR const char * test , DEBUG_VAR const char * file , <nl> msg = strprintf ( " % s \ nFailed assertion : % s \ nAt : % s : % d " , <nl> msg . c_str ( ) , test , file , line ) ; <nl> # endif <nl> - throw exc_t ( msg , bt_src , dummy_frames ) ; <nl> + throw exc_t ( type , msg , bt_src , dummy_frames ) ; <nl> } <nl> - void runtime_check ( DEBUG_VAR const char * test , DEBUG_VAR const char * file , <nl> + void runtime_check ( base_exc_t : : type_t type , <nl> + DEBUG_VAR const char * test , DEBUG_VAR const char * file , <nl> DEBUG_VAR int line , bool pred , std : : string msg ) { <nl> if ( pred ) return ; <nl> # ifndef NDEBUG <nl> msg = strprintf ( " % s \ nFailed assertion : % s \ nAt : % s : % d " , <nl> msg . c_str ( ) , test , file , line ) ; <nl> # endif <nl> - throw datum_exc_t ( msg ) ; <nl> + throw datum_exc_t ( type , msg ) ; <nl> } <nl> <nl> void runtime_sanity_check ( bool test ) { <nl> if ( ! test ) { <nl> lazy_backtrace_t bt ; <nl> - throw exc_t ( " SANITY CHECK FAILED ( server is buggy ) . Backtrace : \ n " + bt . addrs ( ) , <nl> + throw exc_t ( base_exc_t : : GENERIC , <nl> + " SANITY CHECK FAILED ( server is buggy ) . Backtrace : \ n " + bt . addrs ( ) , <nl> backtrace_t ( ) ) ; <nl> } <nl> } <nl> <nl> + base_exc_t : : type_t exc_type ( const datum_t * d ) { <nl> + r_sanity_check ( d ) ; <nl> + return d - > get_type ( ) = = datum_t : : R_NULL <nl> + ? base_exc_t : : NON_EXISTENCE <nl> + : base_exc_t : : GENERIC ; <nl> + } <nl> + base_exc_t : : type_t exc_type ( const counted_t < const datum_t > & d ) { <nl> + r_sanity_check ( d . has ( ) ) ; <nl> + return exc_type ( d . get ( ) ) ; <nl> + } <nl> + base_exc_t : : type_t exc_type ( val_t * v ) { <nl> + r_sanity_check ( v ) ; <nl> + if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : DATUM ) ) { <nl> + return exc_type ( v - > as_datum ( ) ) ; <nl> + } else { <nl> + return base_exc_t : : GENERIC ; <nl> + } <nl> + } <nl> + base_exc_t : : type_t exc_type ( const counted_t < val_t > & v ) { <nl> + r_sanity_check ( v . has ( ) ) ; <nl> + return exc_type ( v . get ( ) ) ; <nl> + } <nl> + <nl> void backtrace_t : : fill_bt ( Backtrace * bt ) const { <nl> for ( std : : list < backtrace_t : : frame_t > : : const_iterator <nl> it = frames . begin ( ) ; it ! = frames . end ( ) ; + + it ) { <nl> mmm a / src / rdb_protocol / error . hpp <nl> ppp b / src / rdb_protocol / error . hpp <nl> <nl> <nl> namespace ql { <nl> <nl> + / / Catch this if you want to handle either ` exc_t ` or ` datum_exc_t ` . <nl> + class base_exc_t : public std : : exception { <nl> + public : <nl> + enum type_t { <nl> + GENERIC , / / All errors except those below . <nl> + <nl> + / / The only thing that cares about these is ` default ` . <nl> + EMPTY_USER , / / An error caused by ` r . error ` with no arguments . <nl> + NON_EXISTENCE / / An error related to the absence of an expected value . <nl> + } ; <nl> + base_exc_t ( type_t type ) : type_ ( type ) { } <nl> + virtual ~ base_exc_t ( ) throw ( ) { } <nl> + type_t get_type ( ) const { return type_ ; } <nl> + protected : <nl> + type_t type_ ; <nl> + } ; <nl> + ARCHIVE_PRIM_MAKE_RANGED_SERIALIZABLE ( <nl> + base_exc_t : : type_t , int8_t , base_exc_t : : GENERIC , base_exc_t : : NON_EXISTENCE ) ; <nl> + <nl> / / NOTE : you usually want to inherit from ` rcheckable_t ` instead of calling this <nl> / / directly . <nl> - void runtime_check ( const char * test , const char * file , int line , <nl> + void runtime_check ( base_exc_t : : type_t type , <nl> + const char * test , const char * file , int line , <nl> bool pred , std : : string msg , const Backtrace * bt_src , <nl> int dummy_frames = 0 ) ; <nl> - void runtime_check ( const char * test , const char * file , int line , <nl> + void runtime_check ( base_exc_t : : type_t type , <nl> + const char * test , const char * file , int line , <nl> bool pred , std : : string msg ) ; <nl> void runtime_sanity_check ( bool test ) ; <nl> <nl> void runtime_sanity_check ( bool test ) ; <nl> class rcheckable_t { <nl> public : <nl> virtual ~ rcheckable_t ( ) { } <nl> - virtual void runtime_check ( const char * test , const char * file , int line , <nl> + virtual void runtime_check ( base_exc_t : : type_t type , <nl> + const char * test , const char * file , int line , <nl> bool pred , std : : string msg ) const = 0 ; <nl> } ; <nl> / / This is a particular type of rcheckable . A ` pb_rcheckable_t ` corresponds to <nl> class pb_rcheckable_t : public rcheckable_t { <nl> explicit pb_rcheckable_t ( const protob_t < const Backtrace > & _bt_src ) <nl> : bt_src ( _bt_src ) { } <nl> <nl> - virtual void runtime_check ( const char * test , const char * file , int line , <nl> + virtual void runtime_check ( base_exc_t : : type_t type , <nl> + const char * test , const char * file , int line , <nl> bool pred , std : : string msg ) const { <nl> - ql : : runtime_check ( test , file , line , pred , msg , bt_src . get ( ) ) ; <nl> + ql : : runtime_check ( type , test , file , line , pred , msg , bt_src . get ( ) ) ; <nl> } <nl> <nl> / / Propagate the associated backtrace through the rewrite term . <nl> class pb_rcheckable_t : public rcheckable_t { <nl> } ; <nl> <nl> / / Use these macros to return errors to users . <nl> - # define rcheck_target ( target , pred , msg ) do { \ <nl> - ( pred ) \ <nl> - ? ( void ) 0 \ <nl> - : ( target ) - > runtime_check ( stringify ( pred ) , __FILE__ , __LINE__ , false , ( msg ) ) ; \ <nl> + # define rcheck_target ( target , type , pred , msg ) do { \ <nl> + ( pred ) \ <nl> + ? ( void ) 0 \ <nl> + : ( target ) - > runtime_check ( type , stringify ( pred ) , \ <nl> + __FILE__ , __LINE__ , false , ( msg ) ) ; \ <nl> + } while ( 0 ) <nl> + # define rcheck_typed_target ( target , pred , msg ) do { \ <nl> + ( pred ) \ <nl> + ? ( void ) 0 \ <nl> + : ( target ) - > runtime_check ( exc_type ( target ) , stringify ( pred ) , \ <nl> + __FILE__ , __LINE__ , false , ( msg ) ) ; \ <nl> } while ( 0 ) <nl> - # define rcheck_src ( src , pred , msg ) do { \ <nl> - ( pred ) \ <nl> - ? ( void ) 0 \ <nl> - : ql : : runtime_check ( stringify ( pred ) , __FILE__ , __LINE__ , false , ( msg ) , ( src ) ) ; \ <nl> + # define rcheck_src ( src , type , pred , msg ) do { \ <nl> + ( pred ) \ <nl> + ? ( void ) 0 \ <nl> + : ql : : runtime_check ( type , stringify ( pred ) , \ <nl> + __FILE__ , __LINE__ , false , ( msg ) , ( src ) ) ; \ <nl> } while ( 0 ) <nl> <nl> - # define rcheck ( pred , msg ) rcheck_target ( this , pred , msg ) <nl> - # define rcheck_toplevel ( pred , msg ) rcheck_src ( NULL , pred , msg ) <nl> + # define rcheck ( pred , type , msg ) rcheck_target ( this , type , pred , msg ) <nl> + # define rcheck_typed ( pred , typed_arg , msg ) \ <nl> + rcheck_target ( this , exc_type ( typed_arg ) , typed_arg , pred , msg ) <nl> + # define rcheck_toplevel ( pred , type , msg ) \ <nl> + rcheck_src ( NULL , type , pred , msg ) <nl> <nl> - # define rfail_target ( target , args . . . ) do { \ <nl> - rcheck_target ( target , false , strprintf ( args ) ) ; \ <nl> - unreachable ( ) ; \ <nl> + # define rfail_target ( target , type , args . . . ) do { \ <nl> + rcheck_target ( target , type , false , strprintf ( args ) ) ; \ <nl> + unreachable ( ) ; \ <nl> + } while ( 0 ) <nl> + # define rfail_typed_target ( target , args . . . ) do { \ <nl> + rcheck_typed_target ( target , false , strprintf ( args ) ) ; \ <nl> + unreachable ( ) ; \ <nl> + } while ( 0 ) <nl> + # define rfail ( type , args . . . ) do { \ <nl> + rcheck ( false , type , strprintf ( args ) ) ; \ <nl> + unreachable ( ) ; \ <nl> } while ( 0 ) <nl> - # define rfail ( args . . . ) do { \ <nl> - rcheck ( false , strprintf ( args ) ) ; \ <nl> + # define rfail_toplevel ( type , args . . . ) do { \ <nl> + rcheck_toplevel ( false , type , strprintf ( args ) ) ; \ <nl> + unreachable ( ) ; \ <nl> + } while ( 0 ) <nl> + # define rfail_typed ( typed_arg , args . . . ) do { \ <nl> + rcheck_typed ( false , typed_arg , strprintf ( args ) ) ; \ <nl> unreachable ( ) ; \ <nl> } while ( 0 ) <nl> - # define rfail_toplevel ( args . . . ) rcheck_toplevel ( false , strprintf ( args ) ) <nl> <nl> <nl> + class datum_t ; <nl> + class val_t ; <nl> + base_exc_t : : type_t exc_type ( const datum_t * d ) ; <nl> + base_exc_t : : type_t exc_type ( const counted_t < const datum_t > & d ) ; <nl> + base_exc_t : : type_t exc_type ( val_t * d ) ; <nl> + base_exc_t : : type_t exc_type ( const counted_t < val_t > & v ) ; <nl> + <nl> / / r_sanity_check should be used in place of guarantee if you think the <nl> / / guarantee will almost always fail due to an error in the query logic rather <nl> / / than memory corruption . <nl> class backtrace_t { <nl> <nl> const backtrace_t : : frame_t head_frame = backtrace_t : : frame_t : : head ( ) ; <nl> <nl> - / / Catch this if you want to handle either ` exc_t ` or ` datum_exc_t ` . <nl> - class base_exc_t : public std : : exception { <nl> - public : <nl> - virtual ~ base_exc_t ( ) throw ( ) { } <nl> - } ; <nl> - <nl> / / A RQL exception . <nl> class exc_t : public base_exc_t { <nl> public : <nl> / / We have a default constructor because these are serialized . <nl> - exc_t ( ) : exc_msg_ ( " UNINITIALIZED " ) { } <nl> - exc_t ( const std : : string & exc_msg , const Backtrace * bt_src , int dummy_frames = 0 ) <nl> - : exc_msg_ ( exc_msg ) { <nl> + exc_t ( ) : base_exc_t ( base_exc_t : : GENERIC ) , exc_msg_ ( " UNINITIALIZED " ) { } <nl> + exc_t ( base_exc_t : : type_t type , const std : : string & exc_msg , <nl> + const Backtrace * bt_src , int dummy_frames = 0 ) <nl> + : base_exc_t ( type ) , exc_msg_ ( exc_msg ) { <nl> + if ( bt_src ! = NULL ) { <nl> + backtrace_ = backtrace_t ( bt_src ) ; <nl> + } <nl> + backtrace_ . delete_frames ( dummy_frames ) ; <nl> + } <nl> + exc_t ( const base_exc_t & e , const Backtrace * bt_src , int dummy_frames = 0 ) <nl> + : base_exc_t ( e . get_type ( ) ) , exc_msg_ ( e . what ( ) ) { <nl> if ( bt_src ! = NULL ) { <nl> backtrace_ = backtrace_t ( bt_src ) ; <nl> } <nl> backtrace_ . delete_frames ( dummy_frames ) ; <nl> } <nl> - exc_t ( const std : : string & exc_msg , const backtrace_t & backtrace , <nl> - int dummy_frames = 0 ) <nl> - : backtrace_ ( backtrace ) , exc_msg_ ( exc_msg ) { <nl> + exc_t ( base_exc_t : : type_t type , const std : : string & exc_msg , <nl> + const backtrace_t & backtrace , int dummy_frames = 0 ) <nl> + : base_exc_t ( type ) , backtrace_ ( backtrace ) , exc_msg_ ( exc_msg ) { <nl> backtrace_ . delete_frames ( dummy_frames ) ; <nl> } <nl> virtual ~ exc_t ( ) throw ( ) { } <nl> class exc_t : public base_exc_t { <nl> const char * what ( ) const throw ( ) { return exc_msg_ . c_str ( ) ; } <nl> const backtrace_t & backtrace ( ) const { return backtrace_ ; } <nl> <nl> - RDB_MAKE_ME_SERIALIZABLE_2 ( backtrace_ , exc_msg_ ) ; <nl> + RDB_MAKE_ME_SERIALIZABLE_3 ( type_ , backtrace_ , exc_msg_ ) ; <nl> private : <nl> backtrace_t backtrace_ ; <nl> std : : string exc_msg_ ; <nl> class exc_t : public base_exc_t { <nl> / / turned into a normal ` exc_t ` . <nl> class datum_exc_t : public base_exc_t { <nl> public : <nl> - datum_exc_t ( ) : exc_msg ( " UNINITIALIZED " ) { } <nl> - explicit datum_exc_t ( const std : : string & _exc_msg ) : exc_msg ( _exc_msg ) { } <nl> + datum_exc_t ( ) : base_exc_t ( base_exc_t : : GENERIC ) , exc_msg ( " UNINITIALIZED " ) { } <nl> + explicit datum_exc_t ( base_exc_t : : type_t type , const std : : string & _exc_msg ) <nl> + : base_exc_t ( type ) , exc_msg ( _exc_msg ) { } <nl> virtual ~ datum_exc_t ( ) throw ( ) { } <nl> const char * what ( ) const throw ( ) { return exc_msg . c_str ( ) ; } <nl> <nl> class datum_exc_t : public base_exc_t { <nl> std : : string exc_msg ; <nl> <nl> public : <nl> - RDB_MAKE_ME_SERIALIZABLE_1 ( exc_msg ) ; <nl> + RDB_MAKE_ME_SERIALIZABLE_2 ( type_ , exc_msg ) ; <nl> } ; <nl> <nl> void fill_error ( Response * res , Response_ResponseType type , std : : string msg , <nl> mmm a / src / rdb_protocol / func . cc <nl> ppp b / src / rdb_protocol / func . cc <nl> func_t : : func_t ( env_t * env , protob_t < const Term > _source ) <nl> js_env ( NULL ) , js_id ( js : : INVALID_ID ) { <nl> protob_t < const Term > t = _source ; <nl> r_sanity_check ( t - > type ( ) = = Term_TermType_FUNC ) ; <nl> - rcheck ( t - > optargs_size ( ) = = 0 , " FUNC takes no optional arguments . " ) ; <nl> - rcheck ( t - > args_size ( ) = = 2 , strprintf ( " Func takes exactly two arguments ( got % d ) " , <nl> - t - > args_size ( ) ) ) ; <nl> + rcheck ( t - > optargs_size ( ) = = 0 , <nl> + base_exc_t : : GENERIC , <nl> + " FUNC takes no optional arguments . " ) ; <nl> + rcheck ( t - > args_size ( ) = = 2 , <nl> + base_exc_t : : GENERIC , <nl> + strprintf ( " Func takes exactly two arguments ( got % d ) " , t - > args_size ( ) ) ) ; <nl> <nl> std : : vector < int > args ; <nl> const Term * vars = & t - > args ( 0 ) ; <nl> if ( vars - > type ( ) = = Term_TermType_DATUM ) { <nl> const Datum * d = & vars - > datum ( ) ; <nl> rcheck ( d - > type ( ) = = Datum_DatumType_R_ARRAY , <nl> + base_exc_t : : GENERIC , <nl> " CLIENT ERROR : FUNC variables must be a literal * array * of numbers . " ) ; <nl> for ( int i = 0 ; i < d - > r_array_size ( ) ; + + i ) { <nl> const Datum * dnum = & d - > r_array ( i ) ; <nl> rcheck ( dnum - > type ( ) = = Datum_DatumType_R_NUM , <nl> + base_exc_t : : GENERIC , <nl> " CLIENT ERROR : FUNC variables must be a literal array of * numbers * . " ) ; <nl> args . push_back ( dnum - > r_num ( ) ) ; <nl> } <nl> func_t : : func_t ( env_t * env , protob_t < const Term > _source ) <nl> for ( int i = 0 ; i < vars - > args_size ( ) ; + + i ) { <nl> const Term * arg = & vars - > args ( i ) ; <nl> rcheck ( arg - > type ( ) = = Term_TermType_DATUM , <nl> + base_exc_t : : GENERIC , <nl> " CLIENT ERROR : FUNC variables must be a * literal * array of numbers . " ) ; <nl> const Datum * dnum = & arg - > datum ( ) ; <nl> rcheck ( dnum - > type ( ) = = Datum_DatumType_R_NUM , <nl> + base_exc_t : : GENERIC , <nl> " CLIENT ERROR : FUNC variables must be a literal array of * numbers * . " ) ; <nl> args . push_back ( dnum - > r_num ( ) ) ; <nl> } <nl> } else { <nl> - rfail ( " CLIENT ERROR : FUNC variables must be a * literal array of numbers * . " ) ; <nl> + rfail ( base_exc_t : : GENERIC , <nl> + " CLIENT ERROR : FUNC variables must be a * literal array of numbers * . " ) ; <nl> } <nl> <nl> argptrs . init ( args . size ( ) ) ; <nl> counted_t < val_t > func_t : : call ( const std : : vector < counted_t < const datum_t > > & args <nl> r_sanity_check ( body . has ( ) & & source . has ( ) & & js_env = = NULL ) ; <nl> rcheck ( args . size ( ) = = static_cast < size_t > ( argptrs . size ( ) ) <nl> | | argptrs . size ( ) = = 0 , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Expected % zd argument ( s ) but found % zu . " , <nl> argptrs . size ( ) , args . size ( ) ) ) ; <nl> for ( ssize_t i = 0 ; i < argptrs . size ( ) ; + + i ) { <nl> counted_t < val_t > func_t : : call ( const std : : vector < counted_t < const datum_t > > & args <nl> return body - > eval ( ) ; <nl> } <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> bool func_t : : is_deterministic ( ) const { <nl> } <nl> void func_t : : assert_deterministic ( const char * extra_msg ) const { <nl> rcheck ( is_deterministic ( ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Could not prove function deterministic . % s " , extra_msg ) ) ; <nl> } <nl> <nl> std : : string func_t : : print_src ( ) const { <nl> return source - > DebugString ( ) ; <nl> } <nl> <nl> + void func_t : : set_default_filter_val ( counted_t < func_t > func ) { <nl> + default_filter_val = func ; <nl> + } <nl> + <nl> / / This JS evaluation resulted in an error <nl> counted_t < val_t > js_result_visitor_t : : operator ( ) ( const std : : string err_val ) const { <nl> - rfail_target ( parent , " % s " , err_val . c_str ( ) ) ; <nl> + rfail_target ( parent , base_exc_t : : GENERIC , " % s " , err_val . c_str ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> <nl> counted_t < val_t > js_result_visitor_t : : operator ( ) ( const id_t id_val ) const { <nl> wire_func_t : : wire_func_t ( ) : source ( make_counted_term ( ) ) { } <nl> wire_func_t : : wire_func_t ( env_t * env , counted_t < func_t > func ) <nl> : source ( make_counted_term_copy ( * func - > source ) ) { <nl> + if ( func - > default_filter_val . has ( ) ) { <nl> + default_filter_val = * func - > default_filter_val - > source . get ( ) ; <nl> + } <nl> if ( env ) { <nl> cached_funcs [ env - > uuid ] = func ; <nl> } <nl> counted_t < func_t > wire_func_t : : compile ( env_t * env ) { <nl> if ( cached_funcs . count ( env - > uuid ) = = 0 ) { <nl> env - > push_scope ( & scope ) ; <nl> cached_funcs [ env - > uuid ] = compile_term ( env , source ) - > eval ( ) - > as_func ( ) ; <nl> + if ( default_filter_val ) { <nl> + cached_funcs [ env - > uuid ] - > set_default_filter_val ( <nl> + make_counted < func_t > ( env , make_counted_term_copy ( * default_filter_val ) ) ) ; <nl> + } <nl> env - > pop_scope ( ) ; <nl> } <nl> return cached_funcs [ env - > uuid ] ; <nl> counted_t < func_t > wire_func_t : : compile ( env_t * env ) { <nl> void wire_func_t : : rdb_serialize ( write_message_t & msg ) const { / / NOLINT ( runtime / references ) <nl> guarantee ( source . has ( ) ) ; <nl> msg < < * source ; <nl> + msg < < default_filter_val ; <nl> msg < < scope ; <nl> } <nl> <nl> archive_result_t wire_func_t : : rdb_deserialize ( read_stream_t * stream ) { <nl> guarantee ( source . has ( ) ) ; <nl> archive_result_t res = deserialize ( stream , source . get ( ) ) ; <nl> if ( res ! = ARCHIVE_SUCCESS ) { return res ; } <nl> + res = deserialize ( stream , & default_filter_val ) ; <nl> + if ( res ! = ARCHIVE_SUCCESS ) { return res ; } <nl> return deserialize ( stream , & scope ) ; <nl> } <nl> <nl> bool func_term_t : : is_deterministic_impl ( ) const { <nl> } <nl> <nl> bool func_t : : filter_call ( counted_t < const datum_t > arg ) { <nl> - counted_t < const datum_t > d = call ( arg ) - > as_datum ( ) ; <nl> - if ( d - > get_type ( ) = = datum_t : : R_OBJECT ) { <nl> - const std : : map < std : : string , counted_t < const datum_t > > & obj = d - > as_object ( ) ; <nl> - for ( auto it = obj . begin ( ) ; it ! = obj . end ( ) ; + + it ) { <nl> - r_sanity_check ( it - > second . has ( ) ) ; <nl> - counted_t < const datum_t > elt = arg - > get ( it - > first , NOTHROW ) ; <nl> - if ( ! elt . has ( ) ) { <nl> - rfail ( " No attribute ` % s ` in object . " , it - > first . c_str ( ) ) ; <nl> - } else if ( * elt ! = * it - > second ) { <nl> - return false ; <nl> + try { <nl> + counted_t < const datum_t > d = call ( arg ) - > as_datum ( ) ; <nl> + if ( d - > get_type ( ) = = datum_t : : R_OBJECT ) { <nl> + const std : : map < std : : string , counted_t < const datum_t > > & obj = d - > as_object ( ) ; <nl> + for ( auto it = obj . begin ( ) ; it ! = obj . end ( ) ; + + it ) { <nl> + r_sanity_check ( it - > second . has ( ) ) ; <nl> + counted_t < const datum_t > elt = arg - > get ( it - > first , NOTHROW ) ; <nl> + if ( ! elt . has ( ) ) { <nl> + rfail ( base_exc_t : : NON_EXISTENCE , <nl> + " No attribute ` % s ` in object . " , it - > first . c_str ( ) ) ; <nl> + } else if ( * elt ! = * it - > second ) { <nl> + return false ; <nl> + } <nl> } <nl> + return true ; <nl> + } else if ( d - > get_type ( ) = = datum_t : : R_BOOL ) { <nl> + return d - > as_bool ( ) ; <nl> + } else { <nl> + d - > type_error ( <nl> + strprintf ( <nl> + " FILTER must be passed either an OBJECT or a predicate ( got % s ) . " , <nl> + d - > get_type_name ( ) ) ) ; <nl> } <nl> - return true ; <nl> - } else if ( d - > get_type ( ) = = datum_t : : R_BOOL ) { <nl> - return d - > as_bool ( ) ; <nl> - } else { <nl> - rfail ( " FILTER must be passed either an OBJECT or a predicate ( got % s ) . " , <nl> - d - > get_type_name ( ) ) ; <nl> + } catch ( const base_exc_t & e ) { <nl> + if ( e . get_type ( ) = = base_exc_t : : NON_EXISTENCE ) { <nl> + / / If a non - existence error is thrown inside a ` filter ` , we return <nl> + / / the default value . Note that we will enter this branch if the <nl> + / / function passed to ` filter ` returns NULL , since the type error <nl> + / / above will produce a non - existence error in the case where ` d ` is <nl> + / / NULL . <nl> + try { <nl> + if ( default_filter_val ) { <nl> + return default_filter_val - > call ( ) - > as_bool ( ) ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } catch ( const base_exc_t & e2 ) { <nl> + if ( e2 . get_type ( ) ! = base_exc_t : : EMPTY_USER ) { <nl> + / / If the default value throws a non - EMPTY_USER exception , <nl> + / / we re - throw that exception . <nl> + throw ; <nl> + } <nl> + } <nl> + } <nl> + / / If we caught a non - NON_EXISTENCE exception or we caught a <nl> + / / NON_EXISTENCE exception and the default value threw an EMPTY_USER <nl> + / / exception , we re - throw the original exception . <nl> + throw ; <nl> } <nl> } <nl> <nl> mmm a / src / rdb_protocol / func . hpp <nl> ppp b / src / rdb_protocol / func . hpp <nl> class func_t : public slow_atomic_countable_t < func_t > , public pb_rcheckable_t { <nl> void assert_deterministic ( const char * extra_msg ) const ; <nl> <nl> std : : string print_src ( ) const ; <nl> + void set_default_filter_val ( counted_t < func_t > func ) ; <nl> private : <nl> / / Pointers to this function ' s arguments . <nl> scoped_array_t < counted_t < const datum_t > > argptrs ; <nl> class func_t : public slow_atomic_countable_t < func_t > , public pb_rcheckable_t { <nl> / / This is what ' s serialized over the wire . <nl> friend class wire_func_t ; <nl> protob_t < const Term > source ; <nl> + / / This is set by ` filter_term_t ` and used by ` filter_call ` . <nl> + / / ` filter_term_t ` will set this if the user provides the ` default ` optarg , <nl> + / / in which case it will be used to handle the case where a non - existence <nl> + / / error is produced while filtering a stream . <nl> + counted_t < func_t > default_filter_val ; <nl> <nl> / / TODO : make this smarter ( it ' s sort of slow and shitty as - is ) <nl> std : : map < int64_t , counted_t < const datum_t > * > scope ; <nl> class wire_func_t { <nl> <nl> / / source is never null , even when wire_func_t is default - constructed . <nl> protob_t < Term > source ; <nl> + boost : : optional < Term > default_filter_val ; <nl> std : : map < int64_t , Datum > scope ; <nl> } ; <nl> <nl> mmm a / src / rdb_protocol / meta_utils . hpp <nl> ppp b / src / rdb_protocol / meta_utils . hpp <nl> uuid_u meta_get_uuid ( T * searcher , const U & predicate , <nl> const std : : string & message , V * caller ) { <nl> metadata_search_status_t status ; <nl> typename T : : iterator entry = searcher - > find_uniq ( predicate , & status ) ; <nl> - rcheck_target ( caller , status = = METADATA_SUCCESS , message ) ; <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , <nl> + status = = METADATA_SUCCESS , message ) ; <nl> return entry - > first ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / op . cc <nl> ppp b / src / rdb_protocol / op . cc <nl> <nl> # include " rdb_protocol / op . hpp " <nl> + # include " rdb_protocol / pb_utils . hpp " <nl> + # pragma GCC diagnostic ignored " - Wshadow " <nl> <nl> namespace ql { <nl> argspec_t : : argspec_t ( int n ) : min ( n ) , max ( n ) { } <nl> op_term_t : : op_term_t ( env_t * env , protob_t < const Term > term , <nl> args . push_back ( t ) ; <nl> } <nl> rcheck ( argspec . contains ( args . size ( ) ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Expected % s but found % zu . " , <nl> argspec . print ( ) . c_str ( ) , args . size ( ) ) ) ; <nl> <nl> op_term_t : : op_term_t ( env_t * env , protob_t < const Term > term , <nl> const Term_AssocPair * ap = & term - > optargs ( i ) ; <nl> if ( ! optargspec . is_make_object ( ) ) { <nl> rcheck ( optargspec . contains ( ap - > key ( ) ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Unrecognized optional argument ` % s ` . " , ap - > key ( ) . c_str ( ) ) ) ; <nl> } <nl> rcheck ( optargs . count ( ap - > key ( ) ) = = 0 , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Duplicate % s : % s " , <nl> ( term - > type ( ) = = Term_TermType_MAKE_OBJ ? <nl> " object key " : " optional argument " ) , <nl> op_term_t : : ~ op_term_t ( ) { } <nl> <nl> size_t op_term_t : : num_args ( ) const { return args . size ( ) ; } <nl> counted_t < val_t > op_term_t : : arg ( size_t i ) { <nl> - rcheck ( i < num_args ( ) , strprintf ( " Index out of range : % zu " , i ) ) ; <nl> + rcheck ( i < num_args ( ) , base_exc_t : : NON_EXISTENCE , <nl> + strprintf ( " Index out of range : % zu " , i ) ) ; <nl> return args [ i ] - > eval ( ) ; <nl> } <nl> <nl> counted_t < val_t > op_term_t : : optarg ( const std : : string & key ) { <nl> return ret ; <nl> } <nl> <nl> + counted_t < func_t > op_term_t : : lazy_literal_optarg ( const std : : string & key ) { <nl> + std : : map < std : : string , counted_t < term_t > > : : iterator it = optargs . find ( key ) ; <nl> + if ( it ! = optargs . end ( ) ) { <nl> + protob_t < Term > func ( make_counted_term ( ) ) ; <nl> + Term * arg = func . get ( ) ; <nl> + N2 ( FUNC , N0 ( MAKE_ARRAY ) , * arg = * it - > second - > get_src ( ) . get ( ) ) ; <nl> + return make_counted < func_t > ( env , func ) ; <nl> + } <nl> + return counted_t < func_t > ( ) ; <nl> + } <nl> + <nl> bool op_term_t : : is_deterministic_impl ( ) const { <nl> for ( size_t i = 0 ; i < num_args ( ) ; + + i ) { <nl> if ( ! args [ i ] - > is_deterministic ( ) ) { <nl> mmm a / src / rdb_protocol / op . hpp <nl> ppp b / src / rdb_protocol / op . hpp <nl> class op_term_t : public term_t { <nl> / / Tries to get an optional argument , returns ` counted_t < val_t > ( ) ` if not <nl> / / found . <nl> counted_t < val_t > optarg ( const std : : string & key ) ; <nl> + / / This returns an optarg which is : <nl> + / / * lazy - - it ' s wrapped in a function , so you don ' t get the value until <nl> + / / you call that function . <nl> + / / * literal - - it checks whether this operation has the literal key you <nl> + / / provided and doesn ' t look anywhere else for optargs ( in particular , it <nl> + / / doesn ' t check global optargs ) . <nl> + counted_t < func_t > lazy_literal_optarg ( const std : : string & key ) ; <nl> private : <nl> virtual bool is_deterministic_impl ( ) const ; <nl> std : : vector < counted_t < term_t > > args ; <nl> mmm a / src / rdb_protocol / protocol . cc <nl> ppp b / src / rdb_protocol / protocol . cc <nl> struct rdb_read_visitor_t : public boost : : static_visitor < void > { <nl> <nl> if ( ! found ) { <nl> res - > result = ql : : datum_exc_t ( <nl> + ql : : base_exc_t : : GENERIC , <nl> strprintf ( " Index ` % s ` was not found . " , <nl> rget . sindex - > c_str ( ) ) ) ; <nl> return ; <nl> } <nl> } catch ( const sindex_not_post_constructed_exc_t & ) { <nl> res - > result = ql : : datum_exc_t ( <nl> + ql : : base_exc_t : : GENERIC , <nl> strprintf ( " Index ` % s ` was accessed before " <nl> " its construction was finished . " , <nl> rget . sindex - > c_str ( ) ) ) ; <nl> mmm a / src / rdb_protocol / ql2 . proto <nl> ppp b / src / rdb_protocol / ql2 . proto <nl> message Term { <nl> / / Takes some javascript code and executes it . <nl> JAVASCRIPT = 11 ; / / STRING { timeout : ! NUMBER } - > DATUM | <nl> / / STRING { timeout : ! NUMBER } - > Function ( * ) <nl> + <nl> / / Takes a string and throws an error with that message . <nl> - ERROR = 12 ; / / STRING - > Error <nl> + / / Inside of a ` default ` block , you can omit the first <nl> + / / argument to rethrow whatever error you catch ( this is most <nl> + / / useful as an argument to the ` default ` filter optarg ) . <nl> + ERROR = 12 ; / / STRING - > Error | - > Error <nl> / / Takes nothing and returns a reference to the implicit variable . <nl> IMPLICIT_VAR = 13 ; / / - > DATUM <nl> <nl> message Term { <nl> BETWEEN = 36 ; / / StreamSelection , DATUM , DATUM , { : index : ! STRING } - > StreamSelection <nl> REDUCE = 37 ; / / Sequence , Function ( 2 ) , { base : DATUM } - > DATUM <nl> MAP = 38 ; / / Sequence , Function ( 1 ) - > Sequence <nl> - FILTER = 39 ; / / Sequence , Function ( 1 ) - > Sequence | Sequence , OBJECT - > Sequence <nl> + <nl> + / / Filter a sequence with either a function or a shortcut <nl> + / / object ( see API docs for details ) . The body of FILTER is <nl> + / / wrapped in an implicit ` . default ( false ) ` , and you can <nl> + / / change the default value by specifying the ` default ` <nl> + / / optarg . If you make the default ` r . error ` , all errors <nl> + / / caught by ` default ` will be rethrown as if the ` default ` <nl> + / / did not exist . <nl> + FILTER = 39 ; / / Sequence , Function ( 1 ) , { default : DATUM } - > Sequence | <nl> + / / Sequence , OBJECT , { default : DATUM } - > Sequence <nl> / / Map a function over a sequence and then concatenate the results together . <nl> CONCATMAP = 40 ; / / Sequence , Function ( 1 ) - > Sequence <nl> / / Order a sequence based on one or more attributes . <nl> message Term { <nl> <nl> / / Select a number of elements from sequence with uniform distribution . <nl> SAMPLE = 81 ; / / Sequence , NUMBER - > Sequence <nl> + <nl> + / / Evaluates its first argument . If that argument returns <nl> + / / NULL or throws an error related to the absence of an <nl> + / / expected value ( for instance , accessing a non - existent <nl> + / / field or adding NULL to an integer ) , DEFAULT will either <nl> + / / return its second argument or execute it if it ' s a <nl> + / / function . If the second argument is a function , it will be <nl> + / / passed either the text of the error or NULL as its <nl> + / / argument . <nl> + DEFAULT = 88 ; / / Top , Top - > Top <nl> } <nl> optional TermType type = 1 ; <nl> <nl> mmm a / src / rdb_protocol / stream . cc <nl> ppp b / src / rdb_protocol / stream . cc <nl> result_t batched_rget_stream_t : : apply_terminal ( <nl> throw runtime_exc_t ( " cannot perform read : " + std : : string ( e . what ( ) ) , * table_scan_backtrace ) ; <nl> } else { <nl> / / No backtrace for these . <nl> - throw ql : : exc_t ( " cannot perform read : " + std : : string ( e . what ( ) ) , <nl> - ql : : backtrace_t ( ) ) ; <nl> + rfail_toplevel ( ql : : base_exc_t : : GENERIC , <nl> + " cannot perform read : % s " , e . what ( ) ) ; <nl> } <nl> } <nl> } <nl> void batched_rget_stream_t : : read_more ( ) { <nl> throw runtime_exc_t ( " cannot perform read : " + std : : string ( e . what ( ) ) , * table_scan_backtrace ) ; <nl> } else { <nl> / / No backtrace . <nl> - throw ql : : exc_t ( " cannot perform read : " + std : : string ( e . what ( ) ) , <nl> - ql : : backtrace_t ( ) ) ; <nl> + rfail_toplevel ( ql : : base_exc_t : : GENERIC , <nl> + " cannot perform read : % s " , e . what ( ) ) ; <nl> } <nl> } <nl> } <nl> mmm a / src / rdb_protocol / term . cc <nl> ppp b / src / rdb_protocol / term . cc <nl> counted_t < term_t > compile_term ( env_t * env , protob_t < const Term > t ) { <nl> case Term : : INFO : return make_info_term ( env , t ) ; <nl> case Term : : SAMPLE : return make_sample_term ( env , t ) ; <nl> case Term : : IS_EMPTY : return make_is_empty_term ( env , t ) ; <nl> + case Term : : DEFAULT : return make_default_term ( env , t ) ; <nl> default : unreachable ( ) ; <nl> } <nl> unreachable ( ) ; <nl> void run ( protob_t < Query > q , scoped_ptr_t < env_t > * env_ptr , <nl> if ( ap . key ( ) ! = " noreply " ) { <nl> bool conflict = env - > add_optarg ( ap . key ( ) , ap . val ( ) ) ; <nl> rcheck_toplevel ( <nl> - ! conflict , <nl> + ! conflict , base_exc_t : : GENERIC , <nl> strprintf ( " Duplicate global optarg : % s " , ap . key ( ) . c_str ( ) ) ) ; <nl> } <nl> } <nl> void run ( protob_t < Query > q , scoped_ptr_t < env_t > * env_ptr , <nl> <nl> try { <nl> rcheck_toplevel ( ! stream_cache2 - > contains ( token ) , <nl> - strprintf ( " ERROR : duplicate token % " PRIi64 , token ) ) ; <nl> + base_exc_t : : GENERIC , <nl> + strprintf ( " ERROR : duplicate token % " PRIi64 , token ) ) ; <nl> } catch ( const exc_t & e ) { <nl> fill_error ( res , Response : : CLIENT_ERROR , e . what ( ) , e . backtrace ( ) ) ; <nl> return ; <nl> void run ( protob_t < Query > q , scoped_ptr_t < env_t > * env_ptr , <nl> bool b = stream_cache2 - > serve ( token , res , env - > interruptor ) ; <nl> r_sanity_check ( b ) ; <nl> } else { <nl> - rfail_toplevel ( " Query result must be of type DATUM or STREAM " <nl> - " ( got % s ) . " , val - > get_type ( ) . name ( ) ) ; <nl> + rfail_toplevel ( base_exc_t : : GENERIC , <nl> + " Query result must be of type DATUM or STREAM ( got % s ) . " , <nl> + val - > get_type ( ) . name ( ) ) ; <nl> } <nl> } catch ( const exc_t & e ) { <nl> fill_error ( res , Response : : RUNTIME_ERROR , e . what ( ) , e . backtrace ( ) ) ; <nl> void run ( protob_t < Query > q , scoped_ptr_t < env_t > * env_ptr , <nl> case Query_QueryType_CONTINUE : { <nl> try { <nl> bool b = stream_cache2 - > serve ( token , res , env - > interruptor ) ; <nl> - rcheck_toplevel ( b , strprintf ( " Token % " PRIi64 " not in stream cache . " , <nl> - token ) ) ; <nl> + rcheck_toplevel ( b , base_exc_t : : GENERIC , <nl> + strprintf ( " Token % " PRIi64 " not in stream cache . " , token ) ) ; <nl> } catch ( const exc_t & e ) { <nl> fill_error ( res , Response : : CLIENT_ERROR , e . what ( ) , e . backtrace ( ) ) ; <nl> return ; <nl> void run ( protob_t < Query > q , scoped_ptr_t < env_t > * env_ptr , <nl> } break ; <nl> case Query_QueryType_STOP : { <nl> try { <nl> - rcheck_toplevel ( stream_cache2 - > contains ( token ) , <nl> - strprintf ( " Token % " PRIi64 " not in stream cache . " , token ) ) ; <nl> + rcheck_toplevel ( stream_cache2 - > contains ( token ) , base_exc_t : : GENERIC , <nl> + strprintf ( " Token % " PRIi64 " not in stream cache . " , token ) ) ; <nl> stream_cache2 - > erase ( token ) ; <nl> } catch ( const exc_t & e ) { <nl> fill_error ( res , Response : : CLIENT_ERROR , e . what ( ) , e . backtrace ( ) ) ; <nl> counted_t < val_t > term_t : : eval ( ) { <nl> } catch ( const datum_exc_t & e ) { <nl> DEC_DEPTH ; <nl> DBG ( " % s THREW \ n " , name ( ) ) ; <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> } <nl> } catch ( . . . ) { <nl> DEC_DEPTH ; <nl> mmm a / src / rdb_protocol / term_walker . cc <nl> ppp b / src / rdb_protocol / term_walker . cc <nl> class term_walker_t { <nl> <nl> if ( t - > type ( ) = = Term : : ASC | | t - > type ( ) = = Term : : DESC ) { <nl> rcheck_src ( & t - > GetExtension ( ql2 : : extension : : backtrace ) , <nl> + base_exc_t : : GENERIC , <nl> parent & & parent - > type ( ) = = Term : : ORDERBY , <nl> strprintf ( " % s may only be used as an argument to ORDERBY . " , <nl> ( t - > type ( ) = = Term : : ASC ? " ASC " : " DESC " ) ) ) ; <nl> class term_walker_t { <nl> <nl> bool writes_still_legal = writes_are_still_legal ( parent , frame ) ; <nl> rcheck_src ( & t - > GetExtension ( ql2 : : extension : : backtrace ) , <nl> + base_exc_t : : GENERIC , <nl> writes_still_legal | | ! term_is_write_or_meta ( t ) , <nl> strprintf ( " Cannot nest writes or meta ops in stream operations . " <nl> " Use FOREACH instead . " ) ) ; <nl> class term_walker_t { <nl> case Term : : INFO : <nl> case Term : : SAMPLE : <nl> case Term : : IS_EMPTY : <nl> + case Term : : DEFAULT : <nl> return false ; <nl> default : unreachable ( ) ; <nl> } <nl> class term_walker_t { <nl> case Term : : INFO : <nl> case Term : : SAMPLE : <nl> case Term : : IS_EMPTY : <nl> + case Term : : DEFAULT : <nl> return false ; <nl> default : unreachable ( ) ; <nl> } <nl> mmm a / src / rdb_protocol / terms / arith . cc <nl> ppp b / src / rdb_protocol / terms / arith . cc <nl> class arith_term_t : public op_term_t { <nl> counted_t < const datum_t > rhs ) { <nl> lhs - > check_type ( datum_t : : R_NUM ) ; <nl> rhs - > check_type ( datum_t : : R_NUM ) ; <nl> - rcheck ( rhs - > as_num ( ) ! = 0 , " Cannot divide by zero . " ) ; <nl> + rcheck ( rhs - > as_num ( ) ! = 0 , base_exc_t : : GENERIC , " Cannot divide by zero . " ) ; <nl> / / throws on non - finite values <nl> return make_counted < datum_t > ( lhs - > as_num ( ) / rhs - > as_num ( ) ) ; <nl> } <nl> class mod_term_t : public op_term_t { <nl> virtual counted_t < val_t > eval_impl ( ) { <nl> int64_t i0 = arg ( 0 ) - > as_int ( ) ; <nl> int64_t i1 = arg ( 1 ) - > as_int ( ) ; <nl> - rcheck ( i1 , " Cannot take a number modulo 0 . " ) ; <nl> + rcheck ( i1 , base_exc_t : : GENERIC , " Cannot take a number modulo 0 . " ) ; <nl> rcheck ( ! ( i0 = = std : : numeric_limits < int64_t > : : min ( ) & & i1 = = - 1 ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Cannot take % " PRIi64 " mod % " PRIi64 , i0 , i1 ) ) ; <nl> return new_val ( make_counted < const datum_t > ( static_cast < double > ( i0 % i1 ) ) ) ; <nl> } <nl> mmm a / src / rdb_protocol / terms / arr . cc <nl> ppp b / src / rdb_protocol / terms / arr . cc <nl> size_t canonicalize ( const term_t * t , int32_t index , size_t size , bool * oob_out = <nl> if ( oob_out ) { <nl> * oob_out = true ; <nl> } else { <nl> - rfail_target ( t , " Index out of bounds : % d " , index ) ; <nl> + rfail_target ( t , base_exc_t : : NON_EXISTENCE , " Index out of bounds : % d " , index ) ; <nl> } <nl> return 0 ; <nl> } <nl> class nth_term_t : public op_term_t { <nl> return new_val ( arr - > get ( real_n ) ) ; <nl> } else { <nl> counted_t < datum_stream_t > s = v - > as_seq ( ) ; <nl> - rcheck ( n > = - 1 , strprintf ( " Cannot use an index < - 1 ( % d ) on a stream . " , n ) ) ; <nl> + rcheck ( n > = - 1 , <nl> + base_exc_t : : GENERIC , <nl> + strprintf ( " Cannot use an index < - 1 ( % d ) on a stream . " , n ) ) ; <nl> <nl> counted_t < const datum_t > last_d ; <nl> for ( int32_t i = 0 ; ; + + i ) { <nl> counted_t < const datum_t > d = s - > next ( ) ; <nl> if ( ! d . has ( ) ) { <nl> - rcheck ( n = = - 1 & & last_d . has ( ) , <nl> + rcheck ( n = = - 1 & & last_d . has ( ) , base_exc_t : : GENERIC , <nl> strprintf ( " Index out of bounds : % d " , n ) ) ; <nl> return new_val ( last_d ) ; <nl> } <nl> class slice_term_t : public op_term_t { <nl> int32_t fake_r = arg ( 2 ) - > as_int < int32_t > ( ) ; <nl> if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : DATUM ) ) { <nl> counted_t < const datum_t > arr = v - > as_datum ( ) ; <nl> - rcheck ( arr - > get_type ( ) = = datum_t : : R_ARRAY , " Cannot slice non - sequences . " ) ; <nl> + arr - > check_type ( datum_t : : R_ARRAY ) ; <nl> bool l_oob = false ; <nl> size_t real_l = canonicalize ( this , fake_l , arr - > size ( ) , & l_oob ) ; <nl> if ( l_oob ) real_l = 0 ; <nl> class slice_term_t : public op_term_t { <nl> seq = v - > as_seq ( ) ; <nl> } <nl> <nl> - rcheck ( fake_l > = 0 , " Cannot use a negative left index on a stream . " ) ; <nl> - rcheck ( fake_r > = - 1 , " Cannot use a right index < - 1 on a stream " ) ; <nl> + rcheck ( fake_l > = 0 , base_exc_t : : GENERIC , <nl> + " Cannot use a negative left index on a stream . " ) ; <nl> + rcheck ( fake_r > = - 1 , base_exc_t : : GENERIC , <nl> + " Cannot use a right index < - 1 on a stream " ) ; <nl> counted_t < datum_stream_t > new_ds = seq - > slice ( fake_l , fake_r ) ; <nl> return t . has ( ) ? new_val ( new_ds , t ) : new_val ( new_ds ) ; <nl> } <nl> - rfail ( " Cannot slice non - sequences . " ) ; <nl> + rcheck_typed_target ( v , false , " Cannot slice non - sequences . " ) ; <nl> unreachable ( ) ; <nl> } <nl> virtual const char * name ( ) const { return " slice " ; } <nl> class limit_term_t : public op_term_t { <nl> } <nl> counted_t < datum_stream_t > ds = v - > as_seq ( ) ; <nl> int32_t r = arg ( 1 ) - > as_int < int32_t > ( ) ; <nl> - rcheck ( r > = 0 , strprintf ( " LIMIT takes a non - negative argument ( got % d ) " , r ) ) ; <nl> + rcheck ( r > = 0 , base_exc_t : : GENERIC , <nl> + strprintf ( " LIMIT takes a non - negative argument ( got % d ) " , r ) ) ; <nl> counted_t < datum_stream_t > new_ds ; <nl> if ( r = = 0 ) { <nl> new_ds = ds - > slice ( 1 , 0 ) ; / / ( 0 , - 1 ) has a different meaning <nl> mmm a / src / rdb_protocol / terms / datum_terms . cc <nl> ppp b / src / rdb_protocol / terms / datum_terms . cc <nl> class make_obj_term_t : public op_term_t { <nl> scoped_ptr_t < datum_t > acc ( new datum_t ( datum_t : : R_OBJECT ) ) ; <nl> for ( auto it = optargs . begin ( ) ; it ! = optargs . end ( ) ; + + it ) { <nl> bool dup = acc - > add ( it - > first , it - > second - > eval ( ) - > as_datum ( ) ) ; <nl> - rcheck ( ! dup , strprintf ( " Duplicate key in object : % s . " , it - > first . c_str ( ) ) ) ; <nl> + rcheck ( ! dup , base_exc_t : : GENERIC , <nl> + strprintf ( " Duplicate key in object : % s . " , it - > first . c_str ( ) ) ) ; <nl> } <nl> return new_val ( counted_t < const datum_t > ( acc . release ( ) ) ) ; <nl> } <nl> mmm a / src / rdb_protocol / terms / db_table . cc <nl> ppp b / src / rdb_protocol / terms / db_table . cc <nl> name_string_t get_name ( counted_t < val_t > val , const term_t * caller ) { <nl> std : : string raw_name = val - > as_str ( ) ; <nl> name_string_t name ; <nl> bool assignment_successful = name . assign_value ( raw_name ) ; <nl> - rcheck_target ( caller , assignment_successful , <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , assignment_successful , <nl> strprintf ( " Database name ` % s ` invalid ( % s ) . " , <nl> raw_name . c_str ( ) , name_string_t : : valid_char_msg ) ) ; <nl> return name ; <nl> class meta_write_op_t : public meta_op_t { <nl> void init ( ) { <nl> on_thread_t rethreader ( metadata_home_thread ) ; <nl> rcheck ( env - > directory_read_manager , <nl> + base_exc_t : : GENERIC , <nl> " Cannot nest meta operations inside queries . " ) ; <nl> guarantee ( env - > directory_read_manager - > home_thread ( ) = = metadata_home_thread ) ; <nl> directory_metadata = env - > directory_read_manager - > get_root_view ( ) ; <nl> class db_create_term_t : public meta_write_op_t { <nl> metadata_search_status_t status ; <nl> meta . db_searcher . find_uniq ( db_name , & status ) ; <nl> rcheck ( status = = METADATA_ERR_NONE , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Database ` % s ` already exists . " , db_name . c_str ( ) ) ) ; <nl> <nl> / / Create database , insert into metadata , then join into real metadata . <nl> class db_create_term_t : public meta_write_op_t { <nl> fill_in_blueprints ( & meta . metadata , directory_metadata - > get ( ) , <nl> env - > this_machine , false ) ; <nl> } catch ( const missing_machine_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , " % s " , e . what ( ) ) ; <nl> } <nl> env - > join_and_wait_to_propagate ( meta . metadata ) ; <nl> <nl> class table_create_term_t : public meta_write_op_t { <nl> rethreading_metadata_accessor_t meta ( this ) ; <nl> meta . ns_searcher . find_uniq ( pred , & status ) ; <nl> rcheck ( status = = METADATA_ERR_NONE , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Table ` % s ` already exists . " , tbl_name . c_str ( ) ) ) ; <nl> <nl> / / Create namespace ( DB + table pair ) and insert into metadata . <nl> class table_create_term_t : public meta_write_op_t { <nl> fill_in_blueprints ( & meta . metadata , directory_metadata - > get ( ) , <nl> env - > this_machine , false ) ; <nl> } catch ( const missing_machine_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , " % s " , e . what ( ) ) ; <nl> } <nl> env - > join_and_wait_to_propagate ( meta . metadata ) ; <nl> <nl> class table_create_term_t : public meta_write_op_t { <nl> wait_for_rdb_table_readiness ( env - > ns_repo , namespace_id , <nl> env - > interruptor , env - > semilattice_metadata ) ; <nl> } catch ( const interrupted_exc_t & e ) { <nl> - rfail ( " Query interrupted , probably by user . " ) ; <nl> + rfail ( base_exc_t : : GENERIC , " Query interrupted , probably by user . " ) ; <nl> } <nl> <nl> return " created " ; <nl> class db_drop_term_t : public meta_write_op_t { <nl> metadata_search_status_t status ; <nl> metadata_searcher_t < database_semilattice_metadata_t > : : iterator <nl> db_metadata = meta . db_searcher . find_uniq ( db_name , & status ) ; <nl> - rcheck ( status = = METADATA_SUCCESS , <nl> + rcheck ( status = = METADATA_SUCCESS , base_exc_t : : GENERIC , <nl> strprintf ( " Database ` % s ` does not exist . " , db_name . c_str ( ) ) ) ; <nl> guarantee ( ! db_metadata - > second . is_deleted ( ) ) ; <nl> uuid_u db_id = db_metadata - > first ; <nl> class db_drop_term_t : public meta_write_op_t { <nl> fill_in_blueprints ( & meta . metadata , directory_metadata - > get ( ) , <nl> env - > this_machine , false ) ; <nl> } catch ( const missing_machine_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , " % s " , e . what ( ) ) ; <nl> } <nl> env - > join_and_wait_to_propagate ( meta . metadata ) ; <nl> <nl> class table_drop_term_t : public meta_write_op_t { <nl> namespace_predicate_t pred ( & tbl_name , & db_id ) ; <nl> metadata_searcher_t < namespace_semilattice_metadata_t < rdb_protocol_t > > : : iterator <nl> ns_metadata = meta . ns_searcher . find_uniq ( pred , & status ) ; <nl> - rcheck ( status = = METADATA_SUCCESS , <nl> + rcheck ( status = = METADATA_SUCCESS , base_exc_t : : GENERIC , <nl> strprintf ( " Table ` % s ` does not exist . " , tbl_name . c_str ( ) ) ) ; <nl> guarantee ( ! ns_metadata - > second . is_deleted ( ) ) ; <nl> <nl> class table_drop_term_t : public meta_write_op_t { <nl> fill_in_blueprints ( & meta . metadata , directory_metadata - > get ( ) , <nl> env - > this_machine , false ) ; <nl> } catch ( const missing_machine_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , " % s " , e . what ( ) ) ; <nl> } <nl> env - > join_and_wait_to_propagate ( meta . metadata ) ; <nl> <nl> mmm a / src / rdb_protocol / terms / error . cc <nl> ppp b / src / rdb_protocol / terms / error . cc <nl> namespace ql { <nl> <nl> class error_term_t : public op_term_t { <nl> public : <nl> - error_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> + error_term_t ( env_t * env , protob_t < const Term > term ) <nl> + : op_term_t ( env , term , argspec_t ( 0 , 1 ) ) { } <nl> private : <nl> virtual counted_t < val_t > eval_impl ( ) { <nl> - rfail ( " % s " , arg ( 0 ) - > as_str ( ) . c_str ( ) ) ; <nl> + if ( num_args ( ) = = 0 ) { <nl> + rfail ( base_exc_t : : EMPTY_USER , " Empty ERROR term outside a default block . " ) ; <nl> + } else { <nl> + rfail ( base_exc_t : : GENERIC , " % s " , arg ( 0 ) - > as_str ( ) . c_str ( ) ) ; <nl> + } <nl> unreachable ( ) ; <nl> } <nl> virtual const char * name ( ) const { return " error " ; } <nl> } ; <nl> <nl> + class default_term_t : public op_term_t { <nl> + public : <nl> + default_term_t ( env_t * env , protob_t < const Term > term ) <nl> + : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> + private : <nl> + virtual counted_t < val_t > eval_impl ( ) { <nl> + counted_t < const datum_t > func_arg ; <nl> + scoped_ptr_t < exc_t > err ; <nl> + counted_t < val_t > v ; <nl> + try { <nl> + v = arg ( 0 ) ; <nl> + if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : DATUM ) ) { <nl> + func_arg = v - > as_datum ( ) ; <nl> + if ( func_arg - > get_type ( ) ! = datum_t : : R_NULL ) { <nl> + return v ; <nl> + } <nl> + } else { <nl> + return v ; <nl> + } <nl> + } catch ( const exc_t & e ) { <nl> + if ( e . get_type ( ) = = base_exc_t : : NON_EXISTENCE ) { <nl> + err . init ( new exc_t ( e ) ) ; <nl> + func_arg = make_counted < const datum_t > ( e . what ( ) ) ; <nl> + } else { <nl> + throw ; <nl> + } <nl> + } catch ( const datum_exc_t & e ) { <nl> + if ( e . get_type ( ) = = base_exc_t : : NON_EXISTENCE ) { <nl> + err . init ( new exc_t ( e . get_type ( ) , e . what ( ) , backtrace ( ) . get ( ) ) ) ; <nl> + func_arg = make_counted < const datum_t > ( e . what ( ) ) ; <nl> + } else { <nl> + throw ; <nl> + } <nl> + } <nl> + r_sanity_check ( func_arg . has ( ) ) ; <nl> + r_sanity_check ( func_arg - > get_type ( ) = = datum_t : : R_NULL <nl> + | | func_arg - > get_type ( ) = = datum_t : : R_STR ) ; <nl> + try { <nl> + counted_t < val_t > def = arg ( 1 ) ; <nl> + if ( def - > get_type ( ) . is_convertible ( val_t : : type_t : : FUNC ) ) { <nl> + return def - > as_func ( ) - > call ( func_arg ) ; <nl> + } else { <nl> + return def ; <nl> + } <nl> + } catch ( const base_exc_t & e ) { <nl> + if ( e . get_type ( ) = = base_exc_t : : EMPTY_USER ) { <nl> + if ( err . has ( ) ) { <nl> + throw * err ; <nl> + } else { <nl> + r_sanity_check ( func_arg - > get_type ( ) = = datum_t : : R_NULL ) ; <nl> + return v ; <nl> + } <nl> + } else { <nl> + throw ; <nl> + } <nl> + } <nl> + } <nl> + virtual const char * name ( ) const { return " error " ; } <nl> + } ; <nl> + <nl> counted_t < term_t > make_error_term ( env_t * env , protob_t < const Term > term ) { <nl> return make_counted < error_term_t > ( env , term ) ; <nl> } <nl> + counted_t < term_t > make_default_term ( env_t * env , protob_t < const Term > term ) { <nl> + return make_counted < default_term_t > ( env , term ) ; <nl> + } <nl> <nl> <nl> } / / namespace ql <nl> mmm a / src / rdb_protocol / terms / js . cc <nl> ppp b / src / rdb_protocol / terms / js . cc <nl> class javascript_term_t : public op_term_t { <nl> this - > counted_from_this ( ) ) , <nl> result ) ; <nl> } catch ( const interrupted_exc_t & e ) { <nl> - rfail ( " JavaScript query \ " % s \ " timed out after % . 2G seconds " , source . c_str ( ) , timeout_s ) ; <nl> + rfail ( base_exc_t : : GENERIC , <nl> + " JavaScript query ` % s ` timed out after % . 2G seconds . " , <nl> + source . c_str ( ) , timeout_s ) ; <nl> } <nl> } <nl> virtual const char * name ( ) const { return " javascript " ; } <nl> mmm a / src / rdb_protocol / terms / obj_or_seq . cc <nl> ppp b / src / rdb_protocol / terms / obj_or_seq . cc <nl> class obj_or_seq_op_term_t : public op_term_t { <nl> if ( v0 - > get_type ( ) . is_convertible ( val_t : : type_t : : SEQUENCE ) ) { <nl> return new_val ( v0 - > as_seq ( ) - > map ( make_counted < func_t > ( env , map_func ) ) ) ; <nl> } <nl> - rfail ( " Cannot perform % s on a non - object non - sequence . " , name ( ) ) ; <nl> + rfail_typed_target ( <nl> + v0 , " Cannot perform % s on a non - object non - sequence . " , name ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> <nl> class pluck_term_t : public obj_or_seq_op_term_t { <nl> scoped_ptr_t < datum_t > out ( new datum_t ( datum_t : : R_OBJECT ) ) ; <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) { <nl> const std : : string & key = arg ( i ) - > as_str ( ) ; <nl> - counted_t < const datum_t > el = obj - > get ( key ) ; <nl> + counted_t < const datum_t > el = obj - > get ( key , NOTHROW ) ; <nl> if ( el . has ( ) ) { <nl> bool conflict = out - > add ( key , el ) ; <nl> r_sanity_check ( ! conflict ) ; <nl> mmm a / src / rdb_protocol / terms / rewrites . cc <nl> ppp b / src / rdb_protocol / terms / rewrites . cc <nl> class rewrite_term_t : public term_t { <nl> : term_t ( env , term ) , in ( term ) , out ( make_counted_term ( ) ) { <nl> int args_size = in - > args_size ( ) ; <nl> rcheck ( argspec . contains ( args_size ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Expected % s but found % d . " , <nl> argspec . print ( ) . c_str ( ) , args_size ) ) ; <nl> protob_t < Term > optarg_inheritor = rewrite ( env , in , out , this ) ; <nl> class groupby_term_t : public rewrite_term_t { <nl> Term * dc_arg_out , const pb_rcheckable_t * bt_src ) { <nl> std : : string errmsg = " Invalid aggregator for GROUPBY . " ; <nl> if ( t - > type ( ) = = Term : : MAKE_OBJ ) { <nl> - rcheck_target ( bt_src , t - > optargs_size ( ) = = 1 , errmsg ) ; <nl> + rcheck_target ( bt_src , base_exc_t : : GENERIC , <nl> + t - > optargs_size ( ) = = 1 , errmsg ) ; <nl> const Term_AssocPair * ap = & t - > optargs ( 0 ) ; <nl> * dc_out = ap - > key ( ) ; <nl> rcheck_target ( <nl> - bt_src , * dc_out = = " SUM " | | * dc_out = = " AVG " | | * dc_out = = " COUNT " , <nl> + bt_src , base_exc_t : : GENERIC , <nl> + * dc_out = = " SUM " | | * dc_out = = " AVG " | | * dc_out = = " COUNT " , <nl> strprintf ( " Unrecognized GROUPBY aggregator ` % s ` . " , dc_out - > c_str ( ) ) ) ; <nl> * dc_arg_out = ap - > val ( ) ; <nl> } else if ( t - > type ( ) = = Term : : DATUM ) { <nl> - rcheck_target ( bt_src , t - > has_datum ( ) , errmsg ) ; <nl> + rcheck_target ( bt_src , base_exc_t : : GENERIC , t - > has_datum ( ) , errmsg ) ; <nl> const Datum * d = & t - > datum ( ) ; <nl> - rcheck_target ( bt_src , d - > type ( ) = = Datum : : R_OBJECT , errmsg ) ; <nl> - rcheck_target ( bt_src , d - > r_object_size ( ) = = 1 , errmsg ) ; <nl> + rcheck_target ( bt_src , base_exc_t : : GENERIC , <nl> + d - > type ( ) = = Datum : : R_OBJECT , errmsg ) ; <nl> + rcheck_target ( bt_src , base_exc_t : : GENERIC , <nl> + d - > r_object_size ( ) = = 1 , errmsg ) ; <nl> const Datum_AssocPair * ap = & d - > r_object ( 0 ) ; <nl> * dc_out = ap - > key ( ) ; <nl> rcheck_target ( <nl> - bt_src , * dc_out = = " SUM " | | * dc_out = = " AVG " | | * dc_out = = " COUNT " , <nl> + bt_src , base_exc_t : : GENERIC , <nl> + * dc_out = = " SUM " | | * dc_out = = " AVG " | | * dc_out = = " COUNT " , <nl> strprintf ( " Unrecognized GROUPBY aggregator ` % s ` . " , dc_out - > c_str ( ) ) ) ; <nl> dc_arg_out - > set_type ( Term : : DATUM ) ; <nl> * dc_arg_out - > mutable_datum ( ) = ap - > val ( ) ; <nl> } else { <nl> - rcheck_target ( bt_src , t - > type ( ) = = Term : : MAKE_OBJ , errmsg ) ; <nl> + rcheck_target ( bt_src , base_exc_t : : GENERIC , <nl> + t - > type ( ) = = Term : : MAKE_OBJ , errmsg ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> mmm a / src / rdb_protocol / terms / seq . cc <nl> ppp b / src / rdb_protocol / terms / seq . cc <nl> class concatmap_term_t : public op_term_t { <nl> class filter_term_t : public op_term_t { <nl> public : <nl> filter_term_t ( env_t * env , protob_t < const Term > term ) <nl> - : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> + : op_term_t ( env , term , argspec_t ( 2 ) , optargspec_t ( { " default " } ) ) , <nl> + default_filter_val ( lazy_literal_optarg ( " default " ) ) { } <nl> private : <nl> virtual counted_t < val_t > eval_impl ( ) { <nl> counted_t < val_t > v0 = arg ( 0 ) ; <nl> counted_t < val_t > v1 = arg ( 1 ) ; <nl> counted_t < func_t > f = v1 - > as_func ( IDENTITY_SHORTCUT ) ; <nl> + if ( default_filter_val . has ( ) ) { <nl> + f - > set_default_filter_val ( default_filter_val ) ; <nl> + } <nl> if ( v0 - > get_type ( ) . is_convertible ( val_t : : type_t : : SELECTION ) ) { <nl> std : : pair < counted_t < table_t > , counted_t < datum_stream_t > > ts <nl> = v0 - > as_selection ( ) ; <nl> class filter_term_t : public op_term_t { <nl> return new_val ( v0 - > as_seq ( ) - > filter ( f ) ) ; <nl> } <nl> } <nl> + counted_t < func_t > default_filter_val ; <nl> virtual const char * name ( ) const { return " filter " ; } <nl> } ; <nl> <nl> mmm a / src / rdb_protocol / terms / sindex . cc <nl> ppp b / src / rdb_protocol / terms / sindex . cc <nl> class sindex_create_term_t : private env_t : : special_var_shadower_t , public op_te <nl> counted_t < const datum_t > name_datum = arg ( 1 ) - > as_datum ( ) ; <nl> std : : string name = name_datum - > as_str ( ) ; <nl> rcheck ( name ! = table - > get_pkey ( ) , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Index name conflict : ` % s ` is the name of the primary key . " , <nl> name . c_str ( ) ) ) ; <nl> counted_t < func_t > index_func ; <nl> class sindex_create_term_t : private env_t : : special_var_shadower_t , public op_te <nl> UNUSED bool b = res - > add ( " created " , make_counted < datum_t > ( 1 . 0 ) ) ; <nl> return new_val ( counted_t < const datum_t > ( res . release ( ) ) ) ; <nl> } else { <nl> - rfail ( " Index ` % s ` already exists . " , name . c_str ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , " Index ` % s ` already exists . " , name . c_str ( ) ) ; <nl> } <nl> } <nl> <nl> class sindex_drop_term_t : public op_term_t { <nl> UNUSED bool b = res - > add ( " dropped " , make_counted < datum_t > ( 1 . 0 ) ) ; <nl> return new_val ( counted_t < const datum_t > ( res . release ( ) ) ) ; <nl> } else { <nl> - rfail ( " Index ` % s ` does not exist . " , name . c_str ( ) ) ; <nl> + rfail ( base_exc_t : : GENERIC , " Index ` % s ` does not exist . " , name . c_str ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / rdb_protocol / terms / terms . hpp <nl> ppp b / src / rdb_protocol / terms / terms . hpp <nl> counted_t < term_t > make_table_list_term ( env_t * env , protob_t < const Term > term ) ; <nl> <nl> / / error . cc <nl> counted_t < term_t > make_error_term ( env_t * env , protob_t < const Term > term ) ; <nl> + counted_t < term_t > make_default_term ( env_t * env , protob_t < const Term > term ) ; <nl> <nl> / / gmr . cc <nl> counted_t < term_t > make_gmr_term ( env_t * env , protob_t < const Term > term ) ; <nl> mmm a / src / rdb_protocol / terms / type_manip . cc <nl> ppp b / src / rdb_protocol / terms / type_manip . cc <nl> class coerce_map_t { <nl> } <nl> int get_type ( const std : : string & s , const rcheckable_t * caller ) const { <nl> std : : map < std : : string , int > : : const_iterator it = map . find ( s ) ; <nl> - rcheck_target ( caller , it ! = map . end ( ) , strprintf ( " Unknown Type : % s " , s . c_str ( ) ) ) ; <nl> + rcheck_target ( caller , base_exc_t : : GENERIC , it ! = map . end ( ) , <nl> + strprintf ( " Unknown Type : % s " , s . c_str ( ) ) ) ; <nl> return it - > second ; <nl> } <nl> std : : string get_name ( int type ) const { <nl> class coerce_term_t : public op_term_t { <nl> try { <nl> ds = val - > as_seq ( ) ; <nl> } catch ( const base_exc_t & e ) { <nl> - rfail ( " Cannot coerce % s to % s ( failed to produce intermediate stream ) . " , <nl> + rfail ( base_exc_t : : GENERIC , <nl> + " Cannot coerce % s to % s ( failed to produce intermediate stream ) . " , <nl> get_name ( start_type ) . c_str ( ) , get_name ( end_type ) . c_str ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> class coerce_term_t : public op_term_t { <nl> std : : string key = pair - > get ( 0 ) - > as_str ( ) ; <nl> counted_t < const datum_t > keyval = pair - > get ( 1 ) ; <nl> bool b = obj - > add ( key , keyval ) ; <nl> - rcheck ( ! b , strprintf ( " Duplicate key % s in coerced object . " <nl> - " ( got % s and % s as values ) " , <nl> - key . c_str ( ) , <nl> - obj - > get ( key ) - > print ( ) . c_str ( ) , <nl> - keyval - > print ( ) . c_str ( ) ) ) ; <nl> + rcheck ( ! b , base_exc_t : : GENERIC , <nl> + strprintf ( " Duplicate key % s in coerced object . " <nl> + " ( got % s and % s as values ) " , <nl> + key . c_str ( ) , <nl> + obj - > get ( key ) - > print ( ) . c_str ( ) , <nl> + keyval - > print ( ) . c_str ( ) ) ) ; <nl> } <nl> return new_val ( counted_t < const datum_t > ( obj . release ( ) ) ) ; <nl> } <nl> } <nl> } <nl> <nl> - rfail ( " Cannot coerce % s to % s . " , <nl> - get_name ( start_type ) . c_str ( ) , get_name ( end_type ) . c_str ( ) ) ; <nl> - unreachable ( ) ; <nl> + rfail_typed_target ( val , " Cannot coerce % s to % s . " , <nl> + get_name ( start_type ) . c_str ( ) , get_name ( end_type ) . c_str ( ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " coerce_to " ; } <nl> } ; <nl> mmm a / src / rdb_protocol / terms / writes . cc <nl> ppp b / src / rdb_protocol / terms / writes . cc <nl> counted_t < const datum_t > stats_merge ( UNUSED const std : : string & key , <nl> <nl> / / Merging a string is left - preferential , which is just a no - op . <nl> rcheck_target ( <nl> - caller , l - > get_type ( ) = = datum_t : : R_STR & & r - > get_type ( ) = = datum_t : : R_STR , <nl> + caller , base_exc_t : : GENERIC , <nl> + l - > get_type ( ) = = datum_t : : R_STR & & r - > get_type ( ) = = datum_t : : R_STR , <nl> strprintf ( " Cannot merge statistics of type % s / % s - - what are you doing ? " , <nl> l - > get_type_name ( ) , r - > get_type_name ( ) ) ) ; <nl> return l ; <nl> durability_requirement_t parse_durability_optarg ( counted_t < val_t > arg , <nl> if ( str = = " hard " ) { return DURABILITY_REQUIREMENT_HARD ; } <nl> if ( str = = " soft " ) { return DURABILITY_REQUIREMENT_SOFT ; } <nl> rfail_target ( target , <nl> + base_exc_t : : GENERIC , <nl> " Durability option ` % s ` unrecognized " <nl> " ( options are \ " hard \ " and \ " soft \ " ) . " , <nl> str . c_str ( ) ) ; <nl> class foreach_term_t : public op_term_t { <nl> } <nl> } <nl> } catch ( const exc_t & e ) { <nl> - throw exc_t ( fail_msg , e . backtrace ( ) ) ; <nl> + throw exc_t ( e . get_type ( ) , fail_msg , e . backtrace ( ) ) ; <nl> } catch ( const datum_exc_t & de ) { <nl> - rfail_target ( v , " % s " , fail_msg ) ; <nl> + rfail_target ( v , base_exc_t : : GENERIC , " % s " , fail_msg ) ; <nl> } <nl> } <nl> return new_val ( stats ) ; <nl> mmm a / src / rdb_protocol / transform_visitors . cc <nl> ppp b / src / rdb_protocol / transform_visitors . cc <nl> class terminal_exc_visitor_t : public boost : : static_visitor < void > { <nl> : exc ( _exc ) , res_out ( _res_out ) { } <nl> <nl> void operator ( ) ( const gmr_wire_func_t & func ) const { <nl> - * res_out = exc_t ( exc . what ( ) , func . get_bt ( ) . get ( ) , 1 ) ; <nl> + * res_out = exc_t ( exc , func . get_bt ( ) . get ( ) , 1 ) ; <nl> } <nl> <nl> NORETURN void operator ( ) ( const count_wire_func_t & ) const { <nl> class terminal_exc_visitor_t : public boost : : static_visitor < void > { <nl> } <nl> <nl> void operator ( ) ( const reduce_wire_func_t & func ) const { <nl> - * res_out = exc_t ( exc . what ( ) , func . get_bt ( ) . get ( ) , 1 ) ; <nl> + * res_out = exc_t ( exc , func . get_bt ( ) . get ( ) , 1 ) ; <nl> } <nl> <nl> private : <nl> class transform_exc_visitor_t : public boost : : static_visitor < void > { <nl> : exc ( _exc ) , res_out ( _res_out ) { } <nl> <nl> void operator ( ) ( const map_wire_func_t & func ) const { <nl> - * res_out = exc_t ( exc . what ( ) , func . get_bt ( ) . get ( ) , 1 ) ; <nl> + * res_out = exc_t ( exc , func . get_bt ( ) . get ( ) , 1 ) ; <nl> } <nl> <nl> void operator ( ) ( const filter_wire_func_t & func ) const { <nl> - * res_out = exc_t ( exc . what ( ) , func . get_bt ( ) . get ( ) , 1 ) ; <nl> + * res_out = exc_t ( exc , func . get_bt ( ) . get ( ) , 1 ) ; <nl> } <nl> <nl> void operator ( ) ( const concatmap_wire_func_t & func ) const { <nl> - * res_out = exc_t ( exc . what ( ) , func . get_bt ( ) . get ( ) , 1 ) ; <nl> + * res_out = exc_t ( exc , func . get_bt ( ) . get ( ) , 1 ) ; <nl> } <nl> <nl> private : <nl> mmm a / src / rdb_protocol / val . cc <nl> ppp b / src / rdb_protocol / val . cc <nl> table_t : : table_t ( env_t * _env , counted_t < const db_t > _db , const std : : string & _nam <nl> uuid_u db_id = db - > id ; <nl> name_string_t table_name ; <nl> bool b = table_name . assign_value ( name ) ; <nl> - rcheck ( b , strprintf ( " Table name ` % s ` invalid ( % s ) . " , <nl> - name . c_str ( ) , name_string_t : : valid_char_msg ) ) ; <nl> + rcheck ( b , base_exc_t : : GENERIC , <nl> + strprintf ( " Table name ` % s ` invalid ( % s ) . " , <nl> + name . c_str ( ) , name_string_t : : valid_char_msg ) ) ; <nl> cow_ptr_t < namespaces_semilattice_metadata_t < rdb_protocol_t > > <nl> namespaces_metadata = env - > namespaces_semilattice_metadata - > get ( ) ; <nl> cow_ptr_t < namespaces_semilattice_metadata_t < rdb_protocol_t > > : : change_t <nl> table_t : : table_t ( env_t * _env , counted_t < const db_t > _db , const std : : string & _nam <nl> metadata_searcher_t < namespace_semilattice_metadata_t < rdb_protocol_t > > : : iterator <nl> ns_metadata_it = ns_searcher . find_uniq ( pred , & status ) ; <nl> rcheck ( status = = METADATA_SUCCESS , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Table ` % s ` does not exist . " , table_name . c_str ( ) ) ) ; <nl> guarantee ( ! ns_metadata_it - > second . is_deleted ( ) ) ; <nl> r_sanity_check ( ! ns_metadata_it - > second . get ( ) . primary_key . in_conflict ( ) ) ; <nl> counted_t < const datum_t > table_t : : sindex_list ( ) { <nl> array - > add ( make_counted < datum_t > ( * it ) ) ; <nl> } <nl> } catch ( const cannot_perform_query_exc_t & ex ) { <nl> - rfail ( " cannot perform read : % s " , ex . what ( ) ) ; <nl> + rfail ( ql : : base_exc_t : : GENERIC , " cannot perform read : % s " , ex . what ( ) ) ; <nl> } <nl> <nl> return counted_t < const datum_t > ( array . release ( ) ) ; <nl> bool val_t : : as_bool ( ) { <nl> r_sanity_check ( d . has ( ) ) ; <nl> return d - > as_bool ( ) ; <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> double val_t : : as_num ( ) { <nl> r_sanity_check ( d . has ( ) ) ; <nl> return d - > as_num ( ) ; <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> int64_t val_t : : as_int ( ) { <nl> r_sanity_check ( d . has ( ) ) ; <nl> return d - > as_int ( ) ; <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> const std : : string & val_t : : as_str ( ) { <nl> r_sanity_check ( d . has ( ) ) ; <nl> return d - > as_str ( ) ; <nl> } catch ( const datum_exc_t & e ) { <nl> - rfail ( " % s " , e . what ( ) ) ; <nl> + rfail ( e . get_type ( ) , " % s " , e . what ( ) ) ; <nl> unreachable ( ) ; <nl> } <nl> } <nl> <nl> void val_t : : rcheck_literal_type ( type_t : : raw_type_t expected_raw_type ) { <nl> - rcheck ( type . raw_type = = expected_raw_type , <nl> - strprintf ( " Expected type % s but found % s : \ n % s " , <nl> - type_t ( expected_raw_type ) . name ( ) , type . name ( ) , print ( ) . c_str ( ) ) ) ; <nl> + rcheck_typed_target ( <nl> + this , type . raw_type = = expected_raw_type , <nl> + strprintf ( " Expected type % s but found % s : \ n % s " , <nl> + type_t ( expected_raw_type ) . name ( ) , type . name ( ) , print ( ) . c_str ( ) ) ) ; <nl> } <nl> <nl> } / / namespace ql <nl> mmm a / src / rdb_protocol / val . hpp <nl> ppp b / src / rdb_protocol / val . hpp <nl> class val_t : public slow_atomic_countable_t < val_t > , public pb_rcheckable_t { <nl> int64_t i = as_int ( ) ; <nl> T t = static_cast < T > ( i ) ; <nl> rcheck ( static_cast < int64_t > ( t ) = = i , <nl> + base_exc_t : : GENERIC , <nl> strprintf ( " Integer too large : % " PRIi64 , i ) ) ; <nl> return t ; <nl> } <nl> mmm a / src / rdb_protocol / validate . cc <nl> ppp b / src / rdb_protocol / validate . cc <nl> <nl> # define check_has ( pb , field ) \ <nl> rcheck_toplevel ( \ <nl> ( pb ) . has_ # # field ( ) , \ <nl> - strprintf ( " MALFORMED PROTOBUF ( missing field ` % s ` ) : \ n % s " , \ <nl> + ql : : base_exc_t : : GENERIC , \ <nl> + strprintf ( " MALFORMED PROTOBUF ( missing field ` % s ` ) : \ n % s " , \ <nl> # field , ( pb ) . DebugString ( ) . c_str ( ) ) ) <nl> # define check_not_has ( pb , field ) \ <nl> rcheck_toplevel ( \ <nl> ! ( pb ) . has_ # # field ( ) , \ <nl> - strprintf ( " MALFORMED PROTOBUF ( spurious field ` % s ` ) : \ n % s " , \ <nl> + ql : : base_exc_t : : GENERIC , \ <nl> + strprintf ( " MALFORMED PROTOBUF ( spurious field ` % s ` ) : \ n % s " , \ <nl> # field , ( pb ) . DebugString ( ) . c_str ( ) ) ) <nl> # define check_empty ( pb , field ) \ <nl> rcheck_toplevel ( \ <nl> ( pb ) . field # # _size ( ) = = 0 , \ <nl> - strprintf ( " MALFORMED PROTOBUF ( non - empty field ` % s ` ) : \ n % s " , \ <nl> + ql : : base_exc_t : : GENERIC , \ <nl> + strprintf ( " MALFORMED PROTOBUF ( non - empty field ` % s ` ) : \ n % s " , \ <nl> # field , ( pb ) . DebugString ( ) . c_str ( ) ) ) <nl> <nl> void validate_pb ( const Query & q ) { <nl> mmm a / test / rql_test / src / arity . yaml <nl> ppp b / test / rql_test / src / arity . yaml <nl> tests : <nl> - r . db_create ( ) <nl> - r . db_drop ( ) <nl> - r . db ( ) <nl> - - r . error ( ) <nl> + <nl> + - cd : r . error ( ) <nl> + ot : err ( " RqlRuntimeError " , " Empty ERROR term outside a default block . " , [ ] ) <nl> <nl> - cd : r . js ( ) <nl> ot : <nl> tests : <nl> - array . prepend ( ) <nl> - tbl . nth ( ) <nl> - tbl . for_each ( ) <nl> - - tbl . filter ( ) <nl> - tbl . get ( ) <nl> - r . expr ( [ ] ) . sample ( ) <nl> - tbl . indexes_of ( ) <nl> tests : <nl> - r . db_create ( 1 , 2 ) <nl> - r . db_drop ( 1 , 2 ) <nl> - r . db ( 1 , 2 ) <nl> - - r . error ( 1 , 2 ) <nl> + <nl> + - ot : <nl> + js : err ( " RqlDriverError " , " Expected 1 argument ( s ) but found 0 . " , [ ] ) <nl> + rb : err ( " RqlCompileError " , " Expected 2 argument ( s ) but found 1 . " , [ ] ) <nl> + py : err_regex ( ' TypeError ' , " . * takes at least 2 arguments \ ( 1 given \ ) " , [ ] ) <nl> + cd : <nl> + - tbl . filter ( ) <nl> + <nl> + - cd : r . error ( 1 , 2 ) <nl> + ot : <nl> + rb : err ( " RqlCompileError " , " Expected between 0 and 1 arguments but found 2 . " , [ ] ) <nl> + py : err ( " RqlCompileError " , " Expected between 0 and 1 arguments but found 2 . " , [ ] ) <nl> + js : err ( " RqlDriverError " , " Expected between 0 and 1 argument ( s ) but found 2 . " , [ ] ) <nl> <nl> - cd : <nl> - db . table_drop ( ) <nl> tests : <nl> - array . prepend ( 1 , 2 ) <nl> - tbl . nth ( 1 , 2 ) <nl> - tbl . for_each ( 1 , 2 ) <nl> - - tbl . filter ( 1 , 2 ) <nl> - tbl . get ( 1 , 2 ) <nl> - r . expr ( [ ] ) . sample ( 1 , 2 ) <nl> - tbl . indexes_of ( 1 , 2 ) <nl> <nl> + - ot : <nl> + js : err ( " RqlDriverError " , " Expected 1 argument ( s ) but found 3 . " , [ ] ) <nl> + rb : err ( " RqlCompileError " , " Expected 2 argument ( s ) but found 4 . " , [ ] ) <nl> + py : err_regex ( ' TypeError ' , " . * takes at most 3 arguments \ ( 4 given \ ) " , [ ] ) <nl> + cd : <nl> + - tbl . filter ( 1 , 2 , 3 ) <nl> + <nl> - cd : db . table_drop ( 1 , 2 ) <nl> ot : <nl> rb : err ( " RqlCompileError " , " Expected between 1 and 2 arguments but found 3 . " , [ ] ) <nl> mmm a / test / rql_test / src / control . yaml <nl> ppp b / test / rql_test / src / control . yaml <nl> tests : <nl> - cd : r . error ( ' Hello World ' ) <nl> ot : err ( " RqlRuntimeError " , " Hello World " , [ 0 ] ) <nl> <nl> - # r . error ( ) negative cases <nl> - - cd : r . error ( ) <nl> - py : [ ] # Here we rely on a native python error <nl> - rb : [ ] <nl> - ot : err ( " RqlDriverError " , " Expected 1 argument ( s ) but found 0 . " , [ 0 ] ) <nl> - <nl> - - cd : r . error ( ' foo ' , ' bar ' ) <nl> - py : [ ] # Here we rely on a native python error <nl> - rb : [ ] <nl> - ot : err ( " RqlDriverError " , " Expected 1 argument ( s ) but found 2 . " , [ 0 ] ) <nl> - <nl> - cd : r . error ( 5 ) # we might want to allow this eventually <nl> ot : err ( " RqlRuntimeError " , " Expected type STRING but found NUMBER . " , [ 0 ] ) <nl> <nl> tests : <nl> <nl> # Should timeout after the default of 5 seconds <nl> - cd : r . js ( ' while ( true ) { } ' ) <nl> - ot : err ( " RqlRuntimeError " , " JavaScript query \ " while ( true ) { } \ " timed out after 5 seconds " , [ 0 ] ) <nl> + ot : err ( " RqlRuntimeError " , " JavaScript query ` while ( true ) { } ` timed out after 5 seconds . " , [ 0 ] ) <nl> <nl> - py : r . js ( ' while ( true ) { } ' , timeout = 1 . 3 ) <nl> js : r . js ( ' while ( true ) { } ' , { timeout : 1 . 3 } ) <nl> rb : r . js ( ' while ( true ) { } ' , : timeout = > 1 . 3 ) <nl> - ot : err ( " RqlRuntimeError " , " JavaScript query \ " while ( true ) { } \ " timed out after 1 . 3 seconds " , [ 0 ] ) <nl> + ot : err ( " RqlRuntimeError " , " JavaScript query ` while ( true ) { } ` timed out after 1 . 3 seconds . " , [ 0 ] ) <nl> <nl> - py : r . js ( ' while ( true ) { } ' , timeout = 8 ) <nl> js : r . js ( ' while ( true ) { } ' , { timeout : 8 } ) <nl> rb : r . js ( ' while ( true ) { } ' , : timeout = > 8 ) <nl> - ot : err ( " RqlRuntimeError " , " JavaScript query \ " while ( true ) { } \ " timed out after 8 seconds " , [ 0 ] ) <nl> + ot : err ( " RqlRuntimeError " , " JavaScript query ` while ( true ) { } ` timed out after 8 seconds . " , [ 0 ] ) <nl> <nl> # js error cases <nl> - cd : r . js ( ' ( function ( ) { return 1 ; } ) ' ) <nl> new file mode 100644 <nl> index 00000000000 . . f841a5966a5 <nl> mmm / dev / null <nl> ppp b / test / rql_test / src / default . yaml <nl> <nl> + desc : Tests r . default <nl> + tests : <nl> + <nl> + # The test driver sometimes rewrites ` null ` to ` None ` in Ruby for unknown reasons . <nl> + <nl> + # tst <nl> + - cd : r . expr ( 1 ) . default ( 2 ) <nl> + ot : 1 <nl> + - cd : r . expr ( null ) . default ( 2 ) <nl> + ot : 2 <nl> + - cd : r . expr ( { } ) [ ' b ' ] . default ( 2 ) <nl> + js : r . expr ( { } ) ( ' b ' ) . default ( 2 ) <nl> + ot : 2 <nl> + - cd : r . expr ( r . expr ( ' a ' ) [ ' b ' ] ) . default ( 2 ) <nl> + js : r . expr ( r . expr ( ' a ' ) ( ' b ' ) ) . default ( 2 ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type OBJECT but found STRING . " , [ ] ) <nl> + - rb : r . expr ( [ ] ) . reduce { | a , b | a + b } . default ( 2 ) <nl> + py : r . expr ( [ ] ) . reduce ( lambda a , b : a + b ) . default ( 2 ) <nl> + js : r . expr ( [ ] ) . reduce ( function ( a , b ) { return a + b } ) . default ( 2 ) <nl> + ot : 2 <nl> + - rb : r . expr ( ' a ' ) . reduce { | a , b | a + b } . default ( 2 ) <nl> + py : r . expr ( ' a ' ) . reduce ( lambda a , b : a + b ) . default ( 2 ) <nl> + js : r . expr ( ' a ' ) . reduce ( function ( a , b ) { return a + b } ) . default ( 2 ) <nl> + ot : err ( " RqlRuntimeError " , " Cannot convert STRING to SEQUENCE " , [ ] ) <nl> + - cd : ( r . expr ( null ) + 5 ) . default ( 2 ) <nl> + js : ( r . expr ( null ) . add ( 5 ) ) . default ( 2 ) <nl> + ot : 2 <nl> + - cd : ( 5 + r . expr ( null ) ) . default ( 2 ) <nl> + js : ( r . expr ( 5 ) . add ( null ) ) . default ( 2 ) <nl> + ot : 2 <nl> + - cd : ( 5 - r . expr ( null ) ) . default ( 2 ) <nl> + js : ( r . expr ( 5 ) . sub ( null ) ) . default ( 2 ) <nl> + ot : 2 <nl> + - cd : ( r . expr ( null ) - 5 ) . default ( 2 ) <nl> + js : ( r . expr ( null ) . sub ( 5 ) ) . default ( 2 ) <nl> + ot : 2 <nl> + - cd : ( r . expr ( ' a ' ) + 5 ) . default ( 2 ) <nl> + js : ( r . expr ( ' a ' ) . add ( 5 ) ) . default ( 2 ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type STRING but found NUMBER . " , [ ] ) <nl> + - cd : ( 5 + r . expr ( ' a ' ) ) . default ( 2 ) <nl> + js : ( r . expr ( 5 ) . add ( ' a ' ) ) . default ( 2 ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found STRING . " , [ ] ) <nl> + - cd : ( r . expr ( ' a ' ) - 5 ) . default ( 2 ) <nl> + js : ( r . expr ( ' a ' ) . sub ( 5 ) ) . default ( 2 ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found STRING . " , [ ] ) <nl> + - cd : ( 5 - r . expr ( ' a ' ) ) . default ( 2 ) <nl> + js : ( r . expr ( 5 ) . sub ( ' a ' ) ) . default ( 2 ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found STRING . " , [ ] ) <nl> + <nl> + - cd : r . expr ( 1 ) . default ( r . error ( ) ) <nl> + ot : 1 <nl> + - cd : r . expr ( null ) . default ( r . error ( ) ) <nl> + ot : ( null ) <nl> + - cd : r . expr ( { } ) [ ' b ' ] . default ( r . error ( ) ) <nl> + js : r . expr ( { } ) ( ' b ' ) . default ( r . error ( ) ) <nl> + ot : err ( " RqlRuntimeError " , " No attribute ` b ` in object . " , [ ] ) <nl> + - rb : r . expr ( [ ] ) . reduce { | a , b | a + b } . default ( r . error ) <nl> + py : r . expr ( [ ] ) . reduce ( lambda a , b : a + b ) . default ( r . error ) <nl> + js : r . expr ( [ ] ) . reduce ( function ( a , b ) { return a + b } ) . default ( r . error ) <nl> + ot : err ( " RqlRuntimeError " , " Cannot reduce over an empty stream with no base . " , [ ] ) <nl> + - cd : ( r . expr ( null ) + 5 ) . default ( r . error ) <nl> + js : ( r . expr ( null ) . add ( 5 ) ) . default ( r . error ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found NULL . " , [ ] ) <nl> + - cd : ( 5 + r . expr ( null ) ) . default ( r . error ) <nl> + js : ( r . expr ( 5 ) . add ( null ) ) . default ( r . error ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found NULL . " , [ ] ) <nl> + - cd : ( 5 - r . expr ( null ) ) . default ( r . error ) <nl> + js : ( r . expr ( 5 ) . sub ( null ) ) . default ( r . error ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found NULL . " , [ ] ) <nl> + - cd : ( r . expr ( null ) - 5 ) . default ( r . error ) <nl> + js : ( r . expr ( null ) . sub ( 5 ) ) . default ( r . error ) <nl> + ot : err ( " RqlRuntimeError " , " Expected type NUMBER but found NULL . " , [ ] ) <nl> + <nl> + - rb : r . expr ( 1 ) . default { | e | e } <nl> + py : r . expr ( 1 ) . default ( lambda e : e ) <nl> + js : r . expr ( 1 ) . default ( function ( e ) { return e } ) <nl> + ot : 1 <nl> + - cd : r . expr ( null ) . default { | e | e } <nl> + py : r . expr ( null ) . default ( lambda e : e ) <nl> + js : r . expr ( null ) . default ( function ( e ) { return e } ) <nl> + ot : ( null ) <nl> + - cd : r . expr ( { } ) [ ' b ' ] . default { | e | e } <nl> + py : r . expr ( { } ) [ ' b ' ] . default ( lambda e : e ) <nl> + js : r . expr ( { } ) ( ' b ' ) . default ( function ( e ) { return e } ) <nl> + ot : ( " No attribute ` b ` in object : \ n { \ n } " ) <nl> + - cd : r . expr ( [ ] ) . reduce { | a , b | a + b } . default { | e | e } <nl> + py : r . expr ( [ ] ) . reduce ( lambda a , b : a + b ) . default ( lambda e : e ) <nl> + js : r . expr ( [ ] ) . reduce ( function ( a , b ) { return a + b } ) . default ( function ( e ) { return e } ) <nl> + ot : ( " Cannot reduce over an empty stream with no base . " ) <nl> + - cd : ( r . expr ( null ) + 5 ) . default { | e | e } <nl> + py : ( r . expr ( null ) + 5 ) . default ( lambda e : e ) <nl> + js : ( r . expr ( null ) . add ( 5 ) ) . default ( function ( e ) { return e } ) <nl> + ot : ( " Expected type NUMBER but found NULL . " ) <nl> + - cd : ( 5 + r . expr ( null ) ) . default { | e | e } <nl> + py : ( 5 + r . expr ( null ) ) . default ( lambda e : e ) <nl> + js : ( r . expr ( 5 ) . add ( null ) ) . default ( function ( e ) { return e } ) <nl> + ot : ( " Expected type NUMBER but found NULL . " ) <nl> + - cd : ( 5 - r . expr ( null ) ) . default { | e | e } <nl> + py : ( 5 - r . expr ( null ) ) . default ( lambda e : e ) <nl> + js : ( r . expr ( 5 ) . sub ( null ) ) . default ( function ( e ) { return e } ) <nl> + ot : ( " Expected type NUMBER but found NULL . " ) <nl> + - cd : ( r . expr ( null ) - 5 ) . default { | e | e } <nl> + py : ( r . expr ( null ) - 5 ) . default ( lambda e : e ) <nl> + js : ( r . expr ( null ) . sub ( 5 ) ) . default ( function ( e ) { return e } ) <nl> + ot : ( " Expected type NUMBER but found NULL . " ) <nl> + <nl> + - def : arr = r . expr ( [ { ' a ' : 1 } , { ' a ' : null } , { } ] ) . order_by ( ' a ' ) <nl> + <nl> + - cd : arr . filter { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : arr . filter ( : default = > false ) { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = False ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { ' default ' : false } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : arr . filter ( : default = > true ) { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = True ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { ' default ' : true } ) <nl> + ot : [ { } , { ' a ' : 1 } ] # ` null ` compares not equal to 1 with no error <nl> + - cd : arr . filter ( : default = > r . error ) { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = r . error ( ) ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { ' default ' : r . error ( ) } ) <nl> + ot : err ( " RqlRuntimeError " , " No attribute ` a ` in object . " , [ ] ) <nl> + <nl> + - cd : r . expr ( false ) . do { | d | arr . filter ( : default = > d ) { | x | x [ ' a ' ] . eq ( 1 ) } } <nl> + py : r . expr ( False ) . do ( lambda d : arr . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = d ) ) <nl> + js : r . expr ( false ) . do ( function ( d ) { return arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { default : d } ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : r . expr ( true ) . do { | d | arr . filter ( : default = > d ) { | x | x [ ' a ' ] . eq ( 1 ) } } . orderby ( ' a ' ) <nl> + py : r . expr ( True ) . do ( lambda d : arr . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = d ) ) . order_by ( ' a ' ) <nl> + js : r . expr ( true ) . do ( function ( d ) { return arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { default : d } ) } ) . orderBy ( ' a ' ) <nl> + ot : [ { } , { ' a ' : 1 } ] # ` null ` compares not equal to 1 with no error <nl> + <nl> + - cd : arr . filter { | x | x [ ' a ' ] . default ( 0 ) . eq ( 1 ) } <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . default ( 0 ) . eq ( 1 ) ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . default ( 0 ) . eq ( 1 ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : arr . filter { | x | x [ ' a ' ] . default ( 1 ) . eq ( 1 ) } . orderby ( ' a ' ) <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . default ( 1 ) . eq ( 1 ) ) . order_by ( ' a ' ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . default ( 1 ) . eq ( 1 ) } ) . orderBy ( ' a ' ) <nl> + ot : ( [ { } , { ' a ' : null } , { ' a ' : 1 } ] ) <nl> + - cd : arr . filter { | x | x [ ' a ' ] . default ( r . error ) . eq ( 1 ) } <nl> + py : arr . filter ( lambda x : x [ ' a ' ] . default ( r . error ( ) ) . eq ( 1 ) ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . default ( r . error ( ) ) . eq ( 1 ) } ) <nl> + ot : [ { ' a ' : 1 } ] # gets caught by ` filter ` default <nl> + <nl> + - cd : r . expr ( 0 ) . do { | i | arr . filter { | x | x [ ' a ' ] . default ( i ) . eq ( 1 ) } } <nl> + py : r . expr ( 0 ) . do ( lambda i : arr . filter ( lambda x : x [ ' a ' ] . default ( i ) . eq ( 1 ) ) ) <nl> + js : r . expr ( 0 ) . do ( function ( i ) { return arr . filter ( function ( x ) { return x ( ' a ' ) . default ( i ) . eq ( 1 ) } ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : r . expr ( 1 ) . do { | i | arr . filter { | x | x [ ' a ' ] . default ( i ) . eq ( 1 ) } } . orderby ( ' a ' ) <nl> + py : r . expr ( 1 ) . do ( lambda i : arr . filter ( lambda x : x [ ' a ' ] . default ( i ) . eq ( 1 ) ) ) . order_by ( ' a ' ) <nl> + js : r . expr ( 1 ) . do ( function ( i ) { return arr . filter ( function ( x ) { return x ( ' a ' ) . default ( i ) . eq ( 1 ) } ) } ) . orderBy ( ' a ' ) <nl> + ot : ( [ { } , { ' a ' : null } , { ' a ' : 1 } ] ) <nl> + <nl> + - cd : arr . filter { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } <nl> + py : arr . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : arr . filter ( : default = > false ) { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } <nl> + py : arr . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) , default = False ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } , { default : false } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : arr . filter ( : default = > true ) { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } . orderby ( ' a ' ) <nl> + py : arr . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) , default = True ) . order_by ( ' a ' ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } , { default : true } ) . orderBy ( ' a ' ) <nl> + ot : ( [ { } , { ' a ' : null } , { ' a ' : 1 } ] ) <nl> + - cd : arr . filter ( : default = > r . error ) { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } <nl> + py : arr . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) , default = r . error ( ) ) <nl> + js : arr . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } , { default : r . error ( ) } ) <nl> + ot : err ( " RqlRuntimeError " , " No attribute ` a ` in object . " , [ ] ) <nl> + <nl> + - cd : r . table_create ( ' default_test ' ) <nl> + ot : ( { ' created ' : 1 } ) <nl> + <nl> + - cd : r . table ( ' default_test ' ) . insert ( arr ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 0 . 0 , ' generated_keys ' : arrlen ( 3 , uuid ( ) ) , ' unchanged ' : 0 . 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 3 } ) <nl> + <nl> + - def : tbl = r . table ( ' default_test ' ) . order_by ( ' a ' ) . pluck ( ' a ' ) <nl> + <nl> + - cd : tbl . filter { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : tbl . filter ( : default = > false ) { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = False ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { ' default ' : false } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : tbl . filter ( : default = > true ) { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = True ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { ' default ' : true } ) <nl> + ot : [ { } , { ' a ' : 1 } ] # ` null ` compares not equal to 1 with no error <nl> + - cd : tbl . filter ( : default = > r . error ) { | x | x [ ' a ' ] . eq ( 1 ) } <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = r . error ( ) ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { ' default ' : r . error ( ) } ) <nl> + ot : err ( " RqlRuntimeError " , " No attribute ` a ` in object . " , [ ] ) <nl> + <nl> + - cd : r . expr ( false ) . do { | d | tbl . filter ( : default = > d ) { | x | x [ ' a ' ] . eq ( 1 ) } } <nl> + py : r . expr ( False ) . do ( lambda d : tbl . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = d ) ) <nl> + js : r . expr ( false ) . do ( function ( d ) { return tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { default : d } ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : r . expr ( true ) . do { | d | tbl . filter ( : default = > d ) { | x | x [ ' a ' ] . eq ( 1 ) } } . orderby ( ' a ' ) <nl> + py : r . expr ( True ) . do ( lambda d : tbl . filter ( lambda x : x [ ' a ' ] . eq ( 1 ) , default = d ) ) . order_by ( ' a ' ) <nl> + js : r . expr ( true ) . do ( function ( d ) { return tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) } , { default : d } ) } ) . orderBy ( ' a ' ) <nl> + ot : [ { } , { ' a ' : 1 } ] # ` null ` compares not equal to 1 with no error <nl> + <nl> + - cd : tbl . filter { | x | x [ ' a ' ] . default ( 0 ) . eq ( 1 ) } <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . default ( 0 ) . eq ( 1 ) ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . default ( 0 ) . eq ( 1 ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : tbl . filter { | x | x [ ' a ' ] . default ( 1 ) . eq ( 1 ) } . orderby ( ' a ' ) <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . default ( 1 ) . eq ( 1 ) ) . order_by ( ' a ' ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . default ( 1 ) . eq ( 1 ) } ) . orderBy ( ' a ' ) <nl> + ot : ( [ { } , { ' a ' : null } , { ' a ' : 1 } ] ) <nl> + - cd : tbl . filter { | x | x [ ' a ' ] . default ( r . error ) . eq ( 1 ) } <nl> + py : tbl . filter ( lambda x : x [ ' a ' ] . default ( r . error ( ) ) . eq ( 1 ) ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . default ( r . error ( ) ) . eq ( 1 ) } ) <nl> + ot : [ { ' a ' : 1 } ] # gets caught by ` filter ` default <nl> + <nl> + - cd : r . expr ( 0 ) . do { | i | tbl . filter { | x | x [ ' a ' ] . default ( i ) . eq ( 1 ) } } <nl> + py : r . expr ( 0 ) . do ( lambda i : tbl . filter ( lambda x : x [ ' a ' ] . default ( i ) . eq ( 1 ) ) ) <nl> + js : r . expr ( 0 ) . do ( function ( i ) { return tbl . filter ( function ( x ) { return x ( ' a ' ) . default ( i ) . eq ( 1 ) } ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : r . expr ( 1 ) . do { | i | tbl . filter { | x | x [ ' a ' ] . default ( i ) . eq ( 1 ) } } . orderby ( ' a ' ) <nl> + py : r . expr ( 1 ) . do ( lambda i : tbl . filter ( lambda x : x [ ' a ' ] . default ( i ) . eq ( 1 ) ) ) . order_by ( ' a ' ) <nl> + js : r . expr ( 1 ) . do ( function ( i ) { return tbl . filter ( function ( x ) { return x ( ' a ' ) . default ( i ) . eq ( 1 ) } ) } ) . orderBy ( ' a ' ) <nl> + ot : ( [ { } , { ' a ' : null } , { ' a ' : 1 } ] ) <nl> + <nl> + - cd : tbl . filter { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } <nl> + py : tbl . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : tbl . filter ( : default = > false ) { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } <nl> + py : tbl . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) , default = False ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } , { default : false } ) <nl> + ot : [ { ' a ' : 1 } ] <nl> + - cd : tbl . filter ( : default = > true ) { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } . orderby ( ' a ' ) <nl> + py : tbl . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) , default = True ) . order_by ( ' a ' ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } , { default : true } ) . orderBy ( ' a ' ) <nl> + ot : ( [ { } , { ' a ' : null } , { ' a ' : 1 } ] ) <nl> + - cd : tbl . filter ( : default = > r . error ) { | x | x [ ' a ' ] . eq ( 1 ) . or ( x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) } <nl> + py : tbl . filter ( lambda x : r . any ( x [ ' a ' ] . eq ( 1 ) , x [ ' a ' ] [ ' b ' ] . eq ( 2 ) ) , default = r . error ( ) ) <nl> + js : tbl . filter ( function ( x ) { return x ( ' a ' ) . eq ( 1 ) . or ( x ( ' a ' ) ( ' b ' ) . eq ( 2 ) ) } , { default : r . error ( ) } ) <nl> + ot : err ( " RqlRuntimeError " , " No attribute ` a ` in object . " , [ ] ) <nl> + <nl> + - cd : r . table_drop ( ' default_test ' ) <nl> + ot : ( { ' dropped ' : 1 } ) <nl> mmm a / test / rql_test / src / selection . yaml <nl> ppp b / test / rql_test / src / selection . yaml <nl> tests : <nl> <nl> # test filtering for things by a missing attribute <nl> - cd : r . expr ( [ { ' a ' : 1 } ] ) . filter ( { ' b ' : 1 } ) <nl> - ot : err ( ' RqlRuntimeError ' , ' No attribute ` b ` in object . ' , [ 0 ] ) <nl> + ot : [ ] <nl> <nl> # Count with parameter <nl> - js : tbl . count ( function ( ) { return { ' a ' : 1 } ; } ) <nl> tests : <nl> <nl> - cd : r . expr ( [ null , 4 , null , ' foo ' ] ) . count ( null ) <nl> ot : 2 <nl> - <nl> + <nl> # what the heck , let ' s see what happens <nl> - py : r . expr ( 5 ) + tbl <nl> js : r . expr ( 5 ) . add ( tbl ) <nl> rb : r 5 + tbl <nl> ot : err ( ' RqlRuntimeError ' , ' Expected type DATUM but found TABLE . ' , [ 0 ] ) <nl> - <nl> + <nl> # Clean up <nl> - cd : r . db ( ' test ' ) . table_list ( ) . for_each ( r . db ( ' test ' ) . table_drop ( r . row ) ) <nl> rb : r . db ( ' test ' ) . table_list ( ) . for_each { | row | r . db ( ' test ' ) . table_drop ( row ) } <nl> mmm a / test / rql_test / src / transformation . yaml <nl> ppp b / test / rql_test / src / transformation . yaml <nl> tests : <nl> ot : ( { ' id ' : 0 , ' a ' : 0 } ) <nl> <nl> - cd : tbl . pluck ( ' id ' , ' missing ' ) . order_by ( ' id ' ) . nth ( 0 ) <nl> - ot : err ( ' RqlRuntimeError ' , ' No attribute ` missing ` in object . ' , [ 0 ] ) <nl> + ot : ( { ' id ' : 0 } ) <nl> <nl> # without <nl> - cd : tbl . without ( ) . order_by ( ' id ' ) . nth ( 0 ) <nl>
merged
rethinkdb/rethinkdb
eca106d54be7358ff89cfed53ad2119332658ce9
2013-06-06T00:27:18Z
mmm a / src / gen / theme_class . cpp <nl> ppp b / src / gen / theme_class . cpp <nl> <nl> # include " base / string . h " <nl> # include " gen / common . h " <nl> <nl> + # include < cstring > <nl> # include < iostream > <nl> # include < vector > <nl> <nl>
Try fix gcc compiler error
aseprite/aseprite
eee87ed1ece574c1b0c9c1ef3666497849f565c5
2017-04-07T14:23:52Z
mmm a / modules / core / misc / objc / common / CVObjcUtil . h <nl> ppp b / modules / core / misc / objc / common / CVObjcUtil . h <nl> <nl> <nl> # pragma once <nl> <nl> - typedef union { double d ; int64_t l ; } V64 ; <nl> - typedef union { float f ; int32_t i ; } V32 ; <nl> - <nl> - # define DOUBLE_TO_BITS ( x ) ( ( V64 ) { . d = x } ) . l <nl> - # define FLOAT_TO_BITS ( x ) ( ( V32 ) { . f = x } ) . i <nl> - <nl> # ifndef CV_EXPORTS <nl> # ifdef __cplusplus <nl> # define CV_EXPORTS __attribute__ ( ( visibility ( " default " ) ) ) <nl> mmm a / modules / core / misc / objc / common / DMatch . mm <nl> ppp b / modules / core / misc / objc / common / DMatch . mm <nl> <nl> / / <nl> <nl> # import " DMatch . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation DMatch { <nl> cv : : DMatch native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / KeyPoint . mm <nl> ppp b / modules / core / misc / objc / common / KeyPoint . mm <nl> <nl> <nl> # import " KeyPoint . h " <nl> # import " Point2f . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation KeyPoint { <nl> cv : : KeyPoint native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Point2d . mm <nl> ppp b / modules / core / misc / objc / common / Point2d . mm <nl> <nl> <nl> # import " Point2d . h " <nl> # import " Rect2d . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Point2d { <nl> cv : : Point2d native ; <nl> - ( BOOL ) inside : ( Rect2d * ) rect { <nl> return [ rect contains : self ] ; <nl> } <nl> <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Point2f . mm <nl> ppp b / modules / core / misc / objc / common / Point2f . mm <nl> <nl> <nl> # import " Point2f . h " <nl> # import " Rect2f . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Point2f { <nl> cv : : Point2f native ; <nl> - ( BOOL ) inside : ( Rect2f * ) rect { <nl> return [ rect contains : self ] ; <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Point3d . mm <nl> ppp b / modules / core / misc / objc / common / Point3d . mm <nl> <nl> <nl> # import " Point3d . h " <nl> # import " Point2d . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Point3d { <nl> cv : : Point3d native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Point3f . mm <nl> ppp b / modules / core / misc / objc / common / Point3f . mm <nl> <nl> <nl> # import " Point3f . h " <nl> # import " Point2f . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Point3f { <nl> cv : : Point3f native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Rect2d . mm <nl> ppp b / modules / core / misc / objc / common / Rect2d . mm <nl> <nl> # import " Rect2d . h " <nl> # import " Point2d . h " <nl> # import " Size2d . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Rect2d { <nl> cv : : Rect2d native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Rect2f . mm <nl> ppp b / modules / core / misc / objc / common / Rect2f . mm <nl> <nl> # import " Rect2f . h " <nl> # import " Point2f . h " <nl> # import " Size2f . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Rect2f { <nl> cv : : Rect2f native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / RotatedRect . mm <nl> ppp b / modules / core / misc / objc / common / RotatedRect . mm <nl> <nl> # import " Point2f . h " <nl> # import " Size2f . h " <nl> # import " Rect2f . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> # include < math . h > <nl> <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Scalar . mm <nl> ppp b / modules / core / misc / objc / common / Scalar . mm <nl> <nl> / / <nl> <nl> # import " Scalar . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> double getVal ( NSArray < NSNumber * > * vals , int index ) { <nl> return [ vals count ] > index ? vals [ index ] . doubleValue : 0 ; <nl> - ( BOOL ) isEqual : ( id ) other <nl> } <nl> } <nl> <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash <nl> { <nl> int prime = 31 ; <nl> mmm a / modules / core / misc / objc / common / Size2d . mm <nl> ppp b / modules / core / misc / objc / common / Size2d . mm <nl> <nl> <nl> # import " Size2d . h " <nl> # import " Point2d . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Size2d { <nl> cv : : Size2d native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / Size2f . mm <nl> ppp b / modules / core / misc / objc / common / Size2f . mm <nl> <nl> <nl> # import " Size2f . h " <nl> # import " Point2f . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation Size2f { <nl> cv : : Size2f native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define FLOAT_TO_BITS ( x ) ( ( Cv32suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / core / misc / objc / common / TermCriteria . mm <nl> ppp b / modules / core / misc / objc / common / TermCriteria . mm <nl> <nl> / / <nl> <nl> # import " TermCriteria . h " <nl> - # import " CVObjcUtil . h " <nl> <nl> @ implementation TermCriteria { <nl> cv : : TermCriteria native ; <nl> - ( BOOL ) isEqual : ( id ) other { <nl> } <nl> } <nl> <nl> + # define DOUBLE_TO_BITS ( x ) ( ( Cv64suf ) { . f = x } ) . i <nl> + <nl> - ( NSUInteger ) hash { <nl> int prime = 31 ; <nl> uint32_t result = 1 ; <nl> mmm a / modules / objc / doc / README . md <nl> ppp b / modules / objc / doc / README . md <nl> To get started : add the OpenCV framework to your project and add the following t <nl> # # # Swift <nl> <nl> import OpenCV <nl> - <nl> - For details of core OpenCV functionality see : ` Core ` , ` Mat ` , ` Imgproc ` <nl> mmm a / modules / objc / generator / gen_objc . py <nl> ppp b / modules / objc / generator / gen_objc . py <nl> def write ( self , s ) : <nl> ( " Mat " , " dot " ) : " - dot : " <nl> } <nl> <nl> + modules = [ ] <nl> + <nl> def read_contents ( fname ) : <nl> with open ( fname , ' r ' ) as f : <nl> data = f . read ( ) <nl> def __init__ ( self , type , decl , namespaces ) : <nl> <nl> docstring + = sanitize_documentation_string ( doc , type ) <nl> elif type = = " class " : <nl> - docstring + = " / * * \ n * The " + self . name + " module \ n * / \ n " <nl> + docstring + = " / * * \ n * The " + self . name + " module \ n * / \ n " <nl> <nl> self . docstring = docstring <nl> <nl> def cast_to ( t ) : <nl> return type_dict [ t ] [ " cast_to " ] <nl> return t <nl> <nl> + def gen_class_doc ( docstring , module , members , enums ) : <nl> + lines = docstring . splitlines ( ) <nl> + lines . insert ( len ( lines ) - 1 , " * " ) <nl> + if len ( members ) > 0 : <nl> + lines . insert ( len ( lines ) - 1 , " * Member classes : " + " , " . join ( [ ( " ` " + m + " ` " ) for m in members ] ) ) <nl> + lines . insert ( len ( lines ) - 1 , " * " ) <nl> + else : <nl> + lines . insert ( len ( lines ) - 1 , " * Member of ` " + module + " ` " ) <nl> + if len ( enums ) > 0 : <nl> + lines . insert ( len ( lines ) - 1 , " * Member enums : " + " , " . join ( [ ( " ` " + m + " ` " ) for m in enums ] ) ) <nl> + <nl> + return " \ n " . join ( lines ) <nl> + <nl> class ClassPropInfo ( ) : <nl> def __init__ ( self , decl ) : # [ f_ctype , f_name , ' ' , ' / RW ' ] <nl> self . ctype = decl [ 0 ] <nl> def __init__ ( self , decl , namespaces = [ ] ) : # [ ' class / struct cname ' , ' : base ' , [ mo <nl> self . base = ' ' <nl> self . is_base_class = True <nl> self . native_ptr_name = " nativePtr " <nl> + self . member_classes = [ ] # Only relevant for modules <nl> + self . member_enums = [ ] # Only relevant for modules <nl> if decl [ 1 ] : <nl> self . base = re . sub ( r " ^ . * : " , " " , decl [ 1 ] . split ( " , " ) [ 0 ] ) . strip ( ) . replace ( self . objc_name , " " ) <nl> if self . base : <nl> def generateObjcHeaderCode ( self , m , M , objcM ) : <nl> objcName = self . objc_name , <nl> cName = self . cname , <nl> imports = " \ n " . join ( self . getImports ( M ) ) , <nl> - docs = self . docstring , <nl> + docs = gen_class_doc ( self . docstring , M , self . member_classes , self . member_enums ) , <nl> base = self . base ) <nl> <nl> def generateObjcBodyCode ( self , m , M ) : <nl> def generateObjcBodyCode ( self , m , M ) : <nl> objcName = self . objc_name , <nl> cName = self . cname , <nl> imports = " \ n " . join ( self . getImports ( M ) ) , <nl> - docs = self . docstring , <nl> + docs = gen_class_doc ( self . docstring , M , self . member_classes , self . member_enums ) , <nl> base = self . base ) <nl> <nl> class ArgInfo ( ) : <nl> def clear ( self ) : <nl> self . skipped_func_list = [ ] <nl> self . def_args_hist = { } # { def_args_cnt : funcs_cnt } <nl> <nl> - def add_class ( self , decl ) : <nl> + def add_class ( self , decl , module ) : <nl> classinfo = ClassInfo ( decl , namespaces = self . namespaces ) <nl> if classinfo . name in class_ignore_list : <nl> logging . info ( ' ignored : % s ' , classinfo ) <nl> return <nl> + if classinfo . name ! = module : <nl> + self . classes [ module ] . member_classes . append ( classinfo . name ) <nl> name = classinfo . name <nl> if self . isWrapped ( name ) and not classinfo . base : <nl> logging . warning ( ' duplicated : % s ' , classinfo ) <nl> def add_const ( self , decl , scope = None , enumType = None ) : # [ " const cname " , val , [ ] <nl> ci . addConst ( constinfo ) <nl> logging . info ( ' ok : % s ' , constinfo ) <nl> <nl> - def add_enum ( self , decl , scope ) : # [ " enum cname " , " " , [ ] , [ ] ] <nl> + def add_enum ( self , decl ) : # [ " enum cname " , " " , [ ] , [ ] ] <nl> enumType = decl [ 0 ] . rsplit ( " " , 1 ) [ 1 ] <nl> if enumType . endswith ( " < unnamed > " ) : <nl> enumType = None <nl> def add_enum ( self , decl , scope ) : # [ " enum cname " , " " , [ ] , [ ] ] <nl> " objc_type " : objc_type , <nl> " is_enum " : True , <nl> " import_module " : import_module } <nl> + self . classes [ self . Module ] . member_enums . append ( objc_type ) <nl> + <nl> const_decls = decl [ 3 ] <nl> <nl> for decl in const_decls : <nl> - self . add_const ( decl , scope , enumType ) <nl> + self . add_const ( decl , self . Module , enumType ) <nl> <nl> def add_func ( self , decl ) : <nl> fi = FuncInfo ( decl , namespaces = self . namespaces ) <nl> def gen ( self , srcfiles , module , output_path , output_objc_path , common_headers ) : <nl> # TODO : support UMat versions of declarations ( implement UMat - wrapper for Java ) <nl> parser = hdr_parser . CppHeaderParser ( generate_umat_decls = False ) <nl> <nl> - self . add_class ( [ ' class ' + self . Module , ' ' , [ ] , [ ] ] ) # [ ' class / struct cname ' , ' : bases ' , [ modlist ] [ props ] ] <nl> + self . add_class ( [ ' class ' + self . Module , ' ' , [ ] , [ ] ] , self . Module ) # [ ' class / struct cname ' , ' : bases ' , [ modlist ] [ props ] ] <nl> <nl> # scan the headers and build more descriptive maps of classes , consts , functions <nl> includes = [ ] <nl> def gen ( self , srcfiles , module , output_path , output_objc_path , common_headers ) : <nl> logging . info ( " \ nmmm Incoming mmm \ n % s " , pformat ( decl [ : 5 ] , 4 ) ) # without docstring <nl> name = decl [ 0 ] <nl> if name . startswith ( " struct " ) or name . startswith ( " class " ) : <nl> - self . add_class ( decl ) <nl> + self . add_class ( decl , self . Module ) <nl> elif name . startswith ( " const " ) : <nl> self . add_const ( decl ) <nl> elif name . startswith ( " enum " ) : <nl> # enum <nl> - self . add_enum ( decl , self . Module ) <nl> + self . add_enum ( decl ) <nl> else : # function <nl> self . add_func ( decl ) <nl> <nl> def smartWrap ( self , ci , fullname ) : <nl> <nl> def finalize ( self , output_objc_path ) : <nl> opencv_header_file = os . path . join ( output_objc_path , framework_name + " . h " ) <nl> - self . save ( opencv_header_file , ' \ n ' . join ( [ ' # import " % s " ' % os . path . basename ( f ) for f in self . header_files if os . path . basename ( f ) ! = " CVObjcUtil . h " ] ) ) <nl> + self . save ( opencv_header_file , ' \ n ' . join ( [ ' # import " % s " ' % os . path . basename ( f ) for f in self . header_files ] ) ) <nl> cmakelist_template = read_contents ( os . path . join ( SCRIPT_DIR , ' templates / cmakelists . template ' ) ) <nl> cmakelist = Template ( cmakelist_template ) . substitute ( modules = " ; " . join ( modules ) , framework = framework_name ) <nl> self . save ( os . path . join ( dstdir , " CMakeLists . txt " ) , cmakelist ) <nl> mkdir_p ( " . / framework_build " ) <nl> mkdir_p ( " . / test_build " ) <nl> mkdir_p ( " . / doc_build " ) <nl> - copyfile ( os . path . join ( SCRIPT_DIR , ' . . / doc / README . md ' ) , " . / doc_build / README . md " ) <nl> + with open ( os . path . join ( SCRIPT_DIR , ' . . / doc / README . md ' ) ) as readme_in : <nl> + readme_body = readme_in . read ( ) <nl> + readme_body + = " \ n \ n \ n # # Modules \ n \ n " + " , " . join ( [ " ` " + m . capitalize ( ) + " ` " for m in modules ] ) <nl> + with open ( " . / doc_build / README . md " , " w " ) as readme_out : <nl> + readme_out . write ( readme_body ) <nl> if framework_name ! = " OpenCV " : <nl> for dirname , dirs , files in os . walk ( os . path . join ( testdir , " test " ) ) : <nl> for filename in files : <nl> def sanitize_documentation_string ( doc , type ) : <nl> generator = ObjectiveCWrapperGenerator ( ) <nl> <nl> gen_dict_files = [ ] <nl> - modules = [ ] <nl> framework_name = args . framework <nl> <nl> print ( " Objective - C : Processing OpenCV modules : % d " % len ( config [ ' modules ' ] ) ) <nl> mmm a / platforms / ios / build_framework . py <nl> ppp b / platforms / ios / build_framework . py <nl> def makeFramework ( self , outdir , builddirs ) : <nl> doc_path = os . path . join ( builddirs [ 0 ] , " modules " , " objc " , " doc_build " , " docs " ) <nl> if os . path . exists ( doc_path ) : <nl> shutil . copytree ( doc_path , os . path . join ( outdir , " docs " ) ) <nl> + shutil . copyfile ( os . path . join ( self . opencv , " doc " , " opencv . ico " ) , os . path . join ( outdir , " docs " , " favicon . ico " ) ) <nl> <nl> def copy_samples ( self , outdir ) : <nl> return <nl>
Merge pull request from komakai : documentation - improvements
opencv/opencv
af9ee90091a67bad24f8f7f188e6d8fbc242adbc
2020-07-15T18:42:05Z
mmm a / src / core / surface / server . c <nl> ppp b / src / core / surface / server . c <nl> static void request_matcher_zombify_all_pending_calls ( <nl> } <nl> } <nl> <nl> + static void request_matcher_kill_requests ( grpc_server * server , <nl> + request_matcher * rm ) { <nl> + int request_id ; <nl> + while ( ( request_id = gpr_stack_lockfree_pop ( rm - > requests ) ) ! = - 1 ) { <nl> + fail_call ( server , & server - > requested_calls [ request_id ] ) ; <nl> + } <nl> + } <nl> + <nl> / * <nl> * server proper <nl> * / <nl> static int num_channels ( grpc_server * server ) { <nl> return n ; <nl> } <nl> <nl> + static void kill_pending_work_locked ( grpc_server * server ) { <nl> + registered_method * rm ; <nl> + request_matcher_kill_requests ( server , & server - > unregistered_request_matcher ) ; <nl> + request_matcher_zombify_all_pending_calls ( <nl> + & server - > unregistered_request_matcher ) ; <nl> + for ( rm = server - > registered_methods ; rm ; rm = rm - > next ) { <nl> + request_matcher_kill_requests ( server , & rm - > request_matcher ) ; <nl> + request_matcher_zombify_all_pending_calls ( & rm - > request_matcher ) ; <nl> + } <nl> + } <nl> + <nl> static void maybe_finish_shutdown ( grpc_server * server ) { <nl> size_t i ; <nl> if ( ! gpr_atm_acq_load ( & server - > shutdown_flag ) | | server - > shutdown_published ) { <nl> return ; <nl> } <nl> <nl> + kill_pending_work_locked ( server ) ; <nl> + <nl> if ( server - > root_channel_data . next ! = & server - > root_channel_data | | <nl> server - > listeners_destroyed < num_listeners ( server ) ) { <nl> if ( gpr_time_cmp ( gpr_time_sub ( gpr_now ( GPR_CLOCK_REALTIME ) , <nl> void grpc_server_setup_transport ( grpc_server * s , grpc_transport * transport , <nl> grpc_transport_perform_op ( transport , & op ) ; <nl> } <nl> <nl> - typedef struct { <nl> - requested_call * * requests ; <nl> - size_t count ; <nl> - size_t capacity ; <nl> - } request_killer ; <nl> - <nl> - static void request_killer_init ( request_killer * rk ) { <nl> - memset ( rk , 0 , sizeof ( * rk ) ) ; <nl> - } <nl> - <nl> - static void request_killer_add ( request_killer * rk , requested_call * rc ) { <nl> - if ( rk - > capacity = = rk - > count ) { <nl> - rk - > capacity = GPR_MAX ( 8 , rk - > capacity * 2 ) ; <nl> - rk - > requests = <nl> - gpr_realloc ( rk - > requests , rk - > capacity * sizeof ( * rk - > requests ) ) ; <nl> - } <nl> - rk - > requests [ rk - > count + + ] = rc ; <nl> - } <nl> - <nl> - static void request_killer_add_request_matcher ( request_killer * rk , <nl> - grpc_server * server , <nl> - request_matcher * rm ) { <nl> - int request_id ; <nl> - while ( ( request_id = gpr_stack_lockfree_pop ( rm - > requests ) ) ! = - 1 ) { <nl> - request_killer_add ( rk , & server - > requested_calls [ request_id ] ) ; <nl> - } <nl> - } <nl> - <nl> - static void request_killer_run ( request_killer * rk , grpc_server * server ) { <nl> - size_t i ; <nl> - for ( i = 0 ; i < rk - > count ; i + + ) { <nl> - fail_call ( server , rk - > requests [ i ] ) ; <nl> - } <nl> - gpr_free ( rk - > requests ) ; <nl> - } <nl> - <nl> void grpc_server_shutdown_and_notify ( grpc_server * server , <nl> grpc_completion_queue * cq , void * tag ) { <nl> listener * l ; <nl> - registered_method * rm ; <nl> shutdown_tag * sdt ; <nl> channel_broadcaster broadcaster ; <nl> - request_killer reqkill ; <nl> <nl> GRPC_SERVER_LOG_SHUTDOWN ( GPR_INFO , server , cq , tag ) ; <nl> <nl> void grpc_server_shutdown_and_notify ( grpc_server * server , <nl> server - > last_shutdown_message_time = gpr_now ( GPR_CLOCK_REALTIME ) ; <nl> <nl> channel_broadcaster_init ( server , & broadcaster ) ; <nl> - request_killer_init ( & reqkill ) ; <nl> <nl> / * collect all unregistered then registered calls * / <nl> gpr_mu_lock ( & server - > mu_call ) ; <nl> - request_killer_add_request_matcher ( & reqkill , server , <nl> - & server - > unregistered_request_matcher ) ; <nl> - request_matcher_zombify_all_pending_calls ( <nl> - & server - > unregistered_request_matcher ) ; <nl> - for ( rm = server - > registered_methods ; rm ; rm = rm - > next ) { <nl> - request_killer_add_request_matcher ( & reqkill , server , & rm - > request_matcher ) ; <nl> - request_matcher_zombify_all_pending_calls ( & rm - > request_matcher ) ; <nl> - } <nl> + kill_pending_work_locked ( server ) ; <nl> gpr_mu_unlock ( & server - > mu_call ) ; <nl> <nl> gpr_atm_rel_store ( & server - > shutdown_flag , 1 ) ; <nl> maybe_finish_shutdown ( server ) ; <nl> gpr_mu_unlock ( & server - > mu_global ) ; <nl> <nl> - / * terminate all the requested calls * / <nl> - request_killer_run ( & reqkill , server ) ; <nl> - <nl> / * Shutdown listeners * / <nl> for ( l = server - > listeners ; l ; l = l - > next ) { <nl> l - > destroy ( server , l - > arg ) ; <nl> static void done_request_event ( void * req , grpc_cq_completion * c ) { <nl> gpr_free ( req ) ; <nl> } <nl> <nl> + if ( gpr_atm_acq_load ( & server - > shutdown_flag ) ) { <nl> + gpr_mu_lock ( & server - > mu_global ) ; <nl> + maybe_finish_shutdown ( server ) ; <nl> + gpr_mu_unlock ( & server - > mu_global ) ; <nl> + } <nl> + <nl> server_unref ( server ) ; <nl> } <nl> <nl>
More aggressively kill pending work
grpc/grpc
1191e218f705055f76d7344ad3acbef241d2f378
2015-07-30T21:49:02Z
mmm a / tensorflow / compiler / mlir / g3doc / _index . yaml <nl> ppp b / tensorflow / compiler / mlir / g3doc / _index . yaml <nl> <nl> book_path : / mlir / _book . yaml <nl> project_path : / mlir / _project . yaml <nl> - description : < ! - - no description - - > <nl> + description : An intermediate representation and compiler framework , MLIR unifies the <nl> + infrastructure for high - performance ML models in TensorFlow . <nl> landing_page : <nl> custom_css_path : / site - assets / css / style . css <nl> rows : <nl>
Updates metadata content
tensorflow/tensorflow
e27bb014ea53a13a55d26c703eeea30a772fc4f3
2020-04-03T22:21:31Z
mmm a / torch / nn / modules / loss . py <nl> ppp b / torch / nn / modules / loss . py <nl> class BCELoss ( _WeightedLoss ) : <nl> between 0 and 1 . <nl> <nl> Args : <nl> + weight ( Tensor , optional ) : a manual rescaling weight given to the loss <nl> + of each batch element . If given , has to be a Tensor of size <nl> + " nbatch " . <nl> size_average ( bool , optional ) : By default , the losses are averaged <nl> over observations for each minibatch . However , if the field <nl> size_average is set to False , the losses are instead summed for <nl> class BCEWithLogitsLoss ( Module ) : <nl> between 0 and 1 . <nl> <nl> Args : <nl> + weight ( Tensor , optional ) : a manual rescaling weight given to the loss <nl> + of each batch element . If given , has to be a Tensor of size <nl> + " nbatch " . <nl> size_average ( bool , optional ) : By default , the losses are averaged <nl> over observations for each minibatch . However , if the field <nl> size_average is set to False , the losses are instead summed for <nl>
Document weights argument format for BCELoss ( )
pytorch/pytorch
9a020ea2ff7712a5a1154150a72b6bb8b7d69b68
2017-11-07T19:19:46Z
mmm a / src / mongo / util / shared_buffer . h <nl> ppp b / src / mongo / util / shared_buffer . h <nl> <nl> # include < boost / intrusive_ptr . hpp > <nl> <nl> # include " mongo / platform / atomic_word . h " <nl> + # include " mongo / util / allocator . h " <nl> <nl> namespace mongo { <nl> <nl> class SharedBuffer { <nl> } <nl> <nl> static SharedBuffer allocate ( size_t bytes ) { <nl> - return takeOwnership ( static_cast < char * > ( malloc ( sizeof ( Holder ) + bytes ) ) ) ; <nl> + return takeOwnership ( static_cast < char * > ( mongoMalloc ( sizeof ( Holder ) + bytes ) ) ) ; <nl> } <nl> <nl> / * * <nl>
SERVER - 20204 : Use mongoMalloc to allocate memory
mongodb/mongo
0a6c20bdc7128d1f13e967a7cc6219b1dfc38b6b
2015-09-01T22:29:09Z
mmm a / cores / esp8266 / umm_malloc / umm_local . h <nl> ppp b / cores / esp8266 / umm_malloc / umm_local . h <nl> void ICACHE_FLASH_ATTR print_stats ( int force ) ; <nl> <nl> <nl> int ICACHE_FLASH_ATTR umm_info_safe_printf_P ( const char * fmt , . . . ) __attribute__ ( ( format ( printf , 1 , 2 ) ) ) ; <nl> - # define UMM_INFO_PRINTF ( fmt , . . . ) umm_info_safe_printf_P ( PSTR ( fmt ) , # # __VA_ARGS__ ) <nl> + # define UMM_INFO_PRINTF ( fmt , . . . ) umm_info_safe_printf_P ( PSTR4 ( fmt ) , # # __VA_ARGS__ ) <nl> + / / use PSTR4 ( ) instead of PSTR ( ) to ensure 4 - bytes alignment in Flash , whatever the default alignment of PSTR_ALIGN <nl> <nl> <nl> # endif <nl> mmm a / tools / sdk / libc / xtensa - lx106 - elf / include / sys / pgmspace . h <nl> ppp b / tools / sdk / libc / xtensa - lx106 - elf / include / sys / pgmspace . h <nl> extern " C " { <nl> # define PGM_VOID_P const void * <nl> # endif <nl> <nl> - / / PSTR ( ) macro modified to start on a 32 - bit boundary . This adds on average <nl> - / / 1 . 5 bytes / string , but in return memcpy_P and strcpy_P will work 4 ~ 8x faster <nl> - # ifndef PSTR <nl> + # ifndef PSTR_ALIGN <nl> + / / PSTR ( ) macro starts by default on a 32 - bit boundary . This adds on average <nl> + / / 1 . 5 bytes / string , but in return memcpy_P and strcpy_P will work 4 ~ 8x faster <nl> + / / Allow users to override the alignment with PSTR_ALIGN <nl> + # define PSTR_ALIGN 4 <nl> + # endif <nl> + # ifndef PSTRN <nl> + / / Multi - alignment variant of PSTR , n controls the alignment and should typically be 1 or 4 <nl> / / Adapted from AVR - specific code at https : / / forum . arduino . cc / index . php ? topic = 194603 . 0 <nl> / / Uses C attribute section instead of ASM block to allow for C language string concatenation ( " x " " y " = = = " xy " ) <nl> - # define PSTR ( s ) ( __extension__ ( { static const char __c [ ] __attribute__ ( ( __aligned__ ( 4 ) ) ) __attribute__ ( ( section ( " \ " . irom0 . pstr . " __FILE__ " . " __STRINGIZE ( __LINE__ ) " . " __STRINGIZE ( __COUNTER__ ) " \ " , \ " aSM \ " , @ progbits , 1 # " ) ) ) = ( s ) ; & __c [ 0 ] ; } ) ) <nl> + # define PSTRN ( s , n ) ( __extension__ ( { static const char __c [ ] __attribute__ ( ( __aligned__ ( n ) ) ) __attribute__ ( ( section ( " \ " . irom0 . pstr . " __FILE__ " . " __STRINGIZE ( __LINE__ ) " . " __STRINGIZE ( __COUNTER__ ) " \ " , \ " aSM \ " , @ progbits , 1 # " ) ) ) = ( s ) ; & __c [ 0 ] ; } ) ) <nl> + # endif <nl> + # ifndef PSTR <nl> + / / PSTR ( ) uses the default alignment defined by PSTR_ALIGN <nl> + # define PSTR ( s ) PSTRN ( s , PSTR_ALIGN ) <nl> + # endif <nl> + # ifndef PSTR4 <nl> + / / PSTR4 ( ) enforces 4 - bytes alignment whatever the value of PSTR_ALIGN <nl> + / / as required by functions like ets_strlen ( ) or ets_memcpy ( ) <nl> + # define PSTR4 ( s ) PSTRN ( s , 4 ) <nl> # endif <nl> <nl> / / Flash memory must be read using 32 bit aligned addresses else a processor <nl>
Allow non - aligned PSTR ( ) ( )
esp8266/Arduino
3e4d7c76c42f95933695065737e674c9234ec464
2020-05-18T19:21:50Z
mmm a / src / init . cpp <nl> ppp b / src / init . cpp <nl> bool AppInitMain ( ) <nl> return InitError ( _ ( " Unable to start HTTP server . See debug log for details . " ) ) ; <nl> } <nl> <nl> - int64_t nStart ; <nl> - <nl> / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Step 5 : verify wallet database integrity <nl> if ( ! g_wallet_init_interface . Verify ( ) ) return false ; <nl> <nl> bool AppInitMain ( ) <nl> <nl> LOCK ( cs_main ) ; <nl> <nl> - nStart = GetTimeMillis ( ) ; <nl> do { <nl> + const int64_t load_block_index_start_time = GetTimeMillis ( ) ; <nl> try { <nl> UnloadBlockIndex ( ) ; <nl> pcoinsTip . reset ( ) ; <nl> bool AppInitMain ( ) <nl> } <nl> <nl> fLoaded = true ; <nl> + LogPrintf ( " block index % 15dms \ n " , GetTimeMillis ( ) - load_block_index_start_time ) ; <nl> } while ( false ) ; <nl> <nl> if ( ! fLoaded & & ! fRequestShutdown ) { <nl> bool AppInitMain ( ) <nl> LogPrintf ( " Shutdown requested . Exiting . \ n " ) ; <nl> return false ; <nl> } <nl> - if ( fLoaded ) { <nl> - LogPrintf ( " block index % 15dms \ n " , GetTimeMillis ( ) - nStart ) ; <nl> - } <nl> <nl> fs : : path est_path = GetDataDir ( ) / FEE_ESTIMATES_FILENAME ; <nl> CAutoFile est_filein ( fsbridge : : fopen ( est_path , " rb " ) , SER_DISK , CLIENT_VERSION ) ; <nl>
logging : avoid nStart may be used uninitialized in AppInitMain warning
bitcoin/bitcoin
2dcd7b4ec76dc23bf901f4517703758c3fa377ba
2018-06-30T11:25:25Z
mmm a / tests / test_core . py <nl> ppp b / tests / test_core . py <nl> def test_pthread_create_proxy ( self ) : <nl> self . emcc_args + = [ ' - DALLOW_SYNC ' ] <nl> self . do_run_in_out_file_test ( ' tests ' , ' core ' , ' pthread ' , ' create . cpp ' ) <nl> <nl> - print ( ' with embind and stack overflow checks ( see # 12356 ) ' ) <nl> + @ node_pthreads <nl> + def test_pthread_create_embind_stack_check ( self ) : <nl> + # embind should work with stack overflow checks ( see # 12356 ) <nl> self . set_setting ( ' STACK_OVERFLOW_CHECK ' , 2 ) <nl> self . emcc_args + = [ ' - - bind ' ] <nl> - test ( ) <nl> + self . do_run_in_out_file_test ( ' tests ' , ' core ' , ' pthread ' , ' create . cpp ' ) <nl> <nl> @ node_pthreads <nl> def test_pthread_exceptions ( self ) : <nl>
Fix a merge conflict with landed pthreads testing PRs ( )
emscripten-core/emscripten
4bb879497edb06ba4f587134abc5da3688962b29
2020-10-06T18:51:08Z
mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> binary_linux_build : & binary_linux_build <nl> source " / builder / upgrade_gcc_abi . sh " <nl> <nl> # Env variables are not persisted into the next step <nl> - echo " export PATH = $ PATH " > / env <nl> - echo " export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH " > / env <nl> + echo " export PATH = $ PATH " > > / env <nl> + echo " export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH " > > / env <nl> else <nl> echo " Not upgrading gcc version " <nl> fi <nl> mmm a / . circleci / verbatim - sources / linux - binary - build - defaults . yml <nl> ppp b / . circleci / verbatim - sources / linux - binary - build - defaults . yml <nl> binary_linux_build : & binary_linux_build <nl> source " / builder / upgrade_gcc_abi . sh " <nl> <nl> # Env variables are not persisted into the next step <nl> - echo " export PATH = $ PATH " > / env <nl> - echo " export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH " > / env <nl> + echo " export PATH = $ PATH " > > / env <nl> + echo " export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH " > > / env <nl> else <nl> echo " Not upgrading gcc version " <nl> fi <nl>
Fix devtoolset7 binary builds ( )
pytorch/pytorch
abbfb7dd2326a56b4c8c32f418cbe6f78826bbb8
2019-04-30T00:21:03Z
mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and assign_ p ur env e1 ty2 = <nl> | _ - > assign_simple p ur env e1 ty2 <nl> end <nl> <nl> - | _ , Class_get _ <nl> - | _ , Obj_get _ - > <nl> + | pobj , Obj_get ( obj , ( pm , Id ( _ , member_name as m ) ) , nullflavor ) - > <nl> let lenv = env . Env . lenv in <nl> let no_fakes = LEnv . env_with_empty_fakes env in <nl> ( * In this section , we check that the assignment is compatible with <nl> and assign_ p ur env e1 ty2 = <nl> * check that the assignment is compatible with the type of <nl> * the member . <nl> * ) <nl> + let nullsafe = match nullflavor with <nl> + | OG_nullthrows - > None <nl> + | OG_nullsafe - > Some pobj in <nl> + let env , tobj , obj_ty = expr ~ accept_using_var : true no_fakes obj in <nl> + let env = save_and_merge_next_in_catch env in <nl> + let env , ty2 ' = Env . unbind env ty2 in <nl> + let k ( env , member_ty , vis ) = <nl> + let env = Type . sub_type p ur env ty2 ' member_ty in <nl> + env , member_ty , vis in <nl> + let env , result = <nl> + obj_get ~ is_method : false ~ nullsafe ~ valkind : ` lvalue <nl> + env obj_ty ( CIexpr e1 ) m k in <nl> + let te1 = <nl> + T . make_typed_expr pobj result <nl> + ( T . Obj_get <nl> + ( tobj , T . make_typed_expr pm result ( T . Id m ) , nullflavor ) ) in <nl> + let env = { env with Env . lenv = lenv } in <nl> + begin match obj with <nl> + | _ , This - > <nl> + let env , local = Env . FakeMembers . make p env obj member_name in <nl> + let env , exp_real_type = Env . expand_type env result in <nl> + Typing_suggest . save_member member_name env exp_real_type ty2 ; <nl> + let env , ty = set_valid_rvalue p env local ty2 in <nl> + env , te1 , ty <nl> + | _ , Lvar _ - > <nl> + let env , local = Env . FakeMembers . make p env obj member_name in <nl> + let env , ty = set_valid_rvalue p env local ty2 in <nl> + env , te1 , ty <nl> + | _ - > env , te1 , ty2 <nl> + end <nl> + | _ , Obj_get _ - > <nl> + let lenv = env . Env . lenv in <nl> + let no_fakes = LEnv . env_with_empty_fakes env in <nl> + let env , te1 , real_type = lvalue no_fakes e1 in <nl> + let env , exp_real_type = Env . expand_type env real_type in <nl> + let env = { env with Env . lenv = lenv } in <nl> + let env , ty2 ' = Env . unbind env ty2 in <nl> + let env = Type . sub_type p ur env ty2 ' exp_real_type in <nl> + env , te1 , ty2 <nl> + | _ , Class_get ( ( ( ) , x ) , ( _ , y ) ) - > <nl> + let lenv = env . Env . lenv in <nl> + let no_fakes = LEnv . env_with_empty_fakes env in <nl> let env , te1 , real_type = lvalue no_fakes e1 in <nl> let env , exp_real_type = Env . expand_type env real_type in <nl> let env = { env with Env . lenv = lenv } in <nl> and assign_ p ur env e1 ty2 = <nl> let env = List . fold_left real_type_list ~ f : begin fun env real_type - > <nl> Type . sub_type p ur env ety2 real_type <nl> end ~ init : env in <nl> - ( match e1 with <nl> - | _ , Obj_get ( ( _ , This | _ , Lvar _ as obj ) , <nl> - ( _ , Id ( _ , member_name ) ) , <nl> - _ ) - > <nl> - let env , local = Env . FakeMembers . make p env obj member_name in <nl> - let ( ) = ( match obj with <nl> - | _ , This - > <nl> - Typing_suggest . save_member member_name env exp_real_type ty2 <nl> - | _ - > ( ) <nl> - ) in <nl> - let env , ty = set_valid_rvalue p env local ty2 in <nl> - env , te1 , ty <nl> - | _ , Class_get ( ( ( ) , x ) , ( _ , y ) ) - > <nl> - let env , local = Env . FakeMembers . make_static p env x y in <nl> - let env , ty3 = set_valid_rvalue p env local ty2 in <nl> - ( match x with <nl> - | CIself <nl> - | CIstatic - > <nl> - Typing_suggest . save_member y env exp_real_type ty2 ; <nl> - | _ - > ( ) ) ; <nl> - env , te1 , ty3 <nl> - | _ - > env , te1 , ty2 <nl> - ) <nl> + let env , local = Env . FakeMembers . make_static p env x y in <nl> + let env , ty3 = set_valid_rvalue p env local ty2 in <nl> + ( match x with <nl> + | CIself <nl> + | CIstatic - > <nl> + Typing_suggest . save_member y env exp_real_type ty2 ; <nl> + | _ - > ( ) ) ; <nl> + env , te1 , ty3 <nl> | _ , Array_get ( ( _ , Lvar ( _ , lvar ) ) as shape , ( ( Some _ ) as e2 ) ) - > <nl> let access_type = Typing_arrays . static_array_access env e2 in <nl> ( * In the case of an assignment of the form $ x [ ' new_field ' ] = . . . ; <nl> and member_not_found pos ~ is_method class_ member_name r = <nl> | Some ( def_pos , v ) - > <nl> error ( ` did_you_mean ( def_pos , v ) ) <nl> <nl> + ( * Look up the type of the property id in the type ty1 of the receiver and <nl> + * use the function k to postprocess the result . <nl> + * <nl> + * Essentially , if ty1 is a concrete type , e . g . , class C , then k is applied <nl> + * to the type of the property id in C ; and if ty1 is an unresolved type , <nl> + * e . g . , a union of classes ( C1 | . . . | Cn ) , then k is applied to the type <nl> + * of the property id in each Ci and the results are collected into an <nl> + * unresolved type . <nl> + * <nl> + * The extra flexibility offered by the functional argument k is used in two <nl> + * places : <nl> + * <nl> + * ( 1 ) when type - checking method calls : if the receiver has an unresolved <nl> + * type , then we need to type - check the method call with each possible <nl> + * receiver type and collect the results into an unresolved type ; <nl> + * <nl> + * ( 2 ) when type - checking assignments to properties : if the receiver has <nl> + * an unresolved type , then we need to check that the right hand side <nl> + * value can be assigned to the property id for each of the possible types <nl> + * of the receiver . <nl> + * ) <nl> and obj_get ~ is_method ~ nullsafe ? ( valkind = ` other ) ? ( explicit_tparams = [ ] ) <nl> ? ( pos_params : expr list option ) env ty1 cid id k = <nl> let env , method_ , _ = <nl> new file mode 100644 <nl> index 00000000000 . . 3dee9ee90d6 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / assign_unresolved . php <nl> <nl> + < ? hh / / strict <nl> + <nl> + class Ref < T > { <nl> + public function __construct ( public T $ value ) { } <nl> + } <nl> + <nl> + function test ( bool $ b ) : arraykey { <nl> + if ( $ b ) { <nl> + $ x = 42 ; <nl> + } else { <nl> + $ x = ' foo ' ; <nl> + } <nl> + $ r = new Ref ( 3 . 14 ) ; <nl> + $ r - > value = $ x ; <nl> + return $ x ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 4269126fceb <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / assign_unresolved . php . exp <nl> @ @ - 0 , 0 + 1 @ @ <nl> + No errors <nl> new file mode 100644 <nl> index 00000000000 . . 7df2795efe9 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / assign_unresolved_class_get . php <nl> <nl> + < ? hh / / strict <nl> + / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> + <nl> + class A { <nl> + public static num $ x = 3 . 14 ; <nl> + } <nl> + <nl> + class B { <nl> + public static arraykey $ x = ' foo ' ; <nl> + } <nl> + <nl> + function test ( bool $ b ) : void { <nl> + if ( $ b ) { <nl> + $ c = A : : class ; <nl> + } else { <nl> + $ c = B : : class ; <nl> + } <nl> + $ c : : $ x = 42 ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 4269126fceb <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / assign_unresolved_class_get . php . exp <nl> @ @ - 0 , 0 + 1 @ @ <nl> + No errors <nl> new file mode 100644 <nl> index 00000000000 . . 0837c6621c3 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / assign_unresolved_obj_get . php <nl> <nl> + < ? hh / / strict <nl> + / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> + <nl> + class C < T > { <nl> + public function __construct ( public T $ value ) { } <nl> + } <nl> + <nl> + function test ( bool $ b , int $ x , float $ y , num $ z ) : void { <nl> + if ( $ b ) { <nl> + $ xory = $ x ; <nl> + } else { <nl> + $ xory = $ y ; <nl> + } <nl> + $ c = new C ( $ xory ) ; <nl> + $ c - > value = $ z ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 4269126fceb <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / assign_unresolved_obj_get . php . exp <nl> @ @ - 0 , 0 + 1 @ @ <nl> + No errors <nl> mmm a / hphp / hack / test / typecheck / class_prop_as_this . php . exp <nl> ppp b / hphp / hack / test / typecheck / class_prop_as_this . php . exp <nl> File " class_prop_as_this . php " , line 17 , characters 5 - 19 : <nl> Invalid assignment ( Typing [ 4110 ] ) <nl> File " class_prop_as_this . php " , line 9 , characters 24 - 24 : <nl> This is the expression dependent type < expr # 1 > <nl> - File " class_prop_as_this . php " , line 17 , characters 5 - 7 : <nl> + File " class_prop_as_this . php " , line 17 , characters 5 - 10 : <nl> where ' < expr # 1 > ' is a reference to this expression <nl> File " class_prop_as_this . php " , line 9 , characters 31 - 31 : <nl> It is incompatible with an object of type C <nl> mmm a / hphp / hack / test / typecheck / this_member . php . exp <nl> ppp b / hphp / hack / test / typecheck / this_member . php . exp <nl> File " this_member . php " , line 16 , characters 5 - 20 : <nl> Invalid assignment ( Typing [ 4110 ] ) <nl> File " this_member . php " , line 15 , characters 24 - 24 : <nl> This is the expression dependent type < expr # 1 > <nl> - File " this_member . php " , line 16 , characters 5 - 6 : <nl> + File " this_member . php " , line 16 , characters 5 - 9 : <nl> where ' < expr # 1 > ' is a reference to this expression <nl> File " this_member . php " , line 13 , characters 38 - 41 : <nl> It is incompatible with the expression dependent type < static > <nl>
Improve typing of assignments to properties of unresolved objects , v2
facebook/hhvm
ab853726889f1ea9c65b010f880a1468efe8b596
2018-07-23T12:12:18Z
mmm a / config . m4 <nl> ppp b / config . m4 <nl> if test " $ PHP_SWOOLE " ! = " no " ; then <nl> src / core / string . c \ <nl> src / core / array . c \ <nl> src / core / socket . c \ <nl> + src / core / list . c \ <nl> src / memory / ShareMemory . c \ <nl> src / memory / MemoryGlobal . c \ <nl> src / memory / RingBuffer . c \ <nl> if test " $ PHP_SWOOLE " ! = " no " ; then <nl> src / pipe / PipeBase . c \ <nl> src / pipe / PipeEventfd . c \ <nl> src / pipe / PipeUnsock . c \ <nl> - src / queue / Msg . c \ <nl> src / lock / Semaphore . c \ <nl> src / lock / Mutex . c \ <nl> src / lock / RWLock . c \ <nl> if test " $ PHP_SWOOLE " ! = " no " ; then <nl> src / os / base . c \ <nl> src / os / linux_aio . c \ <nl> src / os / gcc_aio . c \ <nl> + src / os / msg_queue . c \ <nl> src / os / sendfile . c \ <nl> src / os / signal . c \ <nl> src / os / timer . c \ <nl> mmm a / include / swoole . h <nl> ppp b / include / swoole . h <nl> typedef struct _swString <nl> char * str ; <nl> } swString ; <nl> <nl> + typedef struct _swLinkedList_node <nl> + { <nl> + struct _swLinkedList_node * prev ; <nl> + struct _swLinkedList_node * next ; <nl> + void * data ; <nl> + } swLinkedList_node ; <nl> + <nl> + typedef struct <nl> + { <nl> + uint32_t num ; <nl> + swLinkedList_node * head ; <nl> + swLinkedList_node * tail ; <nl> + } swLinkedList ; <nl> + <nl> + typedef void ( * swDestructor ) ( void * data ) ; <nl> + <nl> typedef struct <nl> { <nl> union <nl> typedef struct _swQueue_Data <nl> char mdata [ sizeof ( swEventData ) ] ; / * text of the message * / <nl> } swQueue_data ; <nl> <nl> - typedef struct _swQueue <nl> + typedef struct _swMsgQueue <nl> { <nl> - void * object ; <nl> int blocking ; <nl> - int ( * in ) ( struct _swQueue * , swQueue_data * in , int data_length ) ; <nl> - int ( * out ) ( struct _swQueue * , swQueue_data * out , int buffer_length ) ; <nl> - void ( * free ) ( struct _swQueue * ) ; <nl> - int ( * notify ) ( struct _swQueue * ) ; <nl> - int ( * wait ) ( struct _swQueue * ) ; <nl> - } swQueue ; <nl> + int msg_id ; <nl> + int ipc_wait ; <nl> + uint8_t delete ; <nl> + long type ; <nl> + } swMsgQueue ; <nl> <nl> - int swQueueMsg_create ( swQueue * p , int wait , key_t msg_key , long type ) ; <nl> - void swQueueMsg_set_blocking ( swQueue * p , uint8_t blocking ) ; <nl> - void swQueueMsg_set_destory ( swQueue * p , uint8_t destory ) ; <nl> + int swMsgQueue_create ( swMsgQueue * q , int wait , key_t msg_key , long type ) ; <nl> + int swMsgQueue_push ( swMsgQueue * p , swQueue_data * in , int data_length ) ; <nl> + int swMsgQueue_pop ( swMsgQueue * p , swQueue_data * out , int buffer_length ) ; <nl> + void swMsgQueue_free ( swMsgQueue * p ) ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmLockmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> enum SW_LOCKS <nl> struct _swWorker <nl> <nl> swMemoryPool * pool_output ; <nl> <nl> - swQueue * queue ; <nl> + swMsgQueue * queue ; <nl> <nl> / * * <nl> * redirect stdout to pipe_master <nl> struct _swWorker <nl> * / <nl> sw_atomic_t tasking_num ; <nl> <nl> - <nl> - <nl> / * * <nl> * worker id <nl> * / <nl> struct _swProcessPool <nl> swPipe * pipes ; <nl> swHashMap * map ; <nl> swReactor * reactor ; <nl> - swQueue * queue ; <nl> + swMsgQueue * queue ; <nl> <nl> void * ptr ; <nl> void * ptr2 ; <nl> int swChannel_wait ( swChannel * object ) ; <nl> int swChannel_notify ( swChannel * object ) ; <nl> void swChannel_free ( swChannel * object ) ; <nl> <nl> + swLinkedList * swLinkedList_new ( void ) ; <nl> + int swLinkedList_append ( swLinkedList * ll , void * data ) ; <nl> + int swLinkedList_prepend ( swLinkedList * ll , void * data ) ; <nl> + void * swLinkedList_pop ( swLinkedList * ll ) ; <nl> + void * swLinkedList_shift ( swLinkedList * ll ) ; <nl> + void swLinkedList_free ( swLinkedList * ll , swDestructor dtor ) ; <nl> / * mmmmmmmmmmmmmmmmmmmmmmmmmmm - Thread Poolmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - * / <nl> enum swThread_type <nl> { <nl> mmm a / include / tests . h <nl> ppp b / include / tests . h <nl> swUnitTest ( http_test1 ) ; <nl> swUnitTest ( http_test2 ) ; <nl> <nl> swUnitTest ( heap_test1 ) ; <nl> - <nl> + swUnitTest ( linkedlist_test ) ; <nl> swUnitTest ( rbtree_test ) ; <nl> void p_str ( void * str ) ; <nl> <nl> mmm a / package . xml <nl> ppp b / package . xml <nl> <nl> < file role = " src " name = " Channel . c " / > <nl> < file role = " src " name = " string . c " / > <nl> < file role = " src " name = " array . c " / > <nl> + < file role = " src " name = " list . c " / > <nl> < / dir > <nl> < dir name = " memory " > <nl> < file role = " src " name = " ShareMemory . c " / > <nl> <nl> < file role = " src " name = " PipeEventfd . c " / > <nl> < file role = " src " name = " PipeUnsock . c " / > <nl> < / dir > <nl> - < dir name = " queue " > <nl> - < file role = " src " name = " Msg . c " / > <nl> - < / dir > <nl> < dir name = " lock " > <nl> < file role = " src " name = " Semaphore . c " / > <nl> < file role = " src " name = " Mutex . c " / > <nl> <nl> < file role = " src " name = " base . c " / > <nl> < file role = " src " name = " gcc_aio . c " / > <nl> < file role = " src " name = " linux_aio . c " / > <nl> + < file role = " src " name = " msg_queue . c " / > <nl> < file role = " src " name = " sendfile . c " / > <nl> < file role = " src " name = " signal . c " / > <nl> < file role = " src " name = " timer . c " / > <nl> new file mode 100644 <nl> index 0000000000 . . 63e11396ca <nl> mmm / dev / null <nl> ppp b / src / core / list . c <nl> <nl> + / * <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Swoole | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | This source file is subject to version 2 . 0 of the Apache license , | <nl> + | that is bundled with this package in the file LICENSE , and is | <nl> + | available through the world - wide - web at the following url : | <nl> + | http : / / www . apache . org / licenses / LICENSE - 2 . 0 . html | <nl> + | If you did not receive a copy of the Apache2 . 0 license and are unable | <nl> + | to obtain it through the world - wide - web , please send a note to | <nl> + | license @ swoole . com so we can mail you a copy immediately . | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Author : Tianfeng Han < mikan . tenny @ gmail . com > | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + * / <nl> + <nl> + # include " swoole . h " <nl> + <nl> + swLinkedList * swLinkedList_new ( void ) <nl> + { <nl> + swLinkedList * q = sw_malloc ( sizeof ( swLinkedList ) ) ; <nl> + if ( q = = NULL ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed . " , sizeof ( swLinkedList ) ) ; <nl> + return NULL ; <nl> + } <nl> + bzero ( q , sizeof ( swLinkedList ) ) ; <nl> + return q ; <nl> + } <nl> + <nl> + int swLinkedList_append ( swLinkedList * ll , void * data ) <nl> + { <nl> + swLinkedList_node * node = sw_malloc ( sizeof ( swLinkedList_node ) ) ; <nl> + if ( node = = NULL ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed . " , sizeof ( swLinkedList_node ) ) ; <nl> + return SW_ERR ; <nl> + } <nl> + node - > data = data ; <nl> + node - > next = NULL ; <nl> + ll - > num + + ; <nl> + if ( ll - > tail ) <nl> + { <nl> + ll - > tail - > next = node ; <nl> + node - > prev = ll - > tail ; <nl> + ll - > tail = node ; <nl> + } <nl> + else <nl> + { <nl> + node - > next = NULL ; <nl> + node - > prev = NULL ; <nl> + ll - > head = node ; <nl> + ll - > tail = node ; <nl> + } <nl> + return SW_OK ; <nl> + } <nl> + <nl> + int swLinkedList_prepend ( swLinkedList * ll , void * data ) <nl> + { <nl> + swLinkedList_node * node = sw_malloc ( sizeof ( swLinkedList_node ) ) ; <nl> + if ( node = = NULL ) <nl> + { <nl> + swWarn ( " malloc ( % ld ) failed . " , sizeof ( swLinkedList_node ) ) ; <nl> + return SW_ERR ; <nl> + } <nl> + node - > data = data ; <nl> + node - > prev = NULL ; <nl> + ll - > num + + ; <nl> + if ( ll - > head ) <nl> + { <nl> + ll - > head - > prev = node ; <nl> + node - > next = ll - > head ; <nl> + ll - > head = node ; <nl> + } <nl> + else <nl> + { <nl> + node - > next = NULL ; <nl> + node - > prev = NULL ; <nl> + ll - > head = node ; <nl> + ll - > tail = node ; <nl> + } <nl> + return SW_OK ; <nl> + } <nl> + <nl> + void * swLinkedList_pop ( swLinkedList * ll ) <nl> + { <nl> + if ( ll - > tail = = NULL ) <nl> + { <nl> + return NULL ; <nl> + } <nl> + <nl> + swLinkedList_node * node = ll - > tail ; <nl> + void * data = node - > data ; <nl> + <nl> + if ( node = = ll - > head ) <nl> + { <nl> + ll - > head = NULL ; <nl> + ll - > tail = NULL ; <nl> + } <nl> + else <nl> + { <nl> + swLinkedList_node * prev = ll - > tail - > prev ; <nl> + prev - > next = NULL ; <nl> + ll - > tail = prev ; <nl> + } <nl> + sw_free ( node ) ; <nl> + ll - > num - - ; <nl> + return data ; <nl> + } <nl> + <nl> + void * swLinkedList_shift ( swLinkedList * ll ) <nl> + { <nl> + swLinkedList_node * node = ll - > head ; <nl> + void * data = node - > data ; <nl> + <nl> + if ( node = = ll - > tail ) <nl> + { <nl> + ll - > head = NULL ; <nl> + ll - > tail = NULL ; <nl> + } <nl> + else <nl> + { <nl> + swLinkedList_node * next = ll - > head - > next ; <nl> + next - > prev = NULL ; <nl> + ll - > head = next ; <nl> + } <nl> + sw_free ( node ) ; <nl> + ll - > num - - ; <nl> + return data ; <nl> + } <nl> + <nl> + void swLinkedList_free ( swLinkedList * ll , swDestructor dtor ) <nl> + { <nl> + swLinkedList_node * node = ll - > head ; <nl> + swLinkedList_node * tmp ; <nl> + <nl> + do <nl> + { <nl> + tmp = node - > next ; <nl> + if ( dtor ) <nl> + { <nl> + dtor ( node - > data ) ; <nl> + } <nl> + sw_free ( node ) ; <nl> + node = tmp ; <nl> + } while ( node ) ; <nl> + <nl> + sw_free ( ll ) ; <nl> + } <nl> mmm a / src / memory / FixedPool . c <nl> ppp b / src / memory / FixedPool . c <nl> static void swFixedPool_init ( swFixedPool * object ) <nl> object - > head = slice ; <nl> cur + = ( sizeof ( swFixedPool_slice ) + object - > slice_size ) ; <nl> <nl> - if ( cur < max ) { <nl> + if ( cur < max ) <nl> + { <nl> slice - > pre = ( swFixedPool_slice * ) cur ; <nl> - } else { <nl> - slice - > pre = NULL ; / / we must ensure the previous element of the head be NULL <nl> + } <nl> + else <nl> + { <nl> + slice - > pre = NULL ; <nl> break ; <nl> } <nl> <nl> mmm a / src / network / ProcessPool . c <nl> ppp b / src / network / ProcessPool . c <nl> int swProcessPool_create ( swProcessPool * pool , int worker_num , int max_request , k <nl> return SW_ERR ; <nl> } <nl> <nl> - pool - > queue = sw_malloc ( sizeof ( swQueue ) ) ; <nl> + pool - > queue = sw_malloc ( sizeof ( swMsgQueue ) ) ; <nl> if ( pool - > queue = = NULL ) <nl> { <nl> swSysError ( " malloc [ 2 ] failed . " ) ; <nl> int swProcessPool_create ( swProcessPool * pool , int worker_num , int max_request , k <nl> int i ; <nl> if ( pool - > use_msgqueue ) <nl> { <nl> - if ( swQueueMsg_create ( pool - > queue , 1 , pool - > msgqueue_key , 1 ) < 0 ) <nl> + if ( swMsgQueue_create ( pool - > queue , 1 , pool - > msgqueue_key , 1 ) < 0 ) <nl> { <nl> return SW_ERR ; <nl> } <nl> static int swProcessPool_worker_loop ( swProcessPool * pool , swWorker * worker ) <nl> { <nl> if ( pool - > use_msgqueue ) <nl> { <nl> - n = pool - > queue - > out ( pool - > queue , ( swQueue_data * ) & out , sizeof ( out . buf ) ) ; <nl> + n = swMsgQueue_pop ( pool - > queue , ( swQueue_data * ) & out , sizeof ( out . buf ) ) ; <nl> if ( n < 0 & & errno ! = EINTR ) <nl> { <nl> swSysError ( " [ Worker # % d ] msgrcv ( ) failed . " , worker - > id ) ; <nl> mmm a / src / network / Worker . c <nl> ppp b / src / network / Worker . c <nl> int swWorker_send2worker ( swWorker * dst_worker , void * buf , int n , int flag ) <nl> msg . mtype = dst_worker - > id + 1 ; <nl> memcpy ( & msg . buf , buf , n ) ; <nl> <nl> - return dst_worker - > pool - > queue - > in ( dst_worker - > pool - > queue , ( swQueue_data * ) & msg , n ) ; <nl> + return swMsgQueue_push ( dst_worker - > pool - > queue , ( swQueue_data * ) & msg , n ) ; <nl> } <nl> <nl> if ( ( flag & SW_PIPE_NONBLOCK ) & & SwooleG . main_reactor ) <nl> similarity index 52 % <nl> rename from src / queue / Msg . c <nl> rename to src / os / msg_queue . c <nl> mmm a / src / queue / Msg . c <nl> ppp b / src / os / msg_queue . c <nl> <nl> # include < sys / ipc . h > <nl> # include < sys / msg . h > <nl> <nl> - static int swQueueMsg_in ( swQueue * p , swQueue_data * in , int data_length ) ; <nl> - static int swQueueMsg_out ( swQueue * p , swQueue_data * out , int buffer_length ) ; <nl> - static void swQueueMsg_free ( swQueue * p ) ; <nl> - <nl> - typedef struct _swQueueMsg <nl> + void swMsgQueue_free ( swMsgQueue * q ) <nl> { <nl> - int msg_id ; <nl> - int ipc_wait ; <nl> - uint8_t delete ; <nl> - long type ; <nl> - } swQueueMsg ; <nl> - <nl> - static void swQueueMsg_free ( swQueue * p ) <nl> - { <nl> - swQueueMsg * object = p - > object ; <nl> - if ( object - > delete ) <nl> + if ( q - > delete ) <nl> { <nl> - msgctl ( object - > msg_id , IPC_RMID , 0 ) ; <nl> + msgctl ( q - > msg_id , IPC_RMID , 0 ) ; <nl> } <nl> - sw_free ( object ) ; <nl> - } <nl> - <nl> - void swQueueMsg_set_blocking ( swQueue * p , uint8_t blocking ) <nl> - { <nl> - swQueueMsg * object = p - > object ; <nl> - object - > ipc_wait = blocking ? 0 : IPC_NOWAIT ; <nl> + sw_free ( q ) ; <nl> } <nl> <nl> - void swQueueMsg_set_destory ( swQueue * p , uint8_t destory ) <nl> + void swMsgQueue_set_blocking ( swMsgQueue * q , uint8_t blocking ) <nl> { <nl> - swQueueMsg * object = p - > object ; <nl> - object - > delete = destory ; <nl> + q - > ipc_wait = blocking ? 0 : IPC_NOWAIT ; <nl> } <nl> <nl> - int swQueueMsg_create ( swQueue * p , int blocking , key_t msg_key , long type ) <nl> + int swMsgQueue_create ( swMsgQueue * q , int blocking , key_t msg_key , long type ) <nl> { <nl> int msg_id ; <nl> - swQueueMsg * object = sw_malloc ( sizeof ( swQueueMsg ) ) ; <nl> - if ( object = = NULL ) <nl> - { <nl> - swWarn ( " malloc failed . Error : % s [ % d ] " , strerror ( errno ) , errno ) ; <nl> - return - 1 ; <nl> - } <nl> if ( blocking = = 0 ) <nl> { <nl> - object - > ipc_wait = IPC_NOWAIT ; <nl> + q - > ipc_wait = IPC_NOWAIT ; <nl> } <nl> else <nl> { <nl> - object - > ipc_wait = 0 ; <nl> + q - > ipc_wait = 0 ; <nl> } <nl> - p - > blocking = blocking ; <nl> + q - > blocking = blocking ; <nl> msg_id = msgget ( msg_key , IPC_CREAT | O_EXCL | 0666 ) ; <nl> if ( msg_id < 0 ) <nl> { <nl> int swQueueMsg_create ( swQueue * p , int blocking , key_t msg_key , long type ) <nl> } <nl> else <nl> { <nl> - object - > msg_id = msg_id ; <nl> - object - > type = type ; <nl> - p - > object = object ; <nl> - p - > in = swQueueMsg_in ; <nl> - p - > out = swQueueMsg_out ; <nl> - p - > free = swQueueMsg_free ; <nl> + q - > msg_id = msg_id ; <nl> + q - > type = type ; <nl> } <nl> return 0 ; <nl> } <nl> <nl> - static int swQueueMsg_out ( swQueue * p , swQueue_data * data , int length ) <nl> + int swMsgQueue_pop ( swMsgQueue * q , swQueue_data * data , int length ) <nl> { <nl> - swQueueMsg * object = p - > object ; <nl> - <nl> - int flag = object - > ipc_wait ; <nl> + int flag = q - > ipc_wait ; <nl> long type = data - > mtype ; <nl> <nl> - return msgrcv ( object - > msg_id , data , length , type , flag ) ; <nl> + return msgrcv ( q - > msg_id , data , length , type , flag ) ; <nl> } <nl> <nl> - static int swQueueMsg_in ( swQueue * p , swQueue_data * in , int length ) <nl> + int swMsgQueue_push ( swMsgQueue * q , swQueue_data * in , int length ) <nl> { <nl> int ret ; <nl> - swQueueMsg * object = p - > object ; <nl> <nl> while ( 1 ) <nl> { <nl> - ret = msgsnd ( object - > msg_id , in , length , object - > ipc_wait ) ; <nl> + ret = msgsnd ( q - > msg_id , in , length , q - > ipc_wait ) ; <nl> <nl> if ( ret < 0 ) <nl> { <nl> mmm a / swoole_process . c <nl> ppp b / swoole_process . c <nl> static PHP_METHOD ( swoole_process , __destruct ) <nl> } <nl> if ( process - > queue ) <nl> { <nl> - process - > queue - > free ( process - > queue ) ; <nl> + swMsgQueue_free ( process - > queue ) ; <nl> efree ( process - > queue ) ; <nl> } <nl> efree ( process ) ; <nl> static PHP_METHOD ( swoole_process , useQueue ) <nl> # endif <nl> } <nl> <nl> - swQueue * queue = emalloc ( sizeof ( swQueue ) ) ; <nl> - if ( swQueueMsg_create ( queue , 1 , msgkey , 0 ) < 0 ) <nl> + swMsgQueue * queue = emalloc ( sizeof ( swMsgQueue ) ) ; <nl> + if ( swMsgQueue_create ( queue , 1 , msgkey , 0 ) < 0 ) <nl> { <nl> RETURN_FALSE ; <nl> } <nl> - swQueueMsg_set_destory ( queue , 0 ) ; <nl> - <nl> + queue - > delete = 0 ; <nl> process - > queue = queue ; <nl> process - > ipc_mode = mode ; <nl> RETURN_TRUE ; <nl> static PHP_METHOD ( swoole_process , push ) <nl> message . type = process - > id ; <nl> memcpy ( message . data , data , length ) ; <nl> <nl> - if ( process - > queue - > in ( process - > queue , ( swQueue_data * ) & message , length ) < 0 ) <nl> + if ( swMsgQueue_push ( process - > queue , ( swQueue_data * ) & message , length ) < 0 ) <nl> { <nl> php_error_docref ( NULL TSRMLS_CC , E_WARNING , " msgsnd ( ) failed . Error : % s [ % d ] " , strerror ( errno ) , errno ) ; <nl> RETURN_FALSE ; <nl> static PHP_METHOD ( swoole_process , pop ) <nl> message . type = process - > id ; <nl> } <nl> <nl> - int n = process - > queue - > out ( process - > queue , ( swQueue_data * ) & message , maxsize ) ; <nl> + int n = swMsgQueue_pop ( process - > queue , ( swQueue_data * ) & message , maxsize ) ; <nl> if ( n < 0 ) <nl> { <nl> php_error_docref ( NULL TSRMLS_CC , E_WARNING , " msgrcv ( ) failed . Error : % s [ % d ] " , strerror ( errno ) , errno ) ; <nl> mmm a / tests / ds . c <nl> ppp b / tests / ds . c <nl> swUnitTest ( rbtree_test ) <nl> printf ( " find_n % d \ n " , ( int ) swRbtree_find ( tree , 17532 ) ) ; <nl> return 0 ; <nl> } <nl> + <nl> + <nl> + swUnitTest ( linkedlist_test ) <nl> + { <nl> + swLinkedList * ll = swLinkedList_new ( ) ; <nl> + uint32_t key ; <nl> + int i , j , n ; <nl> + # define Q_N 2000 <nl> + int data [ Q_N ] ; <nl> + int * value ; <nl> + <nl> + for ( i = 1 ; i < Q_N ; i + + ) <nl> + { <nl> + data [ i ] = i ; <nl> + swLinkedList_append ( ll , & data [ i ] ) ; <nl> + <nl> + if ( i % 200 = = 150 & & ll - > num > 150 ) <nl> + { <nl> + n = rand ( ) % 150 + 10 ; <nl> + printf ( " count = % d , pop n = % d \ n " , ll - > num , n ) ; <nl> + for ( j = 0 ; j < n ; j + + ) <nl> + { <nl> + value = swLinkedList_shift ( ll ) ; <nl> + if ( value ) <nl> + { <nl> + printf ( " value = % d \ n " , * value ) ; <nl> + } <nl> + else <nl> + { <nl> + printf ( " NULL \ n " ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + printf ( " \ nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - \ nnum = % d , pop all \ nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - \ n " , ll - > num ) ; <nl> + <nl> + for ( j = ll - > num ; j > 0 ; j - - ) <nl> + { <nl> + value = swLinkedList_shift ( ll ) ; <nl> + if ( value ) <nl> + { <nl> + printf ( " value = % d \ n " , * value ) ; <nl> + } <nl> + else <nl> + { <nl> + printf ( " NULL \ n " ) ; <nl> + } <nl> + } <nl> + return 0 ; <nl> + } <nl> mmm a / tests / main . c <nl> ppp b / tests / main . c <nl> int main ( int argc , char * * argv ) <nl> swUnitTest_steup ( aio_test2 , 1 , " thread pool aio test " ) ; <nl> <nl> swUnitTest_steup ( rbtree_test , 1 , " rbtree data struct test " ) ; <nl> + swUnitTest_steup ( linkedlist_test , 1 , " linkedlist data struct test " ) ; <nl> / / swUnitTest_steup ( pool_thread , 1 ) ; <nl> <nl> swUnitTest_steup ( type_test1 , 1 , " type test " ) ; <nl>
move src / queue / Msg . c to src / os / msg_queue . c
swoole/swoole-src
4417e3e31c7e29a0f028f11db7fc362d5359e684
2015-12-29T09:01:59Z
mmm a / doc / py_tutorials / py_imgproc / py_houghlines / py_houghlines . markdown <nl> ppp b / doc / py_tutorials / py_imgproc / py_houghlines / py_houghlines . markdown <nl> denotes they are the parameters of possible lines in the image . ( Image courtesy : <nl> <nl> ! [ ] ( images / houghlines2 . jpg ) <nl> <nl> - Hough Tranform in OpenCV <nl> + Hough Transform in OpenCV <nl> = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> Everything explained above is encapsulated in the OpenCV function , \ * \ * cv2 . HoughLines ( ) \ * \ * . It simply returns an array of : math : ( rho , <nl> gray = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) <nl> edges = cv2 . Canny ( gray , 50 , 150 , apertureSize = 3 ) <nl> <nl> lines = cv2 . HoughLines ( edges , 1 , np . pi / 180 , 200 ) <nl> - for rho , theta in lines [ 0 ] : <nl> + for line in lines : <nl> + rho , theta = line [ 0 ] <nl> a = np . cos ( theta ) <nl> b = np . sin ( theta ) <nl> x0 = a * rho <nl> import numpy as np <nl> img = cv2 . imread ( ' dave . jpg ' ) <nl> gray = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) <nl> edges = cv2 . Canny ( gray , 50 , 150 , apertureSize = 3 ) <nl> - minLineLength = 100 <nl> - maxLineGap = 10 <nl> - lines = cv2 . HoughLinesP ( edges , 1 , np . pi / 180 , 100 , minLineLength , maxLineGap ) <nl> - for x1 , y1 , x2 , y2 in lines [ 0 ] : <nl> + lines = cv2 . HoughLinesP ( edges , 1 , np . pi / 180 , 100 , minLineLength = 100 , maxLineGap = 10 ) <nl> + for line in lines : <nl> + x1 , y1 , x2 , y2 = line [ 0 ] <nl> cv2 . line ( img , ( x1 , y1 ) , ( x2 , y2 ) , ( 0 , 255 , 0 ) , 2 ) <nl> <nl> cv2 . imwrite ( ' houghlines5 . jpg ' , img ) <nl> mmm a / samples / python2 / houghlines . py <nl> ppp b / samples / python2 / houghlines . py <nl> <nl> dst = cv2 . Canny ( src , 50 , 200 ) <nl> cdst = cv2 . cvtColor ( dst , cv2 . COLOR_GRAY2BGR ) <nl> <nl> - # HoughLines ( ) <nl> - # lines = cv2 . HoughLines ( dst , 1 , math . pi / 180 . 0 , 50 , np . array ( [ ] ) , 0 , 0 ) <nl> - # a , b , c = lines . shape <nl> - # for i in range ( b ) : <nl> - # rho = lines [ 0 ] [ i ] [ 0 ] <nl> - # theta = lines [ 0 ] [ i ] [ 1 ] <nl> - # a = math . cos ( theta ) <nl> - # b = math . sin ( theta ) <nl> - # x0 , y0 = a * rho , b * rho <nl> - # pt1 = ( int ( x0 + 1000 * ( - b ) ) , int ( y0 + 1000 * ( a ) ) ) <nl> - # pt2 = ( int ( x0 - 1000 * ( - b ) ) , int ( y0 - 1000 * ( a ) ) ) <nl> - # cv2 . line ( cdst , pt1 , pt2 , ( 0 , 0 , 255 ) , 3 , cv2 . LINE_AA ) <nl> + if True : # HoughLinesP <nl> + lines = cv2 . HoughLinesP ( dst , 1 , math . pi / 180 . 0 , 40 , np . array ( [ ] ) , 50 , 10 ) <nl> + a , b , c = lines . shape <nl> + for i in range ( a ) : <nl> + cv2 . line ( cdst , ( lines [ i ] [ 0 ] [ 0 ] , lines [ i ] [ 0 ] [ 1 ] ) , ( lines [ i ] [ 0 ] [ 2 ] , lines [ i ] [ 0 ] [ 3 ] ) , ( 0 , 0 , 255 ) , 3 , cv2 . LINE_AA ) <nl> + <nl> + else : # HoughLines <nl> + lines = cv2 . HoughLines ( dst , 1 , math . pi / 180 . 0 , 50 , np . array ( [ ] ) , 0 , 0 ) <nl> + a , b , c = lines . shape <nl> + for i in range ( a ) : <nl> + rho = lines [ i ] [ 0 ] [ 0 ] <nl> + theta = lines [ i ] [ 0 ] [ 1 ] <nl> + a = math . cos ( theta ) <nl> + b = math . sin ( theta ) <nl> + x0 , y0 = a * rho , b * rho <nl> + pt1 = ( int ( x0 + 1000 * ( - b ) ) , int ( y0 + 1000 * ( a ) ) ) <nl> + pt2 = ( int ( x0 - 1000 * ( - b ) ) , int ( y0 - 1000 * ( a ) ) ) <nl> + cv2 . line ( cdst , pt1 , pt2 , ( 0 , 0 , 255 ) , 3 , cv2 . LINE_AA ) <nl> <nl> - lines = cv2 . HoughLinesP ( dst , 1 , math . pi / 180 . 0 , 50 , np . array ( [ ] ) , 50 , 10 ) <nl> - a , b , c = lines . shape <nl> - for i in range ( b ) : <nl> - cv2 . line ( cdst , ( lines [ 0 ] [ i ] [ 0 ] , lines [ 0 ] [ i ] [ 1 ] ) , ( lines [ 0 ] [ i ] [ 2 ] , lines [ 0 ] [ i ] [ 3 ] ) , ( 0 , 0 , 255 ) , 3 , cv2 . LINE_AA ) <nl> <nl> cv2 . imshow ( " source " , src ) <nl> cv2 . imshow ( " detected lines " , cdst ) <nl>
Merge pull request from berak : py_houghlines_sample
opencv/opencv
c9ea878d103b3a88bc332dc9fab9ad03df8118f1
2015-03-03T18:16:25Z
mmm a / db / compaction_job . cc <nl> ppp b / db / compaction_job . cc <nl> Status CompactionJob : : FinishCompactionOutputFile ( <nl> nullptr / * range_del_agg * / , nullptr , <nl> cfd - > internal_stats ( ) - > GetFileReadHist ( <nl> compact_ - > compaction - > output_level ( ) ) , <nl> - false ) ; <nl> + false , nullptr / * arena * / , false / * skip_filters * / , <nl> + compact_ - > compaction - > output_level ( ) ) ; <nl> s = iter - > status ( ) ; <nl> <nl> if ( s . ok ( ) & & paranoid_file_checks_ ) { <nl>
pin L0 filters / indexes for compaction outputs
facebook/rocksdb
821887036e5235c827029d14decb185bea01ec4b
2017-10-03T23:27:28Z
mmm a / src / core / ext / transport / chttp2 / transport / chttp2_transport . c <nl> ppp b / src / core / ext / transport / chttp2 / transport / chttp2_transport . c <nl> static void remove_stream ( grpc_exec_ctx * exec_ctx , grpc_chttp2_transport * t , <nl> gpr_mu_lock ( & s - > data_parser . parsing_frame - > slice_mu ) ; <nl> if ( error ! = GRPC_ERROR_NONE | | <nl> s - > data_parser . parsing_frame - > on_next ) { <nl> + gpr_mu_unlock ( & s - > data_parser . parsing_frame - > slice_mu ) ; <nl> grpc_chttp2_incoming_byte_stream_finished ( <nl> exec_ctx , s - > data_parser . parsing_frame , GRPC_ERROR_REF ( error ) ) ; <nl> s - > data_parser . parsing_frame = NULL ; <nl>
nit
grpc/grpc
369d5cce0222b911d491135c7b2db6044654d829
2017-03-02T19:18:56Z
mmm a / src / arm / assembler - arm - inl . h <nl> ppp b / src / arm / assembler - arm - inl . h <nl> void Assembler : : deserialization_set_target_internal_reference_at ( <nl> <nl> <nl> bool Assembler : : is_constant_pool_load ( Address pc ) { <nl> - if ( CpuFeatures : : IsSupported ( ARMv7 ) ) { <nl> - return ! Assembler : : IsMovW ( Memory : : int32_at ( pc ) ) ; <nl> - } else { <nl> - return ! Assembler : : IsMovImmed ( Memory : : int32_at ( pc ) ) ; <nl> - } <nl> + return IsLdrPcImmediateOffset ( Memory : : int32_at ( pc ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / arm / assembler - arm . cc <nl> ppp b / src / arm / assembler - arm . cc <nl> static bool fits_shifter ( uint32_t imm32 , <nl> return false ; <nl> } <nl> <nl> + namespace { <nl> <nl> / / We have to use the temporary register for things that can be relocated even <nl> / / if they can be encoded in the ARM ' s 12 bits of immediate - offset instruction <nl> / / space . There is no guarantee that the relocated location can be similarly <nl> / / encoded . <nl> - bool Operand : : must_output_reloc_info ( const Assembler * assembler ) const { <nl> - if ( rmode_ = = RelocInfo : : EXTERNAL_REFERENCE ) { <nl> + bool must_output_reloc_info ( RelocInfo : : Mode rmode , const Assembler * assembler ) { <nl> + if ( rmode = = RelocInfo : : EXTERNAL_REFERENCE ) { <nl> if ( assembler ! = NULL & & assembler - > predictable_code_size ( ) ) return true ; <nl> return assembler - > serializer_enabled ( ) ; <nl> - } else if ( RelocInfo : : IsNone ( rmode_ ) ) { <nl> + } else if ( RelocInfo : : IsNone ( rmode ) ) { <nl> return false ; <nl> } <nl> return true ; <nl> } <nl> <nl> - <nl> - static bool use_mov_immediate_load ( const Operand & x , <nl> - const Assembler * assembler ) { <nl> + bool use_mov_immediate_load ( const Operand & x , const Assembler * assembler ) { <nl> DCHECK ( assembler ! = nullptr ) ; <nl> if ( x . must_output_reloc_info ( assembler ) ) { <nl> / / Prefer constant pool if data is likely to be patched . <nl> static bool use_mov_immediate_load ( const Operand & x , <nl> } <nl> } <nl> <nl> + } / / namespace <nl> + <nl> + bool Operand : : must_output_reloc_info ( const Assembler * assembler ) const { <nl> + return v8 : : internal : : must_output_reloc_info ( rmode_ , assembler ) ; <nl> + } <nl> <nl> int Operand : : instructions_required ( const Assembler * assembler , <nl> Instr instr ) const { <nl> int Operand : : instructions_required ( const Assembler * assembler , <nl> / / for the constant pool or immediate load <nl> int instructions ; <nl> if ( use_mov_immediate_load ( * this , assembler ) ) { <nl> - / / A movw / movt or mov / orr immediate load . <nl> - instructions = CpuFeatures : : IsSupported ( ARMv7 ) ? 2 : 4 ; <nl> + DCHECK ( CpuFeatures : : IsSupported ( ARMv7 ) ) ; <nl> + / / A movw / movt immediate load . <nl> + instructions = 2 ; <nl> } else { <nl> / / A small constant pool load . <nl> instructions = 1 ; <nl> int Operand : : instructions_required ( const Assembler * assembler , <nl> void Assembler : : move_32_bit_immediate ( Register rd , <nl> const Operand & x , <nl> Condition cond ) { <nl> - uint32_t imm32 = static_cast < uint32_t > ( x . imm32_ ) ; <nl> - if ( x . must_output_reloc_info ( this ) ) { <nl> - RecordRelocInfo ( x . rmode_ ) ; <nl> - } <nl> - <nl> if ( use_mov_immediate_load ( x , this ) ) { <nl> / / use_mov_immediate_load should return false when we need to output <nl> / / relocation info , since we prefer the constant pool for values that <nl> void Assembler : : move_32_bit_immediate ( Register rd , <nl> DCHECK ( ! x . must_output_reloc_info ( this ) ) ; <nl> Register target = rd . code ( ) = = pc . code ( ) ? ip : rd ; <nl> if ( CpuFeatures : : IsSupported ( ARMv7 ) ) { <nl> + uint32_t imm32 = static_cast < uint32_t > ( x . imm32_ ) ; <nl> CpuFeatureScope scope ( this , ARMv7 ) ; <nl> movw ( target , imm32 & 0xffff , cond ) ; <nl> movt ( target , imm32 > > 16 , cond ) ; <nl> void Assembler : : move_32_bit_immediate ( Register rd , <nl> mov ( rd , target , LeaveCC , cond ) ; <nl> } <nl> } else { <nl> - ConstantPoolEntry : : Access access = <nl> - ConstantPoolAddEntry ( pc_offset ( ) , x . rmode_ , x . imm32_ ) ; <nl> - DCHECK ( access = = ConstantPoolEntry : : REGULAR ) ; <nl> - USE ( access ) ; <nl> + ConstantPoolAddEntry ( pc_offset ( ) , x . rmode_ , x . imm32_ ) ; <nl> ldr ( rd , MemOperand ( pc , 0 ) , cond ) ; <nl> } <nl> } <nl> void Assembler : : vmov ( const DwVfpRegister dst , <nl> / / The code could also randomize the order of values , though <nl> / / that ' s tricky because vldr has a limited reach . Furthermore <nl> / / it breaks load locality . <nl> - ConstantPoolEntry : : Access access = ConstantPoolAddEntry ( pc_offset ( ) , imm ) ; <nl> - DCHECK ( access = = ConstantPoolEntry : : REGULAR ) ; <nl> - USE ( access ) ; <nl> + ConstantPoolAddEntry ( pc_offset ( ) , imm ) ; <nl> vldr ( dst , MemOperand ( pc , 0 ) ) ; <nl> } else { <nl> / / Synthesise the double from ARM immediates . <nl> void Assembler : : emit_code_stub_address ( Code * stub ) { <nl> pc_ + = sizeof ( uint32_t ) ; <nl> } <nl> <nl> - <nl> void Assembler : : RecordRelocInfo ( RelocInfo : : Mode rmode , intptr_t data ) { <nl> if ( RelocInfo : : IsNone ( rmode ) | | <nl> / / Don ' t record external references unless the heap will be serialized . <nl> void Assembler : : RecordRelocInfo ( RelocInfo : : Mode rmode , intptr_t data ) { <nl> reloc_info_writer . Write ( & rinfo ) ; <nl> } <nl> <nl> - <nl> - ConstantPoolEntry : : Access Assembler : : ConstantPoolAddEntry ( int position , <nl> - RelocInfo : : Mode rmode , <nl> - intptr_t value ) { <nl> + void Assembler : : ConstantPoolAddEntry ( int position , RelocInfo : : Mode rmode , <nl> + intptr_t value ) { <nl> DCHECK ( rmode ! = RelocInfo : : COMMENT & & rmode ! = RelocInfo : : CONST_POOL & & <nl> rmode ! = RelocInfo : : NONE64 ) ; <nl> bool sharing_ok = RelocInfo : : IsNone ( rmode ) | | <nl> - ! ( serializer_enabled ( ) | | rmode < RelocInfo : : CELL ) ; <nl> + ( rmode > = RelocInfo : : FIRST_SHAREABLE_RELOC_MODE ) ; <nl> DCHECK ( pending_32_bit_constants_ . size ( ) < kMaxNumPending32Constants ) ; <nl> if ( pending_32_bit_constants_ . empty ( ) ) { <nl> first_const_pool_32_use_ = position ; <nl> } <nl> - ConstantPoolEntry entry ( position , value , sharing_ok ) ; <nl> + ConstantPoolEntry entry ( <nl> + position , value , <nl> + sharing_ok | | ( rmode = = RelocInfo : : CODE_TARGET & & serializer_enabled ( ) ) ) ; <nl> + <nl> + bool shared = false ; <nl> + if ( sharing_ok ) { <nl> + / / Merge the constant , if possible . <nl> + for ( size_t i = 0 ; i < pending_32_bit_constants_ . size ( ) ; i + + ) { <nl> + ConstantPoolEntry & current_entry = pending_32_bit_constants_ [ i ] ; <nl> + if ( ! current_entry . sharing_ok ( ) ) continue ; <nl> + if ( entry . value ( ) = = current_entry . value ( ) ) { <nl> + entry . set_merged_index ( i ) ; <nl> + shared = true ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( rmode = = RelocInfo : : CODE_TARGET & & serializer_enabled ( ) ) { <nl> + / / TODO ( all ) : We only do this in the serializer , for now , because <nl> + / / full - codegen relies on RelocInfo for translating PCs between full - codegen <nl> + / / normal and debug code . <nl> + / / Sharing entries here relies on canonicalized handles - without them , we <nl> + / / will miss the optimisation opportunity . <nl> + Address handle_address = reinterpret_cast < Address > ( value ) ; <nl> + auto existing = handle_to_index_map_ . find ( handle_address ) ; <nl> + if ( existing ! = handle_to_index_map_ . end ( ) ) { <nl> + int index = existing - > second ; <nl> + entry . set_merged_index ( index ) ; <nl> + shared = true ; <nl> + } else { <nl> + / / Keep track of this code handle . <nl> + handle_to_index_map_ [ handle_address ] = <nl> + static_cast < int > ( pending_32_bit_constants_ . size ( ) ) ; <nl> + } <nl> + } <nl> + <nl> pending_32_bit_constants_ . push_back ( entry ) ; <nl> <nl> / / Make sure the constant pool is not emitted in place of the next <nl> / / instruction for which we just recorded relocation info . <nl> BlockConstPoolFor ( 1 ) ; <nl> - return ConstantPoolEntry : : REGULAR ; <nl> - } <nl> <nl> + / / Emit relocation info . <nl> + if ( must_output_reloc_info ( rmode , this ) & & ! shared ) { <nl> + RecordRelocInfo ( rmode ) ; <nl> + } <nl> + } <nl> <nl> - ConstantPoolEntry : : Access Assembler : : ConstantPoolAddEntry ( int position , <nl> - double value ) { <nl> + void Assembler : : ConstantPoolAddEntry ( int position , double value ) { <nl> DCHECK ( pending_64_bit_constants_ . size ( ) < kMaxNumPending64Constants ) ; <nl> if ( pending_64_bit_constants_ . empty ( ) ) { <nl> first_const_pool_64_use_ = position ; <nl> } <nl> ConstantPoolEntry entry ( position , value ) ; <nl> + <nl> + / / Merge the constant , if possible . <nl> + for ( size_t i = 0 ; i < pending_64_bit_constants_ . size ( ) ; i + + ) { <nl> + ConstantPoolEntry & current_entry = pending_64_bit_constants_ [ i ] ; <nl> + DCHECK ( current_entry . sharing_ok ( ) ) ; <nl> + if ( entry . value ( ) = = current_entry . value ( ) ) { <nl> + entry . set_merged_index ( i ) ; <nl> + break ; <nl> + } <nl> + } <nl> pending_64_bit_constants_ . push_back ( entry ) ; <nl> <nl> / / Make sure the constant pool is not emitted in place of the next <nl> / / instruction for which we just recorded relocation info . <nl> BlockConstPoolFor ( 1 ) ; <nl> - return ConstantPoolEntry : : REGULAR ; <nl> } <nl> <nl> <nl> void Assembler : : CheckConstPool ( bool force_emit , bool require_jump ) { <nl> int size_after_marker = estimated_size_after_marker ; <nl> for ( size_t i = 0 ; i < pending_64_bit_constants_ . size ( ) ; i + + ) { <nl> ConstantPoolEntry & entry = pending_64_bit_constants_ [ i ] ; <nl> - DCHECK ( ! entry . is_merged ( ) ) ; <nl> - for ( size_t j = 0 ; j < i ; j + + ) { <nl> - if ( entry . value64 ( ) = = pending_64_bit_constants_ [ j ] . value64 ( ) ) { <nl> - DCHECK ( ! pending_64_bit_constants_ [ j ] . is_merged ( ) ) ; <nl> - entry . set_merged_index ( j ) ; <nl> - size_after_marker - = kDoubleSize ; <nl> - break ; <nl> - } <nl> - } <nl> + if ( entry . is_merged ( ) ) size_after_marker - = kDoubleSize ; <nl> } <nl> <nl> for ( size_t i = 0 ; i < pending_32_bit_constants_ . size ( ) ; i + + ) { <nl> ConstantPoolEntry & entry = pending_32_bit_constants_ [ i ] ; <nl> - DCHECK ( ! entry . is_merged ( ) ) ; <nl> - if ( ! entry . sharing_ok ( ) ) continue ; <nl> - for ( size_t j = 0 ; j < i ; j + + ) { <nl> - if ( entry . value ( ) = = pending_32_bit_constants_ [ j ] . value ( ) ) { <nl> - DCHECK ( ! pending_32_bit_constants_ [ j ] . is_merged ( ) ) ; <nl> - entry . set_merged_index ( j ) ; <nl> - size_after_marker - = kPointerSize ; <nl> - break ; <nl> - } <nl> - } <nl> + if ( entry . is_merged ( ) ) size_after_marker - = kPointerSize ; <nl> } <nl> <nl> int size = size_up_to_marker + size_after_marker ; <nl> void Assembler : : CheckConstPool ( bool force_emit , bool require_jump ) { <nl> <nl> pending_32_bit_constants_ . clear ( ) ; <nl> pending_64_bit_constants_ . clear ( ) ; <nl> + handle_to_index_map_ . clear ( ) ; <nl> + <nl> first_const_pool_32_use_ = - 1 ; <nl> first_const_pool_64_use_ = - 1 ; <nl> <nl> mmm a / src / arm / assembler - arm . h <nl> ppp b / src / arm / assembler - arm . h <nl> class Assembler : public AssemblerBase { <nl> std : : vector < ConstantPoolEntry > pending_32_bit_constants_ ; <nl> std : : vector < ConstantPoolEntry > pending_64_bit_constants_ ; <nl> <nl> + / / Map of address of handle to index in pending_32_bit_constants_ . <nl> + std : : map < Address , int > handle_to_index_map_ ; <nl> + <nl> private : <nl> / / Avoid overflows for displacements etc . <nl> static const int kMaximalBufferSize = 512 * MB ; <nl> class Assembler : public AssemblerBase { <nl> <nl> / / Record reloc info for current pc_ <nl> void RecordRelocInfo ( RelocInfo : : Mode rmode , intptr_t data = 0 ) ; <nl> - ConstantPoolEntry : : Access ConstantPoolAddEntry ( int position , <nl> - RelocInfo : : Mode rmode , <nl> - intptr_t value ) ; <nl> - ConstantPoolEntry : : Access ConstantPoolAddEntry ( int position , double value ) ; <nl> + void ConstantPoolAddEntry ( int position , RelocInfo : : Mode rmode , <nl> + intptr_t value ) ; <nl> + void ConstantPoolAddEntry ( int position , double value ) ; <nl> <nl> friend class RelocInfo ; <nl> friend class CodePatcher ; <nl> mmm a / src / assembler . h <nl> ppp b / src / assembler . h <nl> class ConstantPoolEntry { <nl> return merged_index_ ; <nl> } <nl> void set_merged_index ( int index ) { <nl> + DCHECK ( sharing_ok ( ) ) ; <nl> merged_index_ = index ; <nl> DCHECK ( is_merged ( ) ) ; <nl> } <nl> mmm a / src / builtins / setup - builtins - internal . cc <nl> ppp b / src / builtins / setup - builtins - internal . cc <nl> Code * BuildWithMacroAssembler ( Isolate * isolate , <nl> MacroAssemblerGenerator generator , <nl> Code : : Flags flags , const char * s_name ) { <nl> HandleScope scope ( isolate ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( isolate ) ; <nl> const size_t buffer_size = 32 * KB ; <nl> byte buffer [ buffer_size ] ; / / NOLINT ( runtime / arrays ) <nl> MacroAssembler masm ( isolate , buffer , buffer_size , CodeObjectRequired : : kYes ) ; <nl> Code * BuildAdaptor ( Isolate * isolate , Address builtin_address , <nl> Builtins : : ExitFrameType exit_frame_type , Code : : Flags flags , <nl> const char * name ) { <nl> HandleScope scope ( isolate ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( isolate ) ; <nl> const size_t buffer_size = 32 * KB ; <nl> byte buffer [ buffer_size ] ; / / NOLINT ( runtime / arrays ) <nl> MacroAssembler masm ( isolate , buffer , buffer_size , CodeObjectRequired : : kYes ) ; <nl> Code * BuildWithCodeStubAssemblerJS ( Isolate * isolate , <nl> CodeAssemblerGenerator generator , int argc , <nl> Code : : Flags flags , const char * name ) { <nl> HandleScope scope ( isolate ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( isolate ) ; <nl> Zone zone ( isolate - > allocator ( ) , ZONE_NAME ) ; <nl> const int argc_with_recv = <nl> ( argc = = SharedFunctionInfo : : kDontAdaptArgumentsSentinel ) ? 0 : argc + 1 ; <nl> Code * BuildWithCodeStubAssemblerCS ( Isolate * isolate , <nl> Code : : Flags flags , const char * name , <nl> int result_size ) { <nl> HandleScope scope ( isolate ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( isolate ) ; <nl> Zone zone ( isolate - > allocator ( ) , ZONE_NAME ) ; <nl> / / The interface descriptor with given key must be initialized at this point <nl> / / and this construction just queries the details from the descriptors table . <nl> mmm a / src / code - stubs . cc <nl> ppp b / src / code - stubs . cc <nl> Handle < Code > CodeStub : : GetCode ( ) { <nl> <nl> { <nl> HandleScope scope ( isolate ( ) ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( isolate ( ) ) ; <nl> <nl> Handle < Code > new_object = GenerateCode ( ) ; <nl> new_object - > set_stub_key ( GetKey ( ) ) ; <nl> mmm a / src / disassembler . cc <nl> ppp b / src / disassembler . cc <nl> static void DumpBuffer ( std : : ostream * os , StringBuilder * out ) { <nl> static const int kOutBufferSize = 2048 + String : : kMaxShortPrintLength ; <nl> static const int kRelocInfoPosition = 57 ; <nl> <nl> + static void PrintRelocInfo ( StringBuilder * out , Isolate * isolate , <nl> + const ExternalReferenceEncoder & ref_encoder , <nl> + std : : ostream * os , RelocInfo * relocinfo , <nl> + bool first_reloc_info = true ) { <nl> + / / Indent the printing of the reloc info . <nl> + if ( first_reloc_info ) { <nl> + / / The first reloc info is printed after the disassembled instruction . <nl> + out - > AddPadding ( ' ' , kRelocInfoPosition - out - > position ( ) ) ; <nl> + } else { <nl> + / / Additional reloc infos are printed on separate lines . <nl> + DumpBuffer ( os , out ) ; <nl> + out - > AddPadding ( ' ' , kRelocInfoPosition ) ; <nl> + } <nl> + <nl> + RelocInfo : : Mode rmode = relocinfo - > rmode ( ) ; <nl> + if ( rmode = = RelocInfo : : DEOPT_SCRIPT_OFFSET ) { <nl> + out - > AddFormatted ( " ; ; debug : deopt position , script offset ' % d ' " , <nl> + static_cast < int > ( relocinfo - > data ( ) ) ) ; <nl> + } else if ( rmode = = RelocInfo : : DEOPT_INLINING_ID ) { <nl> + out - > AddFormatted ( " ; ; debug : deopt position , inlining id ' % d ' " , <nl> + static_cast < int > ( relocinfo - > data ( ) ) ) ; <nl> + } else if ( rmode = = RelocInfo : : DEOPT_REASON ) { <nl> + DeoptimizeReason reason = static_cast < DeoptimizeReason > ( relocinfo - > data ( ) ) ; <nl> + out - > AddFormatted ( " ; ; debug : deopt reason ' % s ' " , <nl> + DeoptimizeReasonToString ( reason ) ) ; <nl> + } else if ( rmode = = RelocInfo : : DEOPT_ID ) { <nl> + out - > AddFormatted ( " ; ; debug : deopt index % d " , <nl> + static_cast < int > ( relocinfo - > data ( ) ) ) ; <nl> + } else if ( rmode = = RelocInfo : : EMBEDDED_OBJECT ) { <nl> + HeapStringAllocator allocator ; <nl> + StringStream accumulator ( & allocator ) ; <nl> + relocinfo - > target_object ( ) - > ShortPrint ( & accumulator ) ; <nl> + std : : unique_ptr < char [ ] > obj_name = accumulator . ToCString ( ) ; <nl> + out - > AddFormatted ( " ; ; object : % s " , obj_name . get ( ) ) ; <nl> + } else if ( rmode = = RelocInfo : : EXTERNAL_REFERENCE ) { <nl> + const char * reference_name = ref_encoder . NameOfAddress ( <nl> + isolate , relocinfo - > target_external_reference ( ) ) ; <nl> + out - > AddFormatted ( " ; ; external reference ( % s ) " , reference_name ) ; <nl> + } else if ( RelocInfo : : IsCodeTarget ( rmode ) ) { <nl> + out - > AddFormatted ( " ; ; code : " ) ; <nl> + Code * code = Code : : GetCodeFromTargetAddress ( relocinfo - > target_address ( ) ) ; <nl> + Code : : Kind kind = code - > kind ( ) ; <nl> + if ( code - > is_inline_cache_stub ( ) ) { <nl> + out - > AddFormatted ( " % s " , Code : : Kind2String ( kind ) ) ; <nl> + if ( kind = = Code : : BINARY_OP_IC | | kind = = Code : : TO_BOOLEAN_IC | | <nl> + kind = = Code : : COMPARE_IC ) { <nl> + InlineCacheState ic_state = IC : : StateFromCode ( code ) ; <nl> + out - > AddFormatted ( " % s " , Code : : ICState2String ( ic_state ) ) ; <nl> + } <nl> + } else if ( kind = = Code : : STUB | | kind = = Code : : HANDLER ) { <nl> + / / Get the STUB key and extract major and minor key . <nl> + uint32_t key = code - > stub_key ( ) ; <nl> + uint32_t minor_key = CodeStub : : MinorKeyFromKey ( key ) ; <nl> + CodeStub : : Major major_key = CodeStub : : GetMajorKey ( code ) ; <nl> + DCHECK ( major_key = = CodeStub : : MajorKeyFromKey ( key ) ) ; <nl> + out - > AddFormatted ( " % s , % s , " , Code : : Kind2String ( kind ) , <nl> + CodeStub : : MajorName ( major_key ) ) ; <nl> + out - > AddFormatted ( " minor : % d " , minor_key ) ; <nl> + } else { <nl> + out - > AddFormatted ( " % s " , Code : : Kind2String ( kind ) ) ; <nl> + } <nl> + if ( rmode = = RelocInfo : : CODE_TARGET_WITH_ID ) { <nl> + out - > AddFormatted ( " ( id = % d ) " , static_cast < int > ( relocinfo - > data ( ) ) ) ; <nl> + } <nl> + } else if ( RelocInfo : : IsRuntimeEntry ( rmode ) & & <nl> + isolate - > deoptimizer_data ( ) ! = nullptr ) { <nl> + / / A runtime entry reloinfo might be a deoptimization bailout - > <nl> + Address addr = relocinfo - > target_address ( ) ; <nl> + int id = <nl> + Deoptimizer : : GetDeoptimizationId ( isolate , addr , Deoptimizer : : EAGER ) ; <nl> + if ( id = = Deoptimizer : : kNotDeoptimizationEntry ) { <nl> + id = Deoptimizer : : GetDeoptimizationId ( isolate , addr , Deoptimizer : : LAZY ) ; <nl> + if ( id = = Deoptimizer : : kNotDeoptimizationEntry ) { <nl> + id = Deoptimizer : : GetDeoptimizationId ( isolate , addr , Deoptimizer : : SOFT ) ; <nl> + if ( id = = Deoptimizer : : kNotDeoptimizationEntry ) { <nl> + out - > AddFormatted ( " ; ; % s " , RelocInfo : : RelocModeName ( rmode ) ) ; <nl> + } else { <nl> + out - > AddFormatted ( " ; ; soft deoptimization bailout % d " , id ) ; <nl> + } <nl> + } else { <nl> + out - > AddFormatted ( " ; ; lazy deoptimization bailout % d " , id ) ; <nl> + } <nl> + } else { <nl> + out - > AddFormatted ( " ; ; deoptimization bailout % d " , id ) ; <nl> + } <nl> + } else { <nl> + out - > AddFormatted ( " ; ; % s " , RelocInfo : : RelocModeName ( rmode ) ) ; <nl> + } <nl> + } <nl> + <nl> static int DecodeIt ( Isolate * isolate , std : : ostream * os , <nl> const V8NameConverter & converter , byte * begin , byte * end ) { <nl> SealHandleScope shs ( isolate ) ; <nl> static int DecodeIt ( Isolate * isolate , std : : ostream * os , <nl> / / Put together the reloc info <nl> RelocInfo relocinfo ( pcs [ i ] , rmodes [ i ] , datas [ i ] , converter . code ( ) ) ; <nl> <nl> - / / Indent the printing of the reloc info . <nl> - if ( i = = 0 ) { <nl> - / / The first reloc info is printed after the disassembled instruction . <nl> - out . AddPadding ( ' ' , kRelocInfoPosition - out . position ( ) ) ; <nl> - } else { <nl> - / / Additional reloc infos are printed on separate lines . <nl> - DumpBuffer ( os , & out ) ; <nl> - out . AddPadding ( ' ' , kRelocInfoPosition ) ; <nl> - } <nl> + bool first_reloc_info = ( i = = 0 ) ; <nl> + PrintRelocInfo ( & out , isolate , ref_encoder , os , & relocinfo , <nl> + first_reloc_info ) ; <nl> + } <nl> <nl> - RelocInfo : : Mode rmode = relocinfo . rmode ( ) ; <nl> - if ( rmode = = RelocInfo : : DEOPT_SCRIPT_OFFSET ) { <nl> - out . AddFormatted ( " ; ; debug : deopt position , script offset ' % d ' " , <nl> - static_cast < int > ( relocinfo . data ( ) ) ) ; <nl> - } else if ( rmode = = RelocInfo : : DEOPT_INLINING_ID ) { <nl> - out . AddFormatted ( " ; ; debug : deopt position , inlining id ' % d ' " , <nl> - static_cast < int > ( relocinfo . data ( ) ) ) ; <nl> - } else if ( rmode = = RelocInfo : : DEOPT_REASON ) { <nl> - DeoptimizeReason reason = <nl> - static_cast < DeoptimizeReason > ( relocinfo . data ( ) ) ; <nl> - out . AddFormatted ( " ; ; debug : deopt reason ' % s ' " , <nl> - DeoptimizeReasonToString ( reason ) ) ; <nl> - } else if ( rmode = = RelocInfo : : DEOPT_ID ) { <nl> - out . AddFormatted ( " ; ; debug : deopt index % d " , <nl> - static_cast < int > ( relocinfo . data ( ) ) ) ; <nl> - } else if ( rmode = = RelocInfo : : EMBEDDED_OBJECT ) { <nl> - HeapStringAllocator allocator ; <nl> - StringStream accumulator ( & allocator ) ; <nl> - relocinfo . target_object ( ) - > ShortPrint ( & accumulator ) ; <nl> - std : : unique_ptr < char [ ] > obj_name = accumulator . ToCString ( ) ; <nl> - out . AddFormatted ( " ; ; object : % s " , obj_name . get ( ) ) ; <nl> - } else if ( rmode = = RelocInfo : : EXTERNAL_REFERENCE ) { <nl> - const char * reference_name = ref_encoder . NameOfAddress ( <nl> - isolate , relocinfo . target_external_reference ( ) ) ; <nl> - out . AddFormatted ( " ; ; external reference ( % s ) " , reference_name ) ; <nl> - } else if ( RelocInfo : : IsCodeTarget ( rmode ) ) { <nl> - out . AddFormatted ( " ; ; code : " ) ; <nl> - Code * code = Code : : GetCodeFromTargetAddress ( relocinfo . target_address ( ) ) ; <nl> - Code : : Kind kind = code - > kind ( ) ; <nl> - if ( code - > is_inline_cache_stub ( ) ) { <nl> - out . AddFormatted ( " % s " , Code : : Kind2String ( kind ) ) ; <nl> - if ( kind = = Code : : BINARY_OP_IC | | kind = = Code : : TO_BOOLEAN_IC | | <nl> - kind = = Code : : COMPARE_IC ) { <nl> - InlineCacheState ic_state = IC : : StateFromCode ( code ) ; <nl> - out . AddFormatted ( " % s " , Code : : ICState2String ( ic_state ) ) ; <nl> + / / If this is a constant pool load and we haven ' t found any RelocInfo <nl> + / / already , check if we can find some RelocInfo for the target address in <nl> + / / the constant pool . <nl> + if ( pcs . is_empty ( ) & & converter . code ( ) ! = nullptr ) { <nl> + RelocInfo dummy_rinfo ( prev_pc , RelocInfo : : NONE32 , 0 , nullptr ) ; <nl> + if ( dummy_rinfo . IsInConstantPool ( ) ) { <nl> + byte * constant_pool_entry_address = <nl> + dummy_rinfo . constant_pool_entry_address ( ) ; <nl> + RelocIterator * it = new RelocIterator ( converter . code ( ) ) ; <nl> + while ( ! it - > done ( ) ) { <nl> + if ( it - > rinfo ( ) - > IsInConstantPool ( ) & & <nl> + ( it - > rinfo ( ) - > constant_pool_entry_address ( ) = = <nl> + constant_pool_entry_address ) ) { <nl> + PrintRelocInfo ( & out , isolate , ref_encoder , os , it - > rinfo ( ) ) ; <nl> + break ; <nl> } <nl> - } else if ( kind = = Code : : STUB | | kind = = Code : : HANDLER ) { <nl> - / / Get the STUB key and extract major and minor key . <nl> - uint32_t key = code - > stub_key ( ) ; <nl> - uint32_t minor_key = CodeStub : : MinorKeyFromKey ( key ) ; <nl> - CodeStub : : Major major_key = CodeStub : : GetMajorKey ( code ) ; <nl> - DCHECK ( major_key = = CodeStub : : MajorKeyFromKey ( key ) ) ; <nl> - out . AddFormatted ( " % s , % s , " , Code : : Kind2String ( kind ) , <nl> - CodeStub : : MajorName ( major_key ) ) ; <nl> - out . AddFormatted ( " minor : % d " , minor_key ) ; <nl> - } else { <nl> - out . AddFormatted ( " % s " , Code : : Kind2String ( kind ) ) ; <nl> + it - > next ( ) ; <nl> } <nl> - if ( rmode = = RelocInfo : : CODE_TARGET_WITH_ID ) { <nl> - out . AddFormatted ( " ( id = % d ) " , static_cast < int > ( relocinfo . data ( ) ) ) ; <nl> - } <nl> - } else if ( RelocInfo : : IsRuntimeEntry ( rmode ) & & <nl> - isolate - > deoptimizer_data ( ) ! = NULL ) { <nl> - / / A runtime entry reloinfo might be a deoptimization bailout . <nl> - Address addr = relocinfo . target_address ( ) ; <nl> - int id = Deoptimizer : : GetDeoptimizationId ( isolate , <nl> - addr , <nl> - Deoptimizer : : EAGER ) ; <nl> - if ( id = = Deoptimizer : : kNotDeoptimizationEntry ) { <nl> - id = Deoptimizer : : GetDeoptimizationId ( isolate , <nl> - addr , <nl> - Deoptimizer : : LAZY ) ; <nl> - if ( id = = Deoptimizer : : kNotDeoptimizationEntry ) { <nl> - id = Deoptimizer : : GetDeoptimizationId ( isolate , <nl> - addr , <nl> - Deoptimizer : : SOFT ) ; <nl> - if ( id = = Deoptimizer : : kNotDeoptimizationEntry ) { <nl> - out . AddFormatted ( " ; ; % s " , RelocInfo : : RelocModeName ( rmode ) ) ; <nl> - } else { <nl> - out . AddFormatted ( " ; ; soft deoptimization bailout % d " , id ) ; <nl> - } <nl> - } else { <nl> - out . AddFormatted ( " ; ; lazy deoptimization bailout % d " , id ) ; <nl> - } <nl> - } else { <nl> - out . AddFormatted ( " ; ; deoptimization bailout % d " , id ) ; <nl> - } <nl> - } else { <nl> - out . AddFormatted ( " ; ; % s " , RelocInfo : : RelocModeName ( rmode ) ) ; <nl> } <nl> } <nl> + <nl> DumpBuffer ( os , & out ) ; <nl> } <nl> <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> void Heap : : CreateFixedStubs ( ) { <nl> / / The eliminates the need for doing dictionary lookup in the <nl> / / stub cache for these stubs . <nl> HandleScope scope ( isolate ( ) ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( isolate ( ) ) ; <nl> <nl> / / Create stubs that should be there , so we don ' t unexpectedly have to <nl> / / create them if we need them during the creation of another stub . <nl> mmm a / src / interpreter / setup - interpreter - internal . cc <nl> ppp b / src / interpreter / setup - interpreter - internal . cc <nl> namespace interpreter { <nl> void SetupInterpreter : : InstallBytecodeHandlers ( Interpreter * interpreter ) { <nl> DCHECK ( ! interpreter - > IsDispatchTableInitialized ( ) ) ; <nl> HandleScope scope ( interpreter - > isolate_ ) ; <nl> + / / Canonicalize handles , so that we can share constant pool entries pointing <nl> + / / to code targets without dereferencing their handles . <nl> + CanonicalHandleScope canonical ( interpreter - > isolate_ ) ; <nl> Address * dispatch_table = interpreter - > dispatch_table_ ; <nl> <nl> / / Generate bytecode handlers for all bytecodes and scales . <nl> mmm a / tools / v8heapconst . py <nl> ppp b / tools / v8heapconst . py <nl> <nl> 0x03e31 : ( 188 , " ExternalMap " ) , <nl> 0x03e89 : ( 106 , " NativeSourceStringMap " ) , <nl> 0x03ee1 : ( 152 , " InterceptorInfoMap " ) , <nl> - 0x03f39 : ( 156 , " AllocationMementoMap " ) , <nl> - 0x03f91 : ( 204 , " JSPromiseCapabilityMap " ) , <nl> - 0x03fe9 : ( 149 , " AccessorInfoMap " ) , <nl> - 0x04041 : ( 150 , " AccessorPairMap " ) , <nl> - 0x04099 : ( 151 , " AccessCheckInfoMap " ) , <nl> - 0x040f1 : ( 153 , " FunctionTemplateInfoMap " ) , <nl> - 0x04149 : ( 154 , " ObjectTemplateInfoMap " ) , <nl> - 0x041a1 : ( 155 , " AllocationSiteMap " ) , <nl> + 0x03f39 : ( 204 , " JSPromiseCapabilityMap " ) , <nl> + 0x03f91 : ( 149 , " AccessorInfoMap " ) , <nl> + 0x03fe9 : ( 150 , " AccessorPairMap " ) , <nl> + 0x04041 : ( 151 , " AccessCheckInfoMap " ) , <nl> + 0x04099 : ( 153 , " FunctionTemplateInfoMap " ) , <nl> + 0x040f1 : ( 154 , " ObjectTemplateInfoMap " ) , <nl> + 0x04149 : ( 155 , " AllocationSiteMap " ) , <nl> + 0x041a1 : ( 156 , " AllocationMementoMap " ) , <nl> 0x041f9 : ( 158 , " AliasedArgumentsEntryMap " ) , <nl> 0x04251 : ( 159 , " PromiseResolveThenableJobInfoMap " ) , <nl> 0x042a9 : ( 160 , " PromiseReactionJobInfoMap " ) , <nl>
[ arm ] Share constant pool entries in snapshot .
v8/v8
c15b3ffc773ef7b14655b59b1ce1437de903fdc0
2017-05-23T18:30:32Z
mmm a / Marlin / src / gcode / feature / L6470 / M916 - 918 . cpp <nl> ppp b / Marlin / src / gcode / feature / L6470 / M916 - 918 . cpp <nl> <nl> <nl> / * * <nl> * <nl> - * M916 : increase KVAL_HOLD until get thermal warning <nl> + * M916 : Increase KVAL_HOLD until thermal warning <nl> * <nl> * <nl> * J - select which driver ( s ) to monitor on multi - driver axis <nl> mmm a / Marlin / src / gcode / gcode . h <nl> ppp b / Marlin / src / gcode / gcode . h <nl> <nl> * M42 - Change pin status via gcode : M42 P < pin > S < value > . LED pin assumed if P is omitted . <nl> * M43 - Display pin status , watch pins for changes , watch endstops & toggle LED , Z servo probe test , toggle pins <nl> * M48 - Measure Z Probe repeatability : M48 P < points > X < pos > Y < pos > V < level > E < engage > L < legs > S < chizoid > . ( Requires Z_MIN_PROBE_REPEATABILITY_TEST ) <nl> + * M73 - Set the progress percentage . ( Requires LCD_SET_PROGRESS_MANUALLY ) <nl> * M75 - Start the print job timer . <nl> * M76 - Pause the print job timer . <nl> * M77 - Stop the print job timer . <nl> <nl> * M106 - Set print fan speed . <nl> * M107 - Print fan off . <nl> * M108 - Break out of heating loops ( M109 , M190 , M303 ) . With no controller , breaks out of M0 / M1 . ( Requires EMERGENCY_PARSER ) <nl> - * M109 - Sxxx Wait for extruder current temp to reach target temp . Waits only when heating <nl> - * Rxxx Wait for extruder current temp to reach target temp . Waits when heating and cooling <nl> + * M109 - S < temp > Wait for extruder current temp to reach target temp . * * Wait only when heating ! * * <nl> + * R < temp > Wait for extruder current temp to reach target temp . * * Wait for heating or cooling . * * <nl> * If AUTOTEMP is enabled , S < mintemp > B < maxtemp > F < factor > . Exit autotemp by any M109 without F <nl> * M110 - Set the current line number . ( Used by host printing ) <nl> * M111 - Set debug flags : " M111 S < flagbits > " . See flag bits defined in enum . h . <nl> <nl> * M119 - Report endstops status . <nl> * M120 - Enable endstops detection . <nl> * M121 - Disable endstops detection . <nl> - * M122 - Debug stepper ( Requires at least one _DRIVER_TYPE defined as TMC2130 / TMC2208 / TMC2660 ) <nl> + * M122 - Debug stepper ( Requires at least one _DRIVER_TYPE defined as TMC2130 / TMC2208 / TMC2660 or L6470 ) <nl> * M125 - Save current position and move to filament change position . ( Requires PARK_HEAD_ON_PAUSE ) <nl> * M126 - Solenoid Air Valve Open . ( Requires BARICUDA ) <nl> * M127 - Solenoid Air Valve Closed . ( Requires BARICUDA ) <nl> * M128 - EtoP Open . ( Requires BARICUDA ) <nl> * M129 - EtoP Closed . ( Requires BARICUDA ) <nl> * M140 - Set bed target temp . S < temp > <nl> + * M141 - Set heated chamber target temp . S < temp > ( Requires a chamber heater ) <nl> * M145 - Set heatup values for materials on the LCD . H < hotend > B < bed > F < fan speed > for S < material > ( 0 = PLA , 1 = ABS ) <nl> * M149 - Set temperature units . ( Requires TEMPERATURE_UNITS_SUPPORT ) <nl> * M150 - Set Status LED Color as R < red > U < green > B < blue > P < bright > . Values 0 - 255 . ( Requires BLINKM , RGB_LED , RGBW_LED , NEOPIXEL_LED , PCA9533 , or PCA9632 ) . <nl> <nl> * M164 - Commit the mix and save to a virtual tool ( current , or as specified by ' S ' ) . ( Requires MIXING_EXTRUDER ) <nl> * M165 - Set the mix for the mixing extruder ( and current virtual tool ) with parameters ABCDHI . ( Requires MIXING_EXTRUDER and DIRECT_MIXING_IN_G1 ) <nl> * M166 - Set the Gradient Mix for the mixing extruder . ( Requires GRADIENT_MIX ) <nl> - * M190 - Sxxx Wait for bed current temp to reach target temp . * * Waits only when heating ! * * <nl> - * Rxxx Wait for bed current temp to reach target temp . * * Waits for heating or cooling . * * <nl> + * M190 - S < temp > Wait for bed current temp to reach target temp . * * Wait only when heating ! * * <nl> + * R < temp > Wait for bed current temp to reach target temp . * * Wait for heating or cooling . * * <nl> * M200 - Set filament diameter , D < diameter > , setting E axis units to cubic . ( Use S0 to revert to linear units . ) <nl> * M201 - Set max acceleration in units / s ^ 2 for print moves : " M201 X < accel > Y < accel > Z < accel > E < accel > " <nl> * M202 - Set max acceleration in units / s ^ 2 for travel moves : " M202 X < accel > Y < accel > Z < accel > E < accel > " * * UNUSED IN MARLIN ! * * <nl> <nl> * M501 - Restore parameters from EEPROM . ( Requires EEPROM_SETTINGS ) <nl> * M502 - Revert to the default " factory settings " . * * Does not write them to EEPROM ! * * <nl> * M503 - Print the current settings ( in memory ) : " M503 S < verbose > " . S0 specifies compact output . <nl> + * M504 - Validate EEPROM contents . ( Requires EEPROM_SETTINGS ) <nl> * M524 - Abort the current SD print job ( started with M24 ) <nl> * M540 - Enable / disable SD card abort on endstop hit : " M540 S < state > " . ( Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ) <nl> - * M569 - Enable stealthChop on an axis . ( Requires at least one # _X_DRIVER_TYPE to be TMC2130 or TMC2208 ) <nl> + * M569 - Enable stealthChop on an axis . ( Requires at least one _DRIVER_TYPE to be TMC2130 or TMC2208 ) <nl> * M600 - Pause for filament change : " M600 X < pos > Y < pos > Z < raise > E < first_retract > L < later_retract > " . ( Requires ADVANCED_PAUSE_FEATURE ) <nl> * M603 - Configure filament change : " M603 T < tool > U < unload_length > L < load_length > " . ( Requires ADVANCED_PAUSE_FEATURE ) <nl> * M605 - Set Dual X - Carriage movement mode : " M605 S < mode > [ X < x_offset > ] [ R < temp_offset > ] " . ( Requires DUAL_X_CARRIAGE ) <nl> <nl> * M867 - Enable / disable or toggle error correction for position encoder modules . <nl> * M868 - Report or set position encoder module error correction threshold . <nl> * M869 - Report position encoder module error . <nl> + * M876 - Handle Prompt Response . ( Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER ) <nl> * M900 - Get or Set Linear Advance K - factor . ( Requires LIN_ADVANCE ) <nl> - * M906 - Set or get motor current in milliamps using axis codes X , Y , Z , E . Report values if no axis codes given . ( Requires at least one _DRIVER_TYPE defined as TMC2130 / TMC2208 / TMC2660 ) <nl> + * M906 - Set or get motor current in milliamps using axis codes X , Y , Z , E . Report values if no axis codes given . ( Requires at least one _DRIVER_TYPE defined as TMC2130 / TMC2208 / TMC2660 or L6470 ) <nl> * M907 - Set digital trimpot motor current using axis codes . ( Requires a board with digital trimpots ) <nl> * M908 - Control digital trimpot directly . ( Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN ) <nl> * M909 - Print digipot / DAC current value . ( Requires DAC_STEPPER_CURRENT ) <nl> <nl> * M912 - Clear stepper driver overtemperature pre - warn condition flag . ( Requires at least one _DRIVER_TYPE defined as TMC2130 / TMC2208 / TMC2660 ) <nl> * M913 - Set HYBRID_THRESHOLD speed . ( Requires HYBRID_THRESHOLD ) <nl> * M914 - Set StallGuard sensitivity . ( Requires SENSORLESS_HOMING or SENSORLESS_PROBING ) <nl> - * M917 - L6470 tuning : Find minimum current thresholds <nl> - * M918 - L6470 tuning : Increase speed until max or error <nl> + * M916 - L6470 tuning : Increase KVAL_HOLD until thermal warning . ( Requires at least one _DRIVER_TYPE L6470 ) <nl> + * M917 - L6470 tuning : Find minimum current thresholds . ( Requires at least one _DRIVER_TYPE L6470 ) <nl> + * M918 - L6470 tuning : Increase speed until max or error . ( Requires at least one _DRIVER_TYPE L6470 ) <nl> * M951 - Set Magnetic Parking Extruder parameters . ( Requires MAGNETIC_PARKING_EXTRUDER ) <nl> + * M7219 - Control Max7219 Matrix LEDs . ( Requires MAX7219_GCODE ) <nl> * <nl> * M360 - SCARA calibration : Move to cal - position ThetaA ( 0 deg calibration ) <nl> * M361 - SCARA calibration : Move to cal - position ThetaB ( 90 deg calibration - steps per degree ) <nl> <nl> * M364 - SCARA calibration : Move to cal - position PSIC ( 90 deg to Theta calibration position ) <nl> * <nl> * * * * * * * * * * * * * Custom codes - This can change to suit future G - code regulations <nl> + * G425 - Calibrate using a conductive object . ( Requires CALIBRATION_GCODE ) <nl> * M928 - Start SD logging : " M928 filename . gco " . Stop with M29 . ( Requires SDSUPPORT ) <nl> * M997 - Perform in - application firmware update <nl> * M999 - Restart after being stopped by error <nl> class GcodeSuite { <nl> static void M702 ( ) ; <nl> # endif <nl> <nl> - # if ENABLED ( MAX7219_GCODE ) <nl> - static void M7219 ( ) ; <nl> - # endif <nl> - <nl> # if ENABLED ( GCODE_MACROS ) <nl> static void M810_819 ( ) ; <nl> # endif <nl> class GcodeSuite { <nl> static void M1000 ( ) ; <nl> # endif <nl> <nl> + # if ENABLED ( MAX7219_GCODE ) <nl> + static void M7219 ( ) ; <nl> + # endif <nl> + <nl> static void T ( const uint8_t tool_index ) ; <nl> <nl> } ; <nl>
Some documentation updates
MarlinFirmware/Marlin
fc52c43a26f6a56f04f4968c8fdf3e910226749e
2019-05-24T21:30:44Z
mmm a / graph / connected_components . cpp <nl> ppp b / graph / connected_components . cpp <nl> <nl> * < pre > <nl> * Example - Here is graph with 3 connected components <nl> * <nl> - * 3 9 6 8 <nl> + * 1 4 5 8 <nl> * / \ / / \ / \ <nl> - * 2mmm4 2 7 3 7 <nl> + * 2mmm3 6 7 9 10 <nl> * <nl> * first second third <nl> * component component component <nl> <nl> * / <nl> <nl> # include < algorithm > <nl> + # include < cassert > <nl> # include < iostream > <nl> # include < vector > <nl> <nl> - using std : : vector ; <nl> - <nl> / * * <nl> - * Class for representing graph as a adjacency list . <nl> + * @ namespace graph <nl> + * @ brief Graph Algorithms <nl> * / <nl> - class graph { <nl> - private : <nl> - / * * \ brief adj stores adjacency list representation of graph * / <nl> - vector < vector < int > > adj ; <nl> - <nl> - / * * \ brief keep track of connected components * / <nl> - int connected_components ; <nl> - <nl> - void depth_first_search ( ) ; <nl> - void explore ( int , vector < bool > & ) ; <nl> - <nl> - public : <nl> - / * * <nl> - * \ brief Constructor that intiliazes the graph on creation and set <nl> - * the connected components to 0 <nl> - * / <nl> - explicit graph ( int n ) : adj ( n , vector < int > ( ) ) { connected_components = 0 ; } <nl> - <nl> - void addEdge ( int , int ) ; <nl> - <nl> - / * * <nl> - * \ brief Function the calculates the connected compoents in the graph <nl> - * by performing the depth first search on graph <nl> - * <nl> - * @ return connected_components total connected components in graph <nl> - * / <nl> - int getConnectedComponents ( ) { <nl> - depth_first_search ( ) ; <nl> - return connected_components ; <nl> - } <nl> - } ; <nl> <nl> + namespace graph { <nl> / * * <nl> - * \ brief Function that add edge between two nodes or vertices of graph <nl> + * @ brief Function that add edge between two nodes or vertices of graph <nl> * <nl> - * @ param u any node or vertex of graph <nl> - * @ param v any node or vertex of graph <nl> + * @ param adj adjacency list of graph . <nl> + * @ param u any node or vertex of graph . <nl> + * @ param v any node or vertex of graph . <nl> * / <nl> - void graph : : addEdge ( int u , int v ) { <nl> - adj [ u - 1 ] . push_back ( v - 1 ) ; <nl> - adj [ v - 1 ] . push_back ( u - 1 ) ; <nl> + void addEdge ( std : : vector < std : : vector < int > > * adj , int u , int v ) { <nl> + ( * adj ) [ u - 1 ] . push_back ( v - 1 ) ; <nl> + ( * adj ) [ v - 1 ] . push_back ( u - 1 ) ; <nl> } <nl> <nl> / * * <nl> - * \ brief Function that perfoms depth first search algorithm on graph <nl> + * @ brief Utility function for depth first seach algorithm <nl> + * this function explores the vertex which is passed into . <nl> + * <nl> + * @ param adj adjacency list of graph . <nl> + * @ param u vertex or node to be explored . <nl> + * @ param visited already visited vertices . <nl> * / <nl> - void graph : : depth_first_search ( ) { <nl> - int n = adj . size ( ) ; <nl> - vector < bool > visited ( n , false ) ; <nl> - <nl> - for ( int i = 0 ; i < n ; i + + ) { <nl> - if ( ! visited [ i ] ) { <nl> - explore ( i , visited ) ; <nl> - connected_components + + ; <nl> + void explore ( const std : : vector < std : : vector < int > > * adj , int u , <nl> + std : : vector < bool > * visited ) { <nl> + ( * visited ) [ u ] = true ; <nl> + for ( auto v : ( * adj ) [ u ] ) { <nl> + if ( ! ( * visited ) [ v ] ) { <nl> + explore ( adj , v , visited ) ; <nl> } <nl> } <nl> } <nl> + <nl> / * * <nl> - * \ brief Utility function for depth first seach algorithm <nl> - * this function explores the vertex which is passed into . <nl> + * @ brief Function that perfoms depth first search algorithm on graph <nl> + * and calculated the number of connected components . <nl> + * <nl> + * @ param adj adjacency list of graph . <nl> * <nl> - * @ param u vertex or node to be explored <nl> - * @ param visited already visited vertex <nl> + * @ return connected_components number of connected components in graph . <nl> * / <nl> - void graph : : explore ( int u , vector < bool > & visited ) { <nl> - visited [ u ] = true ; <nl> - for ( auto v : adj [ u ] ) { <nl> - if ( ! visited [ v ] ) { <nl> - explore ( v , visited ) ; <nl> + int getConnectedComponents ( const std : : vector < std : : vector < int > > * adj ) { <nl> + int n = adj - > size ( ) ; <nl> + int connected_components = 0 ; <nl> + std : : vector < bool > visited ( n , false ) ; <nl> + <nl> + for ( int i = 0 ; i < n ; i + + ) { <nl> + if ( ! visited [ i ] ) { <nl> + explore ( adj , i , & visited ) ; <nl> + connected_components + + ; <nl> } <nl> } <nl> + return connected_components ; <nl> + } <nl> + } / / namespace graph <nl> + <nl> + / * * Function to test the algorithm * / <nl> + void tests ( ) { <nl> + std : : cout < < " Running predefined tests . . . " < < std : : endl ; <nl> + std : : cout < < " Initiating Test 1 . . . " < < std : : endl ; <nl> + std : : vector < std : : vector < int > > adj1 ( 9 , std : : vector < int > ( ) ) ; <nl> + graph : : addEdge ( & adj1 , 1 , 2 ) ; <nl> + graph : : addEdge ( & adj1 , 1 , 3 ) ; <nl> + graph : : addEdge ( & adj1 , 3 , 4 ) ; <nl> + graph : : addEdge ( & adj1 , 5 , 7 ) ; <nl> + graph : : addEdge ( & adj1 , 5 , 6 ) ; <nl> + graph : : addEdge ( & adj1 , 8 , 9 ) ; <nl> + <nl> + assert ( graph : : getConnectedComponents ( & adj1 ) = = 3 ) ; <nl> + std : : cout < < " Test 1 Passed . . . " < < std : : endl ; <nl> + <nl> + std : : cout < < " Innitiating Test 2 . . . " < < std : : endl ; <nl> + std : : vector < std : : vector < int > > adj2 ( 10 , std : : vector < int > ( ) ) ; <nl> + graph : : addEdge ( & adj2 , 1 , 2 ) ; <nl> + graph : : addEdge ( & adj2 , 1 , 3 ) ; <nl> + graph : : addEdge ( & adj2 , 1 , 4 ) ; <nl> + graph : : addEdge ( & adj2 , 2 , 3 ) ; <nl> + graph : : addEdge ( & adj2 , 3 , 4 ) ; <nl> + graph : : addEdge ( & adj2 , 4 , 8 ) ; <nl> + graph : : addEdge ( & adj2 , 4 , 10 ) ; <nl> + graph : : addEdge ( & adj2 , 8 , 10 ) ; <nl> + graph : : addEdge ( & adj2 , 8 , 9 ) ; <nl> + graph : : addEdge ( & adj2 , 5 , 7 ) ; <nl> + graph : : addEdge ( & adj2 , 5 , 6 ) ; <nl> + graph : : addEdge ( & adj2 , 6 , 7 ) ; <nl> + <nl> + assert ( graph : : getConnectedComponents ( & adj2 ) = = 2 ) ; <nl> + std : : cout < < " Test 2 Passed . . . " < < std : : endl ; <nl> } <nl> <nl> / * * Main function * / <nl> int main ( ) { <nl> - / / / creating a graph with 4 vertex <nl> - graph g ( 4 ) ; <nl> + / / / running predefined tests <nl> + tests ( ) ; <nl> <nl> - / / / Adding edges between vertices <nl> - g . addEdge ( 1 , 2 ) ; <nl> - g . addEdge ( 3 , 2 ) ; <nl> + int vertices = int ( ) , edges = int ( ) ; <nl> + std : : cout < < " Enter the number of vertices : " ; <nl> + std : : cin > > vertices ; <nl> + std : : cout < < " Enter the number of edges : " ; <nl> + std : : cin > > edges ; <nl> + <nl> + std : : vector < std : : vector < int > > adj ( vertices , std : : vector < int > ( ) ) ; <nl> + <nl> + int u = int ( ) , v = int ( ) ; <nl> + while ( edges - - ) { <nl> + std : : cin > > u > > v ; <nl> + graph : : addEdge ( & adj , u , v ) ; <nl> + } <nl> <nl> - / / / printing the connected components <nl> - std : : cout < < g . getConnectedComponents ( ) ; <nl> + int cc = graph : : getConnectedComponents ( & adj ) ; <nl> + std : : cout < < cc < < std : : endl ; <nl> return 0 ; <nl> } <nl>
fix : linter for connected_components .
TheAlgorithms/C-Plus-Plus
2c41598e379f746dc91bd28d8a64c8c3e7bcf839
2020-08-15T22:57:45Z
mmm a / Math / Math / GPUMatrix . cu <nl> ppp b / Math / Math / GPUMatrix . cu <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> template < class ElemType > <nl> GPUMatrix < ElemType > & GPUMatrix < ElemType > : : InplaceTruncateBottom ( const ElemType threshold ) <nl> { <nl> - if ( IsEmpty ( ) ) <nl> - LogicError ( " InplaceTruncateBottom : Matrix is empty . " ) ; <nl> - <nl> - CUDA_LONG N = ( CUDA_LONG ) GetNumElements ( ) ; <nl> - int blocksPerGrid = ( int ) ceil ( N * 1 . 0 / threadsPerBlock ) ; <nl> - PrepareDevice ( ) ; <nl> - cudaEvent_t done = nullptr ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventCreate ( & done ) ) ; <nl> - _assignTruncateBottom < ElemType > < < < blocksPerGrid , threadsPerBlock , 0 , t_stream > > > ( m_pArray , m_pArray , threshold , N ) ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventRecord ( done ) ) ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventSynchronize ( done ) ) ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventDestroy ( done ) ) ; <nl> - return * this ; <nl> + return AssignTruncateBottomOf ( * this , threshold ) ; <nl> } <nl> <nl> template < class ElemType > <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> template < class ElemType > <nl> GPUMatrix < ElemType > & GPUMatrix < ElemType > : : InplaceTruncateTop ( const ElemType threshold ) <nl> { <nl> - if ( IsEmpty ( ) ) <nl> - LogicError ( " InplaceTruncateTop : Matrix is empty . " ) ; <nl> - CUDA_LONG N = ( CUDA_LONG ) GetNumElements ( ) ; <nl> - int blocksPerGrid = ( int ) ceil ( N * 1 . 0 / threadsPerBlock ) ; <nl> - PrepareDevice ( ) ; <nl> - cudaEvent_t done = nullptr ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventCreate ( & done ) ) ; <nl> - _assignTruncateTop < ElemType > < < < blocksPerGrid , threadsPerBlock , 0 , t_stream > > > ( m_pArray , m_pArray , threshold , N ) ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventRecord ( done ) ) ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventSynchronize ( done ) ) ; <nl> - if ( do_sync ) CUDA_CALL ( cudaEventDestroy ( done ) ) ; <nl> - return * this ; <nl> + return AssignTruncateTopOf ( * this , threshold ) ; <nl> } <nl> <nl> template < class ElemType > <nl>
CUDA removing redundant code in GPUMatrix : : InplaceTruncate * ( )
microsoft/CNTK
83c94b02ffef524538882e5c9426bb95811d4c7d
2015-12-14T03:44:22Z
mmm a / src / google / protobuf / compiler / command_line_interface_unittest . cc <nl> ppp b / src / google / protobuf / compiler / command_line_interface_unittest . cc <nl> void CommandLineInterfaceTest : : Run ( const string & command ) { <nl> <nl> if ( ! disallow_plugins_ ) { <nl> cli_ . AllowPlugins ( " prefix - " ) ; <nl> + # ifndef GOOGLE_THIRD_PARTY_PROTOBUF <nl> const char * possible_paths [ ] = { <nl> / / When building with shared libraries , libtool hides the real executable <nl> / / in . libs and puts a fake wrapper in the current directory . <nl> void CommandLineInterfaceTest : : Run ( const string & command ) { <nl> } <nl> <nl> if ( plugin_path . empty ( ) ) { <nl> + # else <nl> + string plugin_path = " third_party / protobuf / test_plugin " ; <nl> + <nl> + if ( access ( plugin_path . c_str ( ) , F_OK ) ! = 0 ) { <nl> + # endif / / GOOGLE_THIRD_PARTY_PROTOBUF <nl> GOOGLE_LOG ( ERROR ) <nl> < < " Plugin executable not found . Plugin tests are likely to fail . " ; <nl> } else { <nl> mmm a / src / google / protobuf / testing / googletest . cc <nl> ppp b / src / google / protobuf / testing / googletest . cc <nl> namespace protobuf { <nl> # endif <nl> <nl> string TestSourceDir ( ) { <nl> + # ifndef GOOGLE_THIRD_PARTY_PROTOBUF <nl> # ifdef _MSC_VER <nl> / / Look for the " src " directory . <nl> string prefix = " . " ; <nl> string TestSourceDir ( ) { <nl> return result ; <nl> } <nl> # endif <nl> + # else <nl> + return " third_party / protobuf / src " ; <nl> + # endif / / GOOGLE_THIRD_PARTY_PROTOBUF <nl> } <nl> <nl> namespace { <nl>
Modify directory to use in test
protocolbuffers/protobuf
46bd60b92f593a62e150c93cb8761148f6830b47
2015-04-28T00:44:45Z
mmm a / Telegram / SourceFiles / boxes / send_files_box . cpp <nl> ppp b / Telegram / SourceFiles / boxes / send_files_box . cpp <nl> void SendFilesBox : : setupShadows ( <nl> } <nl> <nl> void SendFilesBox : : prepare ( ) { <nl> - _send = addButton ( <nl> - ( _sendType = = Api : : SendType : : Normal <nl> - ? tr : : lng_send_button ( ) <nl> - : tr : : lng_schedule_button ( ) ) , <nl> - [ = ] { send ( { } ) ; } ) ; <nl> + _send = addButton ( tr : : lng_send_button ( ) , [ = ] { send ( { } ) ; } ) ; <nl> if ( _sendType = = Api : : SendType : : Normal ) { <nl> SetupSendMenuAndShortcuts ( <nl> _send , <nl> void SendFilesBox : : prepare ( ) { <nl> } <nl> } , lifetime ( ) ) ; <nl> <nl> - const auto title = tr : : lng_stickers_featured_add ( tr : : now ) + qsl ( " . . . " ) ; <nl> _addFileToAlbum = addLeftButton ( <nl> - rpl : : single ( title ) , <nl> + tr : : lng_stickers_featured_add ( ) , <nl> App : : LambdaDelayed ( st : : historyAttach . ripple . hideDuration , this , [ = ] { <nl> openDialogToAddFileToAlbum ( ) ; <nl> } ) ) ; <nl>
Changed button names in SendFilesBox .
telegramdesktop/tdesktop
1c77b9c16fd24e573e5fec60bdf3c73b21ed0ec5
2020-06-05T15:46:32Z
mmm a / tensorflow / python / keras / layers / BUILD <nl> ppp b / tensorflow / python / keras / layers / BUILD <nl> tf_py_test ( <nl> srcs = [ " convolutional_recurrent_test . py " ] , <nl> python_version = " PY3 " , <nl> shard_count = 8 , <nl> + tags = [ " no_rocm " ] , <nl> deps = [ <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python / keras " , <nl> mmm a / tensorflow / python / keras / layers / preprocessing / BUILD <nl> ppp b / tensorflow / python / keras / layers / preprocessing / BUILD <nl> tf_py_test ( <nl> size = " small " , <nl> srcs = [ " discretization_test . py " ] , <nl> python_version = " PY3 " , <nl> + tags = [ " no_rocm " ] , <nl> deps = [ <nl> " : discretization " , <nl> " : preprocessing_test_utils " , <nl> mmm a / tensorflow / python / keras / mixed_precision / experimental / BUILD <nl> ppp b / tensorflow / python / keras / mixed_precision / experimental / BUILD <nl> py_test ( <nl> srcs = [ " layer_correctness_test . py " ] , <nl> python_version = " PY3 " , <nl> shard_count = 10 , <nl> + tags = [ " no_rocm " ] , <nl> deps = [ <nl> " / / tensorflow / python : client_testlib " , <nl> " / / tensorflow / python / compat : v2_compat " , <nl> mmm a / tensorflow / python / kernel_tests / BUILD <nl> ppp b / tensorflow / python / kernel_tests / BUILD <nl> tf_py_test ( <nl> name = " fifo_queue_test " , <nl> size = " small " , <nl> srcs = [ " fifo_queue_test . py " ] , <nl> + tags = [ " no_rocm " ] , <nl> deps = [ <nl> " / / tensorflow / core : protos_all_py " , <nl> " / / tensorflow / python : array_ops " , <nl>
[ ROCm ] Adding no_rocm tag to tests currently failing on ROCm platform
tensorflow/tensorflow
5f253f4dc10b5d27865d5de25eaa8a4dbff2cead
2020-04-28T00:47:32Z
mmm a / js / actions / api - cluster . js <nl> ppp b / js / actions / api - cluster . js <nl> var cluster = require ( " org / arangodb / cluster " ) ; <nl> var internal = require ( " internal " ) ; <nl> var console = require ( " console " ) ; <nl> <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - private functions <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - public functions <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> actions . defineHttp ( { <nl> } <nl> } ) ; <nl> <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ } <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl>
cosmetics
arangodb/arangodb
3608301be21dcea3c9cd2125054fa60990914a23
2014-05-04T13:27:34Z
mmm a / cocos / platform / android / java / project . properties <nl> ppp b / cocos / platform / android / java / project . properties <nl> <nl> <nl> android . library = true <nl> # Project target . <nl> - target = android - 19 <nl> + target = android - 10 <nl> mmm a / tests / cpp - empty - test / proj . android / project . properties <nl> ppp b / tests / cpp - empty - test / proj . android / project . properties <nl> <nl> # project structure . <nl> <nl> # Project target . <nl> - target = android - 19 <nl> + target = android - 10 <nl> <nl> android . library . reference . 1 = . . / . . / . . / cocos / platform / android / java <nl>
reverse target = android - 10 on android
cocos2d/cocos2d-x
af0c9ce2fafcb031e9a7fe260264789c66d7a82e
2014-09-25T08:54:33Z
mmm a / xbmc / FileSystem / File . cpp <nl> ppp b / xbmc / FileSystem / File . cpp <nl> bool CFile : : Open ( const CStdString & strFileName , unsigned int flags ) <nl> return false ; <nl> } <nl> <nl> - if ( ( flags & READ_NO_CACHE ) = = 0 & & CUtil : : IsRemote ( strFileName ) & & ! CUtil : : IsPicture ( strFileName ) ) <nl> + if ( ( flags & READ_NO_CACHE ) = = 0 & & CUtil : : IsInternetStream ( strFileName , true ) & & ! CUtil : : IsPicture ( strFileName ) ) <nl> m_flags | = READ_CACHED ; <nl> <nl> CURL url ( strFileName ) ; <nl>
reverted : Part of r31660 ( Use READ_CACHE for all remote files ) until we ' ve sorted out the best approach
xbmc/xbmc
073828985900db2e3b0d02ad92908beaebdeddcf
2010-07-09T08:01:13Z
mmm a / src / hydrogen . cc <nl> ppp b / src / hydrogen . cc <nl> void HSubgraph : : AppendJoin ( HSubgraph * then_graph , <nl> } <nl> <nl> <nl> - void HSubgraph : : ResolveContinue ( IterationStatement * statement ) { <nl> - HBasicBlock * continue_block = BundleContinue ( statement ) ; <nl> + void HSubgraph : : ResolveContinue ( IterationStatement * statement , <nl> + HBasicBlock * continue_block ) { <nl> if ( continue_block ! = NULL ) { <nl> - exit_block_ = JoinBlocks ( exit_block ( ) , <nl> - continue_block , <nl> - statement - > ContinueId ( ) ) ; <nl> + continue_block - > SetJoinId ( statement - > ContinueId ( ) ) ; <nl> } <nl> - } <nl> - <nl> - <nl> - HBasicBlock * HSubgraph : : BundleBreak ( BreakableStatement * statement ) { <nl> - return BundleBreakContinue ( statement , false , statement - > ExitId ( ) ) ; <nl> - } <nl> - <nl> - <nl> - HBasicBlock * HSubgraph : : BundleContinue ( IterationStatement * statement ) { <nl> - return BundleBreakContinue ( statement , true , statement - > ContinueId ( ) ) ; <nl> - } <nl> - <nl> - <nl> - HBasicBlock * HSubgraph : : BundleBreakContinue ( BreakableStatement * statement , <nl> - bool is_continue , <nl> - int join_id ) { <nl> - HBasicBlock * result = NULL ; <nl> - const ZoneList < BreakContinueInfo * > * infos = break_continue_info ( ) ; <nl> - for ( int i = 0 ; i < infos - > length ( ) ; + + i ) { <nl> - BreakContinueInfo * info = infos - > at ( i ) ; <nl> - if ( info - > is_continue ( ) = = is_continue & & <nl> - info - > target ( ) = = statement & & <nl> - ! info - > IsResolved ( ) ) { <nl> - if ( result = = NULL ) { <nl> - result = graph_ - > CreateBasicBlock ( ) ; <nl> - } <nl> - info - > block ( ) - > Goto ( result ) ; <nl> - info - > Resolve ( ) ; <nl> - } <nl> - } <nl> - <nl> - if ( result ! = NULL ) result - > SetJoinId ( join_id ) ; <nl> - <nl> - return result ; <nl> + exit_block_ = <nl> + JoinBlocks ( exit_block ( ) , continue_block , statement - > ContinueId ( ) ) ; <nl> } <nl> <nl> <nl> HBasicBlock * HSubgraph : : JoinBlocks ( HBasicBlock * a , HBasicBlock * b , int id ) { <nl> } <nl> <nl> <nl> - void HSubgraph : : AppendEndless ( HSubgraph * body , IterationStatement * statement ) { <nl> + void HSubgraph : : AppendEndless ( HSubgraph * body , <nl> + IterationStatement * statement , <nl> + HBasicBlock * break_block ) { <nl> ConnectExitTo ( body - > entry_block ( ) ) ; <nl> - body - > ResolveContinue ( statement ) ; <nl> body - > ConnectExitTo ( body - > entry_block ( ) , true ) ; <nl> - exit_block_ = body - > BundleBreak ( statement ) ; <nl> + if ( break_block ! = NULL ) break_block - > SetJoinId ( statement - > ExitId ( ) ) ; <nl> + exit_block_ = break_block ; <nl> body - > entry_block ( ) - > PostProcessLoopHeader ( statement ) ; <nl> } <nl> <nl> void HSubgraph : : AppendEndless ( HSubgraph * body , IterationStatement * statement ) { <nl> void HSubgraph : : AppendDoWhile ( HSubgraph * body , <nl> IterationStatement * statement , <nl> HSubgraph * go_back , <nl> - HSubgraph * exit ) { <nl> + HSubgraph * exit , <nl> + HBasicBlock * break_block ) { <nl> ConnectExitTo ( body - > entry_block ( ) ) ; <nl> go_back - > ConnectExitTo ( body - > entry_block ( ) , true ) ; <nl> - <nl> - HBasicBlock * break_block = body - > BundleBreak ( statement ) ; <nl> + if ( break_block ! = NULL ) break_block - > SetJoinId ( statement - > ExitId ( ) ) ; <nl> exit_block_ = <nl> JoinBlocks ( exit - > exit_block ( ) , break_block , statement - > ExitId ( ) ) ; <nl> body - > entry_block ( ) - > PostProcessLoopHeader ( statement ) ; <nl> void HSubgraph : : AppendWhile ( HSubgraph * condition , <nl> HSubgraph * body , <nl> IterationStatement * statement , <nl> HSubgraph * continue_subgraph , <nl> - HSubgraph * exit ) { <nl> + HSubgraph * exit , <nl> + HBasicBlock * break_block ) { <nl> ConnectExitTo ( condition - > entry_block ( ) ) ; <nl> <nl> - HBasicBlock * break_block = body - > BundleBreak ( statement ) ; <nl> + if ( break_block ! = NULL ) break_block - > SetJoinId ( statement - > ExitId ( ) ) ; <nl> exit_block_ = <nl> JoinBlocks ( exit - > exit_block ( ) , break_block , statement - > ExitId ( ) ) ; <nl> <nl> void HSubgraph : : AppendWhile ( HSubgraph * condition , <nl> } <nl> <nl> <nl> - void HSubgraph : : Append ( HSubgraph * next , BreakableStatement * stmt ) { <nl> + void HSubgraph : : Append ( HSubgraph * next , <nl> + BreakableStatement * stmt , <nl> + HBasicBlock * break_block ) { <nl> exit_block_ - > Goto ( next - > entry_block ( ) ) ; <nl> exit_block_ = next - > exit_block_ ; <nl> <nl> if ( stmt ! = NULL ) { <nl> next - > entry_block ( ) - > SetJoinId ( stmt - > EntryId ( ) ) ; <nl> - HBasicBlock * break_block = next - > BundleBreak ( stmt ) ; <nl> + if ( break_block ! = NULL ) break_block - > SetJoinId ( stmt - > EntryId ( ) ) ; <nl> exit_block_ = JoinBlocks ( exit_block ( ) , break_block , stmt - > ExitId ( ) ) ; <nl> } <nl> } <nl> void HSubgraph : : FinishExit ( HControlInstruction * instruction ) { <nl> } <nl> <nl> <nl> - void HSubgraph : : FinishBreakContinue ( BreakableStatement * target , <nl> - bool is_continue ) { <nl> - ASSERT ( ! exit_block_ - > IsFinished ( ) ) ; <nl> - BreakContinueInfo * info = new BreakContinueInfo ( target , exit_block_ , <nl> - is_continue ) ; <nl> - break_continue_info_ . Add ( info ) ; <nl> - exit_block_ = NULL ; <nl> - } <nl> - <nl> - <nl> HGraph : : HGraph ( CompilationInfo * info ) <nl> : HSubgraph ( this ) , <nl> next_block_id_ ( 0 ) , <nl> class HGraphBuilder : : SubgraphScope BASE_EMBEDDED { <nl> } <nl> <nl> ~ SubgraphScope ( ) { <nl> - old_subgraph_ - > AddBreakContinueInfo ( subgraph_ ) ; <nl> builder_ - > current_subgraph_ = old_subgraph_ ; <nl> } <nl> <nl> HGraph * HGraphBuilder : : CreateGraph ( CompilationInfo * info ) { <nl> HSubgraph * body = CreateGotoSubgraph ( environment ( ) ) ; <nl> AddToSubgraph ( body , stmts ) ; <nl> if ( HasStackOverflow ( ) ) return NULL ; <nl> - current_subgraph_ - > Append ( body , NULL ) ; <nl> + current_subgraph_ - > Append ( body , NULL , NULL ) ; <nl> body - > entry_block ( ) - > SetJoinId ( info - > function ( ) - > id ( ) ) ; <nl> <nl> if ( graph_ - > HasExit ( ) ) { <nl> HSubgraph * HGraphBuilder : : CreateLoopHeaderSubgraph ( HEnvironment * env ) { <nl> void HGraphBuilder : : VisitBlock ( Block * stmt ) { <nl> if ( stmt - > labels ( ) ! = NULL ) { <nl> HSubgraph * block_graph = CreateGotoSubgraph ( environment ( ) ) ; <nl> - ADD_TO_SUBGRAPH ( block_graph , stmt - > statements ( ) ) ; <nl> - current_subgraph_ - > Append ( block_graph , stmt ) ; <nl> + BreakAndContinueInfo break_info ( stmt ) ; <nl> + { BreakAndContinueScope push ( & break_info , this ) ; <nl> + ADD_TO_SUBGRAPH ( block_graph , stmt - > statements ( ) ) ; <nl> + } <nl> + subgraph ( ) - > Append ( block_graph , stmt , break_info . break_block ( ) ) ; <nl> } else { <nl> VisitStatements ( stmt - > statements ( ) ) ; <nl> } <nl> void HGraphBuilder : : VisitIfStatement ( IfStatement * stmt ) { <nl> } <nl> <nl> <nl> + HBasicBlock * HGraphBuilder : : BreakAndContinueScope : : Get ( <nl> + BreakableStatement * stmt , <nl> + BreakType type ) { <nl> + BreakAndContinueScope * current = this ; <nl> + while ( current ! = NULL & & current - > info ( ) - > target ( ) ! = stmt ) { <nl> + current = current - > next ( ) ; <nl> + } <nl> + ASSERT ( current ! = NULL ) ; / / Always found ( unless stack is malformed ) . <nl> + HBasicBlock * block = NULL ; <nl> + switch ( type ) { <nl> + case BREAK : <nl> + block = current - > info ( ) - > break_block ( ) ; <nl> + if ( block = = NULL ) { <nl> + block = current - > owner ( ) - > graph ( ) - > CreateBasicBlock ( ) ; <nl> + current - > info ( ) - > set_break_block ( block ) ; <nl> + } <nl> + break ; <nl> + <nl> + case CONTINUE : <nl> + block = current - > info ( ) - > continue_block ( ) ; <nl> + if ( block = = NULL ) { <nl> + block = current - > owner ( ) - > graph ( ) - > CreateBasicBlock ( ) ; <nl> + current - > info ( ) - > set_continue_block ( block ) ; <nl> + } <nl> + break ; <nl> + } <nl> + <nl> + return block ; <nl> + } <nl> + <nl> + <nl> void HGraphBuilder : : VisitContinueStatement ( ContinueStatement * stmt ) { <nl> - current_subgraph_ - > FinishBreakContinue ( stmt - > target ( ) , true ) ; <nl> + HBasicBlock * continue_block = break_scope ( ) - > Get ( stmt - > target ( ) , CONTINUE ) ; <nl> + subgraph ( ) - > exit_block ( ) - > Goto ( continue_block ) ; <nl> + subgraph ( ) - > set_exit_block ( NULL ) ; <nl> } <nl> <nl> <nl> void HGraphBuilder : : VisitBreakStatement ( BreakStatement * stmt ) { <nl> - current_subgraph_ - > FinishBreakContinue ( stmt - > target ( ) , false ) ; <nl> + HBasicBlock * break_block = break_scope ( ) - > Get ( stmt - > target ( ) , BREAK ) ; <nl> + subgraph ( ) - > exit_block ( ) - > Goto ( break_block ) ; <nl> + subgraph ( ) - > set_exit_block ( NULL ) ; <nl> } <nl> <nl> <nl> void HGraphBuilder : : VisitSwitchStatement ( SwitchStatement * stmt ) { <nl> } <nl> <nl> if ( subgraph ! = NULL ) { <nl> - ADD_TO_SUBGRAPH ( subgraph , clause - > statements ( ) ) ; <nl> - HBasicBlock * break_block = subgraph - > BundleBreak ( stmt ) ; <nl> - if ( break_block ! = NULL ) { <nl> - break_block - > Finish ( new HGoto ( single_exit_block ) ) ; <nl> + BreakAndContinueInfo break_info ( stmt ) ; <nl> + { BreakAndContinueScope push ( & break_info , this ) ; <nl> + ADD_TO_SUBGRAPH ( subgraph , clause - > statements ( ) ) ; <nl> + } <nl> + if ( break_info . break_block ( ) ! = NULL ) { <nl> + break_info . break_block ( ) - > SetJoinId ( stmt - > ExitId ( ) ) ; <nl> + break_info . break_block ( ) - > Finish ( new HGoto ( single_exit_block ) ) ; <nl> } <nl> } <nl> <nl> void HGraphBuilder : : VisitDoWhileStatement ( DoWhileStatement * stmt ) { <nl> subgraph ( ) - > PreProcessOsrEntry ( stmt ) ; <nl> <nl> HSubgraph * body_graph = CreateLoopHeaderSubgraph ( environment ( ) ) ; <nl> - ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> - body_graph - > ResolveContinue ( stmt ) ; <nl> + BreakAndContinueInfo break_info ( stmt ) ; <nl> + { BreakAndContinueScope push ( & break_info , this ) ; <nl> + ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> + } <nl> + body_graph - > ResolveContinue ( stmt , break_info . continue_block ( ) ) ; <nl> <nl> if ( ! body_graph - > HasExit ( ) | | stmt - > cond ( ) - > ToBooleanIsTrue ( ) ) { <nl> - current_subgraph_ - > AppendEndless ( body_graph , stmt ) ; <nl> + subgraph ( ) - > AppendEndless ( body_graph , stmt , break_info . break_block ( ) ) ; <nl> } else { <nl> HSubgraph * go_back = CreateEmptySubgraph ( ) ; <nl> HSubgraph * exit = CreateEmptySubgraph ( ) ; <nl> void HGraphBuilder : : VisitDoWhileStatement ( DoWhileStatement * stmt ) { <nl> go_back - > entry_block ( ) - > SetJoinId ( stmt - > BackEdgeId ( ) ) ; <nl> exit - > entry_block ( ) - > SetJoinId ( stmt - > ExitId ( ) ) ; <nl> } <nl> - current_subgraph_ - > AppendDoWhile ( body_graph , stmt , go_back , exit ) ; <nl> + subgraph ( ) - > AppendDoWhile ( body_graph , stmt , go_back , exit , <nl> + break_info . break_block ( ) ) ; <nl> } <nl> } <nl> <nl> void HGraphBuilder : : VisitWhileStatement ( WhileStatement * stmt ) { <nl> / / If the condition is constant true , do not generate a condition subgraph . <nl> if ( stmt - > cond ( ) - > ToBooleanIsTrue ( ) ) { <nl> body_graph = CreateLoopHeaderSubgraph ( environment ( ) ) ; <nl> - ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> } else { <nl> cond_graph = CreateLoopHeaderSubgraph ( environment ( ) ) ; <nl> body_graph = CreateEmptySubgraph ( ) ; <nl> void HGraphBuilder : : VisitWhileStatement ( WhileStatement * stmt ) { <nl> body_graph - > entry_block ( ) - > SetJoinId ( stmt - > BodyId ( ) ) ; <nl> exit_graph - > entry_block ( ) - > SetJoinId ( stmt - > ExitId ( ) ) ; <nl> } <nl> - ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> } <nl> <nl> - body_graph - > ResolveContinue ( stmt ) ; <nl> + BreakAndContinueInfo break_info ( stmt ) ; <nl> + { BreakAndContinueScope push ( & break_info , this ) ; <nl> + ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> + } <nl> + body_graph - > ResolveContinue ( stmt , break_info . continue_block ( ) ) ; <nl> <nl> if ( cond_graph ! = NULL ) { <nl> - AppendPeeledWhile ( stmt , cond_graph , body_graph , exit_graph ) ; <nl> + AppendPeeledWhile ( stmt , cond_graph , body_graph , exit_graph , <nl> + break_info . break_block ( ) ) ; <nl> } else { <nl> / / TODO ( fschneider ) : Implement peeling for endless loops as well . <nl> - current_subgraph_ - > AppendEndless ( body_graph , stmt ) ; <nl> + subgraph ( ) - > AppendEndless ( body_graph , stmt , break_info . break_block ( ) ) ; <nl> } <nl> } <nl> <nl> void HGraphBuilder : : VisitWhileStatement ( WhileStatement * stmt ) { <nl> void HGraphBuilder : : AppendPeeledWhile ( IterationStatement * stmt , <nl> HSubgraph * cond_graph , <nl> HSubgraph * body_graph , <nl> - HSubgraph * exit_graph ) { <nl> + HSubgraph * exit_graph , <nl> + HBasicBlock * break_block ) { <nl> HSubgraph * loop = NULL ; <nl> if ( body_graph - > HasExit ( ) & & stmt ! = peeled_statement_ & & <nl> ShouldPeel ( cond_graph , body_graph ) ) { <nl> void HGraphBuilder : : AppendPeeledWhile ( IterationStatement * stmt , <nl> ADD_TO_SUBGRAPH ( loop , stmt ) ; <nl> peeled_statement_ = outer_peeled_statement ; <nl> } <nl> - current_subgraph_ - > AppendWhile ( cond_graph , body_graph , stmt , loop , <nl> - exit_graph ) ; <nl> + subgraph ( ) - > AppendWhile ( cond_graph , body_graph , stmt , loop , exit_graph , <nl> + break_block ) ; <nl> } <nl> <nl> <nl> void HGraphBuilder : : VisitForStatement ( ForStatement * stmt ) { <nl> } else { <nl> body_graph = CreateLoopHeaderSubgraph ( environment ( ) ) ; <nl> } <nl> - ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> + BreakAndContinueInfo break_info ( stmt ) ; <nl> + { BreakAndContinueScope push ( & break_info , this ) ; <nl> + ADD_TO_SUBGRAPH ( body_graph , stmt - > body ( ) ) ; <nl> + } <nl> <nl> HSubgraph * next_graph = NULL ; <nl> - body_graph - > ResolveContinue ( stmt ) ; <nl> + body_graph - > ResolveContinue ( stmt , break_info . continue_block ( ) ) ; <nl> <nl> if ( stmt - > next ( ) ! = NULL & & body_graph - > HasExit ( ) ) { <nl> next_graph = CreateGotoSubgraph ( body_graph - > environment ( ) ) ; <nl> ADD_TO_SUBGRAPH ( next_graph , stmt - > next ( ) ) ; <nl> - body_graph - > Append ( next_graph , NULL ) ; <nl> + body_graph - > Append ( next_graph , NULL , NULL ) ; <nl> next_graph - > entry_block ( ) - > SetJoinId ( stmt - > ContinueId ( ) ) ; <nl> } <nl> <nl> if ( cond_graph ! = NULL ) { <nl> - AppendPeeledWhile ( stmt , cond_graph , body_graph , exit_graph ) ; <nl> + AppendPeeledWhile ( stmt , cond_graph , body_graph , exit_graph , <nl> + break_info . break_block ( ) ) ; <nl> } else { <nl> - current_subgraph_ - > AppendEndless ( body_graph , stmt ) ; <nl> + subgraph ( ) - > AppendEndless ( body_graph , stmt , break_info . break_block ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / hydrogen . h <nl> ppp b / src / hydrogen . h <nl> class HSubgraph : public ZoneObject { <nl> explicit HSubgraph ( HGraph * graph ) <nl> : graph_ ( graph ) , <nl> entry_block_ ( NULL ) , <nl> - exit_block_ ( NULL ) , <nl> - break_continue_info_ ( 4 ) { <nl> + exit_block_ ( NULL ) { <nl> } <nl> <nl> HGraph * graph ( ) const { return graph_ ; } <nl> class HSubgraph : public ZoneObject { <nl> HSubgraph * body , <nl> IterationStatement * statement , <nl> HSubgraph * continue_subgraph , <nl> - HSubgraph * exit ) ; <nl> + HSubgraph * exit , <nl> + HBasicBlock * break_block ) ; <nl> void AppendDoWhile ( HSubgraph * body , <nl> IterationStatement * statement , <nl> HSubgraph * go_back , <nl> - HSubgraph * exit ) ; <nl> - void AppendEndless ( HSubgraph * body , IterationStatement * statement ) ; <nl> - void Append ( HSubgraph * next , BreakableStatement * statement ) ; <nl> - void ResolveContinue ( IterationStatement * statement ) ; <nl> - HBasicBlock * BundleBreak ( BreakableStatement * statement ) ; <nl> - HBasicBlock * BundleContinue ( IterationStatement * statement ) ; <nl> - HBasicBlock * BundleBreakContinue ( BreakableStatement * statement , <nl> - bool is_continue , <nl> - int join_id ) ; <nl> + HSubgraph * exit , <nl> + HBasicBlock * break_block ) ; <nl> + void AppendEndless ( HSubgraph * body , <nl> + IterationStatement * statement , <nl> + HBasicBlock * break_block ) ; <nl> + void Append ( HSubgraph * next , <nl> + BreakableStatement * stmt , <nl> + HBasicBlock * break_block ) ; <nl> + void ResolveContinue ( IterationStatement * statement , <nl> + HBasicBlock * continue_block ) ; <nl> HBasicBlock * JoinBlocks ( HBasicBlock * a , HBasicBlock * b , int id ) ; <nl> <nl> void FinishExit ( HControlInstruction * instruction ) ; <nl> - void FinishBreakContinue ( BreakableStatement * target , bool is_continue ) ; <nl> void Initialize ( HBasicBlock * block ) { <nl> ASSERT ( entry_block_ = = NULL ) ; <nl> entry_block_ = block ; <nl> class HSubgraph : public ZoneObject { <nl> } <nl> } <nl> <nl> - void AddBreakContinueInfo ( HSubgraph * other ) { <nl> - break_continue_info_ . AddAll ( other - > break_continue_info_ ) ; <nl> - } <nl> - <nl> protected : <nl> - class BreakContinueInfo : public ZoneObject { <nl> - public : <nl> - BreakContinueInfo ( BreakableStatement * target , HBasicBlock * block , <nl> - bool is_continue ) <nl> - : target_ ( target ) , block_ ( block ) , continue_ ( is_continue ) { } <nl> - BreakableStatement * target ( ) const { return target_ ; } <nl> - HBasicBlock * block ( ) const { return block_ ; } <nl> - bool is_continue ( ) const { return continue_ ; } <nl> - bool IsResolved ( ) const { return block_ = = NULL ; } <nl> - void Resolve ( ) { block_ = NULL ; } <nl> - <nl> - private : <nl> - BreakableStatement * target_ ; <nl> - HBasicBlock * block_ ; <nl> - bool continue_ ; <nl> - } ; <nl> - <nl> - const ZoneList < BreakContinueInfo * > * break_continue_info ( ) const { <nl> - return & break_continue_info_ ; <nl> - } <nl> - <nl> HGraph * graph_ ; / / The graph this is a subgraph of . <nl> HBasicBlock * entry_block_ ; <nl> HBasicBlock * exit_block_ ; <nl> - <nl> - private : <nl> - ZoneList < BreakContinueInfo * > break_continue_info_ ; <nl> } ; <nl> <nl> <nl> class TestContext : public AstContext { <nl> <nl> class HGraphBuilder : public AstVisitor { <nl> public : <nl> + enum BreakType { BREAK , CONTINUE } ; <nl> + <nl> + / / A class encapsulating ( lazily - allocated ) break and continue blocks for <nl> + / / a breakable statement . Separated from BreakAndContinueScope so that it <nl> + / / can have a separate lifetime . <nl> + class BreakAndContinueInfo BASE_EMBEDDED { <nl> + public : <nl> + explicit BreakAndContinueInfo ( BreakableStatement * target ) <nl> + : target_ ( target ) , break_block_ ( NULL ) , continue_block_ ( NULL ) { <nl> + } <nl> + <nl> + BreakableStatement * target ( ) { return target_ ; } <nl> + HBasicBlock * break_block ( ) { return break_block_ ; } <nl> + void set_break_block ( HBasicBlock * block ) { break_block_ = block ; } <nl> + HBasicBlock * continue_block ( ) { return continue_block_ ; } <nl> + void set_continue_block ( HBasicBlock * block ) { continue_block_ = block ; } <nl> + <nl> + private : <nl> + BreakableStatement * target_ ; <nl> + HBasicBlock * break_block_ ; <nl> + HBasicBlock * continue_block_ ; <nl> + } ; <nl> + <nl> + / / A helper class to maintain a stack of current BreakAndContinueInfo <nl> + / / structures mirroring BreakableStatement nesting . <nl> + class BreakAndContinueScope BASE_EMBEDDED { <nl> + public : <nl> + BreakAndContinueScope ( BreakAndContinueInfo * info , HGraphBuilder * owner ) <nl> + : info_ ( info ) , owner_ ( owner ) , next_ ( owner - > break_scope ( ) ) { <nl> + owner - > set_break_scope ( this ) ; <nl> + } <nl> + <nl> + ~ BreakAndContinueScope ( ) { owner_ - > set_break_scope ( next_ ) ; } <nl> + <nl> + BreakAndContinueInfo * info ( ) { return info_ ; } <nl> + HGraphBuilder * owner ( ) { return owner_ ; } <nl> + BreakAndContinueScope * next ( ) { return next_ ; } <nl> + <nl> + / / Search the break stack for a break or continue target . <nl> + HBasicBlock * Get ( BreakableStatement * stmt , BreakType type ) ; <nl> + <nl> + private : <nl> + BreakAndContinueInfo * info_ ; <nl> + HGraphBuilder * owner_ ; <nl> + BreakAndContinueScope * next_ ; <nl> + } ; <nl> + <nl> explicit HGraphBuilder ( TypeFeedbackOracle * oracle ) <nl> : oracle_ ( oracle ) , <nl> graph_ ( NULL ) , <nl> class HGraphBuilder : public AstVisitor { <nl> ast_context_ ( NULL ) , <nl> call_context_ ( NULL ) , <nl> function_return_ ( NULL ) , <nl> - inlined_count_ ( 0 ) { } <nl> + inlined_count_ ( 0 ) , <nl> + break_scope_ ( NULL ) { <nl> + } <nl> <nl> HGraph * CreateGraph ( CompilationInfo * info ) ; <nl> <nl> / / Simple accessors . <nl> HGraph * graph ( ) const { return graph_ ; } <nl> HSubgraph * subgraph ( ) const { return current_subgraph_ ; } <nl> + BreakAndContinueScope * break_scope ( ) const { return break_scope_ ; } <nl> + void set_break_scope ( BreakAndContinueScope * head ) { break_scope_ = head ; } <nl> <nl> HEnvironment * environment ( ) const { return subgraph ( ) - > environment ( ) ; } <nl> HBasicBlock * CurrentBlock ( ) const { return subgraph ( ) - > exit_block ( ) ; } <nl> class HGraphBuilder : public AstVisitor { <nl> void AppendPeeledWhile ( IterationStatement * stmt , <nl> HSubgraph * cond_graph , <nl> HSubgraph * body_graph , <nl> - HSubgraph * exit_graph ) ; <nl> + HSubgraph * exit_graph , <nl> + HBasicBlock * break_block ) ; <nl> <nl> void AddToSubgraph ( HSubgraph * graph , ZoneList < Statement * > * stmts ) ; <nl> void AddToSubgraph ( HSubgraph * graph , Statement * stmt ) ; <nl> class HGraphBuilder : public AstVisitor { <nl> <nl> int inlined_count_ ; <nl> <nl> + BreakAndContinueScope * break_scope_ ; <nl> + <nl> friend class AstContext ; / / Pushes and pops the AST context stack . <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( HGraphBuilder ) ; <nl>
Change the translation of break / continue into Hydrogen .
v8/v8
14e185b31b322b518c586ef8fd9c4445fa8e6dbb
2011-02-22T08:40:10Z
mmm a / data / ilsvrc12 / get_ilsvrc_aux . sh <nl> ppp b / data / ilsvrc12 / get_ilsvrc_aux . sh <nl> <nl> # This script downloads the imagenet example auxiliary files including : <nl> # - the ilsvrc12 image mean , binaryproto <nl> # - synset ids and words <nl> + # - Python pickle - format data of ImageNet graph structure and relative infogain <nl> # - the training splits with labels <nl> <nl> DIR = " $ ( cd " $ ( dirname " $ 0 " ) " ; pwd - P ) " <nl> mmm a / docs / getting_pretrained_models . md <nl> ppp b / docs / getting_pretrained_models . md <nl> layout : default <nl> Note that unlike Caffe itself , these models are licensed for * * academic research / non - commercial use only * * . <nl> If you have any questions , please get in touch with us . <nl> <nl> - This page will be updated as more models become available . <nl> + * UPDATE * July 2014 : we are actively working on a service for hosting user - uploaded model definition and trained weight files . <nl> + Soon , the community will be able to easily contribute different architectures ! <nl> <nl> # # # ImageNet <nl> <nl> This page will be updated as more models become available . <nl> validation accuracy 57 . 258 % and loss 1 . 83948 . <nl> - This model obtains a top - 1 accuracy 57 . 1 % and a top - 5 accuracy 80 . 2 % on the validation set , using just the center crop . ( Using the average of 10 crops , ( 4 + 1 center ) * 2 mirror , should obtain a bit higher accuracy ) <nl> <nl> + # # # Auxiliary Data <nl> + <nl> Additionally , you will probably eventually need some auxiliary data ( mean image , synset list , etc . ) : run ` data / ilsvrc12 / get_ilsvrc_aux . sh ` from the root directory to obtain it . <nl> new file mode 100644 <nl> index 00000000000 . . 9bc4ed5c673 <nl> mmm / dev / null <nl> ppp b / examples / web_demo / app . py <nl> <nl> + import os <nl> + import time <nl> + import cPickle <nl> + import datetime <nl> + import logging <nl> + import flask <nl> + import werkzeug <nl> + import optparse <nl> + import tornado . wsgi <nl> + import tornado . httpserver <nl> + import numpy as np <nl> + import pandas as pd <nl> + from PIL import Image as PILImage <nl> + import cStringIO as StringIO <nl> + import urllib <nl> + import caffe <nl> + import exifutil <nl> + <nl> + REPO_DIRNAME = os . path . abspath ( os . path . dirname ( __file__ ) + ' / . . / . . ' ) <nl> + UPLOAD_FOLDER = ' / tmp / caffe_demos_uploads ' <nl> + ALLOWED_IMAGE_EXTENSIONS = set ( [ ' png ' , ' bmp ' , ' jpg ' , ' jpe ' , ' jpeg ' , ' gif ' ] ) <nl> + <nl> + # Obtain the flask app object <nl> + app = flask . Flask ( __name__ ) <nl> + <nl> + <nl> + @ app . route ( ' / ' ) <nl> + def index ( ) : <nl> + return flask . render_template ( ' index . html ' , has_result = False ) <nl> + <nl> + <nl> + @ app . route ( ' / classify_url ' , methods = [ ' GET ' ] ) <nl> + def classify_url ( ) : <nl> + imageurl = flask . request . args . get ( ' imageurl ' , ' ' ) <nl> + try : <nl> + string_buffer = StringIO . StringIO ( <nl> + urllib . urlopen ( imageurl ) . read ( ) ) <nl> + image = caffe . io . load_image ( string_buffer ) <nl> + <nl> + except Exception as err : <nl> + # For any exception we encounter in reading the image , we will just <nl> + # not continue . <nl> + logging . info ( ' URL Image open error : % s ' , err ) <nl> + return flask . render_template ( <nl> + ' index . html ' , has_result = True , <nl> + result = ( False , ' Cannot open image from URL . ' ) <nl> + ) <nl> + <nl> + logging . info ( ' Image : % s ' , imageurl ) <nl> + result = app . clf . classify_image ( image ) <nl> + return flask . render_template ( <nl> + ' index . html ' , has_result = True , result = result , imagesrc = imageurl ) <nl> + <nl> + <nl> + @ app . route ( ' / classify_upload ' , methods = [ ' POST ' ] ) <nl> + def classify_upload ( ) : <nl> + try : <nl> + # We will save the file to disk for possible data collection . <nl> + imagefile = flask . request . files [ ' imagefile ' ] <nl> + filename_ = str ( datetime . datetime . now ( ) ) . replace ( ' ' , ' _ ' ) + \ <nl> + werkzeug . secure_filename ( imagefile . filename ) <nl> + filename = os . path . join ( UPLOAD_FOLDER , filename_ ) <nl> + imagefile . save ( filename ) <nl> + logging . info ( ' Saving to % s . ' , filename ) <nl> + image = exifutil . open_oriented_im ( filename ) <nl> + <nl> + except Exception as err : <nl> + logging . info ( ' Uploaded image open error : % s ' , err ) <nl> + return flask . render_template ( <nl> + ' index . html ' , has_result = True , <nl> + result = ( False , ' Cannot open uploaded image . ' ) <nl> + ) <nl> + <nl> + result = app . clf . classify_image ( image ) <nl> + return flask . render_template ( <nl> + ' index . html ' , has_result = True , result = result , <nl> + imagesrc = embed_image_html ( image ) <nl> + ) <nl> + <nl> + <nl> + def embed_image_html ( image ) : <nl> + " " " Creates an image embedded in HTML base64 format . " " " <nl> + image_pil = PILImage . fromarray ( ( 255 * image ) . astype ( ' uint8 ' ) ) <nl> + image_pil = image_pil . resize ( ( 256 , 256 ) ) <nl> + string_buf = StringIO . StringIO ( ) <nl> + image_pil . save ( string_buf , format = ' png ' ) <nl> + data = string_buf . getvalue ( ) . encode ( ' base64 ' ) . replace ( ' \ n ' , ' ' ) <nl> + return ' data : image / png ; base64 , ' + data <nl> + <nl> + <nl> + def allowed_file ( filename ) : <nl> + return ( <nl> + ' . ' in filename and <nl> + filename . rsplit ( ' . ' , 1 ) [ 1 ] in ALLOWED_IMAGE_EXTENSIONS <nl> + ) <nl> + <nl> + <nl> + class ImagenetClassifier ( object ) : <nl> + default_args = { <nl> + ' model_def_file ' : ( <nl> + ' { } / examples / imagenet / imagenet_deploy . prototxt ' . format ( REPO_DIRNAME ) ) , <nl> + ' pretrained_model_file ' : ( <nl> + ' { } / examples / imagenet / caffe_reference_imagenet_model ' . format ( REPO_DIRNAME ) ) , <nl> + ' mean_file ' : ( <nl> + ' { } / python / caffe / imagenet / ilsvrc_2012_mean . npy ' . format ( REPO_DIRNAME ) ) , <nl> + ' class_labels_file ' : ( <nl> + ' { } / data / ilsvrc12 / synset_words . txt ' . format ( REPO_DIRNAME ) ) , <nl> + ' bet_file ' : ( <nl> + ' { } / data / ilsvrc12 / imagenet . bet . pickle ' . format ( REPO_DIRNAME ) ) , <nl> + } <nl> + for key , val in default_args . iteritems ( ) : <nl> + if not os . path . exists ( val ) : <nl> + raise Exception ( <nl> + " File for { } is missing . Should be at : { } " . format ( key , val ) ) <nl> + default_args [ ' image_dim ' ] = 227 <nl> + default_args [ ' gpu_mode ' ] = True <nl> + <nl> + def __init__ ( self , model_def_file , pretrained_model_file , mean_file , <nl> + class_labels_file , bet_file , image_dim , gpu_mode = False ) : <nl> + logging . info ( ' Loading net and associated files . . . ' ) <nl> + self . net = caffe . Classifier ( <nl> + model_def_file , pretrained_model_file , input_scale = 255 , <nl> + image_dims = ( image_dim , image_dim ) , gpu = gpu_mode , <nl> + mean_file = mean_file , channel_swap = ( 2 , 1 , 0 ) <nl> + ) <nl> + <nl> + with open ( class_labels_file ) as f : <nl> + labels_df = pd . DataFrame ( [ <nl> + { <nl> + ' synset_id ' : l . strip ( ) . split ( ' ' ) [ 0 ] , <nl> + ' name ' : ' ' . join ( l . strip ( ) . split ( ' ' ) [ 1 : ] ) . split ( ' , ' ) [ 0 ] <nl> + } <nl> + for l in f . readlines ( ) <nl> + ] ) <nl> + self . labels = labels_df . sort ( ' synset_id ' ) [ ' name ' ] . values <nl> + <nl> + self . bet = cPickle . load ( open ( bet_file ) ) <nl> + # A bias to prefer children nodes in single - chain paths <nl> + # I am setting the value to 0 . 1 as a quick , simple model . <nl> + # We could use better psychological models here . . . <nl> + self . bet [ ' infogain ' ] - = np . array ( self . bet [ ' preferences ' ] ) * 0 . 1 <nl> + <nl> + def classify_image ( self , image ) : <nl> + try : <nl> + starttime = time . time ( ) <nl> + scores = self . net . predict ( [ image ] , oversample = True ) . flatten ( ) <nl> + endtime = time . time ( ) <nl> + <nl> + indices = ( - scores ) . argsort ( ) [ : 5 ] <nl> + predictions = self . labels [ indices ] <nl> + <nl> + # In addition to the prediction text , we will also produce <nl> + # the length for the progress bar visualization . <nl> + meta = [ <nl> + ( p , ' % . 5f ' % scores [ i ] ) <nl> + for i , p in zip ( indices , predictions ) <nl> + ] <nl> + logging . info ( ' result : % s ' , str ( meta ) ) <nl> + <nl> + # Compute expected information gain <nl> + expected_infogain = np . dot ( <nl> + self . bet [ ' probmat ' ] , scores [ self . bet [ ' idmapping ' ] ] ) <nl> + expected_infogain * = self . bet [ ' infogain ' ] <nl> + <nl> + # sort the scores <nl> + infogain_sort = expected_infogain . argsort ( ) [ : : - 1 ] <nl> + bet_result = [ ( self . bet [ ' words ' ] [ v ] , ' % . 5f ' % expected_infogain [ v ] ) <nl> + for v in infogain_sort [ : 5 ] ] <nl> + logging . info ( ' bet result : % s ' , str ( bet_result ) ) <nl> + <nl> + return ( True , meta , bet_result , ' % . 3f ' % ( endtime - starttime ) ) <nl> + <nl> + except Exception as err : <nl> + logging . info ( ' Classification error : % s ' , err ) <nl> + return ( False , ' Something went wrong when classifying the ' <nl> + ' image . Maybe try another one ? ' ) <nl> + <nl> + <nl> + def start_tornado ( app , port = 5000 ) : <nl> + http_server = tornado . httpserver . HTTPServer ( <nl> + tornado . wsgi . WSGIContainer ( app ) ) <nl> + http_server . listen ( port ) <nl> + print ( " Tornado server starting on port { } " . format ( port ) ) <nl> + tornado . ioloop . IOLoop . instance ( ) . start ( ) <nl> + <nl> + <nl> + def start_from_terminal ( app ) : <nl> + " " " <nl> + Parse command line options and start the server . <nl> + " " " <nl> + parser = optparse . OptionParser ( ) <nl> + parser . add_option ( <nl> + ' - d ' , ' - - debug ' , <nl> + help = " enable debug mode " , <nl> + action = " store_true " , default = False ) <nl> + parser . add_option ( <nl> + ' - p ' , ' - - port ' , <nl> + help = " which port to serve content on " , <nl> + type = ' int ' , default = 5000 ) <nl> + opts , args = parser . parse_args ( ) <nl> + <nl> + # Initialize classifier <nl> + app . clf = ImagenetClassifier ( * * ImagenetClassifier . default_args ) <nl> + <nl> + if opts . debug : <nl> + app . run ( debug = True , host = ' 0 . 0 . 0 . 0 ' , port = opts . port ) <nl> + else : <nl> + start_tornado ( app , opts . port ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + logging . getLogger ( ) . setLevel ( logging . INFO ) <nl> + if not os . path . exists ( UPLOAD_FOLDER ) : <nl> + os . makedirs ( UPLOAD_FOLDER ) <nl> + start_from_terminal ( app ) <nl> new file mode 100644 <nl> index 00000000000 . . 8c07aa887b2 <nl> mmm / dev / null <nl> ppp b / examples / web_demo / exifutil . py <nl> <nl> + " " " <nl> + This script handles the skimage exif problem . <nl> + " " " <nl> + <nl> + from PIL import Image <nl> + import numpy as np <nl> + <nl> + ORIENTATIONS = { # used in apply_orientation <nl> + 2 : ( Image . FLIP_LEFT_RIGHT , ) , <nl> + 3 : ( Image . ROTATE_180 , ) , <nl> + 4 : ( Image . FLIP_TOP_BOTTOM , ) , <nl> + 5 : ( Image . FLIP_LEFT_RIGHT , Image . ROTATE_90 ) , <nl> + 6 : ( Image . ROTATE_270 , ) , <nl> + 7 : ( Image . FLIP_LEFT_RIGHT , Image . ROTATE_270 ) , <nl> + 8 : ( Image . ROTATE_90 , ) <nl> + } <nl> + <nl> + <nl> + def open_oriented_im ( im_path ) : <nl> + im = Image . open ( im_path ) <nl> + if hasattr ( im , ' _getexif ' ) : <nl> + exif = im . _getexif ( ) <nl> + if exif is not None and 274 in exif : <nl> + orientation = exif [ 274 ] <nl> + im = apply_orientation ( im , orientation ) <nl> + return np . asarray ( im ) . astype ( np . float32 ) / 255 . <nl> + <nl> + <nl> + def apply_orientation ( im , orientation ) : <nl> + if orientation in ORIENTATIONS : <nl> + for method in ORIENTATIONS [ orientation ] : <nl> + im = im . transpose ( method ) <nl> + return im <nl> new file mode 100644 <nl> index 00000000000 . . 559c41e049c <nl> mmm / dev / null <nl> ppp b / examples / web_demo / readme . md <nl> <nl> + mmm <nl> + title : Web demo <nl> + description : Image classification demo running as a Flask web server . <nl> + category : example <nl> + layout : default <nl> + include_in_docs : true <nl> + mmm <nl> + <nl> + # Web Demo <nl> + <nl> + # # Requirements <nl> + <nl> + The demo server requires Python with some dependencies . <nl> + To make sure you have the dependencies , please run ` pip install - r examples / web_demo / requirements . txt ` , and also make sure that you ' ve compiled the Python Caffe interface and that it is on your ` PYTHONPATH ` ( see [ installation instructions ] ( / installation . html ) ) . <nl> + <nl> + Make sure that you have obtained the Caffe Reference ImageNet Model and the ImageNet Auxiliary Data ( [ instructions ] ( / getting_pretrained_models . html ) ) . <nl> + NOTE : if you run into trouble , try re - downloading the auxiliary files . <nl> + <nl> + # # Run <nl> + <nl> + Running ` python examples / web_demo / app . py ` will bring up the demo server , accessible at ` http : / / 0 . 0 . 0 . 0 : 5000 ` . <nl> + You can enable debug mode of the web server , or switch to a different port : <nl> + <nl> + % python examples / web_demo / app . py - h <nl> + Usage : app . py [ options ] <nl> + <nl> + Options : <nl> + - h , - - help show this help message and exit <nl> + - d , - - debug enable debug mode <nl> + - p PORT , - - port = PORT which port to serve content on <nl> new file mode 100644 <nl> index 00000000000 . . 878933415b9 <nl> mmm / dev / null <nl> ppp b / examples / web_demo / templates / index . html <nl> <nl> + < ! DOCTYPE html > <nl> + < html lang = " en " > <nl> + < head > <nl> + < meta charset = " utf - 8 " > <nl> + < meta name = " viewport " content = " width = device - width , initial - scale = 1 . 0 " > <nl> + < meta name = " description " content = " Caffe demos " > <nl> + < meta name = " author " content = " BVLC ( http : / / bvlc . eecs . berkeley . edu / ) " > <nl> + <nl> + < title > Caffe Demos < / title > <nl> + <nl> + < link href = " / / netdna . bootstrapcdn . com / bootstrap / 3 . 1 . 1 / css / bootstrap . min . css " rel = " stylesheet " > <nl> + <nl> + < script type = " text / javascript " src = " / / code . jquery . com / jquery - 2 . 1 . 1 . js " > < / script > <nl> + < script src = " / / netdna . bootstrapcdn . com / bootstrap / 3 . 1 . 1 / js / bootstrap . min . js " > < / script > <nl> + <nl> + < ! - - Script to instantly classify an image once it is uploaded . - - > <nl> + < script type = " text / javascript " > <nl> + $ ( document ) . ready ( <nl> + function ( ) { <nl> + $ ( ' # classifyfile ' ) . attr ( ' disabled ' , true ) ; <nl> + $ ( ' # imagefile ' ) . change ( <nl> + function ( ) { <nl> + if ( $ ( this ) . val ( ) ) { <nl> + $ ( ' # formupload ' ) . submit ( ) ; <nl> + } <nl> + } <nl> + ) ; <nl> + } <nl> + ) ; <nl> + < / script > <nl> + <nl> + < style > <nl> + body { <nl> + font - family : " Helvetica Neue " , Helvetica , Arial , sans - serif ; <nl> + line - height : 1 . 5em ; <nl> + color : # 232323 ; <nl> + - webkit - font - smoothing : antialiased ; <nl> + } <nl> + <nl> + h1 , h2 , h3 { <nl> + font - family : Times , serif ; <nl> + line - height : 1 . 5em ; <nl> + border - bottom : 1px solid # ccc ; <nl> + } <nl> + < / style > <nl> + < / head > <nl> + <nl> + < body > <nl> + < ! - - Begin page content - - > <nl> + < div class = " container " > <nl> + < div class = " page - header " > <nl> + < h1 > < a href = " / " > Caffe Demos < / a > < / h1 > <nl> + < p > <nl> + The < a href = " http : / / caffe . berkeleyvision . org " > Caffe < / a > neural network library makes implementing state - of - the - art computer vision systems easy . <nl> + < / p > <nl> + < / div > <nl> + <nl> + < div > <nl> + < h2 > Classification < / h2 > <nl> + < a href = " / classify_url ? imageurl = http % 3A % 2F % 2Fi . telegraph . co . uk % 2Fmultimedia % 2Farchive % 2F02351 % 2Fcross - eyed - cat_2351472k . jpg " > Click for a Quick Example < / a > <nl> + < / div > <nl> + <nl> + { % if has_result % } <nl> + { % if not result [ 0 ] % } <nl> + < ! - - we have error in the result . - - > <nl> + < div class = " alert alert - danger " > { { result [ 1 ] } } Did you provide a valid URL or a valid image file ? < / div > <nl> + { % else % } <nl> + < div class = " media " > <nl> + < a class = " pull - left " href = " # " > < img class = " media - object " width = " 192 " height = " 192 " src = { { imagesrc } } > < / a > <nl> + < div class = " media - body " > <nl> + < div class = " bs - example bs - example - tabs " > <nl> + < ul id = " myTab " class = " nav nav - tabs " > <nl> + < li class = " active " > < a href = " # infopred " data - toggle = " tab " > Maximally accurate < / a > < / li > <nl> + < li > < a href = " # flatpred " data - toggle = " tab " > Maximally specific < / a > < / li > <nl> + < / ul > <nl> + < div id = " myTabContent " class = " tab - content " > <nl> + < div class = " tab - pane fade in active " id = " infopred " > <nl> + < ul class = " list - group " > <nl> + { % for single_pred in result [ 2 ] % } <nl> + < li class = " list - group - item " > <nl> + < span class = " badge " > { { single_pred [ 1 ] } } < / span > <nl> + < h4 class = " list - group - item - heading " > <nl> + < a href = " https : / / www . google . com / # q = { { single_pred [ 0 ] } } " target = " _blank " > { { single_pred [ 0 ] } } < / a > <nl> + < / h4 > <nl> + < / li > <nl> + { % endfor % } <nl> + < / ul > <nl> + < / div > <nl> + < div class = " tab - pane fade " id = " flatpred " > <nl> + < ul class = " list - group " > <nl> + { % for single_pred in result [ 1 ] % } <nl> + < li class = " list - group - item " > <nl> + < span class = " badge " > { { single_pred [ 1 ] } } < / span > <nl> + < h4 class = " list - group - item - heading " > <nl> + < a href = " https : / / www . google . com / # q = { { single_pred [ 0 ] } } " target = " _blank " > { { single_pred [ 0 ] } } < / a > <nl> + < / h4 > <nl> + < / li > <nl> + { % endfor % } <nl> + < / ul > <nl> + < / div > <nl> + < / div > <nl> + < / div > <nl> + <nl> + < / div > <nl> + < / div > <nl> + < p > CNN took { { result [ 3 ] } } seconds . < / p > <nl> + { % endif % } <nl> + < hr > <nl> + { % endif % } <nl> + <nl> + < form role = " form " action = " classify_url " method = " get " > <nl> + < div class = " form - group " > <nl> + < div class = " input - group " > <nl> + < input type = " text " class = " form - control " name = " imageurl " id = " imageurl " placeholder = " Provide an image URL " > <nl> + < span class = " input - group - btn " > <nl> + < input class = " btn btn - primary " value = " Classify URL " type = " submit " id = " classifyurl " > < / input > <nl> + < / span > <nl> + < / div > < ! - - / input - group - - > <nl> + < / div > <nl> + < / form > <nl> + <nl> + < form id = " formupload " class = " form - inline " role = " form " action = " classify_upload " method = " post " enctype = " multipart / form - data " > <nl> + < div class = " form - group " > <nl> + < label for = " imagefile " > Or upload an image : < / label > <nl> + < input type = " file " name = " imagefile " id = " imagefile " > <nl> + < / div > <nl> + < ! - - < input type = " submit " class = " btn btn - primary " value = " Classify File " id = " classifyfile " > < / input > - - > <nl> + < / form > <nl> + < / div > <nl> + <nl> + < hr > <nl> + < div id = " footer " > <nl> + < div class = " container " > <nl> + < p > & copy ; BVLC 2014 < / p > <nl> + < / div > <nl> + < / div > <nl> + < / body > <nl> + < / html > <nl>
[ example ] image classification web demo
BVLC/caffe
dd546171bae1c3608ce70111c8ffb46c766ea9df
2014-07-12T06:41:12Z
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> if ( LINUX OR MACOSX OR WINDOWS ) <nl> find_package ( Threads REQUIRED ) <nl> set ( THREADS_LIBRARIES $ { CMAKE_THREAD_LIBS_INIT } ) <nl> <nl> - cocos_find_package ( FMODEX FMODEX REQUIRED ) <nl> + cocos_find_package ( FMOD FMOD REQUIRED ) <nl> cocos_find_package ( Fontconfig FONTCONFIG REQUIRED ) <nl> cocos_find_package ( GTK3 GTK3 REQUIRED ) <nl> endif ( ) <nl> mmm a / cmake / Modules / CocosUsePrebuiltLibs . cmake <nl> ppp b / cmake / Modules / CocosUsePrebuiltLibs . cmake <nl> set ( _OpenalSoft_libs OpenAL32 ) <nl> set ( _zlib_inc zlib . h ) <nl> set ( _zlib_libs z libzlib libz ) <nl> <nl> - set ( _fmod_prefix FMODEX ) <nl> - set ( _fmod_inc fmod . h ) <nl> - set ( _fmod_libs fmodex fmodex64 fmodexL fmodexL64 ) <nl> + set ( _fmod_prefix FMOD ) <nl> + set ( _fmod_inc fmod . hpp ) <nl> + set ( _fmod_libs fmod fmod64 fmod fmod64 ) <nl> <nl> set ( all_prebuilt_libs <nl> chipmunk <nl> new file mode 100644 <nl> index 000000000000 . . f14a9a4d5c19 <nl> mmm / dev / null <nl> ppp b / cmake / Modules / FindFMOD . cmake <nl> <nl> + # . rst : <nl> + # FindFMOD <nl> + # mmmmmmmmmmmm <nl> + # <nl> + # Locate FMOD Ex library <nl> + # <nl> + # This module defines <nl> + # <nl> + # : : <nl> + # <nl> + # FMOD_LIBRARIES , the library to link against <nl> + # FMOD_FOUND , if false , do not try to link to fmodex <nl> + # FMOD_INCLUDE_DIRS , where to find headers . <nl> + # <nl> + <nl> + find_path ( FMOD_INCLUDE_DIR fmod . hpp <nl> + HINTS ENV FMOD_DIR <nl> + PATH_SUFFIXES include / fmod include <nl> + PATHS <nl> + ~ / Library / Frameworks <nl> + / Library / Frameworks <nl> + / usr / local <nl> + / usr <nl> + / sw # Fink <nl> + / opt / local # DarwinPorts <nl> + / opt / csw # Blastwave <nl> + / opt <nl> + ) <nl> + <nl> + find_library ( FMOD_LIBRARY NAMES fmod fmod64 <nl> + HINTS ENV FMOD_DIR <nl> + PATH_SUFFIXES lib <nl> + PATHS <nl> + ~ / Library / Frameworks <nl> + / Library / Frameworks <nl> + / usr / local <nl> + / usr <nl> + / sw # Fink <nl> + / opt / local # DarwinPorts <nl> + / opt / csw # Blastwave <nl> + / opt <nl> + ) <nl> + <nl> + set ( FMOD_INCLUDE_DIRS " $ { FMOD_INCLUDE_DIR } " ) <nl> + set ( FMOD_LIBRARIES " $ { FMOD_LIBRARY } " ) <nl> + <nl> + include ( $ { CMAKE_CURRENT_LIST_DIR } / FindPackageHandleStandardArgs . cmake ) <nl> + find_package_handle_standard_args ( FMOD DEFAULT_MSG FMOD_LIBRARIES FMOD_INCLUDE_DIRS ) <nl> + <nl> + mark_as_advanced ( FMOD_INCLUDE_DIR FMOD_LIBRARY FMOD_INCLUDE_DIRS FMOD_LIBRARIES ) <nl> + <nl> deleted file mode 100644 <nl> index 54e4d4a80084 . . 000000000000 <nl> mmm a / cmake / Modules / FindFMODEX . cmake <nl> ppp / dev / null <nl> <nl> - # . rst : <nl> - # FindFMODEX <nl> - # mmmmmmmmmmmm <nl> - # <nl> - # Locate FMOD Ex library <nl> - # <nl> - # This module defines <nl> - # <nl> - # : : <nl> - # <nl> - # FMODEX_LIBRARIES , the library to link against <nl> - # FMODEX_FOUND , if false , do not try to link to fmodex <nl> - # FMODEX_INCLUDE_DIRS , where to find headers . <nl> - # <nl> - <nl> - find_path ( FMODEX_INCLUDE_DIR fmod . h <nl> - HINTS ENV FMODEX_DIR <nl> - PATH_SUFFIXES include / fmodex include <nl> - PATHS <nl> - ~ / Library / Frameworks <nl> - / Library / Frameworks <nl> - / usr / local <nl> - / usr <nl> - / sw # Fink <nl> - / opt / local # DarwinPorts <nl> - / opt / csw # Blastwave <nl> - / opt <nl> - ) <nl> - <nl> - find_library ( FMODEX_LIBRARY NAMES fmodex fmodex64 <nl> - HINTS ENV FMODEX_DIR <nl> - PATH_SUFFIXES lib <nl> - PATHS <nl> - ~ / Library / Frameworks <nl> - / Library / Frameworks <nl> - / usr / local <nl> - / usr <nl> - / sw # Fink <nl> - / opt / local # DarwinPorts <nl> - / opt / csw # Blastwave <nl> - / opt <nl> - ) <nl> - <nl> - set ( FMODEX_INCLUDE_DIRS " $ { FMODEX_INCLUDE_DIR } " ) <nl> - set ( FMODEX_LIBRARIES " $ { FMODEX_LIBRARY } " ) <nl> - <nl> - include ( $ { CMAKE_CURRENT_LIST_DIR } / FindPackageHandleStandardArgs . cmake ) <nl> - find_package_handle_standard_args ( FMODEX DEFAULT_MSG FMODEX_LIBRARIES FMODEX_INCLUDE_DIRS ) <nl> - <nl> - mark_as_advanced ( FMODEX_INCLUDE_DIR FMODEX_LIBRARY FMODEX_INCLUDE_DIRS FMODEX_LIBRARIES ) <nl> - <nl> mmm a / cocos / CMakeLists . txt <nl> ppp b / cocos / CMakeLists . txt <nl> if ( WINDOWS ) <nl> endforeach ( ) <nl> list ( APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm ) <nl> elseif ( LINUX ) <nl> - foreach ( _pkg OPENGL GLEW GLFW3 FMODEX FONTCONFIG THREADS GTK3 ) <nl> + foreach ( _pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3 ) <nl> cocos_use_pkg ( cocos2d $ { _pkg } ) <nl> endforeach ( ) <nl> elseif ( MACOSX OR APPLE ) <nl> mmm a / cocos / audio / AudioEngine . cpp <nl> ppp b / cocos / audio / AudioEngine . cpp <nl> <nl> <nl> # include " platform / CCPlatformConfig . h " <nl> <nl> - # if CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT | | CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_IOS | | CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 <nl> - <nl> # include " audio / include / AudioEngine . h " <nl> # include < condition_variable > <nl> # include < queue > <nl> <nl> # include " win32 / AudioEngine - win32 . h " <nl> # elif CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT <nl> # include " winrt / AudioEngine - winrt . h " <nl> + # elif CC_TARGET_PLATFORM = = CC_PLATFORM_LINUX <nl> + # include " linux / AudioEngine - linux . h " <nl> # endif <nl> <nl> # define TIME_DELAY_PRECISION 0 . 0001 <nl> void AudioEngine : : addTask ( const std : : function < void ( ) > & task ) <nl> s_threadPool - > addTask ( task ) ; <nl> } <nl> } <nl> - <nl> - # endif <nl> mmm a / cocos / audio / CMakeLists . txt <nl> ppp b / cocos / audio / CMakeLists . txt <nl> if ( WINDOWS ) <nl> <nl> elseif ( LINUX ) <nl> set ( COCOS_AUDIO_PLATFORM_SRC <nl> - audio / linux / SimpleAudioEngineFMOD . cpp <nl> - audio / linux / FmodAudioPlayer . cpp <nl> - audio / linux / FmodAudioPlayer . h <nl> - audio / linux / AudioPlayer . h <nl> + audio / linux / SimpleAudioEngine . cpp <nl> + audio / linux / AudioEngine - linux . h <nl> + audio / linux / AudioEngine - linux . cpp <nl> ) <nl> <nl> elseif ( MACOSX ) <nl> mmm a / cocos / audio / include / AudioEngine . h <nl> ppp b / cocos / audio / include / AudioEngine . h <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " platform / CCPlatformConfig . h " <nl> - # if CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT | | CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_IOS | | CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 <nl> <nl> # ifndef __AUDIO_ENGINE_H_ <nl> # define __AUDIO_ENGINE_H_ <nl> NS_CC_END <nl> / / / @ } <nl> <nl> # endif / / __AUDIO_ENGINE_H_ <nl> - # endif <nl> new file mode 100644 <nl> index 000000000000 . . 9fc54a58b4f8 <nl> mmm / dev / null <nl> ppp b / cocos / audio / linux / AudioEngine - linux . cpp <nl> <nl> + / * * <nl> + * @ author cesarpachon <nl> + * / <nl> + # include < cstring > <nl> + # include " AudioEngine - linux . h " <nl> + # include " cocos2d . h " <nl> + using namespace cocos2d ; <nl> + using namespace cocos2d : : experimental ; <nl> + <nl> + AudioEngineImpl * g_AudioEngineImpl = nullptr ; <nl> + <nl> + void ERRCHECKWITHEXIT ( FMOD_RESULT result ) { <nl> + if ( result ! = FMOD_OK ) { <nl> + printf ( " FMOD error ! ( % d ) % s \ n " , result , FMOD_ErrorString ( result ) ) ; <nl> + } <nl> + } <nl> + <nl> + bool ERRCHECK ( FMOD_RESULT result ) { <nl> + if ( result ! = FMOD_OK ) { <nl> + printf ( " FMOD error ! ( % d ) % s \ n " , result , FMOD_ErrorString ( result ) ) ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + FMOD_RESULT F_CALLBACK channelCallback ( FMOD_CHANNELCONTROL * channelcontrol , <nl> + FMOD_CHANNELCONTROL_TYPE controltype , <nl> + FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype , <nl> + void * commandData1 , void * commandData2 ) <nl> + { <nl> + <nl> + if ( controltype = = FMOD_CHANNELCONTROL_CHANNEL & & callbacktype = = FMOD_CHANNELCONTROL_CALLBACK_END ) { <nl> + g_AudioEngineImpl - > onSoundFinished ( ( FMOD : : Channel * ) channelcontrol ) ; <nl> + } else { <nl> + } <nl> + return FMOD_OK ; <nl> + } <nl> + <nl> + <nl> + AudioEngineImpl : : AudioEngineImpl ( ) { <nl> + } ; <nl> + <nl> + AudioEngineImpl : : ~ AudioEngineImpl ( ) { <nl> + FMOD_RESULT result ; <nl> + result = pSystem - > close ( ) ; <nl> + ERRCHECKWITHEXIT ( result ) ; <nl> + result = pSystem - > release ( ) ; <nl> + ERRCHECKWITHEXIT ( result ) ; <nl> + } ; <nl> + <nl> + <nl> + bool AudioEngineImpl : : init ( ) { <nl> + FMOD_RESULT result ; <nl> + / * <nl> + Create a System object and initialize . <nl> + * / <nl> + result = FMOD : : System_Create ( & pSystem ) ; <nl> + ERRCHECKWITHEXIT ( result ) ; <nl> + <nl> + result = pSystem - > setOutput ( FMOD_OUTPUTTYPE_PULSEAUDIO ) ; <nl> + ERRCHECKWITHEXIT ( result ) ; <nl> + <nl> + result = pSystem - > init ( 32 , FMOD_INIT_NORMAL , 0 ) ; <nl> + ERRCHECKWITHEXIT ( result ) ; <nl> + <nl> + mapChannelInfo . clear ( ) ; <nl> + mapSound . clear ( ) ; <nl> + <nl> + auto scheduler = cocos2d : : Director : : getInstance ( ) - > getScheduler ( ) ; <nl> + scheduler - > schedule ( schedule_selector ( AudioEngineImpl : : update ) , this , 0 . 05f , false ) ; <nl> + <nl> + g_AudioEngineImpl = this ; <nl> + <nl> + return true ; <nl> + } ; <nl> + <nl> + int AudioEngineImpl : : play2d ( const std : : string & fileFullPath , bool loop , float volume ) { <nl> + int id = preload ( fileFullPath , nullptr ) ; <nl> + if ( id > = 0 ) { <nl> + mapChannelInfo [ id ] . loop = loop ; <nl> + mapChannelInfo [ id ] . channel - > setPaused ( true ) ; <nl> + mapChannelInfo [ id ] . volume = volume ; <nl> + AudioEngine : : _audioIDInfoMap [ id ] . state = AudioEngine : : AudioState : : PAUSED ; <nl> + resume ( id ) ; <nl> + } <nl> + return id ; <nl> + } ; <nl> + <nl> + void AudioEngineImpl : : setVolume ( int audioID , float volume ) { <nl> + try { <nl> + mapChannelInfo [ audioID ] . channel - > setVolume ( volume ) ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : setVolume : invalid audioID : % d \ n " , audioID ) ; <nl> + } <nl> + } ; <nl> + <nl> + void AudioEngineImpl : : setLoop ( int audioID , bool loop ) { <nl> + try { <nl> + mapChannelInfo [ audioID ] . channel - > setLoopCount ( loop ? - 1 : 0 ) ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : setLoop : invalid audioID : % d \ n " , audioID ) ; <nl> + } <nl> + } ; <nl> + <nl> + bool AudioEngineImpl : : pause ( int audioID ) { <nl> + try { <nl> + mapChannelInfo [ audioID ] . channel - > setPaused ( true ) ; <nl> + AudioEngine : : _audioIDInfoMap [ audioID ] . state = AudioEngine : : AudioState : : PAUSED ; <nl> + return true ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : pause : invalid audioID : % d \ n " , audioID ) ; <nl> + return false ; <nl> + } <nl> + } ; <nl> + <nl> + bool AudioEngineImpl : : resume ( int audioID ) { <nl> + try { <nl> + <nl> + if ( ! mapChannelInfo [ audioID ] . channel ) { <nl> + FMOD : : Channel * channel = nullptr ; <nl> + FMOD : : ChannelGroup * channelgroup = nullptr ; <nl> + / / starts the sound in pause mode , use the channel to unpause <nl> + FMOD_RESULT result = pSystem - > playSound ( mapChannelInfo [ audioID ] . sound , channelgroup , true , & channel ) ; <nl> + if ( ERRCHECK ( result ) ) { <nl> + return false ; <nl> + } <nl> + channel - > setMode ( mapChannelInfo [ audioID ] . loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF ) ; <nl> + channel - > setLoopCount ( mapChannelInfo [ audioID ] . loop ? - 1 : 0 ) ; <nl> + channel - > setVolume ( mapChannelInfo [ audioID ] . volume ) ; <nl> + channel - > setUserData ( ( void * ) mapChannelInfo [ audioID ] . id ) ; <nl> + mapChannelInfo [ audioID ] . channel = channel ; <nl> + } <nl> + <nl> + mapChannelInfo [ audioID ] . channel - > setPaused ( false ) ; <nl> + AudioEngine : : _audioIDInfoMap [ audioID ] . state = AudioEngine : : AudioState : : PLAYING ; <nl> + <nl> + return true ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : resume : invalid audioID : % d \ n " , audioID ) ; <nl> + return false ; <nl> + } <nl> + } ; <nl> + <nl> + bool AudioEngineImpl : : stop ( int audioID ) { <nl> + try { <nl> + mapChannelInfo [ audioID ] . channel - > stop ( ) ; <nl> + mapChannelInfo [ audioID ] . channel = nullptr ; <nl> + return true ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : stop : invalid audioID : % d \ n " , audioID ) ; <nl> + return false ; <nl> + } <nl> + } ; <nl> + <nl> + void AudioEngineImpl : : stopAll ( ) { <nl> + for ( auto it = mapChannelInfo . begin ( ) ; it ! = mapChannelInfo . end ( ) ; + + it ) { <nl> + ChannelInfo & audioRef = it - > second ; <nl> + audioRef . channel - > stop ( ) ; <nl> + audioRef . channel = nullptr ; <nl> + } <nl> + } ; <nl> + <nl> + float AudioEngineImpl : : getDuration ( int audioID ) { <nl> + try { <nl> + FMOD : : Sound * sound = mapChannelInfo [ audioID ] . sound ; <nl> + unsigned int length ; <nl> + FMOD_RESULT result = sound - > getLength ( & length , FMOD_TIMEUNIT_MS ) ; <nl> + ERRCHECK ( result ) ; <nl> + float duration = ( float ) length / 1000 . 0f ; <nl> + return duration ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : getDuration : invalid audioID : % d \ n " , audioID ) ; <nl> + return AudioEngine : : TIME_UNKNOWN ; <nl> + } <nl> + } ; <nl> + <nl> + float AudioEngineImpl : : getCurrentTime ( int audioID ) { <nl> + try { <nl> + unsigned int position ; <nl> + FMOD_RESULT result = mapChannelInfo [ audioID ] . channel - > getPosition ( & position , FMOD_TIMEUNIT_MS ) ; <nl> + ERRCHECK ( result ) ; <nl> + float currenttime = position / 1000 . 0f ; <nl> + return currenttime ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : getCurrentTime : invalid audioID : % d \ n " , audioID ) ; <nl> + return AudioEngine : : TIME_UNKNOWN ; <nl> + } <nl> + } ; <nl> + <nl> + bool AudioEngineImpl : : setCurrentTime ( int audioID , float time ) { <nl> + try { <nl> + unsigned int position = ( unsigned int ) ( time * 1000 . 0f ) ; <nl> + FMOD_RESULT result = mapChannelInfo [ audioID ] . channel - > setPosition ( position , FMOD_TIMEUNIT_MS ) ; <nl> + ERRCHECK ( result ) ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : setCurrentTime : invalid audioID : % d \ n " , audioID ) ; <nl> + } <nl> + } ; <nl> + <nl> + void AudioEngineImpl : : setFinishCallback ( int audioID , const std : : function < void ( int , const std : : string & ) > & callback ) { <nl> + try { <nl> + FMOD : : Channel * channel = mapChannelInfo [ audioID ] . channel ; <nl> + mapChannelInfo [ audioID ] . callback = callback ; <nl> + FMOD_RESULT result = channel - > setCallback ( channelCallback ) ; <nl> + ERRCHECK ( result ) ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : setFinishCallback : invalid audioID : % d \ n " , audioID ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + void AudioEngineImpl : : onSoundFinished ( FMOD : : Channel * channel ) { <nl> + size_t id ; <nl> + try { <nl> + void * data ; <nl> + channel - > getUserData ( & data ) ; <nl> + id = ( size_t ) data ; <nl> + if ( mapChannelInfo [ id ] . callback ) { <nl> + mapChannelInfo [ id ] . callback ( id , mapChannelInfo [ id ] . path ) ; <nl> + } <nl> + mapChannelInfo [ id ] . channel = nullptr ; <nl> + } catch ( const std : : out_of_range & oor ) { <nl> + printf ( " AudioEngineImpl : : onSoundFinished : invalid audioID : % d \ n " , id ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + void AudioEngineImpl : : uncache ( const std : : string & path ) { <nl> + std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( path ) ; <nl> + std : : map < std : : string , FMOD : : Sound * > : : const_iterator it = mapSound . find ( fullPath ) ; <nl> + if ( it ! = mapSound . end ( ) ) { <nl> + FMOD : : Sound * sound = it - > second ; <nl> + if ( sound ) { <nl> + sound - > release ( ) ; <nl> + } <nl> + mapSound . erase ( it ) ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + void AudioEngineImpl : : uncacheAll ( ) { <nl> + for ( auto it = mapSound . cbegin ( ) ; it ! = mapSound . cend ( ) ; + + it ) { <nl> + auto sound = it - > second ; <nl> + if ( sound ) { <nl> + sound - > release ( ) ; <nl> + } <nl> + } <nl> + mapSound . clear ( ) ; <nl> + } ; <nl> + <nl> + <nl> + int AudioEngineImpl : : preload ( const std : : string & filePath , std : : function < void ( bool isSuccess ) > callback ) { <nl> + FMOD : : Sound * sound = findSound ( filePath ) ; <nl> + if ( ! sound ) { <nl> + std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( filePath ) ; <nl> + FMOD_RESULT result = pSystem - > createSound ( fullPath . c_str ( ) , FMOD_LOOP_OFF , 0 , & sound ) ; <nl> + if ( ERRCHECK ( result ) ) { <nl> + printf ( " sound effect in % s could not be preload \ n " , filePath . c_str ( ) ) ; <nl> + if ( callback ) { <nl> + callback ( false ) ; <nl> + } <nl> + return - 1 ; <nl> + } <nl> + mapSound [ fullPath ] = sound ; <nl> + } <nl> + <nl> + int id = mapChannelInfo . size ( ) + 1 ; <nl> + auto & chanelInfo = mapChannelInfo [ id ] ; <nl> + chanelInfo . sound = sound ; <nl> + chanelInfo . id = ( size_t ) id ; <nl> + chanelInfo . channel = nullptr ; <nl> + chanelInfo . callback = nullptr ; <nl> + chanelInfo . path = filePath ; <nl> + / / we are going to use UserData to store pointer to Channel when playing <nl> + chanelInfo . sound - > setUserData ( ( void * ) id ) ; <nl> + <nl> + if ( callback ) { <nl> + callback ( true ) ; <nl> + } <nl> + return id ; <nl> + } ; <nl> + <nl> + <nl> + void AudioEngineImpl : : update ( float dt ) { <nl> + pSystem - > update ( ) ; <nl> + } ; <nl> + <nl> + <nl> + FMOD : : Sound * AudioEngineImpl : : findSound ( const std : : string & path ) { <nl> + std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( path ) ; <nl> + std : : map < std : : string , FMOD : : Sound * > : : const_iterator it = mapSound . find ( fullPath ) ; <nl> + return ( it ! = mapSound . end ( ) ) ? ( it - > second ) : nullptr ; <nl> + } <nl> + <nl> + <nl> + FMOD : : Channel * AudioEngineImpl : : getChannel ( FMOD : : Sound * sound ) { <nl> + size_t id ; <nl> + void * data ; <nl> + sound - > getUserData ( & data ) ; <nl> + id = ( size_t ) data ; <nl> + return mapChannelInfo [ id ] . channel ; <nl> + } ; <nl> new file mode 100644 <nl> index 000000000000 . . c0625ad1f1ca <nl> mmm / dev / null <nl> ppp b / cocos / audio / linux / AudioEngine - linux . h <nl> <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> + Copyright ( c ) 2015 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> + # include " platform / CCPlatformConfig . h " <nl> + <nl> + # if CC_TARGET_PLATFORM = = CC_PLATFORM_LINUX <nl> + <nl> + # ifndef __AUDIO_ENGINE_LINUX_H_ <nl> + # define __AUDIO_ENGINE_LINUX_H_ <nl> + <nl> + # include < functional > <nl> + # include < iostream > <nl> + # include < map > <nl> + # include " fmod . hpp " <nl> + # include " fmod_errors . h " <nl> + # include " AudioEngine . h " <nl> + <nl> + # include " base / CCRef . h " <nl> + <nl> + NS_CC_BEGIN <nl> + namespace experimental { <nl> + # define MAX_AUDIOINSTANCES 32 <nl> + <nl> + class CC_DLL AudioEngineImpl : public cocos2d : : Ref <nl> + { <nl> + public : <nl> + AudioEngineImpl ( ) ; <nl> + ~ AudioEngineImpl ( ) ; <nl> + <nl> + bool init ( ) ; <nl> + int play2d ( const std : : string & fileFullPath , bool loop , float volume ) ; <nl> + void setVolume ( int audioID , float volume ) ; <nl> + void setLoop ( int audioID , bool loop ) ; <nl> + bool pause ( int audioID ) ; <nl> + bool resume ( int audioID ) ; <nl> + bool stop ( int audioID ) ; <nl> + void stopAll ( ) ; <nl> + float getDuration ( int audioID ) ; <nl> + float getCurrentTime ( int audioID ) ; <nl> + bool setCurrentTime ( int audioID , float time ) ; <nl> + void setFinishCallback ( int audioID , const std : : function < void ( int , const std : : string & ) > & callback ) ; <nl> + <nl> + void uncache ( const std : : string & filePath ) ; <nl> + void uncacheAll ( ) ; <nl> + <nl> + <nl> + int preload ( const std : : string & filePath , std : : function < void ( bool isSuccess ) > callback ) ; <nl> + <nl> + void update ( float dt ) ; <nl> + <nl> + / * * <nl> + * used internally by ffmod callback <nl> + * / <nl> + void onSoundFinished ( FMOD : : Channel * channel ) ; <nl> + <nl> + private : <nl> + <nl> + / * * <nl> + * returns null if a sound with the given path is not found <nl> + * / <nl> + FMOD : : Sound * findSound ( const std : : string & path ) ; <nl> + <nl> + FMOD : : Channel * getChannel ( FMOD : : Sound * ) ; <nl> + <nl> + struct ChannelInfo { <nl> + size_t id ; <nl> + std : : string path ; <nl> + FMOD : : Sound * sound ; <nl> + FMOD : : Channel * channel ; <nl> + bool loop ; <nl> + float volume ; <nl> + std : : function < void ( int , const std : : string & ) > callback ; <nl> + } ; <nl> + <nl> + std : : map < int , ChannelInfo > mapChannelInfo ; <nl> + <nl> + std : : map < std : : string , FMOD : : Sound * > mapSound ; <nl> + <nl> + FMOD : : System * pSystem ; <nl> + <nl> + } ; <nl> + } <nl> + NS_CC_END <nl> + # endif / / __AUDIO_ENGINE_LINUX_H_ <nl> + # endif <nl> + <nl> deleted file mode 100644 <nl> index 28aafdce16f3 . . 000000000000 <nl> mmm a / cocos / audio / linux / AudioPlayer . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2011 Laschweinski <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 AUDIOPLAYER_H_ <nl> - # define AUDIOPLAYER_H_ <nl> - <nl> - namespace CocosDenshion { <nl> - <nl> - class AudioPlayer { <nl> - public : <nl> - virtual void close ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Preload background music <nl> - @ param pszFilePath The path of the background music file , or the FileName of T_SoundResInfo <nl> - * / <nl> - virtual void preloadBackgroundMusic ( const char * pszFilePath ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Play background music <nl> - @ param pszFilePath The path of the background music file , or the FileName of T_SoundResInfo <nl> - @ param bLoop Whether the background music loop or not <nl> - * / <nl> - virtual void playBackgroundMusic ( const char * pszFilePath , bool bLoop = false ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Stop playing background music <nl> - @ param bReleaseData If release the background music data or not . As default value is false <nl> - * / <nl> - virtual void stopBackgroundMusic ( bool bReleaseData = false ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Pause playing background music <nl> - * / <nl> - virtual void pauseBackgroundMusic ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Resume playing background music <nl> - * / <nl> - virtual void resumeBackgroundMusic ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Rewind playing background music <nl> - * / <nl> - virtual void rewindBackgroundMusic ( ) = 0 ; <nl> - <nl> - virtual bool willPlayBackgroundMusic ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Whether the background music is playing <nl> - @ return If is playing return true , or return false <nl> - * / <nl> - virtual bool isBackgroundMusicPlaying ( ) = 0 ; <nl> - <nl> - / / properties <nl> - / * * <nl> - @ brief The volume of the background music max value is 1 . 0 , the min value is 0 . 0 <nl> - * / <nl> - virtual float getBackgroundMusicVolume ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief set the volume of background music <nl> - @ param volume must be in 0 . 0 ~ 1 . 0 <nl> - * / <nl> - virtual void setBackgroundMusicVolume ( float volume ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief The volume of the effects max value is 1 . 0 , the min value is 0 . 0 <nl> - * / <nl> - virtual float getEffectsVolume ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief set the volume of sound effecs <nl> - @ param volume must be in 0 . 0 ~ 1 . 0 <nl> - * / <nl> - virtual void setEffectsVolume ( float volume ) = 0 ; <nl> - <nl> - / / for sound effects <nl> - / * * <nl> - @ brief Play sound effect <nl> - @ param pszFilePath The path of the effect file , or the FileName of T_SoundResInfo <nl> - @ bLoop Whether to loop the effect playing , default value is false <nl> - * / <nl> - virtual unsigned int playEffect ( const char * pszFilePath , bool bLoop , <nl> - float pitch , float pan , float gain ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief Stop playing sound effect <nl> - @ param nSoundId The return value of function playEffect <nl> - * / <nl> - virtual void stopEffect ( unsigned int nSoundId ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief preload a compressed audio file <nl> - @ details the compressed audio will be decode to wave , then write into an <nl> - internal buffer in SimpleaudioEngine <nl> - * / <nl> - virtual void preloadEffect ( const char * pszFilePath ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief unload the preloaded effect from internal buffer <nl> - @ param [ in ] pszFilePath The path of the effect file , or the FileName of T_SoundResInfo <nl> - * / <nl> - virtual void unloadEffect ( const char * pszFilePath ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief pause an effect identified by sound id <nl> - @ param [ in ] uSoundId sound id <nl> - * / <nl> - virtual void pauseEffect ( unsigned int uSoundId ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief pause all playing effects <nl> - * / <nl> - virtual void pauseAllEffects ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief resume an effect identified by sound id <nl> - @ param [ in ] uSoundId sound id <nl> - * / <nl> - virtual void resumeEffect ( unsigned int uSoundId ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief resume a effect identified by sound id <nl> - * / <nl> - virtual void resumeAllEffects ( ) = 0 ; <nl> - <nl> - / * * <nl> - @ brief stop all playing effects <nl> - * / <nl> - virtual void stopAllEffects ( ) = 0 ; <nl> - } ; <nl> - } <nl> - <nl> - <nl> - # endif / * AUDIOPLAYER_H_ * / <nl> deleted file mode 100644 <nl> index ffe27136a582 . . 000000000000 <nl> mmm a / cocos / audio / linux / FmodAudioPlayer . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2011 Laschweinski <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 " FmodAudioPlayer . h " <nl> - # include < stdio . h > <nl> - # include " stdlib . h " <nl> - # include " assert . h " <nl> - # include " string . h " <nl> - <nl> - # define szMusicSuffix " | " <nl> - <nl> - namespace CocosDenshion { <nl> - <nl> - FmodAudioPlayer * FmodAudioPlayer : : sharedPlayer ( ) { <nl> - static FmodAudioPlayer s_SharedPlayer ; <nl> - return & s_SharedPlayer ; <nl> - } <nl> - <nl> - void ERRCHECKWITHEXIT ( FMOD_RESULT result ) { <nl> - if ( result ! = FMOD_OK ) { <nl> - printf ( " FMOD error ! ( % d ) % s \ n " , result , FMOD_ErrorString ( result ) ) ; <nl> - / / exit ( - 1 ) ; <nl> - } <nl> - } <nl> - <nl> - bool ERRCHECK ( FMOD_RESULT result ) { <nl> - if ( result ! = FMOD_OK ) { <nl> - printf ( " FMOD error ! ( % d ) % s \ n " , result , FMOD_ErrorString ( result ) ) ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> - <nl> - FmodAudioPlayer : : FmodAudioPlayer ( ) : <nl> - pMusic ( 0 ) , pBGMChannel ( 0 ) , iSoundChannelCount ( 0 ) { <nl> - init ( ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : init ( ) { <nl> - / / init <nl> - FMOD_RESULT result ; <nl> - FMOD : : ChannelGroup * masterChannelGroup ; <nl> - <nl> - / * <nl> - Create a System object and initialize . <nl> - * / <nl> - result = FMOD : : System_Create ( & pSystem ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - result = pSystem - > setOutput ( FMOD_OUTPUTTYPE_ALSA ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - result = pSystem - > init ( 32 , FMOD_INIT_NORMAL , 0 ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - result = pSystem - > createChannelGroup ( " Channel Group " , & pChannelGroup ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - result = pSystem - > getMasterChannelGroup ( & masterChannelGroup ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - result = masterChannelGroup - > addGroup ( pChannelGroup ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - mapEffectSound . clear ( ) ; <nl> - <nl> - } <nl> - <nl> - void FmodAudioPlayer : : close ( ) { <nl> - FMOD_RESULT result ; <nl> - / / BGM <nl> - if ( pBGMChannel ! = NULL ) { <nl> - result = pBGMChannel - > stop ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - pBGMChannel = 0 ; <nl> - } <nl> - <nl> - if ( pMusic ! = NULL ) { <nl> - result = pMusic - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - pMusic = 0 ; <nl> - } <nl> - <nl> - result = pChannelGroup - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - sMusicPath . clear ( ) ; <nl> - <nl> - result = pSystem - > close ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - result = pSystem - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - init ( ) ; <nl> - } <nl> - <nl> - FmodAudioPlayer : : ~ FmodAudioPlayer ( ) { <nl> - FMOD_RESULT result ; <nl> - / / BGM <nl> - if ( pBGMChannel ! = NULL ) { <nl> - result = pBGMChannel - > stop ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - } <nl> - <nl> - if ( pMusic ! = NULL ) { <nl> - result = pMusic - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - } <nl> - <nl> - result = pChannelGroup - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - result = pSystem - > close ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - result = pSystem - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - } <nl> - <nl> - / / BGM <nl> - void FmodAudioPlayer : : preloadBackgroundMusic ( const char * pszFilePath ) { <nl> - FMOD_RESULT result ; <nl> - pSystem - > update ( ) ; <nl> - string sNewMusicPath = string ( pszFilePath ) + szMusicSuffix ; <nl> - if ( pMusic & & sNewMusicPath ! = sMusicPath ) { <nl> - / / release old <nl> - result = pMusic - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - sMusicPath = sNewMusicPath ; <nl> - <nl> - } <nl> - <nl> - result = pSystem - > createSound ( pszFilePath , FMOD_LOOP_NORMAL , 0 , & pMusic ) ; <nl> - ERRCHECK ( result ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : playBackgroundMusic ( const char * pszFilePath , bool bLoop ) { <nl> - pSystem - > update ( ) ; <nl> - if ( pMusic = = NULL ) { <nl> - / / did not load it <nl> - / / load the new music <nl> - FMOD_RESULT result = pSystem - > createSound ( pszFilePath , FMOD_LOOP_NORMAL , <nl> - 0 , & pMusic ) ; <nl> - if ( ! ERRCHECK ( result ) ) { <nl> - sMusicPath = string ( pszFilePath ) + szMusicSuffix ; <nl> - } <nl> - <nl> - } else { <nl> - string sNewMusicPath = string ( pszFilePath ) + szMusicSuffix ; <nl> - if ( pBGMChannel ) { <nl> - pBGMChannel - > stop ( ) ; <nl> - pBGMChannel = 0 ; <nl> - } <nl> - <nl> - if ( sNewMusicPath ! = sMusicPath ) { <nl> - <nl> - pMusic - > release ( ) ; <nl> - / / load the new music <nl> - FMOD_RESULT result = pSystem - > createSound ( pszFilePath , <nl> - FMOD_LOOP_NORMAL , 0 , & pMusic ) ; <nl> - <nl> - if ( ! ERRCHECK ( result ) ) { <nl> - sMusicPath = sNewMusicPath ; <nl> - } <nl> - } <nl> - <nl> - } <nl> - <nl> - FMOD_RESULT result = pSystem - > playSound ( FMOD_CHANNEL_FREE , pMusic , true , <nl> - & pBGMChannel ) ; <nl> - if ( ! ERRCHECK ( result ) ) { <nl> - pBGMChannel - > setLoopCount ( ( bLoop ) ? - 1 : 0 ) ; <nl> - result = pBGMChannel - > setPaused ( false ) ; <nl> - } <nl> - } <nl> - <nl> - void FmodAudioPlayer : : stopBackgroundMusic ( bool bReleaseData ) { <nl> - FMOD_RESULT result ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - if ( pBGMChannel = = NULL | | pMusic = = NULL ) { <nl> - return ; <nl> - } <nl> - if ( bReleaseData ) { <nl> - result = pBGMChannel - > stop ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - result = pMusic - > release ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - pBGMChannel = 0 ; <nl> - pMusic = 0 ; <nl> - } else { <nl> - result = pBGMChannel - > stop ( ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - pBGMChannel = 0 ; <nl> - } <nl> - sMusicPath . clear ( ) ; <nl> - <nl> - } <nl> - <nl> - void FmodAudioPlayer : : pauseBackgroundMusic ( ) { <nl> - if ( pBGMChannel = = NULL ) { <nl> - return ; <nl> - } <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pBGMChannel - > setPaused ( true ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - } <nl> - <nl> - void FmodAudioPlayer : : resumeBackgroundMusic ( ) { <nl> - if ( pBGMChannel = = NULL ) { <nl> - return ; <nl> - } <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pBGMChannel - > setPaused ( false ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : rewindBackgroundMusic ( ) { <nl> - if ( pBGMChannel = = NULL ) { <nl> - return ; <nl> - } <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pBGMChannel - > setPosition ( 0 , FMOD_TIMEUNIT_MS ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - } <nl> - <nl> - bool FmodAudioPlayer : : willPlayBackgroundMusic ( ) { <nl> - pSystem - > update ( ) ; <nl> - return false ; / / do it according to win <nl> - } <nl> - <nl> - bool FmodAudioPlayer : : isBackgroundMusicPlaying ( ) { <nl> - bool bPlaying ; <nl> - if ( pBGMChannel = = NULL ) { <nl> - return false ; <nl> - } <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pBGMChannel - > isPlaying ( & bPlaying ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - return bPlaying ; <nl> - <nl> - } <nl> - <nl> - float FmodAudioPlayer : : getBackgroundMusicVolume ( ) { <nl> - float fVolumn ; <nl> - if ( pBGMChannel = = NULL ) { <nl> - return 0 ; <nl> - } <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pBGMChannel - > getVolume ( & fVolumn ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - return fVolumn ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : setBackgroundMusicVolume ( float volume ) { <nl> - if ( pBGMChannel = = NULL ) { <nl> - return ; <nl> - } <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pBGMChannel - > setVolume ( volume ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - } <nl> - / / ~ BGM <nl> - <nl> - / / for sound effects <nl> - float FmodAudioPlayer : : getEffectsVolume ( ) { <nl> - float fVolumn ; <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pChannelGroup - > getVolume ( & fVolumn ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - return fVolumn ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : setEffectsVolume ( float volume ) { <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pChannelGroup - > setVolume ( volume ) ; <nl> - ERRCHECKWITHEXIT ( result ) ; <nl> - <nl> - } <nl> - <nl> - unsigned int FmodAudioPlayer : : playEffect ( const char * pszFilePath , bool bLoop , <nl> - float pitch , float pan , float gain ) { <nl> - FMOD : : Channel * pChannel ; <nl> - FMOD : : Sound * pSound = NULL ; <nl> - <nl> - do { <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < string , FMOD : : Sound * > : : iterator l_it = mapEffectSound . find ( <nl> - string ( pszFilePath ) ) ; <nl> - if ( l_it = = mapEffectSound . end ( ) ) { <nl> - / / no load it yet <nl> - preloadEffect ( pszFilePath ) ; <nl> - l_it = mapEffectSound . find ( string ( pszFilePath ) ) ; <nl> - } <nl> - pSound = l_it - > second ; <nl> - if ( pSound = = NULL ) { <nl> - break ; <nl> - } <nl> - <nl> - FMOD_RESULT result = pSystem - > playSound ( FMOD_CHANNEL_FREE , pSound , true , <nl> - & pChannel ) ; <nl> - <nl> - if ( ERRCHECK ( result ) ) { <nl> - printf ( " sound effect in % s could not be played " , pszFilePath ) ; <nl> - break ; <nl> - } <nl> - <nl> - pChannel - > setChannelGroup ( pChannelGroup ) ; <nl> - pChannel - > setPan ( pan ) ; <nl> - float freq = 0 ; <nl> - pChannel - > getFrequency ( & freq ) ; <nl> - pChannel - > setFrequency ( pitch * freq ) ; <nl> - pChannel - > setVolume ( gain ) ; <nl> - <nl> - / / set its loop <nl> - pChannel - > setLoopCount ( ( bLoop ) ? - 1 : 0 ) ; <nl> - result = pChannel - > setPaused ( false ) ; <nl> - <nl> - mapEffectSoundChannel [ iSoundChannelCount ] = pChannel ; <nl> - return iSoundChannelCount + + ; <nl> - } while ( 0 ) ; <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : stopEffect ( unsigned int nSoundId ) { <nl> - FMOD : : Channel * pChannel ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < unsigned int , FMOD : : Channel * > : : iterator l_it = <nl> - mapEffectSoundChannel . find ( nSoundId ) ; <nl> - if ( l_it = = mapEffectSoundChannel . end ( ) ) { <nl> - / / no play yet <nl> - return ; <nl> - } <nl> - pChannel = l_it - > second ; <nl> - / / stop the channel ; <nl> - pChannel - > stop ( ) ; <nl> - <nl> - / / delete from the map ; <nl> - mapEffectSoundChannel . erase ( nSoundId ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : pauseEffect ( unsigned int uSoundId ) { <nl> - FMOD : : Channel * pChannel ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < unsigned int , FMOD : : Channel * > : : iterator l_it = <nl> - mapEffectSoundChannel . find ( uSoundId ) ; <nl> - if ( l_it = = mapEffectSoundChannel . end ( ) ) { <nl> - / / no play yet <nl> - return ; <nl> - } <nl> - pChannel = l_it - > second ; <nl> - / / pause the channel ; <nl> - pChannel - > setPaused ( true ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : pauseAllEffects ( ) { <nl> - FMOD : : Channel * pChannel ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < unsigned int , FMOD : : Channel * > : : iterator l_it = <nl> - mapEffectSoundChannel . begin ( ) ; <nl> - <nl> - for ( ; l_it ! = mapEffectSoundChannel . end ( ) ; l_it + + ) { <nl> - pChannel = l_it - > second ; <nl> - / / pause the channel ; <nl> - pChannel - > setPaused ( true ) ; <nl> - } <nl> - } <nl> - <nl> - void FmodAudioPlayer : : resumeEffect ( unsigned int uSoundId ) { <nl> - FMOD : : Channel * pChannel ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < unsigned int , FMOD : : Channel * > : : iterator l_it = <nl> - mapEffectSoundChannel . find ( uSoundId ) ; <nl> - if ( l_it = = mapEffectSoundChannel . end ( ) ) { <nl> - / / no play yet <nl> - return ; <nl> - } <nl> - <nl> - pChannel = l_it - > second ; <nl> - / / resume the channel ; <nl> - pChannel - > setPaused ( false ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : resumeAllEffects ( ) { <nl> - FMOD : : Channel * pChannel ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < unsigned int , FMOD : : Channel * > : : iterator l_it = <nl> - mapEffectSoundChannel . begin ( ) ; <nl> - <nl> - for ( ; l_it ! = mapEffectSoundChannel . end ( ) ; l_it + + ) { <nl> - pChannel = l_it - > second ; <nl> - / / resume the channel ; <nl> - pChannel - > setPaused ( false ) ; <nl> - } <nl> - } <nl> - <nl> - void FmodAudioPlayer : : stopAllEffects ( ) { <nl> - FMOD : : Channel * pChannel ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < unsigned int , FMOD : : Channel * > : : iterator l_it = <nl> - mapEffectSoundChannel . begin ( ) ; <nl> - <nl> - for ( ; l_it ! = mapEffectSoundChannel . end ( ) ; l_it + + ) { <nl> - pChannel = l_it - > second ; <nl> - / / resume the channel ; <nl> - pChannel - > stop ( ) ; <nl> - } <nl> - <nl> - mapEffectSoundChannel . clear ( ) ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : preloadEffect ( const char * pszFilePath ) { <nl> - FMOD : : Sound * pLoadSound ; <nl> - <nl> - pSystem - > update ( ) ; <nl> - FMOD_RESULT result = pSystem - > createSound ( pszFilePath , FMOD_LOOP_NORMAL , 0 , <nl> - & pLoadSound ) ; <nl> - if ( ERRCHECK ( result ) ) { <nl> - printf ( " sound effect in % s could not be preload " , pszFilePath ) ; <nl> - return ; <nl> - } <nl> - mapEffectSound [ string ( pszFilePath ) ] = pLoadSound ; <nl> - } <nl> - <nl> - void FmodAudioPlayer : : unloadEffect ( const char * pszFilePath ) { <nl> - FMOD : : Sound * pSound ; <nl> - pSystem - > update ( ) ; <nl> - <nl> - map < string , FMOD : : Sound * > : : iterator l_it = mapEffectSound . find ( <nl> - string ( pszFilePath ) ) ; <nl> - if ( l_it = = mapEffectSound . end ( ) ) { <nl> - / / no load yet <nl> - return ; <nl> - } <nl> - pSound = l_it - > second ; <nl> - <nl> - / / release the sound ; <nl> - pSound - > release ( ) ; <nl> - <nl> - / / delete from the map <nl> - mapEffectSound . erase ( string ( pszFilePath ) ) ; <nl> - } <nl> - <nl> - / / ~ for sound effects <nl> - <nl> - } / * namespace CocosDenshion * / <nl> deleted file mode 100644 <nl> index 887d67ea8a16 . . 000000000000 <nl> mmm a / cocos / audio / linux / FmodAudioPlayer . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2011 Laschweinski <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 FMODAUDIOPLAYER_H_ <nl> - # define FMODAUDIOPLAYER_H_ <nl> - <nl> - # include " fmod . hpp " <nl> - # include " fmod_errors . h " <nl> - # include " AudioPlayer . h " <nl> - # include " string " <nl> - # include < map > <nl> - <nl> - <nl> - using namespace std ; <nl> - <nl> - namespace CocosDenshion { <nl> - <nl> - class FmodAudioPlayer : public AudioPlayer { <nl> - public : <nl> - FmodAudioPlayer ( ) ; <nl> - virtual ~ FmodAudioPlayer ( ) ; <nl> - <nl> - static FmodAudioPlayer * sharedPlayer ( ) ; <nl> - <nl> - virtual void close ( ) ; <nl> - <nl> - <nl> - <nl> - / * * <nl> - @ brief Preload background music <nl> - @ param pszFilePath The path of the background music file , or the FileName of T_SoundResInfo <nl> - * / <nl> - virtual void preloadBackgroundMusic ( const char * pszFilePath ) ; <nl> - <nl> - / * * <nl> - @ brief Play background music <nl> - @ param pszFilePath The path of the background music file , or the FileName of T_SoundResInfo <nl> - @ param bLoop Whether the background music loop or not <nl> - * / <nl> - virtual void playBackgroundMusic ( const char * pszFilePath , bool bLoop ) ; <nl> - <nl> - / * * <nl> - @ brief Stop playing background music <nl> - @ param bReleaseData If release the background music data or not . As default value is false <nl> - * / <nl> - virtual void stopBackgroundMusic ( bool bReleaseData ) ; <nl> - <nl> - / * * <nl> - @ brief Pause playing background music <nl> - * / <nl> - virtual void pauseBackgroundMusic ( ) ; <nl> - <nl> - / * * <nl> - @ brief Resume playing background music <nl> - * / <nl> - virtual void resumeBackgroundMusic ( ) ; <nl> - <nl> - / * * <nl> - @ brief Rewind playing background music <nl> - * / <nl> - virtual void rewindBackgroundMusic ( ) ; <nl> - <nl> - virtual bool willPlayBackgroundMusic ( ) ; <nl> - <nl> - / * * <nl> - @ brief Whether the background music is playing <nl> - @ return If is playing return true , or return false <nl> - * / <nl> - virtual bool isBackgroundMusicPlaying ( ) ; <nl> - <nl> - / / properties <nl> - / * * <nl> - @ brief The volume of the background music max value is 1 . 0 , the min value is 0 . 0 <nl> - * / <nl> - virtual float getBackgroundMusicVolume ( ) ; <nl> - <nl> - / * * <nl> - @ brief set the volume of background music <nl> - @ param volume must be in 0 . 0 ~ 1 . 0 <nl> - * / <nl> - virtual void setBackgroundMusicVolume ( float volume ) ; <nl> - <nl> - / * * <nl> - @ brief The volume of the effects max value is 1 . 0 , the min value is 0 . 0 <nl> - * / <nl> - virtual float getEffectsVolume ( ) ; <nl> - <nl> - / * * <nl> - @ brief set the volume of sound effecs <nl> - @ param volume must be in 0 . 0 ~ 1 . 0 <nl> - * / <nl> - virtual void setEffectsVolume ( float volume ) ; <nl> - <nl> - / / for sound effects <nl> - / * * <nl> - @ brief Play sound effect <nl> - @ param pszFilePath The path of the effect file , or the FileName of T_SoundResInfo <nl> - @ bLoop Whether to loop the effect playing , default value is false <nl> - * / <nl> - virtual unsigned int playEffect ( const char * pszFilePath , bool bLoop , <nl> - float pitch , float pan , float gain ) ; <nl> - <nl> - / * * <nl> - @ brief Stop playing sound effect <nl> - @ param nSoundId The return value of function playEffect <nl> - * / <nl> - virtual void stopEffect ( unsigned int nSoundId ) ; <nl> - <nl> - / * * <nl> - @ brief preload a compressed audio file <nl> - @ details the compressed audio will be decode to wave , then write into an <nl> - internal buffer in SimpleaudioEngine <nl> - * / <nl> - virtual void preloadEffect ( const char * pszFilePath ) ; <nl> - <nl> - / * * <nl> - @ brief unload the preloaded effect from internal buffer <nl> - @ param [ in ] pszFilePath The path of the effect file , or the FileName of T_SoundResInfo <nl> - * / <nl> - virtual void unloadEffect ( const char * pszFilePath ) ; <nl> - <nl> - / * * <nl> - @ brief pause an effect identified by sound id <nl> - @ param [ in ] uSoundId sound id <nl> - * / <nl> - virtual void pauseEffect ( unsigned int uSoundId ) ; <nl> - <nl> - / * * <nl> - @ brief pause all playing effects <nl> - * / <nl> - virtual void pauseAllEffects ( ) ; <nl> - <nl> - / * * <nl> - @ brief resume an effect identified by sound id <nl> - @ param [ in ] uSoundId sound id <nl> - * / <nl> - virtual void resumeEffect ( unsigned int uSoundId ) ; <nl> - <nl> - / * * <nl> - @ brief resume a effect identified by sound id <nl> - * / <nl> - virtual void resumeAllEffects ( ) ; <nl> - <nl> - / * * <nl> - @ brief stop all playing effects <nl> - * / <nl> - virtual void stopAllEffects ( ) ; <nl> - <nl> - private : <nl> - <nl> - void init ( ) ; <nl> - map < string , FMOD : : Sound * > mapEffectSound ; <nl> - map < unsigned int , FMOD : : Channel * > mapEffectSoundChannel ; <nl> - <nl> - FMOD : : System * pSystem ; <nl> - FMOD : : Sound * pMusic ; / / BGM <nl> - FMOD : : Channel * pBGMChannel ; <nl> - <nl> - FMOD : : ChannelGroup * pChannelGroup ; <nl> - <nl> - unsigned int iSoundChannelCount ; <nl> - <nl> - string sMusicPath ; <nl> - <nl> - } ; <nl> - <nl> - } / * namespace CocosDenshion * / <nl> - # endif / * FMODAUDIOPLAYER_H_ * / <nl> new file mode 100644 <nl> index 000000000000 . . 828271ff2f7f <nl> mmm / dev / null <nl> ppp b / cocos / audio / linux / SimpleAudioEngine . cpp <nl> <nl> + # include < iostream > <nl> + <nl> + # include " . . / include / SimpleAudioEngine . h " <nl> + # include " . . / include / AudioEngine . h " <nl> + <nl> + using namespace CocosDenshion ; <nl> + using namespace cocos2d ; <nl> + using namespace cocos2d : : experimental ; <nl> + <nl> + <nl> + struct SimpleAudioEngineLinux { <nl> + SimpleAudioEngine * engine = nullptr ; <nl> + int musicid ; <nl> + float effectsvolume ; <nl> + std : : string musicpath ; <nl> + } ; <nl> + <nl> + SimpleAudioEngineLinux * g_SimpleAudioEngineLinux = nullptr ; <nl> + <nl> + <nl> + SimpleAudioEngine * SimpleAudioEngine : : getInstance ( ) { <nl> + if ( ! g_SimpleAudioEngineLinux ) { <nl> + g_SimpleAudioEngineLinux = new SimpleAudioEngineLinux ( ) ; <nl> + g_SimpleAudioEngineLinux - > engine = new SimpleAudioEngine ( ) ; <nl> + } <nl> + return g_SimpleAudioEngineLinux - > engine ; <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : end ( ) { <nl> + if ( g_SimpleAudioEngineLinux ) { <nl> + delete g_SimpleAudioEngineLinux - > engine ; <nl> + delete g_SimpleAudioEngineLinux ; <nl> + } <nl> + g_SimpleAudioEngineLinux = nullptr ; <nl> + } ; <nl> + <nl> + <nl> + SimpleAudioEngine : : SimpleAudioEngine ( ) { <nl> + g_SimpleAudioEngineLinux - > musicid = - 1 ; <nl> + g_SimpleAudioEngineLinux - > effectsvolume = 1 . 0f ; <nl> + } ; <nl> + <nl> + SimpleAudioEngine : : ~ SimpleAudioEngine ( ) { <nl> + <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : preloadBackgroundMusic ( const char * filePath ) { <nl> + g_SimpleAudioEngineLinux - > musicpath = filePath ; <nl> + AudioEngine : : preload ( filePath ) ; <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : playBackgroundMusic ( const char * filePath , bool loop ) { <nl> + g_SimpleAudioEngineLinux - > musicpath = filePath ; <nl> + g_SimpleAudioEngineLinux - > musicid = AudioEngine : : play2d ( filePath , loop ) ; <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : stopBackgroundMusic ( bool releaseData ) { <nl> + AudioEngine : : stop ( g_SimpleAudioEngineLinux - > musicid ) ; <nl> + if ( releaseData ) { <nl> + AudioEngine : : uncache ( g_SimpleAudioEngineLinux - > musicpath . c_str ( ) ) ; <nl> + } <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : pauseBackgroundMusic ( ) { <nl> + AudioEngine : : pause ( g_SimpleAudioEngineLinux - > musicid ) ; <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : resumeBackgroundMusic ( ) { <nl> + AudioEngine : : resume ( g_SimpleAudioEngineLinux - > musicid ) ; <nl> + } ; <nl> + <nl> + void SimpleAudioEngine : : rewindBackgroundMusic ( ) { <nl> + AudioEngine : : setCurrentTime ( g_SimpleAudioEngineLinux - > musicid , 0 ) ; <nl> + } ; <nl> + <nl> + bool SimpleAudioEngine : : willPlayBackgroundMusic ( ) { <nl> + return g_SimpleAudioEngineLinux - > musicid ! = - 1 ; <nl> + } ; <nl> + <nl> + bool SimpleAudioEngine : : isBackgroundMusicPlaying ( ) { <nl> + return AudioEngine : : getState ( g_SimpleAudioEngineLinux - > musicid ) = = AudioEngine : : AudioState : : PLAYING ; <nl> + } ; <nl> + <nl> + / / <nl> + / / properties <nl> + / / <nl> + <nl> + / * * <nl> + * The volume of the background music within the range of 0 . 0 as the minimum and 1 . 0 as the maximum . <nl> + * @ js getMusicVolume <nl> + * @ lua getMusicVolume <nl> + * / <nl> + float SimpleAudioEngine : : getBackgroundMusicVolume ( ) { <nl> + return AudioEngine : : getVolume ( g_SimpleAudioEngineLinux - > musicid ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Set the volume of background music . <nl> + * <nl> + * @ param volume must be within the range of 0 . 0 as the minimum and 1 . 0 as the maximum . <nl> + * @ js setMusicVolume <nl> + * @ lua setMusicVolume <nl> + * / <nl> + void SimpleAudioEngine : : setBackgroundMusicVolume ( float volume ) { <nl> + AudioEngine : : setVolume ( g_SimpleAudioEngineLinux - > musicid , volume ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * The volume of the effects within the range of 0 . 0 as the minimum and 1 . 0 as the maximum . <nl> + * / <nl> + float SimpleAudioEngine : : getEffectsVolume ( ) { <nl> + return g_SimpleAudioEngineLinux - > effectsvolume ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Set the volume of sound effects . <nl> + * <nl> + * @ param volume must be within the range of 0 . 0 as the minimum and 1 . 0 as the maximum . <nl> + * / <nl> + void SimpleAudioEngine : : setEffectsVolume ( float volume ) { <nl> + g_SimpleAudioEngineLinux - > effectsvolume = volume ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Play sound effect with a file path , pitch , pan and gain . <nl> + * <nl> + * @ param filePath The path of the effect file . <nl> + * @ param loop Determines whether to loop the effect playing or not . The default value is false . <nl> + * @ param pitch Frequency , normal value is 1 . 0 . Will also change effect play time . <nl> + * @ param pan Stereo effect , in the range of [ - 1 . . 1 ] where - 1 enables only left channel . <nl> + * @ param gain Volume , in the range of [ 0 . . 1 ] . The normal value is 1 . <nl> + * @ return The sound id . <nl> + * <nl> + * @ note Full support is under development , now there are limitations : <nl> + * - no pitch effect on Samsung Galaxy S2 with OpenSL backend enabled ; <nl> + * - no pitch / pan / gain on win32 . <nl> + * / <nl> + unsigned int SimpleAudioEngine : : playEffect ( const char * filePath , bool loop , float pitch , float pan , float gain ) { <nl> + return AudioEngine : : play2d ( filePath , loop , gain ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Pause playing sound effect . <nl> + * <nl> + * @ param soundId The return value of function playEffect . <nl> + * / <nl> + void SimpleAudioEngine : : pauseEffect ( unsigned int soundId ) { <nl> + AudioEngine : : pause ( soundId ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Pause all playing sound effect . <nl> + * / <nl> + void SimpleAudioEngine : : pauseAllEffects ( ) { <nl> + AudioEngine : : pauseAll ( ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Resume playing sound effect . <nl> + * <nl> + * @ param soundId The return value of function playEffect . <nl> + * / <nl> + void SimpleAudioEngine : : resumeEffect ( unsigned int soundId ) { <nl> + AudioEngine : : resume ( soundId ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Resume all playing sound effect . <nl> + * / <nl> + void SimpleAudioEngine : : resumeAllEffects ( ) { <nl> + AudioEngine : : resumeAll ( ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Stop playing sound effect . <nl> + * <nl> + * @ param soundId The return value of function playEffect . <nl> + * / <nl> + void SimpleAudioEngine : : stopEffect ( unsigned int soundId ) { <nl> + AudioEngine : : stop ( soundId ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Stop all playing sound effects . <nl> + * / <nl> + void SimpleAudioEngine : : stopAllEffects ( ) { <nl> + AudioEngine : : stopAll ( ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Preload a compressed audio file . <nl> + * <nl> + * The compressed audio will be decoded to wave , then written into an internal buffer in SimpleAudioEngine . <nl> + * <nl> + * @ param filePath The path of the effect file . <nl> + * @ js NA <nl> + * / <nl> + void SimpleAudioEngine : : preloadEffect ( const char * filePath ) { <nl> + AudioEngine : : preload ( filePath ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Unload the preloaded effect from internal buffer . <nl> + * <nl> + * @ param filePath The path of the effect file . <nl> + * / <nl> + void SimpleAudioEngine : : unloadEffect ( const char * filePath ) { <nl> + AudioEngine : : uncache ( filePath ) ; <nl> + } ; <nl> + <nl> + <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 26fd913abe07 . . 000000000000 <nl> mmm a / cocos / audio / linux / SimpleAudioEngineFMOD . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2011 Laschweinski <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> - # ifndef OPENAL <nl> - <nl> - # include " audio / include / SimpleAudioEngine . h " <nl> - # include " FmodAudioPlayer . h " <nl> - # include " cocos2d . h " <nl> - USING_NS_CC ; <nl> - <nl> - namespace CocosDenshion { <nl> - <nl> - static AudioPlayer * oAudioPlayer ; <nl> - <nl> - SimpleAudioEngine : : SimpleAudioEngine ( ) { <nl> - oAudioPlayer = FmodAudioPlayer : : sharedPlayer ( ) ; <nl> - } <nl> - <nl> - SimpleAudioEngine : : ~ SimpleAudioEngine ( ) { <nl> - } <nl> - <nl> - SimpleAudioEngine * SimpleAudioEngine : : getInstance ( ) { <nl> - static SimpleAudioEngine s_SharedEngine ; <nl> - return & s_SharedEngine ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : end ( ) { <nl> - if ( oAudioPlayer ) <nl> - { <nl> - oAudioPlayer - > close ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / BackgroundMusic <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void SimpleAudioEngine : : playBackgroundMusic ( const char * pszFilePath , <nl> - bool bLoop ) { <nl> - / / Changing file path to full path <nl> - std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( pszFilePath ) ; <nl> - oAudioPlayer - > playBackgroundMusic ( fullPath . c_str ( ) , bLoop ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : stopBackgroundMusic ( bool bReleaseData ) { <nl> - oAudioPlayer - > stopBackgroundMusic ( bReleaseData ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : pauseBackgroundMusic ( ) { <nl> - oAudioPlayer - > pauseBackgroundMusic ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : resumeBackgroundMusic ( ) { <nl> - oAudioPlayer - > resumeBackgroundMusic ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : rewindBackgroundMusic ( ) { <nl> - oAudioPlayer - > rewindBackgroundMusic ( ) ; <nl> - } <nl> - <nl> - bool SimpleAudioEngine : : willPlayBackgroundMusic ( ) { <nl> - return oAudioPlayer - > willPlayBackgroundMusic ( ) ; <nl> - } <nl> - <nl> - bool SimpleAudioEngine : : isBackgroundMusicPlaying ( ) { <nl> - return oAudioPlayer - > isBackgroundMusicPlaying ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : preloadBackgroundMusic ( const char * pszFilePath ) { <nl> - / / Changing file path to full path <nl> - std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( pszFilePath ) ; <nl> - return oAudioPlayer - > preloadBackgroundMusic ( fullPath . c_str ( ) ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / effect function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - unsigned int SimpleAudioEngine : : playEffect ( const char * pszFilePath , bool bLoop , <nl> - float pitch , float pan , float gain ) { <nl> - / / Changing file path to full path <nl> - std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( pszFilePath ) ; <nl> - return oAudioPlayer - > playEffect ( fullPath . c_str ( ) , bLoop , pitch , pan , gain ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : stopEffect ( unsigned int nSoundId ) { <nl> - return oAudioPlayer - > stopEffect ( nSoundId ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : preloadEffect ( const char * pszFilePath ) { <nl> - / / Changing file path to full path <nl> - std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( pszFilePath ) ; <nl> - return oAudioPlayer - > preloadEffect ( fullPath . c_str ( ) ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : unloadEffect ( const char * pszFilePath ) { <nl> - / / Changing file path to full path <nl> - std : : string fullPath = FileUtils : : getInstance ( ) - > fullPathForFilename ( pszFilePath ) ; <nl> - return oAudioPlayer - > unloadEffect ( fullPath . c_str ( ) ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : pauseEffect ( unsigned int uSoundId ) { <nl> - oAudioPlayer - > pauseEffect ( uSoundId ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : pauseAllEffects ( ) { <nl> - oAudioPlayer - > pauseAllEffects ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : resumeEffect ( unsigned int uSoundId ) { <nl> - oAudioPlayer - > resumeEffect ( uSoundId ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : resumeAllEffects ( ) { <nl> - oAudioPlayer - > resumeAllEffects ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : stopAllEffects ( ) { <nl> - oAudioPlayer - > stopAllEffects ( ) ; <nl> - } <nl> - <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / volume interface <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - float SimpleAudioEngine : : getBackgroundMusicVolume ( ) { <nl> - return oAudioPlayer - > getBackgroundMusicVolume ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : setBackgroundMusicVolume ( float volume ) { <nl> - return oAudioPlayer - > setBackgroundMusicVolume ( volume ) ; <nl> - } <nl> - <nl> - float SimpleAudioEngine : : getEffectsVolume ( ) { <nl> - return oAudioPlayer - > getEffectsVolume ( ) ; <nl> - } <nl> - <nl> - void SimpleAudioEngine : : setEffectsVolume ( float volume ) { <nl> - return oAudioPlayer - > setEffectsVolume ( volume ) ; <nl> - } <nl> - <nl> - <nl> - } / / end of namespace CocosDenshion <nl> - <nl> - # endif <nl> mmm a / external / config . json <nl> ppp b / external / config . json <nl> <nl> { <nl> - " version " : " v3 - deps - 75 " , <nl> + " version " : " v3 - deps - 78 " , <nl> " zip_file_size " : " 119277304 " , <nl> " repo_name " : " cocos2d - x - 3rd - party - libs - bin " , <nl> " repo_parent " : " https : / / github . com / cocos2d / " , <nl> mmm a / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> ppp b / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " platform / CCPlatformConfig . h " <nl> - # if CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT | | CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_IOS | | CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 <nl> - <nl> # include " NewAudioEngineTest . h " <nl> # include " ui / CocosGUI . h " <nl> <nl> std : : string AudioIssue11143Test : : subtitle ( ) const <nl> return " 2 seconds after first sound play , you should hear another sound . " ; <nl> } <nl> <nl> - # endif <nl> mmm a / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . h <nl> ppp b / tests / cpp - tests / Classes / NewAudioEngineTest / NewAudioEngineTest . h <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " platform / CCPlatformConfig . h " <nl> - # if CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT | | CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_IOS | | CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 <nl> <nl> # ifndef __NEWAUDIOENGINE_TEST_H_ <nl> # define __NEWAUDIOENGINE_TEST_H_ <nl> class AudioIssue11143Test : public AudioEngineTestDemo <nl> } ; <nl> <nl> # endif / * defined ( __NEWAUDIOENGINE_TEST_H_ ) * / <nl> - # endif <nl> mmm a / tests / cpp - tests / Classes / controller . cpp <nl> ppp b / tests / cpp - tests / Classes / controller . cpp <nl> class RootTests : public TestList <nl> addTest ( " Actions - Progress " , [ ] ( ) { return new ( std : : nothrow ) ActionsProgressTests ( ) ; } ) ; <nl> addTest ( " Allocator - Basic " , [ ] ( ) { return new ( std : : nothrow ) AllocatorTests ( ) ; } ) ; <nl> addTest ( " Audio - CocosDenshion " , [ ] ( ) { return new ( std : : nothrow ) CocosDenshionTests ( ) ; } ) ; <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT | | CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_IOS | | CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 ) <nl> addTest ( " Audio - NewAudioEngine " , [ ] ( ) { return new ( std : : nothrow ) AudioEngineTests ( ) ; } ) ; <nl> - # endif <nl> # if CC_ENABLE_BOX2D_INTEGRATION <nl> addTest ( " Box2d - Basic " , [ ] ( ) { return new ( std : : nothrow ) Box2DTests ( ) ; } ) ; <nl> addTest ( " Box2d - TestBed " , [ ] ( ) { return new ( std : : nothrow ) Box2dTestBedSuite ( ) ; } ) ; <nl> mmm a / tests / cpp - tests / Classes / tests . h <nl> ppp b / tests / cpp - tests / Classes / tests . h <nl> <nl> # include " ChipmunkTest / ChipmunkTest . h " <nl> # include " ClippingNodeTest / ClippingNodeTest . h " <nl> # endif <nl> - # if ( CC_TARGET_PLATFORM = = CC_PLATFORM_WINRT | | CC_TARGET_PLATFORM = = CC_PLATFORM_ANDROID | | CC_TARGET_PLATFORM = = CC_PLATFORM_IOS | | CC_TARGET_PLATFORM = = CC_PLATFORM_MAC | | CC_TARGET_PLATFORM = = CC_PLATFORM_WIN32 ) <nl> # include " NewAudioEngineTest / NewAudioEngineTest . h " <nl> - # endif <nl> # if ( CC_TARGET_PLATFORM ! = CC_PLATFORM_EMSCRIPEN ) <nl> # if ( CC_TARGET_PLATFORM ! = CC_PLATFORM_MARMALADE ) <nl> / / bada don ' t support libcurl <nl>
Merge pull request from cesarpachon / linuxAudioEngine
cocos2d/cocos2d-x
01e619f686c893102f1b0f4401f6417e36855004
2015-11-28T06:27:15Z
mmm a / buildscripts / hang_analyzer . py <nl> ppp b / buildscripts / hang_analyzer . py <nl> def callo ( a = [ ] ) : <nl> <nl> def find_program ( prog , paths ) : <nl> " " " Finds the specified program in env PATH , or tries a set of paths " " " <nl> + loc = spawn . find_executable ( prog ) <nl> + <nl> + if ( loc ! = None ) : <nl> + return loc <nl> <nl> for loc in paths : <nl> p = os . path . join ( loc , prog ) <nl> if os . path . exists ( p ) : <nl> return p <nl> <nl> - return spawn . find_executable ( prog ) <nl> + return None <nl> + <nl> <nl> class WindowsDumper ( object ) : <nl> <nl> class GDBDumper ( object ) : <nl> <nl> def __find_debugger ( self ) : <nl> " " " Finds the installed debugger " " " <nl> - return find_program ( ' gdb ' , [ ' / opt / mongodbtoolchain / bin ' ] ) <nl> + return find_program ( ' gdb ' , [ ' / usr / bin ' ] ) <nl> <nl> def dump_info ( self , pid , stream ) : <nl> dbg = self . __find_debugger ( ) <nl>
Revert " Changes to hang_analyzer to find right gdb version on Linux 64 . "
mongodb/mongo
a43cd78c0c21cdfb14b4fec48f76753c01dd1e6b
2015-07-02T18:06:00Z
mmm a / common / hardware_tici . py <nl> ppp b / common / hardware_tici . py <nl> <nl> - import serial <nl> - <nl> from common . hardware_base import HardwareBase <nl> from cereal import log <nl> import subprocess <nl> <nl> + NM = ' org . freedesktop . NetworkManager ' <nl> + NM_CON_ACT = NM + ' . Connection . Active ' <nl> + NM_DEV_WL = NM + ' . Device . Wireless ' <nl> + NM_AP = NM + ' . AccessPoint ' <nl> + DBUS_PROPS = ' org . freedesktop . DBus . Properties ' <nl> + <nl> + MM = ' org . freedesktop . ModemManager1 ' <nl> + MM_MODEM = MM + " . Modem " <nl> + MM_MODEM_SIMPLE = MM + " . Modem . Simple " <nl> + MM_SIM = MM + " . Sim " <nl> + <nl> + MM_MODEM_STATE_CONNECTED = 11 <nl> <nl> NetworkType = log . ThermalData . NetworkType <nl> NetworkStrength = log . ThermalData . NetworkStrength <nl> <nl> - <nl> - def run_at_command ( cmd , timeout = 0 . 1 ) : <nl> - with serial . Serial ( " / dev / ttyUSB2 " , timeout = timeout ) as ser : <nl> - ser . write ( cmd + b " \ r \ n " ) <nl> - ser . readline ( ) # Modem echos request <nl> - return ser . readline ( ) . decode ( ) . rstrip ( ) <nl> + # https : / / developer . gnome . org / ModemManager / unstable / ModemManager - Flags - and - Enumerations . html # MMModemAccessTechnology <nl> + MM_MODEM_ACCESS_TECHNOLOGY_UMTS = 1 < < 5 <nl> + MM_MODEM_ACCESS_TECHNOLOGY_LTE = 1 < < 14 <nl> <nl> <nl> class Tici ( HardwareBase ) : <nl> - def get_sound_card_online ( self ) : <nl> - return True <nl> + def __init__ ( self ) : <nl> + import dbus # pylint : disable = import - error <nl> <nl> - def get_imei ( self , slot ) : <nl> - if slot ! = 0 : <nl> - return " " <nl> + self . bus = dbus . SystemBus ( ) <nl> + self . nm = self . bus . get_object ( NM , ' / org / freedesktop / NetworkManager ' ) <nl> + self . mm = self . bus . get_object ( MM , ' / org / freedesktop / ModemManager1 ' ) <nl> <nl> - for _ in range ( 10 ) : <nl> - try : <nl> - imei = run_at_command ( b " AT + CGSN " ) <nl> - if len ( imei ) = = 15 : <nl> - return imei <nl> - except serial . SerialException : <nl> - pass <nl> - <nl> - raise RuntimeError ( " Error getting IMEI " ) <nl> + def get_sound_card_online ( self ) : <nl> + return True <nl> <nl> def get_serial ( self ) : <nl> return self . get_cmdline ( ) [ ' androidboot . serialno ' ] <nl> <nl> - def get_subscriber_info ( self ) : <nl> - return " " <nl> - <nl> def reboot ( self , reason = None ) : <nl> subprocess . check_output ( [ " sudo " , " reboot " ] ) <nl> <nl> def get_network_type ( self ) : <nl> - return NetworkType . wifi <nl> + primary_connection = self . nm . Get ( NM , ' PrimaryConnection ' , dbus_interface = DBUS_PROPS ) <nl> + primary_connection = self . bus . get_object ( NM , primary_connection ) <nl> + tp = primary_connection . Get ( NM_CON_ACT , ' Type ' , dbus_interface = DBUS_PROPS ) <nl> + <nl> + if tp in [ ' 802 - 3 - ethernet ' , ' 802 - 11 - wireless ' ] : <nl> + return NetworkType . wifi <nl> + elif tp in [ ' gsm ' ] : <nl> + modem = self . get_modem ( ) <nl> + access_t = modem . Get ( MM_MODEM , ' AccessTechnologies ' , dbus_interface = DBUS_PROPS ) <nl> + if access_t > = MM_MODEM_ACCESS_TECHNOLOGY_LTE : <nl> + return NetworkType . cell4G <nl> + elif access_t > = MM_MODEM_ACCESS_TECHNOLOGY_UMTS : <nl> + return NetworkType . cell3G <nl> + else : <nl> + return NetworkType . cell2G <nl> + <nl> + return NetworkType . none <nl> + <nl> + def get_modem ( self ) : <nl> + objects = self . mm . GetManagedObjects ( dbus_interface = " org . freedesktop . DBus . ObjectManager " ) <nl> + modem_path = list ( objects . keys ( ) ) [ 0 ] <nl> + return self . bus . get_object ( MM , modem_path ) <nl> + <nl> + def get_wlan ( self ) : <nl> + wlan_path = self . nm . GetDeviceByIpIface ( ' wlan0 ' , dbus_interface = NM ) <nl> + return self . bus . get_object ( NM , wlan_path ) <nl> <nl> def get_sim_info ( self ) : <nl> - return { <nl> - ' sim_id ' : ' ' , <nl> - ' mcc_mnc ' : None , <nl> - ' network_type ' : [ " Unknown " ] , <nl> - ' sim_state ' : [ " ABSENT " ] , <nl> - ' data_connected ' : False <nl> - } <nl> + modem = self . get_modem ( ) <nl> + sim_path = modem . Get ( MM_MODEM , ' Sim ' , dbus_interface = DBUS_PROPS ) <nl> + <nl> + if sim_path = = " / " : <nl> + return { <nl> + ' sim_id ' : ' ' , <nl> + ' mcc_mnc ' : None , <nl> + ' network_type ' : [ " Unknown " ] , <nl> + ' sim_state ' : [ " ABSENT " ] , <nl> + ' data_connected ' : False <nl> + } <nl> + else : <nl> + sim = self . bus . get_object ( MM , sim_path ) <nl> + return { <nl> + ' sim_id ' : str ( sim . Get ( MM_SIM , ' SimIdentifier ' , dbus_interface = DBUS_PROPS ) ) , <nl> + ' mcc_mnc ' : str ( sim . Get ( MM_SIM , ' OperatorIdentifier ' , dbus_interface = DBUS_PROPS ) ) , <nl> + ' network_type ' : [ " Unknown " ] , <nl> + ' sim_state ' : [ " READY " ] , <nl> + ' data_connected ' : modem . Get ( MM_MODEM , ' State ' , dbus_interface = DBUS_PROPS ) = = MM_MODEM_STATE_CONNECTED , <nl> + } <nl> + <nl> + def get_subscriber_info ( self ) : <nl> + return " " <nl> + <nl> + def get_imei ( self , slot ) : <nl> + if slot ! = 0 : <nl> + return " " <nl> + <nl> + return str ( self . get_modem ( ) . Get ( MM_MODEM , ' EquipmentIdentifier ' , dbus_interface = DBUS_PROPS ) ) <nl> + <nl> + def parse_strength ( self , percentage ) : <nl> + if percentage < 25 : <nl> + return NetworkStrength . poor <nl> + elif percentage < 50 : <nl> + return NetworkStrength . moderate <nl> + elif percentage < 75 : <nl> + return NetworkStrength . good <nl> + else : <nl> + return NetworkStrength . great <nl> <nl> def get_network_strength ( self , network_type ) : <nl> - return NetworkStrength . unknown <nl> + network_strength = NetworkStrength . unknown <nl> + <nl> + if network_type = = NetworkType . none : <nl> + pass <nl> + elif network_type = = NetworkType . wifi : <nl> + wlan = self . get_wlan ( ) <nl> + active_ap_path = wlan . Get ( NM_DEV_WL , ' ActiveAccessPoint ' , dbus_interface = DBUS_PROPS ) <nl> + if active_ap_path ! = " / " : <nl> + active_ap = self . bus . get_object ( NM , active_ap_path ) <nl> + strength = int ( active_ap . Get ( NM_AP , ' Strength ' , dbus_interface = DBUS_PROPS ) ) <nl> + network_strength = self . parse_strength ( strength ) <nl> + else : # Cellular <nl> + modem = self . get_modem ( ) <nl> + strength = int ( modem . Get ( MM_MODEM , ' SignalQuality ' , dbus_interface = DBUS_PROPS ) [ 0 ] ) <nl> + network_strength = self . parse_strength ( strength ) <nl> + <nl> + return network_strength <nl> <nl> # We don ' t have a battery , so let ' s use some sane constants <nl> def get_battery_capacity ( self ) : <nl>
hardware . py : get network info over dbus ( )
commaai/openpilot
c3b5ef8d4b596cc1463b426a43334a3c53421473
2020-12-14T13:19:14Z
mmm a / src / core / hle / kernel / client_session . cpp <nl> ppp b / src / core / hle / kernel / client_session . cpp <nl> ClientSession : : ~ ClientSession ( ) { <nl> parent - > client = nullptr ; <nl> } <nl> <nl> - ResultVal < SharedPtr < ClientSession > > ClientSession : : Create ( std : : string name ) { <nl> - SharedPtr < ClientSession > client_session ( new ClientSession ) ; <nl> - <nl> - client_session - > name = std : : move ( name ) ; <nl> - client_session - > parent = nullptr ; <nl> - return MakeResult < SharedPtr < ClientSession > > ( std : : move ( client_session ) ) ; <nl> - } <nl> - <nl> ResultCode ClientSession : : SendSyncRequest ( ) { <nl> / / Signal the server session that new data is available <nl> if ( parent - > server ) <nl> mmm a / src / core / hle / kernel / client_session . h <nl> ppp b / src / core / hle / kernel / client_session . h <nl> class ClientSession final : public Object { <nl> private : <nl> ClientSession ( ) ; <nl> ~ ClientSession ( ) override ; <nl> - <nl> - / * * <nl> - * Creates a client session . <nl> - * @ param name Optional name of client session <nl> - * @ return The created client session <nl> - * / <nl> - static ResultVal < SharedPtr < ClientSession > > Create ( std : : string name = " Unknown " ) ; <nl> } ; <nl> <nl> } / / namespace <nl> mmm a / src / core / hle / kernel / server_session . cpp <nl> ppp b / src / core / hle / kernel / server_session . cpp <nl> ServerSession : : SessionPair ServerSession : : CreateSessionPair ( <nl> <nl> auto server_session = <nl> ServerSession : : Create ( name + " _Server " , std : : move ( hle_handler ) ) . MoveFrom ( ) ; <nl> - auto client_session = ClientSession : : Create ( name + " _Client " ) . MoveFrom ( ) ; <nl> + <nl> + SharedPtr < ClientSession > client_session ( new ClientSession ) ; <nl> + client_session - > name = name + " _Client " ; <nl> <nl> std : : shared_ptr < Session > parent ( new Session ) ; <nl> parent - > client = client_session . get ( ) ; <nl>
Kernel / Sessions : Remove the ClientSession : : Create function .
yuzu-emu/yuzu
37347bfa380464a1ee1236d2a35f1ec1b697e4b6
2017-05-21T23:52:42Z
mmm a / stdlib / runtime / Leaks . mm <nl> ppp b / stdlib / runtime / Leaks . mm <nl> static id __swift_leaks_allocWithZone ( id self , SEL _cmd , id zone ) { <nl> pthread_mutex_unlock ( & LeaksMutex ) ; <nl> } <nl> <nl> - extern " C " int swift_leaks_stopTrackingObjects ( const char * name ) { <nl> - pthread_mutex_lock ( & LeaksMutex ) ; <nl> - unsigned Result = TrackedSwiftObjects . size ( ) + TrackedObjCObjects . size ( ) ; <nl> - <nl> - fprintf ( stderr , " { \ " name \ " : \ " % s \ " , \ " swift_count \ " : % u , \ " objc_count \ " : % u , " <nl> - " \ " swift_objects \ " : [ " , <nl> - name , unsigned ( TrackedSwiftObjects . size ( ) ) , <nl> - unsigned ( TrackedObjCObjects . size ( ) ) ) ; <nl> + / / / This assumes that the LeaksMutex is already being held . <nl> + static void dumpSwiftHeapObjects ( ) { <nl> const char * comma = " " ; <nl> for ( HeapObject * Obj : TrackedSwiftObjects ) { <nl> const HeapMetadata * Metadata = Obj - > metadata ; <nl> static id __swift_leaks_allocWithZone ( id self , SEL _cmd , id zone ) { <nl> continue ; <nl> } <nl> <nl> + const char * kindDescriptor = " " ; <nl> + switch ( Metadata - > getKind ( ) ) { <nl> + case MetadataKind : : Class : <nl> + kindDescriptor = " Class " ; <nl> + break ; <nl> + case MetadataKind : : ObjCClassWrapper : <nl> + kindDescriptor = " ObjCClassWrapper " ; <nl> + break ; <nl> + case MetadataKind : : ForeignClass : <nl> + kindDescriptor = " ForeignClass " ; <nl> + break ; <nl> + case MetadataKind : : Block : <nl> + kindDescriptor = " Block " ; <nl> + break ; <nl> + case MetadataKind : : Struct : <nl> + kindDescriptor = " Struct " ; <nl> + break ; <nl> + case MetadataKind : : Enum : <nl> + kindDescriptor = " Enum " ; <nl> + break ; <nl> + case MetadataKind : : Opaque : <nl> + kindDescriptor = " Opaque " ; <nl> + break ; <nl> + case MetadataKind : : Tuple : <nl> + kindDescriptor = " Tuple " ; <nl> + break ; <nl> + case MetadataKind : : Function : <nl> + kindDescriptor = " Function " ; <nl> + break ; <nl> + case MetadataKind : : ThinFunction : <nl> + kindDescriptor = " ThinFunction " ; <nl> + break ; <nl> + case MetadataKind : : PolyFunction : <nl> + kindDescriptor = " PolyFunction " ; <nl> + break ; <nl> + case MetadataKind : : Existential : <nl> + kindDescriptor = " Existential " ; <nl> + break ; <nl> + case MetadataKind : : Metatype : <nl> + kindDescriptor = " Metatype " ; <nl> + break ; <nl> + case MetadataKind : : ExistentialMetatype : <nl> + kindDescriptor = " ExistentialMetatype " ; <nl> + break ; <nl> + case MetadataKind : : HeapLocalVariable : <nl> + kindDescriptor = " HeapLocalVariable " ; <nl> + break ; <nl> + } <nl> + <nl> if ( const NominalTypeDescriptor * NTD = <nl> Metadata - > getNominalTypeDescriptor ( ) ) { <nl> - fprintf ( stderr , " { \ " type \ " : \ " nominal \ " , \ " name \ " : \ " % s \ " } " , NTD - > Name ) ; <nl> + fprintf ( stderr , " { \ " type \ " : \ " nominal \ " , \ " name \ " : \ " % s \ " , \ " kind \ " : \ " % s \ " } " , NTD - > Name , kindDescriptor ) ; <nl> continue ; <nl> } <nl> <nl> - fprintf ( stderr , " { \ " type \ " : \ " unknown \ " } " ) ; <nl> + fprintf ( stderr , " { \ " type \ " : \ " unknown \ " , \ " kind \ " : \ " % s \ " } " , kindDescriptor ) ; <nl> } <nl> + } <nl> <nl> - comma = " " ; <nl> - fprintf ( stderr , " ] , \ " objc_objects \ " : [ " ) ; <nl> + / / / This assumes that the LeaksMutex is already being held . <nl> + static void dumpObjCHeapObjects ( ) { <nl> + const char * comma = " " ; <nl> for ( id Obj : TrackedObjCObjects ) { <nl> / / Just print out the class of Obj . <nl> fprintf ( stderr , " % s \ " % s \ " " , comma , object_getClassName ( Obj ) ) ; <nl> comma = " , " ; <nl> } <nl> + } <nl> + <nl> + extern " C " int swift_leaks_stopTrackingObjects ( const char * name ) { <nl> + pthread_mutex_lock ( & LeaksMutex ) ; <nl> + unsigned Result = TrackedSwiftObjects . size ( ) + TrackedObjCObjects . size ( ) ; <nl> + <nl> + fprintf ( stderr , " { \ " name \ " : \ " % s \ " , \ " swift_count \ " : % u , \ " objc_count \ " : % u , " <nl> + " \ " swift_objects \ " : [ " , <nl> + name , unsigned ( TrackedSwiftObjects . size ( ) ) , <nl> + unsigned ( TrackedObjCObjects . size ( ) ) ) ; <nl> + dumpSwiftHeapObjects ( ) ; <nl> + fprintf ( stderr , " ] , \ " objc_objects \ " : [ " ) ; <nl> + dumpObjCHeapObjects ( ) ; <nl> fprintf ( stderr , " ] } \ n " ) ; <nl> <nl> fflush ( stderr ) ; <nl>
[ + 0 self : leaks ] Print out the metadata kind so we have at least some information when we don ' t have a nominal type descriptor .
apple/swift
56600ace063ae946bc1854f12ad15402923dcd92
2015-02-27T21:45:53Z
mmm a / docker / test / stateful / Dockerfile <nl> ppp b / docker / test / stateful / Dockerfile <nl> CMD dpkg - i package_folder / clickhouse - common - static_ * . deb ; \ <nl> ln - s / usr / share / clickhouse - test / config / listen . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / part_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / text_log . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / metric_log . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / log_queries . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / readonly . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / ints_dictionary . xml / etc / clickhouse - server / ; \ <nl> ln - s / usr / share / clickhouse - test / config / strings_dictionary . xml / etc / clickhouse - server / ; \ <nl> mmm a / docker / test / stateful_with_coverage / run . sh <nl> ppp b / docker / test / stateful_with_coverage / run . sh <nl> ln - s / usr / share / clickhouse - test / config / zookeeper . xml / etc / clickhouse - server / con <nl> ln - s / usr / share / clickhouse - test / config / listen . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / part_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / text_log . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / metric_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / query_masking_rules . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / log_queries . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / readonly . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / ints_dictionary . xml / etc / clickhouse - server / ; \ <nl> ln - s / usr / share / clickhouse - test / config / strings_dictionary . xml / etc / clickhouse - server / ; \ <nl> mmm a / docker / test / stateless / Dockerfile <nl> ppp b / docker / test / stateless / Dockerfile <nl> CMD dpkg - i package_folder / clickhouse - common - static_ * . deb ; \ <nl> ln - s / usr / share / clickhouse - test / config / listen . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / part_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / text_log . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / metric_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / query_masking_rules . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / log_queries . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / readonly . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / access_management . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / ints_dictionary . xml / etc / clickhouse - server / ; \ <nl> mmm a / docker / test / stateless_with_coverage / run . sh <nl> ppp b / docker / test / stateless_with_coverage / run . sh <nl> ln - s / usr / share / clickhouse - test / config / zookeeper . xml / etc / clickhouse - server / con <nl> ln - s / usr / share / clickhouse - test / config / listen . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / part_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / text_log . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / metric_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / query_masking_rules . xml / etc / clickhouse - server / config . d / ; \ <nl> + ln - s / usr / share / clickhouse - test / config / log_queries . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / readonly . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / access_management . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / ints_dictionary . xml / etc / clickhouse - server / ; \ <nl> mmm a / docker / test / stress / Dockerfile <nl> ppp b / docker / test / stress / Dockerfile <nl> CMD dpkg - i package_folder / clickhouse - common - static_ * . deb ; \ <nl> dpkg - i package_folder / clickhouse - server_ * . deb ; \ <nl> dpkg - i package_folder / clickhouse - client_ * . deb ; \ <nl> dpkg - i package_folder / clickhouse - test_ * . deb ; \ <nl> + ln - s / usr / share / clickhouse - test / config / log_queries . xml / etc / clickhouse - server / users . d / ; \ <nl> ln - s / usr / share / clickhouse - test / config / part_log . xml / etc / clickhouse - server / config . d / ; \ <nl> ln - s / usr / lib / llvm - 9 / bin / llvm - symbolizer / usr / bin / llvm - symbolizer ; \ <nl> echo " TSAN_OPTIONS = ' halt_on_error = 1 history_size = 7 ignore_noninstrumented_modules = 1 verbosity = 1 ' " > > / etc / environment ; \ <nl> new file mode 100644 <nl> index 00000000000 . . 25261072ade <nl> mmm / dev / null <nl> ppp b / tests / config / log_queries . xml <nl> <nl> + < yandex > <nl> + < profiles > <nl> + < default > <nl> + < log_queries > 1 < / log_queries > <nl> + < / default > <nl> + < / profiles > <nl> + < / yandex > <nl> new file mode 100644 <nl> index 00000000000 . . 0ca9f162416 <nl> mmm / dev / null <nl> ppp b / tests / config / metric_log . xml <nl> <nl> + < yandex > <nl> + < metric_log > <nl> + < database > system < / database > <nl> + < table > metric_log < / table > <nl> + < flush_interval_milliseconds > 7500 < / flush_interval_milliseconds > <nl> + < collect_interval_milliseconds > 1000 < / collect_interval_milliseconds > <nl> + < / metric_log > <nl> + < / yandex > <nl>
Merge pull request from ClickHouse / revert - 11266 - addition - to - 11184
ClickHouse/ClickHouse
0efa0179769bd8f0e83f66e891a3e765a118fa01
2020-06-09T16:40:17Z
mmm a / src / operator / contrib / bilinear_resize - inl . h <nl> ppp b / src / operator / contrib / bilinear_resize - inl . h <nl> struct BilinearSampleParam : public dmlc : : Parameter < BilinearSampleParam > { <nl> int height ; <nl> int width ; <nl> DMLC_DECLARE_PARAMETER ( BilinearSampleParam ) { <nl> - DMLC_DECLARE_FIELD ( height ) . set_range ( 1 , 1000 ) <nl> + DMLC_DECLARE_FIELD ( height ) . set_range ( 1 , 10000 ) <nl> . describe ( " output height ( required ) " ) ; <nl> - DMLC_DECLARE_FIELD ( width ) . set_range ( 1 , 1000 ) <nl> + DMLC_DECLARE_FIELD ( width ) . set_range ( 1 , 10000 ) <nl> . describe ( " output width ( required ) " ) ; <nl> } <nl> } ; <nl> mmm a / src / operator / contrib / roi_align - inl . h <nl> ppp b / src / operator / contrib / roi_align - inl . h <nl> enum ROIAlignOpOutputs { kOut } ; <nl> struct ROIAlignParam : public dmlc : : Parameter < ROIAlignParam > { <nl> TShape pooled_size ; <nl> float spatial_scale ; <nl> + int sample_ratio ; <nl> DMLC_DECLARE_PARAMETER ( ROIAlignParam ) { <nl> DMLC_DECLARE_FIELD ( pooled_size ) <nl> . set_expect_ndim ( 2 ) . enforce_nonzero ( ) <nl> struct ROIAlignParam : public dmlc : : Parameter < ROIAlignParam > { <nl> DMLC_DECLARE_FIELD ( spatial_scale ) . set_range ( 0 . 0 , 1 . 0 ) <nl> . describe ( " Ratio of input feature map height ( or w ) to raw image height ( or w ) . " <nl> " Equals the reciprocal of total stride in convolutional layers " ) ; <nl> + DMLC_DECLARE_FIELD ( sample_ratio ) . set_default ( - 1 ) <nl> + . describe ( " Optional sampling ratio of ROI align , using adaptive size by default . " ) ; <nl> } <nl> } ; <nl> <nl> mmm a / src / operator / contrib / roi_align . cc <nl> ppp b / src / operator / contrib / roi_align . cc <nl> void ROIAlignForwardCompute ( const nnvm : : NodeAttrs & attrs , <nl> DType * top_data = out_data [ roialign : : kOut ] . dptr < DType > ( ) ; <nl> <nl> ROIAlignForward < DType > ( count , bottom_data , param . spatial_scale , channels , <nl> - height , width , pooled_height , pooled_width , - 1 , bottom_rois , <nl> - rois_cols , top_data ) ; <nl> + height , width , pooled_height , pooled_width , param . sample_ratio , <nl> + bottom_rois , rois_cols , top_data ) ; <nl> } ) <nl> } <nl> <nl> void ROIAlignBackwardCompute ( const nnvm : : NodeAttrs & attrs , <nl> } <nl> ROIAlignBackward < DType > ( count , top_diff , num_rois , param . spatial_scale , <nl> channels , height , width , pooled_height , pooled_width , <nl> - - 1 , grad_in , bottom_rois , rois_cols ) ; <nl> + param . sample_ratio , grad_in , bottom_rois , rois_cols ) ; <nl> } <nl> if ( kWriteTo = = req [ roialign : : kBox ] ) { <nl> Fill < false > ( s , outputs [ 1 ] , kWriteTo , static_cast < DType > ( 0 ) ) ; <nl> mmm a / src / operator / contrib / roi_align . cu <nl> ppp b / src / operator / contrib / roi_align . cu <nl> __device__ void bilinear_interpolate_gradient ( <nl> T lx = x - * x_low ; <nl> T hy = 1 . - ly , hx = 1 . - lx ; <nl> <nl> - / / reference in forward <nl> - / / T v1 = bottom_data [ * y_low * width + * x_low ] ; <nl> - / / T v2 = bottom_data [ * y_low * width + * x_high ] ; <nl> - / / T v3 = bottom_data [ * y_high * width + * x_low ] ; <nl> - / / T v4 = bottom_data [ * y_high * width + * x_high ] ; <nl> - / / T val = ( w1 * v1 + * w2 * v2 + * w3 * v3 + * w4 * v4 ) ; <nl> - <nl> * w1 = hy * hx , * w2 = hy * lx , * w3 = ly * hx , * w4 = ly * lx ; <nl> <nl> return ; <nl> __global__ void RoIAlignBackwardKernel ( <nl> offset_bottom_diff + y_high * width + x_low , static_cast < T > ( g3 ) ) ; <nl> atomicAdd ( <nl> offset_bottom_diff + y_high * width + x_high , static_cast < T > ( g4 ) ) ; <nl> - / * <nl> - gpu_atomic_add ( <nl> - static_cast < T > ( g1 ) , offset_bottom_diff + y_low * width + x_low ) ; <nl> - gpu_atomic_add ( <nl> - static_cast < T > ( g2 ) , offset_bottom_diff + y_low * width + x_high ) ; <nl> - gpu_atomic_add ( <nl> - static_cast < T > ( g3 ) , offset_bottom_diff + y_high * width + x_low ) ; <nl> - gpu_atomic_add ( <nl> - static_cast < T > ( g4 ) , offset_bottom_diff + y_high * width + x_high ) ; <nl> - * / <nl> } / / if <nl> } / / ix <nl> } / / iy <nl> void ROIAlignForwardCompute ( const nnvm : : NodeAttrs & attrs , <nl> width , <nl> pooled_height , <nl> pooled_width , <nl> - - 1 , <nl> + param . sample_ratio , <nl> bottom_rois , <nl> top_data ) ; <nl> } ) <nl> void ROIAlignBackwardCompute ( const nnvm : : NodeAttrs & attrs , <nl> width , <nl> pooled_height , <nl> pooled_width , <nl> - - 1 , <nl> + param . sample_ratio , <nl> grad_in , <nl> bottom_rois ) ; <nl> } ) <nl> mmm a / tests / python / unittest / test_operator . py <nl> ppp b / tests / python / unittest / test_operator . py <nl> def roialign_forward_backward ( data , rois , pooled_size , spatial_scale , sampling_r <nl> out [ r , c , ph , pw ] = val * 1 . 0 / count <nl> return out , [ dx , drois ] <nl> <nl> - def test_roi_align_value ( ) : <nl> + def test_roi_align_value ( sampling_ratio = 0 ) : <nl> ctx = default_context ( ) <nl> dtype = np . float32 <nl> <nl> def test_roi_align_value ( ) : <nl> pooled_size = ( 3 , 4 ) <nl> <nl> spatial_scale = H * 1 . 0 / dlen <nl> - sampling_ratio = 0 <nl> data = mx . nd . array ( np . arange ( N * C * W * H ) . reshape ( ( N , C , H , W ) ) , ctx = ctx , dtype = dtype ) <nl> # data = mx . nd . random . uniform ( 0 , 1 , ( N , C , H , W ) , dtype = dtype ) <nl> center_xy = mx . nd . random . uniform ( 0 , dlen , ( R , 2 ) , ctx = ctx , dtype = dtype ) <nl> def test_roi_align_value ( ) : <nl> rois . attach_grad ( ) <nl> with mx . autograd . record ( ) : <nl> output = mx . nd . contrib . ROIAlign ( data , rois , pooled_size = pooled_size , <nl> - spatial_scale = spatial_scale ) <nl> + spatial_scale = spatial_scale , sample_ratio = sampling_ratio ) <nl> dy = mx . nd . random . uniform ( - 1 , 1 , ( R , C ) + pooled_size , ctx = ctx , dtype = dtype ) <nl> output . backward ( dy ) <nl> - real_output , [ dx , drois ] = roialign_forward_backward ( data . asnumpy ( ) , rois . asnumpy ( ) , pooled_size , spatial_scale , sampling_ratio , dy . asnumpy ( ) ) <nl> + real_output , [ dx , drois ] = roialign_forward_backward ( data . asnumpy ( ) , rois . asnumpy ( ) , pooled_size , <nl> + spatial_scale , sampling_ratio , dy . asnumpy ( ) ) <nl> assert np . allclose ( output . asnumpy ( ) , real_output ) <nl> # It seems that the precision between Cfloat and Pyfloat is different . <nl> assert np . allclose ( data . grad . asnumpy ( ) , dx , atol = 1e - 5 ) , np . abs ( data . grad . asnumpy ( ) - dx ) . max ( ) <nl> assert np . allclose ( rois . grad . asnumpy ( ) , drois ) <nl> <nl> # modified from test_roipooling ( ) <nl> - def test_roi_align_autograd ( ) : <nl> - ctx = default_context ( ) <nl> + def test_roi_align_autograd ( sampling_ratio = 0 ) : <nl> + ctx = default_context ( ) <nl> data = mx . symbol . Variable ( name = ' data ' ) <nl> rois = mx . symbol . Variable ( name = ' rois ' ) <nl> - test = mx . symbol . contrib . ROIAlign ( data = data , rois = rois , pooled_size = ( 4 , 4 ) , spatial_scale = 1 ) <nl> + test = mx . symbol . contrib . ROIAlign ( data = data , rois = rois , pooled_size = ( 4 , 4 ) , spatial_scale = 1 , <nl> + sample_ratio = sampling_ratio ) <nl> <nl> x1 = np . random . rand ( 4 , 1 , 12 , 12 ) . astype ( ' float64 ' ) <nl> x2 = np . array ( [ [ 0 , 1 . 1 , 1 . 1 , 6 . 2 , 6 . 2 ] , [ 2 , 6 . 1 , 2 . 1 , 8 . 2 , 11 . 2 ] , <nl> def test_roi_align_autograd ( ) : <nl> numeric_eps = 1e - 4 , rtol = 1e - 1 , atol = 1e - 4 , ctx = ctx ) <nl> <nl> test_roi_align_value ( ) <nl> + test_roi_align_value ( 2 ) <nl> test_roi_align_autograd ( ) <nl> <nl> <nl>
[ MXNET - 517 ] add sample ratio for ROI Align ( )
apache/incubator-mxnet
e8923011523f900b1f7e9f180feecb89c1a1d6e1
2018-06-29T22:23:33Z
mmm a / config . m4 <nl> ppp b / config . m4 <nl> if test " $ PHP_GRPC " ! = " no " ; then <nl> <nl> LIBS = " - lpthread $ LIBS " <nl> <nl> - CFLAGS = " - Wall - Werror - Wno - parentheses - equality - Wno - unused - value - std = c11 " <nl> - CXXFLAGS = " - std = c + + 11 - fno - exceptions - fno - rtti " <nl> + CFLAGS = " - Wall - Werror - Wno - parentheses - equality - Wno - unused - value - std = c11 - g - O2 " <nl> + CXXFLAGS = " - std = c + + 11 - fno - exceptions - fno - rtti - g - O2 " <nl> GRPC_SHARED_LIBADD = " - lpthread $ GRPC_SHARED_LIBADD " <nl> PHP_REQUIRE_CXX ( ) <nl> PHP_ADD_LIBRARY ( pthread ) <nl> mmm a / templates / config . m4 . template <nl> ppp b / templates / config . m4 . template <nl> <nl> <nl> LIBS = " - lpthread $ LIBS " <nl> <nl> - CFLAGS = " - Wall - Werror - Wno - parentheses - equality - Wno - unused - value - std = c11 " <nl> - CXXFLAGS = " - std = c + + 11 - fno - exceptions - fno - rtti " <nl> + CFLAGS = " - Wall - Werror - Wno - parentheses - equality - Wno - unused - value - std = c11 - g - O2 " <nl> + CXXFLAGS = " - std = c + + 11 - fno - exceptions - fno - rtti - g - O2 " <nl> GRPC_SHARED_LIBADD = " - lpthread $ GRPC_SHARED_LIBADD " <nl> PHP_REQUIRE_CXX ( ) <nl> PHP_ADD_LIBRARY ( pthread ) <nl>
Merge pull request from ZhouyihaiDing / backport - php - O2
grpc/grpc
5e3c80f3fd6f41add78f5f11bbc3b55418b0e1b8
2018-04-03T18:16:42Z
mmm a / libraries / chain / wasm_eosio_constraints . cpp <nl> ppp b / libraries / chain / wasm_eosio_constraints . cpp <nl> struct nop_opcode_visitor { <nl> <nl> # define VISIT_OPCODE ( opcode , name , nameString , Imm , . . . ) \ <nl> virtual void name ( Imm ) { throw wasm_opcode_no_disposition_exception { nameString } ; } <nl> - ENUM_OPERATORS ( VISIT_OPCODE ) <nl> - # undef VISIT_OPCODE <nl> + ENUM_OPERATORS ( VISIT_OPCODE ) <nl> + # undef VISIT_OPCODE <nl> <nl> void unknown ( Opcode ) { <nl> FC_THROW_EXCEPTION ( wasm_execution_error , " Smart contract encountered unknown opcode " ) ; <nl> struct eosio_constraints_visitor : public nop_opcode_visitor { <nl> <nl> # define VISIT_OPCODE ( opcode , name , nameString , Imm , . . . ) \ <nl> void name ( Imm ) override { FC_THROW_EXCEPTION ( wasm_execution_error , " Smart contracts may not use WASM memory operators " ) ; } <nl> - ENUM_MEMORY_OPERATORS ( VISIT_OPCODE ) ; <nl> - # undef VISIT_OPCODE <nl> + ENUM_MEMORY_OPERATORS ( VISIT_OPCODE ) ; <nl> + # undef VISIT_OPCODE <nl> <nl> # define VISIT_OPCODE ( opcode , name , nameString , Imm , . . . ) \ <nl> void name ( Imm ) override { FC_THROW_EXCEPTION ( wasm_execution_error , " Smart contracts may not use any floating point opcodes " ) ; } <nl> - ENUM_FLOAT_NONCONTROL_NONPARAMETRIC_OPERATORS ( VISIT_OPCODE ) ; <nl> - # undef VISIT_OPCODE <nl> + ENUM_FLOAT_NONCONTROL_NONPARAMETRIC_OPERATORS ( VISIT_OPCODE ) ; <nl> + # undef VISIT_OPCODE <nl> <nl> / / Allow all these through untouched / / / / / / / / / / / / / / / / / / / / / / / / / <nl> # define VISIT_OPCODE ( opcode , name , nameString , Imm , . . . ) \ <nl> void name ( Imm ) override { } <nl> - ENUM_CONTROL_OPERATORS ( VISIT_OPCODE ) ; <nl> + ENUM_CONTROL_OPERATORS ( VISIT_OPCODE ) ; <nl> ENUM_PARAMETRIC_OPERATORS ( VISIT_OPCODE ) ; <nl> / / annoyingly the rest need to be defined manually given current design <nl> - VISIT_OPCODE ( 0x01 , nop , " nop " , NoImm , NULLARY ( none ) ) ; <nl> - VISIT_OPCODE ( 0x41 , i32_const , " i32 . const " , LiteralImm < I32 > , NULLARY ( i32 ) ) ; <nl> - VISIT_OPCODE ( 0x42 , i64_const , " i64 . const " , LiteralImm < I64 > , NULLARY ( i64 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0x45 , i32_eqz , " i32 . eqz " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x46 , i32_eq , " i32 . eq " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x47 , i32_ne , " i32 . ne " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x48 , i32_lt_s , " i32 . lt_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x49 , i32_lt_u , " i32 . lt_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x4a , i32_gt_s , " i32 . gt_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x4b , i32_gt_u , " i32 . gt_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x4c , i32_le_s , " i32 . le_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x4d , i32_le_u , " i32 . le_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x4e , i32_ge_s , " i32 . ge_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x4f , i32_ge_u , " i32 . ge_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0x50 , i64_eqz , " i64 . eqz " , NoImm , UNARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x51 , i64_eq , " i64 . eq " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x52 , i64_ne , " i64 . ne " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x53 , i64_lt_s , " i64 . lt_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x54 , i64_lt_u , " i64 . lt_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x55 , i64_gt_s , " i64 . gt_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x56 , i64_gt_u , " i64 . gt_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x57 , i64_le_s , " i64 . le_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x58 , i64_le_u , " i64 . le_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x59 , i64_ge_s , " i64 . ge_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x5a , i64_ge_u , " i64 . ge_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0x67 , i32_clz , " i32 . clz " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x68 , i32_ctz , " i32 . ctz " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x69 , i32_popcnt , " i32 . popcnt " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0x6a , i32_add , " i32 . add " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x6b , i32_sub , " i32 . sub " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x6c , i32_mul , " i32 . mul " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x6d , i32_div_s , " i32 . div_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x6e , i32_div_u , " i32 . div_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x6f , i32_rem_s , " i32 . rem_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x70 , i32_rem_u , " i32 . rem_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x71 , i32_and , " i32 . and " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x72 , i32_or , " i32 . or " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x73 , i32_xor , " i32 . xor " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x74 , i32_shl , " i32 . shl " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x75 , i32_shr_s , " i32 . shr_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x76 , i32_shr_u , " i32 . shr_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x77 , i32_rotl , " i32 . rotl " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0x78 , i32_rotr , " i32 . rotr " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0x79 , i64_clz , " i64 . clz " , NoImm , UNARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x7a , i64_ctz , " i64 . ctz " , NoImm , UNARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x7b , i64_popcnt , " i64 . popcnt " , NoImm , UNARY ( i64 , i64 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0x7c , i64_add , " i64 . add " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x7d , i64_sub , " i64 . sub " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x7e , i64_mul , " i64 . mul " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x7f , i64_div_s , " i64 . div_s " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x80 , i64_div_u , " i64 . div_u " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x81 , i64_rem_s , " i64 . rem_s " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x82 , i64_rem_u , " i64 . rem_u " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x83 , i64_and , " i64 . and " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x84 , i64_or , " i64 . or " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x85 , i64_xor , " i64 . xor " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x86 , i64_shl , " i64 . shl " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x87 , i64_shr_s , " i64 . shr_s " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x88 , i64_shr_u , " i64 . shr_u " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x89 , i64_rotl , " i64 . rotl " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0x8a , i64_rotr , " i64 . rotr " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> - <nl> - VISIT_OPCODE ( 0xa7 , i32_wrap_i64 , " i32 . wrap / i64 " , NoImm , UNARY ( i64 , i32 ) ) ; <nl> - VISIT_OPCODE ( 0xac , i64_extend_s_i32 , " i64 . extend_s / i32 " , NoImm , UNARY ( i32 , i64 ) ) ; <nl> - VISIT_OPCODE ( 0xad , i64_extend_u_i32 , " i64 . extend_u / i32 " , NoImm , UNARY ( i32 , i64 ) ) ; <nl> - # undef VISIT_OPCODE <nl> + VISIT_OPCODE ( 0x01 , nop , " nop " , NoImm , NULLARY ( none ) ) ; <nl> + VISIT_OPCODE ( 0x41 , i32_const , " i32 . const " , LiteralImm < I32 > , NULLARY ( i32 ) ) ; <nl> + VISIT_OPCODE ( 0x42 , i64_const , " i64 . const " , LiteralImm < I64 > , NULLARY ( i64 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0x45 , i32_eqz , " i32 . eqz " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x46 , i32_eq , " i32 . eq " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x47 , i32_ne , " i32 . ne " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x48 , i32_lt_s , " i32 . lt_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x49 , i32_lt_u , " i32 . lt_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x4a , i32_gt_s , " i32 . gt_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x4b , i32_gt_u , " i32 . gt_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x4c , i32_le_s , " i32 . le_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x4d , i32_le_u , " i32 . le_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x4e , i32_ge_s , " i32 . ge_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x4f , i32_ge_u , " i32 . ge_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0x50 , i64_eqz , " i64 . eqz " , NoImm , UNARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x51 , i64_eq , " i64 . eq " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x52 , i64_ne , " i64 . ne " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x53 , i64_lt_s , " i64 . lt_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x54 , i64_lt_u , " i64 . lt_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x55 , i64_gt_s , " i64 . gt_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x56 , i64_gt_u , " i64 . gt_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x57 , i64_le_s , " i64 . le_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x58 , i64_le_u , " i64 . le_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x59 , i64_ge_s , " i64 . ge_s " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x5a , i64_ge_u , " i64 . ge_u " , NoImm , BINARY ( i64 , i32 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0x67 , i32_clz , " i32 . clz " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x68 , i32_ctz , " i32 . ctz " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x69 , i32_popcnt , " i32 . popcnt " , NoImm , UNARY ( i32 , i32 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0x6a , i32_add , " i32 . add " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x6b , i32_sub , " i32 . sub " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x6c , i32_mul , " i32 . mul " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x6d , i32_div_s , " i32 . div_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x6e , i32_div_u , " i32 . div_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x6f , i32_rem_s , " i32 . rem_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x70 , i32_rem_u , " i32 . rem_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x71 , i32_and , " i32 . and " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x72 , i32_or , " i32 . or " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x73 , i32_xor , " i32 . xor " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x74 , i32_shl , " i32 . shl " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x75 , i32_shr_s , " i32 . shr_s " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x76 , i32_shr_u , " i32 . shr_u " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x77 , i32_rotl , " i32 . rotl " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0x78 , i32_rotr , " i32 . rotr " , NoImm , BINARY ( i32 , i32 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0x79 , i64_clz , " i64 . clz " , NoImm , UNARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x7a , i64_ctz , " i64 . ctz " , NoImm , UNARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x7b , i64_popcnt , " i64 . popcnt " , NoImm , UNARY ( i64 , i64 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0x7c , i64_add , " i64 . add " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x7d , i64_sub , " i64 . sub " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x7e , i64_mul , " i64 . mul " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x7f , i64_div_s , " i64 . div_s " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x80 , i64_div_u , " i64 . div_u " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x81 , i64_rem_s , " i64 . rem_s " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x82 , i64_rem_u , " i64 . rem_u " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x83 , i64_and , " i64 . and " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x84 , i64_or , " i64 . or " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x85 , i64_xor , " i64 . xor " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x86 , i64_shl , " i64 . shl " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x87 , i64_shr_s , " i64 . shr_s " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x88 , i64_shr_u , " i64 . shr_u " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x89 , i64_rotl , " i64 . rotl " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0x8a , i64_rotr , " i64 . rotr " , NoImm , BINARY ( i64 , i64 ) ) ; <nl> + <nl> + VISIT_OPCODE ( 0xa7 , i32_wrap_i64 , " i32 . wrap / i64 " , NoImm , UNARY ( i64 , i32 ) ) ; <nl> + VISIT_OPCODE ( 0xac , i64_extend_s_i32 , " i64 . extend_s / i32 " , NoImm , UNARY ( i32 , i64 ) ) ; <nl> + VISIT_OPCODE ( 0xad , i64_extend_u_i32 , " i64 . extend_u / i32 " , NoImm , UNARY ( i32 , i64 ) ) ; <nl> + # undef VISIT_OPCODE <nl> <nl> } ; <nl> <nl> void check_wasm_opcode_dispositions ( ) { <nl> catch ( wasm_opcode_no_disposition_exception & e ) { \ <nl> opcodes_without_disposition . push_back ( e . opcode_name ) ; \ <nl> } <nl> - ENUM_OPERATORS ( VISIT_OPCODE ) <nl> - # undef VISIT_OPCODE <nl> + ENUM_OPERATORS ( VISIT_OPCODE ) <nl> + # undef VISIT_OPCODE <nl> <nl> if ( opcodes_without_disposition . size ( ) ) { <nl> elog ( " WASM opcode disposition not defined for opcodes : " ) ; <nl>
Strictly whitespace cleanup in wasm_eosio_constraints
EOSIO/eos
84eb27d8959d9381f388eb8d45dbeae7d66732db
2018-02-19T20:45:39Z
mmm a / Telegram / cmake / lib_tgvoip . cmake <nl> ppp b / Telegram / cmake / lib_tgvoip . cmake <nl> else ( ) <nl> - Wno - error = sequence - point <nl> - Wno - error = unused - result <nl> ) <nl> - if ( build_linux32 ) <nl> + if ( build_linux32 AND CMAKE_SYSTEM_PROCESSOR MATCHES " i686 . * | i386 . * | x86 . * " ) <nl> target_compile_options ( lib_tgvoip PRIVATE - msse2 ) <nl> endif ( ) <nl> target_compile_definitions ( lib_tgvoip <nl>
lib_tgvoip . cmake : Match against x86 arches .
telegramdesktop/tdesktop
f2c8167124635f2fac59caae547738ee0c02f864
2020-01-17T07:42:50Z
mmm a / src / btree / walk . cc <nl> ppp b / src / btree / walk . cc <nl> struct store_walker_t { <nl> } <nl> } <nl> void done ( ) { <nl> - callback - > done ( ) ; <nl> delete this ; <nl> } <nl> } ; <nl> void walk_slice ( store_walker_t * parent , btree_slice_t * slice ) { <nl> struct branch_walker_t : <nl> public block_available_callback_t , <nl> public large_buf_available_callback_t , <nl> - public store_t : : walk_callback_t : : done_callback_t <nl> + public store_t : : replicant_t : : done_callback_t <nl> { <nl> slice_walker_t * parent ; <nl> buf_t * buf ; <nl> mmm a / src / store . hpp <nl> ppp b / src / store . hpp <nl> struct store_t { <nl> } ; <nl> virtual void delete_key ( store_key_t * key , delete_callback_t * cb ) = 0 ; <nl> <nl> - / * To replicate the database , call replicate ( ) . The given replicant_t will be called for each <nl> - key and value currently in the database , and then subsequently called for every change that <nl> - is made to the database . * / <nl> + / * To start replicating , call replicate ( ) with a replicant_t . <nl> + <nl> + The replicant_t ' s value ( ) method will be called for every key in the database at the time that <nl> + replicate ( ) is called and for every change that is made after replicate ( ) is called . It may be <nl> + called on any thread ( s ) and in any order . <nl> + <nl> + To stop replicating , call stop_replicating ( ) with the same replicant . Note that it is not safe <nl> + to delete the replicant until its stopped ( ) method is called . * / <nl> <nl> struct replicant_t { <nl> <nl> struct store_t { <nl> virtual void have_copied_value ( ) = 0 ; <nl> } ; <nl> virtual void value ( store_key_t * key , const_buffer_group_t * value , done_callback_t * cb , mcflags_t flags , exptime_t exptime , cas_t cas ) = 0 ; <nl> + <nl> + virtual void stopped ( ) = 0 ; <nl> + <nl> + virtual ~ replicant_t ( ) { } <nl> } ; <nl> virtual void replicate ( replicant_t * cb ) = 0 ; <nl> - <nl> - virtual ~ store_t ( ) { } <nl> + virtual void stop_replicating ( replicant_t * cb ) = 0 ; <nl> + <nl> + virtual ~ store_t ( ) { } <nl> } ; <nl> <nl> # endif / * __STORE_HPP__ * / <nl>
More replicatio work .
rethinkdb/rethinkdb
e00aa81f225d06d207c43770f5d6c8a2cfdc5634
2010-12-06T23:42:15Z
mmm a / dbms / src / Storages / StorageLog . cpp <nl> ppp b / dbms / src / Storages / StorageLog . cpp <nl> void LogBlockOutputStream : : writeData ( const String & name , const IDataType & type <nl> <nl> out_marks . push_back ( std : : make_pair ( storage . files [ size_name ] . column_index , mark ) ) ; <nl> <nl> - type_arr - > serializeOffsets ( column , streams [ size_name ] - > compressed ) ; <nl> + type_arr - > serializeOffsets ( column , streams [ size_name ] - > compressed , 0 , 0 ) ; <nl> streams [ size_name ] - > compressed . next ( ) ; <nl> } <nl> <nl> mmm a / dbms / src / Storages / StorageTinyLog . cpp <nl> ppp b / dbms / src / Storages / StorageTinyLog . cpp <nl> void TinyLogBlockOutputStream : : writeData ( const String & name , const IDataType & <nl> if ( offset_columns . count ( size_name ) = = 0 ) <nl> { <nl> offset_columns . insert ( size_name ) ; <nl> - type_arr - > serializeOffsets ( <nl> - column , <nl> - streams [ size_name ] - > compressed ) ; <nl> + type_arr - > serializeOffsets ( column , streams [ size_name ] - > compressed , 0 , 0 ) ; <nl> } <nl> <nl> writeData ( name , * type_arr - > getNestedType ( ) , typeid_cast < const ColumnArray & > ( column ) . getData ( ) , offset_columns , level + 1 ) ; <nl>
Renamed methods for bulk binary serialization ( continued ) [ # METR - 2944 ] .
ClickHouse/ClickHouse
9dc44c1a3aca813bffec7b2c99f25c61804c104c
2017-01-02T23:31:26Z
mmm a / src / wallet / wallet . cpp <nl> ppp b / src / wallet / wallet . cpp <nl> bool CWallet : : ChangeWalletPassphrase ( const SecureString & strOldWalletPassphrase , <nl> return false ; <nl> if ( ! crypter . Encrypt ( _vMasterKey , pMasterKey . second . vchCryptedKey ) ) <nl> return false ; <nl> - WalletBatch ( * database ) . WriteMasterKey ( pMasterKey . first , pMasterKey . second ) ; <nl> + WalletBatch ( GetDatabase ( ) ) . WriteMasterKey ( pMasterKey . first , pMasterKey . second ) ; <nl> if ( fWasLocked ) <nl> Lock ( ) ; <nl> return true ; <nl> bool CWallet : : ChangeWalletPassphrase ( const SecureString & strOldWalletPassphrase , <nl> <nl> void CWallet : : chainStateFlushed ( const CBlockLocator & loc ) <nl> { <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> batch . WriteBestBlock ( loc ) ; <nl> } <nl> <nl> void CWallet : : SetMinVersion ( enum WalletFeature nVersion , WalletBatch * batch_in ) <nl> nWalletVersion = nVersion ; <nl> <nl> { <nl> - WalletBatch * batch = batch_in ? batch_in : new WalletBatch ( * database ) ; <nl> + WalletBatch * batch = batch_in ? batch_in : new WalletBatch ( GetDatabase ( ) ) ; <nl> if ( nWalletVersion > 40000 ) <nl> batch - > WriteMinVersion ( nWalletVersion ) ; <nl> if ( ! batch_in ) <nl> bool CWallet : : HasWalletSpend ( const uint256 & txid ) const <nl> <nl> void CWallet : : Flush ( ) <nl> { <nl> - database - > Flush ( ) ; <nl> + GetDatabase ( ) . Flush ( ) ; <nl> } <nl> <nl> void CWallet : : Close ( ) <nl> { <nl> - database - > Close ( ) ; <nl> + GetDatabase ( ) . Close ( ) ; <nl> } <nl> <nl> void CWallet : : SyncMetaData ( std : : pair < TxSpends : : iterator , TxSpends : : iterator > range ) <nl> bool CWallet : : EncryptWallet ( const SecureString & strWalletPassphrase ) <nl> { <nl> LOCK ( cs_wallet ) ; <nl> mapMasterKeys [ + + nMasterKeyMaxID ] = kMasterKey ; <nl> - WalletBatch * encrypted_batch = new WalletBatch ( * database ) ; <nl> + WalletBatch * encrypted_batch = new WalletBatch ( GetDatabase ( ) ) ; <nl> if ( ! encrypted_batch - > TxnBegin ( ) ) { <nl> delete encrypted_batch ; <nl> encrypted_batch = nullptr ; <nl> bool CWallet : : EncryptWallet ( const SecureString & strWalletPassphrase ) <nl> <nl> / / Need to completely rewrite the wallet file ; if we don ' t , bdb might keep <nl> / / bits of the unencrypted private key in slack space in the database file . <nl> - database - > Rewrite ( ) ; <nl> + GetDatabase ( ) . Rewrite ( ) ; <nl> <nl> / / BDB seems to have a bad habit of writing old data into <nl> / / slack space in . dat files ; that is bad if the old data is <nl> / / unencrypted private keys . So : <nl> - database - > ReloadDbEnv ( ) ; <nl> + GetDatabase ( ) . ReloadDbEnv ( ) ; <nl> <nl> } <nl> NotifyStatusChanged ( this ) ; <nl> bool CWallet : : EncryptWallet ( const SecureString & strWalletPassphrase ) <nl> DBErrors CWallet : : ReorderTransactions ( ) <nl> { <nl> LOCK ( cs_wallet ) ; <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> <nl> / / Old wallets didn ' t have any defined order for transactions <nl> / / Probably a bad idea to change the output of this <nl> int64_t CWallet : : IncOrderPosNext ( WalletBatch * batch ) <nl> if ( batch ) { <nl> batch - > WriteOrderPosNext ( nOrderPosNext ) ; <nl> } else { <nl> - WalletBatch ( * database ) . WriteOrderPosNext ( nOrderPosNext ) ; <nl> + WalletBatch ( GetDatabase ( ) ) . WriteOrderPosNext ( nOrderPosNext ) ; <nl> } <nl> return nRet ; <nl> } <nl> bool CWallet : : MarkReplaced ( const uint256 & originalHash , const uint256 & newHash ) <nl> <nl> wtx . mapValue [ " replaced_by_txid " ] = newHash . ToString ( ) ; <nl> <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> <nl> bool success = true ; <nl> if ( ! batch . WriteTx ( wtx ) ) { <nl> CWalletTx * CWallet : : AddToWallet ( CTransactionRef tx , const CWalletTx : : Confirmatio <nl> { <nl> LOCK ( cs_wallet ) ; <nl> <nl> - WalletBatch batch ( * database , fFlushOnClose ) ; <nl> + WalletBatch batch ( GetDatabase ( ) , fFlushOnClose ) ; <nl> <nl> uint256 hash = tx - > GetHash ( ) ; <nl> <nl> bool CWallet : : AbandonTransaction ( const uint256 & hashTx ) <nl> { <nl> LOCK ( cs_wallet ) ; <nl> <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> <nl> std : : set < uint256 > todo ; <nl> std : : set < uint256 > done ; <nl> void CWallet : : MarkConflicted ( const uint256 & hashBlock , int conflicting_height , c <nl> return ; <nl> <nl> / / Do not flush the wallet here for performance reasons <nl> - WalletBatch batch ( * database , false ) ; <nl> + WalletBatch batch ( GetDatabase ( ) , false ) ; <nl> <nl> std : : set < uint256 > todo ; <nl> std : : set < uint256 > done ; <nl> void CWallet : : SetWalletFlag ( uint64_t flags ) <nl> { <nl> LOCK ( cs_wallet ) ; <nl> m_wallet_flags | = flags ; <nl> - if ( ! WalletBatch ( * database ) . WriteWalletFlags ( m_wallet_flags ) ) <nl> + if ( ! WalletBatch ( GetDatabase ( ) ) . WriteWalletFlags ( m_wallet_flags ) ) <nl> throw std : : runtime_error ( std : : string ( __func__ ) + " : writing wallet flags failed " ) ; <nl> } <nl> <nl> void CWallet : : UnsetWalletFlag ( uint64_t flag ) <nl> { <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> UnsetWalletFlagWithDB ( batch , flag ) ; <nl> } <nl> <nl> bool CWallet : : AddWalletFlags ( uint64_t flags ) <nl> LOCK ( cs_wallet ) ; <nl> / / We should never be writing unknown non - tolerable wallet flags <nl> assert ( ( ( flags & KNOWN_WALLET_FLAGS ) > > 32 ) = = ( flags > > 32 ) ) ; <nl> - if ( ! WalletBatch ( * database ) . WriteWalletFlags ( flags ) ) { <nl> + if ( ! WalletBatch ( GetDatabase ( ) ) . WriteWalletFlags ( flags ) ) { <nl> throw std : : runtime_error ( std : : string ( __func__ ) + " : writing wallet flags failed " ) ; <nl> } <nl> <nl> bool CWallet : : ImportScriptPubKeys ( const std : : string & label , const std : : set < CScri <nl> return false ; <nl> } <nl> if ( apply_label ) { <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> for ( const CScript & script : script_pub_keys ) { <nl> CTxDestination dest ; <nl> ExtractDestination ( script , dest ) ; <nl> DBErrors CWallet : : LoadWallet ( bool & fFirstRunRet ) <nl> LOCK ( cs_wallet ) ; <nl> <nl> fFirstRunRet = false ; <nl> - DBErrors nLoadWalletRet = WalletBatch ( * database ) . LoadWallet ( this ) ; <nl> + DBErrors nLoadWalletRet = WalletBatch ( GetDatabase ( ) ) . LoadWallet ( this ) ; <nl> if ( nLoadWalletRet = = DBErrors : : NEED_REWRITE ) <nl> { <nl> - if ( database - > Rewrite ( " \ x04pool " ) ) <nl> + if ( GetDatabase ( ) . Rewrite ( " \ x04pool " ) ) <nl> { <nl> for ( const auto & spk_man_pair : m_spk_managers ) { <nl> spk_man_pair . second - > RewriteDB ( ) ; <nl> DBErrors CWallet : : LoadWallet ( bool & fFirstRunRet ) <nl> DBErrors CWallet : : ZapSelectTx ( std : : vector < uint256 > & vHashIn , std : : vector < uint256 > & vHashOut ) <nl> { <nl> AssertLockHeld ( cs_wallet ) ; <nl> - DBErrors nZapSelectTxRet = WalletBatch ( * database ) . ZapSelectTx ( vHashIn , vHashOut ) ; <nl> + DBErrors nZapSelectTxRet = WalletBatch ( GetDatabase ( ) ) . ZapSelectTx ( vHashIn , vHashOut ) ; <nl> for ( const uint256 & hash : vHashOut ) { <nl> const auto & it = mapWallet . find ( hash ) ; <nl> wtxOrdered . erase ( it - > second . m_it_wtxOrdered ) ; <nl> DBErrors CWallet : : ZapSelectTx ( std : : vector < uint256 > & vHashIn , std : : vector < uint256 <nl> <nl> if ( nZapSelectTxRet = = DBErrors : : NEED_REWRITE ) <nl> { <nl> - if ( database - > Rewrite ( " \ x04pool " ) ) <nl> + if ( GetDatabase ( ) . Rewrite ( " \ x04pool " ) ) <nl> { <nl> for ( const auto & spk_man_pair : m_spk_managers ) { <nl> spk_man_pair . second - > RewriteDB ( ) ; <nl> bool CWallet : : SetAddressBookWithDB ( WalletBatch & batch , const CTxDestination & add <nl> <nl> bool CWallet : : SetAddressBook ( const CTxDestination & address , const std : : string & strName , const std : : string & strPurpose ) <nl> { <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> return SetAddressBookWithDB ( batch , address , strName , strPurpose ) ; <nl> } <nl> <nl> bool CWallet : : DelAddressBook ( const CTxDestination & address ) <nl> { <nl> bool is_mine ; <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> { <nl> LOCK ( cs_wallet ) ; <nl> / / If we want to delete receiving addresses , we need to take care that DestData " used " ( and possibly newer DestData ) gets preserved ( and the " deleted " address transformed into a change entry instead of actually being deleted ) <nl> std : : shared_ptr < CWallet > CWallet : : Create ( interfaces : : Chain & chain , const std : : st <nl> int rescan_height = 0 ; <nl> if ( ! gArgs . GetBoolArg ( " - rescan " , false ) ) <nl> { <nl> - WalletBatch batch ( * walletInstance - > database ) ; <nl> + WalletBatch batch ( walletInstance - > GetDatabase ( ) ) ; <nl> CBlockLocator locator ; <nl> if ( batch . ReadBestBlock ( locator ) ) { <nl> if ( const Optional < int > fork_height = chain . findLocatorFork ( locator ) ) { <nl> std : : shared_ptr < CWallet > CWallet : : Create ( interfaces : : Chain & chain , const std : : st <nl> } <nl> } <nl> walletInstance - > chainStateFlushed ( chain . getTipLocator ( ) ) ; <nl> - walletInstance - > database - > IncrementUpdateCounter ( ) ; <nl> + walletInstance - > GetDatabase ( ) . IncrementUpdateCounter ( ) ; <nl> } <nl> <nl> { <nl> void CWallet : : postInitProcess ( ) <nl> <nl> bool CWallet : : BackupWallet ( const std : : string & strDest ) const <nl> { <nl> - return database - > Backup ( strDest ) ; <nl> + return GetDatabase ( ) . Backup ( strDest ) ; <nl> } <nl> <nl> CKeyPool : : CKeyPool ( ) <nl> void CWallet : : SetupDescriptorScriptPubKeyMans ( ) <nl> <nl> void CWallet : : AddActiveScriptPubKeyMan ( uint256 id , OutputType type , bool internal ) <nl> { <nl> - WalletBatch batch ( * database ) ; <nl> + WalletBatch batch ( GetDatabase ( ) ) ; <nl> if ( ! batch . WriteActiveScriptPubKeyMan ( static_cast < uint8_t > ( type ) , id , internal ) ) { <nl> throw std : : runtime_error ( std : : string ( __func__ ) + " : writing active ScriptPubKeyMan id failed " ) ; <nl> } <nl> mmm a / src / wallet / wallet . h <nl> ppp b / src / wallet / wallet . h <nl> class CWallet final : public WalletStorage , public interfaces : : Chain : : Notificati <nl> std : : string m_name ; <nl> <nl> / * * Internal database handle . * / <nl> - std : : unique_ptr < WalletDatabase > database ; <nl> + std : : unique_ptr < WalletDatabase > const m_database ; <nl> <nl> / * * <nl> * The following is used to keep track of how far behind the wallet is <nl> class CWallet final : public WalletStorage , public interfaces : : Chain : : Notificati <nl> * / <nl> mutable RecursiveMutex cs_wallet ; <nl> <nl> - / * * Get database handle used by this wallet . Ideally this function would <nl> - * not be necessary . <nl> - * / <nl> - WalletDatabase & GetDBHandle ( ) <nl> + WalletDatabase & GetDatabase ( ) const override <nl> { <nl> - return * database ; <nl> + assert ( static_cast < bool > ( m_database ) ) ; <nl> + return * m_database ; <nl> } <nl> - WalletDatabase & GetDatabase ( ) const override { return * database ; } <nl> <nl> / * * <nl> * Select a set of coins such that nValueRet > = nTargetValue and at least <nl> class CWallet final : public WalletStorage , public interfaces : : Chain : : Notificati <nl> CWallet ( interfaces : : Chain * chain , const std : : string & name , std : : unique_ptr < WalletDatabase > database ) <nl> : m_chain ( chain ) , <nl> m_name ( name ) , <nl> - database ( std : : move ( database ) ) <nl> + m_database ( std : : move ( database ) ) <nl> { <nl> } <nl> <nl> mmm a / src / wallet / walletdb . cpp <nl> ppp b / src / wallet / walletdb . cpp <nl> void MaybeCompactWalletDB ( ) <nl> } <nl> <nl> for ( const std : : shared_ptr < CWallet > & pwallet : GetWallets ( ) ) { <nl> - WalletDatabase & dbh = pwallet - > GetDBHandle ( ) ; <nl> + WalletDatabase & dbh = pwallet - > GetDatabase ( ) ; <nl> <nl> unsigned int nUpdateCounter = dbh . nUpdateCounter ; <nl> <nl>
Merge : refactor : Some wallet cleanups
bitcoin/bitcoin
80d4231e1638969b01c999028eaf3419bf3af23b
2020-12-02T00:23:00Z