| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2025-04-07 15:56:31 -04:00
										 |  |  |  * Copyright (c) 2022-2025, Tim Flynn <trflynn89@ladybird.org> | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/StringView.h>
 | 
					
						
							| 
									
										
										
										
											2022-07-11 11:28:10 -04:00
										 |  |  | #include <LibJS/Runtime/Completion.h>
 | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | #include <LibJS/Runtime/Intl/NumberFormat.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/Object.h>
 | 
					
						
							| 
									
										
										
										
											2024-06-23 09:14:27 -04:00
										 |  |  | #include <LibUnicode/PluralRules.h>
 | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Intl { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class PluralRules final : public NumberFormatBase { | 
					
						
							|  |  |  |     JS_OBJECT(PluralRules, NumberFormatBase); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC_DECLARE_ALLOCATOR(PluralRules); | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual ~PluralRules() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-07 15:56:31 -04:00
										 |  |  |     virtual ReadonlySpan<StringView> relevant_extension_keys() const override; | 
					
						
							|  |  |  |     virtual ReadonlySpan<ResolutionOptionDescriptor> resolution_option_descriptors(VM&) const override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-23 09:14:27 -04:00
										 |  |  |     Unicode::PluralForm type() const { return m_type; } | 
					
						
							|  |  |  |     StringView type_string() const { return Unicode::plural_form_to_string(m_type); } | 
					
						
							|  |  |  |     void set_type(StringView type) { m_type = Unicode::plural_form_from_string(type); } | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-08-28 23:51:28 +02:00
										 |  |  |     explicit PluralRules(Object& prototype); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-23 09:14:27 -04:00
										 |  |  |     Unicode::PluralForm m_type { Unicode::PluralForm::Cardinal }; // [[Type]]
 | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-23 09:14:27 -04:00
										 |  |  | Unicode::PluralCategory resolve_plural(PluralRules const&, Value number); | 
					
						
							|  |  |  | ThrowCompletionOr<Unicode::PluralCategory> resolve_plural_range(VM&, PluralRules const&, Value start, Value end); | 
					
						
							| 
									
										
										
										
											2022-07-07 10:01:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-28 12:56:04 -05:00
										 |  |  | } |