File indexing completed on 2025-02-21 10:05:24
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 UnboundScript;
0022
0023
0024
0025
0026 class V8_EXPORT Function : public Object {
0027 public:
0028
0029
0030
0031
0032 static MaybeLocal<Function> New(
0033 Local<Context> context, FunctionCallback callback,
0034 Local<Value> data = Local<Value>(), int length = 0,
0035 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
0036 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
0037
0038 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
0039 Local<Context> context, int argc, Local<Value> argv[]) const;
0040
0041 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
0042 Local<Context> context) const {
0043 return NewInstance(context, 0, nullptr);
0044 }
0045
0046
0047
0048
0049
0050
0051 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstanceWithSideEffectType(
0052 Local<Context> context, int argc, Local<Value> argv[],
0053 SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
0054
0055 V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
0056 Local<Value> recv, int argc,
0057 Local<Value> argv[]);
0058
0059 void SetName(Local<String> name);
0060 Local<Value> GetName() const;
0061
0062 V8_DEPRECATED("No direct replacement")
0063 MaybeLocal<UnboundScript> GetUnboundScript() const;
0064
0065
0066
0067
0068
0069
0070
0071 Local<Value> GetInferredName() const;
0072
0073
0074
0075
0076
0077 Local<Value> GetDebugName() const;
0078
0079
0080
0081
0082
0083 int GetScriptLineNumber() const;
0084
0085
0086
0087
0088 int GetScriptColumnNumber() const;
0089
0090
0091
0092
0093
0094 int GetScriptStartPosition() const;
0095
0096
0097
0098
0099 int ScriptId() const;
0100
0101
0102
0103
0104
0105 Local<Value> GetBoundFunction() const;
0106
0107
0108
0109
0110
0111
0112
0113 V8_WARN_UNUSED_RESULT MaybeLocal<String> FunctionProtoToString(
0114 Local<Context> context);
0115
0116
0117
0118
0119
0120
0121
0122 V8_WARN_UNUSED_RESULT bool Experimental_IsNopFunction() const;
0123
0124 ScriptOrigin GetScriptOrigin() const;
0125 V8_INLINE static Function* Cast(Value* value) {
0126 #ifdef V8_ENABLE_CHECKS
0127 CheckCast(value);
0128 #endif
0129 return static_cast<Function*>(value);
0130 }
0131
0132 static const int kLineOffsetNotFound;
0133
0134 private:
0135 Function();
0136 static void CheckCast(Value* obj);
0137 };
0138 }
0139
0140 #endif