diff --git a/atom/browser/api/atom_api_app_mas.mm b/atom/browser/api/atom_api_app_mas.mm index 6cec5a1512..05e102ac4e 100644 --- a/atom/browser/api/atom_api_app_mas.mm +++ b/atom/browser/api/atom_api_app_mas.mm @@ -24,8 +24,8 @@ base::RepeatingCallback App::StartAccessingSecurityScopedResource( std::string data; args->GetNext(&data); NSString* base64str = base::SysUTF8ToNSString(data); - NSData* bookmarkData = - [[NSData alloc] initWithBase64EncodedString:base64str options:0]; + NSData* bookmarkData = [[NSData alloc] initWithBase64EncodedString:base64str + options:0]; // Create bookmarkUrl from NSData. BOOL isStale = false; diff --git a/atom/browser/api/atom_api_menu_mac.mm b/atom/browser/api/atom_api_menu_mac.mm index bf9cbfef5a..728bdf8f4c 100644 --- a/atom/browser/api/atom_api_menu_mac.mm +++ b/atom/browser/api/atom_api_menu_mac.mm @@ -60,9 +60,9 @@ void MenuMac::PopupOnUI(const base::WeakPtr& native_window, auto close_callback = base::BindRepeating( &MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback); - popup_controllers_[window_id] = base::scoped_nsobject([ - [AtomMenuController alloc] initWithModel:model() - useDefaultAccelerator:NO]); + popup_controllers_[window_id] = base::scoped_nsobject( + [[AtomMenuController alloc] initWithModel:model() + useDefaultAccelerator:NO]); NSMenu* menu = [popup_controllers_[window_id] menu]; NSView* view = [nswindow contentView]; @@ -136,9 +136,9 @@ void MenuMac::OnClosed(int32_t window_id, base::Closure callback) { // static void Menu::SetApplicationMenu(Menu* base_menu) { MenuMac* menu = static_cast(base_menu); - base::scoped_nsobject menu_controller([ - [AtomMenuController alloc] initWithModel:menu->model_.get() - useDefaultAccelerator:YES]); + base::scoped_nsobject menu_controller( + [[AtomMenuController alloc] initWithModel:menu->model_.get() + useDefaultAccelerator:YES]); NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop]; [currentRunLoop cancelPerformSelector:@selector(setMainMenu:) diff --git a/atom/browser/mac/dict_util.mm b/atom/browser/mac/dict_util.mm index 4f44e00ce5..74cd4b7446 100644 --- a/atom/browser/mac/dict_util.mm +++ b/atom/browser/mac/dict_util.mm @@ -15,8 +15,9 @@ NSArray* ListValueToNSArray(const base::ListValue& value) { if (!base::JSONWriter::Write(value, &json)) return nil; NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()]; - id obj = - [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil]; + id obj = [NSJSONSerialization JSONObjectWithData:jsonData + options:0 + error:nil]; if (![obj isKindOfClass:[NSArray class]]) return nil; return obj; @@ -67,8 +68,9 @@ NSDictionary* DictionaryValueToNSDictionary( if (!base::JSONWriter::Write(value, &json)) return nil; NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()]; - id obj = - [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil]; + id obj = [NSJSONSerialization JSONObjectWithData:jsonData + options:0 + error:nil]; if (![obj isKindOfClass:[NSDictionary class]]) return nil; return obj; diff --git a/atom/browser/mac/in_app_purchase_product.mm b/atom/browser/mac/in_app_purchase_product.mm index 36745dc188..c4a5c575ac 100644 --- a/atom/browser/mac/in_app_purchase_product.mm +++ b/atom/browser/mac/in_app_purchase_product.mm @@ -140,8 +140,8 @@ if (product.priceLocale != nil) { productStruct.formattedPrice = - [[self formatPrice:product.price withLocal:product.priceLocale] - UTF8String]; + [[self formatPrice:product.price + withLocal:product.priceLocale] UTF8String]; } } diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 6ee746121d..f1f1ed4644 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -851,9 +851,9 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) { [window_ setLevel:newLevel]; } else { - *error = std::string([ - [NSString stringWithFormat:@"relativeLevel must be between %d and %d", - minWindowLevel, maxWindowLevel] UTF8String]); + *error = std::string([[NSString + stringWithFormat:@"relativeLevel must be between %d and %d", + minWindowLevel, maxWindowLevel] UTF8String]); } } @@ -1102,7 +1102,7 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) { } [view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView() - removeFromSuperview]; + removeFromSuperview]; remove_browser_view(view); [CATransaction commit]; diff --git a/atom/browser/osr/osr_web_contents_view_mac.mm b/atom/browser/osr/osr_web_contents_view_mac.mm index 2e6535a749..19560fdb11 100644 --- a/atom/browser/osr/osr_web_contents_view_mac.mm +++ b/atom/browser/osr/osr_web_contents_view_mac.mm @@ -20,8 +20,8 @@ [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; NSAttributedString* text = - [[[NSAttributedString alloc] initWithString:str attributes:attributes] - autorelease]; + [[[NSAttributedString alloc] initWithString:str + attributes:attributes] autorelease]; NSRect frame = NSMakeRect(0, (self.frame.size.height - text.size.height) / 2, self.frame.size.width, text.size.height); [str drawInRect:frame withAttributes:attributes]; diff --git a/atom/browser/ui/cocoa/atom_native_widget_mac.mm b/atom/browser/ui/cocoa/atom_native_widget_mac.mm index 5b5f2206e0..ceaa878bd9 100644 --- a/atom/browser/ui/cocoa/atom_native_widget_mac.mm +++ b/atom/browser/ui/cocoa/atom_native_widget_mac.mm @@ -20,8 +20,8 @@ AtomNativeWidgetMac::~AtomNativeWidgetMac() {} NativeWidgetMacNSWindow* AtomNativeWidgetMac::CreateNSWindow( const views_bridge_mac::mojom::CreateWindowParams* params) { - return [[[AtomNSWindow alloc] initWithShell:shell_ styleMask:style_mask_] - autorelease]; + return [[[AtomNSWindow alloc] initWithShell:shell_ + styleMask:style_mask_] autorelease]; } } // namespace atom diff --git a/atom/browser/ui/cocoa/atom_touch_bar.mm b/atom/browser/ui/cocoa/atom_touch_bar.mm index 44ae7d4f3e..7cb265e329 100644 --- a/atom/browser/ui/cocoa/atom_touch_bar.mm +++ b/atom/browser/ui/cocoa/atom_touch_bar.mm @@ -104,8 +104,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; item_id = [self idFromIdentifier:identifier withPrefix:LabelIdentifier]; return [self makeLabelForID:item_id withIdentifier:identifier]; } else if ([identifier hasPrefix:ColorPickerIdentifier]) { - item_id = - [self idFromIdentifier:identifier withPrefix:ColorPickerIdentifier]; + item_id = [self idFromIdentifier:identifier + withPrefix:ColorPickerIdentifier]; return [self makeColorPickerForID:item_id withIdentifier:identifier]; } else if ([identifier hasPrefix:SliderIdentifier]) { item_id = [self idFromIdentifier:identifier withPrefix:SliderIdentifier]; @@ -238,8 +238,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; - (void)colorPickerAction:(id)sender { NSString* identifier = ((NSColorPickerTouchBarItem*)sender).identifier; - NSString* item_id = - [self idFromIdentifier:identifier withPrefix:ColorPickerIdentifier]; + NSString* item_id = [self idFromIdentifier:identifier + withPrefix:ColorPickerIdentifier]; NSColor* color = ((NSColorPickerTouchBarItem*)sender).color; std::string hex_color = atom::ToRGBHex(skia::NSDeviceColorToSkColor(color)); base::DictionaryValue details; @@ -249,8 +249,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; - (void)sliderAction:(id)sender { NSString* identifier = ((NSSliderTouchBarItem*)sender).identifier; - NSString* item_id = - [self idFromIdentifier:identifier withPrefix:SliderIdentifier]; + NSString* item_id = [self idFromIdentifier:identifier + withPrefix:SliderIdentifier]; base::DictionaryValue details; details.SetInteger("value", [((NSSliderTouchBarItem*)sender).slider intValue]); diff --git a/atom/browser/ui/cocoa/views_delegate_mac.mm b/atom/browser/ui/cocoa/views_delegate_mac.mm index 4831f8828f..6a289e8c0f 100644 --- a/atom/browser/ui/cocoa/views_delegate_mac.mm +++ b/atom/browser/ui/cocoa/views_delegate_mac.mm @@ -27,7 +27,8 @@ void ViewsDelegateMac::OnBeforeWidgetInit( return; } - // Setting null here causes Widget to create the default NativeWidget implementation. + // Setting null here causes Widget to create the default NativeWidget + // implementation. params->native_widget = nullptr; } diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index 71d10c93d3..8fffeb64e7 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -326,9 +326,9 @@ const CGFloat kVerticalTitleMargin = 2; - (void)popUpContextMenu:(atom::AtomMenuModel*)menu_model { // Show a custom menu. if (menu_model) { - base::scoped_nsobject menuController([ - [AtomMenuController alloc] initWithModel:menu_model - useDefaultAccelerator:NO]); + base::scoped_nsobject menuController( + [[AtomMenuController alloc] initWithModel:menu_model + useDefaultAccelerator:NO]); forceHighlight_ = YES; // Should highlight when showing menu. [self setNeedsDisplay:YES]; [statusItem_ popUpStatusItemMenu:[menuController menu]]; diff --git a/native_mate/native_mate/arguments.cc b/native_mate/native_mate/arguments.cc index a23e6523ca..e3d3ca17ce 100644 --- a/native_mate/native_mate/arguments.cc +++ b/native_mate/native_mate/arguments.cc @@ -25,21 +25,15 @@ std::string V8TypeAsString(v8::Isolate* isolate, v8::Local value) { } // namespace Arguments::Arguments() - : isolate_(NULL), - info_(NULL), - next_(0), - insufficient_arguments_(false) { -} + : isolate_(NULL), info_(NULL), next_(0), insufficient_arguments_(false) {} Arguments::Arguments(const v8::FunctionCallbackInfo& info) : isolate_(info.GetIsolate()), info_(&info), next_(0), - insufficient_arguments_(false) { -} + insufficient_arguments_(false) {} -Arguments::~Arguments() { -} +Arguments::~Arguments() {} v8::Local Arguments::PeekNext() const { if (next_ >= info_->Length()) @@ -57,15 +51,14 @@ v8::Local Arguments::ThrowError() const { } v8::Local Arguments::ThrowError(const std::string& message) const { - isolate_->ThrowException(v8::Exception::Error( - StringToV8(isolate_, message))); + isolate_->ThrowException(v8::Exception::Error(StringToV8(isolate_, message))); return v8::Undefined(isolate_); } v8::Local Arguments::ThrowTypeError( const std::string& message) const { - isolate_->ThrowException(v8::Exception::TypeError( - StringToV8(isolate_, message))); + isolate_->ThrowException( + v8::Exception::TypeError(StringToV8(isolate_, message))); return v8::Undefined(isolate_); } diff --git a/native_mate/native_mate/arguments.h b/native_mate/native_mate/arguments.h index 99a7ef10f4..108e73f38b 100644 --- a/native_mate/native_mate/arguments.h +++ b/native_mate/native_mate/arguments.h @@ -19,21 +19,19 @@ class Arguments { explicit Arguments(const v8::FunctionCallbackInfo& info); ~Arguments(); - v8::Local GetHolder() const { - return info_->Holder(); - } + v8::Local GetHolder() const { return info_->Holder(); } - template + template bool GetHolder(T* out) { return ConvertFromV8(isolate_, info_->Holder(), out); } - template + template bool GetData(T* out) { return ConvertFromV8(isolate_, info_->Data(), out); } - template + template bool GetNext(T* out) { if (next_ >= info_->Length()) { insufficient_arguments_ = true; @@ -46,7 +44,7 @@ class Arguments { return success; } - template + template bool GetRemaining(std::vector* out) { if (next_ >= info_->Length()) { insufficient_arguments_ = true; @@ -62,19 +60,13 @@ class Arguments { return true; } - v8::Local GetThis() { - return info_->This(); - } + v8::Local GetThis() { return info_->This(); } - bool IsConstructCall() const { - return info_->IsConstructCall(); - } + bool IsConstructCall() const { return info_->IsConstructCall(); } - int Length() const { - return info_->Length(); - } + int Length() const { return info_->Length(); } - template + template void Return(const T& val) { info_->GetReturnValue().Set(ConvertToV8(isolate_, val)); } diff --git a/native_mate/native_mate/function_template.h b/native_mate/native_mate/function_template.h index abbe7b5326..045dc14fb5 100644 --- a/native_mate/native_mate/function_template.h +++ b/native_mate/native_mate/function_template.h @@ -36,20 +36,19 @@ struct Destroyable { } }; -template +template struct CallbackParamTraits { typedef T LocalType; }; -template +template struct CallbackParamTraits { typedef T LocalType; }; -template +template struct CallbackParamTraits { typedef T* LocalType; }; - // CallbackHolder and CallbackHolderBase are used to pass a base::Callback from // CreateFunctionTemplate through v8 (via v8::FunctionTemplate) to // DispatchToCallback, where it is invoked. @@ -75,7 +74,7 @@ class CallbackHolderBase { DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase); }; -template +template class CallbackHolder : public CallbackHolderBase { public: CallbackHolder(v8::Isolate* isolate, @@ -84,14 +83,17 @@ class CallbackHolder : public CallbackHolderBase { : CallbackHolderBase(isolate), callback(callback), flags(flags) {} base::Callback callback; int flags; + private: virtual ~CallbackHolder() {} DISALLOW_COPY_AND_ASSIGN(CallbackHolder); }; -template -bool GetNextArgument(Arguments* args, int create_flags, bool is_first, +template +bool GetNextArgument(Arguments* args, + int create_flags, + bool is_first, T* result) { if (is_first && (create_flags & HolderIsFirstArgument) != 0) { return args->GetHolder(result); @@ -102,20 +104,26 @@ bool GetNextArgument(Arguments* args, int create_flags, bool is_first, // For advanced use cases, we allow callers to request the unparsed Arguments // object and poke around in it directly. -inline bool GetNextArgument(Arguments* args, int create_flags, bool is_first, +inline bool GetNextArgument(Arguments* args, + int create_flags, + bool is_first, Arguments* result) { *result = *args; return true; } -inline bool GetNextArgument(Arguments* args, int create_flags, bool is_first, +inline bool GetNextArgument(Arguments* args, + int create_flags, + bool is_first, Arguments** result) { *result = args; return true; } // It's common for clients to just need the isolate, so we make that easy. -inline bool GetNextArgument(Arguments* args, int create_flags, - bool is_first, v8::Isolate** result) { +inline bool GetNextArgument(Arguments* args, + int create_flags, + bool is_first, + v8::Isolate** result) { *result = args->isolate(); return true; } @@ -145,10 +153,8 @@ struct ArgumentHolder { ArgLocalType value; bool ok; - ArgumentHolder(Arguments* args, int create_flags) - : ok(false) { - if (index == 0 && - (create_flags & HolderIsFirstArgument) && + ArgumentHolder(Arguments* args, int create_flags) : ok(false) { + if (index == 0 && (create_flags & HolderIsFirstArgument) && Destroyable::IsDestroyed(args)) { args->ThrowError("Object has been destroyed"); return; @@ -185,14 +191,12 @@ class Invoker, ArgTypes...> (void)create_flags; } - bool IsOK() { - return And(ArgumentHolder::ok...); - } + bool IsOK() { return And(ArgumentHolder::ok...); } template void DispatchToCallback(base::Callback callback) { - v8::MicrotasksScope script_scope( - args_->isolate(), v8::MicrotasksScope::kRunMicrotasks); + v8::MicrotasksScope script_scope(args_->isolate(), + v8::MicrotasksScope::kRunMicrotasks); args_->Return(callback.Run(ArgumentHolder::value...)); } @@ -200,8 +204,8 @@ class Invoker, ArgTypes...> // expression to foo. As a result, we must specialize the case of Callbacks // that have the void return type. void DispatchToCallback(base::Callback callback) { - v8::MicrotasksScope script_scope( - args_->isolate(), v8::MicrotasksScope::kRunMicrotasks); + v8::MicrotasksScope script_scope(args_->isolate(), + v8::MicrotasksScope::kRunMicrotasks); callback.Run(ArgumentHolder::value...); } @@ -227,8 +231,8 @@ struct Dispatcher { Arguments args(info); v8::Local v8_holder; args.GetData(&v8_holder); - CallbackHolderBase* holder_base = reinterpret_cast( - v8_holder->Value()); + CallbackHolderBase* holder_base = + reinterpret_cast(v8_holder->Value()); typedef CallbackHolder HolderT; HolderT* holder = static_cast(holder_base); @@ -242,7 +246,6 @@ struct Dispatcher { } // namespace internal - // CreateFunctionTemplate creates a v8::FunctionTemplate that will create // JavaScript functions that execute a provided C++ function or base::Callback. // JavaScript arguments are automatically converted via gin::Converter, as is @@ -252,23 +255,23 @@ struct Dispatcher { // internal reasons, thus it is generally a good idea to cache the template // returned by this function. Otherwise, repeated method invocations from JS // will create substantial memory leaks. See http://crbug.com/463487. -template +template v8::Local CreateFunctionTemplate( - v8::Isolate* isolate, const base::Callback callback, + v8::Isolate* isolate, + const base::Callback callback, int callback_flags = 0) { typedef internal::CallbackHolder HolderT; HolderT* holder = new HolderT(isolate, callback, callback_flags); return v8::FunctionTemplate::New( - isolate, - &internal::Dispatcher::DispatchToCallback, - ConvertToV8 >(isolate, - holder->GetHandle(isolate))); + isolate, &internal::Dispatcher::DispatchToCallback, + ConvertToV8>(isolate, + holder->GetHandle(isolate))); } // CreateFunctionHandler installs a CallAsFunction handler on the given // object template that forwards to a provided C++ function or base::Callback. -template +template void CreateFunctionHandler(v8::Isolate* isolate, v8::Local tmpl, const base::Callback callback, @@ -276,7 +279,7 @@ void CreateFunctionHandler(v8::Isolate* isolate, typedef internal::CallbackHolder HolderT; HolderT* holder = new HolderT(isolate, callback, callback_flags); tmpl->SetCallAsFunctionHandler(&internal::Dispatcher::DispatchToCallback, - ConvertToV8 >( + ConvertToV8>( isolate, holder->GetHandle(isolate))); } diff --git a/native_mate/native_mate/object_template_builder.cc b/native_mate/native_mate/object_template_builder.cc index c64e38fa1e..90da13d1af 100644 --- a/native_mate/native_mate/object_template_builder.cc +++ b/native_mate/native_mate/object_template_builder.cc @@ -9,20 +9,20 @@ namespace mate { ObjectTemplateBuilder::ObjectTemplateBuilder( v8::Isolate* isolate, v8::Local templ) - : isolate_(isolate), template_(templ) { -} + : isolate_(isolate), template_(templ) {} -ObjectTemplateBuilder::~ObjectTemplateBuilder() { -} +ObjectTemplateBuilder::~ObjectTemplateBuilder() {} ObjectTemplateBuilder& ObjectTemplateBuilder::SetImpl( - const base::StringPiece& name, v8::Local val) { + const base::StringPiece& name, + v8::Local val) { template_->Set(StringToSymbol(isolate_, name), val); return *this; } ObjectTemplateBuilder& ObjectTemplateBuilder::SetPropertyImpl( - const base::StringPiece& name, v8::Local getter, + const base::StringPiece& name, + v8::Local getter, v8::Local setter) { template_->SetAccessorProperty(StringToSymbol(isolate_, name), getter, setter); diff --git a/native_mate/native_mate/object_template_builder.h b/native_mate/native_mate/object_template_builder.h index 533576f986..88ce1d28c6 100644 --- a/native_mate/native_mate/object_template_builder.h +++ b/native_mate/native_mate/object_template_builder.h @@ -19,19 +19,20 @@ namespace { // Base template - used only for non-member function pointers. Other types // either go to one of the below specializations, or go here and fail to compile // because of base::Bind(). -template +template struct CallbackTraits { - static v8::Local CreateTemplate( - v8::Isolate* isolate, T callback) { + static v8::Local CreateTemplate(v8::Isolate* isolate, + T callback) { return CreateFunctionTemplate(isolate, base::Bind(callback)); } }; // Specialization for base::Callback. -template -struct CallbackTraits > { +template +struct CallbackTraits> { static v8::Local CreateTemplate( - v8::Isolate* isolate, const base::Callback& callback) { + v8::Isolate* isolate, + const base::Callback& callback) { return CreateFunctionTemplate(isolate, callback); } }; @@ -40,11 +41,12 @@ struct CallbackTraits > { // specially because the first parameter for callbacks to MFP should typically // come from the the JavaScript "this" object the function was called on, not // from the first normal parameter. -template -struct CallbackTraits::value>::type> { - static v8::Local CreateTemplate( - v8::Isolate* isolate, T callback) { +template +struct CallbackTraits< + T, + typename std::enable_if::value>::type> { + static v8::Local CreateTemplate(v8::Isolate* isolate, + T callback) { int flags = HolderIsFirstArgument; return CreateFunctionTemplate(isolate, base::Bind(callback), flags); } @@ -52,8 +54,8 @@ struct CallbackTraits -struct CallbackTraits > { +template <> +struct CallbackTraits> { static v8::Local CreateTemplate( v8::Local templ) { return templ; @@ -62,20 +64,18 @@ struct CallbackTraits > { } // namespace - // ObjectTemplateBuilder provides a handy interface to creating // v8::ObjectTemplate instances with various sorts of properties. class ObjectTemplateBuilder { public: - explicit ObjectTemplateBuilder( - v8::Isolate* isolate, - v8::Local templ); + explicit ObjectTemplateBuilder(v8::Isolate* isolate, + v8::Local templ); ~ObjectTemplateBuilder(); // It's against Google C++ style to return a non-const ref, but we take some // poetic license here in order that all calls to Set() can be via the '.' // operator and line up nicely. - template + template ObjectTemplateBuilder& SetValue(const base::StringPiece& name, T val) { return SetImpl(name, ConvertToV8(isolate_, val)); } @@ -84,28 +84,23 @@ class ObjectTemplateBuilder { // pointer, base::Callback, or v8::FunctionTemplate. Most clients will want to // use one of the first two options. Also see mate::CreateFunctionTemplate() // for creating raw function templates. - template - ObjectTemplateBuilder& SetMethod(const base::StringPiece& name, - T callback) { - return SetImpl(name, - CallbackTraits::CreateTemplate(isolate_, callback)); + template + ObjectTemplateBuilder& SetMethod(const base::StringPiece& name, T callback) { + return SetImpl(name, CallbackTraits::CreateTemplate(isolate_, callback)); } - template - ObjectTemplateBuilder& SetProperty(const base::StringPiece& name, - T getter) { - return SetPropertyImpl( - name, - CallbackTraits::CreateTemplate(isolate_, getter), - v8::Local()); + template + ObjectTemplateBuilder& SetProperty(const base::StringPiece& name, T getter) { + return SetPropertyImpl(name, + CallbackTraits::CreateTemplate(isolate_, getter), + v8::Local()); } - template + template ObjectTemplateBuilder& SetProperty(const base::StringPiece& name, T getter, U setter) { - return SetPropertyImpl( - name, - CallbackTraits::CreateTemplate(isolate_, getter), - CallbackTraits::CreateTemplate(isolate_, setter)); + return SetPropertyImpl(name, + CallbackTraits::CreateTemplate(isolate_, getter), + CallbackTraits::CreateTemplate(isolate_, setter)); } // Add "destroy" and "isDestroyed" methods. @@ -117,7 +112,8 @@ class ObjectTemplateBuilder { ObjectTemplateBuilder& SetImpl(const base::StringPiece& name, v8::Local val); ObjectTemplateBuilder& SetPropertyImpl( - const base::StringPiece& name, v8::Local getter, + const base::StringPiece& name, + v8::Local getter, v8::Local setter); v8::Isolate* isolate_; diff --git a/native_mate/native_mate/promise.h b/native_mate/native_mate/promise.h index 225ac6d048..a236eee631 100644 --- a/native_mate/native_mate/promise.h +++ b/native_mate/native_mate/promise.h @@ -22,12 +22,12 @@ class Promise { virtual v8::Local GetHandle() const; - template + template void Resolve(T* value) { resolver_->Resolve(mate::ConvertToV8(isolate(), value)); } - template + template void Reject(T* value) { resolver_->Reject(mate::ConvertToV8(isolate(), value)); } @@ -41,10 +41,9 @@ class Promise { v8::Local resolver_; }; -template<> +template <> struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, - Promise val); + static v8::Local ToV8(v8::Isolate* isolate, Promise val); // TODO(MarshallOfSound): Implement FromV8 to allow promise chaining // in native land // static bool FromV8(v8::Isolate* isolate, diff --git a/native_mate/native_mate/scoped_persistent.h b/native_mate/native_mate/scoped_persistent.h index 5d9c8fff42..0d1273f154 100644 --- a/native_mate/native_mate/scoped_persistent.h +++ b/native_mate/native_mate/scoped_persistent.h @@ -23,9 +23,7 @@ class ScopedPersistent { reset(isolate, v8::Local::Cast(handle)); } - ~ScopedPersistent() { - reset(); - } + ~ScopedPersistent() { reset(); } void reset(v8::Isolate* isolate, v8::Local handle) { if (!handle.IsEmpty()) { @@ -36,17 +34,11 @@ class ScopedPersistent { } } - void reset() { - handle_.Reset(); - } + void reset() { handle_.Reset(); } - bool IsEmpty() const { - return handle_.IsEmpty(); - } + bool IsEmpty() const { return handle_.IsEmpty(); } - v8::Local NewHandle() const { - return NewHandle(isolate_); - } + v8::Local NewHandle() const { return NewHandle(isolate_); } v8::Local NewHandle(v8::Isolate* isolate) const { if (handle_.IsEmpty()) @@ -54,7 +46,7 @@ class ScopedPersistent { return v8::Local::New(isolate, handle_); } - template + template void SetWeak(P* parameter, C callback) { handle_.SetWeak(parameter, callback); } @@ -75,8 +67,7 @@ class RefCountedPersistent : public ScopedPersistent, RefCountedPersistent() {} RefCountedPersistent(v8::Isolate* isolate, v8::Local handle) - : ScopedPersistent(isolate, handle) { - } + : ScopedPersistent(isolate, handle) {} protected: friend class base::RefCounted>; @@ -87,10 +78,10 @@ class RefCountedPersistent : public ScopedPersistent, DISALLOW_COPY_AND_ASSIGN(RefCountedPersistent); }; -template -struct Converter > { +template +struct Converter> { static v8::Local ToV8(v8::Isolate* isolate, - const ScopedPersistent& val) { + const ScopedPersistent& val) { return val.NewHandle(isolate); } @@ -98,7 +89,7 @@ struct Converter > { v8::Local val, ScopedPersistent* out) { v8::Local converted; - if (!Converter >::FromV8(isolate, val, &converted)) + if (!Converter>::FromV8(isolate, val, &converted)) return false; out->reset(isolate, converted); diff --git a/native_mate/native_mate_files.gypi b/native_mate/native_mate_files.gypi deleted file mode 100644 index d7e9374971..0000000000 --- a/native_mate/native_mate_files.gypi +++ /dev/null @@ -1,26 +0,0 @@ -{ - 'variables': { - 'native_mate_files': [ - 'native_mate/arguments.cc', - 'native_mate/arguments.h', - 'native_mate/constructor.h', - 'native_mate/converter.cc', - 'native_mate/converter.h', - 'native_mate/dictionary.cc', - 'native_mate/dictionary.h', - 'native_mate/function_template.cc', - 'native_mate/function_template.h', - 'native_mate/handle.h', - 'native_mate/object_template_builder.cc', - 'native_mate/object_template_builder.h', - 'native_mate/persistent_dictionary.cc', - 'native_mate/persistent_dictionary.h', - 'native_mate/scoped_persistent.h', - 'native_mate/wrappable.cc', - 'native_mate/wrappable.h', - 'native_mate/wrappable_base.h', - 'native_mate/promise.h', - 'native_mate/promise.cc', - ], - }, -}