mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 01:47:36 +00:00
LibJS: Renamed Object::GetOwnPropertyReturnMode to Object::PropertyKind
This enum will be used by iterators, so it makes sense to use a more general name.
This commit is contained in:
parent
e650be98a1
commit
51bfc6c6b3
5 changed files with 14 additions and 14 deletions
|
@ -383,7 +383,7 @@ Value ForInStatement::execute(Interpreter& interpreter, GlobalObject& global_obj
|
||||||
return {};
|
return {};
|
||||||
auto* object = rhs_result.to_object(interpreter, global_object);
|
auto* object = rhs_result.to_object(interpreter, global_object);
|
||||||
while (object) {
|
while (object) {
|
||||||
auto property_names = object->get_own_properties(*object, Object::GetOwnPropertyReturnMode::Key, true);
|
auto property_names = object->get_own_properties(*object, Object::PropertyKind::Key, true);
|
||||||
for (auto& property_name : property_names.as_object().indexed_properties()) {
|
for (auto& property_name : property_names.as_object().indexed_properties()) {
|
||||||
interpreter.set_variable(variable_name, property_name.value_and_attributes(object).value, global_object);
|
interpreter.set_variable(variable_name, property_name.value_and_attributes(object).value, global_object);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
|
|
|
@ -179,7 +179,7 @@ Value Object::get_own_property(const Object& this_object, PropertyName property_
|
||||||
return value_here;
|
return value_here;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value Object::get_own_properties(const Object& this_object, GetOwnPropertyReturnMode kind, bool only_enumerable_properties, GetOwnPropertyReturnType return_type) const
|
Value Object::get_own_properties(const Object& this_object, PropertyKind kind, bool only_enumerable_properties, GetOwnPropertyReturnType return_type) const
|
||||||
{
|
{
|
||||||
auto* properties_array = Array::create(global_object());
|
auto* properties_array = Array::create(global_object());
|
||||||
|
|
||||||
|
@ -188,9 +188,9 @@ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyReturn
|
||||||
auto str = static_cast<const StringObject&>(this_object).primitive_string().string();
|
auto str = static_cast<const StringObject&>(this_object).primitive_string().string();
|
||||||
|
|
||||||
for (size_t i = 0; i < str.length(); ++i) {
|
for (size_t i = 0; i < str.length(); ++i) {
|
||||||
if (kind == GetOwnPropertyReturnMode::Key) {
|
if (kind == PropertyKind::Key) {
|
||||||
properties_array->define_property(i, js_string(interpreter(), String::number(i)));
|
properties_array->define_property(i, js_string(interpreter(), String::number(i)));
|
||||||
} else if (kind == GetOwnPropertyReturnMode::Value) {
|
} else if (kind == PropertyKind::Value) {
|
||||||
properties_array->define_property(i, js_string(interpreter(), String::format("%c", str[i])));
|
properties_array->define_property(i, js_string(interpreter(), String::format("%c", str[i])));
|
||||||
} else {
|
} else {
|
||||||
auto* entry_array = Array::create(global_object());
|
auto* entry_array = Array::create(global_object());
|
||||||
|
@ -211,9 +211,9 @@ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyReturn
|
||||||
if (only_enumerable_properties && !value_and_attributes.attributes.is_enumerable())
|
if (only_enumerable_properties && !value_and_attributes.attributes.is_enumerable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (kind == GetOwnPropertyReturnMode::Key) {
|
if (kind == PropertyKind::Key) {
|
||||||
properties_array->define_property(property_index, js_string(interpreter(), String::number(entry.index())));
|
properties_array->define_property(property_index, js_string(interpreter(), String::number(entry.index())));
|
||||||
} else if (kind == GetOwnPropertyReturnMode::Value) {
|
} else if (kind == PropertyKind::Value) {
|
||||||
properties_array->define_property(property_index, value_and_attributes.value);
|
properties_array->define_property(property_index, value_and_attributes.value);
|
||||||
} else {
|
} else {
|
||||||
auto* entry_array = Array::create(global_object());
|
auto* entry_array = Array::create(global_object());
|
||||||
|
@ -236,9 +236,9 @@ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyReturn
|
||||||
if (return_type == GetOwnPropertyReturnType::SymbolOnly && it.key.is_string())
|
if (return_type == GetOwnPropertyReturnType::SymbolOnly && it.key.is_string())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (kind == GetOwnPropertyReturnMode::Key) {
|
if (kind == PropertyKind::Key) {
|
||||||
properties_array->define_property(property_index, it.key.to_value(interpreter()));
|
properties_array->define_property(property_index, it.key.to_value(interpreter()));
|
||||||
} else if (kind == GetOwnPropertyReturnMode::Value) {
|
} else if (kind == PropertyKind::Value) {
|
||||||
properties_array->define_property(property_index, this_object.get(it.key));
|
properties_array->define_property(property_index, this_object.get(it.key));
|
||||||
} else {
|
} else {
|
||||||
auto* entry_array = Array::create(global_object());
|
auto* entry_array = Array::create(global_object());
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
virtual bool inherits(const StringView& class_name) const { return class_name == this->class_name(); }
|
virtual bool inherits(const StringView& class_name) const { return class_name == this->class_name(); }
|
||||||
|
|
||||||
enum class GetOwnPropertyReturnMode {
|
enum class PropertyKind {
|
||||||
Key,
|
Key,
|
||||||
Value,
|
Value,
|
||||||
KeyAndValue,
|
KeyAndValue,
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
virtual bool put(const PropertyName&, Value, Value receiver = {});
|
virtual bool put(const PropertyName&, Value, Value receiver = {});
|
||||||
|
|
||||||
Value get_own_property(const Object& this_object, PropertyName, Value receiver) const;
|
Value get_own_property(const Object& this_object, PropertyName, Value receiver) const;
|
||||||
Value get_own_properties(const Object& this_object, GetOwnPropertyReturnMode, bool only_enumerable_properties = false, GetOwnPropertyReturnType = GetOwnPropertyReturnType::StringOnly) const;
|
Value get_own_properties(const Object& this_object, PropertyKind, bool only_enumerable_properties = false, GetOwnPropertyReturnType = GetOwnPropertyReturnType::StringOnly) const;
|
||||||
virtual Optional<PropertyDescriptor> get_own_property_descriptor(const PropertyName&) const;
|
virtual Optional<PropertyDescriptor> get_own_property_descriptor(const PropertyName&) const;
|
||||||
Value get_own_property_descriptor_object(const PropertyName&) const;
|
Value get_own_property_descriptor_object(const PropertyName&) const;
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::keys)
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return obj_arg->get_own_properties(*obj_arg, GetOwnPropertyReturnMode::Key, true);
|
return obj_arg->get_own_properties(*obj_arg, PropertyKind::Key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
|
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
|
||||||
|
@ -210,7 +210,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return obj_arg->get_own_properties(*obj_arg, GetOwnPropertyReturnMode::Value, true);
|
return obj_arg->get_own_properties(*obj_arg, PropertyKind::Value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::entries)
|
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::entries)
|
||||||
|
@ -222,7 +222,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::entries)
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return obj_arg->get_own_properties(*obj_arg, GetOwnPropertyReturnMode::KeyAndValue, true);
|
return obj_arg->get_own_properties(*obj_arg, PropertyKind::KeyAndValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::own_keys)
|
||||||
auto* target = get_target_object_from(interpreter, "ownKeys");
|
auto* target = get_target_object_from(interpreter, "ownKeys");
|
||||||
if (!target)
|
if (!target)
|
||||||
return {};
|
return {};
|
||||||
return target->get_own_properties(*target, GetOwnPropertyReturnMode::Key);
|
return target->get_own_properties(*target, PropertyKind::Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ReflectObject::prevent_extensions)
|
JS_DEFINE_NATIVE_FUNCTION(ReflectObject::prevent_extensions)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue