From 5e86e75e2990d706347e577dd79ede05bad07232 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Tue, 19 Dec 2023 01:43:56 -0600 Subject: [PATCH] MSVC: fix max literal length --- MaterialDesign/wxSimpleIconsArt.hpp | 70 ++++++++++++++++++++++------- scripts/create_folder_headers.py | 16 +++++-- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/MaterialDesign/wxSimpleIconsArt.hpp b/MaterialDesign/wxSimpleIconsArt.hpp index dcdfd401..84048e89 100644 --- a/MaterialDesign/wxSimpleIconsArt.hpp +++ b/MaterialDesign/wxSimpleIconsArt.hpp @@ -3612,7 +3612,9 @@ R"rawsvg( #define wxART_COMPOSER wxART_MAKE_ART_ID(wxART_COMPOSER) #endif static constexpr const char *SVG_SIMPLE_ICONS_COMPOSER= -R"rawsvg(Composer)rawsvg" +R"rawsvg(Composer)rawsvg" ; #ifndef wxART_COMPTIA @@ -5089,7 +5091,10 @@ R"rawsvg( #define wxART_ELSEVIER wxART_MAKE_ART_ID(wxART_ELSEVIER) #endif static constexpr const char *SVG_SIMPLE_ICONS_ELSEVIER= -R"rawsvg(Elsevier)rawsvg" +R"rawsvg(Elsevier)rawsvg" ; #ifndef wxART_EMBARCADERO @@ -5579,7 +5584,8 @@ R"rawsvg( #define wxART_FERRARI wxART_MAKE_ART_ID(wxART_FERRARI) #endif static constexpr const char *SVG_SIMPLE_ICONS_FERRARI= -R"rawsvg(Ferrari)rawsvg" +R"rawsvg(Ferrari)rawsvg" ; #ifndef wxART_FERRARINV @@ -5649,7 +5655,8 @@ R"rawsvg( #define wxART_FIGSHARE wxART_MAKE_ART_ID(wxART_FIGSHARE) #endif static constexpr const char *SVG_SIMPLE_ICONS_FIGSHARE= -R"rawsvg(figshare)rawsvg" +R"rawsvg(figshare)rawsvg" ; #ifndef wxART_FILA @@ -7161,7 +7168,8 @@ R"rawsvg( #define wxART_GUTENBERG wxART_MAKE_ART_ID(wxART_GUTENBERG) #endif static constexpr const char *SVG_SIMPLE_ICONS_GUTENBERG= -R"rawsvg(Gutenberg)rawsvg" +R"rawsvg(Gutenberg)rawsvg" ; #ifndef wxART_H3 @@ -7175,7 +7183,8 @@ R"rawsvg( #define wxART_HABR wxART_MAKE_ART_ID(wxART_HABR) #endif static constexpr const char *SVG_SIMPLE_ICONS_HABR= -R"rawsvg(Habr)rawsvg" +R"rawsvg(Habr)rawsvg" ; #ifndef wxART_HACKADAY @@ -8134,7 +8143,8 @@ R"rawsvg( #define wxART_INTERACTIONDESIGNFOUNDATION wxART_MAKE_ART_ID(wxART_INTERACTIONDESIGNFOUNDATION) #endif static constexpr const char *SVG_SIMPLE_ICONS_INTERACTIONDESIGNFOUNDATION= -R"rawsvg(Interaction Design Foundation)rawsvg" +R"rawsvg(Interaction Design Foundation)rawsvg" ; #ifndef wxART_INTERACTJS @@ -9331,7 +9341,20 @@ R"rawsvg( #define wxART_LERNA wxART_MAKE_ART_ID(wxART_LERNA) #endif static constexpr const char *SVG_SIMPLE_ICONS_LERNA= -R"rawsvg(Lerna)rawsvg" +R"rawsvg(Lerna)rawsvg" ; #ifndef wxART_LEROYMERLIN @@ -11130,7 +11153,8 @@ R"rawsvg( #define wxART_NEWJAPANPROWRESTLING wxART_MAKE_ART_ID(wxART_NEWJAPANPROWRESTLING) #endif static constexpr const char *SVG_SIMPLE_ICONS_NEWJAPANPROWRESTLING= -R"rawsvg(New Japan Pro-Wrestling)rawsvg" +R"rawsvg(New Japan Pro-Wrestling)rawsvg" ; #ifndef wxART_NEWRELIC @@ -12873,7 +12897,8 @@ R"rawsvg( #define wxART_PORSCHE wxART_MAKE_ART_ID(wxART_PORSCHE) #endif static constexpr const char *SVG_SIMPLE_ICONS_PORSCHE= -R"rawsvg(Porsche)rawsvg" +R"rawsvg(Porsche)rawsvg" ; #ifndef wxART_PORTAINER @@ -12887,7 +12912,8 @@ R"rawsvg( #define wxART_POSTCSS wxART_MAKE_ART_ID(wxART_POSTCSS) #endif static constexpr const char *SVG_SIMPLE_ICONS_POSTCSS= -R"rawsvg(PostCSS)rawsvg" +R"rawsvg(PostCSS)rawsvg" ; #ifndef wxART_POSTGRESQL @@ -13237,7 +13263,18 @@ R"rawsvg( #define wxART_PUBG wxART_MAKE_ART_ID(wxART_PUBG) #endif static constexpr const char *SVG_SIMPLE_ICONS_PUBG= -R"rawsvg(PUBG)rawsvg" +R"rawsvg(PUBG)rawsvg" ; #ifndef wxART_PUBLONS @@ -17500,7 +17537,8 @@ R"rawsvg( #define wxART_UNILEVER wxART_MAKE_ART_ID(wxART_UNILEVER) #endif static constexpr const char *SVG_SIMPLE_ICONS_UNILEVER= -R"rawsvg(Unilever)rawsvg" +R"rawsvg(Unilever)rawsvg" ; #ifndef wxART_UNITEDAIRLINES @@ -17514,7 +17552,8 @@ R"rawsvg( #define wxART_UNITEDNATIONS wxART_MAKE_ART_ID(wxART_UNITEDNATIONS) #endif static constexpr const char *SVG_SIMPLE_ICONS_UNITEDNATIONS= -R"rawsvg(United Nations)rawsvg" +R"rawsvg(United Nations)rawsvg" ; #ifndef wxART_UNITY @@ -17885,7 +17924,8 @@ R"rawsvg( #define wxART_VIRGIN wxART_MAKE_ART_ID(wxART_VIRGIN) #endif static constexpr const char *SVG_SIMPLE_ICONS_VIRGIN= -R"rawsvg(Virgin)rawsvg" +R"rawsvg(Virgin)rawsvg" ; #ifndef wxART_VIRGINMEDIA diff --git a/scripts/create_folder_headers.py b/scripts/create_folder_headers.py index 81445208..8cef68d9 100644 --- a/scripts/create_folder_headers.py +++ b/scripts/create_folder_headers.py @@ -51,8 +51,7 @@ def create_svg_folder_header(base_path,folder,save_path,client_name): for svg in svg_files: as_text = open(svg,"r") raw_string = as_text.read() - # Convert to a raw c++ literal - literal = 'R"rawsvg(' + raw_string + ')rawsvg"' + as_text.close() # Add literal to header @@ -70,7 +69,18 @@ def create_svg_folder_header(base_path,folder,save_path,client_name): # Actual data fid.write("static constexpr const char *" + char_name + "= \n") - fid.write(literal) + + #MSVC fix: constant literals cannot be longer than 16380 characters each + chunk_size = 16300 + + # Convert to a raw c++ literal + literal = 'R"rawsvg(' + raw_string + ')rawsvg"' + + for i in range(0, len(raw_string), chunk_size): + chunk = ('R"rawsvg(' if i==0 else '\nR"rawsvg(') + raw_string[i:i+chunk_size] + ')rawsvg"' + fid.write(chunk) + + # fid.write(literal) fid.write("\n;") # Define prototype functions