api-natives.h 2.56 KB
Newer Older
1 2 3 4
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef V8_API_API_NATIVES_H_
#define V8_API_API_NATIVES_H_
7

8 9
#include "include/v8.h"
#include "src/base/macros.h"
10 11
#include "src/handles/handles.h"
#include "src/handles/maybe-handles.h"
12
#include "src/objects/objects.h"
13
#include "src/objects/property-details.h"
14 15 16 17

namespace v8 {
namespace internal {

18
// Forward declarations.
19
enum InstanceType : uint16_t;
20 21 22
class ObjectTemplateInfo;
class TemplateInfo;

23 24
class ApiNatives {
 public:
25 26
  static const int kInitialFunctionCacheSize = 256;

27 28 29 30 31
  V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
      Isolate* isolate, Handle<NativeContext> native_context,
      Handle<FunctionTemplateInfo> data,
      MaybeHandle<Name> maybe_name = MaybeHandle<Name>());

32
  V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
33 34
      Handle<FunctionTemplateInfo> data,
      MaybeHandle<Name> maybe_name = MaybeHandle<Name>());
dcarney's avatar
dcarney committed
35

36
  V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> InstantiateObject(
37
      Isolate* isolate, Handle<ObjectTemplateInfo> data,
38
      Handle<JSReceiver> new_target = Handle<JSReceiver>());
dcarney's avatar
dcarney committed
39

40
  V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> InstantiateRemoteObject(
41 42
      Handle<ObjectTemplateInfo> data);

43
  static Handle<JSFunction> CreateApiFunction(
44 45 46
      Isolate* isolate, Handle<NativeContext> native_context,
      Handle<FunctionTemplateInfo> obj, Handle<Object> prototype,
      InstanceType type, MaybeHandle<Name> name = MaybeHandle<Name>());
dcarney's avatar
dcarney committed
47 48 49 50 51

  static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
                              Handle<Name> name, Handle<Object> value,
                              PropertyAttributes attributes);

52 53 54 55
  static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
                              Handle<Name> name, v8::Intrinsic intrinsic,
                              PropertyAttributes attributes);

dcarney's avatar
dcarney committed
56
  static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info,
57 58 59
                                  Handle<Name> name,
                                  Handle<FunctionTemplateInfo> getter,
                                  Handle<FunctionTemplateInfo> setter,
dcarney's avatar
dcarney committed
60 61 62 63
                                  PropertyAttributes attributes);

  static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
                                    Handle<AccessorInfo> property);
64 65 66 67 68
};

}  // namespace internal
}  // namespace v8

69
#endif  // V8_API_API_NATIVES_H_