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   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
     62