OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_API_NATIVES_H_ | 5 #ifndef V8_API_NATIVES_H_ |
6 #define V8_API_NATIVES_H_ | 6 #define V8_API_NATIVES_H_ |
7 | 7 |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/objects.h" | |
10 #include "src/property-details.h" | 9 #include "src/property-details.h" |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 // Forward declarations. | 14 // Forward declarations. |
16 class ObjectTemplateInfo; | 15 class ObjectTemplateInfo; |
17 class TemplateInfo; | 16 class TemplateInfo; |
18 | 17 |
19 class ApiNatives { | 18 class ApiNatives { |
20 public: | 19 public: |
21 static const int kInitialFunctionCacheSize = 256; | 20 static const int kInitialFunctionCacheSize = 256; |
22 | 21 |
23 MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction( | 22 MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction( |
24 Handle<FunctionTemplateInfo> data); | 23 Handle<FunctionTemplateInfo> data); |
25 | 24 |
26 MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateObject( | 25 MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateObject( |
27 Handle<ObjectTemplateInfo> data, | 26 Handle<ObjectTemplateInfo> data, |
28 Handle<JSReceiver> new_target = Handle<JSReceiver>()); | 27 Handle<JSReceiver> new_target = Handle<JSReceiver>()); |
29 | 28 |
| 29 enum ApiInstanceType { |
| 30 JavaScriptObjectType, |
| 31 GlobalObjectType, |
| 32 GlobalProxyType |
| 33 }; |
| 34 |
30 static Handle<JSFunction> CreateApiFunction(Isolate* isolate, | 35 static Handle<JSFunction> CreateApiFunction(Isolate* isolate, |
31 Handle<FunctionTemplateInfo> obj, | 36 Handle<FunctionTemplateInfo> obj, |
32 InstanceType type); | 37 Handle<Object> prototype, |
| 38 ApiInstanceType instance_type); |
33 | 39 |
34 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, | 40 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, |
35 Handle<Name> name, Handle<Object> value, | 41 Handle<Name> name, Handle<Object> value, |
36 PropertyAttributes attributes); | 42 PropertyAttributes attributes); |
37 | 43 |
38 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, | 44 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, |
39 Handle<Name> name, v8::Intrinsic intrinsic, | 45 Handle<Name> name, v8::Intrinsic intrinsic, |
40 PropertyAttributes attributes); | 46 PropertyAttributes attributes); |
41 | 47 |
42 static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info, | 48 static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info, |
43 Handle<Name> name, | 49 Handle<Name> name, |
44 Handle<FunctionTemplateInfo> getter, | 50 Handle<FunctionTemplateInfo> getter, |
45 Handle<FunctionTemplateInfo> setter, | 51 Handle<FunctionTemplateInfo> setter, |
46 PropertyAttributes attributes); | 52 PropertyAttributes attributes); |
47 | 53 |
48 static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info, | 54 static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info, |
49 Handle<AccessorInfo> property); | 55 Handle<AccessorInfo> property); |
50 }; | 56 }; |
51 | 57 |
52 } // namespace internal | 58 } // namespace internal |
53 } // namespace v8 | 59 } // namespace v8 |
54 | 60 |
55 #endif | 61 #endif |
OLD | NEW |