
The main motivation behind this is to remove JS specifics of the Realm from the implementation of the Heap. As a side effect of this change, this is a bit nicer to read than the previous approach, and in my opinion, also makes it a little more clear that this method is specific to a JavaScript Realm.
27 lines
667 B
C++
27 lines
667 B
C++
/*
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Utf8View.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
#include <LibJS/Runtime/StringIterator.h>
|
|
|
|
namespace JS {
|
|
|
|
JS_DEFINE_ALLOCATOR(StringIterator);
|
|
|
|
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String string)
|
|
{
|
|
return realm.create<StringIterator>(move(string), realm.intrinsics().string_iterator_prototype());
|
|
}
|
|
|
|
StringIterator::StringIterator(String string, Object& prototype)
|
|
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
|
, m_string(move(string))
|
|
, m_iterator(Utf8View(m_string).begin())
|
|
{
|
|
}
|
|
|
|
}
|