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

Side by Side Diff: src/api-arguments.cc

Issue 1776913005: Simplify the interface of PropertyCallbackArguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 "src/api-arguments.h" 5 #include "src/api-arguments.h"
6 6
7 #include "src/api.h"
8 #include "src/vm-state-inl.h"
9
10 namespace v8 { 7 namespace v8 {
11 namespace internal { 8 namespace internal {
12 9
13 template <typename T> 10 Handle<Object> FunctionCallbackArguments::Call(FunctionCallback f) {
14 template <typename V>
15 v8::Local<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
16 // Check the ReturnValue.
17 Object** handle = &this->begin()[kReturnValueOffset];
18 // Nothing was set, return empty handle as per previous behaviour.
19 if ((*handle)->IsTheHole()) return v8::Local<V>();
20 return Utils::Convert<Object, V>(Handle<Object>(handle));
21 }
22
23 v8::Local<v8::Value> FunctionCallbackArguments::Call(FunctionCallback f) {
24 Isolate* isolate = this->isolate(); 11 Isolate* isolate = this->isolate();
25 VMState<EXTERNAL> state(isolate); 12 VMState<EXTERNAL> state(isolate);
26 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); 13 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
27 FunctionCallbackInfo<v8::Value> info(begin(), argv_, argc_, 14 FunctionCallbackInfo<v8::Value> info(begin(), argv_, argc_,
28 is_construct_call_); 15 is_construct_call_);
29 f(info); 16 f(info);
30 return GetReturnValue<v8::Value>(isolate); 17 return GetReturnValue<Object>(isolate);
31 } 18 }
32 19
33 #define WRITE_CALL_0(Function, ReturnValue) \ 20 Handle<JSObject> PropertyCallbackArguments::Call(
34 v8::Local<ReturnValue> PropertyCallbackArguments::Call(Function f) { \ 21 IndexedPropertyEnumeratorCallback f) {
35 Isolate* isolate = this->isolate(); \ 22 Isolate* isolate = this->isolate();
36 VMState<EXTERNAL> state(isolate); \ 23 VMState<EXTERNAL> state(isolate);
37 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ 24 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
38 PropertyCallbackInfo<ReturnValue> info(begin()); \ 25 PropertyCallbackInfo<v8::Array> info(begin());
39 f(info); \ 26 f(info);
40 return GetReturnValue<ReturnValue>(isolate); \ 27 return GetReturnValue<JSObject>(isolate);
41 } 28 }
42
43 #define WRITE_CALL_1(Function, ReturnValue, Arg1) \
44 v8::Local<ReturnValue> PropertyCallbackArguments::Call(Function f, \
45 Arg1 arg1) { \
46 Isolate* isolate = this->isolate(); \
47 VMState<EXTERNAL> state(isolate); \
48 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
49 PropertyCallbackInfo<ReturnValue> info(begin()); \
50 f(arg1, info); \
51 return GetReturnValue<ReturnValue>(isolate); \
52 }
53
54 #define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
55 v8::Local<ReturnValue> PropertyCallbackArguments::Call( \
56 Function f, Arg1 arg1, Arg2 arg2) { \
57 Isolate* isolate = this->isolate(); \
58 VMState<EXTERNAL> state(isolate); \
59 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
60 PropertyCallbackInfo<ReturnValue> info(begin()); \
61 f(arg1, arg2, info); \
62 return GetReturnValue<ReturnValue>(isolate); \
63 }
64
65 #define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
66 void PropertyCallbackArguments::Call(Function f, Arg1 arg1, Arg2 arg2) { \
67 Isolate* isolate = this->isolate(); \
68 VMState<EXTERNAL> state(isolate); \
69 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
70 PropertyCallbackInfo<ReturnValue> info(begin()); \
71 f(arg1, arg2, info); \
72 }
73
74 FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
75 FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
76 FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
77 FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
78
79 #undef WRITE_CALL_0
80 #undef WRITE_CALL_1
81 #undef WRITE_CALL_2
82 #undef WRITE_CALL_2_VOID
83 29
84 } // namespace internal 30 } // namespace internal
85 } // namespace v8 31 } // namespace v8
OLDNEW
« src/api-arguments.h ('K') | « src/api-arguments.h ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698