Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$IF Defined #265

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Initial, incomplete
TetzkatLipHoka authored Jan 12, 2023
commit 9f9ae2532fa681c372fd1c3e88375745ed070ed8
164 changes: 164 additions & 0 deletions Source/uPSC_SysUtils.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
unit uPSC_SysUtils;

interface

uses
uPSCompiler, uPSUtils;

procedure RegisterSysUtilsLibrary_C(S: TPSPascalCompiler);

implementation

uses
SysUtils;

procedure RegisterSysUtilsLibrary_C(S: TPSPascalCompiler);
var
Str : string;
begin
{$IF CompilerVersion >= 28}
S.AddConstant('INVALID_HANDLE_VALUE', INVALID_HANDLE_VALUE);
{$IFEND}

S.AddConstant('fmOpenRead', fmOpenRead);
S.AddConstant('fmOpenWrite', fmOpenWrite);
S.AddConstant('fmOpenReadWrite', fmOpenReadWrite);
S.AddConstant('fmExclusive', fmExclusive);
S.AddConstant('fmShareCompat', fmShareCompat);
S.AddConstant('fmShareExclusive', fmShareExclusive);
S.AddConstant('fmShareDenyWrite', fmShareDenyWrite);
S.AddConstant('fmShareDenyRead', fmShareDenyRead);
S.AddConstant('fmShareDenyNone', fmShareDenyNone);

S.AddConstant('faInvalid', faInvalid);
S.AddConstant('faReadOnly', faReadOnly);
S.AddConstant('faHidden', faHidden);
S.AddConstant('faSysFile', faSysFile);
S.AddConstant('faVolumeID', faVolumeID);
S.AddConstant('faDirectory', faDirectory);
S.AddConstant('faArchive', faArchive);
S.AddConstant('faNormal', faNormal);
S.AddConstant('faTemporary', faTemporary);
S.AddConstant('faSymLink', faSymLink);
S.AddConstant('faCompressed', faCompressed);
S.AddConstant('faEncrypted', faEncrypted);
S.AddConstant('faVirtual', faVirtual);
S.AddConstant('faAnyFile', faAnyFile);

S.AddConstant('DefaultTrueBoolStr', DefaultTrueBoolStr);
S.AddConstant('DefaultFalseBoolStr', DefaultFalseBoolStr);

S.AddTypeS( 'TSysCharSet', 'set of AnsiChar' );
// S.AddTypeS( 'TIntegerSet', 'set of 0..31{SizeOf(Integer) * 8 - 1}' );
S.AddTypeS( 'TByteArray', 'array[0..32767] of Byte;' );
S.AddTypeS( 'TWordArray', 'array[0..16383] of Word;' );
S.AddTypeCopyN( 'TFileName', 'string' );

S.AddTypeS( 'TFloatValue', '(fvExtended, fvCurrency)' );
S.AddTypeS( 'TFloatFormat', '(ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency)' );
S.AddTypeS( 'TFloatRec', 'record Exponent: Smallint; Negative: Boolean; Digits: array[0..20] of Byte; end;' );
S.AddTypeS( 'TTimeStamp', 'record Time: Integer; Date: Integer; end;' );
S.AddTypeS( 'TMbcsByteType', '(mbSingleByte, mbLeadByte, mbTrailByte)' );

{$IF CompilerVersion >= 28}
S.AddTypeS( 'TLocaleOptions', '(loInvariantLocale, loUserLocale)' );
{$IFEND}

// s.AddDelphiFunction('function UpperCase(const S: string): string;' );
{$IF CompilerVersion >= 28}
s.AddDelphiFunction('function UpperCaseS(const S: string; LocaleOptions: TLocaleOptions): string;' );
{$IFEND}
// s.AddDelphiFunction('function LowerCase(const S: string): string;' );
{$IF CompilerVersion >= 28}
s.AddDelphiFunction('function LowerCaseS(const S: string; LocaleOptions: TLocaleOptions): string;' );
{$IFEND}
s.AddDelphiFunction('function CompareStr(const S1, S2: string): Integer;' );
{$IF CompilerVersion >= 28}
s.AddDelphiFunction('function CompareStrS(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer;' );
{$IFEND}
{$IF CompilerVersion >= 28}
s.AddDelphiFunction('function SameStr(const S1, S2: string): Boolean;' );
s.AddDelphiFunction('function SameStrS(const S1, S2: string; LocaleOptions: TLocaleOptions): Boolean;' );
{$IFEND}
s.AddDelphiFunction('function CompareMem(P1, P2: Pointer; Length: Integer): Boolean;' );
s.AddDelphiFunction('function CompareText(const S1, S2: string): Integer;' );
{$IF CompilerVersion >= 28}
s.AddDelphiFunction('function CompareTextS(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer;' );
{$IFEND}
s.AddDelphiFunction('function SameText(const S1, S2: string): Boolean;' );
s.AddDelphiFunction('function SameTextS(const S1, S2: string; LocaleOptions: TLocaleOptions): Boolean;' );
// s.AddDelphiFunction('function AnsiUpperCase(const S: string): string;' );
// s.AddDelphiFunction('function AnsiLowerCase(const S: string): string;' );
s.AddDelphiFunction('function AnsiCompareStr(const S1, S2: string): Integer;' );
s.AddDelphiFunction('function AnsiSameStr(const S1, S2: string): Boolean;' );
s.AddDelphiFunction('function AnsiCompareText(const S1, S2: string): Integer;' );
s.AddDelphiFunction('function AnsiSameText(const S1, S2: string): Boolean;' );
s.AddDelphiFunction('function AnsiStrComp(S1, S2: PChar): Integer;' );
s.AddDelphiFunction('function AnsiStrIComp(S1, S2: PChar): Integer;' );
s.AddDelphiFunction('function AnsiStrLComp(S1, S2: PChar; MaxLen: Cardinal): Integer;' );
s.AddDelphiFunction('function AnsiStrLIComp(S1, S2: PChar; MaxLen: Cardinal): Integer;' );
s.AddDelphiFunction('function AnsiStrLower(Str: PChar): PChar;' );
s.AddDelphiFunction('function AnsiStrUpper(Str: PChar): PChar;' );
s.AddDelphiFunction('function AnsiLastChar(const S: string): PChar;' );
s.AddDelphiFunction('function AnsiStrLastChar(P: PChar): PChar;' );
s.AddDelphiFunction('function WideUpperCase(const S: WideString): WideString;' );
s.AddDelphiFunction('function WideLowerCase(const S: WideString): WideString;' );
s.AddDelphiFunction('function WideCompareStr(const S1, S2: WideString): Integer;' );
s.AddDelphiFunction('function WideSameStr(const S1, S2: WideString): Boolean;' );
s.AddDelphiFunction('function WideCompareText(const S1, S2: WideString): Integer;' );
s.AddDelphiFunction('function WideSameText(const S1, S2: WideString): Boolean;' );
// s.AddDelphiFunction('function Trim(const S: string): string;' );
s.AddDelphiFunction('function TrimLeft(const S: string): string;' );
s.AddDelphiFunction('function TrimRight(const S: string): string;' );
s.AddDelphiFunction('function QuotedStr(const S: string): string;' );
s.AddDelphiFunction('function AnsiQuotedStr(const S: string; Quote: Char): string;' );
s.AddDelphiFunction('function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;' );
s.AddDelphiFunction('function AnsiDequotedStr(const S: string; AQuote: Char): string;' );

s.AddDelphiFunction('function GetCurrentDir: string;' );
s.AddDelphiFunction('function SetCurrentDir(const Dir: string): Boolean;' );
s.AddDelphiFunction('function CreateDir(const Dir: string): Boolean;' );
s.AddDelphiFunction('function RemoveDir(const Dir: string): Boolean;' );
s.AddDelphiFunction('function StrLen(const Str: PChar): Cardinal;' );
s.AddDelphiFunction('function StrEnd(const Str: PChar): PChar;' );
s.AddDelphiFunction('function StrMove(Dest: PChar; const Source: PChar; Count: Cardinal): PChar;' );
s.AddDelphiFunction('function StrCopy(Dest: PChar; const Source: PChar): PChar;' );
s.AddDelphiFunction('function StrECopy(Dest:PChar; const Source: PChar): PChar;' );
s.AddDelphiFunction('function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar;' );
s.AddDelphiFunction('function StrPCopy(Dest: PChar; const Source: string): PChar;' );
s.AddDelphiFunction('function StrPLCopy(Dest: PChar; const Source: string; MaxLen: Cardinal): PChar;' );
s.AddDelphiFunction('function StrCat(Dest: PChar; const Source: PChar): PChar;' );
s.AddDelphiFunction('function StrLCat(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar;' );
s.AddDelphiFunction('function StrComp(const Str1, Str2: PChar): Integer;' );
s.AddDelphiFunction('function StrIComp(const Str1, Str2: PChar): Integer;' );
s.AddDelphiFunction('function StrLComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;' );
s.AddDelphiFunction('function StrLIComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;' );
s.AddDelphiFunction('function StrScan(const Str: PChar; AChr: Char): PChar;' );
s.AddDelphiFunction('function StrRScan(const Str: PChar; AChr: Char): PChar;' );
s.AddDelphiFunction('function StrPos(const Str1, Str2: PChar): PChar;' );
s.AddDelphiFunction('function StrUpper(Str: PChar): PChar;' );
s.AddDelphiFunction('function StrLower(Str: PChar): PChar;' );
s.AddDelphiFunction('function StrPas(const Str: PChar): string;' );
s.AddDelphiFunction('function StrAlloc(Size: Cardinal): PChar;' );
s.AddDelphiFunction('function StrBufSize(const Str: PChar): Cardinal;' );
s.AddDelphiFunction('function StrNew(const Str: PChar): PChar;' );
s.AddDelphiFunction('procedure StrDispose(Str: PChar);' );
s.AddDelphiFunction('function Format(const Format: string; const Args: array of const): string; overload;' );
s.AddDelphiFunction('function FormatS(const Format: string; const Args: array of const; const AFormatSettings: TFormatSettings): string;' );
s.AddDelphiFunction('procedure FmtStr(var Result: string; const Format: string; const Args: array of const);' );
s.AddDelphiFunction('procedure FmtStrS(var Result: string; const Format: string; const Args: array of const; const AFormatSettings: TFormatSettings);' );
s.AddDelphiFunction('function StrFmt(Buffer, Format: PChar; const Args: array of const): PChar;' );
s.AddDelphiFunction('function StrFmtS(Buffer, Format: PChar; const Args: array of const; const FormatSettings: TFormatSettings): PChar;' );
s.AddDelphiFunction('function StrLFmt(Buffer: PChar; MaxBufLen: Cardinal; Format: PChar; const Args: array of const): PChar;' );
s.AddDelphiFunction('function StrLFmtS(Buffer: PChar; MaxBufLen: Cardinal; Format: PChar; const Args: array of const; const FormatSettings: TFormatSettings): PChar;' );
// s.AddDelphiFunction('function FormatBuf(var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of const): Cardinal;' );
// s.AddDelphiFunction('function FormatBufS(var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of const; const FormatSettings: TFormatSettings): Cardinal;' );
s.AddDelphiFunction('function WideFormat(const Format: WideString; const Args: array of const): WideString;' );
s.AddDelphiFunction('function WideFormatS(const Format: WideString; const Args: array of const; const AFormatSettings: TFormatSettings): WideString;' );
s.AddDelphiFunction('procedure WideFmtStr(var Result: WideString; const Format: WideString; const Args: array of const);' );
s.AddDelphiFunction('procedure WideFmtStrS(var Result: WideString; const Format: WideString; const Args: array of const; const AFormatSettings: TFormatSettings);' );
// s.AddDelphiFunction('function WideFormatBuf(var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of const): Cardinal;' );
// s.AddDelphiFunction('function WideFormatBufS(var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of const; const AFormatSettings: TFormatSettings): Cardinal;' );
end;

end.
113 changes: 113 additions & 0 deletions Source/uPSR_SysUtils.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
unit uPSR_SysUtils;
{$I PascalScript.inc}
interface
uses
uPSRuntime;

procedure RegisterSysUtilsLibrary_R(S: TPSExec);

implementation

uses
SysUtils;

procedure RegisterSysUtilsLibrary_R(S: TPSExec);
begin
// s.RegisterDelphiFunction(@UpperCase, 'UpperCase', cdRegister );
{$IF CompilerVersion >= 28}
s.RegisterDelphiFunction(@UpperCase, 'UpperCaseS', cdRegister );
{$IFEND}
// s.RegisterDelphiFunction(@LowerCase, 'LowerCase', cdRegister );
{$IF CompilerVersion >= 28}
s.RegisterDelphiFunction(@LowerCase, 'LowerCaseS', cdRegister );
{$IFEND}
s.RegisterDelphiFunction(@CompareStr, 'CompareStr', cdRegister );
{$IF CompilerVersion >= 28}
s.RegisterDelphiFunction(@CompareStr, 'CompareStrS', cdRegister );
{$IFEND}
{$IF CompilerVersion >= 28}
s.RegisterDelphiFunction(@SameStr, 'SameStr', cdRegister );
s.RegisterDelphiFunction(@SameStr, 'SameStrS', cdRegister );
{$IFEND}
s.RegisterDelphiFunction(@CompareMem, 'CompareMem', cdRegister );
s.RegisterDelphiFunction(@CompareText, 'CompareText', cdRegister );
{$IF CompilerVersion >= 28}
s.RegisterDelphiFunction(@CompareText, 'CompareTextS', cdRegister );
{$IFEND}
s.RegisterDelphiFunction(@SameText, 'SameText', cdRegister );
s.RegisterDelphiFunction(@SameText, 'SameTextS', cdRegister );
// s.RegisterDelphiFunction(@AnsiUpperCase, 'AnsiUpperCase', cdRegister );
// s.RegisterDelphiFunction(@AnsiLowerCase, 'AnsiLowerCase', cdRegister );
s.RegisterDelphiFunction(@AnsiCompareStr, 'AnsiCompareStr', cdRegister );
s.RegisterDelphiFunction(@AnsiSameStr, 'AnsiSameStr', cdRegister );
s.RegisterDelphiFunction(@AnsiCompareText, 'AnsiCompareText', cdRegister );
s.RegisterDelphiFunction(@AnsiSameText, 'AnsiSameText', cdRegister );
s.RegisterDelphiFunction(@AnsiStrComp, 'AnsiStrComp', cdRegister );
s.RegisterDelphiFunction(@AnsiStrIComp, 'AnsiStrIComp', cdRegister );
s.RegisterDelphiFunction(@AnsiStrLComp, 'AnsiStrLComp', cdRegister );
s.RegisterDelphiFunction(@AnsiStrLIComp, 'AnsiStrLIComp', cdRegister );
s.RegisterDelphiFunction(@AnsiStrLower, 'AnsiStrLower', cdRegister );
s.RegisterDelphiFunction(@AnsiStrUpper, 'AnsiStrUpper', cdRegister );
s.RegisterDelphiFunction(@AnsiLastChar, 'AnsiLastChar', cdRegister );
s.RegisterDelphiFunction(@AnsiStrLastChar, 'AnsiStrLastChar', cdRegister );
s.RegisterDelphiFunction(@WideUpperCase, 'WideUpperCase', cdRegister );
s.RegisterDelphiFunction(@WideLowerCase, 'WideLowerCase', cdRegister );
s.RegisterDelphiFunction(@WideCompareStr, 'WideCompareStr', cdRegister );
s.RegisterDelphiFunction(@WideSameStr, 'WideSameStr', cdRegister );
s.RegisterDelphiFunction(@WideCompareText, 'WideCompareText', cdRegister );
s.RegisterDelphiFunction(@WideSameText, 'WideSameText', cdRegister );
// s.RegisterDelphiFunction(@Trim, 'Trim', cdRegister );
s.RegisterDelphiFunction(@TrimLeft, 'TrimLeft', cdRegister );
s.RegisterDelphiFunction(@TrimRight, 'TrimRight', cdRegister );
s.RegisterDelphiFunction(@QuotedStr, 'QuotedStr', cdRegister );
s.RegisterDelphiFunction(@AnsiQuotedStr, 'AnsiQuotedStr', cdRegister );
s.RegisterDelphiFunction(@AnsiExtractQuotedStr, 'AnsiExtractQuotedStr', cdRegister );
s.RegisterDelphiFunction(@AnsiDequotedStr, 'AnsiDequotedStr', cdRegister );

s.RegisterDelphiFunction(@GetCurrentDir, 'GetCurrentDir', cdRegister );
s.RegisterDelphiFunction(@SetCurrentDir, 'SetCurrentDir', cdRegister );
s.RegisterDelphiFunction(@CreateDir, 'CreateDir', cdRegister );
s.RegisterDelphiFunction(@RemoveDir, 'RemoveDir', cdRegister );
s.RegisterDelphiFunction(@StrLen, 'StrLen', cdRegister );
s.RegisterDelphiFunction(@StrEnd, 'StrEnd', cdRegister );
s.RegisterDelphiFunction(@StrMove, 'StrMove', cdRegister );
s.RegisterDelphiFunction(@StrCopy, 'StrCopy', cdRegister );
s.RegisterDelphiFunction(@StrECopy, 'StrECopy', cdRegister );
s.RegisterDelphiFunction(@StrLCopy, 'StrLCopy', cdRegister );
s.RegisterDelphiFunction(@StrPCopy, 'StrPCopy', cdRegister );
s.RegisterDelphiFunction(@StrPLCopy, 'StrPLCopy', cdRegister );
s.RegisterDelphiFunction(@StrCat, 'StrCat', cdRegister );
s.RegisterDelphiFunction(@StrLCat, 'StrLCat', cdRegister );
s.RegisterDelphiFunction(@StrComp, 'StrComp', cdRegister );
s.RegisterDelphiFunction(@StrIComp, 'StrIComp', cdRegister );
s.RegisterDelphiFunction(@StrLComp, 'StrLComp', cdRegister );
s.RegisterDelphiFunction(@StrLIComp, 'StrLIComp', cdRegister );
s.RegisterDelphiFunction(@StrScan, 'StrScan', cdRegister );
s.RegisterDelphiFunction(@StrRScan, 'StrRScan', cdRegister );
s.RegisterDelphiFunction(@StrPos, 'StrPos', cdRegister );
s.RegisterDelphiFunction(@StrUpper, 'StrUpper', cdRegister );
s.RegisterDelphiFunction(@StrLower, 'StrLower', cdRegister );
s.RegisterDelphiFunction(@StrPas, 'StrPas', cdRegister );
s.RegisterDelphiFunction(@StrAlloc, 'StrAlloc', cdRegister );
s.RegisterDelphiFunction(@StrBufSize, 'StrBufSize', cdRegister );
s.RegisterDelphiFunction(@StrNew, 'StrNew', cdRegister );
s.RegisterDelphiFunction(@StrDispose, 'StrDispose', cdRegister );
s.RegisterDelphiFunction(@Format, 'Format', cdRegister );
s.RegisterDelphiFunction(@Format, 'FormatS', cdRegister );
s.RegisterDelphiFunction(@FmtStr, 'FmtStr', cdRegister );
s.RegisterDelphiFunction(@FmtStr, 'FmtStrS', cdRegister );
s.RegisterDelphiFunction(@StrFmt, 'StrFmt', cdRegister );
s.RegisterDelphiFunction(@StrFmt, 'StrFmtS', cdRegister );
s.RegisterDelphiFunction(@StrLFmt, 'StrLFmt', cdRegister );
s.RegisterDelphiFunction(@StrLFmt, 'StrLFmtS', cdRegister );
// s.RegisterDelphiFunction(@FormatBuf, 'FormatBuf', cdRegister );
// s.RegisterDelphiFunction(@FormatBuf, 'FormatBufS', cdRegister );
s.RegisterDelphiFunction(@WideFormat, 'WideFormat', cdRegister );
s.RegisterDelphiFunction(@WideFormat, 'WideFormatS', cdRegister );
s.RegisterDelphiFunction(@WideFmtStr, 'WideFmtStr', cdRegister );
s.RegisterDelphiFunction(@WideFmtStr, 'WideFmtStrS', cdRegister );
// s.RegisterDelphiFunction(@WideFormatBuf, 'WideFormatBuf', cdRegister );
// s.RegisterDelphiFunction(@WideFormatBuf, 'WideFormatBufS', cdRegister );
end;

end.