mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:52:44 +00:00 
			
		
		
		
	LibJS: Convert internal_delete() to ThrowCompletionOr
This commit is contained in:
		
							parent
							
								
									e5409c6ead
								
							
						
					
					
						commit
						fbfb0bb908
					
				
					 16 changed files with 55 additions and 65 deletions
				
			
		|  | @ -1418,7 +1418,7 @@ public: | |||
|     virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyName const&) const override; | ||||
|     virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyName const&, JS::Value, JS::Value) override; | ||||
|     virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyName const&, JS::PropertyDescriptor const&) override; | ||||
|     virtual bool internal_delete(JS::PropertyName const&) override; | ||||
|     virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyName const&) override; | ||||
|     virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override; | ||||
|     virtual JS::MarkedValueList internal_own_property_keys() const override; | ||||
| )~~~"); | ||||
|  | @ -2178,7 +2178,7 @@ JS::ThrowCompletionOr<bool> @class_name@::internal_define_own_property(JS::Prope | |||
| 
 | ||||
|         // 3.9.4. [[Delete]], https://heycam.github.io/webidl/#legacy-platform-object-delete
 | ||||
|         scoped_generator.append(R"~~~( | ||||
| bool @class_name@::internal_delete(JS::PropertyName const& property_name) | ||||
| JS::ThrowCompletionOr<bool> @class_name@::internal_delete(JS::PropertyName const& property_name) | ||||
| { | ||||
|     [[maybe_unused]] auto& vm = this->vm(); | ||||
|     auto& global_object = this->global_object(); | ||||
|  | @ -2228,8 +2228,9 @@ bool @class_name@::internal_delete(JS::PropertyName const& property_name) | |||
|                     scoped_generator.append(R"~~~( | ||||
|         // 1. Perform the steps listed in the interface description to delete an existing named property with P as the name.
 | ||||
|         auto result = throw_dom_exception_if_needed(vm, global_object, [&] { return impl().delete_existing_named_property(property_name_string); }); | ||||
|         // FIXME: Make this nicer for ThrowCompletionOr.
 | ||||
|         if (should_return_empty(result)) | ||||
|             return {}; | ||||
|             return JS::throw_completion(vm.exception()->value()); | ||||
| 
 | ||||
|         bool succeeded = result.release_value(); | ||||
| 
 | ||||
|  | @ -2245,8 +2246,9 @@ bool @class_name@::internal_delete(JS::PropertyName const& property_name) | |||
|                     function_scoped_generator.append(R"~~~( | ||||
|         // 1. Perform method steps of operation with O as this and « P » as the argument values.
 | ||||
|         auto result = throw_dom_exception_if_needed(vm, global_object, [&] { return impl().@function.cpp_name@(property_name_string); }); | ||||
|         // FIXME: Make this nicer for ThrowCompletionOr.
 | ||||
|         if (should_return_empty(result)) | ||||
|             return {}; | ||||
|             return JS::throw_completion(vm.exception()->value()); | ||||
| )~~~"); | ||||
| 
 | ||||
|                     // 2. If operation was declared with a return type of boolean and the steps returned false, then return false.
 | ||||
|  | @ -2272,7 +2274,7 @@ bool @class_name@::internal_delete(JS::PropertyName const& property_name) | |||
| 
 | ||||
|         scoped_generator.append(R"~~~( | ||||
|     // 3. If O has an own property with name P, then:
 | ||||
|     auto own_property_named_p_descriptor = TRY_OR_DISCARD(Object::internal_get_own_property(property_name)); | ||||
|     auto own_property_named_p_descriptor = TRY(Object::internal_get_own_property(property_name)); | ||||
| 
 | ||||
|     if (own_property_named_p_descriptor.has_value()) { | ||||
|         // 1. If the property is not configurable, then return false.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh