diff options
author | yurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-27 15:17:58 +0000 |
---|---|---|
committer | yurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-27 15:17:58 +0000 |
commit | 57015e6b0f8ba6902d128afdde1eb71f0f25bf67 (patch) | |
tree | 1ca80fc1b560bc9025a958c8cef858aca1aca4e2 /webkit/glue/devtools/devtools_rpc_js.h | |
parent | 225fd85713705bc75c6765d31657d6da3e344364 (diff) | |
download | chromium_src-57015e6b0f8ba6902d128afdde1eb71f0f25bf67.zip chromium_src-57015e6b0f8ba6902d128afdde1eb71f0f25bf67.tar.gz chromium_src-57015e6b0f8ba6902d128afdde1eb71f0f25bf67.tar.bz2 |
DevTools: prepare devtools files from webkit/glue for upstreaming
BUG=28062
Review URL: http://codereview.chromium.org/549173
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37251 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/devtools/devtools_rpc_js.h')
-rw-r--r-- | webkit/glue/devtools/devtools_rpc_js.h | 160 |
1 files changed, 93 insertions, 67 deletions
diff --git a/webkit/glue/devtools/devtools_rpc_js.h b/webkit/glue/devtools/devtools_rpc_js.h index 39362a3..4352bc4 100644 --- a/webkit/glue/devtools/devtools_rpc_js.h +++ b/webkit/glue/devtools/devtools_rpc_js.h @@ -1,6 +1,32 @@ -// Copyright (c) 2009 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. +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ // Additional set of macros for the JS RPC. @@ -19,100 +45,100 @@ // JS RPC binds and stubs #define TOOLS_RPC_JS_BIND_METHOD0(Method) \ - bound_obj.AddProtoFunction(#Method, OCLASS::Js##Method); + boundObj.addProtoFunction(#Method, OCLASS::js##Method); #define TOOLS_RPC_JS_BIND_METHOD1(Method, T1) \ - bound_obj.AddProtoFunction(#Method, OCLASS::Js##Method); + boundObj.addProtoFunction(#Method, OCLASS::js##Method); #define TOOLS_RPC_JS_BIND_METHOD2(Method, T1, T2) \ - bound_obj.AddProtoFunction(#Method, OCLASS::Js##Method); + boundObj.addProtoFunction(#Method, OCLASS::js##Method); #define TOOLS_RPC_JS_BIND_METHOD3(Method, T1, T2, T3) \ - bound_obj.AddProtoFunction(#Method, OCLASS::Js##Method); + boundObj.addProtoFunction(#Method, OCLASS::js##Method); #define TOOLS_RPC_JS_BIND_METHOD4(Method, T1, T2, T3, T4) \ - bound_obj.AddProtoFunction(#Method, OCLASS::Js##Method); + boundObj.addProtoFunction(#Method, OCLASS::js##Method); #define TOOLS_RPC_JS_BIND_METHOD5(Method, T1, T2, T3, T4, T5) \ - bound_obj.AddProtoFunction(#Method, OCLASS::Js##Method); + boundObj.addProtoFunction(#Method, OCLASS::js##Method); #define TOOLS_RPC_JS_STUB_METHOD0(Method) \ - static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 0); \ - return v8::Undefined(); \ - } + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJs(#Method, args, 0); \ + return v8::Undefined(); \ + } #define TOOLS_RPC_JS_STUB_METHOD1(Method, T1) \ - static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 1); \ - return v8::Undefined(); \ - } + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJs(#Method, args, 1); \ + return v8::Undefined(); \ + } #define TOOLS_RPC_JS_STUB_METHOD2(Method, T1, T2) \ - static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 2); \ - return v8::Undefined(); \ - } + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJs(#Method, args, 2); \ + return v8::Undefined(); \ + } #define TOOLS_RPC_JS_STUB_METHOD3(Method, T1, T2, T3) \ - static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 3); \ - return v8::Undefined(); \ - } + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJs(#Method, args, 3); \ + return v8::Undefined(); \ + } #define TOOLS_RPC_JS_STUB_METHOD4(Method, T1, T2, T3, T4) \ - static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 4); \ - return v8::Undefined(); \ - } + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJs(#Method, args, 4); \ + return v8::Undefined(); \ + } #define TOOLS_RPC_JS_STUB_METHOD5(Method, T1, T2, T3, T4, T5) \ - static v8::Handle<v8::Value> Js##Method(const v8::Arguments& args) { \ - SendRpcMessageFromJs(#Method, args, 5); \ - return v8::Undefined(); \ - } + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJs(#Method, args, 5); \ + return v8::Undefined(); \ + } /////////////////////////////////////////////////////// // JS RPC main obj macro #define DEFINE_RPC_JS_BOUND_OBJ(Class, STRUCT, DClass, DELEGATE_STRUCT) \ class Js##Class##BoundObj : public Class##Stub { \ - public: \ - Js##Class##BoundObj(Delegate* rpc_delegate, \ - v8::Handle<v8::Context> context, \ - const char* classname) \ - : Class##Stub(rpc_delegate) { \ - BoundObject bound_obj(context, this, classname); \ +public: \ + Js##Class##BoundObj(Delegate* rpcDelegate, \ + v8::Handle<v8::Context> context, \ + const char* classname) \ + : Class##Stub(rpcDelegate) { \ + BoundObject boundObj(context, this, classname); \ + STRUCT( \ + TOOLS_RPC_JS_BIND_METHOD0, \ + TOOLS_RPC_JS_BIND_METHOD1, \ + TOOLS_RPC_JS_BIND_METHOD2, \ + TOOLS_RPC_JS_BIND_METHOD3, \ + TOOLS_RPC_JS_BIND_METHOD4, \ + TOOLS_RPC_JS_BIND_METHOD5) \ + boundObj.build(); \ + } \ + virtual ~Js##Class##BoundObj() {} \ + typedef Js##Class##BoundObj OCLASS; \ STRUCT( \ - TOOLS_RPC_JS_BIND_METHOD0, \ - TOOLS_RPC_JS_BIND_METHOD1, \ - TOOLS_RPC_JS_BIND_METHOD2, \ - TOOLS_RPC_JS_BIND_METHOD3, \ - TOOLS_RPC_JS_BIND_METHOD4, \ - TOOLS_RPC_JS_BIND_METHOD5) \ - bound_obj.Build(); \ - } \ - virtual ~Js##Class##BoundObj() {} \ - typedef Js##Class##BoundObj OCLASS; \ - STRUCT( \ - TOOLS_RPC_JS_STUB_METHOD0, \ - TOOLS_RPC_JS_STUB_METHOD1, \ - TOOLS_RPC_JS_STUB_METHOD2, \ - TOOLS_RPC_JS_STUB_METHOD3, \ - TOOLS_RPC_JS_STUB_METHOD4, \ - TOOLS_RPC_JS_STUB_METHOD5) \ - private: \ - static void SendRpcMessageFromJs(const char* method, \ - const v8::Arguments& js_arguments, \ - size_t args_count) { \ - Vector<String> args(args_count); \ - for (size_t i = 0; i < args_count; i++) { \ - args[i] = WebCore::toWebCoreStringWithNullCheck(js_arguments[i]); \ + TOOLS_RPC_JS_STUB_METHOD0, \ + TOOLS_RPC_JS_STUB_METHOD1, \ + TOOLS_RPC_JS_STUB_METHOD2, \ + TOOLS_RPC_JS_STUB_METHOD3, \ + TOOLS_RPC_JS_STUB_METHOD4, \ + TOOLS_RPC_JS_STUB_METHOD5) \ +private: \ + static void sendRpcMessageFromJs(const char* method, \ + const v8::Arguments& jsArguments, \ + size_t argsCount) \ + { \ + Vector<String> args(argsCount); \ + for (size_t i = 0; i < argsCount; i++) \ + args[i] = WebCore::toWebCoreStringWithNullCheck(jsArguments[i]); \ + void* selfPtr = v8::External::Cast(*jsArguments.Data())->Value(); \ + Js##Class##BoundObj* self = static_cast<Js##Class##BoundObj*>(selfPtr); \ + self->sendRpcMessage(#Class, method, args); \ } \ - void* self_ptr = v8::External::Cast(*js_arguments.Data())->Value(); \ - Js##Class##BoundObj* self = static_cast<Js##Class##BoundObj*>(self_ptr); \ - self->SendRpcMessage(#Class, method, args); \ - } \ }; #endif // WEBKIT_GLUE_DEVTOOLS_DEVTOOLS_RPC_JS_H_ |