2012-01-25 00:16:07 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_ACCESSORS_H_
|
|
|
|
#define V8_ACCESSORS_H_
|
|
|
|
|
2015-08-11 07:34:10 +00:00
|
|
|
#include "include/v8.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/globals.h"
|
2015-08-11 07:34:10 +00:00
|
|
|
#include "src/property-details.h"
|
2011-05-06 06:50:20 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-08-11 12:00:01 +00:00
|
|
|
// Forward declarations.
|
2016-01-18 15:08:36 +00:00
|
|
|
class AccessorInfo;
|
2017-01-27 13:53:13 +00:00
|
|
|
template <typename T>
|
|
|
|
class Handle;
|
2017-11-14 14:15:00 +00:00
|
|
|
class FieldIndex;
|
2015-08-11 12:00:01 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The list of accessor descriptors. This is a second-order macro
|
|
|
|
// taking a macro to be applied to all accessor descriptor names.
|
2017-10-27 09:06:44 +00:00
|
|
|
#define ACCESSOR_INFO_LIST(V) \
|
|
|
|
V(arguments_iterator, ArgumentsIterator) \
|
|
|
|
V(array_length, ArrayLength) \
|
|
|
|
V(bound_function_length, BoundFunctionLength) \
|
|
|
|
V(bound_function_name, BoundFunctionName) \
|
|
|
|
V(error_stack, ErrorStack) \
|
|
|
|
V(function_arguments, FunctionArguments) \
|
|
|
|
V(function_caller, FunctionCaller) \
|
|
|
|
V(function_name, FunctionName) \
|
|
|
|
V(function_length, FunctionLength) \
|
|
|
|
V(function_prototype, FunctionPrototype) \
|
|
|
|
V(script_column_offset, ScriptColumnOffset) \
|
|
|
|
V(script_compilation_type, ScriptCompilationType) \
|
|
|
|
V(script_context_data, ScriptContextData) \
|
|
|
|
V(script_eval_from_script, ScriptEvalFromScript) \
|
|
|
|
V(script_eval_from_script_position, ScriptEvalFromScriptPosition) \
|
|
|
|
V(script_eval_from_function_name, ScriptEvalFromFunctionName) \
|
|
|
|
V(script_id, ScriptId) \
|
|
|
|
V(script_line_offset, ScriptLineOffset) \
|
|
|
|
V(script_name, ScriptName) \
|
|
|
|
V(script_source, ScriptSource) \
|
|
|
|
V(script_type, ScriptType) \
|
|
|
|
V(script_source_url, ScriptSourceUrl) \
|
|
|
|
V(script_source_mapping_url, ScriptSourceMappingUrl) \
|
|
|
|
V(string_length, StringLength)
|
2014-04-15 13:25:17 +00:00
|
|
|
|
2016-07-20 13:02:36 +00:00
|
|
|
#define ACCESSOR_SETTER_LIST(V) \
|
|
|
|
V(ArrayLengthSetter) \
|
|
|
|
V(ErrorStackSetter) \
|
2016-10-07 19:37:04 +00:00
|
|
|
V(FunctionPrototypeSetter) \
|
|
|
|
V(ModuleNamespaceEntrySetter) \
|
|
|
|
V(ReconfigureToDataProperty)
|
2016-01-27 13:21:53 +00:00
|
|
|
|
2008-08-27 13:47:52 +00:00
|
|
|
// Accessors contains all predefined proxy accessors.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
class Accessors : public AllStatic {
|
|
|
|
public:
|
2017-10-27 09:06:44 +00:00
|
|
|
#define ACCESSOR_GETTER_DECLARATION(accessor_name, AccessorName) \
|
|
|
|
static void AccessorName##Getter( \
|
|
|
|
v8::Local<v8::Name> name, \
|
|
|
|
const v8::PropertyCallbackInfo<v8::Value>& info);
|
|
|
|
ACCESSOR_INFO_LIST(ACCESSOR_GETTER_DECLARATION)
|
|
|
|
#undef ACCESSOR_GETTER_DECLARATION
|
2014-04-15 13:25:17 +00:00
|
|
|
|
2017-10-27 09:06:44 +00:00
|
|
|
#define ACCESSOR_SETTER_DECLARATION(accessor_name) \
|
|
|
|
static void accessor_name( \
|
|
|
|
v8::Local<v8::Name> name, v8::Local<v8::Value> value, \
|
|
|
|
const v8::PropertyCallbackInfo<v8::Boolean>& info);
|
2016-01-27 13:21:53 +00:00
|
|
|
ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION)
|
|
|
|
#undef ACCESSOR_SETTER_DECLARATION
|
|
|
|
|
2016-10-07 19:37:04 +00:00
|
|
|
static void ModuleNamespaceEntryGetter(
|
|
|
|
v8::Local<v8::Name> name,
|
|
|
|
const v8::PropertyCallbackInfo<v8::Value>& info);
|
2017-10-27 09:06:44 +00:00
|
|
|
static Handle<AccessorInfo> MakeModuleNamespaceEntryInfo(Isolate* isolate,
|
|
|
|
Handle<String> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Accessor functions called directly from the runtime system.
|
2016-02-11 07:12:49 +00:00
|
|
|
static Handle<JSObject> FunctionGetArguments(Handle<JSFunction> object);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2013-09-25 08:19:35 +00:00
|
|
|
// Returns true for properties that are accessors to object fields.
|
2017-11-14 14:15:00 +00:00
|
|
|
// If true, the matching FieldIndex is returned through |field_index|.
|
2015-02-17 15:33:26 +00:00
|
|
|
static bool IsJSObjectFieldAccessor(Handle<Map> map, Handle<Name> name,
|
2017-11-14 14:15:00 +00:00
|
|
|
FieldIndex* field_index);
|
2013-09-25 08:19:35 +00:00
|
|
|
|
2016-10-26 08:59:24 +00:00
|
|
|
// Create an AccessorInfo. The setter is optional (can be nullptr).
|
|
|
|
//
|
|
|
|
// Note that the type of setter is AccessorNameBooleanSetterCallback instead
|
|
|
|
// of v8::AccessorNameSetterCallback. The difference is that the former can
|
|
|
|
// set a (boolean) return value. The setter should roughly follow the same
|
|
|
|
// conventions as many of the internal methods in objects.cc:
|
|
|
|
// - The return value is unset iff there was an exception.
|
|
|
|
// - If the ShouldThrow argument is true, the return value must not be false.
|
|
|
|
typedef void (*AccessorNameBooleanSetterCallback)(
|
|
|
|
Local<v8::Name> property, Local<v8::Value> value,
|
|
|
|
const PropertyCallbackInfo<v8::Boolean>& info);
|
|
|
|
|
2014-04-29 10:59:14 +00:00
|
|
|
static Handle<AccessorInfo> MakeAccessor(
|
2016-10-26 08:59:24 +00:00
|
|
|
Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter,
|
2017-10-26 15:18:09 +00:00
|
|
|
AccessorNameBooleanSetterCallback setter);
|
2017-10-27 09:06:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
#define ACCESSOR_INFO_DECLARATION(accessor_name, AccessorName) \
|
|
|
|
static Handle<AccessorInfo> Make##AccessorName##Info(Isolate* isolate);
|
|
|
|
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
|
|
|
|
#undef ACCESSOR_INFO_DECLARATION
|
|
|
|
|
|
|
|
friend class Heap;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#endif // V8_ACCESSORS_H_
|