blob: 66901fe965e715918c4d33c61d1f0d2b85a0c647 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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 "src/handles.h"
9#include "src/property-details.h"
10
11namespace v8 {
12namespace internal {
13
14// Forward declarations.
15class ObjectTemplateInfo;
16class TemplateInfo;
17
18class ApiNatives {
19 public:
20 static const int kInitialFunctionCacheSize = 256;
21
22 MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
23 Handle<FunctionTemplateInfo> data);
24
25 MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateObject(
Ben Murdochc5610432016-08-08 18:44:38 +010026 Handle<ObjectTemplateInfo> data,
27 Handle<JSReceiver> new_target = Handle<JSReceiver>());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000028
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029 enum ApiInstanceType {
30 JavaScriptObjectType,
31 GlobalObjectType,
32 GlobalProxyType
33 };
34
35 static Handle<JSFunction> CreateApiFunction(Isolate* isolate,
36 Handle<FunctionTemplateInfo> obj,
37 Handle<Object> prototype,
38 ApiInstanceType instance_type);
39
40 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
41 Handle<Name> name, Handle<Object> value,
42 PropertyAttributes attributes);
43
44 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
45 Handle<Name> name, v8::Intrinsic intrinsic,
46 PropertyAttributes attributes);
47
48 static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info,
49 Handle<Name> name,
50 Handle<FunctionTemplateInfo> getter,
51 Handle<FunctionTemplateInfo> setter,
52 PropertyAttributes attributes);
53
54 static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
55 Handle<AccessorInfo> property);
56};
57
58} // namespace internal
59} // namespace v8
60
61#endif