mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-19 01:18:20 +02:00

val/str for enums for now) for the JVM target: insert/delete/pos/... * use generic unicodestring helper routines where possible for the JVM target (not that many as for shortstrings since unicodestring is handled using java.lang.String) + complete widestring manager implementation for the JVM target. It uses a class with virtual methods rather than a record with function pointers for speed reasons though (since no existing widestring manager will be compatible anyway, that shouldn't cause any problems) git-svn-id: branches/jvmbackend@18882 -
98 lines
4.3 KiB
PHP
98 lines
4.3 KiB
PHP
{
|
|
This file is part of the Free Pascal run time library.
|
|
Copyright (c) 2011 by Jonas Maebe,
|
|
member of the Free Pascal development team.
|
|
|
|
This file implements support routines for UnicodeStrings with FPC
|
|
|
|
See the file COPYING.FPC, included in this distribution,
|
|
for details about the copyright.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
**********************************************************************}
|
|
|
|
{$define FPC_HAS_BUILTIN_WIDESTR_MANAGER}
|
|
Type
|
|
TCollatorThreadVar = class(JLThreadLocal)
|
|
protected
|
|
function initialValue: JLObject; override;
|
|
end;
|
|
|
|
TCharsetDecoderThreadvar = class(JLThreadLocal)
|
|
protected
|
|
function initialValue: JLObject; override;
|
|
end;
|
|
|
|
TCharsetEncoderThreadvar = class(JLThreadLocal)
|
|
protected
|
|
function initialValue: JLObject; override;
|
|
end;
|
|
|
|
{ hooks for internationalization
|
|
please add new procedures at the end, it makes it easier to detect new procedures }
|
|
|
|
TUnicodeStringManager = class(JLObject)
|
|
class var
|
|
collator: TCollatorThreadVar;
|
|
decoder: TCharsetDecoderThreadvar;
|
|
encoder: TCharsetEncoderThreadvar;
|
|
|
|
class constructor ClassCreate;
|
|
|
|
procedure Wide2AnsiMoveProc(source:pwidechar;var dest:ansistring;len:SizeInt); virtual;
|
|
procedure Ansi2WideMoveProc(source:pchar;var dest:widestring;len:SizeInt); virtual;
|
|
|
|
function UpperWideStringProc(const S: WideString): WideString; virtual;
|
|
function LowerWideStringProc(const S: WideString): WideString; virtual;
|
|
function CompareWideStringProc(const s1, s2 : WideString) : PtrInt; virtual;
|
|
function CompareTextWideStringProc(const s1, s2 : WideString): PtrInt; virtual;
|
|
{ return value: number of code points in the string. Whenever an invalid
|
|
code point is encountered, all characters part of this invalid code point
|
|
are considered to form one "character" and the next character is
|
|
considered to be the start of a new (possibly also invalid) code point
|
|
|
|
Note: different signature compared to version in native targets: extra
|
|
"Index" parameter, since you cannot increment pchars to point to the
|
|
next character here }
|
|
function CharLengthPCharProc(const Str: PChar; Index: PtrInt): PtrInt; virtual;
|
|
{ return value:
|
|
-1 if incomplete or invalid code point
|
|
0 if NULL character,
|
|
> 0 if that's the length in bytes of the code point
|
|
|
|
Note: different signature compared to version in native targets: extra
|
|
"Index" parameter, since you cannot increment pchars to point to the
|
|
next character here }
|
|
function CodePointLengthProc(const Str: PChar; Index, MaxLookAhead: PtrInt): Ptrint; virtual;
|
|
|
|
function UpperAnsiStringProc(const s : ansistring) : ansistring; virtual;
|
|
function LowerAnsiStringProc(const s : ansistring) : ansistring; virtual;
|
|
function CompareStrAnsiStringProc(const S1, S2: ansistring): PtrInt; virtual;
|
|
function CompareTextAnsiStringProc(const S1, S2: ansistring): PtrInt; virtual;
|
|
function StrCompAnsiStringProc(S1, S2: PChar): PtrInt; virtual;
|
|
function StrICompAnsiStringProc(S1, S2: PChar): PtrInt; virtual;
|
|
function StrLCompAnsiStringProc(S1, S2: PChar; MaxLen: PtrUInt): PtrInt; virtual;
|
|
function StrLICompAnsiStringProc(S1, S2: PChar; MaxLen: PtrUInt): PtrInt; virtual;
|
|
function StrLowerAnsiStringProc(Str: PChar): PChar; virtual;
|
|
function StrUpperAnsiStringProc(Str: PChar): PChar; virtual;
|
|
|
|
// not possible to automatically run code when new thread is started in the
|
|
// JVM -- and not needed either, because threadvars can do so when first
|
|
// accessed from a thread
|
|
// ThreadInitProc : procedure;
|
|
// ThreadFiniProc : procedure;
|
|
|
|
{ this is only different on windows }
|
|
procedure Unicode2AnsiMoveProc(source:punicodechar;var dest:ansistring;len:SizeInt); virtual;
|
|
procedure Ansi2UnicodeMoveProc(source:pchar;var dest:unicodestring;len:SizeInt); virtual;
|
|
function UpperUnicodeStringProc(const S: UnicodeString): UnicodeString; virtual;
|
|
function LowerUnicodeStringProc(const S: UnicodeString): UnicodeString; virtual;
|
|
function CompareUnicodeStringProc(const s1, s2 : UnicodeString) : PtrInt; virtual;
|
|
function CompareTextUnicodeStringProc(const s1, s2 : UnicodeString): PtrInt; virtual;
|
|
end;
|
|
|
|
|