1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:57:44 +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:
Matthew Olsson 2020-07-09 14:42:30 -07:00 committed by Andreas Kling
parent e650be98a1
commit 51bfc6c6b3
5 changed files with 14 additions and 14 deletions

View file

@ -383,7 +383,7 @@ Value ForInStatement::execute(Interpreter& interpreter, GlobalObject& global_obj
return {};
auto* object = rhs_result.to_object(interpreter, global_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()) {
interpreter.set_variable(variable_name, property_name.value_and_attributes(object).value, global_object);
if (interpreter.exception())

View file

@ -179,7 +179,7 @@ Value Object::get_own_property(const Object& this_object, PropertyName property_
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());
@ -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();
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)));
} else if (kind == GetOwnPropertyReturnMode::Value) {
} else if (kind == PropertyKind::Value) {
properties_array->define_property(i, js_string(interpreter(), String::format("%c", str[i])));
} else {
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())
continue;
if (kind == GetOwnPropertyReturnMode::Key) {
if (kind == PropertyKind::Key) {
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);
} else {
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())
continue;
if (kind == GetOwnPropertyReturnMode::Key) {
if (kind == PropertyKind::Key) {
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));
} else {
auto* entry_array = Array::create(global_object());

View file

@ -68,7 +68,7 @@ public:
virtual bool inherits(const StringView& class_name) const { return class_name == this->class_name(); }
enum class GetOwnPropertyReturnMode {
enum class PropertyKind {
Key,
Value,
KeyAndValue,
@ -97,7 +97,7 @@ public:
virtual bool put(const PropertyName&, Value, Value receiver = {});
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;
Value get_own_property_descriptor_object(const PropertyName&) const;

View file

@ -198,7 +198,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::keys)
if (interpreter.exception())
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)
@ -210,7 +210,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
if (interpreter.exception())
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)
@ -222,7 +222,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::entries)
if (interpreter.exception())
return {};
return obj_arg->get_own_properties(*obj_arg, GetOwnPropertyReturnMode::KeyAndValue, true);
return obj_arg->get_own_properties(*obj_arg, PropertyKind::KeyAndValue, true);
}
}

View file

@ -233,7 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::own_keys)
auto* target = get_target_object_from(interpreter, "ownKeys");
if (!target)
return {};
return target->get_own_properties(*target, GetOwnPropertyReturnMode::Key);
return target->get_own_properties(*target, PropertyKind::Key);
}
JS_DEFINE_NATIVE_FUNCTION(ReflectObject::prevent_extensions)