Преглед изворни кода

* renamed some str(x,y) and val(x,y) helpers so the naming scheme is the
same for all string types
+ added the str(x,y) and val(x,y,z) helpers for int64/qword to
compproc.inc

Jonas Maebe пре 24 година
родитељ
комит
4716f168dd
5 измењених фајлова са 117 додато и 49 уклоњено
  1. 15 9
      rtl/inc/astrings.inc
  2. 24 7
      rtl/inc/compproc.inc
  3. 46 17
      rtl/inc/int64.inc
  4. 19 9
      rtl/inc/sstrings.inc
  5. 13 7
      rtl/inc/wstrings.inc

+ 15 - 9
rtl/inc/astrings.inc

@@ -588,32 +588,32 @@ begin
     end;
 end;
 
-Function fpc_Val_UInt64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 Var
   SS : ShortString;
 begin
-  fpc_Val_UInt64_AnsiStr:=0;
+  fpc_Val_qword_AnsiStr:=0;
   if length(S)>255 then
     code:=256
   else
     begin
        SS := S;
-       Val(SS,fpc_Val_UInt64_AnsiStr,Code);
+       Val(SS,fpc_Val_qword_AnsiStr,Code);
     end;
 end;
 
 
-Function fpc_Val_SInt64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 Var
   SS : ShortString;
 begin
-  fpc_Val_SInt64_AnsiStr:=0;
+  fpc_Val_int64_AnsiStr:=0;
   if length(S)>255 then
     code:=256
   else
     begin
        SS := s;
-       Val(SS,fpc_Val_SInt64_AnsiStr,Code);
+       Val(SS,fpc_Val_int64_AnsiStr,Code);
     end;
 end;
 
@@ -626,7 +626,7 @@ begin
 end;
 
 
-Procedure fpc_AnsiStr_UInt(C : Cardinal;Len : Longint; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_CARDINAL']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Procedure fpc_AnsiStr_Cardinal(C : Cardinal;Len : Longint; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_CARDINAL']; {$ifdef hascompilerproc} compilerproc; {$endif}
 Var
   SS : ShortString;
 begin
@@ -636,7 +636,7 @@ end;
 
 
 
-Procedure fpc_AnsiStr_SInt(L : Longint; Len : Longint; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Procedure fpc_AnsiStr_Longint(L : Longint; Len : Longint; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
 Var
   SS : ShortString;
 begin
@@ -732,7 +732,13 @@ end;
 
 {
   $Log$
-  Revision 1.17  2001-08-01 15:00:10  jonas
+  Revision 1.18  2001-08-13 12:40:16  jonas
+    * renamed some str(x,y) and val(x,y) helpers so the naming scheme is the
+      same for all string types
+    + added the str(x,y) and val(x,y,z) helpers for int64/qword to
+      compproc.inc
+
+  Revision 1.17  2001/08/01 15:00:10  jonas
     + "compproc" helpers
     * renamed several helpers so that their name is the same as their
       "public alias", which should facilitate the conversion of processor

+ 24 - 7
rtl/inc/compproc.inc

@@ -63,6 +63,7 @@ Procedure fpc_CharArray_To_AnsiStr(var a : ansistring;p : pchar;l:longint); comp
 Function fpc_AnsiStr_Compare(S1,S2 : Pointer): Longint; compilerproc;
 Procedure fpc_AnsiStr_CheckZero(p : pointer); compilerproc;
 Procedure fpc_AnsiStr_CheckRange(len,index : longint); compilerproc;
+Procedure fpc_AnsiStr_SetLength (Var S : AnsiString; l : Longint); compilerproc;
 {$ifdef EXTRAANSISHORT}
 Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): Longint; compilerproc;
 {$endif EXTRAANSISHORT}
@@ -88,21 +89,31 @@ Procedure fpc_widestr_Unique(Var S : WideString); compilerproc;
 Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; compilerproc;
 Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; compilerproc;
 Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; compilerproc;
-Function fpc_Val_UInt64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword;compilerproc; 
-Function fpc_Val_SInt64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; compilerproc;
+Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword;compilerproc; 
+Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; compilerproc;
 procedure fpc_AnsiStr_Float(d : ValReal;len,fr,rt : longint;var s : ansistring); compilerproc;
-Procedure fpc_AnsiStr_UInt(C : Cardinal;Len : Longint; Var S : AnsiString); compilerproc;
-Procedure fpc_AnsiStr_SInt(L : Longint; Len : Longint; Var S : AnsiString); compilerproc;
+Procedure fpc_AnsiStr_Cardinal(C : Cardinal;Len : Longint; Var S : AnsiString); compilerproc;
+Procedure fpc_AnsiStr_Longint(L : Longint; Len : Longint; Var S : AnsiString); compilerproc;
 
 Function fpc_Val_Real_WideStr(Const S : WideString; Var Code : ValSInt): ValReal; compilerproc;
 Function fpc_Val_UInt_WideStr (Const S : WideString; Var Code : ValSInt): ValUInt; compilerproc;
 Function fpc_Val_SInt_WideStr (DestSize: longint; Const S : WideString; Var Code : ValSInt): ValSInt; compilerproc;
-Function fpc_Val_UInt64_WideStr (Const S : WideString; Var Code : ValSInt): qword; compilerproc;
-Function fpc_Val_SInt64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; compilerproc;
+Function fpc_Val_qword_WideStr (Const S : WideString; Var Code : ValSInt): qword; compilerproc;
+Function fpc_Val_int64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; compilerproc;
 procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : longint;var s : WideString); compilerproc;
 Procedure fpc_WideStr_Cardinal(C : Cardinal;Len : Longint; Var S : WideString); compilerproc;
 Procedure fpc_WideStr_Longint(L : Longint; Len : Longint; Var S : WideString); compilerproc;
 
+{ from int64.inc }
+procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring); compilerproc;
+procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring); compilerproc;
+procedure fpc_ansistr_qword(v : qword;len : longint;var s : ansistring); compilerproc;
+procedure fpc_ansistr_int64(v : int64;len : longint;var s : ansistring); compilerproc;
+Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; compilerproc;
+Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; compilerproc;
+procedure fpc_widestr_qword(v : qword;len : longint;var s : widestring); compilerproc;
+procedure fpc_widestr_int64(v : int64;len : longint;var s : widestring); compilerproc;
+
 function fpc_do_is(aclass : tclass;aobject : tobject) : boolean; compilerproc;
 procedure fpc_do_as(aclass : tclass;aobject : tobject); compilerproc;
 procedure fpc_intf_decr_ref(var i: pointer); compilerproc;
@@ -186,7 +197,13 @@ Procedure fpc_typed_read(TypeSize : Longint;var f : TypedFile;var Buf); compiler
 
 {
   $Log$
-  Revision 1.2  2001-08-06 14:13:55  jonas
+  Revision 1.3  2001-08-13 12:40:16  jonas
+    * renamed some str(x,y) and val(x,y) helpers so the naming scheme is the
+      same for all string types
+    + added the str(x,y) and val(x,y,z) helpers for int64/qword to
+      compproc.inc
+
+  Revision 1.2  2001/08/06 14:13:55  jonas
     * changed buf parameter of fpc_type_write from var to const
     + added names of helpers in typefile.inc to compproc.inc
 

+ 46 - 17
rtl/inc/int64.inc

@@ -347,7 +347,7 @@
            qword_str(qword(value),s);
       end;
 
-  procedure int_str_qword(v : qword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_QWORD'];
+  procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
     begin
        qword_str(v,s);
@@ -355,7 +355,7 @@
           s:=space(len-length(s))+s;
     end;
 
-  procedure int_str_int64(v : int64;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_INT64'];
+  procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_INT64'];  {$ifdef hascompilerproc} compilerproc; {$endif}
 
     begin
        int64_str(v,s);
@@ -363,27 +363,50 @@
          s:=space(len-length(s))+s;
     end;
 
-  procedure int_str_qword(v : qword;len : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_QWORD'];
+  procedure fpc_ansistr_qword(v : qword;len : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
     var
        ss : shortstring;
 
     begin
-       int_str_qword(v,len,ss);
+       str(v:len,ss);
        s:=ss;
     end;
 
-  procedure int_str_int64(v : int64;len : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_INT64'];
+  procedure fpc_ansistr_int64(v : int64;len : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
     var
        ss : shortstring;
 
     begin
-       int_str_int64(v,len,ss);
+       str(v:len,ss);
        s:=ss;
     end;
 
-  Function ValInt64(Const S: ShortString; var Code: ValSInt): Int64; [public, alias:'FPC_VAL_INT64_SHORTSTR'];
+{$ifdef HASWIDESTRING}
+  procedure fpc_widestr_qword(v : qword;len : longint;var s : widestring);[public,alias:'FPC_WIDESTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
+
+    var
+       ss : shortstring;
+
+    begin
+       str(v:len,ss);
+       s:=ss;
+    end;
+
+  procedure fpc_widestr_int64(v : int64;len : longint;var s : widestring);[public,alias:'FPC_WIDESTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
+
+    var
+       ss : shortstring;
+
+    begin
+       str(v:len,ss);
+       s:=ss;
+    end;
+{$endif HASWIDESTRING}
+
+
+  Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; [public, alias:'FPC_VAL_INT64_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
    type
      QWordRec = packed record
        l1,l2: longint;
@@ -395,7 +418,7 @@
        negative : boolean;
 
   begin
-    ValInt64 := 0;
+    fpc_val_int64_shortstr := 0;
     Temp:=0;
     Code:=InitVal(s,negative,base);
     if Code>length(s) then
@@ -430,20 +453,20 @@
          (qword(maxqword-temp) < u)) or
         (prev > maxqword div qword(base)) Then
        Begin
-         ValInt64 := 0;
+         fpc_val_int64_shortstr := 0;
          Exit
        End;
        Temp:=Temp+u;
        inc(code);
      end;
     code:=0;
-    ValInt64:=int64(Temp);
+    fpc_val_int64_shortstr:=int64(Temp);
     If Negative Then
-      ValInt64:=-ValInt64;
+      fpc_val_int64_shortstr:=-fpc_val_int64_shortstr;
   end;
 
 
-  Function ValQWord(Const S: ShortString; var Code: ValSInt): QWord; [public, alias:'FPC_VAL_QWORD_SHORTSTR'];
+  Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; [public, alias:'FPC_VAL_QWORD_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
     type qwordrec = packed record
       l1,l2: longint;
     end;
@@ -452,7 +475,7 @@
        base : byte;
        negative : boolean;
   begin
-    ValQWord:=0;
+    fpc_val_qword_shortstr:=0;
     Code:=InitVal(s,negative,base);
     If Negative or (Code>length(s)) Then
       Exit;
@@ -470,14 +493,14 @@
        else
         u:=16;
        end;
-       prev := ValQWord;
+       prev := fpc_val_qword_shortstr;
        If (u>=base) or
          ((QWord(maxqword-u) div QWord(base))<prev) then
          Begin
-           ValQWord := 0;
+           fpc_val_qword_shortstr := 0;
            Exit
          End;
-       ValQWord:=ValQWord*QWord(base) + u;
+       fpc_val_qword_shortstr:=fpc_val_qword_shortstr*QWord(base) + u;
        inc(code);
      end;
     code := 0;
@@ -485,7 +508,13 @@
 
 {
   $Log$
-  Revision 1.10  2001-04-23 18:25:45  peter
+  Revision 1.11  2001-08-13 12:40:16  jonas
+    * renamed some str(x,y) and val(x,y) helpers so the naming scheme is the
+      same for all string types
+    + added the str(x,y) and val(x,y,z) helpers for int64/qword to
+      compproc.inc
+
+  Revision 1.10  2001/04/23 18:25:45  peter
     * m68k updates
 
   Revision 1.9  2001/04/13 22:30:04  peter

+ 19 - 9
rtl/inc/sstrings.inc

@@ -16,8 +16,6 @@
                     subroutines for string handling
 ****************************************************************************}
 
-{$I real2str.inc}
-
 {$ifndef INTERNSETLENGTH}
 procedure SetLength(var s:shortstring;len:StrLenInt);
 {$else INTERNSETLENGTH}
@@ -311,12 +309,6 @@ end;
                               Str() Helpers
 *****************************************************************************}
 
-procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_FLOAT']; {$ifdef hascompilerproc}compilerproc;{$endif hascompilerproc}
-begin
-  str_real(len,fr,d,treal_type(rt),s);
-end;
-
-
 procedure fpc_shortstr_longint(v : longint;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
 begin
   int_str(v,s);
@@ -332,6 +324,18 @@ begin
     s:=space(len-length(s))+s;
 end;
 
+{ fpc_shortstr_longint must appear before this file is included, because }
+{ it's used inside real2str.inc and otherwise the searching via the      }
+{ compilerproc name will fail (JM)                                       }
+
+{$I real2str.inc}
+
+procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_FLOAT']; {$ifdef hascompilerproc}compilerproc;{$endif hascompilerproc}
+begin
+  str_real(len,fr,d,treal_type(rt),s);
+end;
+
+
 
 {*****************************************************************************
                            Val() Functions
@@ -575,7 +579,13 @@ end;
 
 {
   $Log$
-  Revision 1.15  2001-08-01 15:00:10  jonas
+  Revision 1.16  2001-08-13 12:40:16  jonas
+    * renamed some str(x,y) and val(x,y) helpers so the naming scheme is the
+      same for all string types
+    + added the str(x,y) and val(x,y,z) helpers for int64/qword to
+      compproc.inc
+
+  Revision 1.15  2001/08/01 15:00:10  jonas
     + "compproc" helpers
     * renamed several helpers so that their name is the same as their
       "public alias", which should facilitate the conversion of processor

+ 13 - 7
rtl/inc/wstrings.inc

@@ -710,32 +710,32 @@ begin
     end;
 end; 
 
-Function fpc_Val_UInt64_WideStr (Const S : WideString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Function fpc_Val_qword_WideStr (Const S : WideString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 Var
   SS : ShortString;
 begin
-  fpc_Val_UInt64_WideStr:=0;
+  fpc_Val_qword_WideStr:=0;
   if length(S)>255 then
     code:=256
   else
     begin
        SS := S;
-       Val(SS,fpc_Val_UInt64_WideStr,Code);
+       Val(SS,fpc_Val_qword_WideStr,Code);
     end;
 end; 
   
   
-Function fpc_Val_SInt64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Function fpc_Val_int64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
 Var
   SS : ShortString;
 begin
-  fpc_Val_SInt64_WideStr:=0;
+  fpc_Val_int64_WideStr:=0;
   if length(S)>255 then
     code:=256
   else
     begin
        SS := S;
-       Val(SS,fpc_Val_SInt64_WideStr,Code);
+       Val(SS,fpc_Val_int64_WideStr,Code);
     end;
 end;
 
@@ -771,7 +771,13 @@ end;
 
 {
   $Log$
-  Revision 1.11  2001-08-01 15:00:11  jonas
+  Revision 1.12  2001-08-13 12:40:16  jonas
+    * renamed some str(x,y) and val(x,y) helpers so the naming scheme is the
+      same for all string types
+    + added the str(x,y) and val(x,y,z) helpers for int64/qword to
+      compproc.inc
+
+  Revision 1.11  2001/08/01 15:00:11  jonas
     + "compproc" helpers
     * renamed several helpers so that their name is the same as their
       "public alias", which should facilitate the conversion of processor