Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: base/bind_unittest.cc

Issue 6561004: Callback support for __fastcall and __stdcall functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Address will's comments. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« base/bind_internal.h.pump ('K') | « base/bind_internal_win.h.pump ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 6
7 #if defined(BASE_CALLBACK_H_) 7 #if defined(BASE_CALLBACK_H_)
8 // We explicitly do not want to include callback.h so people are not tempted 8 // We explicitly do not want to include callback.h so people are not tempted
9 // to use bind.h in a headerfile for getting the Callback types. 9 // to use bind.h in a headerfile for getting the Callback types.
10 #error "base/bind.h should avoid pulling in callback.h by default." 10 #error "base/bind.h should avoid pulling in callback.h by default."
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // method_bound_to_array_cb.Run(); 574 // method_bound_to_array_cb.Run();
575 575
576 // - Refcounted types should not be bound as a raw pointer. 576 // - Refcounted types should not be bound as a raw pointer.
577 // HasRef for_raw_ptr; 577 // HasRef for_raw_ptr;
578 // Callback<void(void)> ref_count_as_raw_ptr = 578 // Callback<void(void)> ref_count_as_raw_ptr =
579 // Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr); 579 // Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr);
580 // ASSERT_EQ(&for_raw_ptr, ref_count_as_raw_ptr.Run()); 580 // ASSERT_EQ(&for_raw_ptr, ref_count_as_raw_ptr.Run());
581 581
582 } 582 }
583 583
584 #if defined(OS_WIN)
585 int __fastcall FastCallFunc(int n) {
586 return n;
587 }
588
589 int __stdcall StdCallFunc(int n) {
590 return n;
591 }
592
593 // Windows specific calling convention support.
594 // - Can bind a __fastcall function.
595 // - Can bind a __stdcall function.
596 TEST_F(BindTest, WindowsCallingConventions) {
597 Callback<int(void)> fastcall_cb = Bind(&FastCallFunc, 1);
598 EXPECT_EQ(1, fastcall_cb.Run());
599
600 Callback<int(void)> stdcall_cb = Bind(&StdCallFunc, 2);
601 EXPECT_EQ(2, stdcall_cb.Run());
602 }
603 #endif
604
584 } // namespace 605 } // namespace
585 } // namespace base 606 } // namespace base
OLDNEW
« base/bind_internal.h.pump ('K') | « base/bind_internal_win.h.pump ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698