v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8-function.h
Go to the documentation of this file.
1// Copyright 2021 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 INCLUDE_V8_FUNCTION_H_
6#define INCLUDE_V8_FUNCTION_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "v8-function-callback.h" // NOLINT(build/include_directory)
12#include "v8-local-handle.h" // NOLINT(build/include_directory)
13#include "v8-message.h" // NOLINT(build/include_directory)
14#include "v8-object.h" // NOLINT(build/include_directory)
15#include "v8-template.h" // NOLINT(build/include_directory)
16#include "v8config.h" // NOLINT(build/include_directory)
17
18namespace v8 {
19
20class Context;
21class Location;
22class UnboundScript;
23
27class V8_EXPORT Function : public Object {
28 public:
33 static MaybeLocal<Function> New(
35 Local<Value> data = Local<Value>(), int length = 0,
36 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
37 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
38
40 Local<Context> context, int argc, Local<Value> argv[]) const;
41
43 Local<Context> context) const {
44 return NewInstance(context, 0, nullptr);
45 }
46
52 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstanceWithSideEffectType(
53 Local<Context> context, int argc, Local<Value> argv[],
54 SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
55
57 Local<Context> context,
58 Local<Value> recv, int argc,
59 Local<Value> argv[]);
61 Local<Value> recv, int argc,
62 Local<Value> argv[]);
63
64 void SetName(Local<String> name);
65 Local<Value> GetName() const;
66
73 Local<Value> GetInferredName() const;
74
79 Local<Value> GetDebugName() const;
80
85 int GetScriptLineNumber() const;
90 int GetScriptColumnNumber() const;
91
96 Location GetScriptLocation() const;
97
102 int GetScriptStartPosition() const;
103
107 int ScriptId() const;
108
113 Local<Value> GetBoundFunction() const;
114
121 V8_WARN_UNUSED_RESULT MaybeLocal<String> FunctionProtoToString(
122 Local<Context> context);
123
130 V8_WARN_UNUSED_RESULT bool Experimental_IsNopFunction() const;
131
132 ScriptOrigin GetScriptOrigin() const;
133 V8_INLINE static Function* Cast(Value* value) {
134#ifdef V8_ENABLE_CHECKS
135 CheckCast(value);
136#endif
137 return static_cast<Function*>(value);
138 }
139
140 static const int kLineOffsetNotFound;
141
142 private:
144 static void CheckCast(Value* obj);
145};
146} // namespace v8
147
148#endif // INCLUDE_V8_FUNCTION_H_
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context) const
Definition v8-function.h:42
static const int kLineOffsetNotFound
static V8_INLINE Function * Cast(Value *value)
TNode< Object > callback
SideEffectType
Definition v8-object.h:198
ConstructorBehavior
void(*)(const FunctionCallbackInfo< Value > &info) FunctionCallback
#define V8_EXPORT
Definition v8config.h:800
#define V8_INLINE
Definition v8config.h:500
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671
std::unique_ptr< ValueMirror > value