diff --git a/utils/h2pas/h2pas.pas b/utils/h2pas/h2pas.pas index 06850ee422..c75c496bd0 100644 --- a/utils/h2pas/h2pas.pas +++ b/utils/h2pas/h2pas.pas @@ -6,7 +6,6 @@ program h2pas; (* - $Id: h2pas.y,v 1.10 2005/02/20 11:09:41 florian Exp $ Copyright (c) 1998-2000 by Florian Klaempfl This program is free software; you can redistribute it and/or modify @@ -42,7 +41,7 @@ program h2pas; UINT_STR = 'dword'; CHAR_STR = 'char'; UCHAR_STR = USHORT_STR; { should we use byte or char for 'unsigned char' ?? } - + INT64_STR = 'int64'; QWORD_STR = 'qword'; REAL_STR = 'double'; @@ -55,22 +54,22 @@ program h2pas; cchar_STR = 'cchar'; cschar_STR = 'cschar'; cuchar_STR = 'cuchar'; - + cint16_STR = 'cint16'; cuint16_STR = 'cuint16'; cshort_STR = 'cshort'; csshort_STR = 'csshort'; cushort_STR = 'cushort'; - + cint32_STR = 'cint32'; cuint32_STR = 'cuint32'; cint_STR = 'cint'; csint_STR = 'csint'; cuint_STR = 'cuint'; - + csigned_STR = 'csigned'; cunsigned_STR = 'cunsigned'; - + cint64_STR = 'cint64'; cuint64_STR = 'cuint64'; clonglong_STR = 'clonglong'; @@ -78,32 +77,32 @@ program h2pas; culonglong_STR = 'culonglong'; cbool_STR = 'cbool'; - + clong_STR = 'clong'; cslong_STR = 'cslong'; culong_STR = 'culong'; - + cfloat_STR = 'cfloat'; cdouble_STR = 'cdouble'; clongdouble_STR = 'clongdouble'; - + const MAX_CTYPESARRAY = 25; CTypesArray : array [0..MAX_CTYPESARRAY] of string = - (cint8_STR, cuint8_STR, + (cint8_STR, cuint8_STR, cchar_STR, cschar_STR, cuchar_STR, - cint16_STR, cuint16_STR, + cint16_STR, cuint16_STR, cshort_STR, csshort_STR, cushort_STR, - csigned_STR, cunsigned_STR, + csigned_STR, cunsigned_STR, cint32_STR, cuint32_STR, cint_STR, - csint_STR, cuint_STR, + csint_STR, cuint_STR, cint64_STR, cuint64_STR, clonglong_STR, cslonglong_STR, culonglong_STR, - - cbool_STR, - clong_STR, cslong_STR, culong_STR); - - + + cbool_STR, + clong_STR, cslong_STR, culong_STR); + + var hp,ph : presobject; implemfile : text; (* file for implementation headers extern procs *) @@ -807,7 +806,7 @@ program h2pas; begin pointerwritten:=false; if (p^.p1=nil) and UsePPointers then - begin + begin if (simple_type^.typ=t_id) then begin write(outfile,PointerName(simple_type^.p)); @@ -2368,7 +2367,7 @@ begin begin s:=strpas(hp^.p); if UseCTypesUnit then - begin + begin if s=cint_STR then s:=csint_STR else if s=cshort_STR then @@ -2376,17 +2375,17 @@ begin else if s=cchar_STR then s:=cschar_STR else if s=clong_STR then - s:=cslong_STR + s:=cslong_STR else if s=clonglong_STR then s:=cslonglong_STR else if s=cint8_STR then s:=cint8_STR else if s=cint16_STR then - s:=cint16_STR + s:=cint16_STR else if s=cint32_STR then - s:=cint32_STR + s:=cint32_STR else if s=cint64_STR then - s:=cint64_STR + s:=cint64_STR else s:=''; end @@ -2395,7 +2394,7 @@ begin if s=UINT_STR then s:=INT_STR 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 @@ -2403,8 +2402,8 @@ begin else if s=QWORD_STR then s:=INT64_STR else - s:=''; - end; + s:=''; + end; if s<>'' then hp^.setstr(s); end; @@ -2432,22 +2431,22 @@ begin else if s=cint8_STR then s:=cuint8_STR else if s=cint16_STR then - s:=cuint16_STR + s:=cuint16_STR else if s=cint32_STR then - s:=cuint32_STR + s:=cuint32_STR else if s=cint64_STR then - s:=cuint64_STR + s:=cuint64_STR else - s:=''; + s:=''; end else begin if s=INT_STR then s:=UINT_STR else if s=SHORT_STR then - s:=USHORT_STR + s:=USHORT_STR else if s=SMALL_STR then - s:=USMALL_STR + s:=USMALL_STR else if s=CHAR_STR then s:=UCHAR_STR else if s=INT64_STR then @@ -2463,89 +2462,89 @@ begin 67 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cint_STR)) - else + yyval:=new(presobject,init_id(cint_STR)) + else yyval:=new(presobject,init_intid(INT_STR)); end; 68 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(clong_STR)) - else + yyval:=new(presobject,init_id(clong_STR)) + else yyval:=new(presobject,init_intid(INT_STR)); end; 69 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(clong_STR)) - else + yyval:=new(presobject,init_id(clong_STR)) + else yyval:=new(presobject,init_intid(INT_STR)); end; 70 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(clonglong_STR)) - else + yyval:=new(presobject,init_id(clonglong_STR)) + else yyval:=new(presobject,init_intid(INT64_STR)); end; 71 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(clonglong_STR)) - else + yyval:=new(presobject,init_id(clonglong_STR)) + else yyval:=new(presobject,init_intid(INT64_STR)); end; 72 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cshort_STR)) - else + yyval:=new(presobject,init_id(cshort_STR)) + else yyval:=new(presobject,init_intid(SMALL_STR)); end; 73 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(csint_STR)) - else + yyval:=new(presobject,init_id(csint_STR)) + else yyval:=new(presobject,init_intid(SMALL_STR)); end; 74 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cint8_STR)) - else - yyval:=new(presobject,init_intid(SHORT_STR)); + yyval:=new(presobject,init_id(cint8_STR)) + else + yyval:=new(presobject,init_intid(SHORT_STR)); end; 75 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cint16_STR)) - else - yyval:=new(presobject,init_intid(SMALL_STR)); + yyval:=new(presobject,init_id(cint16_STR)) + else + yyval:=new(presobject,init_intid(SMALL_STR)); end; 76 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cint32_STR)) - else - yyval:=new(presobject,init_intid(INT_STR)); + yyval:=new(presobject,init_id(cint32_STR)) + else + yyval:=new(presobject,init_intid(INT_STR)); end; 77 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cint64_STR)) - else - yyval:=new(presobject,init_intid(INT64_STR)); + yyval:=new(presobject,init_id(cint64_STR)) + else + yyval:=new(presobject,init_intid(INT64_STR)); end; 78 : begin @@ -2561,7 +2560,7 @@ begin 80 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cchar_STR)) + yyval:=new(presobject,init_id(cchar_STR)) else yyval:=new(presobject,init_intid(CHAR_STR)); @@ -2569,8 +2568,8 @@ begin 81 : begin if UseCTypesUnit then - yyval:=new(presobject,init_id(cunsigned_STR)) - else + yyval:=new(presobject,init_id(cunsigned_STR)) + else yyval:=new(presobject,init_intid(UINT_STR)); end; @@ -9250,4 +9249,4 @@ begin PTypeList.Free; freedynlibproc.free; loaddynlibproc.free; -end. +end. \ No newline at end of file diff --git a/utils/h2pas/scan.pas b/utils/h2pas/scan.pas index d1196aafde..8e6977c7ad 100644 --- a/utils/h2pas/scan.pas +++ b/utils/h2pas/scan.pas @@ -3,7 +3,6 @@ (* global definitions: *) { - $Id: scan.l,v 1.7 2004/09/08 22:21:41 carl Exp $ Copyright (c) 1998-2000 by Florian Klaempfl This program is free software; you can redistribute it and/or modify @@ -219,8 +218,8 @@ type > -1 = ifdef sublevel in an else block. } cplusblocklevel : LongInt = 0; - - + + function yylex : integer; function act_token : string; procedure internalerror(i : integer); @@ -331,7 +330,7 @@ type begin NotInCPlusBlock := cplusblocklevel < 1; end; - + constructor tresobject.init_preop(const s : string;_p1 : presobject); begin typ:=t_preop; @@ -498,7 +497,7 @@ begin (* actions: *) case yyruleno of 1: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not stripcomment then write(outfile,aktspace,'{'); @@ -551,10 +550,10 @@ begin until false; flush(outfile); end - else + else skip_until_eol; 2: - if NotInCPlusBlock then + if NotInCPlusBlock then begin commentstr:=''; if (in_define) and not (stripcomment) then @@ -608,14 +607,14 @@ begin until false; flush(outfile); end - else + else skip_until_eol; 3: if NotInCPlusBlock then return(CSTRING) else skip_until_eol; 4: if NotInCPlusBlock then return(CSTRING) else skip_until_eol; 5: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if win32headers then return(CSTRING) @@ -624,7 +623,7 @@ begin end else skip_until_eol; 6: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if win32headers then return(CSTRING) @@ -634,7 +633,7 @@ begin else skip_until_eol; 7: - if NotInCPlusBlock then + if NotInCPlusBlock then begin while yytext[length(yytext)] in ['L','U','l','u'] do Delete(yytext,length(yytext),1); @@ -643,7 +642,7 @@ begin else skip_until_eol; 8: - if NotInCPlusBlock then + if NotInCPlusBlock then begin (* handle pre- and postfixes *) if copy(yytext,1,2)='0x' then @@ -659,21 +658,21 @@ begin skip_until_eol; 9: - if NotInCPlusBlock then + if NotInCPlusBlock then begin return(NUMBER); end - else + else skip_until_eol; 10: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if in_define then return(DEREF) else return(256); end - else + else skip_until_eol; 11: if NotInCPlusBlock then return(MINUS) else skip_until_eol; @@ -718,27 +717,27 @@ begin 31: if NotInCPlusBlock then return(RECKKLAMMER) else skip_until_eol; 32: - if NotInCPlusBlock then - begin + if NotInCPlusBlock then + begin inc(arglevel); return(LKLAMMER); end else skip_until_eol; 33: - if NotInCPlusBlock then + if NotInCPlusBlock then begin dec(arglevel); return(RKLAMMER); end - else + else skip_until_eol; 34: if NotInCPlusBlock then return(STAR) else skip_until_eol; 35: if NotInCPlusBlock then return(ELLIPSIS) else skip_until_eol; 36: - if NotInCPlusBlock then + if NotInCPlusBlock then if in_define then return(POINT) else @@ -748,7 +747,7 @@ begin 38: if NotInCPlusBlock then return(EXTERN) else skip_until_eol; 39: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if Win32headers then return(STDCALL) @@ -758,10 +757,10 @@ begin else begin skip_until_eol; - end; + end; 40: if NotInCPlusBlock then - begin + begin if not Win32headers then return(ID) else @@ -770,9 +769,9 @@ begin else begin skip_until_eol; - end; + end; 41: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not Win32headers then return(ID) @@ -782,9 +781,9 @@ begin else begin skip_until_eol; - end; + end; 42: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not Win32headers then return(ID) @@ -796,7 +795,7 @@ begin skip_until_eol; end; 43: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not Win32headers then return(ID) @@ -806,9 +805,9 @@ begin else begin skip_until_eol; - end; + end; 44: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not palmpilot then return(ID) @@ -818,9 +817,9 @@ begin else begin skip_until_eol; - end; + end; 45: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not Win32headers then return(ID) @@ -832,8 +831,8 @@ begin skip_until_eol; end; 46: - if NotInCPlusBlock then - begin + if NotInCPlusBlock then + begin if not Win32headers then return(ID) else @@ -844,7 +843,7 @@ begin skip_until_eol; end; 47: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if not Win32headers then return(ID) @@ -870,7 +869,7 @@ begin begin if not stripinfo then writeln(outfile,'{ C++ extern C conditionnal removed }'); - end; + end; 52: begin @@ -882,32 +881,32 @@ begin begin if not stripinfo then writeln(outfile,'{ C++ end of extern C conditionnal removed }'); - end; + end; 54: begin Inc(cplusblocklevel); - end; + end; 55: begin Inc(cplusblocklevel); - end; + end; 56: begin if cplusblocklevel > 0 then Inc(cplusblocklevel) else - begin + begin if cplusblocklevel < 0 then Dec(cplusblocklevel); write(outfile,'{$ifdef '); copy_until_eol; writeln(outfile,'}'); - flush(outfile); + flush(outfile); end; - end; + end; 57: begin if cplusblocklevel < -1 then @@ -922,7 +921,7 @@ begin begin writeln(outfile,'{$else}'); block_type:=bt_no; - flush(outfile); + flush(outfile); end; 1 : cplusblocklevel := -1; -1 : cplusblocklevel := 1; @@ -940,7 +939,7 @@ begin 0 : begin writeln(outfile,'{$endif}'); block_type:=bt_no; - flush(outfile); + flush(outfile); end; -1 : begin cplusblocklevel :=0; @@ -973,11 +972,11 @@ begin copy_until_eol; writeln(outfile,'}'); block_type:=bt_no; - flush(outfile); + flush(outfile); end; 1 : cplusblocklevel := -1; -1 : cplusblocklevel := 1; - end; + end; end; 60: begin @@ -1009,7 +1008,7 @@ begin if cplusblocklevel > 0 then Inc(cplusblocklevel) else - begin + begin if cplusblocklevel < 0 then Dec(cplusblocklevel); write(outfile,'{$if'); @@ -1018,7 +1017,7 @@ begin flush(outfile); block_type:=bt_no; end; - end; + end; 64: if NotInCPlusBlock then (* preprocessor line info *) @@ -1083,7 +1082,7 @@ begin 77: if NotInCPlusBlock then return(SIGNED) else skip_until_eol; 78: - if NotInCPlusBlock then return(UNSIGNED) else skip_until_eol; + if NotInCPlusBlock then return(UNSIGNED) else skip_until_eol; 79: if NotInCPlusBlock then return(INT8) else skip_until_eol; 80: @@ -1121,18 +1120,18 @@ begin 96: if NotInCPlusBlock then return(_WHILE) else skip_until_eol; 97: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if in_space_define=1 then in_space_define:=2; return(ID); end - else + else skip_until_eol; 98: if NotInCPlusBlock then return(SEMICOLON) else skip_until_eol; 99: - if NotInCPlusBlock then + if NotInCPlusBlock then begin if (arglevel=0) and (in_space_define=2) then begin @@ -1154,10 +1153,10 @@ begin else begin in_define:=false; - if NotInCPlusBlock then + if NotInCPlusBlock then return(NEW_LINE) else - skip_until_eol + skip_until_eol end; end; end;