mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:22:45 +00:00 
			
		
		
		
	LibWeb: Add support for optional double arguments with no default value
This is implemented by emitting AK::Optional, similar to optional boolean arguments.
This commit is contained in:
		
							parent
							
								
									0072581693
								
							
						
					
					
						commit
						a257ef0f35
					
				
					 1 changed files with 30 additions and 2 deletions
				
			
		|  | @ -599,11 +599,39 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter | |||
|     auto& @cpp_name@ = static_cast<@parameter.type.name@Wrapper*>(@cpp_name@_object)->impl(); | ||||
| )~~~"); | ||||
|     } else if (parameter.type.name == "double") { | ||||
|         scoped_generator.append(R"~~~( | ||||
|     auto @cpp_name@ = @js_name@@js_suffix@.to_double(global_object); | ||||
|         if (!optional) { | ||||
|             scoped_generator.append(R"~~~( | ||||
|     double @cpp_name@ = @js_name@@js_suffix@.to_double(global_object); | ||||
|     if (vm.exception()) | ||||
|         @return_statement@ | ||||
| )~~~"); | ||||
|         } else { | ||||
|             if (!optional_default_value.is_null()) { | ||||
|                 scoped_generator.append(R"~~~( | ||||
|     double @cpp_name@; | ||||
| )~~~"); | ||||
|             } else { | ||||
|                 scoped_generator.append(R"~~~( | ||||
|     Optional<double> @cpp_name@; | ||||
| )~~~"); | ||||
|             } | ||||
|             scoped_generator.append(R"~~~( | ||||
|     if (!@js_name@@js_suffix@.is_undefined()) { | ||||
|         @cpp_name@ = @js_name@@js_suffix@.to_double(global_object); | ||||
|         if (vm.exception()) | ||||
|             @return_statement@ | ||||
|     } | ||||
| )~~~"); | ||||
|             if (!optional_default_value.is_null()) { | ||||
|                 scoped_generator.append(R"~~~( | ||||
|     else | ||||
|         @cpp_name@ = @parameter.optional_default_value@; | ||||
| )~~~"); | ||||
|             } else { | ||||
|                 scoped_generator.append(R"~~~( | ||||
| )~~~"); | ||||
|             } | ||||
|         } | ||||
|     } else if (parameter.type.name == "boolean") { | ||||
|         if (!optional) { | ||||
|             scoped_generator.append(R"~~~( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz