Skip to content
Permalink
Browse files

- added CharUpper and CharLower functions to ZScript.

These, like MakeUpper and MakeLower, use the internal Unicode case conversion tables.
  • Loading branch information...
coelckers committed Apr 13, 2019
1 parent f7561f2 commit 393811919287d1e306a8b2aece4c0ba6f4402b22
Showing with 28 additions and 0 deletions.
  1. +26 −0 src/scripting/vmthunks.cpp
  2. +2 −0 wadsrc/static/zscript/base.zs
@@ -50,6 +50,7 @@
#include "am_map.h"
#include "v_video.h"
#include "gi.h"
#include "fontinternals.h"
#include "intermission/intermission.h"

DVector2 AM_GetPosition();
@@ -285,6 +286,31 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, MakeLower, StringMakeLower)
ACTION_RETURN_STRING(self->MakeLower());
}

static int StringCharUpper(int ch)
{
return ch >= 0 && ch < 65536 ? upperforlower[ch] : ch;
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, CharUpper, StringCharUpper)
{
PARAM_PROLOGUE;
PARAM_INT(ch);
ACTION_RETURN_INT(StringCharUpper(ch));
}

static int StringCharLower(int ch)
{
return ch >= 0 && ch < 65536 ? lowerforupper[ch] : ch;
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, CharLower, StringCharLower)
{
PARAM_PROLOGUE;
PARAM_INT(ch);
ACTION_RETURN_INT(StringCharLower(ch));
}


static int StringToInt(FString *self, int base)
{
return (int)self->ToLong(base);
@@ -909,6 +909,8 @@ struct StringStruct native
deprecated("4.1") native void ToLower();
native String MakeUpper();
native String MakeLower();
native static int CharUpper(int ch);
native static int CharLower(int ch);
native int ToInt(int base = 0) const;
native double ToDouble() const;
native void Split(out Array<String> tokens, String delimiter, EmptyTokenType keepEmpty = TOK_KEEPEMPTY) const;

0 comments on commit 3938119

Please sign in to comment.
You can’t perform that action at this time.