Commit c67ba8bd authored by coppro's avatar coppro

Rename 'cannocial_name_form' to 'canonical_name_form'

parent b0598130
...@@ -50,7 +50,7 @@ IMPLEMENT_REFLECTION(Field) { ...@@ -50,7 +50,7 @@ IMPLEMENT_REFLECTION(Field) {
REFLECT(type); REFLECT(type);
} }
REFLECT(name); REFLECT(name);
REFLECT_IF_READING name = cannocial_name_form(name); REFLECT_IF_READING name = canonical_name_form(name);
REFLECT(description); REFLECT(description);
REFLECT_N("icon", icon_filename); REFLECT_N("icon", icon_filename);
REFLECT(editable); REFLECT(editable);
......
...@@ -46,7 +46,7 @@ ChoiceThumbnailRequest::ChoiceThumbnailRequest(ValueViewer* viewer, int id, bool ...@@ -46,7 +46,7 @@ ChoiceThumbnailRequest::ChoiceThumbnailRequest(ValueViewer* viewer, int id, bool
Image ChoiceThumbnailRequest::generate() { Image ChoiceThumbnailRequest::generate() {
ChoiceStyle& s = style(); ChoiceStyle& s = style();
String name = cannocial_name_form(s.field().choices->choiceName(id)); String name = canonical_name_form(s.field().choices->choiceName(id));
ScriptableImage& img = s.choice_images[name]; ScriptableImage& img = s.choice_images[name];
return img.isReady() return img.isReady()
? img.generate(GeneratedImage::Options(16,16, &viewer().getStylePackage(), &viewer().getLocalPackage(), ASPECT_BORDER, true)) ? img.generate(GeneratedImage::Options(16,16, &viewer().getStylePackage(), &viewer().getLocalPackage(), ASPECT_BORDER, true))
...@@ -181,7 +181,7 @@ void DropDownChoiceListBase::generateThumbnailImages() { ...@@ -181,7 +181,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
if (style().choice_images.empty() && style().image.isScripted()) { if (style().choice_images.empty() && style().image.isScripted()) {
for (int i = 0 ; i < end ; ++i) { for (int i = 0 ; i < end ; ++i) {
try { try {
String name = cannocial_name_form(field().choices->choiceName(i)); String name = canonical_name_form(field().choices->choiceName(i));
ctx.setVariable(_("input"), to_script(name)); ctx.setVariable(_("input"), to_script(name));
GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx)); GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx));
style().choice_images.insert(make_pair(name, ScriptableImage(img))); style().choice_images.insert(make_pair(name, ScriptableImage(img)));
...@@ -197,7 +197,7 @@ void DropDownChoiceListBase::generateThumbnailImages() { ...@@ -197,7 +197,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
if (i >= image_count || status != THUMB_OK) { if (i >= image_count || status != THUMB_OK) {
// update image // update image
ChoiceStyle& s = style(); ChoiceStyle& s = style();
String name = cannocial_name_form(s.field().choices->choiceName(i)); String name = canonical_name_form(s.field().choices->choiceName(i));
ScriptableImage& img = s.choice_images[name]; ScriptableImage& img = s.choice_images[name];
if (!img.update(ctx) && status == THUMB_CHANGED) { if (!img.update(ctx) && status == THUMB_CHANGED) {
status = THUMB_OK; // no need to rebuild status = THUMB_OK; // no need to rebuild
......
...@@ -58,7 +58,7 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const ...@@ -58,7 +58,7 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
size = add_horizontal(size, RealSize(14,16)); size = add_horizontal(size, RealSize(14,16));
} }
if (style().render_style & RENDER_IMAGE) { if (style().render_style & RENDER_IMAGE) {
map<String,ScriptableImage>::iterator it = style().choice_images.find(cannocial_name_form(choice)); map<String,ScriptableImage>::iterator it = style().choice_images.find(canonical_name_form(choice));
if (it != style().choice_images.end() && it->second.isReady()) { if (it != style().choice_images.end() && it->second.isReady()) {
// TODO: caching // TODO: caching
GeneratedImage::Options options(0,0, &getStylePackage(), &getLocalPackage()); GeneratedImage::Options options(0,0, &getStylePackage(), &getLocalPackage());
......
This diff is collapsed.
...@@ -210,7 +210,7 @@ void TokenIterator::readToken() { ...@@ -210,7 +210,7 @@ void TokenIterator::readToken() {
// name, or a number after a . token, as in array.0 // name, or a number after a . token, as in array.0
size_t start = pos - 1; size_t start = pos - 1;
while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos; while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos;
addToken(TOK_NAME, cannocial_name_form(input.substr(start, pos-start)), start); // convert name to cannocial form addToken(TOK_NAME, canonical_name_form(input.substr(start, pos-start)), start); // convert name to cannocial form
} else if (isDigit(c)) { } else if (isDigit(c)) {
// number // number
size_t start = pos - 1; size_t start = pos - 1;
......
...@@ -27,7 +27,7 @@ Variable string_to_variable(const String& s) { ...@@ -27,7 +27,7 @@ Variable string_to_variable(const String& s) {
if (it == variables.end()) { if (it == variables.end()) {
#ifdef _DEBUG #ifdef _DEBUG
variable_names.push_back(s); variable_names.push_back(s);
assert(s == cannocial_name_form(s)); // only use cannocial names assert(s == canonical_name_form(s)); // only use cannocial names
#endif #endif
Variable v = (Variable)variables.size(); Variable v = (Variable)variables.size();
variables.insert(make_pair(s,v)); variables.insert(make_pair(s,v));
......
...@@ -257,7 +257,7 @@ void Reader::readLine(bool in_string) { ...@@ -257,7 +257,7 @@ void Reader::readLine(bool in_string) {
indent += 1; indent += 1;
} }
} }
key = cannocial_name_form(trim(key)); key = canonical_name_form(trim(key));
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1)); value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
if (key.empty() && pos!=String::npos) key = _(" "); // we don't want an empty key if there was a colon if (key.empty() && pos!=String::npos) key = _(" "); // we don't want an empty key if there was a colon
} }
......
...@@ -51,7 +51,7 @@ void Writer::writePending() { ...@@ -51,7 +51,7 @@ void Writer::writePending() {
} }
indentation += 1; indentation += 1;
writeIndentation(); writeIndentation();
writeUTF8(stream, cannocial_name_form(pending_opened[i])); writeUTF8(stream, canonical_name_form(pending_opened[i]));
} }
pending_opened.clear(); pending_opened.clear();
} }
......
...@@ -178,7 +178,7 @@ String capitalize_sentence(const String& s) { ...@@ -178,7 +178,7 @@ String capitalize_sentence(const String& s) {
return ret; return ret;
} }
String cannocial_name_form(const String& str) { String canonical_name_form(const String& str) {
String ret; String ret;
ret.reserve(str.size()); ret.reserve(str.size());
bool leading = true; bool leading = true;
......
...@@ -152,12 +152,12 @@ String capitalize(const String&); ...@@ -152,12 +152,12 @@ String capitalize(const String&);
/** for use in dialogs */ /** for use in dialogs */
String capitalize_sentence(const String&); String capitalize_sentence(const String&);
/// Convert a field name to cannocial form /// Convert a field name to canonical form
/** - lower case and ' ' instead of '_'. /** - lower case and ' ' instead of '_'.
* - non alphanumeric characters are droped * - non alphanumeric characters are droped
* - "camalCase" is converted to words "camel case" (TODO) * - "camalCase" is converted to words "camel case" (TODO)
*/ */
String cannocial_name_form(const String&); String canonical_name_form(const String&);
/// Returns the singular form of a string /// Returns the singular form of a string
/** Used for reflection, for example "vector<T> apples" is written with keys /** Used for reflection, for example "vector<T> apples" is written with keys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment