summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2009-05-14 01:46:41 +0200
committerAndreas Rumpf <rumpf_a@web.de>2009-05-14 01:46:41 +0200
commit0e9d65e4abf949b00cd00546cb772de4e49f8369 (patch)
tree9d733047878867d469f34b2da41315dc645f09cb
parent233687adf7613305664d9e02c5f37e898f7ba255 (diff)
downloadNim-0e9d65e4abf949b00cd00546cb772de4e49f8369.tar.gz
some bugfixes
-rw-r--r--lib/posix/posix.nim26
-rw-r--r--nim/ccgtypes.pas15
-rw-r--r--nim/cgen.pas8
-rw-r--r--tests/sdltest.nim4
-rw-r--r--tools/niminstbin295608 -> 295720 bytes
5 files changed, 34 insertions, 19 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index 570c24980..e71e8a003 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -400,11 +400,6 @@ when hasSpawnH:
                                  header: "<spawn.h>".} = cint 

 

 type
-  Tif_nameindex* {.importc: "struct if_nameindex", final, 
-                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
-    if_index*: cint   ## Numeric index of the interface. 
-    if_name*: cstring ## Null-terminated name of the interface. 
-
   TSocklen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cint
   TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cint
   
@@ -418,6 +413,12 @@ type
                        pure, final.} = object ## struct sockaddr_storage
     ss_family*: Tsa_family ## Address family. 
 
+  Tif_nameindex* {.importc: "struct if_nameindex", final, 
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cint   ## Numeric index of the interface. 
+    if_name*: cstring ## Null-terminated name of the interface. 
+
+
   TIOVec* {.importc: "struct iovec", pure, final,
             header: "<sys/uio.h>".} = object ## struct iovec
     iov_base*: pointer ## Base address of a memory region for input or output. 
@@ -1442,8 +1443,6 @@ var
   SEEK_CUR* {.importc, header: "<unistd.h>".}: cint

   SEEK_END* {.importc, header: "<unistd.h>".}: cint

 
-  IF_NAMESIZE* {.importc, header: "<net/if.h>".}: cint
-
   SCM_RIGHTS* {.importc, header: "<sys/socket.h>".}: cint
     ## Indicates that the data array contains the access rights 
     ## to be sent or received. 
@@ -1525,6 +1524,8 @@ var
     ## Disables further send and receive operations.
   SHUT_WR* {.importc, header: "<sys/socket.h>".}: cint
     ## Disables further send operations. 
+
+  IF_NAMESIZE* {.importc, header: "<net/if.h>".}: cint
     
   IPPROTO_IP* {.importc, header: "<netinet/in.h>".}: cint
     ## Internet protocol.
@@ -2288,11 +2289,6 @@ proc makecontext*(a1: var Tucontext, a4: proc (){.noconv.}, a3: cint) {.
   varargs, importc, header: "<ucontext.h>".}

 proc setcontext*(a1: var Tucontext): cint {.importc, header: "<ucontext.h>".}

 proc swapcontext*(a1, a2: var Tucontext): cint {.importc, header: "<ucontext.h>".}

-proc if_nametoindex*(a1: cstring): cint {.importc, header: "<net/if.h>".}
-proc if_indextoname*(a1: cint, a2: cstring): cstring {.
-  importc, header: "<net/if.h>".}
-proc if_nameindex*(): ptr Tif_nameindex {.importc, header: "<net/if.h>".}
-proc if_freenameindex*(a1: ptr Tif_nameindex) {.importc, header: "<net/if.h>".}
 
 proc readv*(a1: cint, a2: ptr TIOVec, a3: cint): int {.
   importc, header: "<sys/uio.h>".}
@@ -2351,6 +2347,12 @@ proc sockatmark*(a1: cint): cint {.
 proc socketpair*(a1, a2, a3: cint, a4: var array[0..1, cint]): cint {.
   importc, header: "<sys/socket.h>".}
 
+proc if_nametoindex*(a1: cstring): cint {.importc, header: "<net/if.h>".}
+proc if_indextoname*(a1: cint, a2: cstring): cstring {.
+  importc, header: "<net/if.h>".}
+proc if_nameindex*(): ptr Tif_nameindex {.importc, header: "<net/if.h>".}
+proc if_freenameindex*(a1: ptr Tif_nameindex) {.importc, header: "<net/if.h>".}
+
 proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr TIn6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Unspecified address.
diff --git a/nim/ccgtypes.pas b/nim/ccgtypes.pas
index ee7388e1c..600065078 100644
--- a/nim/ccgtypes.pas
+++ b/nim/ccgtypes.pas
@@ -148,6 +148,12 @@ begin
   end
 end;
 
+function mapReturnType(typ: PType): TCTypeKind;
+begin
+  if skipGeneric(typ).kind = tyArray then result := ctPtr
+  else result := mapType(typ)
+end;
+
 function getTypeDescAux(m: BModule; typ: PType;
                         var check: TIntSet): PRope; forward;
 
@@ -232,7 +238,8 @@ procedure fillResult(param: PSym);
 begin
   fillLoc(param.loc, locParam, param.typ, ropeff('Result', '%Result', []), 
           OnStack);
-  if (mapType(param.typ) <> ctArray) and IsInvalidReturnType(param.typ) then
+  if (mapReturnType(param.typ) <> ctArray) 
+  and IsInvalidReturnType(param.typ) then
   begin
     include(param.loc.flags, lfIndirect);
     param.loc.s := OnUnknown
@@ -277,8 +284,10 @@ begin
   end;
   if (t.sons[0] <> nil) and isInvalidReturnType(t.sons[0]) then begin
     if params <> nil then app(params, ', ');
-    app(params, getTypeDescAux(m, t.sons[0], check));
-    if (mapType(t.sons[0]) <> ctArray) or (gCmd = cmdCompileToLLVM) then 
+    arr := t.sons[0];
+    //if skipGeneric(arr).kind = tyArray then arr := arr.sons[1];
+    app(params, getTypeDescAux(m, arr, check));
+    if (mapReturnType(t.sons[0]) <> ctArray) or (gCmd = cmdCompileToLLVM) then 
       app(params, '*'+'');
     appff(params, ' Result', ' @Result', []);
   end;
diff --git a/nim/cgen.pas b/nim/cgen.pas
index ed12d3d8e..6a0ab0390 100644
--- a/nim/cgen.pas
+++ b/nim/cgen.pas
@@ -249,12 +249,12 @@ procedure UseMagic(m: BModule; const name: string); forward;
 {$include 'ccgtypes.pas'}
 
 // ------------------------------ Manager of temporaries ------------------
-
+(*
 function beEqualTypes(a, b: PType): bool;
 begin
   // returns whether two type are equal for the backend
   result := sameType(skipGenericRange(a), skipGenericRange(b))
-end;
+end; *)
 
 procedure getTemp(p: BProc; t: PType; var result: TLoc);
 begin
@@ -642,6 +642,10 @@ begin
     else begin
       fillResult(res);
       assignParam(p, res);
+      if skipGeneric(res.typ).kind = tyArray then begin
+        include(res.loc.flags, lfIndirect);
+        res.loc.s := OnUnknown;
+      end;
     end;
     initVariable(p, res);
     genObjectInit(p, res.typ, res.loc, true);
diff --git a/tests/sdltest.nim b/tests/sdltest.nim
index bac905b0c..ae7f1b41e 100644
--- a/tests/sdltest.nim
+++ b/tests/sdltest.nim
@@ -15,8 +15,8 @@ if SDL_Init(SDL_INIT_VIDEO) == 0:
     greeting = SDL_LoadBmp("backgrnd.bmp")

     if greeting == nil:

       write(stdout, "greeting is nil!")

-    r.x = 0

-    r.y = 0

+    r.x = 0'i16

+    r.y = 0'i16

     discard SDL_blitSurface(greeting, nil, screen, addr(r))

     discard SDL_flip(screen)

     SDL_Delay(3000)

diff --git a/tools/niminst b/tools/niminst
index 628e7632a..188cb78b6 100644
--- a/tools/niminst
+++ b/tools/niminst
Binary files differ