mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 16:57:31 +01:00
[ion] Namespace Ion::UTF8Helper and Ion::UTF8Decoder
This commit is contained in:
@@ -17,9 +17,9 @@ constexpr char Function::k_parenthesedArgument[];
|
||||
bool Function::BaseNameCompliant(const char * baseName, NameNotCompliantError * error) {
|
||||
assert(baseName[0] != 0);
|
||||
|
||||
UTF8Decoder decoder(baseName);
|
||||
Ion::UTF8Decoder decoder(baseName);
|
||||
CodePoint c = decoder.nextCodePoint();
|
||||
if (UTF8Helper::CodePointIsNumber(c)) {
|
||||
if (Ion::UTF8Helper::CodePointIsNumber(c)) {
|
||||
// The name cannot start with a number
|
||||
if (error != nullptr) {
|
||||
*error = NameNotCompliantError::NameCannotStartWithNumber;
|
||||
@@ -29,9 +29,9 @@ bool Function::BaseNameCompliant(const char * baseName, NameNotCompliantError *
|
||||
|
||||
// The name should only have allowed characters
|
||||
while (c != UCodePointNull) {
|
||||
if (!(UTF8Helper::CodePointIsUpperCaseLetter(c)
|
||||
|| UTF8Helper::CodePointIsLowerCaseLetter(c)
|
||||
|| UTF8Helper::CodePointIsNumber(c))
|
||||
if (!(Ion::UTF8Helper::CodePointIsUpperCaseLetter(c)
|
||||
|| Ion::UTF8Helper::CodePointIsLowerCaseLetter(c)
|
||||
|| Ion::UTF8Helper::CodePointIsNumber(c))
|
||||
|| c == '_')
|
||||
{
|
||||
if (error != nullptr) {
|
||||
@@ -65,13 +65,13 @@ void Function::setActive(bool active) {
|
||||
}
|
||||
|
||||
int Function::nameWithArgument(char * buffer, size_t bufferSize, CodePoint arg) {
|
||||
assert(UTF8Decoder::CharSizeOfCodePoint(arg) == 1);
|
||||
assert(Ion::UTF8Decoder::CharSizeOfCodePoint(arg) == 1);
|
||||
const char * functionName = fullName();
|
||||
size_t baseNameLength = SymbolAbstract::TruncateExtension(buffer, functionName, bufferSize - k_parenthesedArgumentLength);
|
||||
int result = baseNameLength + strlcpy(&buffer[baseNameLength], k_parenthesedArgument, bufferSize-baseNameLength);
|
||||
int bufferRemainingSize = bufferSize - (baseNameLength+1);
|
||||
if (bufferRemainingSize > 0) {
|
||||
UTF8Decoder::CodePointToChars(arg, buffer+baseNameLength+1, bufferRemainingSize);
|
||||
Ion::UTF8Decoder::CodePointToChars(arg, buffer+baseNameLength+1, bufferRemainingSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user