api-natives.h 2.16 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
  MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
23 24
      Handle<FunctionTemplateInfo> data,
      MaybeHandle<Name> maybe_name = MaybeHandle<Name>());
dcarney's avatar
dcarney committed
25

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

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

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

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

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

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

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

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

}  // namespace internal
}  // namespace v8

#endif