mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:02:45 +00:00 
			
		
		
		
	LibJS: Support array holes, encoded as empty JS::Value
This patch adds a new kind of JS::Value, the empty value.
It's what you get when you do JSValue() (or most commonly, {} in C++.)
An empty Value signifies the absence of a value, and should never be
visible to JavaScript itself. As of right now, it's used for array
holes and as a return value when an exception has been thrown and we
just want to unwind.
This patch is a bit of a mess as I had to fix a whole bunch of code
that was relying on JSValue() being undefined, etc.
			
			
This commit is contained in:
		
							parent
							
								
									5495f06af5
								
							
						
					
					
						commit
						bdffc9e7fb
					
				
					 9 changed files with 102 additions and 35 deletions
				
			
		|  | @ -78,7 +78,7 @@ JS::Value WindowObject::alert(JS::Interpreter& interpreter) | |||
|     if (arguments.size() < 1) | ||||
|         return {}; | ||||
|     impl->alert(arguments[0].to_string()); | ||||
|     return {}; | ||||
|     return JS::js_undefined(); | ||||
| } | ||||
| 
 | ||||
| JS::Value WindowObject::set_interval(JS::Interpreter& interpreter) | ||||
|  | @ -95,7 +95,7 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter) | |||
|     if (!callback_object->is_function()) | ||||
|         return interpreter.throw_exception<JS::Error>("TypeError", "Not a function"); | ||||
|     impl->set_interval(*static_cast<JS::Function*>(callback_object), arguments[1].to_i32()); | ||||
|     return {}; | ||||
|     return JS::js_undefined(); | ||||
| } | ||||
| 
 | ||||
| JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter) | ||||
|  | @ -117,7 +117,7 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter) | |||
|         interval = arguments[1].to_i32(); | ||||
| 
 | ||||
|     impl->set_timeout(*static_cast<JS::Function*>(callback_object), interval); | ||||
|     return {}; | ||||
|     return JS::js_undefined(); | ||||
| } | ||||
| 
 | ||||
| JS::Value WindowObject::request_animation_frame(JS::Interpreter& interpreter) | ||||
|  | @ -145,7 +145,7 @@ JS::Value WindowObject::cancel_animation_frame(JS::Interpreter& interpreter) | |||
|     if (arguments.size() < 1) | ||||
|         return {}; | ||||
|     impl->cancel_animation_frame(arguments[0].to_i32()); | ||||
|     return {}; | ||||
|     return JS::js_undefined(); | ||||
| } | ||||
| 
 | ||||
| JS::Value WindowObject::document_getter(JS::Interpreter& interpreter) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling