Procházet zdrojové kódy

* patch from J. Peter Mugaas to fix #7616

git-svn-id: trunk@4945 -
florian před 19 roky
rodič
revize
e0200f8fcb
3 změnil soubory, kde provedl 73 přidání a 8 odebrání
  1. 4 1
      utils/h2pas/converu.pas
  2. 60 7
      utils/h2pas/h2pas.y
  3. 9 0
      utils/h2pas/scan.l

+ 4 - 1
utils/h2pas/converu.pas

@@ -73,7 +73,10 @@ const POINT = 324;
 const DEREF = 325;
 const DEREF = 325;
 const STICK = 326;
 const STICK = 326;
 const SIGNED = 327;
 const SIGNED = 327;
-
+const INT8 = 328;
+const INT16 = 329;
+const INT32 = 330;
+const INT64 = 331;
 
 
 implementation
 implementation
 end.
 end.

+ 60 - 7
utils/h2pas/h2pas.y

@@ -29,12 +29,16 @@ program h2pas;
      YYSTYPE = presobject;
      YYSTYPE = presobject;
 
 
    const
    const
-     SHORT_STR  = 'smallint';
-     USHORT_STR = 'word';
+     SHORT_STR = 'shortint';
+     USHORT_STR = 'byte';
+     //C++ SHORT types usually map to the small types
+     SMALL_STR  = 'smallint';
+     USMALL_STR = 'word';
      INT_STR    = 'longint';
      INT_STR    = 'longint';
      UINT_STR   = 'dword';
      UINT_STR   = 'dword';
      CHAR_STR   = 'char';
      CHAR_STR   = 'char';
-     UCHAR_STR  = 'byte'; { should we use byte or char for 'unsigned char' ?? }
+     UCHAR_STR  = USHORT_STR; { should we use byte or char for 'unsigned char' ?? }
+     
      INT64_STR  = 'int64';
      INT64_STR  = 'int64';
      QWORD_STR  = 'qword';
      QWORD_STR  = 'qword';
      REAL_STR   = 'double';
      REAL_STR   = 'double';
@@ -1310,6 +1314,7 @@ program h2pas;
 %left COMMA
 %left COMMA
 %left STICK
 %left STICK
 %token SIGNED
 %token SIGNED
+%token INT8 INT16 INT32 INT64
 %%
 %%
 
 
 file : declaration_list
 file : declaration_list
@@ -2278,6 +2283,14 @@ special_type_name :
               s:=cslong_STR              
               s:=cslong_STR              
             else if s=clonglong_STR then
             else if s=clonglong_STR then
               s:=cslonglong_STR
               s:=cslonglong_STR
+            else if s=cint8_STR then
+              s:=cint8_STR
+            else if s=cint16_STR then
+              s:=cint16_STR 
+            else if s=cint32_STR then
+              s:=cint32_STR 
+            else if s=cint64_STR then
+              s:=cint64_STR                                                     
             else
             else
              s:='';
              s:='';
           end
           end
@@ -2286,7 +2299,9 @@ special_type_name :
             if s=UINT_STR then
             if s=UINT_STR then
               s:=INT_STR
               s:=INT_STR
             else if s=USHORT_STR then
             else if s=USHORT_STR then
-              s:=SHORT_STR
+              s:=SHORT_STR               
+            else if s=USMALL_STR then
+              s:=SMALL_STR
             else if s=UCHAR_STR then
             else if s=UCHAR_STR then
               s:=CHAR_STR
               s:=CHAR_STR
             else if s=QWORD_STR then
             else if s=QWORD_STR then
@@ -2317,6 +2332,14 @@ special_type_name :
               s:=culong_STR
               s:=culong_STR
             else if s=clonglong_STR then
             else if s=clonglong_STR then
               s:=culonglong_STR
               s:=culonglong_STR
+            else if s=cint8_STR then
+              s:=cuint8_STR
+            else if s=cint16_STR then
+              s:=cuint16_STR 
+            else if s=cint32_STR then
+              s:=cuint32_STR 
+            else if s=cint64_STR then
+              s:=cuint64_STR                
             else
             else
               s:='';          
               s:='';          
           end
           end
@@ -2325,7 +2348,9 @@ special_type_name :
             if s=INT_STR then
             if s=INT_STR then
               s:=UINT_STR
               s:=UINT_STR
             else if s=SHORT_STR then
             else if s=SHORT_STR then
-              s:=USHORT_STR
+              s:=USHORT_STR          
+            else if s=SMALL_STR then
+              s:=USMALL_STR          
             else if s=CHAR_STR then
             else if s=CHAR_STR then
               s:=UCHAR_STR
               s:=UCHAR_STR
             else if s=INT64_STR then
             else if s=INT64_STR then
@@ -2377,15 +2402,43 @@ special_type_name :
      if UseCTypesUnit then
      if UseCTypesUnit then
        $$:=new(presobject,init_id(cshort_STR)) 
        $$:=new(presobject,init_id(cshort_STR)) 
      else      
      else      
-       $$:=new(presobject,init_intid(SHORT_STR));
+       $$:=new(presobject,init_intid(SMALL_STR));
      } |
      } |
      SHORT INT
      SHORT INT
      {
      {
      if UseCTypesUnit then
      if UseCTypesUnit then
        $$:=new(presobject,init_id(csint_STR)) 
        $$:=new(presobject,init_id(csint_STR)) 
      else      
      else      
-       $$:=new(presobject,init_intid(SHORT_STR));
+       $$:=new(presobject,init_intid(SMALL_STR));
      } |
      } |
+     INT8
+     {
+     if UseCTypesUnit then
+       $$:=new(presobject,init_id(cint8_STR)) 
+     else      
+       $$:=new(presobject,init_intid(SHORT_STR));     
+     } |
+     INT16
+     {    
+     if UseCTypesUnit then
+       $$:=new(presobject,init_id(cint16_STR)) 
+     else      
+       $$:=new(presobject,init_intid(SMALL_STR));     
+     } |
+     INT32   
+     {    
+     if UseCTypesUnit then
+       $$:=new(presobject,init_id(cint32_STR)) 
+     else      
+       $$:=new(presobject,init_intid(INT_STR));     
+     } |
+     INT64
+     {   
+     if UseCTypesUnit then
+       $$:=new(presobject,init_id(cint64_STR)) 
+     else      
+       $$:=new(presobject,init_intid(INT64_STR));         
+     } |   
      REAL
      REAL
      {
      {
        $$:=new(presobject,init_intid(REAL_STR));
        $$:=new(presobject,init_intid(REAL_STR));

+ 9 - 0
utils/h2pas/scan.l

@@ -791,6 +791,14 @@ D [0-9]
 "long"                  return(LONG);
 "long"                  return(LONG);
 "signed"                return(SIGNED);
 "signed"                return(SIGNED);
 "unsigned"              return(UNSIGNED);
 "unsigned"              return(UNSIGNED);
+"__int8"                return(INT8);
+"__int16"               return(INT16);
+"__int32"               return(INT32);
+"__int64"               return(INT64);
+"int8"                  return(INT8);
+"int16"                 return(INT16);
+"int32"                 return(INT32);
+"int64"                 return(INT64);
 "float"                 return(REAL);
 "float"                 return(REAL);
 "const"                 return(_CONST);
 "const"                 return(_CONST);
 "CONST"                 return(_CONST);
 "CONST"                 return(_CONST);
@@ -856,3 +864,4 @@ end;
 
 
 end.
 end.
 
 
+