@@ -14,45 +14,27 @@ using v8::String;
14
14
using v8::Value;
15
15
16
16
17
- static void IsRegExp (const FunctionCallbackInfo<Value>& args) {
18
- CHECK_EQ (1 , args.Length ());
19
- args.GetReturnValue ().Set (args[0 ]->IsRegExp ());
20
- }
21
-
17
+ #define VALUE_METHOD_MAP (V ) \
18
+ V (isArrayBuffer, IsArrayBuffer) \
19
+ V (isDataView, IsDataView) \
20
+ V (isDate, IsDate) \
21
+ V (isMap, IsMap) \
22
+ V (isMapIterator, IsMapIterator) \
23
+ V (isPromise, IsPromise) \
24
+ V (isRegExp, IsRegExp) \
25
+ V (isSet, IsSet) \
26
+ V (isSetIterator, IsSetIterator) \
27
+ V (isTypedArray, IsTypedArray)
22
28
23
- static void IsDate (const FunctionCallbackInfo<Value>& args) {
24
- CHECK_EQ (1 , args.Length ());
25
- args.GetReturnValue ().Set (args[0 ]->IsDate ());
26
- }
27
29
30
+ #define V (_, ucname ) \
31
+ static void ucname (const FunctionCallbackInfo<Value>& args) { \
32
+ CHECK_EQ (1 , args.Length ()); \
33
+ args.GetReturnValue ().Set (args[0 ]->ucname ()); \
34
+ }
28
35
29
- static void IsMap (const FunctionCallbackInfo<Value>& args) {
30
- CHECK_EQ (1 , args.Length ());
31
- args.GetReturnValue ().Set (args[0 ]->IsMap ());
32
- }
33
-
34
-
35
- static void IsMapIterator (const FunctionCallbackInfo<Value>& args) {
36
- CHECK_EQ (1 , args.Length ());
37
- args.GetReturnValue ().Set (args[0 ]->IsMapIterator ());
38
- }
39
-
40
-
41
- static void IsSet (const FunctionCallbackInfo<Value>& args) {
42
- CHECK_EQ (1 , args.Length ());
43
- args.GetReturnValue ().Set (args[0 ]->IsSet ());
44
- }
45
-
46
-
47
- static void IsSetIterator (const FunctionCallbackInfo<Value>& args) {
48
- CHECK_EQ (1 , args.Length ());
49
- args.GetReturnValue ().Set (args[0 ]->IsSetIterator ());
50
- }
51
-
52
- static void IsPromise (const FunctionCallbackInfo<Value>& args) {
53
- CHECK_EQ (1 , args.Length ());
54
- args.GetReturnValue ().Set (args[0 ]->IsPromise ());
55
- }
36
+ VALUE_METHOD_MAP (V)
37
+ #undef V
56
38
57
39
58
40
static void GetHiddenValue (const FunctionCallbackInfo<Value>& args) {
@@ -75,13 +57,11 @@ void Initialize(Local<Object> target,
75
57
Local<Value> unused,
76
58
Local<Context> context) {
77
59
Environment* env = Environment::GetCurrent (context);
78
- env->SetMethod (target, " isRegExp" , IsRegExp);
79
- env->SetMethod (target, " isDate" , IsDate);
80
- env->SetMethod (target, " isMap" , IsMap);
81
- env->SetMethod (target, " isMapIterator" , IsMapIterator);
82
- env->SetMethod (target, " isSet" , IsSet);
83
- env->SetMethod (target, " isSetIterator" , IsSetIterator);
84
- env->SetMethod (target, " isPromise" , IsPromise);
60
+
61
+ #define V (lcname, ucname ) env->SetMethod (target, #lcname, ucname);
62
+ VALUE_METHOD_MAP (V)
63
+ #undef V
64
+
85
65
env->SetMethod (target, " getHiddenValue" , GetHiddenValue);
86
66
}
87
67
0 commit comments