You've already forked godot
							
							
				mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-04 12:00:25 +00:00 
			
		
		
		
	Remove dependency of variant.h in print_string.h
Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com> Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
This commit is contained in:
		@@ -341,6 +341,14 @@ bool is_print_verbose_enabled() {
 | 
			
		||||
	return OS::get_singleton()->is_stdout_verbose();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
String stringify_variants(const Variant &p_var) {
 | 
			
		||||
	return p_var.operator String();
 | 
			
		||||
String stringify_variants(const Span<Variant> &p_vars) {
 | 
			
		||||
	if (p_vars.is_empty()) {
 | 
			
		||||
		return String();
 | 
			
		||||
	}
 | 
			
		||||
	String result = String(p_vars[0]);
 | 
			
		||||
	for (const Variant &v : Span(p_vars.ptr() + 1, p_vars.size() - 1)) {
 | 
			
		||||
		result += ' ';
 | 
			
		||||
		result += v.operator String();
 | 
			
		||||
	}
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,9 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "core/variant/variant.h"
 | 
			
		||||
#include "core/string/ustring.h"
 | 
			
		||||
 | 
			
		||||
class Variant;
 | 
			
		||||
 | 
			
		||||
extern void (*_print_func)(String);
 | 
			
		||||
 | 
			
		||||
@@ -45,12 +47,7 @@ struct PrintHandlerList {
 | 
			
		||||
	PrintHandlerList() {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
String stringify_variants(const Variant &p_var);
 | 
			
		||||
 | 
			
		||||
template <typename... Args>
 | 
			
		||||
String stringify_variants(const Variant &p_var, Args... p_args) {
 | 
			
		||||
	return p_var.operator String() + " " + stringify_variants(p_args...);
 | 
			
		||||
}
 | 
			
		||||
String stringify_variants(const Span<Variant> &p_vars);
 | 
			
		||||
 | 
			
		||||
void add_print_handler(PrintHandlerList *p_handler);
 | 
			
		||||
void remove_print_handler(const PrintHandlerList *p_handler);
 | 
			
		||||
@@ -69,20 +66,14 @@ extern bool is_print_verbose_enabled();
 | 
			
		||||
		}                                 \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
inline void print_line(const Variant &v) {
 | 
			
		||||
	__print_line(stringify_variants(v));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline void print_line_rich(const Variant &v) {
 | 
			
		||||
	__print_line_rich(stringify_variants(v));
 | 
			
		||||
template <typename... Args>
 | 
			
		||||
void print_line(Args... p_args) {
 | 
			
		||||
	Variant variants[sizeof...(p_args)] = { p_args... };
 | 
			
		||||
	__print_line(stringify_variants(Span(variants)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename... Args>
 | 
			
		||||
void print_line(const Variant &p_var, Args... p_args) {
 | 
			
		||||
	__print_line(stringify_variants(p_var, p_args...));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename... Args>
 | 
			
		||||
void print_line_rich(const Variant &p_var, Args... p_args) {
 | 
			
		||||
	__print_line_rich(stringify_variants(p_var, p_args...));
 | 
			
		||||
void print_line_rich(Args... p_args) {
 | 
			
		||||
	Variant variants[sizeof...(p_args)] = { p_args... };
 | 
			
		||||
	__print_line_rich(stringify_variants(Span(variants)));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,8 +34,8 @@
 | 
			
		||||
#include "core/os/mutex.h"
 | 
			
		||||
#include "core/string/print_string.h"
 | 
			
		||||
#include "core/templates/local_vector.h"
 | 
			
		||||
#include "core/templates/rid.h"
 | 
			
		||||
#include "core/templates/safe_refcount.h"
 | 
			
		||||
#include "core/variant/variant.h"
 | 
			
		||||
 | 
			
		||||
#include <cstdio>
 | 
			
		||||
#include <typeinfo> // IWYU pragma: keep // Used in macro.
 | 
			
		||||
 
 | 
			
		||||
@@ -35,8 +35,8 @@
 | 
			
		||||
#include "shapes/jolt_custom_ray_shape.h"
 | 
			
		||||
#include "shapes/jolt_custom_user_data_shape.h"
 | 
			
		||||
 | 
			
		||||
#include "core/os/memory.h"
 | 
			
		||||
#include "core/string/print_string.h"
 | 
			
		||||
#include "core/variant/variant.h"
 | 
			
		||||
 | 
			
		||||
#include "Jolt/Jolt.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@
 | 
			
		||||
#include "detect_prime_egl.h"
 | 
			
		||||
 | 
			
		||||
#include "core/string/print_string.h"
 | 
			
		||||
#include "core/string/ustring.h"
 | 
			
		||||
#include "core/variant/variant.h"
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@
 | 
			
		||||
#include "detect_prime_x11.h"
 | 
			
		||||
 | 
			
		||||
#include "core/string/print_string.h"
 | 
			
		||||
#include "core/string/ustring.h"
 | 
			
		||||
#include "core/variant/variant.h"
 | 
			
		||||
 | 
			
		||||
#include "thirdparty/glad/glad/gl.h"
 | 
			
		||||
#include "thirdparty/glad/glad/glx.h"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user