2020-07-12 03:23:01 +00:00
|
|
|
/*
|
2021-04-22 23:53:07 +00:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2020-07-12 03:23:01 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +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>
|
2020-09-18 07:49:51 +00:00
|
|
|
#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
|
|
|
{
|
2023-08-13 11:05:26 +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)
|
2022-12-14 11:17:58 +00:00
|
|
|
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
2020-07-12 03:23:01 +00:00
|
|
|
, m_string(move(string))
|
|
|
|
, m_iterator(Utf8View(m_string).begin())
|
|
|
|
{
|
|
|
|
}
|
2022-04-17 20:59:52 +00:00
|
|
|
|
2020-07-12 03:23:01 +00:00
|
|
|
}
|