File indexing completed on 2026-01-10 10:15:04
0001
0002
0003
0004
0005 #ifndef INCLUDE_V8_FUNCTION_H_
0006 #define INCLUDE_V8_FUNCTION_H_
0007
0008 #include <stddef.h>
0009 #include <stdint.h>
0010
0011 #include "v8-function-callback.h" // NOLINT(build/include_directory)
0012 #include "v8-local-handle.h" // NOLINT(build/include_directory)
0013 #include "v8-message.h" // NOLINT(build/include_directory)
0014 #include "v8-object.h" // NOLINT(build/include_directory)
0015 #include "v8-template.h" // NOLINT(build/include_directory)
0016 #include "v8config.h" // NOLINT(build/include_directory)
0017
0018 namespace v8 {
0019
0020 class Context;
0021 class Location;
0022 class UnboundScript;
0023
0024
0025
0026
0027 class V8_EXPORT Function : public Object {
0028 public:
0029
0030
0031
0032
0033 static MaybeLocal<Function> New(
0034 Local<Context> context, FunctionCallback callback,
0035 Local<Value> data = Local<Value>(), int length = 0,
0036 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
0037 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
0038
0039 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
0040 Local<Context> context, int argc, Local<Value> argv[]) const;
0041
0042 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
0043 Local<Context> context) const {
0044 return NewInstance(context, 0, nullptr);
0045 }
0046
0047
0048
0049
0050
0051
0052 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstanceWithSideEffectType(
0053 Local<Context> context, int argc, Local<Value> argv[],
0054 SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
0055
0056 V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(v8::Isolate* isolate,
0057 Local<Context> context,
0058 Local<Value> recv, int argc,
0059 Local<Value> argv[]);
0060 V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
0061 Local<Value> recv, int argc,
0062 Local<Value> argv[]);
0063
0064 void SetName(Local<String> name);
0065 Local<Value> GetName() const;
0066
0067
0068
0069
0070
0071
0072
0073 Local<Value> GetInferredName() const;
0074
0075
0076
0077
0078
0079 Local<Value> GetDebugName() const;
0080
0081
0082
0083
0084
0085 int GetScriptLineNumber() const;
0086
0087
0088
0089
0090 int GetScriptColumnNumber() const;
0091
0092
0093
0094
0095
0096 Location GetScriptLocation() const;
0097
0098
0099
0100
0101
0102 int GetScriptStartPosition() const;
0103
0104
0105
0106
0107 int ScriptId() const;
0108
0109
0110
0111
0112
0113 Local<Value> GetBoundFunction() const;
0114
0115
0116
0117
0118
0119
0120
0121 V8_WARN_UNUSED_RESULT MaybeLocal<String> FunctionProtoToString(
0122 Local<Context> context);
0123
0124
0125
0126
0127
0128
0129
0130 V8_WARN_UNUSED_RESULT bool Experimental_IsNopFunction() const;
0131
0132 ScriptOrigin GetScriptOrigin() const;
0133 V8_INLINE static Function* Cast(Value* value) {
0134 #ifdef V8_ENABLE_CHECKS
0135 CheckCast(value);
0136 #endif
0137 return static_cast<Function*>(value);
0138 }
0139
0140 static const int kLineOffsetNotFound;
0141
0142 private:
0143 Function();
0144 static void CheckCast(Value* obj);
0145 };
0146 }
0147
0148 #endif