File tree Expand file tree Collapse file tree 5 files changed +6
-21
lines changed
Meta/Lagom/Tools/CodeGenerators Expand file tree Collapse file tree 5 files changed +6
-21
lines changed Original file line number Diff line number Diff line change @@ -241,14 +241,6 @@ bool JsonObject::has_object(StringView key) const
241
241
return value.has_value () && value->is_object ();
242
242
}
243
243
244
- #ifndef KERNEL
245
- bool JsonObject::has_double (StringView key) const
246
- {
247
- auto value = get (key);
248
- return value.has_value () && value->is_double ();
249
- }
250
- #endif
251
-
252
244
void JsonObject::set (ByteString const & key, JsonValue value)
253
245
{
254
246
m_members.set (key, move (value));
Original file line number Diff line number Diff line change @@ -51,9 +51,6 @@ class JsonObject {
51
51
[[nodiscard]] bool has_number (StringView key) const ;
52
52
[[nodiscard]] bool has_array (StringView key) const ;
53
53
[[nodiscard]] bool has_object (StringView key) const ;
54
- #ifndef KERNEL
55
- [[nodiscard]] bool has_double (StringView key) const ;
56
- #endif
57
54
58
55
Optional<JsonValue const &> get (StringView key) const ;
59
56
Original file line number Diff line number Diff line change @@ -182,11 +182,6 @@ class JsonValue {
182
182
bool is_null () const { return m_type == Type::Null; }
183
183
bool is_bool () const { return m_type == Type::Bool; }
184
184
bool is_string () const { return m_type == Type::String; }
185
- bool is_i32 () const { return m_type == Type::Int32; }
186
- bool is_u32 () const { return m_type == Type::UnsignedInt32; }
187
- bool is_i64 () const { return m_type == Type::Int64; }
188
- bool is_u64 () const { return m_type == Type::UnsignedInt64; }
189
- bool is_double () const { return m_type == Type::Double; }
190
185
bool is_array () const { return m_type == Type::Array; }
191
186
bool is_object () const { return m_type == Type::Object; }
192
187
bool is_number () const
@@ -206,7 +201,7 @@ class JsonValue {
206
201
template <typename T>
207
202
T to_number (T default_value = 0 ) const
208
203
{
209
- if (is_double () )
204
+ if (type () == Type::Double )
210
205
return (T)m_value.as_double ;
211
206
if (type () == Type::Int32)
212
207
return (T)m_value.as_i32 ;
Original file line number Diff line number Diff line change @@ -235,7 +235,8 @@ static ErrorOr<String> generate_initializer_for(Optional<StringView> property_na
235
235
HANDLE_TYPE (i64 , is_integer<i64 >)
236
236
HANDLE_TYPE (u64 , is_integer<u64 >)
237
237
HANDLE_TYPE (bool , is_bool)
238
- HANDLE_TYPE (double , is_double)
238
+ // FIXME: Do we want to allow precision loss when C++ compiler parses these doubles?
239
+ HANDLE_TYPE (double , is_number)
239
240
return Error::from_string_view (" Inconsistent contained type in JSON array" sv);
240
241
#undef HANDLE_TYPE
241
242
}
Original file line number Diff line number Diff line change @@ -764,11 +764,11 @@ size_t property_maximum_value_count(PropertyID property_id)
764
764
properties.for_each_member ([&](auto & name, auto & value) {
765
765
VERIFY (value.is_object ());
766
766
if (value.as_object ().has (" max-values" sv)) {
767
- auto max_values = value.as_object ().get (" max-values" sv);
768
- VERIFY (max_values.has_value () && max_values-> is_number () && !max_values-> is_double ());
767
+ JsonValue max_values = value.as_object ().get (" max-values" sv). release_value ( );
768
+ VERIFY (max_values.is_integer < size_t > ());
769
769
auto property_generator = generator.fork ();
770
770
property_generator.set (" name:titlecase" , title_casify (name));
771
- property_generator.set (" max_values" , max_values-> template serialized <StringBuilder>( ));
771
+ property_generator.set (" max_values" , MUST ( String::formatted ( " {} " , max_values. as_integer < size_t >()) ));
772
772
property_generator.append (R"~~~(
773
773
case PropertyID::@name:titlecase@:
774
774
return @max_values@;
You can’t perform that action at this time.
0 commit comments