summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-02-24 15:20:53 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-25 12:55:53 +0100
commit33b5c571995cce60a21784ac33fcf958640ed1e2 (patch)
treeb6f087b46a88fe8e2bac093c521da829108714f5 /modules/gdscript
parentc19488bd895f911f37bf2c03624d05ea8d0ec1ee (diff)
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array. - Renames PackedFloatArray to PackedFloat32Array. - Adds PackedInt64Array and PackedFloat64Array. - Renames Variant::REAL to Variant::FLOAT for consistency. Packed arrays are for storing large amount of data and creating stuff like meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of memory. That said, many users requested the ability to have 64 bits packed arrays for their games, so this is just an optional added type. For Variant, the float datatype is always 64 bits, and exposed as `float`. We still have `real_t` which is the datatype that can change from 32 to 64 bits depending on a compile flag (not entirely working right now, but that's the idea). It affects math related datatypes and code only. Neither Variant nor PackedArray make use of real_t, which is only intended for math precision, so the term is removed from there to keep only float.
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript_editor.cpp4
-rw-r--r--modules/gdscript/gdscript_functions.cpp204
-rw-r--r--modules/gdscript/gdscript_parser.cpp42
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp8
4 files changed, 138 insertions, 120 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index bc3f66719f..85265a1fe5 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -1124,7 +1124,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
v2 = 1;
v2_use_value = false;
}
- if (vop == Variant::OP_DIVIDE && v2.get_type() == Variant::REAL) {
+ if (vop == Variant::OP_DIVIDE && v2.get_type() == Variant::FLOAT) {
v2 = 1.0;
v2_use_value = false;
}
@@ -2173,7 +2173,7 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
static const char *_type_names[Variant::VARIANT_MAX] = {
"null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform",
- "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "PackedByteArray", "PackedIntArray", "PackedRealArray", "PackedStringArray",
+ "Color", "NodePath", "RID", "Object", "Callable", "Signal", "Dictionary", "Array", "PackedByteArray", "PackedInt32Array", "PackedInt64Array", "PackedFloat32Array", "PackedFloat64Array", "PackedStringArray",
"PackedVector2Array", "PackedVector3Array", "PackedColorArray"
};
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 426b5b58cb..aaa308f40f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -162,7 +162,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (!p_args[m_arg]->is_num()) { \
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; \
r_error.argument = m_arg; \
- r_error.expected = Variant::REAL; \
+ r_error.expected = Variant::FLOAT; \
r_ret = Variant(); \
return; \
}
@@ -272,7 +272,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
int64_t i = *p_args[0];
r_ret = ABS(i);
- } else if (p_args[0]->get_type() == Variant::REAL) {
+ } else if (p_args[0]->get_type() == Variant::FLOAT) {
double r = *p_args[0];
r_ret = Math::abs(r);
@@ -280,7 +280,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
r_ret = Variant();
}
} break;
@@ -290,7 +290,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
int64_t i = *p_args[0];
r_ret = i < 0 ? -1 : (i > 0 ? +1 : 0);
- } else if (p_args[0]->get_type() == Variant::REAL) {
+ } else if (p_args[0]->get_type() == Variant::FLOAT) {
real_t r = *p_args[0];
r_ret = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
@@ -298,7 +298,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
r_ret = Variant();
}
} break;
@@ -360,7 +360,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(2);
const double t = (double)*p_args[2];
- switch (p_args[0]->get_type() == p_args[1]->get_type() ? p_args[0]->get_type() : Variant::REAL) {
+ switch (p_args[0]->get_type() == p_args[1]->get_type() ? p_args[0]->get_type() : Variant::FLOAT) {
case Variant::VECTOR2: {
r_ret = ((Vector2)*p_args[0]).linear_interpolate((Vector2)*p_args[1], t);
} break;
@@ -1359,7 +1359,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case INSTANCE_FROM_ID: {
VALIDATE_ARG_COUNT(1);
- if (p_args[0]->get_type() != Variant::INT && p_args[0]->get_type() != Variant::REAL) {
+ if (p_args[0]->get_type() != Variant::INT && p_args[0]->get_type() != Variant::FLOAT) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::INT;
@@ -1395,14 +1395,24 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Vector<uint8_t> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::PACKED_INT_ARRAY: {
+ case Variant::PACKED_INT32_ARRAY: {
- Vector<int> d = *p_args[0];
+ Vector<int32_t> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::PACKED_REAL_ARRAY: {
+ case Variant::PACKED_INT64_ARRAY: {
- Vector<real_t> d = *p_args[0];
+ Vector<int64_t> d = *p_args[0];
+ r_ret = d.size();
+ } break;
+ case Variant::PACKED_FLOAT32_ARRAY: {
+
+ Vector<float> d = *p_args[0];
+ r_ret = d.size();
+ } break;
+ case Variant::PACKED_FLOAT64_ARRAY: {
+
+ Vector<double> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_STRING_ARRAY: {
@@ -1530,69 +1540,69 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
switch (p_func) {
case MATH_SIN: {
- MethodInfo mi("sin", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sin", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_COS: {
- MethodInfo mi("cos", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("cos", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_TAN: {
- MethodInfo mi("tan", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("tan", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SINH: {
- MethodInfo mi("sinh", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sinh", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_COSH: {
- MethodInfo mi("cosh", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("cosh", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_TANH: {
- MethodInfo mi("tanh", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("tanh", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ASIN: {
- MethodInfo mi("asin", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("asin", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ACOS: {
- MethodInfo mi("acos", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("acos", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ATAN: {
- MethodInfo mi("atan", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("atan", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ATAN2: {
- MethodInfo mi("atan2", PropertyInfo(Variant::REAL, "y"), PropertyInfo(Variant::REAL, "x"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("atan2", PropertyInfo(Variant::FLOAT, "y"), PropertyInfo(Variant::FLOAT, "x"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SQRT: {
- MethodInfo mi("sqrt", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sqrt", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_FMOD: {
- MethodInfo mi("fmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("fmod", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_FPOSMOD: {
- MethodInfo mi("fposmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("fposmod", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_POSMOD: {
@@ -1601,114 +1611,114 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_FLOOR: {
- MethodInfo mi("floor", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("floor", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_CEIL: {
- MethodInfo mi("ceil", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("ceil", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ROUND: {
- MethodInfo mi("round", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("round", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ABS: {
- MethodInfo mi("abs", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("abs", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SIGN: {
- MethodInfo mi("sign", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sign", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_POW: {
- MethodInfo mi("pow", PropertyInfo(Variant::REAL, "base"), PropertyInfo(Variant::REAL, "exp"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("pow", PropertyInfo(Variant::FLOAT, "base"), PropertyInfo(Variant::FLOAT, "exp"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_LOG: {
- MethodInfo mi("log", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("log", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_EXP: {
- MethodInfo mi("exp", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("exp", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ISNAN: {
- MethodInfo mi("is_nan", PropertyInfo(Variant::REAL, "s"));
+ MethodInfo mi("is_nan", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_ISINF: {
- MethodInfo mi("is_inf", PropertyInfo(Variant::REAL, "s"));
+ MethodInfo mi("is_inf", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_ISEQUALAPPROX: {
- MethodInfo mi("is_equal_approx", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
+ MethodInfo mi("is_equal_approx", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_ISZEROAPPROX: {
- MethodInfo mi("is_zero_approx", PropertyInfo(Variant::REAL, "s"));
+ MethodInfo mi("is_zero_approx", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_EASE: {
- MethodInfo mi("ease", PropertyInfo(Variant::REAL, "s"), PropertyInfo(Variant::REAL, "curve"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("ease", PropertyInfo(Variant::FLOAT, "s"), PropertyInfo(Variant::FLOAT, "curve"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_STEP_DECIMALS: {
- MethodInfo mi("step_decimals", PropertyInfo(Variant::REAL, "step"));
+ MethodInfo mi("step_decimals", PropertyInfo(Variant::FLOAT, "step"));
mi.return_val.type = Variant::INT;
return mi;
} break;
case MATH_STEPIFY: {
- MethodInfo mi("stepify", PropertyInfo(Variant::REAL, "s"), PropertyInfo(Variant::REAL, "step"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("stepify", PropertyInfo(Variant::FLOAT, "s"), PropertyInfo(Variant::FLOAT, "step"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_LERP: {
- MethodInfo mi("lerp", PropertyInfo(Variant::NIL, "from"), PropertyInfo(Variant::NIL, "to"), PropertyInfo(Variant::REAL, "weight"));
+ MethodInfo mi("lerp", PropertyInfo(Variant::NIL, "from"), PropertyInfo(Variant::NIL, "to"), PropertyInfo(Variant::FLOAT, "weight"));
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case MATH_LERP_ANGLE: {
- MethodInfo mi("lerp_angle", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("lerp_angle", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "weight"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_INVERSE_LERP: {
- MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "weight"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RANGE_LERP: {
- MethodInfo mi("range_lerp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "istart"), PropertyInfo(Variant::REAL, "istop"), PropertyInfo(Variant::REAL, "ostart"), PropertyInfo(Variant::REAL, "ostop"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("range_lerp", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "istart"), PropertyInfo(Variant::FLOAT, "istop"), PropertyInfo(Variant::FLOAT, "ostart"), PropertyInfo(Variant::FLOAT, "ostop"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SMOOTHSTEP: {
- MethodInfo mi("smoothstep", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("smoothstep", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "weight"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_MOVE_TOWARD: {
- MethodInfo mi("move_toward", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "delta"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("move_toward", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "delta"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_DECTIME: {
- MethodInfo mi("dectime", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "amount"), PropertyInfo(Variant::REAL, "step"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("dectime", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "amount"), PropertyInfo(Variant::FLOAT, "step"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RANDOMIZE: {
@@ -1723,12 +1733,12 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case MATH_RANDF: {
MethodInfo mi("randf");
- mi.return_val.type = Variant::REAL;
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RANDOM: {
- MethodInfo mi("rand_range", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("rand_range", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SEED: {
@@ -1742,32 +1752,32 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_DEG2RAD: {
- MethodInfo mi("deg2rad", PropertyInfo(Variant::REAL, "deg"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("deg2rad", PropertyInfo(Variant::FLOAT, "deg"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RAD2DEG: {
- MethodInfo mi("rad2deg", PropertyInfo(Variant::REAL, "rad"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("rad2deg", PropertyInfo(Variant::FLOAT, "rad"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_LINEAR2DB: {
- MethodInfo mi("linear2db", PropertyInfo(Variant::REAL, "nrg"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("linear2db", PropertyInfo(Variant::FLOAT, "nrg"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_DB2LINEAR: {
- MethodInfo mi("db2linear", PropertyInfo(Variant::REAL, "db"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("db2linear", PropertyInfo(Variant::FLOAT, "db"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_POLAR2CARTESIAN: {
- MethodInfo mi("polar2cartesian", PropertyInfo(Variant::REAL, "r"), PropertyInfo(Variant::REAL, "th"));
+ MethodInfo mi("polar2cartesian", PropertyInfo(Variant::FLOAT, "r"), PropertyInfo(Variant::FLOAT, "th"));
mi.return_val.type = Variant::VECTOR2;
return mi;
} break;
case MATH_CARTESIAN2POLAR: {
- MethodInfo mi("cartesian2polar", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y"));
+ MethodInfo mi("cartesian2polar", PropertyInfo(Variant::FLOAT, "x"), PropertyInfo(Variant::FLOAT, "y"));
mi.return_val.type = Variant::VECTOR2;
return mi;
} break;
@@ -1777,24 +1787,24 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_WRAPF: {
- MethodInfo mi("wrapf", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("wrapf", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "min"), PropertyInfo(Variant::FLOAT, "max"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_MAX: {
- MethodInfo mi("max", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("max", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_MIN: {
- MethodInfo mi("min", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("min", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_CLAMP: {
- MethodInfo mi("clamp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("clamp", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "min"), PropertyInfo(Variant::FLOAT, "max"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_NEAREST_PO2: {
@@ -2012,7 +2022,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case COLORN: {
- MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::REAL, "alpha"));
+ MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::FLOAT, "alpha"));
mi.default_arguments.push_back(1.0f);
mi.return_val.type = Variant::COLOR;
return mi;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 842ce6c1c1..0382944efd 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3108,7 +3108,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
args.push_back(op->arguments[i]);
if (constant && op->arguments[i]->type == Node::TYPE_CONSTANT) {
ConstantNode *c = static_cast<ConstantNode *>(op->arguments[i]);
- if (c->value.get_type() == Variant::REAL || c->value.get_type() == Variant::INT) {
+ if (c->value.get_type() == Variant::FLOAT || c->value.get_type() == Variant::INT) {
constants.push_back(c->value);
constant = true;
}
@@ -4222,7 +4222,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
[[fallthrough]];
}
- case Variant::REAL: {
+ case Variant::FLOAT: {
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
current_export.hint = PROPERTY_HINT_EXP_EASING;
@@ -5955,10 +5955,10 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper
}
// Avoid division by zero
- if (a_type == Variant::INT || a_type == Variant::REAL) {
+ if (a_type == Variant::INT || a_type == Variant::FLOAT) {
Variant::evaluate(Variant::OP_ADD, a, 1, a, r_valid);
}
- if (b_type == Variant::INT || b_type == Variant::REAL) {
+ if (b_type == Variant::INT || b_type == Variant::FLOAT) {
Variant::evaluate(Variant::OP_ADD, b, 1, b, r_valid);
}
if (a_type == Variant::STRING && b_type != Variant::ARRAY) {
@@ -6598,14 +6598,16 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
// Expect int or real as index
case Variant::PACKED_BYTE_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
- case Variant::PACKED_INT_ARRAY:
- case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::ARRAY:
case Variant::STRING: {
- error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::REAL;
+ error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::FLOAT;
} break;
// Expect String only
case Variant::RECT2:
@@ -6621,7 +6623,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM: {
- error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::REAL &&
+ error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::FLOAT &&
index_type.builtin_type != Variant::STRING;
} break;
// Expect String or int
@@ -6648,8 +6650,10 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::DICTIONARY:
case Variant::PACKED_BYTE_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
- case Variant::PACKED_INT_ARRAY:
- case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY: {
@@ -6691,7 +6695,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::NIL:
case Variant::BOOL:
case Variant::INT:
- case Variant::REAL:
+ case Variant::FLOAT:
case Variant::NODE_PATH:
case Variant::_RID: {
_set_error("Can't index on a value of type \"" + base_type.to_string() + "\".", op->line);
@@ -6699,15 +6703,17 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
} break;
// Return int
case Variant::PACKED_BYTE_ARRAY:
- case Variant::PACKED_INT_ARRAY: {
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY: {
result.builtin_type = Variant::INT;
} break;
// Return real
- case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
case Variant::VECTOR2:
case Variant::VECTOR3:
case Variant::QUAT: {
- result.builtin_type = Variant::REAL;
+ result.builtin_type = Variant::FLOAT;
} break;
// Return color
case Variant::PACKED_COLOR_ARRAY: {
@@ -7002,7 +7008,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
break;
} else {
#ifdef DEBUG_ENABLED
- if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_types[i].kind == DataType::BUILTIN && par_types[i].builtin_type == Variant::REAL) {
+ if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_types[i].kind == DataType::BUILTIN && par_types[i].builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, p_call->line, Variant::get_type_name(tn->vtype));
}
if (par_types[i].may_yield && p_call->arguments[i + 1]->type == Node::TYPE_OPERATOR) {
@@ -7245,7 +7251,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
_mark_line_as_unsafe(p_call->line);
}
} else {
- if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_type.kind == DataType::BUILTIN && par_type.builtin_type == Variant::REAL) {
+ if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_type.kind == DataType::BUILTIN && par_type.builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, p_call->line, callee_name);
}
}
@@ -8103,7 +8109,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
lv->assign = convert_call;
lv->assign_op->arguments.write[1] = convert_call;
#ifdef DEBUG_ENABLED
- if (lv->datatype.builtin_type == Variant::INT && assign_type.builtin_type == Variant::REAL) {
+ if (lv->datatype.builtin_type == Variant::INT && assign_type.builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, lv->line);
}
#endif // DEBUG_ENABLED
@@ -8240,7 +8246,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
type_match = true; // Since we are converting, the type is matching
}
#ifdef DEBUG_ENABLED
- if (lh_type.builtin_type == Variant::INT && rh_type.builtin_type == Variant::REAL) {
+ if (lh_type.builtin_type == Variant::INT && rh_type.builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, op->line);
}
#endif // DEBUG_ENABLED
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 818033025e..9064998d32 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -146,7 +146,7 @@ static const _bit _type_list[] = {
//types
{ Variant::BOOL, "bool" },
{ Variant::INT, "int" },
- { Variant::REAL, "float" },
+ { Variant::FLOAT, "float" },
{ Variant::STRING, "String" },
{ Variant::VECTOR2, "Vector2" },
{ Variant::VECTOR2I, "Vector2i" },
@@ -170,8 +170,10 @@ static const _bit _type_list[] = {
{ Variant::SIGNAL, "Signal" },
{ Variant::ARRAY, "Array" },
{ Variant::PACKED_BYTE_ARRAY, "PackedByteArray" },
- { Variant::PACKED_INT_ARRAY, "PackedIntArray" },
- { Variant::PACKED_REAL_ARRAY, "PackedRealArray" },
+ { Variant::PACKED_INT32_ARRAY, "PackedInt32Array" },
+ { Variant::PACKED_INT64_ARRAY, "PackedInt64Array" },
+ { Variant::PACKED_FLOAT32_ARRAY, "PackedFloat32Array" },
+ { Variant::PACKED_FLOAT64_ARRAY, "PackedFloat64Array" },
{ Variant::PACKED_STRING_ARRAY, "PackedStringArray" },
{ Variant::PACKED_VECTOR2_ARRAY, "PackedVector2Array" },
{ Variant::PACKED_VECTOR3_ARRAY, "PackedVector3Array" },