mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:12:43 +00:00 
			
		
		
		
	 db2ba5f1d9
			
		
	
	
		db2ba5f1d9
		
	
	
	
	
		
			
			These are currently initialized in a [[gnu::constructor]], which has a weird initialization order. These constructors are invoked before main() and, incidentally, before any user-defined default constructors of the static strings they are initializing. This will become an issue when these strings are ported to FlyString, which has a user-defined default constructor. In that scenario, when the FlyString constructor is executed after the [[gnu::constructor]], the strings will be "reset" to the empty string. Instead of relying on a non-standard compiler extension here, let's just initialize these strings explicitly during main-thread VM creation, as this now happens in WebContent's main().
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			547 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			547 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/XHR/EventNames.h>
 | |
| 
 | |
| namespace Web::XHR::EventNames {
 | |
| 
 | |
| #define __ENUMERATE_XHR_EVENT(name) DeprecatedFlyString name;
 | |
| ENUMERATE_XHR_EVENTS
 | |
| #undef __ENUMERATE_XHR_EVENT
 | |
| 
 | |
| ErrorOr<void> initialize_strings()
 | |
| {
 | |
|     static bool s_initialized = false;
 | |
|     VERIFY(!s_initialized);
 | |
| 
 | |
| #define __ENUMERATE_XHR_EVENT(name) \
 | |
|     name = #name;
 | |
|     ENUMERATE_XHR_EVENTS
 | |
| #undef __ENUMERATE_XHR_EVENT
 | |
| 
 | |
|     s_initialized = true;
 | |
|     return {};
 | |
| }
 | |
| 
 | |
| }
 |