# HG changeset patch # User unc0rr # Date 1336681686 -14400 # Node ID 7c080e5ac8d05ed175ee9b6b16e2ac3b35750951 # Parent de20086a6bcc01312b50063d4195abb6e2c4e054 Some work to make more units compile after conversion to c diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/LuaPas.pas --- a/hedgewars/LuaPas.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/LuaPas.pas Fri May 11 00:28:06 2012 +0400 @@ -10,9 +10,8 @@ *) interface - +uses uConsts; {.$DEFINE LUA_GETHOOK} -{$INCLUDE "config.inc"} type size_t = Cardinal; diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/Types.h diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/pas2c.h --- a/hedgewars/pas2c.h Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/pas2c.h Fri May 11 00:28:06 2012 +0400 @@ -38,8 +38,10 @@ typedef LongInt Integer; typedef float extended; typedef float real; +typedef float single; typedef bool boolean; +typedef int LongBool; typedef void * pointer; typedef Byte * PByte; @@ -72,6 +74,7 @@ string255 _strappend(string255 s, char c); string255 _strprepend(char c, string255 s); bool _strcompare(string255 a, string255 b); +bool _strncompare(string255 a, string255 b); char * _pchar(string255 s); int Length(string255 a); @@ -81,6 +84,7 @@ #define STRINIT(a) {.len = sizeof(a) - 1, .str = a} typedef int file; +typedef int TextFile; extern int FileMode; extern int IOResult; @@ -108,3 +112,4 @@ double sqr(double n); double sqrt(double n); int trunc(double n); +int round(double n); diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uFloat.pas Fri May 11 00:28:06 2012 +0400 @@ -63,7 +63,9 @@ // The implemented operators operator = (const z1, z2: hwFloat) z : boolean; inline; +{$IFDEF PAS2C} operator <> (const z1, z2: hwFloat) z : boolean; inline; +{$ENDIF} operator + (const z1, z2: hwFloat) z : hwFloat; inline; operator - (const z1, z2: hwFloat) z : hwFloat; inline; operator - (const z1: hwFloat) z : hwFloat; inline; @@ -213,12 +215,12 @@ z:= (z1.isNegative = z2.isNegative) and (z1.QWordValue = z2.QWordValue); end; - +{$IFDEF PAS2C} operator <> (const z1, z2: hwFloat) z : boolean; inline; begin z:= (z1.isNegative <> z2.isNegative) or (z1.QWordValue <> z2.QWordValue); end; - +{$ENDIF} operator + (const z1, z2: hwFloat) z : hwFloat; begin diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uLandPainted.pas --- a/hedgewars/uLandPainted.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uLandPainted.pas Fri May 11 00:28:06 2012 +0400 @@ -130,7 +130,7 @@ rec.X:= SDLNet_Read16(@rec.X); rec.Y:= SDLNet_Read16(@rec.Y); - pe:= new(PPointEntry); + new(pe); if pointsListLast = nil then pointsListHead:= pe else diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uMisc.pas Fri May 11 00:28:06 2012 +0400 @@ -37,7 +37,7 @@ {$ENDIF} implementation -uses typinfo, sysutils, uVariables, uUtils +uses SysUtils, uVariables, uUtils {$IFDEF PNG_SCREENSHOTS}, PNGh, png {$ENDIF} {$IFNDEF USE_SDLTHREADS} {$IFDEF UNIX}, cthreads{$ENDIF} {$ENDIF}; diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uRandom.pas --- a/hedgewars/uRandom.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uRandom.pas Fri May 11 00:28:06 2012 +0400 @@ -29,7 +29,6 @@ *) interface uses uFloat; -{$INCLUDE "config.inc"} procedure initModule; procedure freeModule; diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uSound.pas Fri May 11 00:28:06 2012 +0400 @@ -33,7 +33,7 @@ * The channel id can be used to stop a specific sound loop. *) interface -uses SDLh, uConsts, uTypes, sysutils; +uses SDLh, uConsts, uTypes, SysUtils; procedure initModule; procedure freeModule; diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uStore.pas Fri May 11 00:28:06 2012 +0400 @@ -21,7 +21,7 @@ unit uStore; interface -uses sysutils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat; +uses SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat; procedure initModule; procedure freeModule; diff -r de20086a6bcc -r 7c080e5ac8d0 hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Thu May 10 23:51:05 2012 +0400 +++ b/hedgewars/uUtils.pas Fri May 11 00:28:06 2012 +0400 @@ -70,7 +70,7 @@ implementation -uses typinfo, Math, uConsts, uVariables, SysUtils; +uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, SysUtils; {$IFDEF DEBUGFILE} var f: textfile; diff -r de20086a6bcc -r 7c080e5ac8d0 tools/PascalParser.hs --- a/tools/PascalParser.hs Thu May 10 23:51:05 2012 +0400 +++ b/tools/PascalParser.hs Fri May 11 00:28:06 2012 +0400 @@ -382,13 +382,13 @@ , Infix (char '>' >> return (BinOp ">")) AssocNone , Infix (char '=' >> return (BinOp "=")) AssocNone ] + , [ Infix (try $ string "shl" >> return (BinOp "shl")) AssocNone + , Infix (try $ string "shr" >> return (BinOp "shr")) AssocNone + ] , [ Infix (try $ string "and" >> return (BinOp "and")) AssocLeft , Infix (try $ string "or" >> return (BinOp "or")) AssocLeft , Infix (try $ string "xor" >> return (BinOp "xor")) AssocLeft ] - , [ Infix (try $ string "shl" >> return (BinOp "shl")) AssocNone - , Infix (try $ string "shr" >> return (BinOp "shr")) AssocNone - ] ] phrasesBlock = do diff -r de20086a6bcc -r 7c080e5ac8d0 tools/pas2c.hs --- a/tools/pas2c.hs Thu May 10 23:51:05 2012 +0400 +++ b/tools/pas2c.hs Fri May 11 00:28:06 2012 +0400 @@ -692,7 +692,10 @@ expr2C (HexNumber s) = return $ text "0x" <> (text . map toLower $ s) expr2C (StringLiteral [a]) = do modify(\s -> s{lastType = BTChar}) - return . quotes $ text [a] + return . quotes . text $ escape a + where + escape '\'' = "\\\'" + escape a = [a] expr2C (StringLiteral s) = addStringConst s expr2C (Reference ref) = ref2CF ref expr2C (PrefixOp op expr) = do