• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/property-details.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 // Forward declarations.
18 class ObjectTemplateInfo;
19 class TemplateInfo;
20 
21 class ApiNatives {
22  public:
23   static const int kInitialFunctionCacheSize = 256;
24 
25   V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
26       Handle<FunctionTemplateInfo> data,
27       MaybeHandle<Name> maybe_name = MaybeHandle<Name>());
28 
29   V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> InstantiateObject(
30       Isolate* isolate, Handle<ObjectTemplateInfo> data,
31       Handle<JSReceiver> new_target = Handle<JSReceiver>());
32 
33   V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> InstantiateRemoteObject(
34       Handle<ObjectTemplateInfo> data);
35 
36   enum ApiInstanceType {
37     JavaScriptObjectType,
38     GlobalObjectType,
39     GlobalProxyType
40   };
41 
42   static Handle<JSFunction> CreateApiFunction(
43       Isolate* isolate, Handle<FunctionTemplateInfo> obj,
44       Handle<Object> prototype, ApiInstanceType instance_type,
45       MaybeHandle<Name> name = MaybeHandle<Name>());
46 
47   static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
48                               Handle<Name> name, Handle<Object> value,
49                               PropertyAttributes attributes);
50 
51   static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
52                               Handle<Name> name, v8::Intrinsic intrinsic,
53                               PropertyAttributes attributes);
54 
55   static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info,
56                                   Handle<Name> name,
57                                   Handle<FunctionTemplateInfo> getter,
58                                   Handle<FunctionTemplateInfo> setter,
59                                   PropertyAttributes attributes);
60 
61   static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
62                                     Handle<AccessorInfo> property);
63 };
64 
65 }  // namespace internal
66 }  // namespace v8
67 
68 #endif  // V8_API_NATIVES_H_
69