mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 11:08:02 +02:00

o support for the new codepage-aware ansistrings in the jvm branch o empty ansistrings are now always represented by a nil pointer rather than by an empty string, because an empty string also has a code page which can confuse code (although this will make ansistrings harder to use in Java code) o more string helpers code shared between the general and jvm rtl o support for indexbyte/word in the jvm rtl (warning: first parameter is an open array rather than an untyped parameter there, so indexchar(pcharvar^,10,0) will be equivalent to indexchar[pcharvar^],10,0) there, which is different from what is intended; changing it to an untyped parameter wouldn't help though) o default() support is not yet complete o calling fpcres is currently broken due to limitations in sysutils.executeprocess() regarding handling unix quoting and the compiler using the same command lines for scripts and directly calling external programs o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1 to the make command line git-svn-id: branches/jvmbackend@20887 -
102 lines
4.6 KiB
PHP
102 lines
4.6 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;
|
|
public
|
|
function getForCodePage(cp: TSystemCodePage): JNCCharsetDecoder;
|
|
end;
|
|
|
|
TCharsetEncoderThreadvar = class(JLThreadLocal)
|
|
protected
|
|
function initialValue: JLObject; override;
|
|
public
|
|
function getForCodePage(cp: TSystemCodePage): JNCCharsetEncoder;
|
|
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:RawByteString;cp : TSystemCodePage;len:SizeInt); virtual;
|
|
procedure Ansi2WideMoveProc(source:pchar;cp : TSystemCodePage;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:RawByteString;cp : TSystemCodePage;len:SizeInt); virtual;
|
|
procedure Ansi2UnicodeMoveProc(source:pchar;cp : TSystemCodePage;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;
|
|
|
|
|