| OLD | NEW | 
|    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  Loading... | 
|  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 | 
| OLD | NEW |