ladybird/Libraries/LibJS/Runtime/StringIterator.cpp

28 lines
662 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 {
GC_DEFINE_ALLOCATOR(StringIterator);
GC::Ref<StringIterator> StringIterator::create(Realm& realm, String string)
2020-07-12 03:23:01 +00:00
{
return realm.create<StringIterator>(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
}