Godot Engine – Multi-platform 2D and 3D game engine
Core: Migrate regex code to core, remove module
Thaddeus Crews77ab4dcdf639
diff --git a/SConstruct b/SConstructindex b44cd914daf..bf4b78832b6 100644--- a/SConstruct+++ b/SConstruct@@ -1148,7 +1148,7 @@ methods.sort_module_list(env)if env.editor_build:# Add editor-specific dependencies to the dependency graph.- env.module_add_dependencies("editor", ["freetype", "regex", "svg"])+ env.module_add_dependencies("editor", ["freetype", "svg"])# And check if they are met.if not env.module_check_dependencies("editor"):diff --git a/core/SCsub b/core/SCsubindex 0bbcfe75c51..a77a2a5ed1b 100644--- a/core/SCsub+++ b/core/SCsub@@ -61,6 +61,53 @@ if env["brotli"] and env["builtin_brotli"]:env_thirdparty.add_source_files(thirdparty_obj, thirdparty_brotli_sources)+# PCRE2+if env["builtin_pcre2"]:+ thirdparty_pcre2_dir = "#thirdparty/pcre2/src/"+ thirdparty_pcre2_sources = [+ "pcre2_auto_possess.c",+ "pcre2_chartables.c",+ "pcre2_chkdint.c",+ "pcre2_compile.c",+ "pcre2_compile_cgroup.c",+ "pcre2_compile_class.c",+ "pcre2_config.c",+ "pcre2_context.c",+ "pcre2_convert.c",+ "pcre2_dfa_match.c",+ "pcre2_error.c",+ "pcre2_extuni.c",+ "pcre2_find_bracket.c",+ "pcre2_jit_compile.c",+ "pcre2_maketables.c",+ "pcre2_match.c",+ "pcre2_match_data.c",+ "pcre2_match_next.c",+ "pcre2_newline.c",+ "pcre2_ord2utf.c",+ "pcre2_pattern_info.c",+ "pcre2_script_run.c",+ "pcre2_serialize.c",+ "pcre2_string_utils.c",+ "pcre2_study.c",+ "pcre2_substitute.c",+ "pcre2_substring.c",+ "pcre2_tables.c",+ "pcre2_ucd.c",+ "pcre2_valid_utf.c",+ "pcre2_xclass.c",+ ]++ thirdparty_pcre2_sources = [thirdparty_pcre2_dir + file for file in thirdparty_pcre2_sources]++ thirdparty_pcre2_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H", "SUPPORT_UNICODE", ("PCRE2_CODE_UNIT_WIDTH", 32)]+ if env["builtin_pcre2_with_jit"]:+ thirdparty_pcre2_flags.append("SUPPORT_JIT")+ env_thirdparty.Append(CPPDEFINES=thirdparty_pcre2_flags)+ env_thirdparty.Prepend(CPPPATH=[thirdparty_pcre2_dir])++ env_thirdparty.add_source_files(thirdparty_obj, thirdparty_pcre2_sources)+# Clipper2 Thirdparty source files used for polygon and polyline boolean operations.if env["builtin_clipper2"]:thirdparty_clipper_dir = "#thirdparty/clipper2/"diff --git a/core/io/logger.cpp b/core/io/logger.cppindex a830b66cb80..65e3ab5bb3c 100644--- a/core/io/logger.cpp+++ b/core/io/logger.cpp@@ -35,16 +35,11 @@#include "core/io/file_access.h"#include "core/object/script_backtrace.h"#include "core/os/time.h"+#include "core/string/regex.h"#include "core/templates/rb_set.h"-#include "modules/modules_enabled.gen.h" // For regex.-#include <cstdio>-#ifdef MODULE_REGEX_ENABLED-#include "modules/regex/regex.h"-#endif // MODULE_REGEX_ENABLED-#if defined(MINGW_ENABLED) || defined(_MSC_VER)#define sprintf sprintf_s#endif@@ -174,11 +169,9 @@ RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files)max_files(p_max_files > 0 ? p_max_files : 1) {rotate_file();-#ifdef MODULE_REGEX_ENABLEDstrip_ansi_regex.instantiate();strip_ansi_regex->detach_from_objectdb(); // Note: This RegEx instance will exist longer than ObjectDB, therefore can't be registered in ObjectDB.strip_ansi_regex->compile("\u001b\\[((?:\\d|;)*)([a-zA-Z])");-#endif // MODULE_REGEX_ENABLED}void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) {@@ -199,14 +192,10 @@ void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) {}va_end(list_copy);-#ifdef MODULE_REGEX_ENABLED// Strip ANSI escape codes (such as those inserted by `print_rich()`)// before writing to file, as text editors cannot display those// correctly.file->store_string(strip_ansi_regex->sub(String::utf8(buf), "", true));-#else- file->store_buffer((uint8_t *)buf, len);-#endif // MODULE_REGEX_ENABLEDif (len >= static_buf_size) {Memory::free_static(buf);diff --git a/core/register_core_types.cpp b/core/register_core_types.cppindex 0b3e904290e..3ce4e37db03 100644--- a/core/register_core_types.cpp+++ b/core/register_core_types.cpp@@ -86,6 +86,7 @@#include "core/os/time.h"#include "core/string/fuzzy_search.h"#include "core/string/optimized_translation.h"+#include "core/string/regex.h"#include "core/string/translation.h"#include "core/string/translation_server.h"#ifndef DISABLE_DEPRECATED@@ -275,6 +276,8 @@ void register_core_types() {GDREGISTER_CLASS(XMLParser);GDREGISTER_CLASS(JSON);+ GDREGISTER_CLASS(RegExMatch);+ GDREGISTER_CLASS(RegEx);GDREGISTER_CLASS(ConfigFile);diff --git a/modules/regex/regex.compat.inc b/core/string/regex.compat.incsimilarity index 100%rename from modules/regex/regex.compat.increname to core/string/regex.compat.incdiff --git a/modules/regex/regex.cpp b/core/string/regex.cppsimilarity index 96%rename from modules/regex/regex.cpprename to core/string/regex.cppindex 4d199515f50..d78237e50f5 100644--- a/modules/regex/regex.cpp+++ b/core/string/regex.cpp@@ -34,17 +34,23 @@#include "core/object/class_db.h"#include "core/os/memory.h"-extern "C" {-#include <pcre2.h>-}+#ifndef PCRE2_STATIC+#define PCRE2_STATIC+#endif++#ifndef PCRE2_CODE_UNIT_WIDTH+#define PCRE2_CODE_UNIT_WIDTH 32+#endif++#include <thirdparty/pcre2/src/pcre2.h>-static void *_regex_malloc(PCRE2_SIZE size, void *user) {- return memalloc(size);+static void *_regex_malloc(PCRE2_SIZE p_size, void *p_user) {+ return memalloc(p_size);}-static void _regex_free(void *ptr, void *user) {- if (ptr) {- memfree(ptr);+static void _regex_free(void *p_ptr, void *p_user) {+ if (p_ptr) {+ memfree(p_ptr);}}@@ -159,8 +165,8 @@ void RegExMatch::_bind_methods() {ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "strings"), "", "get_strings");}-void RegEx::_pattern_info(uint32_t what, void *where) const {- pcre2_pattern_info_32((pcre2_code_32 *)code, what, where);+void RegEx::_pattern_info(uint32_t p_what, void *r_where) const {+ pcre2_pattern_info_32((pcre2_code_32 *)code, p_what, r_where);}Ref<RegEx> RegEx::create_from_string(const String &p_pattern, bool p_show_error) {diff --git a/modules/regex/regex.h b/core/string/regex.hsimilarity index 98%rename from modules/regex/regex.hrename to core/string/regex.hindex 2086fdc7937..fae5ea056b3 100644--- a/modules/regex/regex.h+++ b/core/string/regex.h@@ -75,7 +75,7 @@ class RegEx : public RefCounted {void *code = nullptr;String pattern;- void _pattern_info(uint32_t what, void *where) const;+ void _pattern_info(uint32_t p_what, void *r_where) const;int _sub(const String &p_subject, const String &p_replacement, int p_offset, int p_end, uint32_t p_flags, String &r_output) const;diff --git a/modules/regex/doc_classes/RegEx.xml b/doc/classes/RegEx.xmlsimilarity index 99%rename from modules/regex/doc_classes/RegEx.xmlrename to doc/classes/RegEx.xmlindex f4ac69e91b1..0c781c6e65c 100644--- a/modules/regex/doc_classes/RegEx.xml+++ b/doc/classes/RegEx.xml@@ -1,5 +1,5 @@<?xml version="1.0" encoding="UTF-8" ?>-<class name="RegEx" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">+<class name="RegEx" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"><brief_description>Class for searching text for patterns using regular expressions.</brief_description>diff --git a/modules/regex/doc_classes/RegExMatch.xml b/doc/classes/RegExMatch.xmlsimilarity index 98%rename from modules/regex/doc_classes/RegExMatch.xmlrename to doc/classes/RegExMatch.xmlindex 394d2efaed2..bf0fe221650 100644--- a/modules/regex/doc_classes/RegExMatch.xml+++ b/doc/classes/RegExMatch.xml@@ -1,5 +1,5 @@<?xml version="1.0" encoding="UTF-8" ?>-<class name="RegExMatch" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">+<class name="RegExMatch" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"><brief_description>Contains the results of a [RegEx] search.</brief_description>diff --git a/editor/doc/editor_help.cpp b/editor/doc/editor_help.cppindex 84eed642e92..fa921bf8e04 100644--- a/editor/doc/editor_help.cpp+++ b/editor/doc/editor_help.cpp@@ -43,6 +43,7 @@#include "core/object/script_language.h"#include "core/os/keyboard.h"#include "core/os/os.h"+#include "core/string/regex.h"#include "core/string/string_builder.h"#include "core/version.h"#include "editor/doc/doc_data_compressed.gen.h"@@ -75,8 +76,6 @@#include "modules/mono/csharp_script.h"#endif-#include "modules/regex/regex.h"-#define CONTRIBUTE_URL "https://contributing.godotengine.org/en/latest/documentation/class_reference.html"#ifdef MODULE_MONO_ENABLEDdiff --git a/editor/export/codesign.cpp b/editor/export/codesign.cppindex ca2c6fef79b..23f8bb8e3a3 100644--- a/editor/export/codesign.cpp+++ b/editor/export/codesign.cpp@@ -33,12 +33,11 @@#include "core/crypto/crypto_core.h"#include "core/io/dir_access.h"#include "core/io/plist.h"+#include "core/string/regex.h"#include "editor/export/lipo.h"#include "editor/export/macho.h"#include "editor/file_system/editor_paths.h"-#include "modules/regex/regex.h"-#include <ctime>/*************************************************************************/diff --git a/modules/regex/icons/RegEx.svg b/editor/icons/RegEx.svgsimilarity index 100%rename from modules/regex/icons/RegEx.svgrename to editor/icons/RegEx.svgdiff --git a/modules/regex/icons/RegExMatch.svg b/editor/icons/RegExMatch.svgsimilarity index 100%rename from modules/regex/icons/RegExMatch.svgrename to editor/icons/RegExMatch.svgdiff --git a/editor/project_upgrade/project_converter_3_to_4.cpp b/editor/project_upgrade/project_converter_3_to_4.cppindex 8966981c18e..7290c373648 100644--- a/editor/project_upgrade/project_converter_3_to_4.cpp+++ b/editor/project_upgrade/project_converter_3_to_4.cpp@@ -39,11 +39,10 @@#include "core/object/ref_counted.h"#include "core/os/keyboard.h"#include "core/os/time.h"+#include "core/string/regex.h"#include "core/templates/list.h"#include "editor/project_upgrade/renames_map_3_to_4.h"-#include "modules/regex/regex.h"-// Find "OS.set_property(x)", capturing x into $1.static String make_regex_gds_os_property_set(const String &name_set) {return String("\\bOS\\.") + name_set + "\\s*\\((.*)\\)";diff --git a/editor/scene/3d/bone_map_editor_plugin.cpp b/editor/scene/3d/bone_map_editor_plugin.cppindex f955d4ae750..5557f05ff3c 100644--- a/editor/scene/3d/bone_map_editor_plugin.cpp+++ b/editor/scene/3d/bone_map_editor_plugin.cpp@@ -32,6 +32,7 @@#include "core/object/callable_mp.h"#include "core/object/class_db.h"+#include "core/string/regex.h"#include "editor/import/3d/post_import_plugin_skeleton_renamer.h"#include "editor/import/3d/post_import_plugin_skeleton_rest_fixer.h"#include "editor/import/3d/post_import_plugin_skeleton_track_organizer.h"@@ -44,8 +45,6 @@#include "scene/gui/texture_rect.h"#include "scene/resources/texture.h"-#include "modules/regex/regex.h"-void BoneMapperButton::fetch_textures() {if (selected) {set_texture_normal(get_editor_theme_icon(SNAME("BoneMapperHandleSelected")));diff --git a/editor/scene/rename_dialog.cpp b/editor/scene/rename_dialog.cppindex fbb263a0ccc..f7c55f85546 100644--- a/editor/scene/rename_dialog.cpp+++ b/editor/scene/rename_dialog.cpp@@ -32,6 +32,7 @@#include "core/object/callable_mp.h"#include "core/object/class_db.h"+#include "core/string/regex.h"#include "editor/editor_node.h"#include "editor/editor_string_names.h"#include "editor/editor_undo_redo_manager.h"@@ -47,8 +48,6 @@#include "scene/gui/tab_container.h"#include "scene/main/scene_tree.h"-#include "modules/regex/regex.h"-RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor) {scene_tree_editor = p_scene_tree_editor;preview_node = nullptr;diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cppindex 715fe8a145b..c62a42d61b5 100644--- a/editor/settings/editor_settings.cpp+++ b/editor/settings/editor_settings.cpp@@ -45,6 +45,7 @@#include "core/object/class_db.h"#include "core/os/keyboard.h"#include "core/os/os.h"+#include "core/string/regex.h"#include "core/string/translation_server.h"#include "core/templates/rb_set.h"#include "core/version.h"@@ -62,8 +63,6 @@#include "scene/resources/animation.h"#include "servers/display/display_server.h"-#include "modules/regex/regex.h"-// PRIVATE METHODSRef<EditorSettings> EditorSettings::singleton = nullptr;diff --git a/editor/shader/shader_text_editor.cpp b/editor/shader/shader_text_editor.cppindex dda37460f99..58892bf5b87 100644--- a/editor/shader/shader_text_editor.cpp+++ b/editor/shader/shader_text_editor.cpp@@ -32,6 +32,7 @@#include "core/config/project_settings.h"#include "core/object/callable_mp.h"+#include "core/string/regex.h"#include "editor/docks/inspector_dock.h"#include "editor/editor_node.h"#include "editor/editor_string_names.h"@@ -56,8 +57,6 @@#include "servers/rendering/shader_preprocessor.h"#include "servers/rendering/shader_types.h"-#include "modules/regex/regex.h"-/*** SHADER PREVIEW LINE LAYER ****/void TextShaderPreviewLineLayer::_notification(int p_what) {diff --git a/modules/gdscript/tests/test_lsp.h b/modules/gdscript/tests/test_lsp.hindex 53729cbbe4b..7de9d9d14cd 100644--- a/modules/gdscript/tests/test_lsp.h+++ b/modules/gdscript/tests/test_lsp.h@@ -42,11 +42,10 @@#include "gdscript_test_runner.h"#include "core/io/dir_access.h"+#include "core/string/regex.h"#include "editor/file_system/editor_file_system.h"#include "tests/test_macros.h"-#include "modules/regex/regex.h"-#include <thirdparty/doctest/doctest.h>class TestGDScriptLanguageProtocolInitializer {diff --git a/modules/mono/config.py b/modules/mono/config.pyindex 24d028a9d0b..c6017b6035e 100644--- a/modules/mono/config.py+++ b/modules/mono/config.py@@ -1,7 +1,4 @@def can_build(env, platform):- if env.editor_build:- env.module_add_dependencies("mono", ["regex"])-return Truediff --git a/modules/mono/editor/semver.h b/modules/mono/editor/semver.hindex 935d0e60067..5c4a8ac67cf 100644--- a/modules/mono/editor/semver.h+++ b/modules/mono/editor/semver.h@@ -30,10 +30,9 @@#pragma once+#include "core/string/regex.h"#include "core/string/ustring.h"-#include "modules/regex/regex.h"-// <sys/sysmacros.h> is included somewhere, which defines major(dev) to gnu_dev_major(dev)#if defined(major)#undef majordiff --git a/modules/regex/SCsub b/modules/regex/SCsubdeleted file mode 100644index 7aa86299c4a..00000000000--- a/modules/regex/SCsub+++ /dev/null@@ -1,80 +0,0 @@-#!/usr/bin/env python-from misc.utility.scons_hints import *--Import("env")-Import("env_modules")--env_regex = env_modules.Clone()--# Thirdparty source files--thirdparty_obj = []--if env["builtin_pcre2"]:- thirdparty_dir = "#thirdparty/pcre2/src/"- thirdparty_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H", "SUPPORT_UNICODE"]-- if env["builtin_pcre2_with_jit"]:- thirdparty_flags.append("SUPPORT_JIT")-- thirdparty_sources = [- "pcre2_auto_possess.c",- "pcre2_chartables.c",- "pcre2_chkdint.c",- "pcre2_compile.c",- "pcre2_compile_cgroup.c",- "pcre2_compile_class.c",- "pcre2_config.c",- "pcre2_context.c",- "pcre2_convert.c",- "pcre2_dfa_match.c",- "pcre2_error.c",- "pcre2_extuni.c",- "pcre2_find_bracket.c",- "pcre2_jit_compile.c",- "pcre2_maketables.c",- "pcre2_match.c",- "pcre2_match_data.c",- "pcre2_match_next.c",- "pcre2_newline.c",- "pcre2_ord2utf.c",- "pcre2_pattern_info.c",- "pcre2_script_run.c",- "pcre2_serialize.c",- "pcre2_string_utils.c",- "pcre2_study.c",- "pcre2_substitute.c",- "pcre2_substring.c",- "pcre2_tables.c",- "pcre2_ucd.c",- "pcre2_valid_utf.c",- "pcre2_xclass.c",- ]-- thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]-- env_regex.Prepend(CPPPATH=[thirdparty_dir])- env_regex.Append(CPPDEFINES=thirdparty_flags)-- def pcre2_builtin(width):- env_pcre2 = env_regex.Clone()- env_pcre2.disable_warnings()- env_pcre2["OBJSUFFIX"] = "_" + width + env_pcre2["OBJSUFFIX"]- env_pcre2.Append(CPPDEFINES=[("PCRE2_CODE_UNIT_WIDTH", width)])- env_pcre2.add_source_files(thirdparty_obj, thirdparty_sources)-- pcre2_builtin("16")- pcre2_builtin("32")- env.modules_sources += thirdparty_obj---# Godot source files--module_obj = []--env_regex.Append(CPPDEFINES=[("PCRE2_CODE_UNIT_WIDTH", 0)])-env_regex.add_source_files(module_obj, "*.cpp")-env.modules_sources += module_obj--# Needed to force rebuilding the module files when the thirdparty library is updated.-env.Depends(module_obj, thirdparty_obj)diff --git a/modules/regex/config.py b/modules/regex/config.pydeleted file mode 100644index df9f44cb952..00000000000--- a/modules/regex/config.py+++ /dev/null@@ -1,17 +0,0 @@-def can_build(env, platform):- return True---def configure(env):- pass---def get_doc_classes():- return [- "RegEx",- "RegExMatch",- ]---def get_doc_path():- return "doc_classes"diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cppdeleted file mode 100644index 9e3a296ce37..00000000000--- a/modules/regex/register_types.cpp+++ /dev/null@@ -1,50 +0,0 @@-/**************************************************************************/-/* register_types.cpp */-/**************************************************************************/-/* This file is part of: */-/* GODOT ENGINE */-/* https://godotengine.org */-/**************************************************************************/-/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */-/* */-/* Permission is hereby granted, free of charge, to any person obtaining */-/* a copy of this software and associated documentation files (the */-/* "Software"), to deal in the Software without restriction, including */-/* without limitation the rights to use, copy, modify, merge, publish, */-/* distribute, sublicense, and/or sell copies of the Software, and to */-/* permit persons to whom the Software is furnished to do so, subject to */-/* the following conditions: */-/* */-/* The above copyright notice and this permission notice shall be */-/* included in all copies or substantial portions of the Software. */-/* */-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */-/**************************************************************************/--#include "register_types.h"--#include "regex.h"--#include "core/object/class_db.h"--void initialize_regex_module(ModuleInitializationLevel p_level) {- if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {- return;- }-- GDREGISTER_CLASS(RegExMatch);- GDREGISTER_CLASS(RegEx);-}--void uninitialize_regex_module(ModuleInitializationLevel p_level) {- if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {- return;- }-}diff --git a/modules/regex/register_types.h b/modules/regex/register_types.hdeleted file mode 100644index 612af28bca3..00000000000--- a/modules/regex/register_types.h+++ /dev/null@@ -1,36 +0,0 @@-/**************************************************************************/-/* register_types.h */-/**************************************************************************/-/* This file is part of: */-/* GODOT ENGINE */-/* https://godotengine.org */-/**************************************************************************/-/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */-/* */-/* Permission is hereby granted, free of charge, to any person obtaining */-/* a copy of this software and associated documentation files (the */-/* "Software"), to deal in the Software without restriction, including */-/* without limitation the rights to use, copy, modify, merge, publish, */-/* distribute, sublicense, and/or sell copies of the Software, and to */-/* permit persons to whom the Software is furnished to do so, subject to */-/* the following conditions: */-/* */-/* The above copyright notice and this permission notice shall be */-/* included in all copies or substantial portions of the Software. */-/* */-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */-/**************************************************************************/--#pragma once--#include "modules/register_module_types.h"--void initialize_regex_module(ModuleInitializationLevel p_level);-void uninitialize_regex_module(ModuleInitializationLevel p_level);diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cppindex a953c1a6a12..e49bbab9fd6 100644--- a/platform/android/export/gradle_export_util.cpp+++ b/platform/android/export/gradle_export_util.cpp@@ -33,12 +33,11 @@#include "core/io/dir_access.h"#include "core/io/file_access.h"#include "core/os/os.h"+#include "core/string/regex.h"#include "core/string/translation_server.h"#include "editor/export/editor_export.h"#include "editor/export/editor_export_plugin.h"-#include "modules/regex/regex.h"-int _get_android_orientation_value(DisplayServerEnums::ScreenOrientation screen_orientation) {switch (screen_orientation) {case DisplayServerEnums::SCREEN_PORTRAIT:diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cppindex 4aa445c5ee3..3dd63017e36 100644--- a/platform/linuxbsd/os_linuxbsd.cpp+++ b/platform/linuxbsd/os_linuxbsd.cpp@@ -36,6 +36,7 @@#include "core/os/main_loop.h"#include "core/os/os.h"#include "core/profiling/profiling.h"+#include "core/string/regex.h"#include "main/main.h"#include "servers/display/display_server.h"#include "servers/rendering/rendering_server.h"@@ -54,11 +55,6 @@#include "wayland/display_server_wayland.h"#endif-#include "modules/modules_enabled.gen.h" // For regex.-#ifdef MODULE_REGEX_ENABLED-#include "modules/regex/regex.h"-#endif-#if defined(RD_ENABLED)#include "servers/rendering/rendering_device.h"#endif@@ -375,10 +371,8 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {Vector<String> class_display_device_candidates;Vector<String> class_3d_device_candidates;-#ifdef MODULE_REGEX_ENABLEDRegEx regex_id_format = RegEx();regex_id_format.compile("^[a-f0-9]{4}:[a-f0-9]{4}$"); // e.g. `10de:13c2`; IDs are always in hexadecimal-#endifVector<String> value_lines = vendor_device_id_mappings.split("\n", false); // example: `02:00.0 0300: 10de:13c2 (rev a1)`for (const String &line : value_lines) {@@ -389,11 +383,9 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {String device_class = columns[1].trim_suffix(":");const String &vendor_device_id_mapping = columns[2];-#ifdef MODULE_REGEX_ENABLEDif (regex_id_format.search(vendor_device_id_mapping).is_null()) {continue;}-#endifif (device_class == dc_vga) {class_vga_device_candidates.push_back(vendor_device_id_mapping);diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cppindex 47f8cfc350d..eca0c5c3f77 100644--- a/scene/gui/rich_text_label.cpp+++ b/scene/gui/rich_text_label.cpp@@ -38,6 +38,7 @@#include "core/object/class_db.h"#include "core/os/keyboard.h"#include "core/os/os.h"+#include "core/string/regex.h"#include "core/string/translation_server.h"#include "scene/gui/label.h"#include "scene/gui/popup_menu.h"@@ -53,11 +54,6 @@#include "servers/display/display_server.h"#include "servers/rendering/rendering_server.h"-#include "modules/modules_enabled.gen.h" // For regex.-#ifdef MODULE_REGEX_ENABLED-#include "modules/regex/regex.h"-#endif-RichTextLabel::ItemDropcap::~ItemDropcap() {if (font.is_valid()) {RichTextLabel *owner_rtl = ObjectDB::get_instance<RichTextLabel>(owner);@@ -8127,9 +8123,7 @@ void RichTextLabel::_bind_methods() {BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, RichTextLabel, table_border);ADD_CLASS_DEPENDENCY("PopupMenu");-#ifdef MODULE_REGEX_ENABLEDADD_CLASS_DEPENDENCY("RegEx");-#endif}TextServer::VisibleCharactersBehavior RichTextLabel::get_visible_characters_behavior() const {@@ -8425,7 +8419,6 @@ Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressiVector<String> values = parts[1].split(",", false);-#ifdef MODULE_REGEX_ENABLEDRegEx color = RegEx();color.compile("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$");RegEx nodepath = RegEx();@@ -8459,7 +8452,6 @@ Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressia.append(values[j]);}}-#endifif (values.size() > 1) {d[key] = a;diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cppindex 2b8c1300ce8..dbb6083ae97 100644--- a/scene/resources/shader.cpp+++ b/scene/resources/shader.cpp@@ -41,12 +41,8 @@#include "servers/rendering/shader_preprocessor.h"#ifdef TOOLS_ENABLED+#include "core/string/regex.h"#include "editor/doc/editor_help.h"--#include "modules/modules_enabled.gen.h" // For regex.-#ifdef MODULE_REGEX_ENABLED-#include "modules/regex/regex.h"-#endif#endifShader::Mode Shader::get_mode() const {diff --git a/modules/regex/tests/test_regex.h b/tests/core/string/test_regex.cppsimilarity index 98%rename from modules/regex/tests/test_regex.hrename to tests/core/string/test_regex.cppindex 1aa697bdbba..63336dd2dcb 100644--- a/modules/regex/tests/test_regex.h+++ b/tests/core/string/test_regex.cpp@@ -1,5 +1,5 @@/**************************************************************************/-/* test_regex.h */+/* test_regex.cpp *//**************************************************************************//* This file is part of: *//* GODOT ENGINE */@@ -28,12 +28,11 @@/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *//**************************************************************************/-#pragma once+#include "tests/test_macros.h"-#include "../regex.h"+TEST_FORCE_LINK(test_regex)-#include "core/string/ustring.h"-#include "tests/test_macros.h"+#include "core/string/regex.h"namespace TestRegEx {