summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-02-24 17:00:40 +0100
committerRémi Verschelde <rverschelde@gmail.com>2020-02-25 15:27:29 +0100
commit6c8f2ae53a1921aa8589cf4da735f5cd443ff706 (patch)
treea3d444dd3179172a39d6d9759cfbbbdaf5d9e530 /core
parent2f237d181b6fd769b52bded49cafc9bc5eb9f087 (diff)
Update docs and bindings for new integer vector types
Diffstat (limited to 'core')
-rw-r--r--core/global_constants.cpp20
-rw-r--r--core/io/marshalls.cpp8
-rw-r--r--core/variant.h16
-rw-r--r--core/variant_call.cpp22
-rw-r--r--core/variant_op.cpp48
5 files changed, 56 insertions, 58 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 73db723c65..0945240c1f 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -92,9 +92,6 @@ VARIANT_ENUM_CAST(JoystickList);
VARIANT_ENUM_CAST(MidiMessageList);
void register_global_constants() {
-
- //{ KEY_BACKSPACE, VK_BACK },// (0x08) // backspace
-
BIND_GLOBAL_ENUM_CONSTANT(MARGIN_LEFT);
BIND_GLOBAL_ENUM_CONSTANT(MARGIN_TOP);
BIND_GLOBAL_ENUM_CONSTANT(MARGIN_RIGHT);
@@ -116,7 +113,7 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(VALIGN_CENTER);
BIND_GLOBAL_ENUM_CONSTANT(VALIGN_BOTTOM);
- // hueg list of keys
+ // huge list of keys
BIND_GLOBAL_CONSTANT(SPKEY);
BIND_GLOBAL_ENUM_CONSTANT(KEY_ESCAPE);
@@ -596,23 +593,26 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT", Variant::INT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL", Variant::FLOAT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING", Variant::STRING);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2", Variant::VECTOR2); // 5
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2", Variant::VECTOR2);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2I", Variant::VECTOR2I);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT2", Variant::RECT2);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT2I", Variant::RECT2I);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3", Variant::VECTOR3);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3I", Variant::VECTOR3I);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_NAME", Variant::STRING_NAME); // 15
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NODE_PATH", Variant::NODE_PATH); // 15
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_NAME", Variant::STRING_NAME);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NODE_PATH", Variant::NODE_PATH);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RID", Variant::_RID);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_OBJECT", Variant::OBJECT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_CALLABLE", Variant::CALLABLE);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_SIGNAL", Variant::SIGNAL);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY); // 20
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_ARRAY", Variant::ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RAW_ARRAY", Variant::PACKED_BYTE_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT32_ARRAY", Variant::PACKED_INT32_ARRAY);
@@ -620,7 +620,7 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_FLOAT32_ARRAY", Variant::PACKED_FLOAT32_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_FLOAT64_ARRAY", Variant::PACKED_FLOAT64_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_ARRAY", Variant::PACKED_STRING_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::PACKED_VECTOR2_ARRAY); // 25
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::PACKED_VECTOR2_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3_ARRAY", Variant::PACKED_VECTOR3_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR_ARRAY", Variant::PACKED_COLOR_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_MAX", Variant::VARIANT_MAX);
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 0b815b2c7b..fbcaa582b7 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -186,7 +186,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += 4 * 2;
- } break; // 5
+ } break;
case Variant::VECTOR2I: {
ERR_FAIL_COND_V(len < 4 * 2, ERR_INVALID_DATA);
@@ -198,7 +198,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += 4 * 2;
- } break; // 5
+ } break;
case Variant::RECT2: {
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
@@ -1058,7 +1058,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 2 * 4;
- } break; // 5
+ } break;
case Variant::VECTOR2I: {
if (buf) {
@@ -1069,7 +1069,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 2 * 4;
- } break; // 5
+ } break;
case Variant::RECT2: {
if (buf) {
diff --git a/core/variant.h b/core/variant.h
index 9ab25b9406..614d39e84a 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -78,7 +78,6 @@ class Variant {
public:
// If this changes the table in variant_op must be updated
enum Type {
-
NIL,
// atomic types
@@ -88,8 +87,7 @@ public:
STRING,
// math types
-
- VECTOR2, // 5
+ VECTOR2,
VECTOR2I,
RECT2,
RECT2I,
@@ -97,7 +95,7 @@ public:
VECTOR3I,
TRANSFORM2D,
PLANE,
- QUAT, // 10
+ QUAT,
AABB,
BASIS,
TRANSFORM,
@@ -105,26 +103,26 @@ public:
// misc types
COLOR,
STRING_NAME,
- NODE_PATH, // 15
+ NODE_PATH,
_RID,
OBJECT,
CALLABLE,
SIGNAL,
DICTIONARY,
ARRAY,
- // arrays
- PACKED_BYTE_ARRAY, // 20
+
+ // typed arrays
+ PACKED_BYTE_ARRAY,
PACKED_INT32_ARRAY,
PACKED_INT64_ARRAY,
PACKED_FLOAT32_ARRAY,
PACKED_FLOAT64_ARRAY,
PACKED_STRING_ARRAY,
PACKED_VECTOR2_ARRAY,
- PACKED_VECTOR3_ARRAY, // 25
+ PACKED_VECTOR3_ARRAY,
PACKED_COLOR_ARRAY,
VARIANT_MAX
-
};
private:
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index e82b491e4b..9cc08b54e6 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1291,14 +1291,14 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// math types
case VECTOR2:
- return Vector2(); // 5
+ return Vector2();
case RECT2: return Rect2();
case VECTOR3: return Vector3();
case TRANSFORM2D: return Transform2D();
case PLANE: return Plane();
case QUAT: return Quat();
case AABB:
- return ::AABB(); // 10
+ return ::AABB();
case BASIS: return Basis();
case TRANSFORM:
return Transform();
@@ -1306,16 +1306,16 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// misc types
case COLOR: return Color();
case STRING_NAME:
- return StringName(); // 15
+ return StringName();
case NODE_PATH:
- return NodePath(); // 15
+ return NodePath();
case _RID: return RID();
case OBJECT: return (Object *)NULL;
case CALLABLE: return Callable();
case SIGNAL: return Signal();
case DICTIONARY: return Dictionary();
case ARRAY:
- return Array(); // 20
+ return Array();
case PACKED_BYTE_ARRAY: return PackedByteArray();
case PACKED_INT32_ARRAY: return PackedInt32Array();
case PACKED_INT64_ARRAY: return PackedInt64Array();
@@ -1323,7 +1323,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case PACKED_FLOAT64_ARRAY: return PackedFloat64Array();
case PACKED_STRING_ARRAY: return PackedStringArray();
case PACKED_VECTOR2_ARRAY:
- return PackedVector2Array(); // 25
+ return PackedVector2Array();
case PACKED_VECTOR3_ARRAY: return PackedVector3Array();
case PACKED_COLOR_ARRAY: return PackedColorArray();
default: return Variant();
@@ -1364,7 +1364,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case PLANE: return (Plane(*p_args[0]));
case QUAT: return (p_args[0]->operator Quat());
case AABB:
- return (::AABB(*p_args[0])); // 10
+ return (::AABB(*p_args[0]));
case BASIS: return (Basis(p_args[0]->operator Basis()));
case TRANSFORM:
return (Transform(p_args[0]->operator Transform()));
@@ -1372,16 +1372,16 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// 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())); // 15
+ return (StringName(p_args[0]->operator StringName()));
case NODE_PATH:
- return (NodePath(p_args[0]->operator NodePath())); // 15
+ 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(); // 20
+ return p_args[0]->operator Array();
// arrays
case PACKED_BYTE_ARRAY: return (PackedByteArray(*p_args[0]));
@@ -1391,7 +1391,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
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])); // 25
+ 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();
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 8bdd8389dc..36d1278929 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1612,7 +1612,7 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
}
- } break; // 10
+ } break;
case AABB: {
if (p_value.type == Variant::VECTOR3) {
@@ -1870,7 +1870,7 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
return v->w;
}
- } break; // 10
+ } break;
case AABB: {
const ::AABB *v = _data._aabb;
@@ -2097,7 +2097,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
}
- } break; // 5
+ } break;
case VECTOR2I: {
if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
@@ -2132,7 +2132,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
}
- } break; // 5
+ } break;
case RECT2: {
if (p_value.type != Variant::VECTOR2)
@@ -2368,7 +2368,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
}
- } break; // 10
+ } break;
case AABB: {
if (p_value.type != Variant::VECTOR3)
@@ -2544,9 +2544,9 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case STRING_NAME: {
- } break; // 15
+ } break;
case NODE_PATH: {
- } break; // 15
+ } break;
case _RID: {
} break;
case OBJECT: {
@@ -2580,14 +2580,14 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
valid = true; //always valid, i guess? should this really be ok?
return;
} break;
- DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return ) // 20
+ DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return )
DEFAULT_OP_DVECTOR_SET(PACKED_BYTE_ARRAY, uint8_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
DEFAULT_OP_DVECTOR_SET(PACKED_INT32_ARRAY, int32_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
DEFAULT_OP_DVECTOR_SET(PACKED_INT64_ARRAY, int64_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
DEFAULT_OP_DVECTOR_SET(PACKED_FLOAT32_ARRAY, float, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
DEFAULT_OP_DVECTOR_SET(PACKED_FLOAT64_ARRAY, double, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
DEFAULT_OP_DVECTOR_SET(PACKED_STRING_ARRAY, String, p_value.type != Variant::STRING)
- DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25
+ DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2)
DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3)
DEFAULT_OP_DVECTOR_SET(PACKED_COLOR_ARRAY, Color, p_value.type != Variant::COLOR)
default:
@@ -2660,7 +2660,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
}
- } break; // 5
+ } break;
case VECTOR2I: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
@@ -2688,7 +2688,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
}
- } break; // 5
+ } break;
case RECT2: {
if (p_index.get_type() == Variant::STRING) {
@@ -2867,7 +2867,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
}
- } break; // 10
+ } break;
case AABB: {
if (p_index.get_type() == Variant::STRING) {
@@ -3000,9 +3000,9 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case STRING_NAME: {
- } break; // 15
+ } break;
case NODE_PATH: {
- } break; // 15
+ } break;
case _RID: {
} break;
case OBJECT: {
@@ -3034,14 +3034,14 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
return *res;
}
} break;
- DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) // 20
+ DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index])
DEFAULT_OP_DVECTOR_GET(PACKED_BYTE_ARRAY, uint8_t)
DEFAULT_OP_DVECTOR_GET(PACKED_INT32_ARRAY, int32_t)
DEFAULT_OP_DVECTOR_GET(PACKED_INT64_ARRAY, int64_t)
DEFAULT_OP_DVECTOR_GET(PACKED_FLOAT32_ARRAY, float)
DEFAULT_OP_DVECTOR_GET(PACKED_FLOAT64_ARRAY, double)
DEFAULT_OP_DVECTOR_GET(PACKED_STRING_ARRAY, String)
- DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR2_ARRAY, Vector2) // 25
+ DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR2_ARRAY, Vector2)
DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR3_ARRAY, Vector3)
DEFAULT_OP_DVECTOR_GET(PACKED_COLOR_ARRAY, Color)
default:
@@ -3103,7 +3103,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
return dic->has(p_index);
- } break; // 20
+ } break;
case ARRAY: {
const Array *arr = reinterpret_cast<const Array *>(_data._mem);
@@ -3302,13 +3302,13 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
- } break; // 5
+ } break;
case VECTOR2I: {
p_list->push_back(PropertyInfo(Variant::INT, "x"));
p_list->push_back(PropertyInfo(Variant::INT, "y"));
- } break; // 5
+ } break;
case RECT2: {
p_list->push_back(PropertyInfo(Variant::VECTOR2, "position"));
@@ -3360,7 +3360,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::FLOAT, "z"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "w"));
- } break; // 10
+ } break;
case AABB: {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "size"));
@@ -3394,9 +3394,9 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} break;
case STRING_NAME: {
- } break; // 15
+ } break;
case NODE_PATH: {
- } break; // 15
+ } break;
case _RID: {
} break;
case OBJECT: {
@@ -3427,14 +3427,14 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
}
}
} break;
- case ARRAY: // 20
+ case ARRAY:
case PACKED_BYTE_ARRAY:
case PACKED_INT32_ARRAY:
case PACKED_INT64_ARRAY:
case PACKED_FLOAT32_ARRAY:
case PACKED_FLOAT64_ARRAY:
case PACKED_STRING_ARRAY:
- case PACKED_VECTOR2_ARRAY: // 25
+ case PACKED_VECTOR2_ARRAY:
case PACKED_VECTOR3_ARRAY:
case PACKED_COLOR_ARRAY: {