From ebcf4c022467a43a5379446e1c031ffd10438b9c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 7 Aug 2015 18:09:37 +0800 Subject: [PATCH] Remove callback.h --- native_mate/callback.h | 443 ------------------------------------ native_mate/callback.h.pump | 133 ----------- 2 files changed, 576 deletions(-) delete mode 100644 native_mate/callback.h delete mode 100644 native_mate/callback.h.pump diff --git a/native_mate/callback.h b/native_mate/callback.h deleted file mode 100644 index 2b3640050448..000000000000 --- a/native_mate/callback.h +++ /dev/null @@ -1,443 +0,0 @@ -// This file was GENERATED by command: -// pump.py callback.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright (c) 2014 GitHub, Inc. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "base/bind.h" -#include "base/callback.h" -#include "native_mate/function_template.h" -#include "native_mate/locker.h" -#include "native_mate/scoped_persistent.h" - -namespace mate { - -namespace internal { - -typedef scoped_refptr > SafeV8Function; - -// This set of templates invokes a V8::Function by converting the C++ types. -template -struct V8FunctionInvoker; - -template -struct V8FunctionInvoker()> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local val(holder->Call(holder, 0, NULL)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local val(holder->Call(holder, 0, NULL)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template<> -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - holder->Call(holder, 0, NULL); - } -}; - -template -struct V8FunctionInvoker(P1)> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - }; - holder->Call(holder, arraysize(args), args); - } -}; - -template -struct V8FunctionInvoker(P1, P2)> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, - P2 a2) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - }; - holder->Call(holder, arraysize(args), args); - } -}; - -template -struct V8FunctionInvoker(P1, P2, P3)> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, - P2 a2, P3 a3) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - }; - holder->Call(holder, arraysize(args), args); - } -}; - -template -struct V8FunctionInvoker(P1, P2, P3, P4)> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, - P2 a2, P3 a3, P4 a4) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3, P4 a4) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3, P4 a4) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - }; - holder->Call(holder, arraysize(args), args); - } -}; - -template -struct V8FunctionInvoker(P1, P2, P3, P4, P5)> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, - P2 a2, P3 a3, P4 a4, P5 a5) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - ConvertToV8(isolate, a5), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3, P4 a4, P5 a5) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - ConvertToV8(isolate, a5), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3, P4 a4, P5 a5) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - ConvertToV8(isolate, a5), - }; - holder->Call(holder, arraysize(args), args); - } -}; - -template -struct V8FunctionInvoker(P1, P2, P3, P4, P5, P6)> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, - P2 a2, P3 a3, P4 a4, P5 a5, P6 a6) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - ConvertToV8(isolate, a5), - ConvertToV8(isolate, a6), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3, P4 a4, P5 a5, P6 a6) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - ConvertToV8(isolate, a5), - ConvertToV8(isolate, a6), - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function, P1 a1, P2 a2, - P3 a3, P4 a4, P5 a5, P6 a6) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - v8::Local args[] = { - ConvertToV8(isolate, a1), - ConvertToV8(isolate, a2), - ConvertToV8(isolate, a3), - ConvertToV8(isolate, a4), - ConvertToV8(isolate, a5), - ConvertToV8(isolate, a6), - }; - holder->Call(holder, arraysize(args), args); - } -}; - -} // namespace internal - -template -struct Converter > { - static v8::Local ToV8(v8::Isolate* isolate, - const base::Callback& val) { - return CreateFunctionTemplate(isolate, val)->GetFunction(); - } - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - base::Callback* out) { - if (!val->IsFunction()) - return false; - - internal::SafeV8Function function( - new RefCountedPersistent(isolate, val)); - *out = base::Bind(&internal::V8FunctionInvoker::Go, isolate, function); - return true; - } -}; - -} // namespace mate diff --git a/native_mate/callback.h.pump b/native_mate/callback.h.pump deleted file mode 100644 index 4ed621dc1c62..000000000000 --- a/native_mate/callback.h.pump +++ /dev/null @@ -1,133 +0,0 @@ -$$ This is a pump file for generating file templates. Pump is a python -$$ script that is part of the Google Test suite of utilities. Description -$$ can be found here: -$$ -$$ http://code.google.com/p/googletest/wiki/PumpManual -$$ -$var MAX_ARITY = 6 -// Copyright (c) 2014 GitHub, Inc. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "base/bind.h" -#include "base/callback.h" -#include "native_mate/function_template.h" -#include "native_mate/locker.h" -#include "native_mate/scoped_persistent.h" - -namespace mate { - -namespace internal { - -typedef scoped_refptr > SafeV8Function; - -// This set of templates invokes a V8::Function by converting the C++ types. -template -struct V8FunctionInvoker; - -$range ARITY 0..MAX_ARITY -$for ARITY [[ -$range ARG 1..ARITY - -template -struct V8FunctionInvoker($for ARG , [[P$(ARG)]])> { - static v8::Local Go(v8::Isolate* isolate, SafeV8Function function$for ARG [[, P$(ARG) a$(ARG)]]) { - Locker locker(isolate); - v8::EscapableHandleScope handle_scope(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - -$if ARITY == 0 [[ - v8::Local val(holder->Call(holder, 0, NULL)); -]] $else [[ - v8::Local args[] = { -$for ARG [[ - - ConvertToV8(isolate, a$(ARG)), -]] - - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); -]] - return handle_scope.Escape(val); - } -}; - -template -struct V8FunctionInvoker { - static R Go(v8::Isolate* isolate, SafeV8Function function$for ARG [[, P$(ARG) a$(ARG)]]) { - R ret; - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - -$if ARITY == 0 [[ - v8::Local val(holder->Call(holder, 0, NULL)); -]] $else [[ - v8::Local args[] = { -$for ARG [[ - - ConvertToV8(isolate, a$(ARG)), -]] - - }; - v8::Local val(holder->Call(holder, arraysize(args), args)); -]] - - Converter::FromV8(isolate, val, &ret); - return ret; - } -}; - -template<$for ARG , [[typename P$(ARG)]]> -struct V8FunctionInvoker { - static void Go(v8::Isolate* isolate, SafeV8Function function$for ARG [[, P$(ARG) a$(ARG)]]) { - Locker locker(isolate); - MATE_HANDLE_SCOPE(isolate); - v8::Local holder = function->NewHandle(); - v8::Local context = holder->CreationContext(); - v8::Context::Scope context_scope(context); - -$if ARITY == 0 [[ - holder->Call(holder, 0, NULL); -]] $else [[ - v8::Local args[] = { -$for ARG [[ - - ConvertToV8(isolate, a$(ARG)), -]] - - }; - holder->Call(holder, arraysize(args), args); -]] - - } -}; - -]] - -} // namespace internal - -template -struct Converter > { - static v8::Local ToV8(v8::Isolate* isolate, - const base::Callback& val) { - return CreateFunctionTemplate(isolate, val)->GetFunction(); - } - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - base::Callback* out) { - if (!val->IsFunction()) - return false; - - internal::SafeV8Function function( - new RefCountedPersistent(isolate, val)); - *out = base::Bind(&internal::V8FunctionInvoker::Go, isolate, function); - return true; - } -}; - -} // namespace mate