HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Kitkat
|
4.4.4_r1
下载
查看原文件
收藏
根目录
external
chromium
base
bind_internal.h
// This file was GENERATED by command: // pump.py bind_internal.h.pump // DO NOT EDIT BY HAND!!! // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_BIND_INTERNAL_H_ #define BASE_BIND_INTERNAL_H_ #pragma once #include "base/bind_helpers.h" #include "base/callback_internal.h" #include "base/template_util.h" #include "build/build_config.h" #if defined(OS_WIN) #include "base/bind_internal_win.h" #endif namespace base { namespace internal { // The method by which a function is invoked is determined by 3 different // dimensions: // // 1) The type of function (normal or method). // 2) The arity of the function. // 3) The number of bound parameters. // // The templates below handle the determination of each of these dimensions. // In brief: // // FunctionTraits<> -- Provides a normalied signature, and other traits. // InvokerN<> -- Provides a DoInvoke() function that actually executes // a calback. // InvokerStorageN<> -- Provides storage for the bound parameters, and // typedefs to the above. // // More details about the design of each class is included in a comment closer // to their defition. // FunctionTraits<> // // The FunctionTraits<> template determines the type of function, and also // creates a NormalizedType used to select the InvokerN classes. It turns out // that syntactically, you only really have 2 variations when invoking a // funciton pointer: normal, and method. One is invoked func_ptr(arg1). The // other is invoked (*obj_->method_ptr(arg1)). // // However, in the type system, there are many more distinctions. In standard // C++, there's all variations of const, and volatile on the function pointer. // In Windows, there are additional calling conventions (eg., __stdcall, // __fastcall, etc.). FunctionTraits<> handles categorizing each of these into // a normalized signature. // // Having a NormalizedSignature signature, reduces the combinatoric // complexity of defintions for the InvokerN<> later. Even though there are // only 2 syntactic variations on invoking a function, without normalizing the // signature, there would need to be one specialization of InvokerN for each // unique (function_type, bound_arg, unbound_args) tuple in order to match all // function signatures. // // By normalizing the function signature, we reduce function_type to exactly 2. template
struct FunctionTraits; // Function: Arity 0. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(); typedef false_type IsMethod; }; // Method: Arity 0. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; }; // Const Method: Arity 0. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; }; // Function: Arity 1. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(X1); typedef false_type IsMethod; // Target type for each bound parameter. typedef X1 B1; }; // Method: Arity 1. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; }; // Const Method: Arity 1. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; }; // Function: Arity 2. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(X1, X2); typedef false_type IsMethod; // Target type for each bound parameter. typedef X1 B1; typedef X2 B2; }; // Method: Arity 2. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; }; // Const Method: Arity 2. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; }; // Function: Arity 3. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(X1, X2, X3); typedef false_type IsMethod; // Target type for each bound parameter. typedef X1 B1; typedef X2 B2; typedef X3 B3; }; // Method: Arity 3. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; }; // Const Method: Arity 3. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; }; // Function: Arity 4. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(X1, X2, X3, X4); typedef false_type IsMethod; // Target type for each bound parameter. typedef X1 B1; typedef X2 B2; typedef X3 B3; typedef X4 B4; }; // Method: Arity 4. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3, X4); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; typedef X4 B5; }; // Const Method: Arity 4. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3, X4); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; typedef X4 B5; }; // Function: Arity 5. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(X1, X2, X3, X4, X5); typedef false_type IsMethod; // Target type for each bound parameter. typedef X1 B1; typedef X2 B2; typedef X3 B3; typedef X4 B4; typedef X5 B5; }; // Method: Arity 5. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; typedef X4 B5; typedef X5 B6; }; // Const Method: Arity 5. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; typedef X4 B5; typedef X5 B6; }; // Function: Arity 6. template
struct FunctionTraits
{ typedef R (*NormalizedSig)(X1, X2, X3, X4, X5, X6); typedef false_type IsMethod; // Target type for each bound parameter. typedef X1 B1; typedef X2 B2; typedef X3 B3; typedef X4 B4; typedef X5 B5; typedef X6 B6; }; // Method: Arity 6. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; typedef X4 B5; typedef X5 B6; typedef X6 B7; }; // Const Method: Arity 6. template
struct FunctionTraits
{ typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); typedef true_type IsMethod; // Target type for each bound parameter. typedef T B1; typedef X1 B2; typedef X2 B3; typedef X3 B4; typedef X4 B5; typedef X5 B6; typedef X6 B7; }; // InvokerN<> // // The InvokerN templates contain a static DoInvoke() function that is the key // to implementing type erasure in the Callback() classes. // // DoInvoke() is a static function with a fixed signature that is independent // of StorageType; its first argument is a pointer to the non-templated common // baseclass of StorageType. This lets us store pointer to DoInvoke() in a // function pointer that has knowledge of the specific StorageType, and thus // no knowledge of the bound function and bound parameter types. // // As long as we ensure that DoInvoke() is only used with pointers there were // upcasted from the correct StorageType, we can be sure that execution is // safe. // // The InvokerN templates are the only point that knows the number of bound // and unbound arguments. This is intentional because it allows the other // templates classes in the system to only have as many specializations as // the max arity of function we wish to support. template
struct Invoker0; // Function: Arity 0 -> 0. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return invoker->f_(); } }; // Function: Arity 1 -> 1. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1) { StorageType* invoker = static_cast
(base); return invoker->f_(x1); } }; // Function: Arity 2 -> 2. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2) { StorageType* invoker = static_cast
(base); return invoker->f_(x1, x2); } }; // Function: Arity 3 -> 3. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3) { StorageType* invoker = static_cast
(base); return invoker->f_(x1, x2, x3); } }; // Function: Arity 4 -> 4. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return invoker->f_(x1, x2, x3, x4); } }; // Function: Arity 5 -> 5. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return invoker->f_(x1, x2, x3, x4, x5); } }; // Function: Arity 6 -> 6. template
struct Invoker0
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5, typename internal::ParamTraits
::ForwardType x6) { StorageType* invoker = static_cast
(base); return invoker->f_(x1, x2, x3, x4, x5, x6); } }; template
struct Invoker1; // Function: Arity 1 -> 0. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_)); } }; // Method: Arity 0 -> 0. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(); } }; // Function: Arity 2 -> 1. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), x2); } }; // Method: Arity 1 -> 1. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(x1); } }; // Function: Arity 3 -> 2. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), x2, x3); } }; // Method: Arity 2 -> 2. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); } }; // Function: Arity 4 -> 3. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); } }; // Method: Arity 3 -> 3. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); } }; // Function: Arity 5 -> 4. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); } }; // Method: Arity 4 -> 4. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); } }; // Function: Arity 6 -> 5. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5, typename internal::ParamTraits
::ForwardType x6) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); } }; // Method: Arity 5 -> 5. template
struct Invoker1
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x1, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); } }; template
struct Invoker2; // Function: Arity 2 -> 0. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); } }; // Method: Arity 1 -> 0. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); } }; // Function: Arity 3 -> 1. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); } }; // Method: Arity 2 -> 1. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); } }; // Function: Arity 4 -> 2. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); } }; // Method: Arity 3 -> 2. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); } }; // Function: Arity 5 -> 3. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); } }; // Method: Arity 4 -> 3. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, x4); } }; // Function: Arity 6 -> 4. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5, typename internal::ParamTraits
::ForwardType x6) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, x6); } }; // Method: Arity 5 -> 4. template
struct Invoker2
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x2, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, x4, x5); } }; template
struct Invoker3; // Function: Arity 3 -> 0. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), Unwrap(invoker->p3_)); } }; // Method: Arity 2 -> 0. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_)); } }; // Function: Arity 4 -> 1. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), Unwrap(invoker->p3_), x4); } }; // Method: Arity 3 -> 1. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3); } }; // Function: Arity 5 -> 2. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), Unwrap(invoker->p3_), x4, x5); } }; // Method: Arity 4 -> 2. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3, x4); } }; // Function: Arity 6 -> 3. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5, typename internal::ParamTraits
::ForwardType x6) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), Unwrap(invoker->p3_), x4, x5, x6); } }; // Method: Arity 5 -> 3. template
struct Invoker3
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x3, typename internal::ParamTraits
::ForwardType x4, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3, x4, x5); } }; template
struct Invoker4; // Function: Arity 4 -> 0. template
struct Invoker4
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), Unwrap(invoker->p3_), Unwrap(invoker->p4_)); } }; // Method: Arity 3 -> 0. template
struct Invoker4
{ static R DoInvoke(InvokerStorageBase* base) { StorageType* invoker = static_cast
(base); return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), Unwrap(invoker->p4_)); } }; // Function: Arity 5 -> 1. template
struct Invoker4
{ static R DoInvoke(InvokerStorageBase* base, typename internal::ParamTraits
::ForwardType x5) { StorageType* invoker = static_cast
(base); return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); } }; // Method: Arity 4 -> 1. template
struct Invoker4