Normalize RecordFields before conversion. Helps with namespaces problem.
authorunc0rr
Wed, 04 Apr 2012 15:05:14 +0400
changeset 6854 873929cbd54b
parent 6853 affeaba0af71
child 6855 807156c01475
Normalize RecordFields before conversion. Helps with namespaces problem.
hedgewars/pas2cSystem.pas
hedgewars/uChat.pas
tools/pas2c.hs
--- a/hedgewars/pas2cSystem.pas	Tue Apr 03 17:53:33 2012 +0400
+++ b/hedgewars/pas2cSystem.pas	Wed Apr 04 15:05:14 2012 +0400
@@ -94,8 +94,11 @@
     gldeletetextures, glreadpixels : procedure;
 
     TThreadId : function : integer;
-    ThreadSwitch : procedure;
+    BeginThread, ThreadSwitch : procedure;
+    InterlockedIncrement, InterlockedDecrement : procedure;
     
     random : function : integer;
     
     Assigned : function : boolean;
+    
+
--- a/hedgewars/uChat.pas	Tue Apr 03 17:53:33 2012 +0400
+++ b/hedgewars/uChat.pas	Wed Apr 04 15:05:14 2012 +0400
@@ -361,7 +361,7 @@
 procedure chHistory(var s: shortstring);
 begin
     s:= s; // avoid compiler hint
-    uChat.showAll:= not uChat.showAll
+    showAll:= not showAll
 end;
 
 procedure chChat(var s: shortstring);
--- a/tools/pas2c.hs	Tue Apr 03 17:53:33 2012 +0400
+++ b/tools/pas2c.hs	Wed Apr 04 15:05:14 2012 +0400
@@ -115,8 +115,8 @@
     toCFiles' p
     where
     toCFiles' (fn, p@(Program {})) = writeFile (fn ++ ".c") $ (render2C initialState . pascal2C) p
-    toCFiles' (fn, (Unit _ interface implementation _ _)) = do
-        let (a, s) = runState (interface2C interface) initialState
+    toCFiles' (fn, (Unit unitId interface implementation _ _)) = do
+        let (a, s) = runState (id2C IOInsert (setBaseType BTUnit unitId) >> interface2C interface) initialState
         writeFile (fn ++ ".h") $ "#pragma once\n" ++ (render a)
         writeFile (fn ++ ".c") $ (render2C s . implementation2C) implementation
     initialState = emptyState ns
@@ -451,6 +451,11 @@
 
 
 ref2C :: Reference -> State RenderState Doc
+-- rewrite into proper form
+ref2C r@(RecordField ref1 (ArrayElement exprs ref2)) = ref2C $ ArrayElement exprs (RecordField ref1 ref2)
+ref2C r@(RecordField ref1 (Dereference ref2)) = ref2C $ Dereference (RecordField ref1 ref2)
+ref2C r@(RecordField ref1 (RecordField ref2 ref3)) = ref2C $ RecordField (RecordField ref1 ref2) ref3
+-- conversion routines
 ref2C ae@(ArrayElement exprs ref) = do
     es <- mapM expr2C exprs
     r <- ref2C ref