api-natives.h 2.17 KB
Newer Older
1 2 3 4 5 6 7 8
// 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.

#ifndef V8_API_NATIVES_H_
#define V8_API_NATIVES_H_

#include "src/handles.h"
9
#include "src/property-details.h"
10 11 12 13

namespace v8 {
namespace internal {

14 15 16 17
// Forward declarations.
class ObjectTemplateInfo;
class TemplateInfo;

18 19
class ApiNatives {
 public:
20 21
  static const int kInitialFunctionCacheSize = 256;

22 23
  MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
      Handle<FunctionTemplateInfo> data);
dcarney's avatar
dcarney committed
24

25
  MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateObject(
26 27
      Handle<ObjectTemplateInfo> data,
      Handle<JSReceiver> new_target = Handle<JSReceiver>());
dcarney's avatar
dcarney committed
28

29 30 31
  MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateRemoteObject(
      Handle<ObjectTemplateInfo> data);

32 33 34 35 36 37
  enum ApiInstanceType {
    JavaScriptObjectType,
    GlobalObjectType,
    GlobalProxyType
  };

38 39
  static Handle<JSFunction> CreateApiFunction(Isolate* isolate,
                                              Handle<FunctionTemplateInfo> obj,
40 41
                                              Handle<Object> prototype,
                                              ApiInstanceType instance_type);
dcarney's avatar
dcarney committed
42 43 44 45 46

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

47 48 49 50
  static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
                              Handle<Name> name, v8::Intrinsic intrinsic,
                              PropertyAttributes attributes);

dcarney's avatar
dcarney committed
51
  static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info,
52 53 54
                                  Handle<Name> name,
                                  Handle<FunctionTemplateInfo> getter,
                                  Handle<FunctionTemplateInfo> setter,
dcarney's avatar
dcarney committed
55 56 57 58
                                  PropertyAttributes attributes);

  static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
                                    Handle<AccessorInfo> property);
59 60 61 62 63 64
};

}  // namespace internal
}  // namespace v8

#endif