From ed9cdc572e8d9d7723d8ae941e6f437f1840c16d Mon Sep 17 00:00:00 2001 From: Vivraan Date: Tue, 4 Aug 2020 17:22:44 +0530 Subject: [PATCH 01/27] Correct C# named color constants --- modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index d05a0414aa50..33de13ecaf30 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs @@ -28,7 +28,7 @@ public static class Colors {"chartreuse", new Color(0.50f, 1.00f, 0.00f)}, {"chocolate", new Color(0.82f, 0.41f, 0.12f)}, {"coral", new Color(1.00f, 0.50f, 0.31f)}, - {"cornflower", new Color(0.39f, 0.58f, 0.93f)}, + {"cornflowerblue", new Color(0.39f, 0.58f, 0.93f)}, {"cornsilk", new Color(1.00f, 0.97f, 0.86f)}, {"crimson", new Color(0.86f, 0.08f, 0.24f)}, {"cyan", new Color(0.00f, 1.00f, 1.00f)}, @@ -171,12 +171,12 @@ public static class Colors public static Color Blue { get { return namedColors["blue"]; } } public static Color BlueViolet { get { return namedColors["blueviolet"]; } } public static Color Brown { get { return namedColors["brown"]; } } - public static Color BurlyWood { get { return namedColors["burlywood"]; } } + public static Color Burlywood { get { return namedColors["burlywood"]; } } public static Color CadetBlue { get { return namedColors["cadetblue"]; } } public static Color Chartreuse { get { return namedColors["chartreuse"]; } } public static Color Chocolate { get { return namedColors["chocolate"]; } } public static Color Coral { get { return namedColors["coral"]; } } - public static Color Cornflower { get { return namedColors["cornflower"]; } } + public static Color CornflowerBlue { get { return namedColors["cornflowerblue"]; } } public static Color Cornsilk { get { return namedColors["cornsilk"]; } } public static Color Crimson { get { return namedColors["crimson"]; } } public static Color Cyan { get { return namedColors["cyan"]; } } @@ -236,7 +236,7 @@ public static class Colors public static Color LightSteelBlue { get { return namedColors["lightsteelblue"]; } } public static Color LightYellow { get { return namedColors["lightyellow"]; } } public static Color Lime { get { return namedColors["lime"]; } } - public static Color Limegreen { get { return namedColors["limegreen"]; } } + public static Color LimeGreen { get { return namedColors["limegreen"]; } } public static Color Linen { get { return namedColors["linen"]; } } public static Color Magenta { get { return namedColors["magenta"]; } } public static Color Maroon { get { return namedColors["maroon"]; } } @@ -280,7 +280,7 @@ public static class Colors public static Color Salmon { get { return namedColors["salmon"]; } } public static Color SandyBrown { get { return namedColors["sandybrown"]; } } public static Color SeaGreen { get { return namedColors["seagreen"]; } } - public static Color SeaShell { get { return namedColors["seashell"]; } } + public static Color Seashell { get { return namedColors["seashell"]; } } public static Color Sienna { get { return namedColors["sienna"]; } } public static Color Silver { get { return namedColors["silver"]; } } public static Color SkyBlue { get { return namedColors["skyblue"]; } } From e0dedf80d2b1f4ba377fd4b9dd0762b6c99af5c0 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Tue, 4 Aug 2020 17:23:37 +0530 Subject: [PATCH 02/27] Correct C++ named colors --- core/color_names.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/color_names.inc b/core/color_names.inc index 2b50d88b02fa..d1b22291f487 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -23,7 +23,7 @@ static void _populate_named_colors() { _named_colors.insert("chartreuse", Color(0.50, 1.00, 0.00)); _named_colors.insert("chocolate", Color(0.82, 0.41, 0.12)); _named_colors.insert("coral", Color(1.00, 0.50, 0.31)); - _named_colors.insert("cornflower", Color(0.39, 0.58, 0.93)); + _named_colors.insert("cornflowerblue", Color(0.39, 0.58, 0.93)); _named_colors.insert("cornsilk", Color(1.00, 0.97, 0.86)); _named_colors.insert("crimson", Color(0.86, 0.08, 0.24)); _named_colors.insert("cyan", Color(0.00, 1.00, 1.00)); From 4e1e13e5ff6e825673d4313590624d9441047781 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Tue, 4 Aug 2020 17:36:04 +0530 Subject: [PATCH 03/27] Correct Color GDScript docs --- doc/classes/Color.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 240e70db9fd9..b62fb673578b 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -336,7 +336,7 @@ Black color. - Blanche almond color. + Blanched almond color. Blue color. @@ -348,7 +348,7 @@ Brown color. - Burly wood color. + Burlywood color. Cadet blue color. @@ -362,8 +362,8 @@ Coral color. - - Cornflower color. + + Cornflower Blue color. Corn silk color. From 3b118080217bddafee350aeb6cb37ac687e6f7ce Mon Sep 17 00:00:00 2001 From: Vivraan Date: Tue, 4 Aug 2020 22:06:58 +0530 Subject: [PATCH 04/27] Add the pedantic versions of color names --- core/color_names.inc | 149 ++++++++++++++++++ .../glue/GodotSharp/GodotSharp/Core/Colors.cs | 5 + 2 files changed, 154 insertions(+) diff --git a/core/color_names.inc b/core/color_names.inc index d1b22291f487..d08c23234c02 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -23,6 +23,7 @@ static void _populate_named_colors() { _named_colors.insert("chartreuse", Color(0.50, 1.00, 0.00)); _named_colors.insert("chocolate", Color(0.82, 0.41, 0.12)); _named_colors.insert("coral", Color(1.00, 0.50, 0.31)); + _named_colors.insert("cornflower", Color(0.39, 0.58, 0.93)); // for compatibility _named_colors.insert("cornflowerblue", Color(0.39, 0.58, 0.93)); _named_colors.insert("cornsilk", Color(1.00, 0.97, 0.86)); _named_colors.insert("crimson", Color(0.86, 0.08, 0.24)); @@ -152,4 +153,152 @@ static void _populate_named_colors() { _named_colors.insert("whitesmoke", Color(0.96, 0.96, 0.96)); _named_colors.insert("yellow", Color(1.00, 1.00, 0.00)); _named_colors.insert("yellowgreen", Color(0.60, 0.80, 0.20)); + + // You're a pedant + _named_colors.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); + _named_colors.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); + _named_colors.insert("AQUA", Color(0.00, 1.00, 1.00)); + _named_colors.insert("AQUAMARINE", Color(0.50, 1.00, 0.83)); + _named_colors.insert("AZURE", Color(0.94, 1.00, 1.00)); + _named_colors.insert("BEIGE", Color(0.96, 0.96, 0.86)); + _named_colors.insert("BISQUE", Color(1.00, 0.89, 0.77)); + _named_colors.insert("BLACK", Color(0.00, 0.00, 0.00)); + _named_colors.insert("BLANCHED_ALMOND", Color(1.00, 0.92, 0.80)); + _named_colors.insert("BLUE", Color(0.00, 0.00, 1.00)); + _named_colors.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); + _named_colors.insert("BROWN", Color(0.65, 0.16, 0.16)); + _named_colors.insert("BURLYWOOD", Color(0.87, 0.72, 0.53)); + _named_colors.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); + _named_colors.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); + _named_colors.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); + _named_colors.insert("CORAL", Color(1.00, 0.50, 0.31)); + _named_colors.insert("CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93)); + _named_colors.insert("CORNSILK", Color(1.00, 0.97, 0.86)); + _named_colors.insert("CRIMSON", Color(0.86, 0.08, 0.24)); + _named_colors.insert("CYAN", Color(0.00, 1.00, 1.00)); + _named_colors.insert("DARK_BLUE", Color(0.00, 0.00, 0.55)); + _named_colors.insert("DARK_CYAN", Color(0.00, 0.55, 0.55)); + _named_colors.insert("DARK_GOLDENROD", Color(0.72, 0.53, 0.04)); + _named_colors.insert("DARK_GRAY", Color(0.66, 0.66, 0.66)); + _named_colors.insert("DARK_GREEN", Color(0.00, 0.39, 0.00)); + _named_colors.insert("DARK_KHAKI", Color(0.74, 0.72, 0.42)); + _named_colors.insert("DARK_MAGENTA", Color(0.55, 0.00, 0.55)); + _named_colors.insert("DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18)); + _named_colors.insert("DARK_ORANGE", Color(1.00, 0.55, 0.00)); + _named_colors.insert("DARK_ORCHID", Color(0.60, 0.20, 0.80)); + _named_colors.insert("DARK_RED", Color(0.55, 0.00, 0.00)); + _named_colors.insert("DARK_SALMON", Color(0.91, 0.59, 0.48)); + _named_colors.insert("DARK_SEA_GREEN", Color(0.56, 0.74, 0.56)); + _named_colors.insert("DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55)); + _named_colors.insert("DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31)); + _named_colors.insert("DARK_TURQUOISE", Color(0.00, 0.81, 0.82)); + _named_colors.insert("DARK_VIOLET", Color(0.58, 0.00, 0.83)); + _named_colors.insert("DEEP_PINK", Color(1.00, 0.08, 0.58)); + _named_colors.insert("DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00)); + _named_colors.insert("DIM_GRAY", Color(0.41, 0.41, 0.41)); + _named_colors.insert("DODGER_BLUE", Color(0.12, 0.56, 1.00)); + _named_colors.insert("FIREBRICK", Color(0.70, 0.13, 0.13)); + _named_colors.insert("FLORAL_WHITE", Color(1.00, 0.98, 0.94)); + _named_colors.insert("FOREST_GREEN", Color(0.13, 0.55, 0.13)); + _named_colors.insert("FUCHSIA", Color(1.00, 0.00, 1.00)); + _named_colors.insert("GAINSBORO", Color(0.86, 0.86, 0.86)); + _named_colors.insert("GHOST_WHITE", Color(0.97, 0.97, 1.00)); + _named_colors.insert("GOLD", Color(1.00, 0.84, 0.00)); + _named_colors.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); + _named_colors.insert("GRAY", Color(0.75, 0.75, 0.75)); + _named_colors.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); + _named_colors.insert("GREEN", Color(0.00, 1.00, 0.00)); + _named_colors.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); + _named_colors.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); + _named_colors.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); + _named_colors.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); + _named_colors.insert("INDIAN_RED", Color(0.80, 0.36, 0.36)); + _named_colors.insert("INDIGO", Color(0.29, 0.00, 0.51)); + _named_colors.insert("IVORY", Color(1.00, 1.00, 0.94)); + _named_colors.insert("KHAKI", Color(0.94, 0.90, 0.55)); + _named_colors.insert("LAVENDER", Color(0.90, 0.90, 0.98)); + _named_colors.insert("LAVENDER_BLUSH", Color(1.00, 0.94, 0.96)); + _named_colors.insert("LAWN_GREEN", Color(0.49, 0.99, 0.00)); + _named_colors.insert("LEMON_CHIFFON", Color(1.00, 0.98, 0.80)); + _named_colors.insert("LIGHT_BLUE", Color(0.68, 0.85, 0.90)); + _named_colors.insert("LIGHT_CORAL", Color(0.94, 0.50, 0.50)); + _named_colors.insert("LIGHT_CYAN", Color(0.88, 1.00, 1.00)); + _named_colors.insert("LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82)); + _named_colors.insert("LIGHT_GRAY", Color(0.83, 0.83, 0.83)); + _named_colors.insert("LIGHT_GREEN", Color(0.56, 0.93, 0.56)); + _named_colors.insert("LIGHT_PINK", Color(1.00, 0.71, 0.76)); + _named_colors.insert("LIGHT_SALMON", Color(1.00, 0.63, 0.48)); + _named_colors.insert("LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67)); + _named_colors.insert("LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98)); + _named_colors.insert("LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60)); + _named_colors.insert("LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87)); + _named_colors.insert("LIGHT_YELLOW", Color(1.00, 1.00, 0.88)); + _named_colors.insert("LIME", Color(0.00, 1.00, 0.00)); + _named_colors.insert("LIME_GREEN", Color(0.20, 0.80, 0.20)); + _named_colors.insert("LINEN", Color(0.98, 0.94, 0.90)); + _named_colors.insert("MAGENTA", Color(1.00, 0.00, 1.00)); + _named_colors.insert("MAROON", Color(0.69, 0.19, 0.38)); + _named_colors.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); + _named_colors.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); + _named_colors.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); + _named_colors.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); + _named_colors.insert("MEDIUM_PURPLE", Color(0.58, 0.44, 0.86)); + _named_colors.insert("MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44)); + _named_colors.insert("MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93)); + _named_colors.insert("MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60)); + _named_colors.insert("MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80)); + _named_colors.insert("MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52)); + _named_colors.insert("MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44)); + _named_colors.insert("MINT_CREAM", Color(0.96, 1.00, 0.98)); + _named_colors.insert("MISTY_ROSE", Color(1.00, 0.89, 0.88)); + _named_colors.insert("MOCCASIN", Color(1.00, 0.89, 0.71)); + _named_colors.insert("NAVAJO_WHITE", Color(1.00, 0.87, 0.68)); + _named_colors.insert("NAVY_BLUE", Color(0.00, 0.00, 0.50)); + _named_colors.insert("OLD_LACE", Color(0.99, 0.96, 0.90)); + _named_colors.insert("OLIVE", Color(0.50, 0.50, 0.00)); + _named_colors.insert("OLIVE_DRAB", Color(0.42, 0.56, 0.14)); + _named_colors.insert("ORANGE", Color(1.00, 0.65, 0.00)); + _named_colors.insert("ORANGE_RED", Color(1.00, 0.27, 0.00)); + _named_colors.insert("ORCHID", Color(0.85, 0.44, 0.84)); + _named_colors.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); + _named_colors.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); + _named_colors.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); + _named_colors.insert("PALE_VIOLETRED", Color(0.86, 0.44, 0.58)); + _named_colors.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); + _named_colors.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); + _named_colors.insert("PERU", Color(0.80, 0.52, 0.25)); + _named_colors.insert("PINK", Color(1.00, 0.75, 0.80)); + _named_colors.insert("PLUM", Color(0.87, 0.63, 0.87)); + _named_colors.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); + _named_colors.insert("PURPLE", Color(0.63, 0.13, 0.94)); + _named_colors.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); + _named_colors.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); + _named_colors.insert("RED", Color(1.00, 0.00, 0.00)); + _named_colors.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); + _named_colors.insert("ROYAL_BLUE", Color(0.25, 0.41, 0.88)); + _named_colors.insert("SADDLE_BROWN", Color(0.55, 0.27, 0.07)); + _named_colors.insert("SALMON", Color(0.98, 0.50, 0.45)); + _named_colors.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); + _named_colors.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); + _named_colors.insert("SEASHELL", Color(1.00, 0.96, 0.93)); + _named_colors.insert("SIENNA", Color(0.63, 0.32, 0.18)); + _named_colors.insert("SILVER", Color(0.75, 0.75, 0.75)); + _named_colors.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); + _named_colors.insert("SLATE_BLUE", Color(0.42, 0.35, 0.80)); + _named_colors.insert("SLATE_GRAY", Color(0.44, 0.50, 0.56)); + _named_colors.insert("SNOW", Color(1.00, 0.98, 0.98)); + _named_colors.insert("SPRING_GREEN", Color(0.00, 1.00, 0.50)); + _named_colors.insert("STEEL_BLUE", Color(0.27, 0.51, 0.71)); + _named_colors.insert("TAN", Color(0.82, 0.71, 0.55)); + _named_colors.insert("TEAL", Color(0.00, 0.50, 0.50)); + _named_colors.insert("THISTLE", Color(0.85, 0.75, 0.85)); + _named_colors.insert("TOMATO", Color(1.00, 0.39, 0.28)); + _named_colors.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); + _named_colors.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); + _named_colors.insert("VIOLET", Color(0.93, 0.51, 0.93)); + _named_colors.insert("WHEAT", Color(0.96, 0.87, 0.70)); + _named_colors.insert("WHITE", Color(1.00, 1.00, 1.00)); + _named_colors.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); + _named_colors.insert("YELLOW", Color(1.00, 1.00, 0.00)); + _named_colors.insert("YELLOW_GREEN", Color(0.60, 0.80, 0.20)); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index 33de13ecaf30..8f5cb741cf57 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs @@ -28,6 +28,7 @@ public static class Colors {"chartreuse", new Color(0.50f, 1.00f, 0.00f)}, {"chocolate", new Color(0.82f, 0.41f, 0.12f)}, {"coral", new Color(1.00f, 0.50f, 0.31f)}, + {"cornflower", new Color(0.39f, 0.58f, 0.93f)}, // for compatibility {"cornflowerblue", new Color(0.39f, 0.58f, 0.93f)}, {"cornsilk", new Color(1.00f, 0.97f, 0.86f)}, {"crimson", new Color(0.86f, 0.08f, 0.24f)}, @@ -171,11 +172,13 @@ public static class Colors public static Color Blue { get { return namedColors["blue"]; } } public static Color BlueViolet { get { return namedColors["blueviolet"]; } } public static Color Brown { get { return namedColors["brown"]; } } + public static Color BurlyWood { get { return namedColors["burlywood"]; } } // for compatibility public static Color Burlywood { get { return namedColors["burlywood"]; } } public static Color CadetBlue { get { return namedColors["cadetblue"]; } } public static Color Chartreuse { get { return namedColors["chartreuse"]; } } public static Color Chocolate { get { return namedColors["chocolate"]; } } public static Color Coral { get { return namedColors["coral"]; } } + public static Color Cornflower { get { return namedColors["cornflower"]; } } // for compatibility public static Color CornflowerBlue { get { return namedColors["cornflowerblue"]; } } public static Color Cornsilk { get { return namedColors["cornsilk"]; } } public static Color Crimson { get { return namedColors["crimson"]; } } @@ -236,6 +239,7 @@ public static class Colors public static Color LightSteelBlue { get { return namedColors["lightsteelblue"]; } } public static Color LightYellow { get { return namedColors["lightyellow"]; } } public static Color Lime { get { return namedColors["lime"]; } } + public static Color Limegreen { get { return namedColors["limegreen"]; } } // for compatibility public static Color LimeGreen { get { return namedColors["limegreen"]; } } public static Color Linen { get { return namedColors["linen"]; } } public static Color Magenta { get { return namedColors["magenta"]; } } @@ -280,6 +284,7 @@ public static class Colors public static Color Salmon { get { return namedColors["salmon"]; } } public static Color SandyBrown { get { return namedColors["sandybrown"]; } } public static Color SeaGreen { get { return namedColors["seagreen"]; } } + public static Color SeaShell { get { return namedColors["seashell"]; } } // for compatibility public static Color Seashell { get { return namedColors["seashell"]; } } public static Color Sienna { get { return namedColors["sienna"]; } } public static Color Silver { get { return namedColors["silver"]; } } From c37a4df1b2cdc336a8b4d0ae91d886514cdfb1b6 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 00:10:52 +0530 Subject: [PATCH 05/27] Update, per suggestions to stick with .NET, X11, HTML5 schemes --- core/color_names.inc | 7 +++---- modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs | 9 ++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index d08c23234c02..fe569f849fc0 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -23,7 +23,6 @@ static void _populate_named_colors() { _named_colors.insert("chartreuse", Color(0.50, 1.00, 0.00)); _named_colors.insert("chocolate", Color(0.82, 0.41, 0.12)); _named_colors.insert("coral", Color(1.00, 0.50, 0.31)); - _named_colors.insert("cornflower", Color(0.39, 0.58, 0.93)); // for compatibility _named_colors.insert("cornflowerblue", Color(0.39, 0.58, 0.93)); _named_colors.insert("cornsilk", Color(1.00, 0.97, 0.86)); _named_colors.insert("crimson", Color(0.86, 0.08, 0.24)); @@ -167,7 +166,7 @@ static void _populate_named_colors() { _named_colors.insert("BLUE", Color(0.00, 0.00, 1.00)); _named_colors.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); _named_colors.insert("BROWN", Color(0.65, 0.16, 0.16)); - _named_colors.insert("BURLYWOOD", Color(0.87, 0.72, 0.53)); + _named_colors.insert("BURLY_WOOD", Color(0.87, 0.72, 0.53)); _named_colors.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); _named_colors.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); _named_colors.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); @@ -263,7 +262,7 @@ static void _populate_named_colors() { _named_colors.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); _named_colors.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); _named_colors.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); - _named_colors.insert("PALE_VIOLETRED", Color(0.86, 0.44, 0.58)); + _named_colors.insert("PALE_VIOLET_RED", Color(0.86, 0.44, 0.58)); _named_colors.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); _named_colors.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); _named_colors.insert("PERU", Color(0.80, 0.52, 0.25)); @@ -280,7 +279,7 @@ static void _populate_named_colors() { _named_colors.insert("SALMON", Color(0.98, 0.50, 0.45)); _named_colors.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); _named_colors.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); - _named_colors.insert("SEASHELL", Color(1.00, 0.96, 0.93)); + _named_colors.insert("SEA_SHELL", Color(1.00, 0.96, 0.93)); _named_colors.insert("SIENNA", Color(0.63, 0.32, 0.18)); _named_colors.insert("SILVER", Color(0.75, 0.75, 0.75)); _named_colors.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index 8f5cb741cf57..7dbce0ef5697 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs @@ -28,7 +28,6 @@ public static class Colors {"chartreuse", new Color(0.50f, 1.00f, 0.00f)}, {"chocolate", new Color(0.82f, 0.41f, 0.12f)}, {"coral", new Color(1.00f, 0.50f, 0.31f)}, - {"cornflower", new Color(0.39f, 0.58f, 0.93f)}, // for compatibility {"cornflowerblue", new Color(0.39f, 0.58f, 0.93f)}, {"cornsilk", new Color(1.00f, 0.97f, 0.86f)}, {"crimson", new Color(0.86f, 0.08f, 0.24f)}, @@ -172,13 +171,11 @@ public static class Colors public static Color Blue { get { return namedColors["blue"]; } } public static Color BlueViolet { get { return namedColors["blueviolet"]; } } public static Color Brown { get { return namedColors["brown"]; } } - public static Color BurlyWood { get { return namedColors["burlywood"]; } } // for compatibility - public static Color Burlywood { get { return namedColors["burlywood"]; } } + public static Color BurlyWood { get { return namedColors["burlywood"]; } } public static Color CadetBlue { get { return namedColors["cadetblue"]; } } public static Color Chartreuse { get { return namedColors["chartreuse"]; } } public static Color Chocolate { get { return namedColors["chocolate"]; } } public static Color Coral { get { return namedColors["coral"]; } } - public static Color Cornflower { get { return namedColors["cornflower"]; } } // for compatibility public static Color CornflowerBlue { get { return namedColors["cornflowerblue"]; } } public static Color Cornsilk { get { return namedColors["cornsilk"]; } } public static Color Crimson { get { return namedColors["crimson"]; } } @@ -239,7 +236,6 @@ public static class Colors public static Color LightSteelBlue { get { return namedColors["lightsteelblue"]; } } public static Color LightYellow { get { return namedColors["lightyellow"]; } } public static Color Lime { get { return namedColors["lime"]; } } - public static Color Limegreen { get { return namedColors["limegreen"]; } } // for compatibility public static Color LimeGreen { get { return namedColors["limegreen"]; } } public static Color Linen { get { return namedColors["linen"]; } } public static Color Magenta { get { return namedColors["magenta"]; } } @@ -284,8 +280,7 @@ public static class Colors public static Color Salmon { get { return namedColors["salmon"]; } } public static Color SandyBrown { get { return namedColors["sandybrown"]; } } public static Color SeaGreen { get { return namedColors["seagreen"]; } } - public static Color SeaShell { get { return namedColors["seashell"]; } } // for compatibility - public static Color Seashell { get { return namedColors["seashell"]; } } + public static Color SeaShell { get { return namedColors["seashell"]; } } public static Color Sienna { get { return namedColors["sienna"]; } } public static Color Silver { get { return namedColors["silver"]; } } public static Color SkyBlue { get { return namedColors["skyblue"]; } } From 530e98ddd82f94d2386faffe8ffae406038d1213 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 12:15:53 +0530 Subject: [PATCH 06/27] Replace the weird comment --- core/color_names.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/color_names.inc b/core/color_names.inc index fe569f849fc0..12e82326cbd9 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -153,7 +153,7 @@ static void _populate_named_colors() { _named_colors.insert("yellow", Color(1.00, 1.00, 0.00)); _named_colors.insert("yellowgreen", Color(0.60, 0.80, 0.20)); - // You're a pedant + // UPPERCASE_NAMES _named_colors.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); _named_colors.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); _named_colors.insert("AQUA", Color(0.00, 1.00, 1.00)); From 65d3e2ef530f2d59c554720fe1dadd9373761708 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 12:31:15 +0530 Subject: [PATCH 07/27] Arrange entries in lexicographic order --- core/color_names.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index 12e82326cbd9..9cd98e636f47 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -205,9 +205,7 @@ static void _populate_named_colors() { _named_colors.insert("GOLD", Color(1.00, 0.84, 0.00)); _named_colors.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); _named_colors.insert("GRAY", Color(0.75, 0.75, 0.75)); - _named_colors.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); _named_colors.insert("GREEN", Color(0.00, 1.00, 0.00)); - _named_colors.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); _named_colors.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); _named_colors.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); _named_colors.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); @@ -237,7 +235,6 @@ static void _populate_named_colors() { _named_colors.insert("LINEN", Color(0.98, 0.94, 0.90)); _named_colors.insert("MAGENTA", Color(1.00, 0.00, 1.00)); _named_colors.insert("MAROON", Color(0.69, 0.19, 0.38)); - _named_colors.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); _named_colors.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); _named_colors.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); _named_colors.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); @@ -270,7 +267,6 @@ static void _populate_named_colors() { _named_colors.insert("PLUM", Color(0.87, 0.63, 0.87)); _named_colors.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); _named_colors.insert("PURPLE", Color(0.63, 0.13, 0.94)); - _named_colors.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); _named_colors.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); _named_colors.insert("RED", Color(1.00, 0.00, 0.00)); _named_colors.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); @@ -292,9 +288,13 @@ static void _populate_named_colors() { _named_colors.insert("TEAL", Color(0.00, 0.50, 0.50)); _named_colors.insert("THISTLE", Color(0.85, 0.75, 0.85)); _named_colors.insert("TOMATO", Color(1.00, 0.39, 0.28)); - _named_colors.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); _named_colors.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); + _named_colors.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); _named_colors.insert("VIOLET", Color(0.93, 0.51, 0.93)); + _named_colors.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); + _named_colors.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); + _named_colors.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); + _named_colors.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); _named_colors.insert("WHEAT", Color(0.96, 0.87, 0.70)); _named_colors.insert("WHITE", Color(1.00, 1.00, 1.00)); _named_colors.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); From bd709b4180d35261a5df78adbd5379108573a850 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 12:31:30 +0530 Subject: [PATCH 08/27] Replace with UPPERCASE_NAMES --- doc/classes/Color.xml | 298 +++++++++++++++++++++--------------------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index b62fb673578b..6fa680c41b90 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -311,442 +311,442 @@ - + Alice blue color. - + Antique white color. - + Aqua color. - + Aquamarine color. - + Azure color. - + Beige color. - + Bisque color. - + Black color. - + Blanched almond color. - + Blue color. - + Blue violet color. - + Brown color. - - Burlywood color. + + Burly wood color. - + Cadet blue color. - + Chartreuse color. - + Chocolate color. - + Coral color. - - Cornflower Blue color. + + Cornflower blue color. - + Corn silk color. - + Crimson color. - + Cyan color. - + Dark blue color. - + Dark cyan color. - + Dark goldenrod color. - + Dark gray color. - + Dark green color. - + Dark khaki color. - + Dark magenta color. - + Dark olive green color. - + Dark orange color. - + Dark orchid color. - + Dark red color. - + Dark salmon color. - + Dark sea green color. - + Dark slate blue color. - + Dark slate gray color. - + Dark turquoise color. - + Dark violet color. - + Deep pink color. - + Deep sky blue color. - + Dim gray color. - + Dodger blue color. - + Firebrick color. - + Floral white color. - + Forest green color. - + Fuchsia color. - + Gainsboro color. - + Ghost white color. - + Gold color. - + Goldenrod color. - + Gray color. - + Green color. - + Green yellow color. - + Honeydew color. - + Hot pink color. - + Indian red color. - + Indigo color. - + Ivory color. - + Khaki color. - + Lavender color. - + Lavender blush color. - + Lawn green color. - + Lemon chiffon color. - + Light blue color. - + Light coral color. - + Light cyan color. - + Light goldenrod color. - + Light gray color. - + Light green color. - + Light pink color. - + Light salmon color. - + Light sea green color. - + Light sky blue color. - + Light slate gray color. - + Light steel blue color. - + Light yellow color. - + Lime color. - + Lime green color. - + Linen color. - + Magenta color. - + Maroon color. - + Medium aquamarine color. - + Medium blue color. - + Medium orchid color. - + Medium purple color. - + Medium sea green color. - + Medium slate blue color. - + Medium spring green color. - + Medium turquoise color. - + Medium violet red color. - + Midnight blue color. - + Mint cream color. - + Misty rose color. - + Moccasin color. - + Navajo white color. - + Navy blue color. - + Old lace color. - + Olive color. - + Olive drab color. - + Orange color. - + Orange red color. - + Orchid color. - + Pale goldenrod color. - + Pale green color. - + Pale turquoise color. - + Pale violet red color. - + Papaya whip color. - + Peach puff color. - + Peru color. - + Pink color. - + Plum color. - + Powder blue color. - + Purple color. - + Rebecca purple color. - + Red color. - + Rosy brown color. - + Royal blue color. - + Saddle brown color. - + Salmon color. - + Sandy brown color. - + Sea green color. - - Seashell color. + + Sea shell color. - + Sienna color. - + Silver color. - + Sky blue color. - + Slate blue color. - + Slate gray color. - + Snow color. - + Spring green color. - + Steel blue color. - + Tan color. - + Teal color. - + Thistle color. - + Tomato color. - + Transparent color (white with no alpha). - + Turquoise color. - + Violet color. - + Web gray color. - + Web green color. - + Web maroon color. - + Web purple color. - + Wheat color. - + White color. - + White smoke color. - + Yellow color. - + Yellow green color. From 0b0617e6b7947bf66d4a0eb5c6b78ee781a2c6e0 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 12:39:28 +0530 Subject: [PATCH 09/27] Separate UPPERCASE_NAMES map for sole use in _VariantCall --- core/color_names.inc | 301 +++++++++++++++++++++--------------------- core/variant_call.cpp | 4 +- 2 files changed, 156 insertions(+), 149 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index 9cd98e636f47..2ceabd85e782 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -2,6 +2,8 @@ #include "core/map.h" static Map _named_colors; +static Map _named_colors_uppercase; + static void _populate_named_colors() { if (!_named_colors.empty()) { return; @@ -152,152 +154,157 @@ static void _populate_named_colors() { _named_colors.insert("whitesmoke", Color(0.96, 0.96, 0.96)); _named_colors.insert("yellow", Color(1.00, 1.00, 0.00)); _named_colors.insert("yellowgreen", Color(0.60, 0.80, 0.20)); +} - // UPPERCASE_NAMES - _named_colors.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); - _named_colors.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); - _named_colors.insert("AQUA", Color(0.00, 1.00, 1.00)); - _named_colors.insert("AQUAMARINE", Color(0.50, 1.00, 0.83)); - _named_colors.insert("AZURE", Color(0.94, 1.00, 1.00)); - _named_colors.insert("BEIGE", Color(0.96, 0.96, 0.86)); - _named_colors.insert("BISQUE", Color(1.00, 0.89, 0.77)); - _named_colors.insert("BLACK", Color(0.00, 0.00, 0.00)); - _named_colors.insert("BLANCHED_ALMOND", Color(1.00, 0.92, 0.80)); - _named_colors.insert("BLUE", Color(0.00, 0.00, 1.00)); - _named_colors.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); - _named_colors.insert("BROWN", Color(0.65, 0.16, 0.16)); - _named_colors.insert("BURLY_WOOD", Color(0.87, 0.72, 0.53)); - _named_colors.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); - _named_colors.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); - _named_colors.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); - _named_colors.insert("CORAL", Color(1.00, 0.50, 0.31)); - _named_colors.insert("CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93)); - _named_colors.insert("CORNSILK", Color(1.00, 0.97, 0.86)); - _named_colors.insert("CRIMSON", Color(0.86, 0.08, 0.24)); - _named_colors.insert("CYAN", Color(0.00, 1.00, 1.00)); - _named_colors.insert("DARK_BLUE", Color(0.00, 0.00, 0.55)); - _named_colors.insert("DARK_CYAN", Color(0.00, 0.55, 0.55)); - _named_colors.insert("DARK_GOLDENROD", Color(0.72, 0.53, 0.04)); - _named_colors.insert("DARK_GRAY", Color(0.66, 0.66, 0.66)); - _named_colors.insert("DARK_GREEN", Color(0.00, 0.39, 0.00)); - _named_colors.insert("DARK_KHAKI", Color(0.74, 0.72, 0.42)); - _named_colors.insert("DARK_MAGENTA", Color(0.55, 0.00, 0.55)); - _named_colors.insert("DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18)); - _named_colors.insert("DARK_ORANGE", Color(1.00, 0.55, 0.00)); - _named_colors.insert("DARK_ORCHID", Color(0.60, 0.20, 0.80)); - _named_colors.insert("DARK_RED", Color(0.55, 0.00, 0.00)); - _named_colors.insert("DARK_SALMON", Color(0.91, 0.59, 0.48)); - _named_colors.insert("DARK_SEA_GREEN", Color(0.56, 0.74, 0.56)); - _named_colors.insert("DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55)); - _named_colors.insert("DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31)); - _named_colors.insert("DARK_TURQUOISE", Color(0.00, 0.81, 0.82)); - _named_colors.insert("DARK_VIOLET", Color(0.58, 0.00, 0.83)); - _named_colors.insert("DEEP_PINK", Color(1.00, 0.08, 0.58)); - _named_colors.insert("DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00)); - _named_colors.insert("DIM_GRAY", Color(0.41, 0.41, 0.41)); - _named_colors.insert("DODGER_BLUE", Color(0.12, 0.56, 1.00)); - _named_colors.insert("FIREBRICK", Color(0.70, 0.13, 0.13)); - _named_colors.insert("FLORAL_WHITE", Color(1.00, 0.98, 0.94)); - _named_colors.insert("FOREST_GREEN", Color(0.13, 0.55, 0.13)); - _named_colors.insert("FUCHSIA", Color(1.00, 0.00, 1.00)); - _named_colors.insert("GAINSBORO", Color(0.86, 0.86, 0.86)); - _named_colors.insert("GHOST_WHITE", Color(0.97, 0.97, 1.00)); - _named_colors.insert("GOLD", Color(1.00, 0.84, 0.00)); - _named_colors.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); - _named_colors.insert("GRAY", Color(0.75, 0.75, 0.75)); - _named_colors.insert("GREEN", Color(0.00, 1.00, 0.00)); - _named_colors.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); - _named_colors.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); - _named_colors.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); - _named_colors.insert("INDIAN_RED", Color(0.80, 0.36, 0.36)); - _named_colors.insert("INDIGO", Color(0.29, 0.00, 0.51)); - _named_colors.insert("IVORY", Color(1.00, 1.00, 0.94)); - _named_colors.insert("KHAKI", Color(0.94, 0.90, 0.55)); - _named_colors.insert("LAVENDER", Color(0.90, 0.90, 0.98)); - _named_colors.insert("LAVENDER_BLUSH", Color(1.00, 0.94, 0.96)); - _named_colors.insert("LAWN_GREEN", Color(0.49, 0.99, 0.00)); - _named_colors.insert("LEMON_CHIFFON", Color(1.00, 0.98, 0.80)); - _named_colors.insert("LIGHT_BLUE", Color(0.68, 0.85, 0.90)); - _named_colors.insert("LIGHT_CORAL", Color(0.94, 0.50, 0.50)); - _named_colors.insert("LIGHT_CYAN", Color(0.88, 1.00, 1.00)); - _named_colors.insert("LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82)); - _named_colors.insert("LIGHT_GRAY", Color(0.83, 0.83, 0.83)); - _named_colors.insert("LIGHT_GREEN", Color(0.56, 0.93, 0.56)); - _named_colors.insert("LIGHT_PINK", Color(1.00, 0.71, 0.76)); - _named_colors.insert("LIGHT_SALMON", Color(1.00, 0.63, 0.48)); - _named_colors.insert("LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67)); - _named_colors.insert("LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98)); - _named_colors.insert("LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60)); - _named_colors.insert("LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87)); - _named_colors.insert("LIGHT_YELLOW", Color(1.00, 1.00, 0.88)); - _named_colors.insert("LIME", Color(0.00, 1.00, 0.00)); - _named_colors.insert("LIME_GREEN", Color(0.20, 0.80, 0.20)); - _named_colors.insert("LINEN", Color(0.98, 0.94, 0.90)); - _named_colors.insert("MAGENTA", Color(1.00, 0.00, 1.00)); - _named_colors.insert("MAROON", Color(0.69, 0.19, 0.38)); - _named_colors.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); - _named_colors.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); - _named_colors.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); - _named_colors.insert("MEDIUM_PURPLE", Color(0.58, 0.44, 0.86)); - _named_colors.insert("MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44)); - _named_colors.insert("MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93)); - _named_colors.insert("MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60)); - _named_colors.insert("MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80)); - _named_colors.insert("MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52)); - _named_colors.insert("MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44)); - _named_colors.insert("MINT_CREAM", Color(0.96, 1.00, 0.98)); - _named_colors.insert("MISTY_ROSE", Color(1.00, 0.89, 0.88)); - _named_colors.insert("MOCCASIN", Color(1.00, 0.89, 0.71)); - _named_colors.insert("NAVAJO_WHITE", Color(1.00, 0.87, 0.68)); - _named_colors.insert("NAVY_BLUE", Color(0.00, 0.00, 0.50)); - _named_colors.insert("OLD_LACE", Color(0.99, 0.96, 0.90)); - _named_colors.insert("OLIVE", Color(0.50, 0.50, 0.00)); - _named_colors.insert("OLIVE_DRAB", Color(0.42, 0.56, 0.14)); - _named_colors.insert("ORANGE", Color(1.00, 0.65, 0.00)); - _named_colors.insert("ORANGE_RED", Color(1.00, 0.27, 0.00)); - _named_colors.insert("ORCHID", Color(0.85, 0.44, 0.84)); - _named_colors.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); - _named_colors.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); - _named_colors.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); - _named_colors.insert("PALE_VIOLET_RED", Color(0.86, 0.44, 0.58)); - _named_colors.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); - _named_colors.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); - _named_colors.insert("PERU", Color(0.80, 0.52, 0.25)); - _named_colors.insert("PINK", Color(1.00, 0.75, 0.80)); - _named_colors.insert("PLUM", Color(0.87, 0.63, 0.87)); - _named_colors.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); - _named_colors.insert("PURPLE", Color(0.63, 0.13, 0.94)); - _named_colors.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); - _named_colors.insert("RED", Color(1.00, 0.00, 0.00)); - _named_colors.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); - _named_colors.insert("ROYAL_BLUE", Color(0.25, 0.41, 0.88)); - _named_colors.insert("SADDLE_BROWN", Color(0.55, 0.27, 0.07)); - _named_colors.insert("SALMON", Color(0.98, 0.50, 0.45)); - _named_colors.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); - _named_colors.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); - _named_colors.insert("SEA_SHELL", Color(1.00, 0.96, 0.93)); - _named_colors.insert("SIENNA", Color(0.63, 0.32, 0.18)); - _named_colors.insert("SILVER", Color(0.75, 0.75, 0.75)); - _named_colors.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); - _named_colors.insert("SLATE_BLUE", Color(0.42, 0.35, 0.80)); - _named_colors.insert("SLATE_GRAY", Color(0.44, 0.50, 0.56)); - _named_colors.insert("SNOW", Color(1.00, 0.98, 0.98)); - _named_colors.insert("SPRING_GREEN", Color(0.00, 1.00, 0.50)); - _named_colors.insert("STEEL_BLUE", Color(0.27, 0.51, 0.71)); - _named_colors.insert("TAN", Color(0.82, 0.71, 0.55)); - _named_colors.insert("TEAL", Color(0.00, 0.50, 0.50)); - _named_colors.insert("THISTLE", Color(0.85, 0.75, 0.85)); - _named_colors.insert("TOMATO", Color(1.00, 0.39, 0.28)); - _named_colors.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); - _named_colors.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); - _named_colors.insert("VIOLET", Color(0.93, 0.51, 0.93)); - _named_colors.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); - _named_colors.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); - _named_colors.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); - _named_colors.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); - _named_colors.insert("WHEAT", Color(0.96, 0.87, 0.70)); - _named_colors.insert("WHITE", Color(1.00, 1.00, 1.00)); - _named_colors.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); - _named_colors.insert("YELLOW", Color(1.00, 1.00, 0.00)); - _named_colors.insert("YELLOW_GREEN", Color(0.60, 0.80, 0.20)); +// UPPERCASE_NAMES +static void _populate_named_colors_uppercase() { + if (!_named_colors_uppercase.empty()) { + return; + } + _named_colors_uppercase.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); + _named_colors_uppercase.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); + _named_colors_uppercase.insert("AQUA", Color(0.00, 1.00, 1.00)); + _named_colors_uppercase.insert("AQUAMARINE", Color(0.50, 1.00, 0.83)); + _named_colors_uppercase.insert("AZURE", Color(0.94, 1.00, 1.00)); + _named_colors_uppercase.insert("BEIGE", Color(0.96, 0.96, 0.86)); + _named_colors_uppercase.insert("BISQUE", Color(1.00, 0.89, 0.77)); + _named_colors_uppercase.insert("BLACK", Color(0.00, 0.00, 0.00)); + _named_colors_uppercase.insert("BLANCHED_ALMOND", Color(1.00, 0.92, 0.80)); + _named_colors_uppercase.insert("BLUE", Color(0.00, 0.00, 1.00)); + _named_colors_uppercase.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); + _named_colors_uppercase.insert("BROWN", Color(0.65, 0.16, 0.16)); + _named_colors_uppercase.insert("BURLY_WOOD", Color(0.87, 0.72, 0.53)); + _named_colors_uppercase.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); + _named_colors_uppercase.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); + _named_colors_uppercase.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); + _named_colors_uppercase.insert("CORAL", Color(1.00, 0.50, 0.31)); + _named_colors_uppercase.insert("CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93)); + _named_colors_uppercase.insert("CORNSILK", Color(1.00, 0.97, 0.86)); + _named_colors_uppercase.insert("CRIMSON", Color(0.86, 0.08, 0.24)); + _named_colors_uppercase.insert("CYAN", Color(0.00, 1.00, 1.00)); + _named_colors_uppercase.insert("DARK_BLUE", Color(0.00, 0.00, 0.55)); + _named_colors_uppercase.insert("DARK_CYAN", Color(0.00, 0.55, 0.55)); + _named_colors_uppercase.insert("DARK_GOLDENROD", Color(0.72, 0.53, 0.04)); + _named_colors_uppercase.insert("DARK_GRAY", Color(0.66, 0.66, 0.66)); + _named_colors_uppercase.insert("DARK_GREEN", Color(0.00, 0.39, 0.00)); + _named_colors_uppercase.insert("DARK_KHAKI", Color(0.74, 0.72, 0.42)); + _named_colors_uppercase.insert("DARK_MAGENTA", Color(0.55, 0.00, 0.55)); + _named_colors_uppercase.insert("DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18)); + _named_colors_uppercase.insert("DARK_ORANGE", Color(1.00, 0.55, 0.00)); + _named_colors_uppercase.insert("DARK_ORCHID", Color(0.60, 0.20, 0.80)); + _named_colors_uppercase.insert("DARK_RED", Color(0.55, 0.00, 0.00)); + _named_colors_uppercase.insert("DARK_SALMON", Color(0.91, 0.59, 0.48)); + _named_colors_uppercase.insert("DARK_SEA_GREEN", Color(0.56, 0.74, 0.56)); + _named_colors_uppercase.insert("DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55)); + _named_colors_uppercase.insert("DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31)); + _named_colors_uppercase.insert("DARK_TURQUOISE", Color(0.00, 0.81, 0.82)); + _named_colors_uppercase.insert("DARK_VIOLET", Color(0.58, 0.00, 0.83)); + _named_colors_uppercase.insert("DEEP_PINK", Color(1.00, 0.08, 0.58)); + _named_colors_uppercase.insert("DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00)); + _named_colors_uppercase.insert("DIM_GRAY", Color(0.41, 0.41, 0.41)); + _named_colors_uppercase.insert("DODGER_BLUE", Color(0.12, 0.56, 1.00)); + _named_colors_uppercase.insert("FIREBRICK", Color(0.70, 0.13, 0.13)); + _named_colors_uppercase.insert("FLORAL_WHITE", Color(1.00, 0.98, 0.94)); + _named_colors_uppercase.insert("FOREST_GREEN", Color(0.13, 0.55, 0.13)); + _named_colors_uppercase.insert("FUCHSIA", Color(1.00, 0.00, 1.00)); + _named_colors_uppercase.insert("GAINSBORO", Color(0.86, 0.86, 0.86)); + _named_colors_uppercase.insert("GHOST_WHITE", Color(0.97, 0.97, 1.00)); + _named_colors_uppercase.insert("GOLD", Color(1.00, 0.84, 0.00)); + _named_colors_uppercase.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); + _named_colors_uppercase.insert("GRAY", Color(0.75, 0.75, 0.75)); + _named_colors_uppercase.insert("GREEN", Color(0.00, 1.00, 0.00)); + _named_colors_uppercase.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); + _named_colors_uppercase.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); + _named_colors_uppercase.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); + _named_colors_uppercase.insert("INDIAN_RED", Color(0.80, 0.36, 0.36)); + _named_colors_uppercase.insert("INDIGO", Color(0.29, 0.00, 0.51)); + _named_colors_uppercase.insert("IVORY", Color(1.00, 1.00, 0.94)); + _named_colors_uppercase.insert("KHAKI", Color(0.94, 0.90, 0.55)); + _named_colors_uppercase.insert("LAVENDER", Color(0.90, 0.90, 0.98)); + _named_colors_uppercase.insert("LAVENDER_BLUSH", Color(1.00, 0.94, 0.96)); + _named_colors_uppercase.insert("LAWN_GREEN", Color(0.49, 0.99, 0.00)); + _named_colors_uppercase.insert("LEMON_CHIFFON", Color(1.00, 0.98, 0.80)); + _named_colors_uppercase.insert("LIGHT_BLUE", Color(0.68, 0.85, 0.90)); + _named_colors_uppercase.insert("LIGHT_CORAL", Color(0.94, 0.50, 0.50)); + _named_colors_uppercase.insert("LIGHT_CYAN", Color(0.88, 1.00, 1.00)); + _named_colors_uppercase.insert("LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82)); + _named_colors_uppercase.insert("LIGHT_GRAY", Color(0.83, 0.83, 0.83)); + _named_colors_uppercase.insert("LIGHT_GREEN", Color(0.56, 0.93, 0.56)); + _named_colors_uppercase.insert("LIGHT_PINK", Color(1.00, 0.71, 0.76)); + _named_colors_uppercase.insert("LIGHT_SALMON", Color(1.00, 0.63, 0.48)); + _named_colors_uppercase.insert("LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67)); + _named_colors_uppercase.insert("LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98)); + _named_colors_uppercase.insert("LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60)); + _named_colors_uppercase.insert("LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87)); + _named_colors_uppercase.insert("LIGHT_YELLOW", Color(1.00, 1.00, 0.88)); + _named_colors_uppercase.insert("LIME", Color(0.00, 1.00, 0.00)); + _named_colors_uppercase.insert("LIME_GREEN", Color(0.20, 0.80, 0.20)); + _named_colors_uppercase.insert("LINEN", Color(0.98, 0.94, 0.90)); + _named_colors_uppercase.insert("MAGENTA", Color(1.00, 0.00, 1.00)); + _named_colors_uppercase.insert("MAROON", Color(0.69, 0.19, 0.38)); + _named_colors_uppercase.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); + _named_colors_uppercase.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); + _named_colors_uppercase.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); + _named_colors_uppercase.insert("MEDIUM_PURPLE", Color(0.58, 0.44, 0.86)); + _named_colors_uppercase.insert("MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44)); + _named_colors_uppercase.insert("MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93)); + _named_colors_uppercase.insert("MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60)); + _named_colors_uppercase.insert("MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80)); + _named_colors_uppercase.insert("MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52)); + _named_colors_uppercase.insert("MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44)); + _named_colors_uppercase.insert("MINT_CREAM", Color(0.96, 1.00, 0.98)); + _named_colors_uppercase.insert("MISTY_ROSE", Color(1.00, 0.89, 0.88)); + _named_colors_uppercase.insert("MOCCASIN", Color(1.00, 0.89, 0.71)); + _named_colors_uppercase.insert("NAVAJO_WHITE", Color(1.00, 0.87, 0.68)); + _named_colors_uppercase.insert("NAVY_BLUE", Color(0.00, 0.00, 0.50)); + _named_colors_uppercase.insert("OLD_LACE", Color(0.99, 0.96, 0.90)); + _named_colors_uppercase.insert("OLIVE", Color(0.50, 0.50, 0.00)); + _named_colors_uppercase.insert("OLIVE_DRAB", Color(0.42, 0.56, 0.14)); + _named_colors_uppercase.insert("ORANGE", Color(1.00, 0.65, 0.00)); + _named_colors_uppercase.insert("ORANGE_RED", Color(1.00, 0.27, 0.00)); + _named_colors_uppercase.insert("ORCHID", Color(0.85, 0.44, 0.84)); + _named_colors_uppercase.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); + _named_colors_uppercase.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); + _named_colors_uppercase.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); + _named_colors_uppercase.insert("PALE_VIOLET_RED", Color(0.86, 0.44, 0.58)); + _named_colors_uppercase.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); + _named_colors_uppercase.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); + _named_colors_uppercase.insert("PERU", Color(0.80, 0.52, 0.25)); + _named_colors_uppercase.insert("PINK", Color(1.00, 0.75, 0.80)); + _named_colors_uppercase.insert("PLUM", Color(0.87, 0.63, 0.87)); + _named_colors_uppercase.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); + _named_colors_uppercase.insert("PURPLE", Color(0.63, 0.13, 0.94)); + _named_colors_uppercase.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); + _named_colors_uppercase.insert("RED", Color(1.00, 0.00, 0.00)); + _named_colors_uppercase.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); + _named_colors_uppercase.insert("ROYAL_BLUE", Color(0.25, 0.41, 0.88)); + _named_colors_uppercase.insert("SADDLE_BROWN", Color(0.55, 0.27, 0.07)); + _named_colors_uppercase.insert("SALMON", Color(0.98, 0.50, 0.45)); + _named_colors_uppercase.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); + _named_colors_uppercase.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); + _named_colors_uppercase.insert("SEA_SHELL", Color(1.00, 0.96, 0.93)); + _named_colors_uppercase.insert("SIENNA", Color(0.63, 0.32, 0.18)); + _named_colors_uppercase.insert("SILVER", Color(0.75, 0.75, 0.75)); + _named_colors_uppercase.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); + _named_colors_uppercase.insert("SLATE_BLUE", Color(0.42, 0.35, 0.80)); + _named_colors_uppercase.insert("SLATE_GRAY", Color(0.44, 0.50, 0.56)); + _named_colors_uppercase.insert("SNOW", Color(1.00, 0.98, 0.98)); + _named_colors_uppercase.insert("SPRING_GREEN", Color(0.00, 1.00, 0.50)); + _named_colors_uppercase.insert("STEEL_BLUE", Color(0.27, 0.51, 0.71)); + _named_colors_uppercase.insert("TAN", Color(0.82, 0.71, 0.55)); + _named_colors_uppercase.insert("TEAL", Color(0.00, 0.50, 0.50)); + _named_colors_uppercase.insert("THISTLE", Color(0.85, 0.75, 0.85)); + _named_colors_uppercase.insert("TOMATO", Color(1.00, 0.39, 0.28)); + _named_colors_uppercase.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); + _named_colors_uppercase.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); + _named_colors_uppercase.insert("VIOLET", Color(0.93, 0.51, 0.93)); + _named_colors_uppercase.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); + _named_colors_uppercase.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); + _named_colors_uppercase.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); + _named_colors_uppercase.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); + _named_colors_uppercase.insert("WHEAT", Color(0.96, 0.87, 0.70)); + _named_colors_uppercase.insert("WHITE", Color(1.00, 1.00, 1.00)); + _named_colors_uppercase.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); + _named_colors_uppercase.insert("YELLOW", Color(1.00, 1.00, 0.00)); + _named_colors_uppercase.insert("YELLOW_GREEN", Color(0.60, 0.80, 0.20)); } diff --git a/core/variant_call.cpp b/core/variant_call.cpp index b96fd0c10373..2ddb8cefaadc 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -2331,8 +2331,8 @@ void register_variant_methods() { /* REGISTER CONSTANTS */ - _populate_named_colors(); - for (Map::Element *color = _named_colors.front(); color; color = color->next()) { + _populate_named_colors_uppercase(); + for (Map::Element *color = _named_colors_uppercase.front(); color; color = color->next()) { _VariantCall::add_variant_constant(Variant::COLOR, color->key(), color->value()); } From 7458a377126146fb37cd11ff92895de892bd839b Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 14:11:19 +0530 Subject: [PATCH 10/27] Acknowledge Microsoft .NET docs --- core/color_names.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/core/color_names.inc b/core/color_names.inc index 2ceabd85e782..c3b22b282689 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -1,4 +1,5 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names +// and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 #include "core/map.h" static Map _named_colors; From c5992d98deb8416489563618051a1c34d0788c4d Mon Sep 17 00:00:00 2001 From: Vivraan Date: Wed, 5 Aug 2020 14:35:10 +0530 Subject: [PATCH 11/27] Implement new normalisation, change back _VariantCall, remove old names --- core/color.cpp | 13 +- core/color_names.inc | 447 ++++++++++++++---------------------------- core/variant_call.cpp | 4 +- 3 files changed, 157 insertions(+), 307 deletions(-) diff --git a/core/color.cpp b/core/color.cpp index 27a2d0af5cf1..9a1756e630e5 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -398,12 +398,17 @@ Color Color::named(const String &p_name) { } String name = p_name; // Normalize name - name = name.replace(" ", ""); - name = name.replace("-", ""); - name = name.replace("_", ""); + // name = name.replace(" ", ""); + // name = name.replace("-", ""); + // name = name.replace("_", ""); + // name = name.replace("'", ""); + // name = name.replace(".", ""); + // name = name.to_lower(); + name = name.replace(" ", "_"); + name = name.replace("-", "_"); name = name.replace("'", ""); name = name.replace(".", ""); - name = name.to_lower(); + name = name.to_upper(); const Map::Element *color = _named_colors.find(name); ERR_FAIL_NULL_V_MSG(color, Color(), "Invalid color name: " + p_name + "."); diff --git a/core/color_names.inc b/core/color_names.inc index c3b22b282689..dfa9f24e1653 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -3,309 +3,154 @@ #include "core/map.h" static Map _named_colors; -static Map _named_colors_uppercase; - static void _populate_named_colors() { if (!_named_colors.empty()) { return; } - _named_colors.insert("aliceblue", Color(0.94, 0.97, 1.00)); - _named_colors.insert("antiquewhite", Color(0.98, 0.92, 0.84)); - _named_colors.insert("aqua", Color(0.00, 1.00, 1.00)); - _named_colors.insert("aquamarine", Color(0.50, 1.00, 0.83)); - _named_colors.insert("azure", Color(0.94, 1.00, 1.00)); - _named_colors.insert("beige", Color(0.96, 0.96, 0.86)); - _named_colors.insert("bisque", Color(1.00, 0.89, 0.77)); - _named_colors.insert("black", Color(0.00, 0.00, 0.00)); - _named_colors.insert("blanchedalmond", Color(1.00, 0.92, 0.80)); - _named_colors.insert("blue", Color(0.00, 0.00, 1.00)); - _named_colors.insert("blueviolet", Color(0.54, 0.17, 0.89)); - _named_colors.insert("brown", Color(0.65, 0.16, 0.16)); - _named_colors.insert("burlywood", Color(0.87, 0.72, 0.53)); - _named_colors.insert("cadetblue", Color(0.37, 0.62, 0.63)); - _named_colors.insert("chartreuse", Color(0.50, 1.00, 0.00)); - _named_colors.insert("chocolate", Color(0.82, 0.41, 0.12)); - _named_colors.insert("coral", Color(1.00, 0.50, 0.31)); - _named_colors.insert("cornflowerblue", Color(0.39, 0.58, 0.93)); - _named_colors.insert("cornsilk", Color(1.00, 0.97, 0.86)); - _named_colors.insert("crimson", Color(0.86, 0.08, 0.24)); - _named_colors.insert("cyan", Color(0.00, 1.00, 1.00)); - _named_colors.insert("darkblue", Color(0.00, 0.00, 0.55)); - _named_colors.insert("darkcyan", Color(0.00, 0.55, 0.55)); - _named_colors.insert("darkgoldenrod", Color(0.72, 0.53, 0.04)); - _named_colors.insert("darkgray", Color(0.66, 0.66, 0.66)); - _named_colors.insert("darkgreen", Color(0.00, 0.39, 0.00)); - _named_colors.insert("darkkhaki", Color(0.74, 0.72, 0.42)); - _named_colors.insert("darkmagenta", Color(0.55, 0.00, 0.55)); - _named_colors.insert("darkolivegreen", Color(0.33, 0.42, 0.18)); - _named_colors.insert("darkorange", Color(1.00, 0.55, 0.00)); - _named_colors.insert("darkorchid", Color(0.60, 0.20, 0.80)); - _named_colors.insert("darkred", Color(0.55, 0.00, 0.00)); - _named_colors.insert("darksalmon", Color(0.91, 0.59, 0.48)); - _named_colors.insert("darkseagreen", Color(0.56, 0.74, 0.56)); - _named_colors.insert("darkslateblue", Color(0.28, 0.24, 0.55)); - _named_colors.insert("darkslategray", Color(0.18, 0.31, 0.31)); - _named_colors.insert("darkturquoise", Color(0.00, 0.81, 0.82)); - _named_colors.insert("darkviolet", Color(0.58, 0.00, 0.83)); - _named_colors.insert("deeppink", Color(1.00, 0.08, 0.58)); - _named_colors.insert("deepskyblue", Color(0.00, 0.75, 1.00)); - _named_colors.insert("dimgray", Color(0.41, 0.41, 0.41)); - _named_colors.insert("dodgerblue", Color(0.12, 0.56, 1.00)); - _named_colors.insert("firebrick", Color(0.70, 0.13, 0.13)); - _named_colors.insert("floralwhite", Color(1.00, 0.98, 0.94)); - _named_colors.insert("forestgreen", Color(0.13, 0.55, 0.13)); - _named_colors.insert("fuchsia", Color(1.00, 0.00, 1.00)); - _named_colors.insert("gainsboro", Color(0.86, 0.86, 0.86)); - _named_colors.insert("ghostwhite", Color(0.97, 0.97, 1.00)); - _named_colors.insert("gold", Color(1.00, 0.84, 0.00)); - _named_colors.insert("goldenrod", Color(0.85, 0.65, 0.13)); - _named_colors.insert("gray", Color(0.75, 0.75, 0.75)); - _named_colors.insert("webgray", Color(0.50, 0.50, 0.50)); - _named_colors.insert("green", Color(0.00, 1.00, 0.00)); - _named_colors.insert("webgreen", Color(0.00, 0.50, 0.00)); - _named_colors.insert("greenyellow", Color(0.68, 1.00, 0.18)); - _named_colors.insert("honeydew", Color(0.94, 1.00, 0.94)); - _named_colors.insert("hotpink", Color(1.00, 0.41, 0.71)); - _named_colors.insert("indianred", Color(0.80, 0.36, 0.36)); - _named_colors.insert("indigo", Color(0.29, 0.00, 0.51)); - _named_colors.insert("ivory", Color(1.00, 1.00, 0.94)); - _named_colors.insert("khaki", Color(0.94, 0.90, 0.55)); - _named_colors.insert("lavender", Color(0.90, 0.90, 0.98)); - _named_colors.insert("lavenderblush", Color(1.00, 0.94, 0.96)); - _named_colors.insert("lawngreen", Color(0.49, 0.99, 0.00)); - _named_colors.insert("lemonchiffon", Color(1.00, 0.98, 0.80)); - _named_colors.insert("lightblue", Color(0.68, 0.85, 0.90)); - _named_colors.insert("lightcoral", Color(0.94, 0.50, 0.50)); - _named_colors.insert("lightcyan", Color(0.88, 1.00, 1.00)); - _named_colors.insert("lightgoldenrod", Color(0.98, 0.98, 0.82)); - _named_colors.insert("lightgray", Color(0.83, 0.83, 0.83)); - _named_colors.insert("lightgreen", Color(0.56, 0.93, 0.56)); - _named_colors.insert("lightpink", Color(1.00, 0.71, 0.76)); - _named_colors.insert("lightsalmon", Color(1.00, 0.63, 0.48)); - _named_colors.insert("lightseagreen", Color(0.13, 0.70, 0.67)); - _named_colors.insert("lightskyblue", Color(0.53, 0.81, 0.98)); - _named_colors.insert("lightslategray", Color(0.47, 0.53, 0.60)); - _named_colors.insert("lightsteelblue", Color(0.69, 0.77, 0.87)); - _named_colors.insert("lightyellow", Color(1.00, 1.00, 0.88)); - _named_colors.insert("lime", Color(0.00, 1.00, 0.00)); - _named_colors.insert("limegreen", Color(0.20, 0.80, 0.20)); - _named_colors.insert("linen", Color(0.98, 0.94, 0.90)); - _named_colors.insert("magenta", Color(1.00, 0.00, 1.00)); - _named_colors.insert("maroon", Color(0.69, 0.19, 0.38)); - _named_colors.insert("webmaroon", Color(0.50, 0.00, 0.00)); - _named_colors.insert("mediumaquamarine", Color(0.40, 0.80, 0.67)); - _named_colors.insert("mediumblue", Color(0.00, 0.00, 0.80)); - _named_colors.insert("mediumorchid", Color(0.73, 0.33, 0.83)); - _named_colors.insert("mediumpurple", Color(0.58, 0.44, 0.86)); - _named_colors.insert("mediumseagreen", Color(0.24, 0.70, 0.44)); - _named_colors.insert("mediumslateblue", Color(0.48, 0.41, 0.93)); - _named_colors.insert("mediumspringgreen", Color(0.00, 0.98, 0.60)); - _named_colors.insert("mediumturquoise", Color(0.28, 0.82, 0.80)); - _named_colors.insert("mediumvioletred", Color(0.78, 0.08, 0.52)); - _named_colors.insert("midnightblue", Color(0.10, 0.10, 0.44)); - _named_colors.insert("mintcream", Color(0.96, 1.00, 0.98)); - _named_colors.insert("mistyrose", Color(1.00, 0.89, 0.88)); - _named_colors.insert("moccasin", Color(1.00, 0.89, 0.71)); - _named_colors.insert("navajowhite", Color(1.00, 0.87, 0.68)); - _named_colors.insert("navyblue", Color(0.00, 0.00, 0.50)); - _named_colors.insert("oldlace", Color(0.99, 0.96, 0.90)); - _named_colors.insert("olive", Color(0.50, 0.50, 0.00)); - _named_colors.insert("olivedrab", Color(0.42, 0.56, 0.14)); - _named_colors.insert("orange", Color(1.00, 0.65, 0.00)); - _named_colors.insert("orangered", Color(1.00, 0.27, 0.00)); - _named_colors.insert("orchid", Color(0.85, 0.44, 0.84)); - _named_colors.insert("palegoldenrod", Color(0.93, 0.91, 0.67)); - _named_colors.insert("palegreen", Color(0.60, 0.98, 0.60)); - _named_colors.insert("paleturquoise", Color(0.69, 0.93, 0.93)); - _named_colors.insert("palevioletred", Color(0.86, 0.44, 0.58)); - _named_colors.insert("papayawhip", Color(1.00, 0.94, 0.84)); - _named_colors.insert("peachpuff", Color(1.00, 0.85, 0.73)); - _named_colors.insert("peru", Color(0.80, 0.52, 0.25)); - _named_colors.insert("pink", Color(1.00, 0.75, 0.80)); - _named_colors.insert("plum", Color(0.87, 0.63, 0.87)); - _named_colors.insert("powderblue", Color(0.69, 0.88, 0.90)); - _named_colors.insert("purple", Color(0.63, 0.13, 0.94)); - _named_colors.insert("webpurple", Color(0.50, 0.00, 0.50)); - _named_colors.insert("rebeccapurple", Color(0.40, 0.20, 0.60)); - _named_colors.insert("red", Color(1.00, 0.00, 0.00)); - _named_colors.insert("rosybrown", Color(0.74, 0.56, 0.56)); - _named_colors.insert("royalblue", Color(0.25, 0.41, 0.88)); - _named_colors.insert("saddlebrown", Color(0.55, 0.27, 0.07)); - _named_colors.insert("salmon", Color(0.98, 0.50, 0.45)); - _named_colors.insert("sandybrown", Color(0.96, 0.64, 0.38)); - _named_colors.insert("seagreen", Color(0.18, 0.55, 0.34)); - _named_colors.insert("seashell", Color(1.00, 0.96, 0.93)); - _named_colors.insert("sienna", Color(0.63, 0.32, 0.18)); - _named_colors.insert("silver", Color(0.75, 0.75, 0.75)); - _named_colors.insert("skyblue", Color(0.53, 0.81, 0.92)); - _named_colors.insert("slateblue", Color(0.42, 0.35, 0.80)); - _named_colors.insert("slategray", Color(0.44, 0.50, 0.56)); - _named_colors.insert("snow", Color(1.00, 0.98, 0.98)); - _named_colors.insert("springgreen", Color(0.00, 1.00, 0.50)); - _named_colors.insert("steelblue", Color(0.27, 0.51, 0.71)); - _named_colors.insert("tan", Color(0.82, 0.71, 0.55)); - _named_colors.insert("teal", Color(0.00, 0.50, 0.50)); - _named_colors.insert("thistle", Color(0.85, 0.75, 0.85)); - _named_colors.insert("tomato", Color(1.00, 0.39, 0.28)); - _named_colors.insert("turquoise", Color(0.25, 0.88, 0.82)); - _named_colors.insert("transparent", Color(1.00, 1.00, 1.00, 0.00)); - _named_colors.insert("violet", Color(0.93, 0.51, 0.93)); - _named_colors.insert("wheat", Color(0.96, 0.87, 0.70)); - _named_colors.insert("white", Color(1.00, 1.00, 1.00)); - _named_colors.insert("whitesmoke", Color(0.96, 0.96, 0.96)); - _named_colors.insert("yellow", Color(1.00, 1.00, 0.00)); - _named_colors.insert("yellowgreen", Color(0.60, 0.80, 0.20)); -} - -// UPPERCASE_NAMES -static void _populate_named_colors_uppercase() { - if (!_named_colors_uppercase.empty()) { - return; - } - _named_colors_uppercase.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); - _named_colors_uppercase.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); - _named_colors_uppercase.insert("AQUA", Color(0.00, 1.00, 1.00)); - _named_colors_uppercase.insert("AQUAMARINE", Color(0.50, 1.00, 0.83)); - _named_colors_uppercase.insert("AZURE", Color(0.94, 1.00, 1.00)); - _named_colors_uppercase.insert("BEIGE", Color(0.96, 0.96, 0.86)); - _named_colors_uppercase.insert("BISQUE", Color(1.00, 0.89, 0.77)); - _named_colors_uppercase.insert("BLACK", Color(0.00, 0.00, 0.00)); - _named_colors_uppercase.insert("BLANCHED_ALMOND", Color(1.00, 0.92, 0.80)); - _named_colors_uppercase.insert("BLUE", Color(0.00, 0.00, 1.00)); - _named_colors_uppercase.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); - _named_colors_uppercase.insert("BROWN", Color(0.65, 0.16, 0.16)); - _named_colors_uppercase.insert("BURLY_WOOD", Color(0.87, 0.72, 0.53)); - _named_colors_uppercase.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); - _named_colors_uppercase.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); - _named_colors_uppercase.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); - _named_colors_uppercase.insert("CORAL", Color(1.00, 0.50, 0.31)); - _named_colors_uppercase.insert("CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93)); - _named_colors_uppercase.insert("CORNSILK", Color(1.00, 0.97, 0.86)); - _named_colors_uppercase.insert("CRIMSON", Color(0.86, 0.08, 0.24)); - _named_colors_uppercase.insert("CYAN", Color(0.00, 1.00, 1.00)); - _named_colors_uppercase.insert("DARK_BLUE", Color(0.00, 0.00, 0.55)); - _named_colors_uppercase.insert("DARK_CYAN", Color(0.00, 0.55, 0.55)); - _named_colors_uppercase.insert("DARK_GOLDENROD", Color(0.72, 0.53, 0.04)); - _named_colors_uppercase.insert("DARK_GRAY", Color(0.66, 0.66, 0.66)); - _named_colors_uppercase.insert("DARK_GREEN", Color(0.00, 0.39, 0.00)); - _named_colors_uppercase.insert("DARK_KHAKI", Color(0.74, 0.72, 0.42)); - _named_colors_uppercase.insert("DARK_MAGENTA", Color(0.55, 0.00, 0.55)); - _named_colors_uppercase.insert("DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18)); - _named_colors_uppercase.insert("DARK_ORANGE", Color(1.00, 0.55, 0.00)); - _named_colors_uppercase.insert("DARK_ORCHID", Color(0.60, 0.20, 0.80)); - _named_colors_uppercase.insert("DARK_RED", Color(0.55, 0.00, 0.00)); - _named_colors_uppercase.insert("DARK_SALMON", Color(0.91, 0.59, 0.48)); - _named_colors_uppercase.insert("DARK_SEA_GREEN", Color(0.56, 0.74, 0.56)); - _named_colors_uppercase.insert("DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55)); - _named_colors_uppercase.insert("DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31)); - _named_colors_uppercase.insert("DARK_TURQUOISE", Color(0.00, 0.81, 0.82)); - _named_colors_uppercase.insert("DARK_VIOLET", Color(0.58, 0.00, 0.83)); - _named_colors_uppercase.insert("DEEP_PINK", Color(1.00, 0.08, 0.58)); - _named_colors_uppercase.insert("DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00)); - _named_colors_uppercase.insert("DIM_GRAY", Color(0.41, 0.41, 0.41)); - _named_colors_uppercase.insert("DODGER_BLUE", Color(0.12, 0.56, 1.00)); - _named_colors_uppercase.insert("FIREBRICK", Color(0.70, 0.13, 0.13)); - _named_colors_uppercase.insert("FLORAL_WHITE", Color(1.00, 0.98, 0.94)); - _named_colors_uppercase.insert("FOREST_GREEN", Color(0.13, 0.55, 0.13)); - _named_colors_uppercase.insert("FUCHSIA", Color(1.00, 0.00, 1.00)); - _named_colors_uppercase.insert("GAINSBORO", Color(0.86, 0.86, 0.86)); - _named_colors_uppercase.insert("GHOST_WHITE", Color(0.97, 0.97, 1.00)); - _named_colors_uppercase.insert("GOLD", Color(1.00, 0.84, 0.00)); - _named_colors_uppercase.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); - _named_colors_uppercase.insert("GRAY", Color(0.75, 0.75, 0.75)); - _named_colors_uppercase.insert("GREEN", Color(0.00, 1.00, 0.00)); - _named_colors_uppercase.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); - _named_colors_uppercase.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); - _named_colors_uppercase.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); - _named_colors_uppercase.insert("INDIAN_RED", Color(0.80, 0.36, 0.36)); - _named_colors_uppercase.insert("INDIGO", Color(0.29, 0.00, 0.51)); - _named_colors_uppercase.insert("IVORY", Color(1.00, 1.00, 0.94)); - _named_colors_uppercase.insert("KHAKI", Color(0.94, 0.90, 0.55)); - _named_colors_uppercase.insert("LAVENDER", Color(0.90, 0.90, 0.98)); - _named_colors_uppercase.insert("LAVENDER_BLUSH", Color(1.00, 0.94, 0.96)); - _named_colors_uppercase.insert("LAWN_GREEN", Color(0.49, 0.99, 0.00)); - _named_colors_uppercase.insert("LEMON_CHIFFON", Color(1.00, 0.98, 0.80)); - _named_colors_uppercase.insert("LIGHT_BLUE", Color(0.68, 0.85, 0.90)); - _named_colors_uppercase.insert("LIGHT_CORAL", Color(0.94, 0.50, 0.50)); - _named_colors_uppercase.insert("LIGHT_CYAN", Color(0.88, 1.00, 1.00)); - _named_colors_uppercase.insert("LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82)); - _named_colors_uppercase.insert("LIGHT_GRAY", Color(0.83, 0.83, 0.83)); - _named_colors_uppercase.insert("LIGHT_GREEN", Color(0.56, 0.93, 0.56)); - _named_colors_uppercase.insert("LIGHT_PINK", Color(1.00, 0.71, 0.76)); - _named_colors_uppercase.insert("LIGHT_SALMON", Color(1.00, 0.63, 0.48)); - _named_colors_uppercase.insert("LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67)); - _named_colors_uppercase.insert("LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98)); - _named_colors_uppercase.insert("LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60)); - _named_colors_uppercase.insert("LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87)); - _named_colors_uppercase.insert("LIGHT_YELLOW", Color(1.00, 1.00, 0.88)); - _named_colors_uppercase.insert("LIME", Color(0.00, 1.00, 0.00)); - _named_colors_uppercase.insert("LIME_GREEN", Color(0.20, 0.80, 0.20)); - _named_colors_uppercase.insert("LINEN", Color(0.98, 0.94, 0.90)); - _named_colors_uppercase.insert("MAGENTA", Color(1.00, 0.00, 1.00)); - _named_colors_uppercase.insert("MAROON", Color(0.69, 0.19, 0.38)); - _named_colors_uppercase.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); - _named_colors_uppercase.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); - _named_colors_uppercase.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); - _named_colors_uppercase.insert("MEDIUM_PURPLE", Color(0.58, 0.44, 0.86)); - _named_colors_uppercase.insert("MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44)); - _named_colors_uppercase.insert("MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93)); - _named_colors_uppercase.insert("MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60)); - _named_colors_uppercase.insert("MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80)); - _named_colors_uppercase.insert("MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52)); - _named_colors_uppercase.insert("MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44)); - _named_colors_uppercase.insert("MINT_CREAM", Color(0.96, 1.00, 0.98)); - _named_colors_uppercase.insert("MISTY_ROSE", Color(1.00, 0.89, 0.88)); - _named_colors_uppercase.insert("MOCCASIN", Color(1.00, 0.89, 0.71)); - _named_colors_uppercase.insert("NAVAJO_WHITE", Color(1.00, 0.87, 0.68)); - _named_colors_uppercase.insert("NAVY_BLUE", Color(0.00, 0.00, 0.50)); - _named_colors_uppercase.insert("OLD_LACE", Color(0.99, 0.96, 0.90)); - _named_colors_uppercase.insert("OLIVE", Color(0.50, 0.50, 0.00)); - _named_colors_uppercase.insert("OLIVE_DRAB", Color(0.42, 0.56, 0.14)); - _named_colors_uppercase.insert("ORANGE", Color(1.00, 0.65, 0.00)); - _named_colors_uppercase.insert("ORANGE_RED", Color(1.00, 0.27, 0.00)); - _named_colors_uppercase.insert("ORCHID", Color(0.85, 0.44, 0.84)); - _named_colors_uppercase.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); - _named_colors_uppercase.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); - _named_colors_uppercase.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); - _named_colors_uppercase.insert("PALE_VIOLET_RED", Color(0.86, 0.44, 0.58)); - _named_colors_uppercase.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); - _named_colors_uppercase.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); - _named_colors_uppercase.insert("PERU", Color(0.80, 0.52, 0.25)); - _named_colors_uppercase.insert("PINK", Color(1.00, 0.75, 0.80)); - _named_colors_uppercase.insert("PLUM", Color(0.87, 0.63, 0.87)); - _named_colors_uppercase.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); - _named_colors_uppercase.insert("PURPLE", Color(0.63, 0.13, 0.94)); - _named_colors_uppercase.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); - _named_colors_uppercase.insert("RED", Color(1.00, 0.00, 0.00)); - _named_colors_uppercase.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); - _named_colors_uppercase.insert("ROYAL_BLUE", Color(0.25, 0.41, 0.88)); - _named_colors_uppercase.insert("SADDLE_BROWN", Color(0.55, 0.27, 0.07)); - _named_colors_uppercase.insert("SALMON", Color(0.98, 0.50, 0.45)); - _named_colors_uppercase.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); - _named_colors_uppercase.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); - _named_colors_uppercase.insert("SEA_SHELL", Color(1.00, 0.96, 0.93)); - _named_colors_uppercase.insert("SIENNA", Color(0.63, 0.32, 0.18)); - _named_colors_uppercase.insert("SILVER", Color(0.75, 0.75, 0.75)); - _named_colors_uppercase.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); - _named_colors_uppercase.insert("SLATE_BLUE", Color(0.42, 0.35, 0.80)); - _named_colors_uppercase.insert("SLATE_GRAY", Color(0.44, 0.50, 0.56)); - _named_colors_uppercase.insert("SNOW", Color(1.00, 0.98, 0.98)); - _named_colors_uppercase.insert("SPRING_GREEN", Color(0.00, 1.00, 0.50)); - _named_colors_uppercase.insert("STEEL_BLUE", Color(0.27, 0.51, 0.71)); - _named_colors_uppercase.insert("TAN", Color(0.82, 0.71, 0.55)); - _named_colors_uppercase.insert("TEAL", Color(0.00, 0.50, 0.50)); - _named_colors_uppercase.insert("THISTLE", Color(0.85, 0.75, 0.85)); - _named_colors_uppercase.insert("TOMATO", Color(1.00, 0.39, 0.28)); - _named_colors_uppercase.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); - _named_colors_uppercase.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); - _named_colors_uppercase.insert("VIOLET", Color(0.93, 0.51, 0.93)); - _named_colors_uppercase.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); - _named_colors_uppercase.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); - _named_colors_uppercase.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); - _named_colors_uppercase.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); - _named_colors_uppercase.insert("WHEAT", Color(0.96, 0.87, 0.70)); - _named_colors_uppercase.insert("WHITE", Color(1.00, 1.00, 1.00)); - _named_colors_uppercase.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); - _named_colors_uppercase.insert("YELLOW", Color(1.00, 1.00, 0.00)); - _named_colors_uppercase.insert("YELLOW_GREEN", Color(0.60, 0.80, 0.20)); + _named_colors.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); + _named_colors.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); + _named_colors.insert("AQUA", Color(0.00, 1.00, 1.00)); + _named_colors.insert("AQUAMARINE", Color(0.50, 1.00, 0.83)); + _named_colors.insert("AZURE", Color(0.94, 1.00, 1.00)); + _named_colors.insert("BEIGE", Color(0.96, 0.96, 0.86)); + _named_colors.insert("BISQUE", Color(1.00, 0.89, 0.77)); + _named_colors.insert("BLACK", Color(0.00, 0.00, 0.00)); + _named_colors.insert("BLANCHED_ALMOND", Color(1.00, 0.92, 0.80)); + _named_colors.insert("BLUE", Color(0.00, 0.00, 1.00)); + _named_colors.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); + _named_colors.insert("BROWN", Color(0.65, 0.16, 0.16)); + _named_colors.insert("BURLY_WOOD", Color(0.87, 0.72, 0.53)); + _named_colors.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); + _named_colors.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); + _named_colors.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); + _named_colors.insert("CORAL", Color(1.00, 0.50, 0.31)); + _named_colors.insert("CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93)); + _named_colors.insert("CORNSILK", Color(1.00, 0.97, 0.86)); + _named_colors.insert("CRIMSON", Color(0.86, 0.08, 0.24)); + _named_colors.insert("CYAN", Color(0.00, 1.00, 1.00)); + _named_colors.insert("DARK_BLUE", Color(0.00, 0.00, 0.55)); + _named_colors.insert("DARK_CYAN", Color(0.00, 0.55, 0.55)); + _named_colors.insert("DARK_GOLDENROD", Color(0.72, 0.53, 0.04)); + _named_colors.insert("DARK_GRAY", Color(0.66, 0.66, 0.66)); + _named_colors.insert("DARK_GREEN", Color(0.00, 0.39, 0.00)); + _named_colors.insert("DARK_KHAKI", Color(0.74, 0.72, 0.42)); + _named_colors.insert("DARK_MAGENTA", Color(0.55, 0.00, 0.55)); + _named_colors.insert("DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18)); + _named_colors.insert("DARK_ORANGE", Color(1.00, 0.55, 0.00)); + _named_colors.insert("DARK_ORCHID", Color(0.60, 0.20, 0.80)); + _named_colors.insert("DARK_RED", Color(0.55, 0.00, 0.00)); + _named_colors.insert("DARK_SALMON", Color(0.91, 0.59, 0.48)); + _named_colors.insert("DARK_SEA_GREEN", Color(0.56, 0.74, 0.56)); + _named_colors.insert("DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55)); + _named_colors.insert("DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31)); + _named_colors.insert("DARK_TURQUOISE", Color(0.00, 0.81, 0.82)); + _named_colors.insert("DARK_VIOLET", Color(0.58, 0.00, 0.83)); + _named_colors.insert("DEEP_PINK", Color(1.00, 0.08, 0.58)); + _named_colors.insert("DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00)); + _named_colors.insert("DIM_GRAY", Color(0.41, 0.41, 0.41)); + _named_colors.insert("DODGER_BLUE", Color(0.12, 0.56, 1.00)); + _named_colors.insert("FIREBRICK", Color(0.70, 0.13, 0.13)); + _named_colors.insert("FLORAL_WHITE", Color(1.00, 0.98, 0.94)); + _named_colors.insert("FOREST_GREEN", Color(0.13, 0.55, 0.13)); + _named_colors.insert("FUCHSIA", Color(1.00, 0.00, 1.00)); + _named_colors.insert("GAINSBORO", Color(0.86, 0.86, 0.86)); + _named_colors.insert("GHOST_WHITE", Color(0.97, 0.97, 1.00)); + _named_colors.insert("GOLD", Color(1.00, 0.84, 0.00)); + _named_colors.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); + _named_colors.insert("GRAY", Color(0.75, 0.75, 0.75)); + _named_colors.insert("GREEN", Color(0.00, 1.00, 0.00)); + _named_colors.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); + _named_colors.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); + _named_colors.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); + _named_colors.insert("INDIAN_RED", Color(0.80, 0.36, 0.36)); + _named_colors.insert("INDIGO", Color(0.29, 0.00, 0.51)); + _named_colors.insert("IVORY", Color(1.00, 1.00, 0.94)); + _named_colors.insert("KHAKI", Color(0.94, 0.90, 0.55)); + _named_colors.insert("LAVENDER", Color(0.90, 0.90, 0.98)); + _named_colors.insert("LAVENDER_BLUSH", Color(1.00, 0.94, 0.96)); + _named_colors.insert("LAWN_GREEN", Color(0.49, 0.99, 0.00)); + _named_colors.insert("LEMON_CHIFFON", Color(1.00, 0.98, 0.80)); + _named_colors.insert("LIGHT_BLUE", Color(0.68, 0.85, 0.90)); + _named_colors.insert("LIGHT_CORAL", Color(0.94, 0.50, 0.50)); + _named_colors.insert("LIGHT_CYAN", Color(0.88, 1.00, 1.00)); + _named_colors.insert("LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82)); + _named_colors.insert("LIGHT_GRAY", Color(0.83, 0.83, 0.83)); + _named_colors.insert("LIGHT_GREEN", Color(0.56, 0.93, 0.56)); + _named_colors.insert("LIGHT_PINK", Color(1.00, 0.71, 0.76)); + _named_colors.insert("LIGHT_SALMON", Color(1.00, 0.63, 0.48)); + _named_colors.insert("LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67)); + _named_colors.insert("LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98)); + _named_colors.insert("LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60)); + _named_colors.insert("LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87)); + _named_colors.insert("LIGHT_YELLOW", Color(1.00, 1.00, 0.88)); + _named_colors.insert("LIME", Color(0.00, 1.00, 0.00)); + _named_colors.insert("LIME_GREEN", Color(0.20, 0.80, 0.20)); + _named_colors.insert("LINEN", Color(0.98, 0.94, 0.90)); + _named_colors.insert("MAGENTA", Color(1.00, 0.00, 1.00)); + _named_colors.insert("MAROON", Color(0.69, 0.19, 0.38)); + _named_colors.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); + _named_colors.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); + _named_colors.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); + _named_colors.insert("MEDIUM_PURPLE", Color(0.58, 0.44, 0.86)); + _named_colors.insert("MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44)); + _named_colors.insert("MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93)); + _named_colors.insert("MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60)); + _named_colors.insert("MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80)); + _named_colors.insert("MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52)); + _named_colors.insert("MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44)); + _named_colors.insert("MINT_CREAM", Color(0.96, 1.00, 0.98)); + _named_colors.insert("MISTY_ROSE", Color(1.00, 0.89, 0.88)); + _named_colors.insert("MOCCASIN", Color(1.00, 0.89, 0.71)); + _named_colors.insert("NAVAJO_WHITE", Color(1.00, 0.87, 0.68)); + _named_colors.insert("NAVY_BLUE", Color(0.00, 0.00, 0.50)); + _named_colors.insert("OLD_LACE", Color(0.99, 0.96, 0.90)); + _named_colors.insert("OLIVE", Color(0.50, 0.50, 0.00)); + _named_colors.insert("OLIVE_DRAB", Color(0.42, 0.56, 0.14)); + _named_colors.insert("ORANGE", Color(1.00, 0.65, 0.00)); + _named_colors.insert("ORANGE_RED", Color(1.00, 0.27, 0.00)); + _named_colors.insert("ORCHID", Color(0.85, 0.44, 0.84)); + _named_colors.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); + _named_colors.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); + _named_colors.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); + _named_colors.insert("PALE_VIOLET_RED", Color(0.86, 0.44, 0.58)); + _named_colors.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); + _named_colors.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); + _named_colors.insert("PERU", Color(0.80, 0.52, 0.25)); + _named_colors.insert("PINK", Color(1.00, 0.75, 0.80)); + _named_colors.insert("PLUM", Color(0.87, 0.63, 0.87)); + _named_colors.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); + _named_colors.insert("PURPLE", Color(0.63, 0.13, 0.94)); + _named_colors.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); + _named_colors.insert("RED", Color(1.00, 0.00, 0.00)); + _named_colors.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); + _named_colors.insert("ROYAL_BLUE", Color(0.25, 0.41, 0.88)); + _named_colors.insert("SADDLE_BROWN", Color(0.55, 0.27, 0.07)); + _named_colors.insert("SALMON", Color(0.98, 0.50, 0.45)); + _named_colors.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); + _named_colors.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); + _named_colors.insert("SEA_SHELL", Color(1.00, 0.96, 0.93)); + _named_colors.insert("SIENNA", Color(0.63, 0.32, 0.18)); + _named_colors.insert("SILVER", Color(0.75, 0.75, 0.75)); + _named_colors.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); + _named_colors.insert("SLATE_BLUE", Color(0.42, 0.35, 0.80)); + _named_colors.insert("SLATE_GRAY", Color(0.44, 0.50, 0.56)); + _named_colors.insert("SNOW", Color(1.00, 0.98, 0.98)); + _named_colors.insert("SPRING_GREEN", Color(0.00, 1.00, 0.50)); + _named_colors.insert("STEEL_BLUE", Color(0.27, 0.51, 0.71)); + _named_colors.insert("TAN", Color(0.82, 0.71, 0.55)); + _named_colors.insert("TEAL", Color(0.00, 0.50, 0.50)); + _named_colors.insert("THISTLE", Color(0.85, 0.75, 0.85)); + _named_colors.insert("TOMATO", Color(1.00, 0.39, 0.28)); + _named_colors.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); + _named_colors.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); + _named_colors.insert("VIOLET", Color(0.93, 0.51, 0.93)); + _named_colors.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); + _named_colors.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); + _named_colors.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); + _named_colors.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); + _named_colors.insert("WHEAT", Color(0.96, 0.87, 0.70)); + _named_colors.insert("WHITE", Color(1.00, 1.00, 1.00)); + _named_colors.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); + _named_colors.insert("YELLOW", Color(1.00, 1.00, 0.00)); + _named_colors.insert("YELLOW_GREEN", Color(0.60, 0.80, 0.20)); } diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2ddb8cefaadc..b96fd0c10373 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -2331,8 +2331,8 @@ void register_variant_methods() { /* REGISTER CONSTANTS */ - _populate_named_colors_uppercase(); - for (Map::Element *color = _named_colors_uppercase.front(); color; color = color->next()) { + _populate_named_colors(); + for (Map::Element *color = _named_colors.front(); color; color = color->next()) { _VariantCall::add_variant_constant(Variant::COLOR, color->key(), color->value()); } From 502186ec0b3f0260d2775b95b917e8220137287f Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 10:15:40 +0530 Subject: [PATCH 12/27] Remove commented code from color.cpp --- core/color.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core/color.cpp b/core/color.cpp index 9a1756e630e5..36e84497668b 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -397,13 +397,6 @@ Color Color::named(const String &p_name) { _populate_named_colors(); // from color_names.inc } String name = p_name; - // Normalize name - // name = name.replace(" ", ""); - // name = name.replace("-", ""); - // name = name.replace("_", ""); - // name = name.replace("'", ""); - // name = name.replace(".", ""); - // name = name.to_lower(); name = name.replace(" ", "_"); name = name.replace("-", "_"); name = name.replace("'", ""); From b23e333d7e022bef940a0df686d3553e467be97d Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 12:35:52 +0530 Subject: [PATCH 13/27] Implement _to_uppercase_name for transforming normalised names to UPPERCASE_NAMING --- core/color.cpp | 8 +- core/color_names.inc | 383 ++++++++++++++++++++++++++---------------- core/variant_call.cpp | 2 +- 3 files changed, 243 insertions(+), 150 deletions(-) diff --git a/core/color.cpp b/core/color.cpp index 36e84497668b..27a2d0af5cf1 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -397,11 +397,13 @@ Color Color::named(const String &p_name) { _populate_named_colors(); // from color_names.inc } String name = p_name; - name = name.replace(" ", "_"); - name = name.replace("-", "_"); + // Normalize name + name = name.replace(" ", ""); + name = name.replace("-", ""); + name = name.replace("_", ""); name = name.replace("'", ""); name = name.replace(".", ""); - name = name.to_upper(); + name = name.to_lower(); const Map::Element *color = _named_colors.find(name); ERR_FAIL_NULL_V_MSG(color, Color(), "Invalid color name: " + p_name + "."); diff --git a/core/color_names.inc b/core/color_names.inc index dfa9f24e1653..63e46b35988e 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -1,5 +1,7 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names // and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 +#include + #include "core/map.h" static Map _named_colors; @@ -7,150 +9,239 @@ static void _populate_named_colors() { if (!_named_colors.empty()) { return; } - _named_colors.insert("ALICE_BLUE", Color(0.94, 0.97, 1.00)); - _named_colors.insert("ANTIQUE_WHITE", Color(0.98, 0.92, 0.84)); - _named_colors.insert("AQUA", Color(0.00, 1.00, 1.00)); - _named_colors.insert("AQUAMARINE", Color(0.50, 1.00, 0.83)); - _named_colors.insert("AZURE", Color(0.94, 1.00, 1.00)); - _named_colors.insert("BEIGE", Color(0.96, 0.96, 0.86)); - _named_colors.insert("BISQUE", Color(1.00, 0.89, 0.77)); - _named_colors.insert("BLACK", Color(0.00, 0.00, 0.00)); - _named_colors.insert("BLANCHED_ALMOND", Color(1.00, 0.92, 0.80)); - _named_colors.insert("BLUE", Color(0.00, 0.00, 1.00)); - _named_colors.insert("BLUE_VIOLET", Color(0.54, 0.17, 0.89)); - _named_colors.insert("BROWN", Color(0.65, 0.16, 0.16)); - _named_colors.insert("BURLY_WOOD", Color(0.87, 0.72, 0.53)); - _named_colors.insert("CADET_BLUE", Color(0.37, 0.62, 0.63)); - _named_colors.insert("CHARTREUSE", Color(0.50, 1.00, 0.00)); - _named_colors.insert("CHOCOLATE", Color(0.82, 0.41, 0.12)); - _named_colors.insert("CORAL", Color(1.00, 0.50, 0.31)); - _named_colors.insert("CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93)); - _named_colors.insert("CORNSILK", Color(1.00, 0.97, 0.86)); - _named_colors.insert("CRIMSON", Color(0.86, 0.08, 0.24)); - _named_colors.insert("CYAN", Color(0.00, 1.00, 1.00)); - _named_colors.insert("DARK_BLUE", Color(0.00, 0.00, 0.55)); - _named_colors.insert("DARK_CYAN", Color(0.00, 0.55, 0.55)); - _named_colors.insert("DARK_GOLDENROD", Color(0.72, 0.53, 0.04)); - _named_colors.insert("DARK_GRAY", Color(0.66, 0.66, 0.66)); - _named_colors.insert("DARK_GREEN", Color(0.00, 0.39, 0.00)); - _named_colors.insert("DARK_KHAKI", Color(0.74, 0.72, 0.42)); - _named_colors.insert("DARK_MAGENTA", Color(0.55, 0.00, 0.55)); - _named_colors.insert("DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18)); - _named_colors.insert("DARK_ORANGE", Color(1.00, 0.55, 0.00)); - _named_colors.insert("DARK_ORCHID", Color(0.60, 0.20, 0.80)); - _named_colors.insert("DARK_RED", Color(0.55, 0.00, 0.00)); - _named_colors.insert("DARK_SALMON", Color(0.91, 0.59, 0.48)); - _named_colors.insert("DARK_SEA_GREEN", Color(0.56, 0.74, 0.56)); - _named_colors.insert("DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55)); - _named_colors.insert("DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31)); - _named_colors.insert("DARK_TURQUOISE", Color(0.00, 0.81, 0.82)); - _named_colors.insert("DARK_VIOLET", Color(0.58, 0.00, 0.83)); - _named_colors.insert("DEEP_PINK", Color(1.00, 0.08, 0.58)); - _named_colors.insert("DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00)); - _named_colors.insert("DIM_GRAY", Color(0.41, 0.41, 0.41)); - _named_colors.insert("DODGER_BLUE", Color(0.12, 0.56, 1.00)); - _named_colors.insert("FIREBRICK", Color(0.70, 0.13, 0.13)); - _named_colors.insert("FLORAL_WHITE", Color(1.00, 0.98, 0.94)); - _named_colors.insert("FOREST_GREEN", Color(0.13, 0.55, 0.13)); - _named_colors.insert("FUCHSIA", Color(1.00, 0.00, 1.00)); - _named_colors.insert("GAINSBORO", Color(0.86, 0.86, 0.86)); - _named_colors.insert("GHOST_WHITE", Color(0.97, 0.97, 1.00)); - _named_colors.insert("GOLD", Color(1.00, 0.84, 0.00)); - _named_colors.insert("GOLDENROD", Color(0.85, 0.65, 0.13)); - _named_colors.insert("GRAY", Color(0.75, 0.75, 0.75)); - _named_colors.insert("GREEN", Color(0.00, 1.00, 0.00)); - _named_colors.insert("GREEN_YELLOW", Color(0.68, 1.00, 0.18)); - _named_colors.insert("HONEYDEW", Color(0.94, 1.00, 0.94)); - _named_colors.insert("HOT_PINK", Color(1.00, 0.41, 0.71)); - _named_colors.insert("INDIAN_RED", Color(0.80, 0.36, 0.36)); - _named_colors.insert("INDIGO", Color(0.29, 0.00, 0.51)); - _named_colors.insert("IVORY", Color(1.00, 1.00, 0.94)); - _named_colors.insert("KHAKI", Color(0.94, 0.90, 0.55)); - _named_colors.insert("LAVENDER", Color(0.90, 0.90, 0.98)); - _named_colors.insert("LAVENDER_BLUSH", Color(1.00, 0.94, 0.96)); - _named_colors.insert("LAWN_GREEN", Color(0.49, 0.99, 0.00)); - _named_colors.insert("LEMON_CHIFFON", Color(1.00, 0.98, 0.80)); - _named_colors.insert("LIGHT_BLUE", Color(0.68, 0.85, 0.90)); - _named_colors.insert("LIGHT_CORAL", Color(0.94, 0.50, 0.50)); - _named_colors.insert("LIGHT_CYAN", Color(0.88, 1.00, 1.00)); - _named_colors.insert("LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82)); - _named_colors.insert("LIGHT_GRAY", Color(0.83, 0.83, 0.83)); - _named_colors.insert("LIGHT_GREEN", Color(0.56, 0.93, 0.56)); - _named_colors.insert("LIGHT_PINK", Color(1.00, 0.71, 0.76)); - _named_colors.insert("LIGHT_SALMON", Color(1.00, 0.63, 0.48)); - _named_colors.insert("LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67)); - _named_colors.insert("LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98)); - _named_colors.insert("LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60)); - _named_colors.insert("LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87)); - _named_colors.insert("LIGHT_YELLOW", Color(1.00, 1.00, 0.88)); - _named_colors.insert("LIME", Color(0.00, 1.00, 0.00)); - _named_colors.insert("LIME_GREEN", Color(0.20, 0.80, 0.20)); - _named_colors.insert("LINEN", Color(0.98, 0.94, 0.90)); - _named_colors.insert("MAGENTA", Color(1.00, 0.00, 1.00)); - _named_colors.insert("MAROON", Color(0.69, 0.19, 0.38)); - _named_colors.insert("MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67)); - _named_colors.insert("MEDIUM_BLUE", Color(0.00, 0.00, 0.80)); - _named_colors.insert("MEDIUM_ORCHID", Color(0.73, 0.33, 0.83)); - _named_colors.insert("MEDIUM_PURPLE", Color(0.58, 0.44, 0.86)); - _named_colors.insert("MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44)); - _named_colors.insert("MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93)); - _named_colors.insert("MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60)); - _named_colors.insert("MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80)); - _named_colors.insert("MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52)); - _named_colors.insert("MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44)); - _named_colors.insert("MINT_CREAM", Color(0.96, 1.00, 0.98)); - _named_colors.insert("MISTY_ROSE", Color(1.00, 0.89, 0.88)); - _named_colors.insert("MOCCASIN", Color(1.00, 0.89, 0.71)); - _named_colors.insert("NAVAJO_WHITE", Color(1.00, 0.87, 0.68)); - _named_colors.insert("NAVY_BLUE", Color(0.00, 0.00, 0.50)); - _named_colors.insert("OLD_LACE", Color(0.99, 0.96, 0.90)); - _named_colors.insert("OLIVE", Color(0.50, 0.50, 0.00)); - _named_colors.insert("OLIVE_DRAB", Color(0.42, 0.56, 0.14)); - _named_colors.insert("ORANGE", Color(1.00, 0.65, 0.00)); - _named_colors.insert("ORANGE_RED", Color(1.00, 0.27, 0.00)); - _named_colors.insert("ORCHID", Color(0.85, 0.44, 0.84)); - _named_colors.insert("PALE_GOLDENROD", Color(0.93, 0.91, 0.67)); - _named_colors.insert("PALE_GREEN", Color(0.60, 0.98, 0.60)); - _named_colors.insert("PALE_TURQUOISE", Color(0.69, 0.93, 0.93)); - _named_colors.insert("PALE_VIOLET_RED", Color(0.86, 0.44, 0.58)); - _named_colors.insert("PAPAYA_WHIP", Color(1.00, 0.94, 0.84)); - _named_colors.insert("PEACH_PUFF", Color(1.00, 0.85, 0.73)); - _named_colors.insert("PERU", Color(0.80, 0.52, 0.25)); - _named_colors.insert("PINK", Color(1.00, 0.75, 0.80)); - _named_colors.insert("PLUM", Color(0.87, 0.63, 0.87)); - _named_colors.insert("POWDER_BLUE", Color(0.69, 0.88, 0.90)); - _named_colors.insert("PURPLE", Color(0.63, 0.13, 0.94)); - _named_colors.insert("REBECCA_PURPLE", Color(0.40, 0.20, 0.60)); - _named_colors.insert("RED", Color(1.00, 0.00, 0.00)); - _named_colors.insert("ROSY_BROWN", Color(0.74, 0.56, 0.56)); - _named_colors.insert("ROYAL_BLUE", Color(0.25, 0.41, 0.88)); - _named_colors.insert("SADDLE_BROWN", Color(0.55, 0.27, 0.07)); - _named_colors.insert("SALMON", Color(0.98, 0.50, 0.45)); - _named_colors.insert("SANDY_BROWN", Color(0.96, 0.64, 0.38)); - _named_colors.insert("SEA_GREEN", Color(0.18, 0.55, 0.34)); - _named_colors.insert("SEA_SHELL", Color(1.00, 0.96, 0.93)); - _named_colors.insert("SIENNA", Color(0.63, 0.32, 0.18)); - _named_colors.insert("SILVER", Color(0.75, 0.75, 0.75)); - _named_colors.insert("SKY_BLUE", Color(0.53, 0.81, 0.92)); - _named_colors.insert("SLATE_BLUE", Color(0.42, 0.35, 0.80)); - _named_colors.insert("SLATE_GRAY", Color(0.44, 0.50, 0.56)); - _named_colors.insert("SNOW", Color(1.00, 0.98, 0.98)); - _named_colors.insert("SPRING_GREEN", Color(0.00, 1.00, 0.50)); - _named_colors.insert("STEEL_BLUE", Color(0.27, 0.51, 0.71)); - _named_colors.insert("TAN", Color(0.82, 0.71, 0.55)); - _named_colors.insert("TEAL", Color(0.00, 0.50, 0.50)); - _named_colors.insert("THISTLE", Color(0.85, 0.75, 0.85)); - _named_colors.insert("TOMATO", Color(1.00, 0.39, 0.28)); - _named_colors.insert("TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00)); - _named_colors.insert("TURQUOISE", Color(0.25, 0.88, 0.82)); - _named_colors.insert("VIOLET", Color(0.93, 0.51, 0.93)); - _named_colors.insert("WEB_GRAY", Color(0.50, 0.50, 0.50)); - _named_colors.insert("WEB_GREEN", Color(0.00, 0.50, 0.00)); - _named_colors.insert("WEB_MAROON", Color(0.50, 0.00, 0.00)); - _named_colors.insert("WEB_PURPLE", Color(0.50, 0.00, 0.50)); - _named_colors.insert("WHEAT", Color(0.96, 0.87, 0.70)); - _named_colors.insert("WHITE", Color(1.00, 1.00, 1.00)); - _named_colors.insert("WHITE_SMOKE", Color(0.96, 0.96, 0.96)); - _named_colors.insert("YELLOW", Color(1.00, 1.00, 0.00)); - _named_colors.insert("YELLOW_GREEN", Color(0.60, 0.80, 0.20)); + _named_colors.insert("aliceblue", Color(0.94f, 0.97f, 1.00f)); + _named_colors.insert("antiquewhite", Color(0.98f, 0.92f, 0.84f)); + _named_colors.insert("aqua", Color(0.00f, 1.00f, 1.00f)); + _named_colors.insert("aquamarine", Color(0.50f, 1.00f, 0.83f)); + _named_colors.insert("azure", Color(0.94f, 1.00f, 1.00f)); + _named_colors.insert("beige", Color(0.96f, 0.96f, 0.86f)); + _named_colors.insert("bisque", Color(1.00f, 0.89f, 0.77f)); + _named_colors.insert("black", Color(0.00f, 0.00f, 0.00f)); + _named_colors.insert("blanchedalmond", Color(1.00f, 0.92f, 0.80f)); + _named_colors.insert("blue", Color(0.00f, 0.00f, 1.00f)); + _named_colors.insert("blueviolet", Color(0.54f, 0.17f, 0.89f)); + _named_colors.insert("brown", Color(0.65f, 0.16f, 0.16f)); + _named_colors.insert("burlywood", Color(0.87f, 0.72f, 0.53f)); + _named_colors.insert("cadetblue", Color(0.37f, 0.62f, 0.63f)); + _named_colors.insert("chartreuse", Color(0.50f, 1.00f, 0.00f)); + _named_colors.insert("chocolate", Color(0.82f, 0.41f, 0.12f)); + _named_colors.insert("coral", Color(1.00f, 0.50f, 0.31f)); + _named_colors.insert("cornflowerblue", Color(0.39f, 0.58f, 0.93f)); + _named_colors.insert("cornsilk", Color(1.00f, 0.97f, 0.86f)); + _named_colors.insert("crimson", Color(0.86f, 0.08f, 0.24f)); + _named_colors.insert("cyan", Color(0.00f, 1.00f, 1.00f)); + _named_colors.insert("darkblue", Color(0.00f, 0.00f, 0.55f)); + _named_colors.insert("darkcyan", Color(0.00f, 0.55f, 0.55f)); + _named_colors.insert("darkgoldenrod", Color(0.72f, 0.53f, 0.04f)); + _named_colors.insert("darkgray", Color(0.66f, 0.66f, 0.66f)); + _named_colors.insert("darkgreen", Color(0.00f, 0.39f, 0.00f)); + _named_colors.insert("darkkhaki", Color(0.74f, 0.72f, 0.42f)); + _named_colors.insert("darkmagenta", Color(0.55f, 0.00f, 0.55f)); + _named_colors.insert("darkolivegreen", Color(0.33f, 0.42f, 0.18f)); + _named_colors.insert("darkorange", Color(1.00f, 0.55f, 0.00f)); + _named_colors.insert("darkorchid", Color(0.60f, 0.20f, 0.80f)); + _named_colors.insert("darkred", Color(0.55f, 0.00f, 0.00f)); + _named_colors.insert("darksalmon", Color(0.91f, 0.59f, 0.48f)); + _named_colors.insert("darkseagreen", Color(0.56f, 0.74f, 0.56f)); + _named_colors.insert("darkslateblue", Color(0.28f, 0.24f, 0.55f)); + _named_colors.insert("darkslategray", Color(0.18f, 0.31f, 0.31f)); + _named_colors.insert("darkturquoise", Color(0.00f, 0.81f, 0.82f)); + _named_colors.insert("darkviolet", Color(0.58f, 0.00f, 0.83f)); + _named_colors.insert("deeppink", Color(1.00f, 0.08f, 0.58f)); + _named_colors.insert("deepskyblue", Color(0.00f, 0.75f, 1.00f)); + _named_colors.insert("dimgray", Color(0.41f, 0.41f, 0.41f)); + _named_colors.insert("dodgerblue", Color(0.12f, 0.56f, 1.00f)); + _named_colors.insert("firebrick", Color(0.70f, 0.13f, 0.13f)); + _named_colors.insert("floralwhite", Color(1.00f, 0.98f, 0.94f)); + _named_colors.insert("forestgreen", Color(0.13f, 0.55f, 0.13f)); + _named_colors.insert("fuchsia", Color(1.00f, 0.00f, 1.00f)); + _named_colors.insert("gainsboro", Color(0.86f, 0.86f, 0.86f)); + _named_colors.insert("ghostwhite", Color(0.97f, 0.97f, 1.00f)); + _named_colors.insert("gold", Color(1.00f, 0.84f, 0.00f)); + _named_colors.insert("goldenrod", Color(0.85f, 0.65f, 0.13f)); + _named_colors.insert("gray", Color(0.75f, 0.75f, 0.75f)); + _named_colors.insert("green", Color(0.00f, 1.00f, 0.00f)); + _named_colors.insert("greenyellow", Color(0.68f, 1.00f, 0.18f)); + _named_colors.insert("honeydew", Color(0.94f, 1.00f, 0.94f)); + _named_colors.insert("hotpink", Color(1.00f, 0.41f, 0.71f)); + _named_colors.insert("indianred", Color(0.80f, 0.36f, 0.36f)); + _named_colors.insert("indigo", Color(0.29f, 0.00f, 0.51f)); + _named_colors.insert("ivory", Color(1.00f, 1.00f, 0.94f)); + _named_colors.insert("khaki", Color(0.94f, 0.90f, 0.55f)); + _named_colors.insert("lavender", Color(0.90f, 0.90f, 0.98f)); + _named_colors.insert("lavenderblush", Color(1.00f, 0.94f, 0.96f)); + _named_colors.insert("lawngreen", Color(0.49f, 0.99f, 0.00f)); + _named_colors.insert("lemonchiffon", Color(1.00f, 0.98f, 0.80f)); + _named_colors.insert("lightblue", Color(0.68f, 0.85f, 0.90f)); + _named_colors.insert("lightcoral", Color(0.94f, 0.50f, 0.50f)); + _named_colors.insert("lightcyan", Color(0.88f, 1.00f, 1.00f)); + _named_colors.insert("lightgoldenrod", Color(0.98f, 0.98f, 0.82f)); + _named_colors.insert("lightgray", Color(0.83f, 0.83f, 0.83f)); + _named_colors.insert("lightgreen", Color(0.56f, 0.93f, 0.56f)); + _named_colors.insert("lightpink", Color(1.00f, 0.71f, 0.76f)); + _named_colors.insert("lightsalmon", Color(1.00f, 0.63f, 0.48f)); + _named_colors.insert("lightseagreen", Color(0.13f, 0.70f, 0.67f)); + _named_colors.insert("lightskyblue", Color(0.53f, 0.81f, 0.98f)); + _named_colors.insert("lightslategray", Color(0.47f, 0.53f, 0.60f)); + _named_colors.insert("lightsteelblue", Color(0.69f, 0.77f, 0.87f)); + _named_colors.insert("lightyellow", Color(1.00f, 1.00f, 0.88f)); + _named_colors.insert("lime", Color(0.00f, 1.00f, 0.00f)); + _named_colors.insert("limegreen", Color(0.20f, 0.80f, 0.20f)); + _named_colors.insert("linen", Color(0.98f, 0.94f, 0.90f)); + _named_colors.insert("magenta", Color(1.00f, 0.00f, 1.00f)); + _named_colors.insert("maroon", Color(0.69f, 0.19f, 0.38f)); + _named_colors.insert("mediumaquamarine", Color(0.40f, 0.80f, 0.67f)); + _named_colors.insert("mediumblue", Color(0.00f, 0.00f, 0.80f)); + _named_colors.insert("mediumorchid", Color(0.73f, 0.33f, 0.83f)); + _named_colors.insert("mediumpurple", Color(0.58f, 0.44f, 0.86f)); + _named_colors.insert("mediumseagreen", Color(0.24f, 0.70f, 0.44f)); + _named_colors.insert("mediumslateblue", Color(0.48f, 0.41f, 0.93f)); + _named_colors.insert("mediumspringgreen", Color(0.00f, 0.98f, 0.60f)); + _named_colors.insert("mediumturquoise", Color(0.28f, 0.82f, 0.80f)); + _named_colors.insert("mediumvioletred", Color(0.78f, 0.08f, 0.52f)); + _named_colors.insert("midnightblue", Color(0.10f, 0.10f, 0.44f)); + _named_colors.insert("mintcream", Color(0.96f, 1.00f, 0.98f)); + _named_colors.insert("mistyrose", Color(1.00f, 0.89f, 0.88f)); + _named_colors.insert("moccasin", Color(1.00f, 0.89f, 0.71f)); + _named_colors.insert("navajowhite", Color(1.00f, 0.87f, 0.68f)); + _named_colors.insert("navyblue", Color(0.00f, 0.00f, 0.50f)); + _named_colors.insert("oldlace", Color(0.99f, 0.96f, 0.90f)); + _named_colors.insert("olive", Color(0.50f, 0.50f, 0.00f)); + _named_colors.insert("olivedrab", Color(0.42f, 0.56f, 0.14f)); + _named_colors.insert("orange", Color(1.00f, 0.65f, 0.00f)); + _named_colors.insert("orangered", Color(1.00f, 0.27f, 0.00f)); + _named_colors.insert("orchid", Color(0.85f, 0.44f, 0.84f)); + _named_colors.insert("palegoldenrod", Color(0.93f, 0.91f, 0.67f)); + _named_colors.insert("palegreen", Color(0.60f, 0.98f, 0.60f)); + _named_colors.insert("paleturquoise", Color(0.69f, 0.93f, 0.93f)); + _named_colors.insert("palevioletred", Color(0.86f, 0.44f, 0.58f)); + _named_colors.insert("papayawhip", Color(1.00f, 0.94f, 0.84f)); + _named_colors.insert("peachpuff", Color(1.00f, 0.85f, 0.73f)); + _named_colors.insert("peru", Color(0.80f, 0.52f, 0.25f)); + _named_colors.insert("pink", Color(1.00f, 0.75f, 0.80f)); + _named_colors.insert("plum", Color(0.87f, 0.63f, 0.87f)); + _named_colors.insert("powderblue", Color(0.69f, 0.88f, 0.90f)); + _named_colors.insert("purple", Color(0.63f, 0.13f, 0.94f)); + _named_colors.insert("rebeccapurple", Color(0.40f, 0.20f, 0.60f)); + _named_colors.insert("red", Color(1.00f, 0.00f, 0.00f)); + _named_colors.insert("rosybrown", Color(0.74f, 0.56f, 0.56f)); + _named_colors.insert("royalblue", Color(0.25f, 0.41f, 0.88f)); + _named_colors.insert("saddlebrown", Color(0.55f, 0.27f, 0.07f)); + _named_colors.insert("salmon", Color(0.98f, 0.50f, 0.45f)); + _named_colors.insert("sandybrown", Color(0.96f, 0.64f, 0.38f)); + _named_colors.insert("seagreen", Color(0.18f, 0.55f, 0.34f)); + _named_colors.insert("seashell", Color(1.00f, 0.96f, 0.93f)); + _named_colors.insert("sienna", Color(0.63f, 0.32f, 0.18f)); + _named_colors.insert("silver", Color(0.75f, 0.75f, 0.75f)); + _named_colors.insert("skyblue", Color(0.53f, 0.81f, 0.92f)); + _named_colors.insert("slateblue", Color(0.42f, 0.35f, 0.80f)); + _named_colors.insert("slategray", Color(0.44f, 0.50f, 0.56f)); + _named_colors.insert("snow", Color(1.00f, 0.98f, 0.98f)); + _named_colors.insert("springgreen", Color(0.00f, 1.00f, 0.50f)); + _named_colors.insert("steelblue", Color(0.27f, 0.51f, 0.71f)); + _named_colors.insert("tan", Color(0.82f, 0.71f, 0.55f)); + _named_colors.insert("teal", Color(0.00f, 0.50f, 0.50f)); + _named_colors.insert("thistle", Color(0.85f, 0.75f, 0.85f)); + _named_colors.insert("tomato", Color(1.00f, 0.39f, 0.28f)); + _named_colors.insert("turquoise", Color(0.25f, 0.88f, 0.82f)); + _named_colors.insert("transparent", Color(1.00f, 1.00f, 1.00f, 0.00)); + _named_colors.insert("violet", Color(0.93f, 0.51f, 0.93f)); + _named_colors.insert("webgray", Color(0.50f, 0.50f, 0.50f)); + _named_colors.insert("webgreen", Color(0.00f, 0.50f, 0.00f)); + _named_colors.insert("webmaroon", Color(0.50f, 0.00f, 0.00f)); + _named_colors.insert("webpurple", Color(0.50f, 0.00f, 0.50f)); + _named_colors.insert("wheat", Color(0.96f, 0.87f, 0.70f)); + _named_colors.insert("white", Color(1.00f, 1.00f, 1.00f)); + _named_colors.insert("whitesmoke", Color(0.96f, 0.96f, 0.96f)); + _named_colors.insert("yellow", Color(1.00f, 1.00f, 0.00f)); + _named_colors.insert("yellowgreen", Color(0.60f, 0.80f, 0.20f)); } + +static std::vector _modifiable_colors = { + "AQUAMARINE", + "BLACK", + "BLUE", + "BROWN", + "CORAL", + "CYAN", + "GRAY", + "GREEN", + "GOLDENROD", + "KHAKI", + "MAROON", + "ORANGE", + "ORCHID", + "PINK", + "PURPLE", + "RED", + "TURQUOISE", + "WHITE", + "YELLOW", +}; + +static std::vector _color_descriptors = { + "BLUSH", + "DARK", + "DRAB", + "MEDIUM", + "LIGHT", + "OLIVE", + "PALE", + "SEA", + "SKY", + "SLATE", + "SPRING", + "STEEL", + "WEB", +}; + +static void _append_underscores(String &out_name, const std::vector &strings) { + for (int i = 0; i < strings.size(); ++i) { + const String &word = strings[i]; + int word_size = word.size(); + int word_begins_at = out_name.find(word); + + if (word_begins_at > 0) { + if (out_name[i - 1] != '_') { + out_name.insert(i - 1, "_"); + } + } + + if (word_begins_at + word_size < out_name.size()) { + if (out_name[word_begins_at + word_size + 1] != '_') { + out_name.insert(word_begins_at + word_size + 1, "_"); + } + } + } +} + +static String _to_uppercase_name(const String &name) { + // Edge cases + if (name == "blanchedalmond") { + return "BLANCHED_ALMOND"; + } else if (name == "burlywood") { + return "BURLY_WOOD"; + } else if (name == "lemonchiffon") { + return "LEMON_CHIFFON"; + } else if (name == "mintcream") { + return "MINT_CREAM"; + } else if (name == "mistyrose") { + return "MISTY_ROSE"; + } else if (name == "oldlace") { + return "OLD_LACE"; + } else if (name == "olivedrab") { + return "OLIVE_DRAB"; + } else if (name == "papayawhip") { + return "PAPAYA_WHIP"; + } else if (name == "peachpuff") { + return "PEACH_PUFF"; + } else if (name == "seashell") { + return "SEA_SHELL"; + } + + // Cases with standard color names + String uppercase_name = name.to_upper(); + _append_underscores(uppercase_name, _modifiable_colors); + _append_underscores(uppercase_name, _color_descriptors); + return uppercase_name; +} \ No newline at end of file diff --git a/core/variant_call.cpp b/core/variant_call.cpp index b96fd0c10373..241451cd3ea6 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -2333,7 +2333,7 @@ void register_variant_methods() { _populate_named_colors(); for (Map::Element *color = _named_colors.front(); color; color = color->next()) { - _VariantCall::add_variant_constant(Variant::COLOR, color->key(), color->value()); + _VariantCall::add_variant_constant(Variant::COLOR, _to_uppercase_name(color->key()), color->value()); } _VariantCall::add_constant(Variant::VECTOR3, "AXIS_X", Vector3::AXIS_X); From 479201d2f451354d3dfd8ce7a99709897d0fc39a Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 12:50:08 +0530 Subject: [PATCH 14/27] Fix wrong index --- core/color_names.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index 63e46b35988e..599904a5ea4b 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -198,18 +198,18 @@ static std::vector _color_descriptors = { static void _append_underscores(String &out_name, const std::vector &strings) { for (int i = 0; i < strings.size(); ++i) { const String &word = strings[i]; - int word_size = word.size(); int word_begins_at = out_name.find(word); + int word_ends_at = word_begins_at + word.size(); if (word_begins_at > 0) { - if (out_name[i - 1] != '_') { - out_name.insert(i - 1, "_"); + if (out_name[word_begins_at - 1] != '_') { + out_name.insert(word_begins_at - 1, "_"); } } - if (word_begins_at + word_size < out_name.size()) { - if (out_name[word_begins_at + word_size + 1] != '_') { - out_name.insert(word_begins_at + word_size + 1, "_"); + if (word_ends_at < out_name.size()) { + if (out_name[word_ends_at + 1] != '_') { + out_name.insert(word_ends_at + 1, "_"); } } } From 814aa7653f1d42227285fb5fbfc1adbb7be9bcb1 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 13:05:45 +0530 Subject: [PATCH 15/27] Rename append -> insert --- core/color_names.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index 599904a5ea4b..e545af34a19c 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -195,7 +195,7 @@ static std::vector _color_descriptors = { "WEB", }; -static void _append_underscores(String &out_name, const std::vector &strings) { +static void _insert_underscores(String &out_name, const std::vector &strings) { for (int i = 0; i < strings.size(); ++i) { const String &word = strings[i]; int word_begins_at = out_name.find(word); @@ -241,7 +241,7 @@ static String _to_uppercase_name(const String &name) { // Cases with standard color names String uppercase_name = name.to_upper(); - _append_underscores(uppercase_name, _modifiable_colors); - _append_underscores(uppercase_name, _color_descriptors); + _insert_underscores(uppercase_name, _modifiable_colors); + _insert_underscores(uppercase_name, _color_descriptors); return uppercase_name; } \ No newline at end of file From 2c5d7d9063cae16024337017896dc2239bd1c1ce Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 13:30:31 +0530 Subject: [PATCH 16/27] Use Godot Vectors --- core/color_names.inc | 89 +++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index e545af34a19c..0dc6fe34bb44 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -1,8 +1,7 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names // and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 -#include - #include "core/map.h" +#include "core/vector.h" static Map _named_colors; static void _populate_named_colors() { @@ -157,48 +156,53 @@ static void _populate_named_colors() { _named_colors.insert("yellowgreen", Color(0.60f, 0.80f, 0.20f)); } -static std::vector _modifiable_colors = { - "AQUAMARINE", - "BLACK", - "BLUE", - "BROWN", - "CORAL", - "CYAN", - "GRAY", - "GREEN", - "GOLDENROD", - "KHAKI", - "MAROON", - "ORANGE", - "ORCHID", - "PINK", - "PURPLE", - "RED", - "TURQUOISE", - "WHITE", - "YELLOW", -}; +static Vector _modifiable_colors; +static Vector _color_descriptors; +static void _populate_uppercase_helper_lists() { + if (_modifiable_colors.empty()) { + _modifiable_colors.append("AQUAMARINE"); + _modifiable_colors.append("BLACK"); + _modifiable_colors.append("BLUE"); + _modifiable_colors.append("BROWN"); + _modifiable_colors.append("CORAL"); + _modifiable_colors.append("CYAN"); + _modifiable_colors.append("GRAY"); + _modifiable_colors.append("GREEN"); + _modifiable_colors.append("GOLDENROD"); + _modifiable_colors.append("KHAKI"); + _modifiable_colors.append("MAROON"); + _modifiable_colors.append("ORANGE"); + _modifiable_colors.append("ORCHID"); + _modifiable_colors.append("PINK"); + _modifiable_colors.append("PURPLE"); + _modifiable_colors.append("RED"); + _modifiable_colors.append("TURQUOISE"); + _modifiable_colors.append("WHITE"); + _modifiable_colors.append("YELLOW"); + } -static std::vector _color_descriptors = { - "BLUSH", - "DARK", - "DRAB", - "MEDIUM", - "LIGHT", - "OLIVE", - "PALE", - "SEA", - "SKY", - "SLATE", - "SPRING", - "STEEL", - "WEB", -}; + if (_color_descriptors.empty()) { + _color_descriptors.append("BLUSH"); + _color_descriptors.append("DARK"); + _color_descriptors.append("DRAB"); + _color_descriptors.append("MEDIUM"); + _color_descriptors.append("LIGHT"); + _color_descriptors.append("OLIVE"); + _color_descriptors.append("PALE"); + _color_descriptors.append("SEA"); + _color_descriptors.append("SKY"); + _color_descriptors.append("SLATE"); + _color_descriptors.append("SPRING"); + _color_descriptors.append("STEEL"); + _color_descriptors.append("WEB"); + } +} -static void _insert_underscores(String &out_name, const std::vector &strings) { - for (int i = 0; i < strings.size(); ++i) { - const String &word = strings[i]; - int word_begins_at = out_name.find(word); +static void _insert_underscores(String &out_name, const Vector &helper_list) { + for (int i = 0; i < helper_list.size(); ++i) { + const String &word = helper_list[i]; + int word_begins_at = out_name.find(word, 0); + ERR_PRINT_ONCE(itos(word_begins_at)); int word_ends_at = word_begins_at + word.size(); if (word_begins_at > 0) { @@ -239,6 +243,7 @@ static String _to_uppercase_name(const String &name) { return "SEA_SHELL"; } + _populate_uppercase_helper_lists(); // Cases with standard color names String uppercase_name = name.to_upper(); _insert_underscores(uppercase_name, _modifiable_colors); From 534d43459944cf8aca3156c6b543163d5fdeabbd Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 14:24:58 +0530 Subject: [PATCH 17/27] Debug using print --- core/color_names.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index 0dc6fe34bb44..b5ddd64c5884 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -202,8 +202,10 @@ static void _insert_underscores(String &out_name, const Vector &helper_l for (int i = 0; i < helper_list.size(); ++i) { const String &word = helper_list[i]; int word_begins_at = out_name.find(word, 0); - ERR_PRINT_ONCE(itos(word_begins_at)); - int word_ends_at = word_begins_at + word.size(); + int word_ends_at = word_begins_at + word.size() - 2; + if (word_begins_at >= 0) { + ERR_PRINT("Found " + word + " in " + out_name + " between [" + itos(word_begins_at) + "] and [" + itos(word_ends_at) + "]."); + } if (word_begins_at > 0) { if (out_name[word_begins_at - 1] != '_') { From d8ce60c16ab90b513da02df99e2aa1eb5b6e1122 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 14:44:56 +0530 Subject: [PATCH 18/27] Debug using prints --- core/color_names.inc | 50 +++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index b5ddd64c5884..0ec36c6c28fe 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -1,6 +1,7 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names // and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 #include "core/map.h" +#include "core/ustring.h" #include "core/vector.h" static Map _named_colors; @@ -182,7 +183,6 @@ static void _populate_uppercase_helper_lists() { } if (_color_descriptors.empty()) { - _color_descriptors.append("BLUSH"); _color_descriptors.append("DARK"); _color_descriptors.append("DRAB"); _color_descriptors.append("MEDIUM"); @@ -198,27 +198,47 @@ static void _populate_uppercase_helper_lists() { } } -static void _insert_underscores(String &out_name, const Vector &helper_list) { +static String _insert_underscores(const String &name, const Vector &helper_list) { + String name_with_underscores = name; + for (int i = 0; i < helper_list.size(); ++i) { const String &word = helper_list[i]; - int word_begins_at = out_name.find(word, 0); - int word_ends_at = word_begins_at + word.size() - 2; - if (word_begins_at >= 0) { - ERR_PRINT("Found " + word + " in " + out_name + " between [" + itos(word_begins_at) + "] and [" + itos(word_ends_at) + "]."); + + if (word == name) { + break; + } + + int word_begins_at = name_with_underscores.find(word, 0); + + if (word_begins_at < 0) { + break; } + int word_ends_at = word_begins_at + word.length() - 1; + WARN_PRINT("Found " + word + " in " + name_with_underscores + " between [" + itos(word_begins_at) + "] and [" + itos(word_ends_at) + "]."); + if (word_begins_at > 0) { - if (out_name[word_begins_at - 1] != '_') { - out_name.insert(word_begins_at - 1, "_"); + WARN_PRINT(word + " isn't the first word."); + if (name_with_underscores[word_begins_at - 1] != '_') { + WARN_PRINT(word + " isn't preceded by a _."); + String old = name_with_underscores; + name_with_underscores = name_with_underscores.insert(word_begins_at - 1, "_"); + WARN_PRINT(old + " has been changed to " + name_with_underscores); } } - if (word_ends_at < out_name.size()) { - if (out_name[word_ends_at + 1] != '_') { - out_name.insert(word_ends_at + 1, "_"); + if (word_ends_at < name_with_underscores.length() - 2) { + WARN_PRINT(word + " isn't the last word."); + if (name_with_underscores[word_ends_at + 1] != '_') { + WARN_PRINT(word + " isn't followed by a _."); + String old = name_with_underscores; + name_with_underscores = name_with_underscores.insert(word_ends_at + 1, "_"); + WARN_PRINT(old + " has been changed to " + name_with_underscores); } } } + + return name_with_underscores; } static String _to_uppercase_name(const String &name) { @@ -227,6 +247,8 @@ static String _to_uppercase_name(const String &name) { return "BLANCHED_ALMOND"; } else if (name == "burlywood") { return "BURLY_WOOD"; + } else if (name == "lavenderblush") { + return "LAVENDER_BLUSH"; } else if (name == "lemonchiffon") { return "LEMON_CHIFFON"; } else if (name == "mintcream") { @@ -245,10 +267,10 @@ static String _to_uppercase_name(const String &name) { return "SEA_SHELL"; } - _populate_uppercase_helper_lists(); // Cases with standard color names + _populate_uppercase_helper_lists(); String uppercase_name = name.to_upper(); - _insert_underscores(uppercase_name, _modifiable_colors); - _insert_underscores(uppercase_name, _color_descriptors); + uppercase_name = _insert_underscores(uppercase_name, _modifiable_colors); + uppercase_name = _insert_underscores(uppercase_name, _color_descriptors); return uppercase_name; } \ No newline at end of file From d098dc171748ff2ca24490b25ed5d69748bf2380 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 16:32:01 +0530 Subject: [PATCH 19/27] Correct implementation --- core/color_names.inc | 56 ++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/core/color_names.inc b/core/color_names.inc index 0ec36c6c28fe..03c28e144cb1 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -159,7 +159,7 @@ static void _populate_named_colors() { static Vector _modifiable_colors; static Vector _color_descriptors; -static void _populate_uppercase_helper_lists() { +static void _populate_uppercase_token_lists() { if (_modifiable_colors.empty()) { _modifiable_colors.append("AQUAMARINE"); _modifiable_colors.append("BLACK"); @@ -184,7 +184,6 @@ static void _populate_uppercase_helper_lists() { if (_color_descriptors.empty()) { _color_descriptors.append("DARK"); - _color_descriptors.append("DRAB"); _color_descriptors.append("MEDIUM"); _color_descriptors.append("LIGHT"); _color_descriptors.append("OLIVE"); @@ -198,42 +197,39 @@ static void _populate_uppercase_helper_lists() { } } -static String _insert_underscores(const String &name, const Vector &helper_list) { - String name_with_underscores = name; +static String _insert_underscores(const String &name, const Vector &tokens) { + String name_with_underscores(name); - for (int i = 0; i < helper_list.size(); ++i) { - const String &word = helper_list[i]; + for (int i = 0; i < tokens.size(); ++i) { + const String &token = tokens[i]; - if (word == name) { - break; + // Skip the following steps if the word is the same as the whole name + if (token == name_with_underscores) { + continue; } - int word_begins_at = name_with_underscores.find(word, 0); + int begin = name_with_underscores.find(token, 0); - if (word_begins_at < 0) { - break; + // Skip the following steps if the word isn't found in the name + if (begin < 0) { + continue; } - int word_ends_at = word_begins_at + word.length() - 1; - WARN_PRINT("Found " + word + " in " + name_with_underscores + " between [" + itos(word_begins_at) + "] and [" + itos(word_ends_at) + "]."); + int end = begin + token.length() - 1; - if (word_begins_at > 0) { - WARN_PRINT(word + " isn't the first word."); - if (name_with_underscores[word_begins_at - 1] != '_') { - WARN_PRINT(word + " isn't preceded by a _."); - String old = name_with_underscores; - name_with_underscores = name_with_underscores.insert(word_begins_at - 1, "_"); - WARN_PRINT(old + " has been changed to " + name_with_underscores); + // If the word isn't at the beginning + if (begin > 0) { + // If the letter before it isn't already an underscore + if (name_with_underscores[begin - 1] != '_') { + name_with_underscores = name_with_underscores.insert(begin, "_"); } } - if (word_ends_at < name_with_underscores.length() - 2) { - WARN_PRINT(word + " isn't the last word."); - if (name_with_underscores[word_ends_at + 1] != '_') { - WARN_PRINT(word + " isn't followed by a _."); - String old = name_with_underscores; - name_with_underscores = name_with_underscores.insert(word_ends_at + 1, "_"); - WARN_PRINT(old + " has been changed to " + name_with_underscores); + // If the word isn't at the end + if (end < name_with_underscores.length() - 2) { + // If the letter after it isn't already an underscore + if (name_with_underscores[end + 1] != '_') { + name_with_underscores = name_with_underscores.insert(end + 1, "_"); } } } @@ -267,10 +263,10 @@ static String _to_uppercase_name(const String &name) { return "SEA_SHELL"; } - // Cases with standard color names - _populate_uppercase_helper_lists(); + // All other cases + _populate_uppercase_token_lists(); String uppercase_name = name.to_upper(); uppercase_name = _insert_underscores(uppercase_name, _modifiable_colors); uppercase_name = _insert_underscores(uppercase_name, _color_descriptors); return uppercase_name; -} \ No newline at end of file +} From 1059469c5bec1cd46561a9fd9626f368ba3079ef Mon Sep 17 00:00:00 2001 From: Vivraan Date: Thu, 13 Aug 2020 16:43:09 +0530 Subject: [PATCH 20/27] Make alpha of "transparent: a float literal --- core/color_names.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/color_names.inc b/core/color_names.inc index 03c28e144cb1..2cf052c7d443 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -144,7 +144,7 @@ static void _populate_named_colors() { _named_colors.insert("thistle", Color(0.85f, 0.75f, 0.85f)); _named_colors.insert("tomato", Color(1.00f, 0.39f, 0.28f)); _named_colors.insert("turquoise", Color(0.25f, 0.88f, 0.82f)); - _named_colors.insert("transparent", Color(1.00f, 1.00f, 1.00f, 0.00)); + _named_colors.insert("transparent", Color(1.00f, 1.00f, 1.00f, 0.00f)); _named_colors.insert("violet", Color(0.93f, 0.51f, 0.93f)); _named_colors.insert("webgray", Color(0.50f, 0.50f, 0.50f)); _named_colors.insert("webgreen", Color(0.00f, 0.50f, 0.00f)); From 63526de97626a60dd3df2987c6f35a78fe5395f7 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 16 Aug 2020 11:46:43 +0530 Subject: [PATCH 21/27] Separate the transformation code to a new .inc file to prevent linker errors --- core/color_names.inc | 116 ------------------------ core/uppercase_name_transformation.inc | 118 +++++++++++++++++++++++++ core/variant_call.cpp | 1 + 3 files changed, 119 insertions(+), 116 deletions(-) create mode 100644 core/uppercase_name_transformation.inc diff --git a/core/color_names.inc b/core/color_names.inc index 2cf052c7d443..a45feebac641 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -1,8 +1,6 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names // and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 #include "core/map.h" -#include "core/ustring.h" -#include "core/vector.h" static Map _named_colors; static void _populate_named_colors() { @@ -156,117 +154,3 @@ static void _populate_named_colors() { _named_colors.insert("yellow", Color(1.00f, 1.00f, 0.00f)); _named_colors.insert("yellowgreen", Color(0.60f, 0.80f, 0.20f)); } - -static Vector _modifiable_colors; -static Vector _color_descriptors; -static void _populate_uppercase_token_lists() { - if (_modifiable_colors.empty()) { - _modifiable_colors.append("AQUAMARINE"); - _modifiable_colors.append("BLACK"); - _modifiable_colors.append("BLUE"); - _modifiable_colors.append("BROWN"); - _modifiable_colors.append("CORAL"); - _modifiable_colors.append("CYAN"); - _modifiable_colors.append("GRAY"); - _modifiable_colors.append("GREEN"); - _modifiable_colors.append("GOLDENROD"); - _modifiable_colors.append("KHAKI"); - _modifiable_colors.append("MAROON"); - _modifiable_colors.append("ORANGE"); - _modifiable_colors.append("ORCHID"); - _modifiable_colors.append("PINK"); - _modifiable_colors.append("PURPLE"); - _modifiable_colors.append("RED"); - _modifiable_colors.append("TURQUOISE"); - _modifiable_colors.append("WHITE"); - _modifiable_colors.append("YELLOW"); - } - - if (_color_descriptors.empty()) { - _color_descriptors.append("DARK"); - _color_descriptors.append("MEDIUM"); - _color_descriptors.append("LIGHT"); - _color_descriptors.append("OLIVE"); - _color_descriptors.append("PALE"); - _color_descriptors.append("SEA"); - _color_descriptors.append("SKY"); - _color_descriptors.append("SLATE"); - _color_descriptors.append("SPRING"); - _color_descriptors.append("STEEL"); - _color_descriptors.append("WEB"); - } -} - -static String _insert_underscores(const String &name, const Vector &tokens) { - String name_with_underscores(name); - - for (int i = 0; i < tokens.size(); ++i) { - const String &token = tokens[i]; - - // Skip the following steps if the word is the same as the whole name - if (token == name_with_underscores) { - continue; - } - - int begin = name_with_underscores.find(token, 0); - - // Skip the following steps if the word isn't found in the name - if (begin < 0) { - continue; - } - - int end = begin + token.length() - 1; - - // If the word isn't at the beginning - if (begin > 0) { - // If the letter before it isn't already an underscore - if (name_with_underscores[begin - 1] != '_') { - name_with_underscores = name_with_underscores.insert(begin, "_"); - } - } - - // If the word isn't at the end - if (end < name_with_underscores.length() - 2) { - // If the letter after it isn't already an underscore - if (name_with_underscores[end + 1] != '_') { - name_with_underscores = name_with_underscores.insert(end + 1, "_"); - } - } - } - - return name_with_underscores; -} - -static String _to_uppercase_name(const String &name) { - // Edge cases - if (name == "blanchedalmond") { - return "BLANCHED_ALMOND"; - } else if (name == "burlywood") { - return "BURLY_WOOD"; - } else if (name == "lavenderblush") { - return "LAVENDER_BLUSH"; - } else if (name == "lemonchiffon") { - return "LEMON_CHIFFON"; - } else if (name == "mintcream") { - return "MINT_CREAM"; - } else if (name == "mistyrose") { - return "MISTY_ROSE"; - } else if (name == "oldlace") { - return "OLD_LACE"; - } else if (name == "olivedrab") { - return "OLIVE_DRAB"; - } else if (name == "papayawhip") { - return "PAPAYA_WHIP"; - } else if (name == "peachpuff") { - return "PEACH_PUFF"; - } else if (name == "seashell") { - return "SEA_SHELL"; - } - - // All other cases - _populate_uppercase_token_lists(); - String uppercase_name = name.to_upper(); - uppercase_name = _insert_underscores(uppercase_name, _modifiable_colors); - uppercase_name = _insert_underscores(uppercase_name, _color_descriptors); - return uppercase_name; -} diff --git a/core/uppercase_name_transformation.inc b/core/uppercase_name_transformation.inc new file mode 100644 index 000000000000..d701048ceaea --- /dev/null +++ b/core/uppercase_name_transformation.inc @@ -0,0 +1,118 @@ +// Names from https://en.wikipedia.org/wiki/X11_color_names +// and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 +#include "core/ustring.h" +#include "core/vector.h" + +static Vector _modifiable_colors; +static Vector _color_descriptors; +static void _populate_uppercase_token_lists() { + if (_modifiable_colors.empty()) { + _modifiable_colors.append("AQUAMARINE"); + _modifiable_colors.append("BLACK"); + _modifiable_colors.append("BLUE"); + _modifiable_colors.append("BROWN"); + _modifiable_colors.append("CORAL"); + _modifiable_colors.append("CYAN"); + _modifiable_colors.append("GRAY"); + _modifiable_colors.append("GREEN"); + _modifiable_colors.append("GOLDENROD"); + _modifiable_colors.append("KHAKI"); + _modifiable_colors.append("MAROON"); + _modifiable_colors.append("ORANGE"); + _modifiable_colors.append("ORCHID"); + _modifiable_colors.append("PINK"); + _modifiable_colors.append("PURPLE"); + _modifiable_colors.append("RED"); + _modifiable_colors.append("TURQUOISE"); + _modifiable_colors.append("WHITE"); + _modifiable_colors.append("YELLOW"); + } + + if (_color_descriptors.empty()) { + _color_descriptors.append("DARK"); + _color_descriptors.append("MEDIUM"); + _color_descriptors.append("LIGHT"); + _color_descriptors.append("OLIVE"); + _color_descriptors.append("PALE"); + _color_descriptors.append("SEA"); + _color_descriptors.append("SKY"); + _color_descriptors.append("SLATE"); + _color_descriptors.append("SPRING"); + _color_descriptors.append("STEEL"); + _color_descriptors.append("WEB"); + } +} + +static String _insert_underscores(const String &name, const Vector &tokens) { + String name_with_underscores(name); + + for (int i = 0; i < tokens.size(); ++i) { + const String &token = tokens[i]; + + // Skip the following steps if the word is the same as the whole name + if (token == name_with_underscores) { + continue; + } + + int begin = name_with_underscores.find(token, 0); + + // Skip the following steps if the word isn't found in the name + if (begin < 0) { + continue; + } + + int end = begin + token.length() - 1; + + // If the word isn't at the beginning + if (begin > 0) { + // If the letter before it isn't already an underscore + if (name_with_underscores[begin - 1] != '_') { + name_with_underscores = name_with_underscores.insert(begin, "_"); + } + } + + // If the word isn't at the end + if (end < name_with_underscores.length() - 2) { + // If the letter after it isn't already an underscore + if (name_with_underscores[end + 1] != '_') { + name_with_underscores = name_with_underscores.insert(end + 1, "_"); + } + } + } + + return name_with_underscores; +} + +String _to_uppercase_name(const String &name) { + // Edge cases + if (name == "blanchedalmond") { + return "BLANCHED_ALMOND"; + } else if (name == "burlywood") { + return "BURLY_WOOD"; + } else if (name == "lavenderblush") { + return "LAVENDER_BLUSH"; + } else if (name == "lemonchiffon") { + return "LEMON_CHIFFON"; + } else if (name == "mintcream") { + return "MINT_CREAM"; + } else if (name == "mistyrose") { + return "MISTY_ROSE"; + } else if (name == "oldlace") { + return "OLD_LACE"; + } else if (name == "olivedrab") { + return "OLIVE_DRAB"; + } else if (name == "papayawhip") { + return "PAPAYA_WHIP"; + } else if (name == "peachpuff") { + return "PEACH_PUFF"; + } else if (name == "seashell") { + return "SEA_SHELL"; + } + + // All other cases + _populate_uppercase_token_lists(); + String uppercase_name = name.to_upper(); + uppercase_name = _insert_underscores(uppercase_name, _modifiable_colors); + uppercase_name = _insert_underscores(uppercase_name, _color_descriptors); + return uppercase_name; +} diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 241451cd3ea6..2ca8bc4769b4 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -37,6 +37,7 @@ #include "core/io/compression.h" #include "core/object.h" #include "core/os/os.h" +#include "core/uppercase_name_transformation.inc" typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args); typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args); From 2f3f2859560a1b39ad21a004bd70ae1c387e081a Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 16 Aug 2020 11:57:20 +0530 Subject: [PATCH 22/27] Add deepksyblue as an edge case --- core/uppercase_name_transformation.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/uppercase_name_transformation.inc b/core/uppercase_name_transformation.inc index d701048ceaea..8a6e92c892ee 100644 --- a/core/uppercase_name_transformation.inc +++ b/core/uppercase_name_transformation.inc @@ -89,6 +89,8 @@ String _to_uppercase_name(const String &name) { return "BLANCHED_ALMOND"; } else if (name == "burlywood") { return "BURLY_WOOD"; + } else if (name == "deepskyblue") { + return "DEEP_SKY_BLUE"; } else if (name == "lavenderblush") { return "LAVENDER_BLUSH"; } else if (name == "lemonchiffon") { From f63dab24310ae64a8b71b18a520da9a1fe5e7194 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 16 Aug 2020 14:15:39 +0530 Subject: [PATCH 23/27] Make _to_uppercase_name() static as intended --- core/uppercase_name_transformation.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/uppercase_name_transformation.inc b/core/uppercase_name_transformation.inc index 8a6e92c892ee..f165747877c3 100644 --- a/core/uppercase_name_transformation.inc +++ b/core/uppercase_name_transformation.inc @@ -83,7 +83,7 @@ static String _insert_underscores(const String &name, const Vector &toke return name_with_underscores; } -String _to_uppercase_name(const String &name) { +static String _to_uppercase_name(const String &name) { // Edge cases if (name == "blanchedalmond") { return "BLANCHED_ALMOND"; From ec0635382d779c72ca62c850f02a9ba07f4a0e71 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 15 Nov 2020 13:44:21 +0530 Subject: [PATCH 24/27] Add descriptive comments and remove Vectors --- core/uppercase_name_transformation.inc | 76 +++++++++++++------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/core/uppercase_name_transformation.inc b/core/uppercase_name_transformation.inc index f165747877c3..0b3c024d02e3 100644 --- a/core/uppercase_name_transformation.inc +++ b/core/uppercase_name_transformation.inc @@ -3,43 +3,43 @@ #include "core/ustring.h" #include "core/vector.h" -static Vector _modifiable_colors; -static Vector _color_descriptors; +static Vector _common_colors; +static Vector _common_color_adjectives; + static void _populate_uppercase_token_lists() { - if (_modifiable_colors.empty()) { - _modifiable_colors.append("AQUAMARINE"); - _modifiable_colors.append("BLACK"); - _modifiable_colors.append("BLUE"); - _modifiable_colors.append("BROWN"); - _modifiable_colors.append("CORAL"); - _modifiable_colors.append("CYAN"); - _modifiable_colors.append("GRAY"); - _modifiable_colors.append("GREEN"); - _modifiable_colors.append("GOLDENROD"); - _modifiable_colors.append("KHAKI"); - _modifiable_colors.append("MAROON"); - _modifiable_colors.append("ORANGE"); - _modifiable_colors.append("ORCHID"); - _modifiable_colors.append("PINK"); - _modifiable_colors.append("PURPLE"); - _modifiable_colors.append("RED"); - _modifiable_colors.append("TURQUOISE"); - _modifiable_colors.append("WHITE"); - _modifiable_colors.append("YELLOW"); + if (_common_colors.empty()) { + _common_colors.append("AQUAMARINE"); + _common_colors.append("BLACK"); + _common_colors.append("BLUE"); + _common_colors.append("BROWN"); + _common_colors.append("CORAL"); + _common_colors.append("CYAN"); + _common_colors.append("GRAY"); + _common_colors.append("GREEN"); + _common_colors.append("GOLDENROD"); + _common_colors.append("KHAKI"); + _common_colors.append("MAROON"); + _common_colors.append("ORANGE"); + _common_colors.append("ORCHID"); + _common_colors.append("PINK"); + _common_colors.append("PURPLE"); + _common_colors.append("RED"); + _common_colors.append("TURQUOISE"); + _common_colors.append("WHITE"); + _common_colors.append("YELLOW"); } - if (_color_descriptors.empty()) { - _color_descriptors.append("DARK"); - _color_descriptors.append("MEDIUM"); - _color_descriptors.append("LIGHT"); - _color_descriptors.append("OLIVE"); - _color_descriptors.append("PALE"); - _color_descriptors.append("SEA"); - _color_descriptors.append("SKY"); - _color_descriptors.append("SLATE"); - _color_descriptors.append("SPRING"); - _color_descriptors.append("STEEL"); - _color_descriptors.append("WEB"); + if (_common_color_adjectives.empty()) { + _common_color_adjectives.append("DARK"); + _common_color_adjectives.append("MEDIUM"); + _common_color_adjectives.append("LIGHT"); + _common_color_adjectives.append("PALE"); + _common_color_adjectives.append("SEA"); + _common_color_adjectives.append("SKY"); + _common_color_adjectives.append("SLATE"); + _common_color_adjectives.append("SPRING"); + _common_color_adjectives.append("STEEL"); + _common_color_adjectives.append("WEB"); } } @@ -84,12 +84,14 @@ static String _insert_underscores(const String &name, const Vector &toke } static String _to_uppercase_name(const String &name) { - // Edge cases + // Edge cases where the color names and their respective adjectives don't appear in the cached lists. + // These names are unique enough to warrant not caching them in the lists. if (name == "blanchedalmond") { return "BLANCHED_ALMOND"; } else if (name == "burlywood") { return "BURLY_WOOD"; } else if (name == "deepskyblue") { + // This case behaves weirdly unless kept here since "DEEP" is not in the cached lists. return "DEEP_SKY_BLUE"; } else if (name == "lavenderblush") { return "LAVENDER_BLUSH"; @@ -114,7 +116,7 @@ static String _to_uppercase_name(const String &name) { // All other cases _populate_uppercase_token_lists(); String uppercase_name = name.to_upper(); - uppercase_name = _insert_underscores(uppercase_name, _modifiable_colors); - uppercase_name = _insert_underscores(uppercase_name, _color_descriptors); + uppercase_name = _insert_underscores(uppercase_name, _common_colors); + uppercase_name = _insert_underscores(uppercase_name, _common_color_adjectives); return uppercase_name; } From 50fb362fbc44e64c31f5fe349226e0353145cd26 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 15 Nov 2020 14:13:42 +0530 Subject: [PATCH 25/27] Adopt changes with new code organisation --- core/color_names.inc | 156 -- core/math/color.cpp | 3 + core/math/color_names.inc | 295 +- .../color_uppercase_name_transformation.inc} | 36 +- core/variant_call.cpp | 2421 ----------------- 5 files changed, 184 insertions(+), 2727 deletions(-) delete mode 100644 core/color_names.inc rename core/{uppercase_name_transformation.inc => variant/color_uppercase_name_transformation.inc} (62%) delete mode 100644 core/variant_call.cpp diff --git a/core/color_names.inc b/core/color_names.inc deleted file mode 100644 index a45feebac641..000000000000 --- a/core/color_names.inc +++ /dev/null @@ -1,156 +0,0 @@ -// Names from https://en.wikipedia.org/wiki/X11_color_names -// and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 -#include "core/map.h" - -static Map _named_colors; -static void _populate_named_colors() { - if (!_named_colors.empty()) { - return; - } - _named_colors.insert("aliceblue", Color(0.94f, 0.97f, 1.00f)); - _named_colors.insert("antiquewhite", Color(0.98f, 0.92f, 0.84f)); - _named_colors.insert("aqua", Color(0.00f, 1.00f, 1.00f)); - _named_colors.insert("aquamarine", Color(0.50f, 1.00f, 0.83f)); - _named_colors.insert("azure", Color(0.94f, 1.00f, 1.00f)); - _named_colors.insert("beige", Color(0.96f, 0.96f, 0.86f)); - _named_colors.insert("bisque", Color(1.00f, 0.89f, 0.77f)); - _named_colors.insert("black", Color(0.00f, 0.00f, 0.00f)); - _named_colors.insert("blanchedalmond", Color(1.00f, 0.92f, 0.80f)); - _named_colors.insert("blue", Color(0.00f, 0.00f, 1.00f)); - _named_colors.insert("blueviolet", Color(0.54f, 0.17f, 0.89f)); - _named_colors.insert("brown", Color(0.65f, 0.16f, 0.16f)); - _named_colors.insert("burlywood", Color(0.87f, 0.72f, 0.53f)); - _named_colors.insert("cadetblue", Color(0.37f, 0.62f, 0.63f)); - _named_colors.insert("chartreuse", Color(0.50f, 1.00f, 0.00f)); - _named_colors.insert("chocolate", Color(0.82f, 0.41f, 0.12f)); - _named_colors.insert("coral", Color(1.00f, 0.50f, 0.31f)); - _named_colors.insert("cornflowerblue", Color(0.39f, 0.58f, 0.93f)); - _named_colors.insert("cornsilk", Color(1.00f, 0.97f, 0.86f)); - _named_colors.insert("crimson", Color(0.86f, 0.08f, 0.24f)); - _named_colors.insert("cyan", Color(0.00f, 1.00f, 1.00f)); - _named_colors.insert("darkblue", Color(0.00f, 0.00f, 0.55f)); - _named_colors.insert("darkcyan", Color(0.00f, 0.55f, 0.55f)); - _named_colors.insert("darkgoldenrod", Color(0.72f, 0.53f, 0.04f)); - _named_colors.insert("darkgray", Color(0.66f, 0.66f, 0.66f)); - _named_colors.insert("darkgreen", Color(0.00f, 0.39f, 0.00f)); - _named_colors.insert("darkkhaki", Color(0.74f, 0.72f, 0.42f)); - _named_colors.insert("darkmagenta", Color(0.55f, 0.00f, 0.55f)); - _named_colors.insert("darkolivegreen", Color(0.33f, 0.42f, 0.18f)); - _named_colors.insert("darkorange", Color(1.00f, 0.55f, 0.00f)); - _named_colors.insert("darkorchid", Color(0.60f, 0.20f, 0.80f)); - _named_colors.insert("darkred", Color(0.55f, 0.00f, 0.00f)); - _named_colors.insert("darksalmon", Color(0.91f, 0.59f, 0.48f)); - _named_colors.insert("darkseagreen", Color(0.56f, 0.74f, 0.56f)); - _named_colors.insert("darkslateblue", Color(0.28f, 0.24f, 0.55f)); - _named_colors.insert("darkslategray", Color(0.18f, 0.31f, 0.31f)); - _named_colors.insert("darkturquoise", Color(0.00f, 0.81f, 0.82f)); - _named_colors.insert("darkviolet", Color(0.58f, 0.00f, 0.83f)); - _named_colors.insert("deeppink", Color(1.00f, 0.08f, 0.58f)); - _named_colors.insert("deepskyblue", Color(0.00f, 0.75f, 1.00f)); - _named_colors.insert("dimgray", Color(0.41f, 0.41f, 0.41f)); - _named_colors.insert("dodgerblue", Color(0.12f, 0.56f, 1.00f)); - _named_colors.insert("firebrick", Color(0.70f, 0.13f, 0.13f)); - _named_colors.insert("floralwhite", Color(1.00f, 0.98f, 0.94f)); - _named_colors.insert("forestgreen", Color(0.13f, 0.55f, 0.13f)); - _named_colors.insert("fuchsia", Color(1.00f, 0.00f, 1.00f)); - _named_colors.insert("gainsboro", Color(0.86f, 0.86f, 0.86f)); - _named_colors.insert("ghostwhite", Color(0.97f, 0.97f, 1.00f)); - _named_colors.insert("gold", Color(1.00f, 0.84f, 0.00f)); - _named_colors.insert("goldenrod", Color(0.85f, 0.65f, 0.13f)); - _named_colors.insert("gray", Color(0.75f, 0.75f, 0.75f)); - _named_colors.insert("green", Color(0.00f, 1.00f, 0.00f)); - _named_colors.insert("greenyellow", Color(0.68f, 1.00f, 0.18f)); - _named_colors.insert("honeydew", Color(0.94f, 1.00f, 0.94f)); - _named_colors.insert("hotpink", Color(1.00f, 0.41f, 0.71f)); - _named_colors.insert("indianred", Color(0.80f, 0.36f, 0.36f)); - _named_colors.insert("indigo", Color(0.29f, 0.00f, 0.51f)); - _named_colors.insert("ivory", Color(1.00f, 1.00f, 0.94f)); - _named_colors.insert("khaki", Color(0.94f, 0.90f, 0.55f)); - _named_colors.insert("lavender", Color(0.90f, 0.90f, 0.98f)); - _named_colors.insert("lavenderblush", Color(1.00f, 0.94f, 0.96f)); - _named_colors.insert("lawngreen", Color(0.49f, 0.99f, 0.00f)); - _named_colors.insert("lemonchiffon", Color(1.00f, 0.98f, 0.80f)); - _named_colors.insert("lightblue", Color(0.68f, 0.85f, 0.90f)); - _named_colors.insert("lightcoral", Color(0.94f, 0.50f, 0.50f)); - _named_colors.insert("lightcyan", Color(0.88f, 1.00f, 1.00f)); - _named_colors.insert("lightgoldenrod", Color(0.98f, 0.98f, 0.82f)); - _named_colors.insert("lightgray", Color(0.83f, 0.83f, 0.83f)); - _named_colors.insert("lightgreen", Color(0.56f, 0.93f, 0.56f)); - _named_colors.insert("lightpink", Color(1.00f, 0.71f, 0.76f)); - _named_colors.insert("lightsalmon", Color(1.00f, 0.63f, 0.48f)); - _named_colors.insert("lightseagreen", Color(0.13f, 0.70f, 0.67f)); - _named_colors.insert("lightskyblue", Color(0.53f, 0.81f, 0.98f)); - _named_colors.insert("lightslategray", Color(0.47f, 0.53f, 0.60f)); - _named_colors.insert("lightsteelblue", Color(0.69f, 0.77f, 0.87f)); - _named_colors.insert("lightyellow", Color(1.00f, 1.00f, 0.88f)); - _named_colors.insert("lime", Color(0.00f, 1.00f, 0.00f)); - _named_colors.insert("limegreen", Color(0.20f, 0.80f, 0.20f)); - _named_colors.insert("linen", Color(0.98f, 0.94f, 0.90f)); - _named_colors.insert("magenta", Color(1.00f, 0.00f, 1.00f)); - _named_colors.insert("maroon", Color(0.69f, 0.19f, 0.38f)); - _named_colors.insert("mediumaquamarine", Color(0.40f, 0.80f, 0.67f)); - _named_colors.insert("mediumblue", Color(0.00f, 0.00f, 0.80f)); - _named_colors.insert("mediumorchid", Color(0.73f, 0.33f, 0.83f)); - _named_colors.insert("mediumpurple", Color(0.58f, 0.44f, 0.86f)); - _named_colors.insert("mediumseagreen", Color(0.24f, 0.70f, 0.44f)); - _named_colors.insert("mediumslateblue", Color(0.48f, 0.41f, 0.93f)); - _named_colors.insert("mediumspringgreen", Color(0.00f, 0.98f, 0.60f)); - _named_colors.insert("mediumturquoise", Color(0.28f, 0.82f, 0.80f)); - _named_colors.insert("mediumvioletred", Color(0.78f, 0.08f, 0.52f)); - _named_colors.insert("midnightblue", Color(0.10f, 0.10f, 0.44f)); - _named_colors.insert("mintcream", Color(0.96f, 1.00f, 0.98f)); - _named_colors.insert("mistyrose", Color(1.00f, 0.89f, 0.88f)); - _named_colors.insert("moccasin", Color(1.00f, 0.89f, 0.71f)); - _named_colors.insert("navajowhite", Color(1.00f, 0.87f, 0.68f)); - _named_colors.insert("navyblue", Color(0.00f, 0.00f, 0.50f)); - _named_colors.insert("oldlace", Color(0.99f, 0.96f, 0.90f)); - _named_colors.insert("olive", Color(0.50f, 0.50f, 0.00f)); - _named_colors.insert("olivedrab", Color(0.42f, 0.56f, 0.14f)); - _named_colors.insert("orange", Color(1.00f, 0.65f, 0.00f)); - _named_colors.insert("orangered", Color(1.00f, 0.27f, 0.00f)); - _named_colors.insert("orchid", Color(0.85f, 0.44f, 0.84f)); - _named_colors.insert("palegoldenrod", Color(0.93f, 0.91f, 0.67f)); - _named_colors.insert("palegreen", Color(0.60f, 0.98f, 0.60f)); - _named_colors.insert("paleturquoise", Color(0.69f, 0.93f, 0.93f)); - _named_colors.insert("palevioletred", Color(0.86f, 0.44f, 0.58f)); - _named_colors.insert("papayawhip", Color(1.00f, 0.94f, 0.84f)); - _named_colors.insert("peachpuff", Color(1.00f, 0.85f, 0.73f)); - _named_colors.insert("peru", Color(0.80f, 0.52f, 0.25f)); - _named_colors.insert("pink", Color(1.00f, 0.75f, 0.80f)); - _named_colors.insert("plum", Color(0.87f, 0.63f, 0.87f)); - _named_colors.insert("powderblue", Color(0.69f, 0.88f, 0.90f)); - _named_colors.insert("purple", Color(0.63f, 0.13f, 0.94f)); - _named_colors.insert("rebeccapurple", Color(0.40f, 0.20f, 0.60f)); - _named_colors.insert("red", Color(1.00f, 0.00f, 0.00f)); - _named_colors.insert("rosybrown", Color(0.74f, 0.56f, 0.56f)); - _named_colors.insert("royalblue", Color(0.25f, 0.41f, 0.88f)); - _named_colors.insert("saddlebrown", Color(0.55f, 0.27f, 0.07f)); - _named_colors.insert("salmon", Color(0.98f, 0.50f, 0.45f)); - _named_colors.insert("sandybrown", Color(0.96f, 0.64f, 0.38f)); - _named_colors.insert("seagreen", Color(0.18f, 0.55f, 0.34f)); - _named_colors.insert("seashell", Color(1.00f, 0.96f, 0.93f)); - _named_colors.insert("sienna", Color(0.63f, 0.32f, 0.18f)); - _named_colors.insert("silver", Color(0.75f, 0.75f, 0.75f)); - _named_colors.insert("skyblue", Color(0.53f, 0.81f, 0.92f)); - _named_colors.insert("slateblue", Color(0.42f, 0.35f, 0.80f)); - _named_colors.insert("slategray", Color(0.44f, 0.50f, 0.56f)); - _named_colors.insert("snow", Color(1.00f, 0.98f, 0.98f)); - _named_colors.insert("springgreen", Color(0.00f, 1.00f, 0.50f)); - _named_colors.insert("steelblue", Color(0.27f, 0.51f, 0.71f)); - _named_colors.insert("tan", Color(0.82f, 0.71f, 0.55f)); - _named_colors.insert("teal", Color(0.00f, 0.50f, 0.50f)); - _named_colors.insert("thistle", Color(0.85f, 0.75f, 0.85f)); - _named_colors.insert("tomato", Color(1.00f, 0.39f, 0.28f)); - _named_colors.insert("turquoise", Color(0.25f, 0.88f, 0.82f)); - _named_colors.insert("transparent", Color(1.00f, 1.00f, 1.00f, 0.00f)); - _named_colors.insert("violet", Color(0.93f, 0.51f, 0.93f)); - _named_colors.insert("webgray", Color(0.50f, 0.50f, 0.50f)); - _named_colors.insert("webgreen", Color(0.00f, 0.50f, 0.00f)); - _named_colors.insert("webmaroon", Color(0.50f, 0.00f, 0.00f)); - _named_colors.insert("webpurple", Color(0.50f, 0.00f, 0.50f)); - _named_colors.insert("wheat", Color(0.96f, 0.87f, 0.70f)); - _named_colors.insert("white", Color(1.00f, 1.00f, 1.00f)); - _named_colors.insert("whitesmoke", Color(0.96f, 0.96f, 0.96f)); - _named_colors.insert("yellow", Color(1.00f, 1.00f, 0.00f)); - _named_colors.insert("yellowgreen", Color(0.60f, 0.80f, 0.20f)); -} diff --git a/core/math/color.cpp b/core/math/color.cpp index 2afe14bd6317..7df336f721f6 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -35,6 +35,8 @@ #include "core/string/print_string.h" #include "core/templates/map.h" +#include "color_uppercase_name_transformation.inc" + uint32_t Color::to_argb32() const { uint32_t c = (uint8_t)Math::round(a * 255); c <<= 8; @@ -363,6 +365,7 @@ Color Color::named(const String &p_name) { name = name.replace("'", ""); name = name.replace(".", ""); name = name.to_lower(); + name = _to_uppercase_color_name(name); int idx = 0; while (named_colors[idx].name != nullptr) { diff --git a/core/math/color_names.inc b/core/math/color_names.inc index 523c7e3c59c2..0764c4c745bc 100644 --- a/core/math/color_names.inc +++ b/core/math/color_names.inc @@ -1,4 +1,5 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names +// and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 // So this in a way that does not require memory allocation // the old way leaked memory @@ -10,151 +11,151 @@ struct NamedColor { }; static NamedColor named_colors[] = { - { "aliceblue", Color(0.94, 0.97, 1.00) }, - { "antiquewhite", Color(0.98, 0.92, 0.84) }, - { "aqua", Color(0.00, 1.00, 1.00) }, - { "aquamarine", Color(0.50, 1.00, 0.83) }, - { "azure", Color(0.94, 1.00, 1.00) }, - { "beige", Color(0.96, 0.96, 0.86) }, - { "bisque", Color(1.00, 0.89, 0.77) }, - { "black", Color(0.00, 0.00, 0.00) }, - { "blanchedalmond", Color(1.00, 0.92, 0.80) }, - { "blue", Color(0.00, 0.00, 1.00) }, - { "blueviolet", Color(0.54, 0.17, 0.89) }, - { "brown", Color(0.65, 0.16, 0.16) }, - { "burlywood", Color(0.87, 0.72, 0.53) }, - { "cadetblue", Color(0.37, 0.62, 0.63) }, - { "chartreuse", Color(0.50, 1.00, 0.00) }, - { "chocolate", Color(0.82, 0.41, 0.12) }, - { "coral", Color(1.00, 0.50, 0.31) }, - { "cornflower", Color(0.39, 0.58, 0.93) }, - { "cornsilk", Color(1.00, 0.97, 0.86) }, - { "crimson", Color(0.86, 0.08, 0.24) }, - { "cyan", Color(0.00, 1.00, 1.00) }, - { "darkblue", Color(0.00, 0.00, 0.55) }, - { "darkcyan", Color(0.00, 0.55, 0.55) }, - { "darkgoldenrod", Color(0.72, 0.53, 0.04) }, - { "darkgray", Color(0.66, 0.66, 0.66) }, - { "darkgreen", Color(0.00, 0.39, 0.00) }, - { "darkkhaki", Color(0.74, 0.72, 0.42) }, - { "darkmagenta", Color(0.55, 0.00, 0.55) }, - { "darkolivegreen", Color(0.33, 0.42, 0.18) }, - { "darkorange", Color(1.00, 0.55, 0.00) }, - { "darkorchid", Color(0.60, 0.20, 0.80) }, - { "darkred", Color(0.55, 0.00, 0.00) }, - { "darksalmon", Color(0.91, 0.59, 0.48) }, - { "darkseagreen", Color(0.56, 0.74, 0.56) }, - { "darkslateblue", Color(0.28, 0.24, 0.55) }, - { "darkslategray", Color(0.18, 0.31, 0.31) }, - { "darkturquoise", Color(0.00, 0.81, 0.82) }, - { "darkviolet", Color(0.58, 0.00, 0.83) }, - { "deeppink", Color(1.00, 0.08, 0.58) }, - { "deepskyblue", Color(0.00, 0.75, 1.00) }, - { "dimgray", Color(0.41, 0.41, 0.41) }, - { "dodgerblue", Color(0.12, 0.56, 1.00) }, - { "firebrick", Color(0.70, 0.13, 0.13) }, - { "floralwhite", Color(1.00, 0.98, 0.94) }, - { "forestgreen", Color(0.13, 0.55, 0.13) }, - { "fuchsia", Color(1.00, 0.00, 1.00) }, - { "gainsboro", Color(0.86, 0.86, 0.86) }, - { "ghostwhite", Color(0.97, 0.97, 1.00) }, - { "gold", Color(1.00, 0.84, 0.00) }, - { "goldenrod", Color(0.85, 0.65, 0.13) }, - { "gray", Color(0.75, 0.75, 0.75) }, - { "green", Color(0.00, 1.00, 0.00) }, - { "greenyellow", Color(0.68, 1.00, 0.18) }, - { "honeydew", Color(0.94, 1.00, 0.94) }, - { "hotpink", Color(1.00, 0.41, 0.71) }, - { "indianred", Color(0.80, 0.36, 0.36) }, - { "indigo", Color(0.29, 0.00, 0.51) }, - { "ivory", Color(1.00, 1.00, 0.94) }, - { "khaki", Color(0.94, 0.90, 0.55) }, - { "lavender", Color(0.90, 0.90, 0.98) }, - { "lavenderblush", Color(1.00, 0.94, 0.96) }, - { "lawngreen", Color(0.49, 0.99, 0.00) }, - { "lemonchiffon", Color(1.00, 0.98, 0.80) }, - { "lightblue", Color(0.68, 0.85, 0.90) }, - { "lightcoral", Color(0.94, 0.50, 0.50) }, - { "lightcyan", Color(0.88, 1.00, 1.00) }, - { "lightgoldenrod", Color(0.98, 0.98, 0.82) }, - { "lightgray", Color(0.83, 0.83, 0.83) }, - { "lightgreen", Color(0.56, 0.93, 0.56) }, - { "lightpink", Color(1.00, 0.71, 0.76) }, - { "lightsalmon", Color(1.00, 0.63, 0.48) }, - { "lightseagreen", Color(0.13, 0.70, 0.67) }, - { "lightskyblue", Color(0.53, 0.81, 0.98) }, - { "lightslategray", Color(0.47, 0.53, 0.60) }, - { "lightsteelblue", Color(0.69, 0.77, 0.87) }, - { "lightyellow", Color(1.00, 1.00, 0.88) }, - { "lime", Color(0.00, 1.00, 0.00) }, - { "limegreen", Color(0.20, 0.80, 0.20) }, - { "linen", Color(0.98, 0.94, 0.90) }, - { "magenta", Color(1.00, 0.00, 1.00) }, - { "maroon", Color(0.69, 0.19, 0.38) }, - { "mediumaquamarine", Color(0.40, 0.80, 0.67) }, - { "mediumblue", Color(0.00, 0.00, 0.80) }, - { "mediumorchid", Color(0.73, 0.33, 0.83) }, - { "mediumpurple", Color(0.58, 0.44, 0.86) }, - { "mediumseagreen", Color(0.24, 0.70, 0.44) }, - { "mediumslateblue", Color(0.48, 0.41, 0.93) }, - { "mediumspringgreen", Color(0.00, 0.98, 0.60) }, - { "mediumturquoise", Color(0.28, 0.82, 0.80) }, - { "mediumvioletred", Color(0.78, 0.08, 0.52) }, - { "midnightblue", Color(0.10, 0.10, 0.44) }, - { "mintcream", Color(0.96, 1.00, 0.98) }, - { "mistyrose", Color(1.00, 0.89, 0.88) }, - { "moccasin", Color(1.00, 0.89, 0.71) }, - { "navajowhite", Color(1.00, 0.87, 0.68) }, - { "navyblue", Color(0.00, 0.00, 0.50) }, - { "oldlace", Color(0.99, 0.96, 0.90) }, - { "olive", Color(0.50, 0.50, 0.00) }, - { "olivedrab", Color(0.42, 0.56, 0.14) }, - { "orange", Color(1.00, 0.65, 0.00) }, - { "orangered", Color(1.00, 0.27, 0.00) }, - { "orchid", Color(0.85, 0.44, 0.84) }, - { "palegoldenrod", Color(0.93, 0.91, 0.67) }, - { "palegreen", Color(0.60, 0.98, 0.60) }, - { "paleturquoise", Color(0.69, 0.93, 0.93) }, - { "palevioletred", Color(0.86, 0.44, 0.58) }, - { "papayawhip", Color(1.00, 0.94, 0.84) }, - { "peachpuff", Color(1.00, 0.85, 0.73) }, - { "peru", Color(0.80, 0.52, 0.25) }, - { "pink", Color(1.00, 0.75, 0.80) }, - { "plum", Color(0.87, 0.63, 0.87) }, - { "powderblue", Color(0.69, 0.88, 0.90) }, - { "purple", Color(0.63, 0.13, 0.94) }, - { "rebeccapurple", Color(0.40, 0.20, 0.60) }, - { "red", Color(1.00, 0.00, 0.00) }, - { "rosybrown", Color(0.74, 0.56, 0.56) }, - { "royalblue", Color(0.25, 0.41, 0.88) }, - { "saddlebrown", Color(0.55, 0.27, 0.07) }, - { "salmon", Color(0.98, 0.50, 0.45) }, - { "sandybrown", Color(0.96, 0.64, 0.38) }, - { "seagreen", Color(0.18, 0.55, 0.34) }, - { "seashell", Color(1.00, 0.96, 0.93) }, - { "sienna", Color(0.63, 0.32, 0.18) }, - { "silver", Color(0.75, 0.75, 0.75) }, - { "skyblue", Color(0.53, 0.81, 0.92) }, - { "slateblue", Color(0.42, 0.35, 0.80) }, - { "slategray", Color(0.44, 0.50, 0.56) }, - { "snow", Color(1.00, 0.98, 0.98) }, - { "springgreen", Color(0.00, 1.00, 0.50) }, - { "steelblue", Color(0.27, 0.51, 0.71) }, - { "tan", Color(0.82, 0.71, 0.55) }, - { "teal", Color(0.00, 0.50, 0.50) }, - { "thistle", Color(0.85, 0.75, 0.85) }, - { "tomato", Color(1.00, 0.39, 0.28) }, - { "transparent", Color(1.00, 1.00, 1.00, 0.00) }, - { "turquoise", Color(0.25, 0.88, 0.82) }, - { "violet", Color(0.93, 0.51, 0.93) }, - { "webgray", Color(0.50, 0.50, 0.50) }, - { "webgreen", Color(0.00, 0.50, 0.00) }, - { "webmaroon", Color(0.50, 0.00, 0.00) }, - { "webpurple", Color(0.50, 0.00, 0.50) }, - { "wheat", Color(0.96, 0.87, 0.70) }, - { "white", Color(1.00, 1.00, 1.00) }, - { "whitesmoke", Color(0.96, 0.96, 0.96) }, - { "yellow", Color(1.00, 1.00, 0.00) }, - { "yellowgreen", Color(0.60, 0.80, 0.20) }, - { nullptr, Color(0.60, 0.80, 0.20) }, + { "aliceblue", Color(0.94f, 0.97f, 1.00f) }, + { "antiquewhite", Color(0.98f, 0.92f, 0.84f) }, + { "aqua", Color(0.00f, 1.00f, 1.00f) }, + { "aquamarine", Color(0.50f, 1.00f, 0.83f) }, + { "azure", Color(0.94f, 1.00f, 1.00f) }, + { "beige", Color(0.96f, 0.96f, 0.86f) }, + { "bisque", Color(1.00f, 0.89f, 0.77f) }, + { "black", Color(0.00f, 0.00f, 0.00f) }, + { "blanchedalmond", Color(1.00f, 0.92f, 0.80f) }, + { "blue", Color(0.00f, 0.00f, 1.00f) }, + { "blueviolet", Color(0.54f, 0.17f, 0.89f) }, + { "brown", Color(0.65f, 0.16f, 0.16f) }, + { "burlywood", Color(0.87f, 0.72f, 0.53f) }, + { "cadetblue", Color(0.37f, 0.62f, 0.63f) }, + { "chartreuse", Color(0.50f, 1.00f, 0.00f) }, + { "chocolate", Color(0.82f, 0.41f, 0.12f) }, + { "coral", Color(1.00f, 0.50f, 0.31f) }, + { "cornflowerblue", Color(0.39f, 0.58f, 0.93f) }, + { "cornsilk", Color(1.00f, 0.97f, 0.86f) }, + { "crimson", Color(0.86f, 0.08f, 0.24f) }, + { "cyan", Color(0.00f, 1.00f, 1.00f) }, + { "darkblue", Color(0.00f, 0.00f, 0.55f) }, + { "darkcyan", Color(0.00f, 0.55f, 0.55f) }, + { "darkgoldenrod", Color(0.72f, 0.53f, 0.04f) }, + { "darkgray", Color(0.66f, 0.66f, 0.66f) }, + { "darkgreen", Color(0.00f, 0.39f, 0.00f) }, + { "darkkhaki", Color(0.74f, 0.72f, 0.42f) }, + { "darkmagenta", Color(0.55f, 0.00f, 0.55f) }, + { "darkolivegreen", Color(0.33f, 0.42f, 0.18f) }, + { "darkorange", Color(1.00f, 0.55f, 0.00f) }, + { "darkorchid", Color(0.60f, 0.20f, 0.80f) }, + { "darkred", Color(0.55f, 0.00f, 0.00f) }, + { "darksalmon", Color(0.91f, 0.59f, 0.48f) }, + { "darkseagreen", Color(0.56f, 0.74f, 0.56f) }, + { "darkslateblue", Color(0.28f, 0.24f, 0.55f) }, + { "darkslategray", Color(0.18f, 0.31f, 0.31f) }, + { "darkturquoise", Color(0.00f, 0.81f, 0.82f) }, + { "darkviolet", Color(0.58f, 0.00f, 0.83f) }, + { "deeppink", Color(1.00f, 0.08f, 0.58f) }, + { "deepskyblue", Color(0.00f, 0.75f, 1.00f) }, + { "dimgray", Color(0.41f, 0.41f, 0.41f) }, + { "dodgerblue", Color(0.12f, 0.56f, 1.00f) }, + { "firebrick", Color(0.70f, 0.13f, 0.13f) }, + { "floralwhite", Color(1.00f, 0.98f, 0.94f) }, + { "forestgreen", Color(0.13f, 0.55f, 0.13f) }, + { "fuchsia", Color(1.00f, 0.00f, 1.00f) }, + { "gainsboro", Color(0.86f, 0.86f, 0.86f) }, + { "ghostwhite", Color(0.97f, 0.97f, 1.00f) }, + { "gold", Color(1.00f, 0.84f, 0.00f) }, + { "goldenrod", Color(0.85f, 0.65f, 0.13f) }, + { "gray", Color(0.75f, 0.75f, 0.75f) }, + { "green", Color(0.00f, 1.00f, 0.00f) }, + { "greenyellow", Color(0.68f, 1.00f, 0.18f) }, + { "honeydew", Color(0.94f, 1.00f, 0.94f) }, + { "hotpink", Color(1.00f, 0.41f, 0.71f) }, + { "indianred", Color(0.80f, 0.36f, 0.36f) }, + { "indigo", Color(0.29f, 0.00f, 0.51f) }, + { "ivory", Color(1.00f, 1.00f, 0.94f) }, + { "khaki", Color(0.94f, 0.90f, 0.55f) }, + { "lavender", Color(0.90f, 0.90f, 0.98f) }, + { "lavenderblush", Color(1.00f, 0.94f, 0.96f) }, + { "lawngreen", Color(0.49f, 0.99f, 0.00f) }, + { "lemonchiffon", Color(1.00f, 0.98f, 0.80f) }, + { "lightblue", Color(0.68f, 0.85f, 0.90f) }, + { "lightcoral", Color(0.94f, 0.50f, 0.50f) }, + { "lightcyan", Color(0.88f, 1.00f, 1.00f) }, + { "lightgoldenrod", Color(0.98f, 0.98f, 0.82f) }, + { "lightgray", Color(0.83f, 0.83f, 0.83f) }, + { "lightgreen", Color(0.56f, 0.93f, 0.56f) }, + { "lightpink", Color(1.00f, 0.71f, 0.76f) }, + { "lightsalmon", Color(1.00f, 0.63f, 0.48f) }, + { "lightseagreen", Color(0.13f, 0.70f, 0.67f) }, + { "lightskyblue", Color(0.53f, 0.81f, 0.98f) }, + { "lightslategray", Color(0.47f, 0.53f, 0.60f) }, + { "lightsteelblue", Color(0.69f, 0.77f, 0.87f) }, + { "lightyellow", Color(1.00f, 1.00f, 0.88f) }, + { "lime", Color(0.00f, 1.00f, 0.00f) }, + { "limegreen", Color(0.20f, 0.80f, 0.20f) }, + { "linen", Color(0.98f, 0.94f, 0.90f) }, + { "magenta", Color(1.00f, 0.00f, 1.00f) }, + { "maroon", Color(0.69f, 0.19f, 0.38f) }, + { "mediumaquamarine", Color(0.40f, 0.80f, 0.67f) }, + { "mediumblue", Color(0.00f, 0.00f, 0.80f) }, + { "mediumorchid", Color(0.73f, 0.33f, 0.83f) }, + { "mediumpurple", Color(0.58f, 0.44f, 0.86f) }, + { "mediumseagreen", Color(0.24f, 0.70f, 0.44f) }, + { "mediumslateblue", Color(0.48f, 0.41f, 0.93f) }, + { "mediumspringgreen", Color(0.00f, 0.98f, 0.60f) }, + { "mediumturquoise", Color(0.28f, 0.82f, 0.80f) }, + { "mediumvioletred", Color(0.78f, 0.08f, 0.52f) }, + { "midnightblue", Color(0.10f, 0.10f, 0.44f) }, + { "mintcream", Color(0.96f, 1.00f, 0.98f) }, + { "mistyrose", Color(1.00f, 0.89f, 0.88f) }, + { "moccasin", Color(1.00f, 0.89f, 0.71f) }, + { "navajowhite", Color(1.00f, 0.87f, 0.68f) }, + { "navyblue", Color(0.00f, 0.00f, 0.50f) }, + { "oldlace", Color(0.99f, 0.96f, 0.90f) }, + { "olive", Color(0.50f, 0.50f, 0.00f) }, + { "olivedrab", Color(0.42f, 0.56f, 0.14f) }, + { "orange", Color(1.00f, 0.65f, 0.00f) }, + { "orangered", Color(1.00f, 0.27f, 0.00f) }, + { "orchid", Color(0.85f, 0.44f, 0.84f) }, + { "palegoldenrod", Color(0.93f, 0.91f, 0.67f) }, + { "palegreen", Color(0.60f, 0.98f, 0.60f) }, + { "paleturquoise", Color(0.69f, 0.93f, 0.93f) }, + { "palevioletred", Color(0.86f, 0.44f, 0.58f) }, + { "papayawhip", Color(1.00f, 0.94f, 0.84f) }, + { "peachpuff", Color(1.00f, 0.85f, 0.73f) }, + { "peru", Color(0.80f, 0.52f, 0.25f) }, + { "pink", Color(1.00f, 0.75f, 0.80f) }, + { "plum", Color(0.87f, 0.63f, 0.87f) }, + { "powderblue", Color(0.69f, 0.88f, 0.90f) }, + { "purple", Color(0.63f, 0.13f, 0.94f) }, + { "rebeccapurple", Color(0.40f, 0.20f, 0.60f) }, + { "red", Color(1.00f, 0.00f, 0.00f) }, + { "rosybrown", Color(0.74f, 0.56f, 0.56f) }, + { "royalblue", Color(0.25f, 0.41f, 0.88f) }, + { "saddlebrown", Color(0.55f, 0.27f, 0.07f) }, + { "salmon", Color(0.98f, 0.50f, 0.45f) }, + { "sandybrown", Color(0.96f, 0.64f, 0.38f) }, + { "seagreen", Color(0.18f, 0.55f, 0.34f) }, + { "seashell", Color(1.00f, 0.96f, 0.93f) }, + { "sienna", Color(0.63f, 0.32f, 0.18f) }, + { "silver", Color(0.75f, 0.75f, 0.75f) }, + { "skyblue", Color(0.53f, 0.81f, 0.92f) }, + { "slateblue", Color(0.42f, 0.35f, 0.80f) }, + { "slategray", Color(0.44f, 0.50f, 0.56f) }, + { "snow", Color(1.00f, 0.98f, 0.98f) }, + { "springgreen", Color(0.00f, 1.00f, 0.50f) }, + { "steelblue", Color(0.27f, 0.51f, 0.71f) }, + { "tan", Color(0.82f, 0.71f, 0.55f) }, + { "teal", Color(0.00f, 0.50f, 0.50f) }, + { "thistle", Color(0.85f, 0.75f, 0.85f) }, + { "tomato", Color(1.00f, 0.39f, 0.28f) }, + { "turquoise", Color(0.25f, 0.88f, 0.82f) }, + { "transparent", Color(1.00f, 1.00f, 1.00f, 0.00f) }, + { "violet", Color(0.93f, 0.51f, 0.93f) }, + { "webgray", Color(0.50f, 0.50f, 0.50f) }, + { "webgreen", Color(0.00f, 0.50f, 0.00f) }, + { "webmaroon", Color(0.50f, 0.00f, 0.00f) }, + { "webpurple", Color(0.50f, 0.00f, 0.50f) }, + { "wheat", Color(0.96f, 0.87f, 0.70f) }, + { "white", Color(1.00f, 1.00f, 1.00f) }, + { "whitesmoke", Color(0.96f, 0.96f, 0.96f) }, + { "yellow", Color(1.00f, 1.00f, 0.00f) }, + { "yellowgreen", Color(0.60f, 0.80f, 0.20f) }, + { nullptr, Color(0.60f, 0.80f, 0.20f) } }; diff --git a/core/uppercase_name_transformation.inc b/core/variant/color_uppercase_name_transformation.inc similarity index 62% rename from core/uppercase_name_transformation.inc rename to core/variant/color_uppercase_name_transformation.inc index 0b3c024d02e3..49ab3a9e5eb6 100644 --- a/core/uppercase_name_transformation.inc +++ b/core/variant/color_uppercase_name_transformation.inc @@ -1,7 +1,37 @@ +/*************************************************************************/ +/* color_uppercase_name_transformation.inc */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + // Names from https://en.wikipedia.org/wiki/X11_color_names // and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 -#include "core/ustring.h" -#include "core/vector.h" +#include "core/string/ustring.h" +#include "core/templates/vector.h" static Vector _common_colors; static Vector _common_color_adjectives; @@ -83,7 +113,7 @@ static String _insert_underscores(const String &name, const Vector &toke return name_with_underscores; } -static String _to_uppercase_name(const String &name) { +static String _to_uppercase_color_name(const String &name) { // Edge cases where the color names and their respective adjectives don't appear in the cached lists. // These names are unique enough to warrant not caching them in the lists. if (name == "blanchedalmond") { diff --git a/core/variant_call.cpp b/core/variant_call.cpp deleted file mode 100644 index 2ca8bc4769b4..000000000000 --- a/core/variant_call.cpp +++ /dev/null @@ -1,2421 +0,0 @@ -/*************************************************************************/ -/* variant_call.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "variant.h" - -#include "core/color_names.inc" -#include "core/core_string_names.h" -#include "core/crypto/crypto_core.h" -#include "core/debugger/engine_debugger.h" -#include "core/io/compression.h" -#include "core/object.h" -#include "core/os/os.h" -#include "core/uppercase_name_transformation.inc" - -typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args); -typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args); - -struct _VariantCall { - static void Vector3_dot(Variant &r_ret, Variant &p_self, const Variant **p_args) { - r_ret = reinterpret_cast(p_self._data._mem)->dot(*reinterpret_cast(p_args[0]->_data._mem)); - } - - struct FuncData { - int arg_count; - Vector default_args; - Vector arg_types; - Vector arg_names; - Variant::Type return_type; - - bool _const; - bool returns; - - VariantFunc func; - - _FORCE_INLINE_ bool verify_arguments(const Variant **p_args, Callable::CallError &r_error) { - if (arg_count == 0) { - return true; - } - - const Variant::Type *tptr = &arg_types[0]; - - for (int i = 0; i < arg_count; i++) { - if (tptr[i] == Variant::NIL || tptr[i] == p_args[i]->type) { - continue; // all good - } - if (!Variant::can_convert(p_args[i]->type, tptr[i])) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = i; - r_error.expected = tptr[i]; - return false; - } - } - return true; - } - - _FORCE_INLINE_ void call(Variant &r_ret, Variant &p_self, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { -#ifdef DEBUG_ENABLED - if (p_argcount > arg_count) { - r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; - r_error.argument = arg_count; - return; - } else -#endif - if (p_argcount < arg_count) { - int def_argcount = default_args.size(); -#ifdef DEBUG_ENABLED - if (p_argcount < (arg_count - def_argcount)) { - r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = arg_count - def_argcount; - return; - } - -#endif - ERR_FAIL_COND(p_argcount > VARIANT_ARG_MAX); - const Variant *newargs[VARIANT_ARG_MAX]; - for (int i = 0; i < p_argcount; i++) { - newargs[i] = p_args[i]; - } - // fill in any remaining parameters with defaults - int first_default_arg = arg_count - def_argcount; - for (int i = p_argcount; i < arg_count; i++) { - newargs[i] = &default_args[i - first_default_arg]; - } -#ifdef DEBUG_ENABLED - if (!verify_arguments(newargs, r_error)) { - return; - } -#endif - func(r_ret, p_self, newargs); - } else { -#ifdef DEBUG_ENABLED - if (!verify_arguments(p_args, r_error)) { - return; - } -#endif - func(r_ret, p_self, p_args); - } - } - }; - - struct TypeFunc { - Map functions; - }; - - static TypeFunc *type_funcs; - - struct Arg { - StringName name; - Variant::Type type; - Arg() { type = Variant::NIL; } - Arg(Variant::Type p_type, const StringName &p_name) : - name(p_name), - type(p_type) { - } - }; - - //void addfunc(Variant::Type p_type, const StringName& p_name,VariantFunc p_func); - - static void make_func_return_variant(Variant::Type p_type, const StringName &p_name) { -#ifdef DEBUG_ENABLED - type_funcs[p_type].functions[p_name].returns = true; -#endif - } - - static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, bool p_has_return, const StringName &p_name, VariantFunc p_func, const Vector &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) { - FuncData funcdata; - funcdata.func = p_func; - funcdata.default_args = p_defaultarg; - funcdata._const = p_const; - funcdata.returns = p_has_return; - funcdata.return_type = p_return; - - if (p_argtype1.name) { - funcdata.arg_types.push_back(p_argtype1.type); -#ifdef DEBUG_ENABLED - funcdata.arg_names.push_back(p_argtype1.name); -#endif - - } else { - goto end; - } - - if (p_argtype2.name) { - funcdata.arg_types.push_back(p_argtype2.type); -#ifdef DEBUG_ENABLED - funcdata.arg_names.push_back(p_argtype2.name); -#endif - - } else { - goto end; - } - - if (p_argtype3.name) { - funcdata.arg_types.push_back(p_argtype3.type); -#ifdef DEBUG_ENABLED - funcdata.arg_names.push_back(p_argtype3.name); -#endif - - } else { - goto end; - } - - if (p_argtype4.name) { - funcdata.arg_types.push_back(p_argtype4.type); -#ifdef DEBUG_ENABLED - funcdata.arg_names.push_back(p_argtype4.name); -#endif - } else { - goto end; - } - - if (p_argtype5.name) { - funcdata.arg_types.push_back(p_argtype5.type); -#ifdef DEBUG_ENABLED - funcdata.arg_names.push_back(p_argtype5.name); -#endif - } else { - goto end; - } - - end: - - funcdata.arg_count = funcdata.arg_types.size(); - type_funcs[p_type].functions[p_name] = funcdata; - } - -#define VCALL_LOCALMEM0(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._mem)->m_method(); } -#define VCALL_LOCALMEM0R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._mem)->m_method(); } -#define VCALL_LOCALMEM1(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._mem)->m_method(*p_args[0]); } -#define VCALL_LOCALMEM1R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._mem)->m_method(*p_args[0]); } -#define VCALL_LOCALMEM2(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1]); } -#define VCALL_LOCALMEM2R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1]); } -#define VCALL_LOCALMEM3(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2]); } -#define VCALL_LOCALMEM3R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2]); } -#define VCALL_LOCALMEM4(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); } -#define VCALL_LOCALMEM4R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); } -#define VCALL_LOCALMEM5(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } -#define VCALL_LOCALMEM5R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } - - // built-in functions of localmem based types - - VCALL_LOCALMEM1R(String, casecmp_to); - VCALL_LOCALMEM1R(String, nocasecmp_to); - VCALL_LOCALMEM0R(String, length); - VCALL_LOCALMEM3R(String, count); - VCALL_LOCALMEM3R(String, countn); - VCALL_LOCALMEM2R(String, substr); - VCALL_LOCALMEM2R(String, find); - VCALL_LOCALMEM2R(String, findn); - VCALL_LOCALMEM2R(String, rfind); - VCALL_LOCALMEM2R(String, rfindn); - VCALL_LOCALMEM1R(String, match); - VCALL_LOCALMEM1R(String, matchn); - VCALL_LOCALMEM1R(String, begins_with); - VCALL_LOCALMEM1R(String, ends_with); - VCALL_LOCALMEM1R(String, is_subsequence_of); - VCALL_LOCALMEM1R(String, is_subsequence_ofi); - VCALL_LOCALMEM0R(String, bigrams); - VCALL_LOCALMEM1R(String, similarity); - VCALL_LOCALMEM2R(String, format); - VCALL_LOCALMEM2R(String, replace); - VCALL_LOCALMEM2R(String, replacen); - VCALL_LOCALMEM1R(String, repeat); - VCALL_LOCALMEM2R(String, insert); - VCALL_LOCALMEM0R(String, capitalize); - VCALL_LOCALMEM3R(String, split); - VCALL_LOCALMEM3R(String, rsplit); - VCALL_LOCALMEM2R(String, split_floats); - VCALL_LOCALMEM1R(String, join); - VCALL_LOCALMEM0R(String, to_upper); - VCALL_LOCALMEM0R(String, to_lower); - VCALL_LOCALMEM1R(String, left); - VCALL_LOCALMEM1R(String, right); - VCALL_LOCALMEM0R(String, dedent); - VCALL_LOCALMEM2R(String, strip_edges); - VCALL_LOCALMEM0R(String, strip_escapes); - VCALL_LOCALMEM1R(String, lstrip); - VCALL_LOCALMEM1R(String, rstrip); - VCALL_LOCALMEM0R(String, get_extension); - VCALL_LOCALMEM0R(String, get_basename); - VCALL_LOCALMEM1R(String, plus_file); - VCALL_LOCALMEM1R(String, ord_at); - VCALL_LOCALMEM2(String, erase); - VCALL_LOCALMEM0R(String, hash); - VCALL_LOCALMEM0R(String, md5_text); - VCALL_LOCALMEM0R(String, sha1_text); - VCALL_LOCALMEM0R(String, sha256_text); - VCALL_LOCALMEM0R(String, md5_buffer); - VCALL_LOCALMEM0R(String, sha1_buffer); - VCALL_LOCALMEM0R(String, sha256_buffer); - VCALL_LOCALMEM0R(String, empty); - VCALL_LOCALMEM1R(String, humanize_size); - VCALL_LOCALMEM0R(String, is_abs_path); - VCALL_LOCALMEM0R(String, is_rel_path); - VCALL_LOCALMEM0R(String, get_base_dir); - VCALL_LOCALMEM0R(String, get_file); - VCALL_LOCALMEM0R(String, xml_escape); - VCALL_LOCALMEM0R(String, xml_unescape); - VCALL_LOCALMEM0R(String, http_escape); - VCALL_LOCALMEM0R(String, http_unescape); - VCALL_LOCALMEM0R(String, c_escape); - VCALL_LOCALMEM0R(String, c_unescape); - VCALL_LOCALMEM0R(String, json_escape); - VCALL_LOCALMEM0R(String, percent_encode); - VCALL_LOCALMEM0R(String, percent_decode); - VCALL_LOCALMEM0R(String, is_valid_identifier); - VCALL_LOCALMEM0R(String, is_valid_integer); - VCALL_LOCALMEM0R(String, is_valid_float); - VCALL_LOCALMEM1R(String, is_valid_hex_number); - VCALL_LOCALMEM0R(String, is_valid_html_color); - VCALL_LOCALMEM0R(String, is_valid_ip_address); - VCALL_LOCALMEM0R(String, is_valid_filename); - VCALL_LOCALMEM0R(String, to_int); - VCALL_LOCALMEM0R(String, to_float); - VCALL_LOCALMEM0R(String, hex_to_int); - VCALL_LOCALMEM1R(String, pad_decimals); - VCALL_LOCALMEM1R(String, pad_zeros); - VCALL_LOCALMEM1R(String, trim_prefix); - VCALL_LOCALMEM1R(String, trim_suffix); - - static void _call_String_to_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) { - String *s = reinterpret_cast(p_self._data._mem); - if (s->empty()) { - r_ret = PackedByteArray(); - return; - } - CharString charstr = s->ascii(); - - PackedByteArray retval; - size_t len = charstr.length(); - retval.resize(len); - uint8_t *w = retval.ptrw(); - copymem(w, charstr.ptr(), len); - - r_ret = retval; - } - - static void _call_String_to_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) { - String *s = reinterpret_cast(p_self._data._mem); - if (s->empty()) { - r_ret = PackedByteArray(); - return; - } - CharString charstr = s->utf8(); - - PackedByteArray retval; - size_t len = charstr.length(); - retval.resize(len); - uint8_t *w = retval.ptrw(); - copymem(w, charstr.ptr(), len); - - r_ret = retval; - } - - VCALL_LOCALMEM1R(Vector2, distance_to); - VCALL_LOCALMEM1R(Vector2, distance_squared_to); - VCALL_LOCALMEM0R(Vector2, length); - VCALL_LOCALMEM0R(Vector2, length_squared); - VCALL_LOCALMEM0R(Vector2, normalized); - VCALL_LOCALMEM0R(Vector2, is_normalized); - VCALL_LOCALMEM1R(Vector2, is_equal_approx); - VCALL_LOCALMEM1R(Vector2, posmod); - VCALL_LOCALMEM1R(Vector2, posmodv); - VCALL_LOCALMEM1R(Vector2, project); - VCALL_LOCALMEM1R(Vector2, angle_to); - VCALL_LOCALMEM1R(Vector2, angle_to_point); - VCALL_LOCALMEM1R(Vector2, direction_to); - VCALL_LOCALMEM2R(Vector2, lerp); - VCALL_LOCALMEM2R(Vector2, slerp); - VCALL_LOCALMEM4R(Vector2, cubic_interpolate); - VCALL_LOCALMEM2R(Vector2, move_toward); - VCALL_LOCALMEM1R(Vector2, rotated); - VCALL_LOCALMEM0R(Vector2, tangent); - VCALL_LOCALMEM0R(Vector2, floor); - VCALL_LOCALMEM0R(Vector2, ceil); - VCALL_LOCALMEM0R(Vector2, round); - VCALL_LOCALMEM1R(Vector2, snapped); - VCALL_LOCALMEM0R(Vector2, aspect); - VCALL_LOCALMEM1R(Vector2, dot); - VCALL_LOCALMEM1R(Vector2, slide); - VCALL_LOCALMEM1R(Vector2, bounce); - VCALL_LOCALMEM1R(Vector2, reflect); - VCALL_LOCALMEM0R(Vector2, angle); - VCALL_LOCALMEM1R(Vector2, cross); - VCALL_LOCALMEM0R(Vector2, abs); - VCALL_LOCALMEM1R(Vector2, clamped); - VCALL_LOCALMEM0R(Vector2, sign); - - VCALL_LOCALMEM0R(Vector2i, aspect); - VCALL_LOCALMEM0R(Vector2i, sign); - VCALL_LOCALMEM0R(Vector2i, abs); - - VCALL_LOCALMEM0R(Rect2, get_area); - VCALL_LOCALMEM0R(Rect2, has_no_area); - VCALL_LOCALMEM1R(Rect2, has_point); - VCALL_LOCALMEM1R(Rect2, is_equal_approx); - VCALL_LOCALMEM2R(Rect2, intersects); - VCALL_LOCALMEM1R(Rect2, encloses); - VCALL_LOCALMEM1R(Rect2, clip); - VCALL_LOCALMEM1R(Rect2, merge); - VCALL_LOCALMEM1R(Rect2, expand); - VCALL_LOCALMEM1R(Rect2, grow); - VCALL_LOCALMEM2R(Rect2, grow_margin); - VCALL_LOCALMEM4R(Rect2, grow_individual); - VCALL_LOCALMEM0R(Rect2, abs); - - VCALL_LOCALMEM0R(Rect2i, get_area); - VCALL_LOCALMEM0R(Rect2i, has_no_area); - VCALL_LOCALMEM1R(Rect2i, has_point); - VCALL_LOCALMEM1R(Rect2i, intersects); - VCALL_LOCALMEM1R(Rect2i, encloses); - VCALL_LOCALMEM1R(Rect2i, clip); - VCALL_LOCALMEM1R(Rect2i, merge); - VCALL_LOCALMEM1R(Rect2i, expand); - VCALL_LOCALMEM1R(Rect2i, grow); - VCALL_LOCALMEM2R(Rect2i, grow_margin); - VCALL_LOCALMEM4R(Rect2i, grow_individual); - VCALL_LOCALMEM0R(Rect2i, abs); - - VCALL_LOCALMEM0R(Vector3, min_axis); - VCALL_LOCALMEM0R(Vector3, max_axis); - VCALL_LOCALMEM1R(Vector3, distance_to); - VCALL_LOCALMEM1R(Vector3, distance_squared_to); - VCALL_LOCALMEM0R(Vector3, length); - VCALL_LOCALMEM0R(Vector3, length_squared); - VCALL_LOCALMEM0R(Vector3, normalized); - VCALL_LOCALMEM0R(Vector3, is_normalized); - VCALL_LOCALMEM1R(Vector3, is_equal_approx); - VCALL_LOCALMEM0R(Vector3, inverse); - VCALL_LOCALMEM1R(Vector3, snapped); - VCALL_LOCALMEM2R(Vector3, rotated); - VCALL_LOCALMEM2R(Vector3, lerp); - VCALL_LOCALMEM2R(Vector3, slerp); - VCALL_LOCALMEM4R(Vector3, cubic_interpolate); - VCALL_LOCALMEM2R(Vector3, move_toward); - VCALL_LOCALMEM1R(Vector3, dot); - VCALL_LOCALMEM1R(Vector3, cross); - VCALL_LOCALMEM1R(Vector3, outer); - VCALL_LOCALMEM0R(Vector3, to_diagonal_matrix); - VCALL_LOCALMEM0R(Vector3, abs); - VCALL_LOCALMEM0R(Vector3, floor); - VCALL_LOCALMEM0R(Vector3, ceil); - VCALL_LOCALMEM0R(Vector3, round); - VCALL_LOCALMEM1R(Vector3, posmod); - VCALL_LOCALMEM1R(Vector3, posmodv); - VCALL_LOCALMEM1R(Vector3, project); - VCALL_LOCALMEM1R(Vector3, angle_to); - VCALL_LOCALMEM1R(Vector3, direction_to); - VCALL_LOCALMEM1R(Vector3, slide); - VCALL_LOCALMEM1R(Vector3, bounce); - VCALL_LOCALMEM1R(Vector3, reflect); - VCALL_LOCALMEM0R(Vector3, sign); - - VCALL_LOCALMEM0R(Vector3i, min_axis); - VCALL_LOCALMEM0R(Vector3i, max_axis); - VCALL_LOCALMEM0R(Vector3i, sign); - - VCALL_LOCALMEM0R(Plane, normalized); - VCALL_LOCALMEM0R(Plane, center); - VCALL_LOCALMEM1R(Plane, is_equal_approx); - VCALL_LOCALMEM1R(Plane, is_point_over); - VCALL_LOCALMEM1R(Plane, distance_to); - VCALL_LOCALMEM2R(Plane, has_point); - VCALL_LOCALMEM1R(Plane, project); - - //return vector3 if intersected, nil if not - static void _call_Plane_intersect_3(Variant &r_ret, Variant &p_self, const Variant **p_args) { - Vector3 result; - if (reinterpret_cast(p_self._data._mem)->intersect_3(*p_args[0], *p_args[1], &result)) { - r_ret = result; - } else { - r_ret = Variant(); - } - } - - static void _call_Plane_intersects_ray(Variant &r_ret, Variant &p_self, const Variant **p_args) { - Vector3 result; - if (reinterpret_cast(p_self._data._mem)->intersects_ray(*p_args[0], *p_args[1], &result)) { - r_ret = result; - } else { - r_ret = Variant(); - } - } - - static void _call_Plane_intersects_segment(Variant &r_ret, Variant &p_self, const Variant **p_args) { - Vector3 result; - if (reinterpret_cast(p_self._data._mem)->intersects_segment(*p_args[0], *p_args[1], &result)) { - r_ret = result; - } else { - r_ret = Variant(); - } - } - - VCALL_LOCALMEM0R(Quat, length); - VCALL_LOCALMEM0R(Quat, length_squared); - VCALL_LOCALMEM0R(Quat, normalized); - VCALL_LOCALMEM0R(Quat, is_normalized); - VCALL_LOCALMEM1R(Quat, is_equal_approx); - VCALL_LOCALMEM0R(Quat, inverse); - VCALL_LOCALMEM1R(Quat, dot); - VCALL_LOCALMEM1R(Quat, xform); - VCALL_LOCALMEM2R(Quat, slerp); - VCALL_LOCALMEM2R(Quat, slerpni); - VCALL_LOCALMEM4R(Quat, cubic_slerp); - VCALL_LOCALMEM0R(Quat, get_euler); - VCALL_LOCALMEM1(Quat, set_euler); - VCALL_LOCALMEM2(Quat, set_axis_angle); - - VCALL_LOCALMEM0R(Color, to_argb32); - VCALL_LOCALMEM0R(Color, to_abgr32); - VCALL_LOCALMEM0R(Color, to_rgba32); - VCALL_LOCALMEM0R(Color, to_argb64); - VCALL_LOCALMEM0R(Color, to_abgr64); - VCALL_LOCALMEM0R(Color, to_rgba64); - VCALL_LOCALMEM0R(Color, inverted); - VCALL_LOCALMEM0R(Color, contrasted); - VCALL_LOCALMEM2R(Color, lerp); - VCALL_LOCALMEM1R(Color, blend); - VCALL_LOCALMEM1R(Color, lightened); - VCALL_LOCALMEM1R(Color, darkened); - VCALL_LOCALMEM1R(Color, to_html); - VCALL_LOCALMEM4R(Color, from_hsv); - VCALL_LOCALMEM1R(Color, is_equal_approx); - - VCALL_LOCALMEM0R(RID, get_id); - - VCALL_LOCALMEM0R(NodePath, is_absolute); - VCALL_LOCALMEM0R(NodePath, get_name_count); - VCALL_LOCALMEM1R(NodePath, get_name); - VCALL_LOCALMEM0R(NodePath, get_subname_count); - VCALL_LOCALMEM1R(NodePath, get_subname); - VCALL_LOCALMEM0R(NodePath, get_concatenated_subnames); - VCALL_LOCALMEM0R(NodePath, get_as_property_path); - VCALL_LOCALMEM0R(NodePath, is_empty); - - VCALL_LOCALMEM0R(Dictionary, size); - VCALL_LOCALMEM0R(Dictionary, empty); - VCALL_LOCALMEM0(Dictionary, clear); - VCALL_LOCALMEM1R(Dictionary, has); - VCALL_LOCALMEM1R(Dictionary, has_all); - VCALL_LOCALMEM1R(Dictionary, erase); - VCALL_LOCALMEM0R(Dictionary, hash); - VCALL_LOCALMEM0R(Dictionary, keys); - VCALL_LOCALMEM0R(Dictionary, values); - VCALL_LOCALMEM1R(Dictionary, duplicate); - VCALL_LOCALMEM2R(Dictionary, get); - - VCALL_LOCALMEM0R(Callable, is_null); - VCALL_LOCALMEM0R(Callable, is_custom); - VCALL_LOCALMEM0(Callable, is_standard); - VCALL_LOCALMEM0(Callable, get_object); - VCALL_LOCALMEM0(Callable, get_object_id); - VCALL_LOCALMEM0(Callable, get_method); - VCALL_LOCALMEM0(Callable, hash); - - VCALL_LOCALMEM0R(Signal, is_null); - VCALL_LOCALMEM0R(Signal, get_object); - VCALL_LOCALMEM0R(Signal, get_object_id); - VCALL_LOCALMEM0R(Signal, get_name); - VCALL_LOCALMEM3R(Signal, connect); - VCALL_LOCALMEM1(Signal, disconnect); - VCALL_LOCALMEM1R(Signal, is_connected); - VCALL_LOCALMEM0R(Signal, get_connections); - - VCALL_LOCALMEM2(Array, set); - VCALL_LOCALMEM1R(Array, get); - VCALL_LOCALMEM0R(Array, size); - VCALL_LOCALMEM0R(Array, empty); - VCALL_LOCALMEM0(Array, clear); - VCALL_LOCALMEM0R(Array, hash); - VCALL_LOCALMEM1(Array, push_back); - VCALL_LOCALMEM1(Array, push_front); - VCALL_LOCALMEM0R(Array, pop_back); - VCALL_LOCALMEM0R(Array, pop_front); - VCALL_LOCALMEM1(Array, append); - VCALL_LOCALMEM1(Array, resize); - VCALL_LOCALMEM2(Array, insert); - VCALL_LOCALMEM1(Array, remove); - VCALL_LOCALMEM0R(Array, front); - VCALL_LOCALMEM0R(Array, back); - VCALL_LOCALMEM2R(Array, find); - VCALL_LOCALMEM2R(Array, rfind); - VCALL_LOCALMEM1R(Array, find_last); - VCALL_LOCALMEM1R(Array, count); - VCALL_LOCALMEM1R(Array, has); - VCALL_LOCALMEM1(Array, erase); - VCALL_LOCALMEM0(Array, sort); - VCALL_LOCALMEM2(Array, sort_custom); - VCALL_LOCALMEM0(Array, shuffle); - VCALL_LOCALMEM2R(Array, bsearch); - VCALL_LOCALMEM4R(Array, bsearch_custom); - VCALL_LOCALMEM1R(Array, duplicate); - VCALL_LOCALMEM4R(Array, slice); - VCALL_LOCALMEM0(Array, invert); - VCALL_LOCALMEM0R(Array, max); - VCALL_LOCALMEM0R(Array, min); - - static void _call_PackedByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) { - PackedByteArray *ba = reinterpret_cast(p_self._data._mem); - String s; - if (ba->size() > 0) { - const uint8_t *r = ba->ptr(); - CharString cs; - cs.resize(ba->size() + 1); - copymem(cs.ptrw(), r, ba->size()); - cs[ba->size()] = 0; - - s = cs.get_data(); - } - r_ret = s; - } - - static void _call_PackedByteArray_get_string_from_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) { - PackedByteArray *ba = reinterpret_cast(p_self._data._mem); - String s; - if (ba->size() > 0) { - const uint8_t *r = ba->ptr(); - s.parse_utf8((const char *)r, ba->size()); - } - r_ret = s; - } - - static void _call_PackedByteArray_compress(Variant &r_ret, Variant &p_self, const Variant **p_args) { - PackedByteArray *ba = reinterpret_cast(p_self._data._mem); - PackedByteArray compressed; - if (ba->size() > 0) { - Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]); - - compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode)); - int result = Compression::compress(compressed.ptrw(), ba->ptr(), ba->size(), mode); - - result = result >= 0 ? result : 0; - compressed.resize(result); - } - r_ret = compressed; - } - - static void _call_PackedByteArray_decompress(Variant &r_ret, Variant &p_self, const Variant **p_args) { - PackedByteArray *ba = reinterpret_cast(p_self._data._mem); - PackedByteArray decompressed; - Compression::Mode mode = (Compression::Mode)(int)(*p_args[1]); - - int buffer_size = (int)(*p_args[0]); - - if (buffer_size <= 0) { - r_ret = decompressed; - ERR_FAIL_MSG("Decompression buffer size must be greater than zero."); - } - - decompressed.resize(buffer_size); - int result = Compression::decompress(decompressed.ptrw(), buffer_size, ba->ptr(), ba->size(), mode); - - result = result >= 0 ? result : 0; - decompressed.resize(result); - - r_ret = decompressed; - } - - static void _call_PackedByteArray_hex_encode(Variant &r_ret, Variant &p_self, const Variant **p_args) { - PackedByteArray *ba = reinterpret_cast(p_self._data._mem); - if (ba->size() == 0) { - r_ret = String(); - return; - } - const uint8_t *r = ba->ptr(); - String s = String::hex_encode_buffer(&r[0], ba->size()); - r_ret = s; - } - -#define VCALL_PARRMEM0(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(); } -#define VCALL_PARRMEM0R(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(); } -#define VCALL_PARRMEM1(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0]); } -#define VCALL_PARRMEM1R(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0]); } -#define VCALL_PARRMEM2(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1]); } -#define VCALL_PARRMEM2R(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1]); } -#define VCALL_PARRMEM3(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2]); } -#define VCALL_PARRMEM3R(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2]); } -#define VCALL_PARRMEM4(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); } -#define VCALL_PARRMEM4R(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); } -#define VCALL_PARRMEM5(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } -#define VCALL_PARRMEM5R(m_type, m_elemtype, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } - - VCALL_PARRMEM0R(PackedByteArray, uint8_t, size); - VCALL_PARRMEM0R(PackedByteArray, uint8_t, empty); - VCALL_PARRMEM2(PackedByteArray, uint8_t, set); - VCALL_PARRMEM1R(PackedByteArray, uint8_t, get); - VCALL_PARRMEM1(PackedByteArray, uint8_t, push_back); - VCALL_PARRMEM1(PackedByteArray, uint8_t, resize); - VCALL_PARRMEM2R(PackedByteArray, uint8_t, insert); - VCALL_PARRMEM1(PackedByteArray, uint8_t, remove); - VCALL_PARRMEM1(PackedByteArray, uint8_t, append); - VCALL_PARRMEM1(PackedByteArray, uint8_t, append_array); - VCALL_PARRMEM1R(PackedByteArray, uint8_t, has); - VCALL_PARRMEM0(PackedByteArray, uint8_t, sort); - VCALL_PARRMEM0(PackedByteArray, uint8_t, invert); - VCALL_PARRMEM2R(PackedByteArray, uint8_t, subarray); - - VCALL_PARRMEM0R(PackedInt32Array, int32_t, size); - VCALL_PARRMEM0R(PackedInt32Array, int32_t, empty); - VCALL_PARRMEM2(PackedInt32Array, int32_t, set); - VCALL_PARRMEM1R(PackedInt32Array, int32_t, get); - VCALL_PARRMEM1(PackedInt32Array, int32_t, push_back); - VCALL_PARRMEM1(PackedInt32Array, int32_t, resize); - VCALL_PARRMEM2R(PackedInt32Array, int32_t, insert); - VCALL_PARRMEM1(PackedInt32Array, int32_t, remove); - VCALL_PARRMEM1(PackedInt32Array, int32_t, append); - VCALL_PARRMEM1(PackedInt32Array, int32_t, append_array); - VCALL_PARRMEM1R(PackedInt32Array, int32_t, has); - VCALL_PARRMEM0(PackedInt32Array, int32_t, sort); - VCALL_PARRMEM0(PackedInt32Array, int32_t, invert); - - VCALL_PARRMEM0R(PackedInt64Array, int64_t, size); - VCALL_PARRMEM0R(PackedInt64Array, int64_t, empty); - VCALL_PARRMEM2(PackedInt64Array, int64_t, set); - VCALL_PARRMEM1R(PackedInt64Array, int64_t, get); - VCALL_PARRMEM1(PackedInt64Array, int64_t, push_back); - VCALL_PARRMEM1(PackedInt64Array, int64_t, resize); - VCALL_PARRMEM2R(PackedInt64Array, int64_t, insert); - VCALL_PARRMEM1(PackedInt64Array, int64_t, remove); - VCALL_PARRMEM1(PackedInt64Array, int64_t, append); - VCALL_PARRMEM1(PackedInt64Array, int64_t, append_array); - VCALL_PARRMEM1R(PackedInt64Array, int64_t, has); - VCALL_PARRMEM0(PackedInt64Array, int64_t, sort); - VCALL_PARRMEM0(PackedInt64Array, int64_t, invert); - - VCALL_PARRMEM0R(PackedFloat32Array, float, size); - VCALL_PARRMEM0R(PackedFloat32Array, float, empty); - VCALL_PARRMEM2(PackedFloat32Array, float, set); - VCALL_PARRMEM1R(PackedFloat32Array, float, get); - VCALL_PARRMEM1(PackedFloat32Array, float, push_back); - VCALL_PARRMEM1(PackedFloat32Array, float, resize); - VCALL_PARRMEM2R(PackedFloat32Array, float, insert); - VCALL_PARRMEM1(PackedFloat32Array, float, remove); - VCALL_PARRMEM1(PackedFloat32Array, float, append); - VCALL_PARRMEM1(PackedFloat32Array, float, append_array); - VCALL_PARRMEM1R(PackedFloat32Array, float, has); - VCALL_PARRMEM0(PackedFloat32Array, float, sort); - VCALL_PARRMEM0(PackedFloat32Array, float, invert); - - VCALL_PARRMEM0R(PackedFloat64Array, double, size); - VCALL_PARRMEM0R(PackedFloat64Array, double, empty); - VCALL_PARRMEM2(PackedFloat64Array, double, set); - VCALL_PARRMEM1R(PackedFloat64Array, double, get); - VCALL_PARRMEM1(PackedFloat64Array, double, push_back); - VCALL_PARRMEM1(PackedFloat64Array, double, resize); - VCALL_PARRMEM2R(PackedFloat64Array, double, insert); - VCALL_PARRMEM1(PackedFloat64Array, double, remove); - VCALL_PARRMEM1(PackedFloat64Array, double, append); - VCALL_PARRMEM1(PackedFloat64Array, double, append_array); - VCALL_PARRMEM1R(PackedFloat64Array, double, has); - VCALL_PARRMEM0(PackedFloat64Array, double, sort); - VCALL_PARRMEM0(PackedFloat64Array, double, invert); - - VCALL_PARRMEM0R(PackedStringArray, String, size); - VCALL_PARRMEM0R(PackedStringArray, String, empty); - VCALL_PARRMEM2(PackedStringArray, String, set); - VCALL_PARRMEM1R(PackedStringArray, String, get); - VCALL_PARRMEM1(PackedStringArray, String, push_back); - VCALL_PARRMEM1(PackedStringArray, String, resize); - VCALL_PARRMEM2R(PackedStringArray, String, insert); - VCALL_PARRMEM1(PackedStringArray, String, remove); - VCALL_PARRMEM1(PackedStringArray, String, append); - VCALL_PARRMEM1(PackedStringArray, String, append_array); - VCALL_PARRMEM1R(PackedStringArray, String, has); - VCALL_PARRMEM0(PackedStringArray, String, sort); - VCALL_PARRMEM0(PackedStringArray, String, invert); - - VCALL_PARRMEM0R(PackedVector2Array, Vector2, size); - VCALL_PARRMEM0R(PackedVector2Array, Vector2, empty); - VCALL_PARRMEM2(PackedVector2Array, Vector2, set); - VCALL_PARRMEM1R(PackedVector2Array, Vector2, get); - VCALL_PARRMEM1(PackedVector2Array, Vector2, push_back); - VCALL_PARRMEM1(PackedVector2Array, Vector2, resize); - VCALL_PARRMEM2R(PackedVector2Array, Vector2, insert); - VCALL_PARRMEM1(PackedVector2Array, Vector2, remove); - VCALL_PARRMEM1(PackedVector2Array, Vector2, append); - VCALL_PARRMEM1(PackedVector2Array, Vector2, append_array); - VCALL_PARRMEM1R(PackedVector2Array, Vector2, has); - VCALL_PARRMEM0(PackedVector2Array, Vector2, sort); - VCALL_PARRMEM0(PackedVector2Array, Vector2, invert); - - VCALL_PARRMEM0R(PackedVector3Array, Vector3, size); - VCALL_PARRMEM0R(PackedVector3Array, Vector3, empty); - VCALL_PARRMEM2(PackedVector3Array, Vector3, set); - VCALL_PARRMEM1R(PackedVector3Array, Vector3, get); - VCALL_PARRMEM1(PackedVector3Array, Vector3, push_back); - VCALL_PARRMEM1(PackedVector3Array, Vector3, resize); - VCALL_PARRMEM2R(PackedVector3Array, Vector3, insert); - VCALL_PARRMEM1(PackedVector3Array, Vector3, remove); - VCALL_PARRMEM1(PackedVector3Array, Vector3, append); - VCALL_PARRMEM1(PackedVector3Array, Vector3, append_array); - VCALL_PARRMEM1R(PackedVector3Array, Vector3, has); - VCALL_PARRMEM0(PackedVector3Array, Vector3, sort); - VCALL_PARRMEM0(PackedVector3Array, Vector3, invert); - - VCALL_PARRMEM0R(PackedColorArray, Color, size); - VCALL_PARRMEM0R(PackedColorArray, Color, empty); - VCALL_PARRMEM2(PackedColorArray, Color, set); - VCALL_PARRMEM1R(PackedColorArray, Color, get); - VCALL_PARRMEM1(PackedColorArray, Color, push_back); - VCALL_PARRMEM1(PackedColorArray, Color, resize); - VCALL_PARRMEM2R(PackedColorArray, Color, insert); - VCALL_PARRMEM1(PackedColorArray, Color, remove); - VCALL_PARRMEM1(PackedColorArray, Color, append); - VCALL_PARRMEM1(PackedColorArray, Color, append_array); - VCALL_PARRMEM1R(PackedColorArray, Color, has); - VCALL_PARRMEM0(PackedColorArray, Color, sort); - VCALL_PARRMEM0(PackedColorArray, Color, invert); - -#define VCALL_PTR0(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._ptr)->m_method(); } -#define VCALL_PTR0R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._ptr)->m_method(); } -#define VCALL_PTR1(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0]); } -#define VCALL_PTR1R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0]); } -#define VCALL_PTR2(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1]); } -#define VCALL_PTR2R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1]); } -#define VCALL_PTR3(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2]); } -#define VCALL_PTR3R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2]); } -#define VCALL_PTR4(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); } -#define VCALL_PTR4R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); } -#define VCALL_PTR5(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } -#define VCALL_PTR5R(m_type, m_method) \ - static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } - - VCALL_PTR0R(AABB, abs); - VCALL_PTR0R(AABB, get_area); - VCALL_PTR0R(AABB, has_no_area); - VCALL_PTR0R(AABB, has_no_surface); - VCALL_PTR1R(AABB, has_point); - VCALL_PTR1R(AABB, is_equal_approx); - VCALL_PTR1R(AABB, intersects); - VCALL_PTR1R(AABB, encloses); - VCALL_PTR1R(AABB, intersects_plane); - VCALL_PTR2R(AABB, intersects_segment); - VCALL_PTR1R(AABB, intersection); - VCALL_PTR1R(AABB, merge); - VCALL_PTR1R(AABB, expand); - VCALL_PTR1R(AABB, grow); - VCALL_PTR1R(AABB, get_support); - VCALL_PTR0R(AABB, get_longest_axis); - VCALL_PTR0R(AABB, get_longest_axis_index); - VCALL_PTR0R(AABB, get_longest_axis_size); - VCALL_PTR0R(AABB, get_shortest_axis); - VCALL_PTR0R(AABB, get_shortest_axis_index); - VCALL_PTR0R(AABB, get_shortest_axis_size); - VCALL_PTR1R(AABB, get_endpoint); - - VCALL_PTR0R(Transform2D, inverse); - VCALL_PTR0R(Transform2D, affine_inverse); - VCALL_PTR0R(Transform2D, get_rotation); - VCALL_PTR0R(Transform2D, get_origin); - VCALL_PTR0R(Transform2D, get_scale); - VCALL_PTR0R(Transform2D, orthonormalized); - VCALL_PTR1R(Transform2D, rotated); - VCALL_PTR1R(Transform2D, scaled); - VCALL_PTR1R(Transform2D, translated); - VCALL_PTR2R(Transform2D, interpolate_with); - VCALL_PTR1R(Transform2D, is_equal_approx); - - static void _call_Transform2D_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator Vector2()); - return; - case Variant::RECT2: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator Rect2()); - return; - case Variant::PACKED_VECTOR2_ARRAY: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator PackedVector2Array()); - return; - default: - r_ret = Variant(); - ERR_PRINT("Invalid type in function 'xform' in base 'Transform2D'. Valid types are Vector2, Rect2, and PackedVector2Array."); - } - } - - static void _call_Transform2D_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector2()); - return; - case Variant::RECT2: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect2()); - return; - case Variant::PACKED_VECTOR2_ARRAY: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator PackedVector2Array()); - return; - default: - r_ret = Variant(); - ERR_PRINT("Invalid type in function 'xform_inv' in base 'Transform2D'. Valid types are Vector2, Rect2, and PackedVector2Array."); - } - } - - static void _call_Transform2D_basis_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: - r_ret = reinterpret_cast(p_self._data._ptr)->basis_xform(p_args[0]->operator Vector2()); - return; - default: - r_ret = Variant(); - ERR_PRINT("Invalid type in function 'basis_xform' in base 'Transform2D'. Only Vector2 is valid."); - } - } - - static void _call_Transform2D_basis_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: - r_ret = reinterpret_cast(p_self._data._ptr)->basis_xform_inv(p_args[0]->operator Vector2()); - return; - default: - r_ret = Variant(); - ERR_PRINT("Invalid type in function 'basis_xform_inv' in base 'Transform2D'. Only Vector2 is valid."); - } - } - - VCALL_PTR0R(Basis, inverse); - VCALL_PTR0R(Basis, transposed); - VCALL_PTR0R(Basis, determinant); - VCALL_PTR2R(Basis, rotated); - VCALL_PTR1R(Basis, scaled); - VCALL_PTR0R(Basis, get_scale); - VCALL_PTR0R(Basis, get_euler); - VCALL_PTR0R(Basis, get_euler_xyz); - VCALL_PTR1(Basis, set_euler_xyz); - VCALL_PTR0R(Basis, get_euler_xzy); - VCALL_PTR1(Basis, set_euler_xzy); - VCALL_PTR0R(Basis, get_euler_yzx); - VCALL_PTR1(Basis, set_euler_yzx); - VCALL_PTR0R(Basis, get_euler_yxz); - VCALL_PTR1(Basis, set_euler_yxz); - VCALL_PTR0R(Basis, get_euler_zxy); - VCALL_PTR1(Basis, set_euler_zxy); - VCALL_PTR0R(Basis, get_euler_zyx); - VCALL_PTR1(Basis, set_euler_zyx); - VCALL_PTR1R(Basis, tdotx); - VCALL_PTR1R(Basis, tdoty); - VCALL_PTR1R(Basis, tdotz); - VCALL_PTR1R(Basis, xform); - VCALL_PTR1R(Basis, xform_inv); - VCALL_PTR0R(Basis, get_orthogonal_index); - VCALL_PTR0R(Basis, orthonormalized); - VCALL_PTR2R(Basis, slerp); - VCALL_PTR2R(Basis, is_equal_approx); // TODO: Break compatibility in 4.0 to change this to an instance method (a.is_equal_approx(b) as VCALL_PTR1R) for consistency. - VCALL_PTR0R(Basis, get_rotation_quat); - - VCALL_PTR0R(Transform, inverse); - VCALL_PTR0R(Transform, affine_inverse); - VCALL_PTR2R(Transform, rotated); - VCALL_PTR1R(Transform, scaled); - VCALL_PTR1R(Transform, translated); - VCALL_PTR0R(Transform, orthonormalized); - VCALL_PTR2R(Transform, looking_at); - VCALL_PTR2R(Transform, interpolate_with); - VCALL_PTR1R(Transform, is_equal_approx); - - static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR3: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); - return; - case Variant::PLANE: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator Plane()); - return; - case Variant::AABB: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); - return; - case Variant::PACKED_VECTOR3_ARRAY: - r_ret = reinterpret_cast(p_self._data._ptr)->xform(p_args[0]->operator ::PackedVector3Array()); - return; - default: - r_ret = Variant(); - ERR_PRINT("Invalid type in function 'xform' in base 'Transform'. Valid types are Vector3, Plane, AABB, and PackedVector3Array."); - } - } - - static void _call_Transform_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR3: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); - return; - case Variant::PLANE: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); - return; - case Variant::AABB: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); - return; - case Variant::PACKED_VECTOR3_ARRAY: - r_ret = reinterpret_cast(p_self._data._ptr)->xform_inv(p_args[0]->operator ::PackedVector3Array()); - return; - default: - r_ret = Variant(); - ERR_PRINT("Invalid type in function 'xform_inv' in base 'Transform'. Valid types are Vector3, Plane, AABB, and PackedVector3Array."); - } - } - - struct ConstructData { - int arg_count; - Vector arg_types; - Vector arg_names; - VariantConstructFunc func; - }; - - struct ConstructFunc { - List constructors; - }; - - static ConstructFunc *construct_funcs; - - static void Vector2_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Vector2(*p_args[0], *p_args[1]); - } - - static void Vector2i_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Vector2i(*p_args[0], *p_args[1]); - } - - static void Rect2_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Rect2(*p_args[0], *p_args[1]); - } - - static void Rect2_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Rect2(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); - } - - static void Rect2i_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Rect2i(*p_args[0], *p_args[1]); - } - - static void Rect2i_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Rect2i(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); - } - - static void Transform2D_init2(Variant &r_ret, const Variant **p_args) { - Transform2D m(*p_args[0], *p_args[1]); - r_ret = m; - } - - static void Transform2D_init3(Variant &r_ret, const Variant **p_args) { - Transform2D m; - m[0] = *p_args[0]; - m[1] = *p_args[1]; - m[2] = *p_args[2]; - r_ret = m; - } - - static void Vector3_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Vector3(*p_args[0], *p_args[1], *p_args[2]); - } - - static void Vector3i_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Vector3i(*p_args[0], *p_args[1], *p_args[2]); - } - - static void Plane_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Plane(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); - } - - static void Plane_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Plane(*p_args[0], *p_args[1], *p_args[2]); - } - - static void Plane_init3(Variant &r_ret, const Variant **p_args) { - r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator real_t()); - } - static void Plane_init4(Variant &r_ret, const Variant **p_args) { - r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator Vector3()); - } - - static void Quat_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Quat(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); - } - - static void Quat_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Quat(((Vector3)(*p_args[0])), ((real_t)(*p_args[1]))); - } - - static void Quat_init3(Variant &r_ret, const Variant **p_args) { - r_ret = Quat(((Vector3)(*p_args[0]))); - } - - static void Color_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Color(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); - } - - static void Color_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Color(*p_args[0], *p_args[1], *p_args[2]); - } - - static void Color_init3(Variant &r_ret, const Variant **p_args) { - r_ret = Color::html(*p_args[0]); - } - - static void Color_init4(Variant &r_ret, const Variant **p_args) { - r_ret = Color::hex(*p_args[0]); - } - - static void Color_init5(Variant &r_ret, const Variant **p_args) { - r_ret = Color(((Color)(*p_args[0])), *p_args[1]); - } - - static void AABB_init1(Variant &r_ret, const Variant **p_args) { - r_ret = ::AABB(*p_args[0], *p_args[1]); - } - - static void Basis_init1(Variant &r_ret, const Variant **p_args) { - Basis m; - m.set_axis(0, *p_args[0]); - m.set_axis(1, *p_args[1]); - m.set_axis(2, *p_args[2]); - r_ret = m; - } - - static void Basis_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Basis(p_args[0]->operator Vector3(), p_args[1]->operator real_t()); - } - - static void Transform_init1(Variant &r_ret, const Variant **p_args) { - Transform t; - t.basis.set_axis(0, *p_args[0]); - t.basis.set_axis(1, *p_args[1]); - t.basis.set_axis(2, *p_args[2]); - t.origin = *p_args[3]; - r_ret = t; - } - - static void Transform_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Transform(p_args[0]->operator Basis(), p_args[1]->operator Vector3()); - } - - static void Callable_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Callable(p_args[0]->operator ObjectID(), p_args[1]->operator String()); - } - - static void Signal_init2(Variant &r_ret, const Variant **p_args) { - r_ret = Signal(p_args[0]->operator ObjectID(), p_args[1]->operator String()); - } - - static void add_constructor(VariantConstructFunc p_func, const Variant::Type p_type, - const String &p_name1 = "", const Variant::Type p_type1 = Variant::NIL, - const String &p_name2 = "", const Variant::Type p_type2 = Variant::NIL, - const String &p_name3 = "", const Variant::Type p_type3 = Variant::NIL, - const String &p_name4 = "", const Variant::Type p_type4 = Variant::NIL) { - ConstructData cd; - cd.func = p_func; - cd.arg_count = 0; - - if (p_name1 == "") { - goto end; - } - cd.arg_count++; - cd.arg_names.push_back(p_name1); - cd.arg_types.push_back(p_type1); - - if (p_name2 == "") { - goto end; - } - cd.arg_count++; - cd.arg_names.push_back(p_name2); - cd.arg_types.push_back(p_type2); - - if (p_name3 == "") { - goto end; - } - cd.arg_count++; - cd.arg_names.push_back(p_name3); - cd.arg_types.push_back(p_type3); - - if (p_name4 == "") { - goto end; - } - cd.arg_count++; - cd.arg_names.push_back(p_name4); - cd.arg_types.push_back(p_type4); - - end: - - construct_funcs[p_type].constructors.push_back(cd); - } - - struct ConstantData { - Map value; -#ifdef DEBUG_ENABLED - List value_ordered; -#endif - Map variant_value; -#ifdef DEBUG_ENABLED - List variant_value_ordered; -#endif - }; - - static ConstantData *constant_data; - - static void add_constant(int p_type, StringName p_constant_name, int p_constant_value) { - constant_data[p_type].value[p_constant_name] = p_constant_value; -#ifdef DEBUG_ENABLED - constant_data[p_type].value_ordered.push_back(p_constant_name); -#endif - } - - static void add_variant_constant(int p_type, StringName p_constant_name, const Variant &p_constant_value) { - constant_data[p_type].variant_value[p_constant_name] = p_constant_value; -#ifdef DEBUG_ENABLED - constant_data[p_type].variant_value_ordered.push_back(p_constant_name); -#endif - } -}; - -_VariantCall::TypeFunc *_VariantCall::type_funcs = nullptr; -_VariantCall::ConstructFunc *_VariantCall::construct_funcs = nullptr; -_VariantCall::ConstantData *_VariantCall::constant_data = nullptr; - -Variant Variant::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - Variant ret; - call_ptr(p_method, p_args, p_argcount, &ret, r_error); - return ret; -} - -void Variant::call_ptr(const StringName &p_method, const Variant **p_args, int p_argcount, Variant *r_ret, Callable::CallError &r_error) { - Variant ret; - - if (type == Variant::OBJECT) { - //call object - Object *obj = _get_obj().obj; - if (!obj) { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - return; - } -#ifdef DEBUG_ENABLED - if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) { - r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - return; - } - -#endif - ret = _get_obj().obj->call(p_method, p_args, p_argcount, r_error); - - //else if (type==Variant::METHOD) { - - } else { - r_error.error = Callable::CallError::CALL_OK; - - Map::Element *E = _VariantCall::type_funcs[type].functions.find(p_method); - - if (E) { - _VariantCall::FuncData &funcdata = E->get(); - funcdata.call(ret, *this, p_args, p_argcount, r_error); - - } else { - //handle vararg functions manually - bool valid = false; - if (type == CALLABLE) { - if (p_method == CoreStringNames::get_singleton()->call) { - reinterpret_cast(_data._mem)->call(p_args, p_argcount, ret, r_error); - valid = true; - } - if (p_method == CoreStringNames::get_singleton()->call_deferred) { - reinterpret_cast(_data._mem)->call_deferred(p_args, p_argcount); - valid = true; - } - } else if (type == SIGNAL) { - if (p_method == CoreStringNames::get_singleton()->emit) { - if (r_ret) { - *r_ret = Variant(); - } - reinterpret_cast(_data._mem)->emit(p_args, p_argcount); - valid = true; - } - } - if (!valid) { - //ok fail because not found - r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; - return; - } - } - } - - if (r_error.error == Callable::CallError::CALL_OK && r_ret) { - *r_ret = ret; - } -} - -#define VCALL(m_type, m_method) _VariantCall::_call_##m_type##_##m_method - -Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, int p_argcount, Callable::CallError &r_error, bool p_strict) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; - ERR_FAIL_INDEX_V(p_type, VARIANT_MAX, Variant()); - - r_error.error = Callable::CallError::CALL_OK; - if (p_argcount == 0) { //generic construct - - switch (p_type) { - case NIL: - return Variant(); - - // atomic types - case BOOL: - return Variant(false); - case INT: - return 0; - case FLOAT: - return 0.0f; - case STRING: - return String(); - - // math types - case VECTOR2: - return Vector2(); - case VECTOR2I: - return Vector2i(); - case RECT2: - return Rect2(); - case RECT2I: - return Rect2i(); - case VECTOR3: - return Vector3(); - case VECTOR3I: - return Vector3i(); - case TRANSFORM2D: - return Transform2D(); - case PLANE: - return Plane(); - case QUAT: - return Quat(); - case AABB: - return ::AABB(); - case BASIS: - return Basis(); - case TRANSFORM: - return Transform(); - - // misc types - case COLOR: - return Color(); - case STRING_NAME: - return StringName(); - case NODE_PATH: - return NodePath(); - case _RID: - return RID(); - case OBJECT: - return (Object *)nullptr; - case CALLABLE: - return Callable(); - case SIGNAL: - return Signal(); - case DICTIONARY: - return Dictionary(); - case ARRAY: - return Array(); - case PACKED_BYTE_ARRAY: - return PackedByteArray(); - case PACKED_INT32_ARRAY: - return PackedInt32Array(); - case PACKED_INT64_ARRAY: - return PackedInt64Array(); - case PACKED_FLOAT32_ARRAY: - return PackedFloat32Array(); - case PACKED_FLOAT64_ARRAY: - return PackedFloat64Array(); - case PACKED_STRING_ARRAY: - return PackedStringArray(); - case PACKED_VECTOR2_ARRAY: - return PackedVector2Array(); - case PACKED_VECTOR3_ARRAY: - return PackedVector3Array(); - case PACKED_COLOR_ARRAY: - return PackedColorArray(); - default: - return Variant(); - } - - } else if (p_argcount == 1 && p_args[0]->type == p_type) { - return *p_args[0]; //copy construct - } else if (p_argcount == 1 && (!p_strict || Variant::can_convert(p_args[0]->type, p_type))) { - //near match construct - - switch (p_type) { - case NIL: { - return Variant(); - } break; - case BOOL: { - return Variant(bool(*p_args[0])); - } - case INT: { - return (int64_t(*p_args[0])); - } - case FLOAT: { - return double(*p_args[0]); - } - case STRING: { - return String(*p_args[0]); - } - case VECTOR2: { - return Vector2(*p_args[0]); - } - case VECTOR2I: { - return Vector2i(*p_args[0]); - } - case RECT2: - return (Rect2(*p_args[0])); - case RECT2I: - return (Rect2i(*p_args[0])); - case VECTOR3: - return (Vector3(*p_args[0])); - case VECTOR3I: - return (Vector3i(*p_args[0])); - case TRANSFORM2D: - return (Transform2D(p_args[0]->operator Transform2D())); - case PLANE: - return (Plane(*p_args[0])); - case QUAT: - return (p_args[0]->operator Quat()); - case AABB: - return (::AABB(*p_args[0])); - case BASIS: - return (Basis(p_args[0]->operator Basis())); - case TRANSFORM: - return (Transform(p_args[0]->operator Transform())); - - // misc types - case COLOR: - return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]); - case STRING_NAME: - return (StringName(p_args[0]->operator StringName())); - case NODE_PATH: - return (NodePath(p_args[0]->operator NodePath())); - case _RID: - return (RID(*p_args[0])); - case OBJECT: - return ((Object *)(p_args[0]->operator Object *())); - case CALLABLE: - return ((Callable)(p_args[0]->operator Callable())); - case SIGNAL: - return ((Signal)(p_args[0]->operator Signal())); - case DICTIONARY: - return p_args[0]->operator Dictionary(); - case ARRAY: - return p_args[0]->operator Array(); - - // arrays - case PACKED_BYTE_ARRAY: - return (PackedByteArray(*p_args[0])); - case PACKED_INT32_ARRAY: - return (PackedInt32Array(*p_args[0])); - case PACKED_INT64_ARRAY: - return (PackedInt64Array(*p_args[0])); - case PACKED_FLOAT32_ARRAY: - return (PackedFloat32Array(*p_args[0])); - case PACKED_FLOAT64_ARRAY: - return (PackedFloat64Array(*p_args[0])); - case PACKED_STRING_ARRAY: - return (PackedStringArray(*p_args[0])); - case PACKED_VECTOR2_ARRAY: - return (PackedVector2Array(*p_args[0])); - case PACKED_VECTOR3_ARRAY: - return (PackedVector3Array(*p_args[0])); - case PACKED_COLOR_ARRAY: - return (PackedColorArray(*p_args[0])); - default: - return Variant(); - } - } else if (p_argcount >= 1) { - _VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type]; - - for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) { - const _VariantCall::ConstructData &cd = E->get(); - - if (cd.arg_count != p_argcount) { - continue; - } - - //validate parameters - for (int i = 0; i < cd.arg_count; i++) { - if (!Variant::can_convert(p_args[i]->type, cd.arg_types[i])) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor - r_error.argument = i; - r_error.expected = cd.arg_types[i]; - return Variant(); - } - } - - Variant v; - cd.func(v, p_args); - return v; - } - } - r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; //no such constructor - return Variant(); -} - -bool Variant::has_method(const StringName &p_method) const { - if (type == OBJECT) { - Object *obj = get_validated_object(); - if (!obj) { - return false; - } - - return obj->has_method(p_method); - } - - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[type]; - return tf.functions.has(p_method); -} - -Vector Variant::get_method_argument_types(Variant::Type p_type, const StringName &p_method) { - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type]; - - const Map::Element *E = tf.functions.find(p_method); - if (!E) { - return Vector(); - } - - return E->get().arg_types; -} - -bool Variant::is_method_const(Variant::Type p_type, const StringName &p_method) { - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type]; - - const Map::Element *E = tf.functions.find(p_method); - if (!E) { - return false; - } - - return E->get()._const; -} - -Vector Variant::get_method_argument_names(Variant::Type p_type, const StringName &p_method) { - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type]; - - const Map::Element *E = tf.functions.find(p_method); - if (!E) { - return Vector(); - } - - return E->get().arg_names; -} - -Variant::Type Variant::get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return) { - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type]; - - const Map::Element *E = tf.functions.find(p_method); - if (!E) { - return Variant::NIL; - } - - if (r_has_return) { - *r_has_return = E->get().returns; - } - - return E->get().return_type; -} - -Vector Variant::get_method_default_arguments(Variant::Type p_type, const StringName &p_method) { - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type]; - - const Map::Element *E = tf.functions.find(p_method); - if (!E) { - return Vector(); - } - - return E->get().default_args; -} - -void Variant::get_method_list(List *p_list) const { - const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[type]; - - for (const Map::Element *E = tf.functions.front(); E; E = E->next()) { - const _VariantCall::FuncData &fd = E->get(); - - MethodInfo mi; - mi.name = E->key(); - - if (fd._const) { - mi.flags |= METHOD_FLAG_CONST; - } - - for (int i = 0; i < fd.arg_types.size(); i++) { - PropertyInfo pi; - pi.type = fd.arg_types[i]; -#ifdef DEBUG_ENABLED - pi.name = fd.arg_names[i]; -#endif - mi.arguments.push_back(pi); - } - - mi.default_arguments = fd.default_args; - PropertyInfo ret; -#ifdef DEBUG_ENABLED - ret.type = fd.return_type; - if (fd.returns) { - ret.name = "ret"; - if (fd.return_type == Variant::NIL) { - ret.usage = PROPERTY_USAGE_NIL_IS_VARIANT; - } - } - mi.return_val = ret; -#endif - - p_list->push_back(mi); - } - - if (type == CALLABLE) { - MethodInfo mi; - mi.name = "call"; - mi.return_val.usage = PROPERTY_USAGE_NIL_IS_VARIANT; - mi.flags |= METHOD_FLAG_VARARG; - - p_list->push_back(mi); - - mi.name = "call_deferred"; - mi.return_val.usage = 0; - - p_list->push_back(mi); - } - - if (type == SIGNAL) { - MethodInfo mi; - mi.name = "emit"; - mi.flags |= METHOD_FLAG_VARARG; - - p_list->push_back(mi); - } -} - -void Variant::get_constructor_list(Variant::Type p_type, List *p_list) { - ERR_FAIL_INDEX(p_type, VARIANT_MAX); - - //custom constructors - for (const List<_VariantCall::ConstructData>::Element *E = _VariantCall::construct_funcs[p_type].constructors.front(); E; E = E->next()) { - const _VariantCall::ConstructData &cd = E->get(); - MethodInfo mi; - mi.name = Variant::get_type_name(p_type); - mi.return_val.type = p_type; - for (int i = 0; i < cd.arg_count; i++) { - PropertyInfo pi; - pi.name = cd.arg_names[i]; - pi.type = cd.arg_types[i]; - mi.arguments.push_back(pi); - } - p_list->push_back(mi); - } - //default constructors - for (int i = 0; i < VARIANT_MAX; i++) { - if (i == p_type) { - continue; - } - if (!Variant::can_convert(Variant::Type(i), p_type)) { - continue; - } - - MethodInfo mi; - mi.name = Variant::get_type_name(p_type); - PropertyInfo pi; - pi.name = "from"; - pi.type = Variant::Type(i); - mi.arguments.push_back(pi); - mi.return_val.type = p_type; - p_list->push_back(mi); - } -} - -void Variant::get_constants_for_type(Variant::Type p_type, List *p_constants) { - ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); - - _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; - -#ifdef DEBUG_ENABLED - for (List::Element *E = cd.value_ordered.front(); E; E = E->next()) { - p_constants->push_back(E->get()); -#else - for (Map::Element *E = cd.value.front(); E; E = E->next()) { - p_constants->push_back(E->key()); -#endif - } - -#ifdef DEBUG_ENABLED - for (List::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { - p_constants->push_back(E->get()); -#else - for (Map::Element *E = cd.variant_value.front(); E; E = E->next()) { - p_constants->push_back(E->key()); -#endif - } -} - -bool Variant::has_constant(Variant::Type p_type, const StringName &p_value) { - ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); - _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; - return cd.value.has(p_value) || cd.variant_value.has(p_value); -} - -Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid) { - if (r_valid) { - *r_valid = false; - } - - ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0); - _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; - - Map::Element *E = cd.value.find(p_value); - if (!E) { - Map::Element *F = cd.variant_value.find(p_value); - if (F) { - if (r_valid) { - *r_valid = true; - } - return F->get(); - } else { - return -1; - } - } - if (r_valid) { - *r_valid = true; - } - - return E->get(); -} - -void register_variant_methods() { - _VariantCall::type_funcs = memnew_arr(_VariantCall::TypeFunc, Variant::VARIANT_MAX); - - _VariantCall::construct_funcs = memnew_arr(_VariantCall::ConstructFunc, Variant::VARIANT_MAX); - _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX); - -#define ADDFUNC0R(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); -#define ADDFUNC1R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); -#define ADDFUNC2R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); -#define ADDFUNC3R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); -#define ADDFUNC4R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); - -#define ADDFUNC0RNC(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); -#define ADDFUNC1RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); -#define ADDFUNC2RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); -#define ADDFUNC3RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); -#define ADDFUNC4RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); - -#define ADDFUNC0(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); -#define ADDFUNC1(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); -#define ADDFUNC2(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); -#define ADDFUNC3(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); -#define ADDFUNC4(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); - -#define ADDFUNC0NC(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); -#define ADDFUNC1NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); -#define ADDFUNC2NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); -#define ADDFUNC3NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); -#define ADDFUNC4NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); - - /* STRING */ - ADDFUNC1R(STRING, INT, String, casecmp_to, STRING, "to", varray()); - ADDFUNC1R(STRING, INT, String, nocasecmp_to, STRING, "to", varray()); - ADDFUNC0R(STRING, INT, String, length, varray()); - ADDFUNC2R(STRING, STRING, String, substr, INT, "from", INT, "len", varray(-1)); - - ADDFUNC2R(STRING, INT, String, find, STRING, "what", INT, "from", varray(0)); - - ADDFUNC3R(STRING, INT, String, count, STRING, "what", INT, "from", INT, "to", varray(0, 0)); - ADDFUNC3R(STRING, INT, String, countn, STRING, "what", INT, "from", INT, "to", varray(0, 0)); - - ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0)); - ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1)); - ADDFUNC2R(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1)); - ADDFUNC1R(STRING, BOOL, String, match, STRING, "expr", varray()); - ADDFUNC1R(STRING, BOOL, String, matchn, STRING, "expr", varray()); - ADDFUNC1R(STRING, BOOL, String, begins_with, STRING, "text", varray()); - ADDFUNC1R(STRING, BOOL, String, ends_with, STRING, "text", varray()); - ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray()); - ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray()); - ADDFUNC0R(STRING, PACKED_STRING_ARRAY, String, bigrams, varray()); - ADDFUNC1R(STRING, FLOAT, String, similarity, STRING, "text", varray()); - - ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}")); - ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray()); - ADDFUNC2R(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray()); - ADDFUNC1R(STRING, STRING, String, repeat, INT, "count", varray()); - ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray()); - ADDFUNC0R(STRING, STRING, String, capitalize, varray()); - ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); - ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, rsplit, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); - ADDFUNC2R(STRING, PACKED_FLOAT32_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true)); - ADDFUNC1R(STRING, STRING, String, join, PACKED_STRING_ARRAY, "parts", varray()); - - ADDFUNC0R(STRING, STRING, String, to_upper, varray()); - ADDFUNC0R(STRING, STRING, String, to_lower, varray()); - - ADDFUNC1R(STRING, STRING, String, left, INT, "position", varray()); - ADDFUNC1R(STRING, STRING, String, right, INT, "position", varray()); - ADDFUNC2R(STRING, STRING, String, strip_edges, BOOL, "left", BOOL, "right", varray(true, true)); - ADDFUNC0R(STRING, STRING, String, strip_escapes, varray()); - ADDFUNC1R(STRING, STRING, String, lstrip, STRING, "chars", varray()); - ADDFUNC1R(STRING, STRING, String, rstrip, STRING, "chars", varray()); - ADDFUNC0R(STRING, STRING, String, get_extension, varray()); - ADDFUNC0R(STRING, STRING, String, get_basename, varray()); - ADDFUNC1R(STRING, STRING, String, plus_file, STRING, "file", varray()); - ADDFUNC1R(STRING, INT, String, ord_at, INT, "at", varray()); - ADDFUNC0R(STRING, STRING, String, dedent, varray()); - ADDFUNC2(STRING, NIL, String, erase, INT, "position", INT, "chars", varray()); - ADDFUNC0R(STRING, INT, String, hash, varray()); - ADDFUNC0R(STRING, STRING, String, md5_text, varray()); - ADDFUNC0R(STRING, STRING, String, sha1_text, varray()); - ADDFUNC0R(STRING, STRING, String, sha256_text, varray()); - ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, md5_buffer, varray()); - ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, sha1_buffer, varray()); - ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, sha256_buffer, varray()); - ADDFUNC0R(STRING, BOOL, String, empty, varray()); - ADDFUNC1R(STRING, STRING, String, humanize_size, INT, "size", varray()); - ADDFUNC0R(STRING, BOOL, String, is_abs_path, varray()); - ADDFUNC0R(STRING, BOOL, String, is_rel_path, varray()); - ADDFUNC0R(STRING, STRING, String, get_base_dir, varray()); - ADDFUNC0R(STRING, STRING, String, get_file, varray()); - ADDFUNC0R(STRING, STRING, String, xml_escape, varray()); - ADDFUNC0R(STRING, STRING, String, xml_unescape, varray()); - ADDFUNC0R(STRING, STRING, String, http_escape, varray()); - ADDFUNC0R(STRING, STRING, String, http_unescape, varray()); - ADDFUNC0R(STRING, STRING, String, c_escape, varray()); - ADDFUNC0R(STRING, STRING, String, c_unescape, varray()); - ADDFUNC0R(STRING, STRING, String, json_escape, varray()); - ADDFUNC0R(STRING, STRING, String, percent_encode, varray()); - ADDFUNC0R(STRING, STRING, String, percent_decode, varray()); - ADDFUNC0R(STRING, BOOL, String, is_valid_identifier, varray()); - ADDFUNC0R(STRING, BOOL, String, is_valid_integer, varray()); - ADDFUNC0R(STRING, BOOL, String, is_valid_float, varray()); - ADDFUNC1R(STRING, BOOL, String, is_valid_hex_number, BOOL, "with_prefix", varray(false)); - ADDFUNC0R(STRING, BOOL, String, is_valid_html_color, varray()); - ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray()); - ADDFUNC0R(STRING, BOOL, String, is_valid_filename, varray()); - ADDFUNC0R(STRING, INT, String, to_int, varray()); - ADDFUNC0R(STRING, FLOAT, String, to_float, varray()); - ADDFUNC0R(STRING, INT, String, hex_to_int, varray()); - ADDFUNC1R(STRING, STRING, String, pad_decimals, INT, "digits", varray()); - ADDFUNC1R(STRING, STRING, String, pad_zeros, INT, "digits", varray()); - ADDFUNC1R(STRING, STRING, String, trim_prefix, STRING, "prefix", varray()); - ADDFUNC1R(STRING, STRING, String, trim_suffix, STRING, "suffix", varray()); - - ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_ascii, varray()); - ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_utf8, varray()); - - ADDFUNC0R(VECTOR2, FLOAT, Vector2, angle, varray()); - ADDFUNC1R(VECTOR2, FLOAT, Vector2, angle_to, VECTOR2, "to", varray()); - ADDFUNC1R(VECTOR2, FLOAT, Vector2, angle_to_point, VECTOR2, "to", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, direction_to, VECTOR2, "b", varray()); - ADDFUNC1R(VECTOR2, FLOAT, Vector2, distance_to, VECTOR2, "to", varray()); - ADDFUNC1R(VECTOR2, FLOAT, Vector2, distance_squared_to, VECTOR2, "to", varray()); - ADDFUNC0R(VECTOR2, FLOAT, Vector2, length, varray()); - ADDFUNC0R(VECTOR2, FLOAT, Vector2, length_squared, varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray()); - ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray()); - ADDFUNC1R(VECTOR2, BOOL, Vector2, is_equal_approx, VECTOR2, "v", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, FLOAT, "mod", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, lerp, VECTOR2, "b", FLOAT, "t", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", FLOAT, "t", varray()); - ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", FLOAT, "t", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", FLOAT, "delta", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, FLOAT, "phi", varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, floor, varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, ceil, varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, round, varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray()); - ADDFUNC0R(VECTOR2, FLOAT, Vector2, aspect, varray()); - ADDFUNC1R(VECTOR2, FLOAT, Vector2, dot, VECTOR2, "with", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray()); - ADDFUNC1R(VECTOR2, FLOAT, Vector2, cross, VECTOR2, "with", varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray()); - ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, FLOAT, "length", varray()); - ADDFUNC0R(VECTOR2, VECTOR2, Vector2, sign, varray()); - - ADDFUNC0R(VECTOR2I, FLOAT, Vector2i, aspect, varray()); - ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, sign, varray()); - ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, abs, varray()); - - ADDFUNC0R(RECT2, FLOAT, Rect2, get_area, varray()); - ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray()); - ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray()); - ADDFUNC1R(RECT2, BOOL, Rect2, is_equal_approx, RECT2, "rect", varray()); - ADDFUNC2R(RECT2, BOOL, Rect2, intersects, RECT2, "b", BOOL, "include_borders", varray(false)); - ADDFUNC1R(RECT2, BOOL, Rect2, encloses, RECT2, "b", varray()); - ADDFUNC1R(RECT2, RECT2, Rect2, clip, RECT2, "b", varray()); - ADDFUNC1R(RECT2, RECT2, Rect2, merge, RECT2, "b", varray()); - ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray()); - ADDFUNC1R(RECT2, RECT2, Rect2, grow, FLOAT, "by", varray()); - ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", FLOAT, "by", varray()); - ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, FLOAT, "left", FLOAT, "top", FLOAT, "right", FLOAT, " bottom", varray()); - ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray()); - - ADDFUNC0R(RECT2I, INT, Rect2i, get_area, varray()); - ADDFUNC0R(RECT2I, BOOL, Rect2i, has_no_area, varray()); - ADDFUNC1R(RECT2I, BOOL, Rect2i, has_point, VECTOR2I, "point", varray()); - ADDFUNC1R(RECT2I, BOOL, Rect2i, intersects, RECT2I, "b", varray()); - ADDFUNC1R(RECT2I, BOOL, Rect2i, encloses, RECT2I, "b", varray()); - ADDFUNC1R(RECT2I, RECT2I, Rect2i, clip, RECT2I, "b", varray()); - ADDFUNC1R(RECT2I, RECT2I, Rect2i, merge, RECT2I, "b", varray()); - ADDFUNC1R(RECT2I, RECT2I, Rect2i, expand, VECTOR2I, "to", varray()); - ADDFUNC1R(RECT2I, RECT2I, Rect2i, grow, INT, "by", varray()); - ADDFUNC2R(RECT2I, RECT2I, Rect2i, grow_margin, INT, "margin", INT, "by", varray()); - ADDFUNC4R(RECT2I, RECT2I, Rect2i, grow_individual, INT, "left", INT, "top", INT, "right", INT, " bottom", varray()); - ADDFUNC0R(RECT2I, RECT2I, Rect2i, abs, varray()); - - ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray()); - ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray()); - ADDFUNC1R(VECTOR3, FLOAT, Vector3, angle_to, VECTOR3, "to", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, direction_to, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, FLOAT, Vector3, distance_to, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, FLOAT, Vector3, distance_squared_to, VECTOR3, "b", varray()); - ADDFUNC0R(VECTOR3, FLOAT, Vector3, length, varray()); - ADDFUNC0R(VECTOR3, FLOAT, Vector3, length_squared, varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray()); - ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray()); - ADDFUNC1R(VECTOR3, BOOL, Vector3, is_equal_approx, VECTOR3, "v", varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, lerp, VECTOR3, "b", FLOAT, "t", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", FLOAT, "t", varray()); - ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", FLOAT, "t", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", FLOAT, "delta", varray()); - ADDFUNC1R(VECTOR3, FLOAT, Vector3, dot, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray()); - ADDFUNC0R(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, abs, varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, round, varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmod, FLOAT, "mod", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmodv, VECTOR3, "modv", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, project, VECTOR3, "b", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray()); - ADDFUNC1R(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray()); - ADDFUNC0R(VECTOR3, VECTOR3, Vector3, sign, varray()); - - ADDFUNC0R(VECTOR3I, INT, Vector3i, min_axis, varray()); - ADDFUNC0R(VECTOR3I, INT, Vector3i, max_axis, varray()); - ADDFUNC0R(VECTOR3I, VECTOR3I, Vector3i, sign, varray()); - - ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray()); - ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray()); - ADDFUNC1R(PLANE, BOOL, Plane, is_equal_approx, PLANE, "plane", varray()); - ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray()); - ADDFUNC1R(PLANE, FLOAT, Plane, distance_to, VECTOR3, "point", varray()); - ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", FLOAT, "epsilon", varray(CMP_EPSILON)); - ADDFUNC1R(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray()); - ADDFUNC2R(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray()); - ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray()); - ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray()); - - ADDFUNC0R(QUAT, FLOAT, Quat, length, varray()); - ADDFUNC0R(QUAT, FLOAT, Quat, length_squared, varray()); - ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray()); - ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray()); - ADDFUNC1R(QUAT, BOOL, Quat, is_equal_approx, QUAT, "quat", varray()); - ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray()); - ADDFUNC1R(QUAT, FLOAT, Quat, dot, QUAT, "b", varray()); - ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray()); - ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", FLOAT, "t", varray()); - ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", FLOAT, "t", varray()); - ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", FLOAT, "t", varray()); - ADDFUNC0R(QUAT, VECTOR3, Quat, get_euler, varray()); - ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray()); - ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", FLOAT, "angle", varray()); - - ADDFUNC0R(COLOR, INT, Color, to_argb32, varray()); - ADDFUNC0R(COLOR, INT, Color, to_abgr32, varray()); - ADDFUNC0R(COLOR, INT, Color, to_rgba32, varray()); - ADDFUNC0R(COLOR, INT, Color, to_argb64, varray()); - ADDFUNC0R(COLOR, INT, Color, to_abgr64, varray()); - ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray()); - ADDFUNC0R(COLOR, COLOR, Color, inverted, varray()); - ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray()); - ADDFUNC2R(COLOR, COLOR, Color, lerp, COLOR, "b", FLOAT, "t", varray()); - ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray()); - ADDFUNC1R(COLOR, COLOR, Color, lightened, FLOAT, "amount", varray()); - ADDFUNC1R(COLOR, COLOR, Color, darkened, FLOAT, "amount", varray()); - ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true)); - ADDFUNC4R(COLOR, COLOR, Color, from_hsv, FLOAT, "h", FLOAT, "s", FLOAT, "v", FLOAT, "a", varray(1.0)); - ADDFUNC1R(COLOR, BOOL, Color, is_equal_approx, COLOR, "color", varray()); - - ADDFUNC0R(_RID, INT, RID, get_id, varray()); - - ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_absolute, varray()); - ADDFUNC0R(NODE_PATH, INT, NodePath, get_name_count, varray()); - ADDFUNC1R(NODE_PATH, STRING, NodePath, get_name, INT, "idx", varray()); - ADDFUNC0R(NODE_PATH, INT, NodePath, get_subname_count, varray()); - ADDFUNC1R(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray()); - ADDFUNC0R(NODE_PATH, STRING, NodePath, get_concatenated_subnames, varray()); - ADDFUNC0R(NODE_PATH, NODE_PATH, NodePath, get_as_property_path, varray()); - ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_empty, varray()); - - ADDFUNC0R(DICTIONARY, INT, Dictionary, size, varray()); - ADDFUNC0R(DICTIONARY, BOOL, Dictionary, empty, varray()); - ADDFUNC0NC(DICTIONARY, NIL, Dictionary, clear, varray()); - ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray()); - ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray()); - ADDFUNC1RNC(DICTIONARY, BOOL, Dictionary, erase, NIL, "key", varray()); - ADDFUNC0R(DICTIONARY, INT, Dictionary, hash, varray()); - ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, keys, varray()); - ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, values, varray()); - ADDFUNC1R(DICTIONARY, DICTIONARY, Dictionary, duplicate, BOOL, "deep", varray(false)); - ADDFUNC2R(DICTIONARY, NIL, Dictionary, get, NIL, "key", NIL, "default", varray(Variant())); - - ADDFUNC0R(CALLABLE, BOOL, Callable, is_null, varray()); - ADDFUNC0R(CALLABLE, BOOL, Callable, is_custom, varray()); - ADDFUNC0R(CALLABLE, BOOL, Callable, is_standard, varray()); - ADDFUNC0R(CALLABLE, OBJECT, Callable, get_object, varray()); - ADDFUNC0R(CALLABLE, INT, Callable, get_object_id, varray()); - ADDFUNC0R(CALLABLE, STRING_NAME, Callable, get_method, varray()); - ADDFUNC0R(CALLABLE, INT, Callable, hash, varray()); - - ADDFUNC0R(SIGNAL, BOOL, Signal, is_null, varray()); - ADDFUNC0R(SIGNAL, OBJECT, Signal, get_object, varray()); - ADDFUNC0R(SIGNAL, INT, Signal, get_object_id, varray()); - ADDFUNC0R(SIGNAL, STRING_NAME, Signal, get_name, varray()); - - ADDFUNC3R(SIGNAL, INT, Signal, connect, CALLABLE, "callable", ARRAY, "binds", INT, "flags", varray(Array(), 0)); - - ADDFUNC1R(SIGNAL, NIL, Signal, disconnect, CALLABLE, "callable", varray()); - ADDFUNC1R(SIGNAL, BOOL, Signal, is_connected, CALLABLE, "callable", varray()); - ADDFUNC0R(SIGNAL, ARRAY, Signal, get_connections, varray()); - - ADDFUNC0R(ARRAY, INT, Array, size, varray()); - ADDFUNC0R(ARRAY, BOOL, Array, empty, varray()); - ADDFUNC0NC(ARRAY, NIL, Array, clear, varray()); - ADDFUNC0R(ARRAY, INT, Array, hash, varray()); - ADDFUNC1NC(ARRAY, NIL, Array, push_back, NIL, "value", varray()); - ADDFUNC1NC(ARRAY, NIL, Array, push_front, NIL, "value", varray()); - ADDFUNC1NC(ARRAY, NIL, Array, append, NIL, "value", varray()); - ADDFUNC1NC(ARRAY, NIL, Array, resize, INT, "size", varray()); - ADDFUNC2NC(ARRAY, NIL, Array, insert, INT, "position", NIL, "value", varray()); - ADDFUNC1NC(ARRAY, NIL, Array, remove, INT, "position", varray()); - ADDFUNC1NC(ARRAY, NIL, Array, erase, NIL, "value", varray()); - ADDFUNC0R(ARRAY, NIL, Array, front, varray()); - ADDFUNC0R(ARRAY, NIL, Array, back, varray()); - ADDFUNC2R(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0)); - ADDFUNC2R(ARRAY, INT, Array, rfind, NIL, "what", INT, "from", varray(-1)); - ADDFUNC1R(ARRAY, INT, Array, find_last, NIL, "value", varray()); - ADDFUNC1R(ARRAY, INT, Array, count, NIL, "value", varray()); - ADDFUNC1R(ARRAY, BOOL, Array, has, NIL, "value", varray()); - ADDFUNC0RNC(ARRAY, NIL, Array, pop_back, varray()); - ADDFUNC0RNC(ARRAY, NIL, Array, pop_front, varray()); - ADDFUNC0NC(ARRAY, NIL, Array, sort, varray()); - ADDFUNC2NC(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray()); - ADDFUNC0NC(ARRAY, NIL, Array, shuffle, varray()); - ADDFUNC2R(ARRAY, INT, Array, bsearch, NIL, "value", BOOL, "before", varray(true)); - ADDFUNC4R(ARRAY, INT, Array, bsearch_custom, NIL, "value", OBJECT, "obj", STRING, "func", BOOL, "before", varray(true)); - ADDFUNC0NC(ARRAY, NIL, Array, invert, varray()); - ADDFUNC1R(ARRAY, ARRAY, Array, duplicate, BOOL, "deep", varray(false)); - ADDFUNC4R(ARRAY, ARRAY, Array, slice, INT, "begin", INT, "end", INT, "step", BOOL, "deep", varray(1, false)); - ADDFUNC0R(ARRAY, NIL, Array, max, varray()); - ADDFUNC0R(ARRAY, NIL, Array, min, varray()); - - ADDFUNC0R(PACKED_BYTE_ARRAY, INT, PackedByteArray, size, varray()); - ADDFUNC0R(PACKED_BYTE_ARRAY, BOOL, PackedByteArray, empty, varray()); - ADDFUNC2(PACKED_BYTE_ARRAY, NIL, PackedByteArray, set, INT, "idx", INT, "byte", varray()); - ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, push_back, INT, "byte", varray()); - ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, append, INT, "byte", varray()); - ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, append_array, PACKED_BYTE_ARRAY, "array", varray()); - ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_BYTE_ARRAY, INT, PackedByteArray, insert, INT, "idx", INT, "byte", varray()); - ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_BYTE_ARRAY, BOOL, PackedByteArray, has, INT, "value", varray()); - ADDFUNC0(PACKED_BYTE_ARRAY, NIL, PackedByteArray, sort, varray()); - ADDFUNC0(PACKED_BYTE_ARRAY, NIL, PackedByteArray, invert, varray()); - ADDFUNC2R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, subarray, INT, "from", INT, "to", varray()); - - ADDFUNC0R(PACKED_BYTE_ARRAY, STRING, PackedByteArray, get_string_from_ascii, varray()); - ADDFUNC0R(PACKED_BYTE_ARRAY, STRING, PackedByteArray, get_string_from_utf8, varray()); - ADDFUNC0R(PACKED_BYTE_ARRAY, STRING, PackedByteArray, hex_encode, varray()); - ADDFUNC1R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, compress, INT, "compression_mode", varray(0)); - ADDFUNC2R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0)); - - ADDFUNC0R(PACKED_INT32_ARRAY, INT, PackedInt32Array, size, varray()); - ADDFUNC0R(PACKED_INT32_ARRAY, BOOL, PackedInt32Array, empty, varray()); - ADDFUNC2(PACKED_INT32_ARRAY, NIL, PackedInt32Array, set, INT, "idx", INT, "integer", varray()); - ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, push_back, INT, "integer", varray()); - ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, append, INT, "integer", varray()); - ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, append_array, PACKED_INT32_ARRAY, "array", varray()); - ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_INT32_ARRAY, INT, PackedInt32Array, insert, INT, "idx", INT, "integer", varray()); - ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_INT32_ARRAY, BOOL, PackedInt32Array, has, INT, "value", varray()); - ADDFUNC0(PACKED_INT32_ARRAY, NIL, PackedInt32Array, sort, varray()); - ADDFUNC0(PACKED_INT32_ARRAY, NIL, PackedInt32Array, invert, varray()); - - ADDFUNC0R(PACKED_INT64_ARRAY, INT, PackedInt64Array, size, varray()); - ADDFUNC0R(PACKED_INT64_ARRAY, BOOL, PackedInt64Array, empty, varray()); - ADDFUNC2(PACKED_INT64_ARRAY, NIL, PackedInt64Array, set, INT, "idx", INT, "integer", varray()); - ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, push_back, INT, "integer", varray()); - ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, append, INT, "integer", varray()); - ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, append_array, PACKED_INT64_ARRAY, "array", varray()); - ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_INT64_ARRAY, INT, PackedInt64Array, insert, INT, "idx", INT, "integer", varray()); - ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_INT64_ARRAY, BOOL, PackedInt64Array, has, INT, "value", varray()); - ADDFUNC0(PACKED_INT64_ARRAY, NIL, PackedInt64Array, sort, varray()); - ADDFUNC0(PACKED_INT64_ARRAY, NIL, PackedInt64Array, invert, varray()); - - ADDFUNC0R(PACKED_FLOAT32_ARRAY, INT, PackedFloat32Array, size, varray()); - ADDFUNC0R(PACKED_FLOAT32_ARRAY, BOOL, PackedFloat32Array, empty, varray()); - ADDFUNC2(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, set, INT, "idx", FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, push_back, FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, append, FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, append_array, PACKED_FLOAT32_ARRAY, "array", varray()); - ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_FLOAT32_ARRAY, INT, PackedFloat32Array, insert, INT, "idx", FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_FLOAT32_ARRAY, BOOL, PackedFloat32Array, has, FLOAT, "value", varray()); - ADDFUNC0(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, sort, varray()); - ADDFUNC0(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, invert, varray()); - - ADDFUNC0R(PACKED_FLOAT64_ARRAY, INT, PackedFloat64Array, size, varray()); - ADDFUNC0R(PACKED_FLOAT64_ARRAY, BOOL, PackedFloat64Array, empty, varray()); - ADDFUNC2(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, set, INT, "idx", FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, push_back, FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, append, FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, append_array, PACKED_FLOAT64_ARRAY, "array", varray()); - ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_FLOAT64_ARRAY, INT, PackedFloat64Array, insert, INT, "idx", FLOAT, "value", varray()); - ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_FLOAT64_ARRAY, BOOL, PackedFloat64Array, has, FLOAT, "value", varray()); - ADDFUNC0(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, sort, varray()); - ADDFUNC0(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, invert, varray()); - - ADDFUNC0R(PACKED_STRING_ARRAY, INT, PackedStringArray, size, varray()); - ADDFUNC0R(PACKED_STRING_ARRAY, BOOL, PackedStringArray, empty, varray()); - ADDFUNC2(PACKED_STRING_ARRAY, NIL, PackedStringArray, set, INT, "idx", STRING, "string", varray()); - ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, push_back, STRING, "string", varray()); - ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, append, STRING, "string", varray()); - ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, append_array, PACKED_STRING_ARRAY, "array", varray()); - ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_STRING_ARRAY, INT, PackedStringArray, insert, INT, "idx", STRING, "string", varray()); - ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_STRING_ARRAY, BOOL, PackedStringArray, has, STRING, "value", varray()); - ADDFUNC0(PACKED_STRING_ARRAY, NIL, PackedStringArray, sort, varray()); - ADDFUNC0(PACKED_STRING_ARRAY, NIL, PackedStringArray, invert, varray()); - - ADDFUNC0R(PACKED_VECTOR2_ARRAY, INT, PackedVector2Array, size, varray()); - ADDFUNC0R(PACKED_VECTOR2_ARRAY, BOOL, PackedVector2Array, empty, varray()); - ADDFUNC2(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, set, INT, "idx", VECTOR2, "vector2", varray()); - ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, push_back, VECTOR2, "vector2", varray()); - ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, append, VECTOR2, "vector2", varray()); - ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, append_array, PACKED_VECTOR2_ARRAY, "array", varray()); - ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_VECTOR2_ARRAY, INT, PackedVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray()); - ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_VECTOR2_ARRAY, BOOL, PackedVector2Array, has, VECTOR2, "value", varray()); - ADDFUNC0(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, sort, varray()); - ADDFUNC0(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, invert, varray()); - - ADDFUNC0R(PACKED_VECTOR3_ARRAY, INT, PackedVector3Array, size, varray()); - ADDFUNC0R(PACKED_VECTOR3_ARRAY, BOOL, PackedVector3Array, empty, varray()); - ADDFUNC2(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, set, INT, "idx", VECTOR3, "vector3", varray()); - ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, push_back, VECTOR3, "vector3", varray()); - ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, append, VECTOR3, "vector3", varray()); - ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, append_array, PACKED_VECTOR3_ARRAY, "array", varray()); - ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_VECTOR3_ARRAY, INT, PackedVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray()); - ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_VECTOR3_ARRAY, BOOL, PackedVector3Array, has, VECTOR3, "value", varray()); - ADDFUNC0(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, sort, varray()); - ADDFUNC0(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, invert, varray()); - - ADDFUNC0R(PACKED_COLOR_ARRAY, INT, PackedColorArray, size, varray()); - ADDFUNC0R(PACKED_COLOR_ARRAY, BOOL, PackedColorArray, empty, varray()); - ADDFUNC2(PACKED_COLOR_ARRAY, NIL, PackedColorArray, set, INT, "idx", COLOR, "color", varray()); - ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, push_back, COLOR, "color", varray()); - ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, append, COLOR, "color", varray()); - ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, append_array, PACKED_COLOR_ARRAY, "array", varray()); - ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, remove, INT, "idx", varray()); - ADDFUNC2R(PACKED_COLOR_ARRAY, INT, PackedColorArray, insert, INT, "idx", COLOR, "color", varray()); - ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, resize, INT, "idx", varray()); - ADDFUNC1R(PACKED_COLOR_ARRAY, BOOL, PackedColorArray, has, COLOR, "value", varray()); - ADDFUNC0(PACKED_COLOR_ARRAY, NIL, PackedColorArray, sort, varray()); - ADDFUNC0(PACKED_COLOR_ARRAY, NIL, PackedColorArray, invert, varray()); - - //pointerbased - - ADDFUNC0R(AABB, AABB, AABB, abs, varray()); - ADDFUNC0R(AABB, FLOAT, AABB, get_area, varray()); - ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray()); - ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray()); - ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray()); - ADDFUNC1R(AABB, BOOL, AABB, is_equal_approx, AABB, "aabb", varray()); - ADDFUNC1R(AABB, BOOL, AABB, intersects, AABB, "with", varray()); - ADDFUNC1R(AABB, BOOL, AABB, encloses, AABB, "with", varray()); - ADDFUNC1R(AABB, BOOL, AABB, intersects_plane, PLANE, "plane", varray()); - ADDFUNC2R(AABB, BOOL, AABB, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); - ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray()); - ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray()); - ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray()); - ADDFUNC1R(AABB, AABB, AABB, grow, FLOAT, "by", varray()); - ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray()); - ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray()); - ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray()); - ADDFUNC0R(AABB, FLOAT, AABB, get_longest_axis_size, varray()); - ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray()); - ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray()); - ADDFUNC0R(AABB, FLOAT, AABB, get_shortest_axis_size, varray()); - ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray()); - - ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray()); - ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray()); - ADDFUNC0R(TRANSFORM2D, FLOAT, Transform2D, get_rotation, varray()); - ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray()); - ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray()); - ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray()); - ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, FLOAT, "phi", varray()); - ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray()); - ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray()); - ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform, NIL, "v", varray()); - ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform_inv, NIL, "v", varray()); - ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform, VECTOR2, "v", varray()); - ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform_inv, VECTOR2, "v", varray()); - ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", FLOAT, "weight", varray()); - ADDFUNC1R(TRANSFORM2D, BOOL, Transform2D, is_equal_approx, TRANSFORM2D, "transform", varray()); - - ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray()); - ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray()); - ADDFUNC0R(BASIS, BASIS, Basis, orthonormalized, varray()); - ADDFUNC0R(BASIS, FLOAT, Basis, determinant, varray()); - ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); - ADDFUNC1R(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); - ADDFUNC0R(BASIS, VECTOR3, Basis, get_scale, varray()); - ADDFUNC0R(BASIS, VECTOR3, Basis, get_euler, varray()); - ADDFUNC1R(BASIS, FLOAT, Basis, tdotx, VECTOR3, "with", varray()); - ADDFUNC1R(BASIS, FLOAT, Basis, tdoty, VECTOR3, "with", varray()); - ADDFUNC1R(BASIS, FLOAT, Basis, tdotz, VECTOR3, "with", varray()); - ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray()); - ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray()); - ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray()); - ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", FLOAT, "t", varray()); - ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", FLOAT, "epsilon", varray(CMP_EPSILON)); // TODO: Replace in 4.0, see other TODO. - ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray()); - - ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray()); - ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray()); - ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray()); - ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); - ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray()); - ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "offset", varray()); - ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray()); - ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", FLOAT, "weight", varray()); - ADDFUNC1R(TRANSFORM, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray()); - ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray()); - ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray()); - - /* REGISTER CONSTRUCTORS */ - - _VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::FLOAT, "y", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Vector2i_init1, Variant::VECTOR2I, "x", Variant::INT, "y", Variant::INT); - - _VariantCall::add_constructor(_VariantCall::Rect2_init1, Variant::RECT2, "position", Variant::VECTOR2, "size", Variant::VECTOR2); - _VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::FLOAT, "y", Variant::FLOAT, "width", Variant::FLOAT, "height", Variant::FLOAT); - - _VariantCall::add_constructor(_VariantCall::Rect2i_init1, Variant::RECT2I, "position", Variant::VECTOR2, "size", Variant::VECTOR2); - _VariantCall::add_constructor(_VariantCall::Rect2i_init2, Variant::RECT2I, "x", Variant::INT, "y", Variant::INT, "width", Variant::INT, "height", Variant::INT); - - _VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::FLOAT, "position", Variant::VECTOR2); - _VariantCall::add_constructor(_VariantCall::Transform2D_init3, Variant::TRANSFORM2D, "x_axis", Variant::VECTOR2, "y_axis", Variant::VECTOR2, "origin", Variant::VECTOR2); - - _VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::FLOAT, "y", Variant::FLOAT, "z", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Vector3i_init1, Variant::VECTOR3I, "x", Variant::INT, "y", Variant::INT, "z", Variant::INT); - - _VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::FLOAT, "b", Variant::FLOAT, "c", Variant::FLOAT, "d", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Plane_init2, Variant::PLANE, "v1", Variant::VECTOR3, "v2", Variant::VECTOR3, "v3", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::FLOAT); - - _VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::FLOAT, "y", Variant::FLOAT, "z", Variant::FLOAT, "w", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Quat_init3, Variant::QUAT, "euler", Variant::VECTOR3); - - _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::FLOAT, "g", Variant::FLOAT, "b", Variant::FLOAT, "a", Variant::FLOAT); - _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::FLOAT, "g", Variant::FLOAT, "b", Variant::FLOAT); - // init3 and init4 are the constructors for HTML hex strings and integers respectively which don't need binding here, so we skip to init5. - _VariantCall::add_constructor(_VariantCall::Color_init5, Variant::COLOR, "c", Variant::COLOR, "a", Variant::FLOAT); - - _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3); - - _VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::FLOAT); - - _VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3); - - _VariantCall::add_constructor(_VariantCall::Callable_init2, Variant::CALLABLE, "object", Variant::OBJECT, "method_name", Variant::STRING_NAME); - _VariantCall::add_constructor(_VariantCall::Signal_init2, Variant::SIGNAL, "object", Variant::OBJECT, "signal_name", Variant::STRING_NAME); - - /* REGISTER CONSTANTS */ - - _populate_named_colors(); - for (Map::Element *color = _named_colors.front(); color; color = color->next()) { - _VariantCall::add_variant_constant(Variant::COLOR, _to_uppercase_name(color->key()), color->value()); - } - - _VariantCall::add_constant(Variant::VECTOR3, "AXIS_X", Vector3::AXIS_X); - _VariantCall::add_constant(Variant::VECTOR3, "AXIS_Y", Vector3::AXIS_Y); - _VariantCall::add_constant(Variant::VECTOR3, "AXIS_Z", Vector3::AXIS_Z); - - _VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math_INF, Math_INF, Math_INF)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "UP", Vector3(0, 1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "DOWN", Vector3(0, -1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "FORWARD", Vector3(0, 0, -1)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3(0, 0, 1)); - - _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_X", Vector3::AXIS_X); - _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_Y", Vector3::AXIS_Y); - _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_Z", Vector3::AXIS_Z); - - _VariantCall::add_variant_constant(Variant::VECTOR3I, "ZERO", Vector3i(0, 0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "ONE", Vector3i(1, 1, 1)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "LEFT", Vector3i(-1, 0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "RIGHT", Vector3i(1, 0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "UP", Vector3i(0, 1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "DOWN", Vector3i(0, -1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "FORWARD", Vector3i(0, 0, -1)); - _VariantCall::add_variant_constant(Variant::VECTOR3I, "BACK", Vector3i(0, 0, 1)); - - _VariantCall::add_constant(Variant::VECTOR2, "AXIS_X", Vector2::AXIS_X); - _VariantCall::add_constant(Variant::VECTOR2, "AXIS_Y", Vector2::AXIS_Y); - - _VariantCall::add_constant(Variant::VECTOR2I, "AXIS_X", Vector2::AXIS_X); - _VariantCall::add_constant(Variant::VECTOR2I, "AXIS_Y", Vector2::AXIS_Y); - - _VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math_INF, Math_INF)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2(0, -1)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "DOWN", Vector2(0, 1)); - - _VariantCall::add_variant_constant(Variant::VECTOR2I, "ZERO", Vector2i(0, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR2I, "ONE", Vector2i(1, 1)); - _VariantCall::add_variant_constant(Variant::VECTOR2I, "LEFT", Vector2i(-1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR2I, "RIGHT", Vector2i(1, 0)); - _VariantCall::add_variant_constant(Variant::VECTOR2I, "UP", Vector2i(0, -1)); - _VariantCall::add_variant_constant(Variant::VECTOR2I, "DOWN", Vector2i(0, 1)); - - _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "IDENTITY", Transform2D()); - _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0)); - _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0)); - - Transform identity_transform = Transform(); - Transform flip_x_transform = Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); - Transform flip_y_transform = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0); - Transform flip_z_transform = Transform(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0); - _VariantCall::add_variant_constant(Variant::TRANSFORM, "IDENTITY", identity_transform); - _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_X", flip_x_transform); - _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Y", flip_y_transform); - _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Z", flip_z_transform); - - Basis identity_basis = Basis(); - Basis flip_x_basis = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1); - Basis flip_y_basis = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1); - Basis flip_z_basis = Basis(1, 0, 0, 0, 1, 0, 0, 0, -1); - _VariantCall::add_variant_constant(Variant::BASIS, "IDENTITY", identity_basis); - _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_X", flip_x_basis); - _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_Y", flip_y_basis); - _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_Z", flip_z_basis); - - _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_YZ", Plane(Vector3(1, 0, 0), 0)); - _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XZ", Plane(Vector3(0, 1, 0), 0)); - _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XY", Plane(Vector3(0, 0, 1), 0)); - - _VariantCall::add_variant_constant(Variant::QUAT, "IDENTITY", Quat(0, 0, 0, 1)); -} - -void unregister_variant_methods() { - memdelete_arr(_VariantCall::type_funcs); - memdelete_arr(_VariantCall::construct_funcs); - memdelete_arr(_VariantCall::constant_data); -} From d2033a27e4ae71e46a7fa6e8484edee15e6a6293 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 15 Nov 2020 14:15:34 +0530 Subject: [PATCH 26/27] Remove to_lower transformation --- core/math/color.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/core/math/color.cpp b/core/math/color.cpp index 7df336f721f6..1fd1d467a0ab 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -364,7 +364,6 @@ Color Color::named(const String &p_name) { name = name.replace("_", ""); name = name.replace("'", ""); name = name.replace(".", ""); - name = name.to_lower(); name = _to_uppercase_color_name(name); int idx = 0; From acd7168169243d05d97c005a9acd1a8604d29923 Mon Sep 17 00:00:00 2001 From: Vivraan Date: Sun, 15 Nov 2020 14:32:39 +0530 Subject: [PATCH 27/27] Remove transformation code --- core/math/color.cpp | 4 +- .../color_uppercase_name_transformation.inc | 152 ------------------ 2 files changed, 1 insertion(+), 155 deletions(-) delete mode 100644 core/variant/color_uppercase_name_transformation.inc diff --git a/core/math/color.cpp b/core/math/color.cpp index 1fd1d467a0ab..2afe14bd6317 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -35,8 +35,6 @@ #include "core/string/print_string.h" #include "core/templates/map.h" -#include "color_uppercase_name_transformation.inc" - uint32_t Color::to_argb32() const { uint32_t c = (uint8_t)Math::round(a * 255); c <<= 8; @@ -364,7 +362,7 @@ Color Color::named(const String &p_name) { name = name.replace("_", ""); name = name.replace("'", ""); name = name.replace(".", ""); - name = _to_uppercase_color_name(name); + name = name.to_lower(); int idx = 0; while (named_colors[idx].name != nullptr) { diff --git a/core/variant/color_uppercase_name_transformation.inc b/core/variant/color_uppercase_name_transformation.inc deleted file mode 100644 index 49ab3a9e5eb6..000000000000 --- a/core/variant/color_uppercase_name_transformation.inc +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************/ -/* color_uppercase_name_transformation.inc */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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. */ -/*************************************************************************/ - -// Names from https://en.wikipedia.org/wiki/X11_color_names -// and https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1 -#include "core/string/ustring.h" -#include "core/templates/vector.h" - -static Vector _common_colors; -static Vector _common_color_adjectives; - -static void _populate_uppercase_token_lists() { - if (_common_colors.empty()) { - _common_colors.append("AQUAMARINE"); - _common_colors.append("BLACK"); - _common_colors.append("BLUE"); - _common_colors.append("BROWN"); - _common_colors.append("CORAL"); - _common_colors.append("CYAN"); - _common_colors.append("GRAY"); - _common_colors.append("GREEN"); - _common_colors.append("GOLDENROD"); - _common_colors.append("KHAKI"); - _common_colors.append("MAROON"); - _common_colors.append("ORANGE"); - _common_colors.append("ORCHID"); - _common_colors.append("PINK"); - _common_colors.append("PURPLE"); - _common_colors.append("RED"); - _common_colors.append("TURQUOISE"); - _common_colors.append("WHITE"); - _common_colors.append("YELLOW"); - } - - if (_common_color_adjectives.empty()) { - _common_color_adjectives.append("DARK"); - _common_color_adjectives.append("MEDIUM"); - _common_color_adjectives.append("LIGHT"); - _common_color_adjectives.append("PALE"); - _common_color_adjectives.append("SEA"); - _common_color_adjectives.append("SKY"); - _common_color_adjectives.append("SLATE"); - _common_color_adjectives.append("SPRING"); - _common_color_adjectives.append("STEEL"); - _common_color_adjectives.append("WEB"); - } -} - -static String _insert_underscores(const String &name, const Vector &tokens) { - String name_with_underscores(name); - - for (int i = 0; i < tokens.size(); ++i) { - const String &token = tokens[i]; - - // Skip the following steps if the word is the same as the whole name - if (token == name_with_underscores) { - continue; - } - - int begin = name_with_underscores.find(token, 0); - - // Skip the following steps if the word isn't found in the name - if (begin < 0) { - continue; - } - - int end = begin + token.length() - 1; - - // If the word isn't at the beginning - if (begin > 0) { - // If the letter before it isn't already an underscore - if (name_with_underscores[begin - 1] != '_') { - name_with_underscores = name_with_underscores.insert(begin, "_"); - } - } - - // If the word isn't at the end - if (end < name_with_underscores.length() - 2) { - // If the letter after it isn't already an underscore - if (name_with_underscores[end + 1] != '_') { - name_with_underscores = name_with_underscores.insert(end + 1, "_"); - } - } - } - - return name_with_underscores; -} - -static String _to_uppercase_color_name(const String &name) { - // Edge cases where the color names and their respective adjectives don't appear in the cached lists. - // These names are unique enough to warrant not caching them in the lists. - if (name == "blanchedalmond") { - return "BLANCHED_ALMOND"; - } else if (name == "burlywood") { - return "BURLY_WOOD"; - } else if (name == "deepskyblue") { - // This case behaves weirdly unless kept here since "DEEP" is not in the cached lists. - return "DEEP_SKY_BLUE"; - } else if (name == "lavenderblush") { - return "LAVENDER_BLUSH"; - } else if (name == "lemonchiffon") { - return "LEMON_CHIFFON"; - } else if (name == "mintcream") { - return "MINT_CREAM"; - } else if (name == "mistyrose") { - return "MISTY_ROSE"; - } else if (name == "oldlace") { - return "OLD_LACE"; - } else if (name == "olivedrab") { - return "OLIVE_DRAB"; - } else if (name == "papayawhip") { - return "PAPAYA_WHIP"; - } else if (name == "peachpuff") { - return "PEACH_PUFF"; - } else if (name == "seashell") { - return "SEA_SHELL"; - } - - // All other cases - _populate_uppercase_token_lists(); - String uppercase_name = name.to_upper(); - uppercase_name = _insert_underscores(uppercase_name, _common_colors); - uppercase_name = _insert_underscores(uppercase_name, _common_color_adjectives); - return uppercase_name; -}