Use underscores instead of spaces for all internal names. And renamed some script functions at the same time.

* cannocial_name_form now outputs "_", where it used to use " "
* this simplifies reflectio and scripting code, because now C++ names are also MSE internal names
* added 'caption' property to fields. This is used instead of the name in NativeLookEditor, since the latter will now contain underscores.
* renamed text related script functions for consistency, since we were touching that part of the code anyway.
This commit is contained in:
Twan van Laarhoven
2020-04-22 23:33:06 +02:00
parent be4bb8d8ed
commit 713a9e4a40
33 changed files with 240 additions and 197 deletions
+35 -9
View File
@@ -168,22 +168,47 @@ String capitalize_sentence(const String& s) {
return ret;
}
wxUniChar canonical_name_form(wxUniChar c) {
if (c == _(' ')) return _('_');
return c;
}
String canonical_name_form(const String& str) {
String ret;
ret.reserve(str.size());
bool leading = true;
FOR_EACH_CONST(c, str) {
ret += canonical_name_form(c);
}
return ret;
}
wxUniChar uncanonical_name_form(wxUniChar c) {
if (c == _('_')) return _(' ');
return c;
}
String uncanonical_name_form(const String& str) {
String ret;
ret.reserve(str.size());
FOR_EACH_CONST(c, str) {
ret += uncanonical_name_form(c);
}
return ret;
}
String name_to_caption(const String& str) {
String ret;
ret.reserve(str.size());
bool leading = true, first = true;
FOR_EACH_CONST(c, str) {
if ((c == _('_') || c == _(' '))) {
ret += leading ? c : wxUniChar(' ');
ret += leading ? c : _(' ');
} else if (first) {
// capitalize_sentence
ret += toUpper(c);
leading = false;
first = false;
} else {
ret += c;
leading = false;
/*
} else if (isAlnum(c) || c == _('-')) {
ret += toLower(c);
leading = false;
} else {
// ignore non alpha numeric*/
}
}
return ret;
@@ -392,9 +417,10 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp) {
}
bool canonical_name_compare(const String& as, const Char* b) {
assert(canonical_name_form(b) == b);
const Char* a = as.c_str();
while (true) {
if (*a != *b && !(*a == _(' ') && *b == _('_'))) return false;
if (*a != *b && !(*a == _('_') && *b == _(' '))) return false;
if (*a == _('\0')) return true;
a++; b++;
}