Some work to make more units compile after conversion to c
authorunc0rr
Fri, 11 May 2012 00:28:06 +0400
changeset 7043 7c080e5ac8d0
parent 7042 de20086a6bcc
child 7044 46cb4e8cedfb
Some work to make more units compile after conversion to c
hedgewars/LuaPas.pas
hedgewars/Types.h
hedgewars/pas2c.h
hedgewars/uFloat.pas
hedgewars/uLandPainted.pas
hedgewars/uMisc.pas
hedgewars/uRandom.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uUtils.pas
tools/PascalParser.hs
tools/pas2c.hs
--- 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;
--- 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);
--- 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
--- 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
--- 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};
 
--- 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;
--- 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;
--- 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;
--- 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;
--- 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
--- 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