From 3200ff5f4f424b5938d9e7e2a411da5e6963ad1c Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Fri, 27 Nov 2020 17:14:50 +0330 Subject: [PATCH] LibJS+js: Rename RegExp.{content => pattern} The spec talks about it as 'pattern', so let's use that instead. --- Libraries/LibJS/Runtime/RegExpConstructor.cpp | 4 ++-- Libraries/LibJS/Runtime/RegExpObject.cpp | 8 ++++---- Libraries/LibJS/Runtime/RegExpObject.h | 8 ++++---- Libraries/LibJS/Runtime/RegExpPrototype.cpp | 2 +- Userland/js.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Libraries/LibJS/Runtime/RegExpConstructor.cpp index 6e96637d38..a416ee54e4 100644 --- a/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -58,13 +58,13 @@ Value RegExpConstructor::construct(Function&) auto& vm = this->vm(); if (!vm.argument_count()) return RegExpObject::create(global_object(), "(?:)", ""); - auto contents = vm.argument(0).to_string(global_object()); + auto pattern = vm.argument(0).to_string(global_object()); if (vm.exception()) return {}; auto flags = vm.argument_count() > 1 ? vm.argument(1).to_string(global_object()) : ""; if (vm.exception()) return {}; - return RegExpObject::create(global_object(), contents, flags); + return RegExpObject::create(global_object(), pattern, flags); } } diff --git a/Libraries/LibJS/Runtime/RegExpObject.cpp b/Libraries/LibJS/Runtime/RegExpObject.cpp index 4aab7dff13..6959034f52 100644 --- a/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -33,14 +33,14 @@ namespace JS { -RegExpObject* RegExpObject::create(GlobalObject& global_object, String content, String flags) +RegExpObject* RegExpObject::create(GlobalObject& global_object, String pattern, String flags) { - return global_object.heap().allocate(global_object, content, flags, *global_object.regexp_prototype()); + return global_object.heap().allocate(global_object, pattern, flags, *global_object.regexp_prototype()); } -RegExpObject::RegExpObject(String content, String flags, Object& prototype) +RegExpObject::RegExpObject(String pattern, String flags, Object& prototype) : Object(prototype) - , m_content(content) + , m_pattern(pattern) , m_flags(flags) { } diff --git a/Libraries/LibJS/Runtime/RegExpObject.h b/Libraries/LibJS/Runtime/RegExpObject.h index e15694bf5a..341b8acf0a 100644 --- a/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Libraries/LibJS/Runtime/RegExpObject.h @@ -35,18 +35,18 @@ class RegExpObject : public Object { JS_OBJECT(RegExpObject, Object); public: - static RegExpObject* create(GlobalObject&, String content, String flags); + static RegExpObject* create(GlobalObject&, String pattern, String flags); - RegExpObject(String content, String flags, Object& prototype); + RegExpObject(String pattern, String flags, Object& prototype); virtual ~RegExpObject() override; - const String& content() const { return m_content; } + const String& pattern() const { return m_pattern; } const String& flags() const { return m_flags; } private: virtual bool is_regexp_object() const override { return true; } - String m_content; + String m_pattern; String m_flags; }; diff --git a/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Libraries/LibJS/Runtime/RegExpPrototype.cpp index 7be563acf5..83f7c9fb8b 100644 --- a/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string) auto* regexp_object = regexp_object_from(vm, global_object); if (!regexp_object) return {}; - return js_string(vm, String::formatted("/{}/{}", regexp_object->content(), regexp_object->flags())); + return js_string(vm, String::formatted("/{}/{}", regexp_object->pattern(), regexp_object->flags())); } } diff --git a/Userland/js.cpp b/Userland/js.cpp index 849ebf0580..6163ea91f5 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -235,7 +235,7 @@ static void print_error(const JS::Object& object, HashTable&) static void print_regexp(const JS::Object& object, HashTable&) { auto& regexp = static_cast(object); - out("\033[34;1m/{}/{}\033[0m", regexp.content(), regexp.flags()); + out("\033[34;1m/{}/{}\033[0m", regexp.pattern(), regexp.flags()); } static void print_value(JS::Value value, HashTable& seen_objects)