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_API_NATIVES_H_ 6 #define V8_API_API_NATIVES_H_ 7 8 #include "include/v8-template.h" 9 #include "src/base/macros.h" 10 #include "src/handles/handles.h" 11 #include "src/handles/maybe-handles.h" 12 #include "src/objects/objects.h" 13 #include "src/objects/property-details.h" 14 15 namespace v8 { 16 namespace internal { 17 18 // Forward declarations. 19 enum InstanceType : uint16_t; 20 class ObjectTemplateInfo; 21 class TemplateInfo; 22 23 class ApiNatives { 24 public: 25 static const int kInitialFunctionCacheSize = 256; 26 27 V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction( 28 Isolate* isolate, Handle<NativeContext> native_context, 29 Handle<FunctionTemplateInfo> data, 30 MaybeHandle<Name> maybe_name = MaybeHandle<Name>()); 31 32 V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction( 33 Handle<FunctionTemplateInfo> data, 34 MaybeHandle<Name> maybe_name = MaybeHandle<Name>()); 35 36 V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> InstantiateObject( 37 Isolate* isolate, Handle<ObjectTemplateInfo> data, 38 Handle<JSReceiver> new_target = Handle<JSReceiver>()); 39 40 V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> InstantiateRemoteObject( 41 Handle<ObjectTemplateInfo> data); 42 43 static Handle<JSFunction> CreateApiFunction( 44 Isolate* isolate, Handle<NativeContext> native_context, 45 Handle<FunctionTemplateInfo> obj, Handle<Object> prototype, 46 InstanceType type, MaybeHandle<Name> name = MaybeHandle<Name>()); 47 48 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, 49 Handle<Name> name, Handle<Object> value, 50 PropertyAttributes attributes); 51 52 static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, 53 Handle<Name> name, v8::Intrinsic intrinsic, 54 PropertyAttributes attributes); 55 56 static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info, 57 Handle<Name> name, 58 Handle<FunctionTemplateInfo> getter, 59 Handle<FunctionTemplateInfo> setter, 60 PropertyAttributes attributes); 61 62 static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info, 63 Handle<AccessorInfo> property); 64 }; 65 66 } // namespace internal 67 } // namespace v8 68 69 #endif // V8_API_API_NATIVES_H_ 70