Home | History | Annotate | Download | only in src
      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 "src/handles.h"
      9 #include "src/property-details.h"
     10 
     11 namespace v8 {
     12 namespace internal {
     13 
     14 // Forward declarations.
     15 class ObjectTemplateInfo;
     16 class TemplateInfo;
     17 
     18 class 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(
     26       Handle<ObjectTemplateInfo> data,
     27       Handle<JSReceiver> new_target = Handle<JSReceiver>());
     28 
     29   MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateRemoteObject(
     30       Handle<ObjectTemplateInfo> data);
     31 
     32   enum ApiInstanceType {
     33     JavaScriptObjectType,
     34     GlobalObjectType,
     35     GlobalProxyType
     36   };
     37 
     38   static Handle<JSFunction> CreateApiFunction(Isolate* isolate,
     39                                               Handle<FunctionTemplateInfo> obj,
     40                                               Handle<Object> prototype,
     41                                               ApiInstanceType instance_type);
     42 
     43   static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
     44                               Handle<Name> name, Handle<Object> value,
     45                               PropertyAttributes attributes);
     46 
     47   static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
     48                               Handle<Name> name, v8::Intrinsic intrinsic,
     49                               PropertyAttributes attributes);
     50 
     51   static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info,
     52                                   Handle<Name> name,
     53                                   Handle<FunctionTemplateInfo> getter,
     54                                   Handle<FunctionTemplateInfo> setter,
     55                                   PropertyAttributes attributes);
     56 
     57   static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
     58                                     Handle<AccessorInfo> property);
     59 };
     60 
     61 }  // namespace internal
     62 }  // namespace v8
     63 
     64 #endif
     65