ladybird/Userland/Libraries/LibJS/Runtime/StringIterator.cpp

26 lines
645 B
C++
Raw Normal View History

2020-07-12 03:23:01 +00:00
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
2020-07-12 03:23:01 +00:00
*
* SPDX-License-Identifier: BSD-2-Clause
2020-07-12 03:23:01 +00:00
*/
#include <AK/Utf8View.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/StringIterator.h>
2020-07-12 03:23:01 +00:00
namespace JS {
2023-01-15 04:17:49 +00:00
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String string)
2020-07-12 03:23:01 +00:00
{
return realm.heap().allocate<StringIterator>(realm, move(string), realm.intrinsics().string_iterator_prototype());
2020-07-12 03:23:01 +00:00
}
2023-01-15 04:17:49 +00:00
StringIterator::StringIterator(String string, Object& prototype)
: Object(ConstructWithPrototypeTag::Tag, prototype)
2020-07-12 03:23:01 +00:00
, m_string(move(string))
, m_iterator(Utf8View(m_string).begin())
{
}
2020-07-12 03:23:01 +00:00
}