Revert "[ion] Namespace Ion::UTF8Helper and Ion::UTF8Decoder"

This reverts commit 23da0d3f2c.
This commit is contained in:
Émilie Feral
2019-05-03 16:29:28 +02:00
parent 72d8fdd4a5
commit 8b926612a2
39 changed files with 129 additions and 145 deletions

View File

@@ -48,7 +48,7 @@ bool App::Snapshot::lockOnConsole() const {
void App::Snapshot::setOpt(const char * name, char * value) {
if (strcmp(name, "script") == 0) {
m_scriptStore.deleteAllScripts();
char * separator = const_cast<char *>(Ion::UTF8Helper::CodePointSearch(value, ':'));
char * separator = const_cast<char *>(UTF8Helper::CodePointSearch(value, ':'));
if (!separator) {
return;
}

View File

@@ -70,9 +70,9 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
/* If the cursor is on the left of the text of a line, backspace one
* indentation space at a time. */
const char * text = textArea->text();
const char * firstNonSpace = Ion::UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation());
const char * firstNonSpace = UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation());
assert(firstNonSpace >= text);
if (Ion::UTF8Helper::CodePointIs(firstNonSpace, '\n') && ((text - firstNonSpace)/Ion::UTF8Decoder::CharSizeOfCodePoint(' ')) >= k_indentationSpacesNumber) {
if (UTF8Helper::CodePointIs(firstNonSpace, '\n') && ((text - firstNonSpace)/UTF8Decoder::CharSizeOfCodePoint(' ')) >= k_indentationSpacesNumber) {
for (int i = 0; i < k_indentationSpacesNumber; i++) {
textArea->removeCodePoint();
}
@@ -82,10 +82,10 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
/* If the cursor is on the left of the text of a line, a space triggers an
* indentation. */
const char * text = textArea->text();
const char * firstNonSpace = Ion::UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation());
const char * firstNonSpace = UTF8Helper::NotCodePointSearch(text, ' ', true, textArea->cursorLocation());
assert(firstNonSpace >= text);
if (Ion::UTF8Helper::CodePointIs(firstNonSpace, '\n')) {
assert(Ion::UTF8Decoder::CharSizeOfCodePoint(' ') == 1);
if (UTF8Helper::CodePointIs(firstNonSpace, '\n')) {
assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1);
char indentationBuffer[k_indentationSpacesNumber+1];
for (int i = 0; i < k_indentationSpacesNumber; i++) {
indentationBuffer[i] = ' ';

View File

@@ -313,7 +313,7 @@ bool MenuController::textFieldDidFinishEditing(TextField * textField, const char
bool foundDefaultName = Script::DefaultName(numberedDefaultName, Script::k_defaultScriptNameMaxSize);
int defaultNameLength = strlen(numberedDefaultName);
assert(defaultNameLength < bufferSize);
assert(Ion::UTF8Decoder::CharSizeOfCodePoint('.') == 1);
assert(UTF8Decoder::CharSizeOfCodePoint('.') == 1);
numberedDefaultName[defaultNameLength++] = '.';
strlcpy(numberedDefaultName + defaultNameLength, ScriptStore::k_scriptExtension, bufferSize - defaultNameLength);
/* If there are already scripts named script1.py, script2.py,... until

View File

@@ -99,8 +99,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
LOG_DRAW("Drawing \"%.*s\"\n", byteLength, text);
if (!m_pythonDelegate->isPythonUser(this)) {
const char * lineStart = Ion::UTF8Helper::CodePointAtGlyphOffset(text, fromColumn);
const char * lineEnd = Ion::UTF8Helper::CodePointAtGlyphOffset(text, toColumn);
const char * lineStart = UTF8Helper::CodePointAtGlyphOffset(text, fromColumn);
const char * lineEnd = UTF8Helper::CodePointAtGlyphOffset(text, toColumn);
drawStringAt(
ctx,
line,
@@ -119,8 +119,8 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
* basis. This can work, however the MicroPython lexer won't accept a line
* starting with a whitespace. So we're discarding leading whitespaces
* beforehand. */
const char * firstNonSpace = Ion::UTF8Helper::NotCodePointSearch(text, ' ');
if (Ion::UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) {
const char * firstNonSpace = UTF8Helper::NotCodePointSearch(text, ' ');
if (UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) {
nlr_pop();
return;
}
@@ -136,7 +136,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
tokenLength = TokenLength(lex);
LOG_DRAW("Draw \"%.*s\" for token %d\n", tokenLength, tokenFrom, lex->tok_kind);
drawStringAt(ctx, line,
Ion::UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
tokenFrom,
tokenLength,
TokenColor(lex->tok_kind),
@@ -151,7 +151,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
if (tokenFrom < text + byteLength) {
LOG_DRAW("Draw comment \"%.*s\" from %d\n", byteLength - (tokenFrom - text), firstNonSpace, tokenFrom);
drawStringAt(ctx, line,
Ion::UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
tokenFrom,
text + byteLength - tokenFrom,
CommentColor,

View File

@@ -330,7 +330,7 @@ bool PythonToolbox::handleEvent(Ion::Events::Event event) {
}
if (event.hasText() && strlen(event.text()) == 1 ) {
char c = event.text()[0];
if (Ion::UTF8Helper::CodePointIsLetter(c)) {
if (UTF8Helper::CodePointIsLetter(c)) {
scrollToLetter(c);
return true;
}
@@ -390,7 +390,7 @@ int PythonToolbox::maxNumberOfDisplayedRows() {
}
void PythonToolbox::scrollToLetter(char letter) {
assert(Ion::UTF8Helper::CodePointIsLetter(letter));
assert(UTF8Helper::CodePointIsLetter(letter));
/* We look for a child MessageTree that starts with the wanted letter. If we
* do not find one, we scroll to the first child MessageTree that starts with
* a letter higher than the wanted letter. */
@@ -402,7 +402,7 @@ void PythonToolbox::scrollToLetter(char letter) {
index = i;
break;
}
if (index < 0 && l >= lowerLetter && Ion::UTF8Helper::CodePointIsLowerCaseLetter(l)) {
if (index < 0 && l >= lowerLetter && UTF8Helper::CodePointIsLowerCaseLetter(l)) {
index = i;
}
}

View File

@@ -46,9 +46,9 @@ bool Script::nameCompliant(const char * name) {
* We do not allow upper cases in the script names because script names are
* used in the URLs of the NumWorks workshop website and we do not want
* problems with case sensitivity. */
Ion::UTF8Decoder decoder(name);
UTF8Decoder decoder(name);
CodePoint c = decoder.nextCodePoint();
if (c == UCodePointNull || !(Ion::UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || c == '.')) {
if (c == UCodePointNull || !(UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || c == '.')) {
/* The name cannot be empty. Its first letter must be in [a-z_] or the
* extension dot. */
return false;
@@ -57,7 +57,7 @@ bool Script::nameCompliant(const char * name) {
if (c == '.' && strcmp(decoder.stringPosition(), ScriptStore::k_scriptExtension) == 0) {
return true;
}
if (!(Ion::UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || Ion::UTF8Helper::CodePointIsNumber(c))) {
if (!(UTF8Helper::CodePointIsLowerCaseLetter(c) || c == '_' || UTF8Helper::CodePointIsNumber(c))) {
return false;
}
c = decoder.nextCodePoint();

View File

@@ -41,7 +41,7 @@ static bool shouldAddObject(const char * name, int maxLength) {
return false;
}
assert(name != nullptr);
if (Ion::UTF8Helper::CodePointIs(name, '_')) {
if (UTF8Helper::CodePointIs(name, '_')) {
return false;
}
return true;