mirror of
https://github.com/godotengine/godot
synced 2024-09-04 22:48:26 +00:00
Add test to check for :: in enum/constant bindings
Since class scoping should not be used for bindings as they might have uninteded consequences in scripting.
This commit is contained in:
parent
0525467fbc
commit
c2b43839ce
|
@ -754,6 +754,9 @@ void add_exposed_classes(Context &r_context) {
|
||||||
const List<StringName> &enum_constants = enum_map.get(*k);
|
const List<StringName> &enum_constants = enum_map.get(*k);
|
||||||
for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) {
|
for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) {
|
||||||
const StringName &constant_name = E->get();
|
const StringName &constant_name = E->get();
|
||||||
|
TEST_FAIL_COND(String(constant_name).find("::") != -1,
|
||||||
|
"Enum constant contains '::', check bindings to remove the scope: '",
|
||||||
|
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
|
||||||
int *value = class_info->constant_map.getptr(constant_name);
|
int *value = class_info->constant_map.getptr(constant_name);
|
||||||
TEST_FAIL_COND(!value, "Missing enum constant value: '",
|
TEST_FAIL_COND(!value, "Missing enum constant value: '",
|
||||||
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
|
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
|
||||||
|
@ -773,8 +776,11 @@ void add_exposed_classes(Context &r_context) {
|
||||||
|
|
||||||
for (const List<String>::Element *E = constants.front(); E; E = E->next()) {
|
for (const List<String>::Element *E = constants.front(); E; E = E->next()) {
|
||||||
const String &constant_name = E->get();
|
const String &constant_name = E->get();
|
||||||
|
TEST_FAIL_COND(constant_name.find("::") != -1,
|
||||||
|
"Constant contains '::', check bindings to remove the scope: '",
|
||||||
|
String(class_name), ".", constant_name, "'.");
|
||||||
int *value = class_info->constant_map.getptr(StringName(E->get()));
|
int *value = class_info->constant_map.getptr(StringName(E->get()));
|
||||||
TEST_FAIL_COND(!value, "Missing enum constant value: '", String(class_name), ".", String(constant_name), "'.");
|
TEST_FAIL_COND(!value, "Missing constant value: '", String(class_name), ".", String(constant_name), "'.");
|
||||||
|
|
||||||
ConstantData constant;
|
ConstantData constant;
|
||||||
constant.name = constant_name;
|
constant.name = constant_name;
|
||||||
|
|
Loading…
Reference in a new issue