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