Browse Source

+ implemented support for 64 bit int types
+ options are written now to output file
* improved compact mode
* fixed writing of variables

florian 25 years ago
parent
commit
deb19f0eb6
3 changed files with 341 additions and 252 deletions
  1. 291 240
      utils/h2pas/h2pas.pas
  2. 46 12
      utils/h2pas/h2pas.y
  3. 4 0
      utils/h2pas/testit.h

File diff suppressed because it is too large
+ 291 - 240
utils/h2pas/h2pas.pas


+ 46 - 12
utils/h2pas/h2pas.y

@@ -45,6 +45,8 @@ program h2pas;
      UINT_STR = 'dword';
      UINT_STR = 'dword';
      USHORT_STR = 'word';
      USHORT_STR = 'word';
      CHAR_STR = 'char';
      CHAR_STR = 'char';
+     INT64_STR = 'int64';
+     QWORD_STR = 'qword';
      { should we use byte or char for 'unsigned char' ?? }
      { should we use byte or char for 'unsigned char' ?? }
      UCHAR_STR = 'byte';
      UCHAR_STR = 'byte';
      REAL_STR = 'double';
      REAL_STR = 'double';
@@ -662,7 +664,7 @@ program h2pas;
                       hp1:=p^.p1;
                       hp1:=p^.p1;
                       l:=0;
                       l:=0;
                       lastexpr:=nil;
                       lastexpr:=nil;
-                      Writeln (outfile,aktspace,'Const');
+                      Writeln (outfile,copy(aktspace,1,length(aktspace)-2),'Const');
                       while assigned(hp1) do
                       while assigned(hp1) do
                         begin
                         begin
                            write (outfile,aktspace,hp1^.p1^.p,' = ');
                            write (outfile,aktspace,hp1^.p1^.p,' = ');
@@ -1087,7 +1089,8 @@ declaration :
             shift(2);
             shift(2);
             if block_type<>bt_var then
             if block_type<>bt_var then
               begin
               begin
-                 writeln(outfile);
+                 if not(compactmode) then
+                   writeln(outfile);
                  writeln(outfile,aktspace,'var');
                  writeln(outfile,aktspace,'var');
               end;
               end;
             block_type:=bt_var;
             block_type:=bt_var;
@@ -1109,9 +1112,9 @@ declaration :
                  if assigned(hp^.p1^.p2)and assigned(hp^.p1^.p2^.p)then
                  if assigned(hp^.p1^.p2)and assigned(hp^.p1^.p2^.p)then
                    begin
                    begin
                       if isExtern then
                       if isExtern then
-                        write(outfile,';cvar;external')
+                        write(outfile,';cvar;external ''')
                       else
                       else
-                        write(outfile,';cvar;export');
+                        write(outfile,';cvar;export ''');
                       write(outfile,hp^.p1^.p2^.p);
                       write(outfile,hp^.p1^.p2^.p);
                    end;
                    end;
                  writeln(outfile,''';');
                  writeln(outfile,''';');
@@ -1129,7 +1132,8 @@ declaration :
      {
      {
        if block_type<>bt_type then
        if block_type<>bt_type then
          begin
          begin
-            writeln(outfile);
+            if not(compactmode) then
+              writeln(outfile);
             writeln(outfile,aktspace,'type');
             writeln(outfile,aktspace,'type');
             block_type:=bt_type;
             block_type:=bt_type;
          end;
          end;
@@ -1166,7 +1170,8 @@ declaration :
      {
      {
        if block_type<>bt_type then
        if block_type<>bt_type then
          begin
          begin
-            writeln(outfile);
+            if not(compactmode) then
+              writeln(outfile);
             writeln(outfile,aktspace,'type');
             writeln(outfile,aktspace,'type');
             block_type:=bt_type;
             block_type:=bt_type;
          end;
          end;
@@ -1194,7 +1199,8 @@ declaration :
      {
      {
        if block_type<>bt_type then
        if block_type<>bt_type then
          begin
          begin
-            writeln(outfile);
+            if not(compactmode) then
+              writeln(outfile);
             writeln(outfile,aktspace,'type');
             writeln(outfile,aktspace,'type');
             block_type:=bt_type;
             block_type:=bt_type;
          end;
          end;
@@ -1245,7 +1251,8 @@ declaration :
      {
      {
        if block_type<>bt_type then
        if block_type<>bt_type then
          begin
          begin
-            writeln(outfile);
+            if not(compactmode) then
+              writeln(outfile);
             writeln(outfile,aktspace,'type');
             writeln(outfile,aktspace,'type');
             block_type:=bt_type;
             block_type:=bt_type;
          end;
          end;
@@ -1316,7 +1323,8 @@ declaration :
      {
      {
        if block_type<>bt_type then
        if block_type<>bt_type then
          begin
          begin
-            writeln(outfile);
+            if not(compactmode) then
+              writeln(outfile);
             writeln(outfile,aktspace,'type');
             writeln(outfile,aktspace,'type');
             block_type:=bt_type;
             block_type:=bt_type;
          end;
          end;
@@ -1635,6 +1643,22 @@ special_type_name : INT
      {
      {
        $$:=new(presobject,init_id(INT_STR));
        $$:=new(presobject,init_id(INT_STR));
      } |
      } |
+     LONG LONG INT
+     {
+       $$:=new(presobject,init_id(INT64_STR));
+     } |
+     UNSIGNED LONG LONG INT
+     {
+       $$:=new(presobject,init_id(QWORD_STR));
+     } |
+     LONG LONG
+     {
+       $$:=new(presobject,init_id(INT64_STR));
+     } |
+     UNSIGNED LONG LONG
+     {
+       $$:=new(presobject,init_id(QWORD_STR));
+     } |
      UNSIGNED LONG INT
      UNSIGNED LONG INT
      {
      {
        $$:=new(presobject,init_id(UINT_STR));
        $$:=new(presobject,init_id(UINT_STR));
@@ -2089,6 +2113,7 @@ end;
 
 
 var
 var
   SS : string;
   SS : string;
+  i : longint;
 begin
 begin
 { Initialize }
 { Initialize }
   yydebug:=true;
   yydebug:=true;
@@ -2118,6 +2143,10 @@ begin
      writeln(outfile,aktspace,'interface');
      writeln(outfile,aktspace,'interface');
      writeln(outfile);
      writeln(outfile);
      writeln(outfile,'{ Automatically converted by H2Pas ',version,' from ',inputfilename,' }');
      writeln(outfile,'{ Automatically converted by H2Pas ',version,' from ',inputfilename,' }');
+     writeln(outfile,'{ The following command line parameters were used:');
+     for i:=1 to paramcount do
+       writeln(outfile,'    ',paramstr(i));
+     writeln(outfile,'}');
      writeln(outfile);
      writeln(outfile);
    end;
    end;
   if UseName then
   if UseName then
@@ -2175,7 +2204,13 @@ end.
 
 
 (*
 (*
  $Log$
  $Log$
- Revision 1.6  2000-04-01 14:16:32  peter
+ Revision 1.7  2000-04-01 20:19:38  florian
+   + implemented support for 64 bit int types
+   + options are written now to output file
+   * improved compact mode
+   * fixed writing of variables
+
+ Revision 1.6  2000/04/01 14:16:32  peter
    * addition for another procvar style decl (not working correct yet)
    * addition for another procvar style decl (not working correct yet)
 
 
  Revision 1.5  2000/03/28 06:56:31  michael
  Revision 1.5  2000/03/28 06:56:31  michael
@@ -2218,5 +2253,4 @@ end.
    * all predefined C types
    * all predefined C types
    * misplaced comments
    * misplaced comments
    * handle functions without result
    * handle functions without result
-*)
-
+*)

+ 4 - 0
utils/h2pas/testit.h

@@ -36,3 +36,7 @@ mytype* somefunc (char *firstarg);
 
 
 #define test 0x012345UL
 #define test 0x012345UL
 
 
+extern long long i641;
+extern unsigned long long q641;
+extern long long int i642;
+extern unsigned long long int q642;

Some files were not shown because too many files changed in this diff