@@ -14,45 +14,27 @@ using v8::String;
1414using v8::Value;
1515
1616
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)
2228
23- static void IsDate (const FunctionCallbackInfo<Value>& args) {
24- CHECK_EQ (1 , args.Length ());
25- args.GetReturnValue ().Set (args[0 ]->IsDate ());
26- }
2729
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+ }
2835
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
5638
5739
5840static void GetHiddenValue (const FunctionCallbackInfo<Value>& args) {
@@ -75,13 +57,11 @@ void Initialize(Local<Object> target,
7557 Local<Value> unused,
7658 Local<Context> context) {
7759 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+
8565 env->SetMethod (target, " getHiddenValue" , GetHiddenValue);
8666}
8767
0 commit comments