浏览代码

* more fixes that were still laying around

peter 24 年之前
父节点
当前提交
efb19714f0
共有 3 个文件被更改,包括 419 次插入312 次删除
  1. 322 282
      utils/h2pas/h2pas.pas
  2. 70 30
      utils/h2pas/h2pas.y
  3. 27 0
      utils/h2pas/testit.h

文件差异内容过多而无法显示
+ 322 - 282
utils/h2pas/h2pas.pas


+ 70 - 30
utils/h2pas/h2pas.y

@@ -147,9 +147,10 @@ program h2pas;
           'F' : b:=(up='FUNCTION') or (up='FALSE');
           'F' : b:=(up='FUNCTION') or (up='FALSE');
           'N' : b:=(up='NEW');
           'N' : b:=(up='NEW');
           'P' : b:=(up='PROPERTY') or (up='PROCEDURE');
           'P' : b:=(up='PROPERTY') or (up='PROCEDURE');
-          'R' : b:=(up='RECORD');
+          'R' : b:=(up='RECORD') or (up='REPEAT');
           'S' : b:=(up='STRING');
           'S' : b:=(up='STRING');
           'T' : b:=(up='TYPE') or (up='TRUE');
           'T' : b:=(up='TYPE') or (up='TRUE');
+          'U' : b:=(up='UNTIL');
         end;
         end;
         if b then
         if b then
          FixId:='_'+s
          FixId:='_'+s
@@ -509,14 +510,15 @@ program h2pas;
 
 
     procedure write_args(var outfile:text; p : presobject);
     procedure write_args(var outfile:text; p : presobject);
       var
       var
-         length,para : longint;
+         len,para : longint;
          old_in_args : boolean;
          old_in_args : boolean;
          varpara : boolean;
          varpara : boolean;
          lastp : presobject;
          lastp : presobject;
+         hs : string;
       begin
       begin
          NeedEllipsisOverload:=false;
          NeedEllipsisOverload:=false;
          para:=1;
          para:=1;
-         length:=0;
+         len:=0;
          lastp:=nil;
          lastp:=nil;
          old_in_args:=in_args;
          old_in_args:=in_args;
          in_args:=true;
          in_args:=true;
@@ -569,26 +571,27 @@ program h2pas;
                    if varpara then
                    if varpara then
                      begin
                      begin
                         write(outfile,'var ');
                         write(outfile,'var ');
-                        length:=length+4;
+                        inc(len,4);
                      end;
                      end;
 
 
-                   (* write new type name *)
+                   (* write new parameter name *)
                    if assigned(p^.p1^.p2^.p2) then
                    if assigned(p^.p1^.p2^.p2) then
                      begin
                      begin
-                        write(outfile,p^.p1^.p2^.p2^.p);
-                        length:=length+p^.p1^.p2^.p2^.strlength;
+                        hs:=FixId(p^.p1^.p2^.p2^.p);
+                        write(outfile,hs);
+                        inc(len,length(hs));
                      end
                      end
                    else
                    else
                      begin
                      begin
                        If removeUnderscore then
                        If removeUnderscore then
                          begin
                          begin
                            Write (outfile,'para',para);
                            Write (outfile,'para',para);
-                           inc(Length,5);
+                           inc(Len,5);
                          end
                          end
                        else
                        else
                          begin
                          begin
                            write(outfile,'_para',para);
                            write(outfile,'_para',para);
-                           inc(Length,6);
+                           inc(Len,6);
                          end;
                          end;
                      end;
                      end;
                    write(outfile,':');
                    write(outfile,':');
@@ -603,7 +606,7 @@ program h2pas;
               if assigned(p) then
               if assigned(p) then
                 begin
                 begin
                    write(outfile,'; ');
                    write(outfile,'; ');
-                   { if length>40 then : too complicated to compute }
+                   { if len>40 then : too complicated to compute }
                    if (para mod 5) = 0 then
                    if (para mod 5) = 0 then
                      begin
                      begin
                         writeln(outfile);
                         writeln(outfile);
@@ -701,25 +704,33 @@ program h2pas;
                            end;
                            end;
             t_arraydef : begin
             t_arraydef : begin
                              constant:=false;
                              constant:=false;
-                             if p^.p2^.typ=t_id then
-                               begin
-                                  val(p^.p2^.str,i,error);
-                                  if error=0 then
+                             if assigned(p^.p2) then
+                              begin
+                                if p^.p2^.typ=t_id then
+                                 begin
+                                   val(p^.p2^.str,i,error);
+                                   if error=0 then
                                     begin
                                     begin
-                                       dec(i);
-                                       constant:=true;
+                                      dec(i);
+                                      constant:=true;
                                     end;
                                     end;
-                               end;
-                             if not constant then
-                               begin
-                                  write(outfile,'array[0..(');
-                                  write_expr(outfile,p^.p2);
-                                  write(outfile,')-1] of ');
-                               end
+                                 end;
+                                if not constant then
+                                 begin
+                                   write(outfile,'array[0..(');
+                                   write_expr(outfile,p^.p2);
+                                   write(outfile,')-1] of ');
+                                 end
+                                else
+                                 begin
+                                   write(outfile,'array[0..',i,'] of ');
+                                 end;
+                              end
                              else
                              else
-                               begin
-                                  write(outfile,'array[0..',i,'] of ');
-                               end;
+                              begin
+                                (* open array *)
+                                write(outfile,'array of ');
+                              end;
                              flush(outfile);
                              flush(outfile);
                              write_p_a_def(outfile,p^.p1,simple_type);
                              write_p_a_def(outfile,p^.p1,simple_type);
                           end;
                           end;
@@ -1056,7 +1067,7 @@ program h2pas;
                            hp1:=p^.p1;
                            hp1:=p^.p1;
                            while assigned(hp1) do
                            while assigned(hp1) do
                              begin
                              begin
-                                write(outfile,hp1^.p1^.p);
+                                write(outfile,FixId(hp1^.p1^.p));
                                 hp1:=hp1^.next;
                                 hp1:=hp1^.next;
                                 if assigned(hp1) then
                                 if assigned(hp1) then
                                   write(outfile,',')
                                   write(outfile,',')
@@ -1938,6 +1949,9 @@ argument_declaration_list : argument_declaration
      ELLIPSIS
      ELLIPSIS
      {
      {
        $$:=new(presobject,init_two(t_arglist,ellipsisarg,nil));
        $$:=new(presobject,init_two(t_arglist,ellipsisarg,nil));
+     } |
+     {
+       $$:=nil;
      }
      }
      ;
      ;
 
 
@@ -2026,7 +2040,19 @@ declarator :
          hp:=hp^.p1;
          hp:=hp^.p1;
        hp^.p1:=new(presobject,init_two(t_arraydef,nil,$3));
        hp^.p1:=new(presobject,init_two(t_arraydef,nil,$3));
      } |
      } |
-     LKLAMMER declarator RKLAMMER { $$:=$2; }
+     declarator LECKKLAMMER RECKKLAMMER
+     {
+       (* this is translated into a pointer *)
+       hp:=$1;
+       $$:=hp;
+       while assigned(hp^.p1) do
+         hp:=hp^.p1;
+       hp^.p1:=new(presobject,init_two(t_arraydef,nil,nil));
+     } |
+     LKLAMMER declarator RKLAMMER
+     {
+       $$:=$2;
+     }
      ;
      ;
 
 
 no_arg : LKLAMMER RKLAMMER |
 no_arg : LKLAMMER RKLAMMER |
@@ -2082,8 +2108,19 @@ abstract_declarator :
          hp:=hp^.p1;
          hp:=hp^.p1;
        hp^.p1:=new(presobject,init_two(t_arraydef,nil,$3));
        hp^.p1:=new(presobject,init_two(t_arraydef,nil,$3));
      } |
      } |
+     declarator LECKKLAMMER RECKKLAMMER
+     {
+       (* this is translated into a pointer *)
+       hp:=$1;
+       $$:=hp;
+       while assigned(hp^.p1) do
+         hp:=hp^.p1;
+       hp^.p1:=new(presobject,init_two(t_arraydef,nil,nil));
+     } |
      LKLAMMER abstract_declarator RKLAMMER
      LKLAMMER abstract_declarator RKLAMMER
-     { $$:=$2; } |
+     {
+       $$:=$2;
+     } |
      {
      {
        $$:=new(presobject,init_two(t_dec,nil,nil));
        $$:=new(presobject,init_two(t_dec,nil,nil));
      }
      }
@@ -2404,7 +2441,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2000-12-27 21:59:59  peter
+  Revision 1.3  2001-04-10 21:22:38  peter
+    * more fixes that were still laying around
+
+  Revision 1.2  2000/12/27 21:59:59  peter
     * big update, it now converts much more files without serious errors
     * big update, it now converts much more files without serious errors
     + h2pas preprocessor to remove specific defines from a .h file
     + h2pas preprocessor to remove specific defines from a .h file
       (you need to run h2paspp manual)
       (you need to run h2paspp manual)

+ 27 - 0
utils/h2pas/testit.h

@@ -43,3 +43,30 @@ extern unsigned long long int q642;
 
 
 typedef DWORD (WINAPI *LPTHREAD_START_ROUTINE)(LPVOID);
 typedef DWORD (WINAPI *LPTHREAD_START_ROUTINE)(LPVOID);
 typedef DWORD(WINAPI *LPPROGRESS_ROUTINE)(LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,DWORD,DWORD,HANDLE,HANDLE,LPVOID);
 typedef DWORD(WINAPI *LPPROGRESS_ROUTINE)(LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,DWORD,DWORD,HANDLE,HANDLE,LPVOID);
+
+typedef Status (*XcmsConversionProc)();
+
+typedef XrmHashTable XrmSearchList[];
+
+#define XrmStringToRepresentation(string)   XrmStringToQuark(string)
+#define XrmRepresentationToString(type)   XrmQuarkToString(type)
+
+typedef struct _XRenderPictureAttributes {
+    Bool                repeat;
+    Picture             alpha_map;
+    int                 alpha_x_origin;
+    int                 alpha_y_origin;
+    int                 clip_x_origin;
+    int                 clip_y_origin;
+    Pixmap              clip_mask;
+    Bool                graphics_exposures;
+    int                 subwindow_mode;
+    int                 poly_edge;
+    int                 poly_mode;
+    Atom                dither;
+} XRenderPictureAttributes;
+
+void   gdk_gc_set_dashes          (GdkGC            *gc,
+                                   gint              dash_offset,
+                                   gint8             dash_list[],
+                                   gint              n);

部分文件因为文件数量过多而无法显示