[svn:parrot] r37770 - in trunk: examples/io include/parrot src/io

Infinoid at svn.parrot.org Infinoid at svn.parrot.org
Fri Mar 27 22:07:14 UTC 2009


Author: Infinoid
Date: Fri Mar 27 22:07:13 2009
New Revision: 37770
URL: https://trac.parrot.org/parrot/changeset/37770

Log:
Apply patch from bacek++ in TT #516:
* Change Parrot_io_socket to return INTVAL as all other functions

Modified:
   trunk/examples/io/httpd.pir
   trunk/include/parrot/io.h
   trunk/include/parrot/io_unix.h
   trunk/include/parrot/io_win32.h
   trunk/src/io/socket_api.c
   trunk/src/io/socket_unix.c
   trunk/src/io/socket_win32.c

Modified: trunk/examples/io/httpd.pir
==============================================================================
--- trunk/examples/io/httpd.pir	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/examples/io/httpd.pir	Fri Mar 27 22:07:13 2009	(r37770)
@@ -111,13 +111,12 @@
     port = 1234
 
     # TODO provide sys/socket constants
-    .local pmc sock
-    sock = new 'Socket'
-    listener = sock.'socket'(2, 1, 6)	# PF_INET, SOCK_STREAM, tcp
+    listener = new 'Socket'
+    listener.'socket'(2, 1, 6)	# PF_INET, SOCK_STREAM, tcp
     unless listener goto ERR_NO_SOCKET
 
     # Pack a sockaddr_in structure with IP and port
-    address = sock.'sockaddr'(host, port)
+    address = listener.'sockaddr'(host, port)
     ret = listener.'bind'(address)
     if ret == -1 goto ERR_bind
     $S0 = port

Modified: trunk/include/parrot/io.h
==============================================================================
--- trunk/include/parrot/io.h	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/include/parrot/io.h	Fri Mar 27 22:07:13 2009	(r37770)
@@ -829,7 +829,7 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-PMC * Parrot_io_socket(PARROT_INTERP,
+INTVAL Parrot_io_socket(PARROT_INTERP,
     ARGMOD_NULLOK(PMC * socket),
     INTVAL fam,
     INTVAL type,

Modified: trunk/include/parrot/io_unix.h
==============================================================================
--- trunk/include/parrot/io_unix.h	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/include/parrot/io_unix.h	Fri Mar 27 22:07:13 2009	(r37770)
@@ -220,7 +220,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-PMC * Parrot_io_socket_unix(PARROT_INTERP,
+INTVAL Parrot_io_socket_unix(PARROT_INTERP,
     ARGIN(PMC *s),
     int fam,
     int type,

Modified: trunk/include/parrot/io_win32.h
==============================================================================
--- trunk/include/parrot/io_win32.h	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/include/parrot/io_win32.h	Fri Mar 27 22:07:13 2009	(r37770)
@@ -199,7 +199,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-PMC * Parrot_io_socket_win32(PARROT_INTERP,
+INTVAL Parrot_io_socket_win32(PARROT_INTERP,
     ARGIN(PMC * s),
     int fam,
     int type,

Modified: trunk/src/io/socket_api.c
==============================================================================
--- trunk/src/io/socket_api.c	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/src/io/socket_api.c	Fri Mar 27 22:07:13 2009	(r37770)
@@ -69,7 +69,7 @@
 
 /*
 
-=item C<PMC * Parrot_io_socket>
+=item C<INTVAL Parrot_io_socket>
 
 Creates and returns a socket using the specified address family, socket type,
 and protocol number. Check the returned PMC with a boolean test to see whether
@@ -82,7 +82,7 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-PMC *
+INTVAL
 Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC * socket), INTVAL fam,
             INTVAL type, INTVAL proto)
 {

Modified: trunk/src/io/socket_unix.c
==============================================================================
--- trunk/src/io/socket_unix.c	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/src/io/socket_unix.c	Fri Mar 27 22:07:13 2009	(r37770)
@@ -115,7 +115,7 @@
 
 /*
 
-=item C<PMC * Parrot_io_socket_unix>
+=item C<INTVAL Parrot_io_socket_unix>
 
 Uses C<socket()> to create a socket with the specified address family,
 socket type and protocol number.
@@ -126,7 +126,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-PMC *
+INTVAL
 Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto)
 {
     ASSERT_ARGS(Parrot_io_socket_unix)
@@ -136,9 +136,9 @@
         setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i));
         Parrot_io_set_os_handle(interp, s, sock);
         SOCKADDR_REMOTE(s)->sin_family = fam;
-        return s;
+        return 0;
     }
-    return PMCNULL;
+    return -1;
 }
 
 /*

Modified: trunk/src/io/socket_win32.c
==============================================================================
--- trunk/src/io/socket_win32.c	Fri Mar 27 22:07:05 2009	(r37769)
+++ trunk/src/io/socket_win32.c	Fri Mar 27 22:07:13 2009	(r37770)
@@ -61,7 +61,7 @@
 
 /*
 
-=item C<PMC * Parrot_io_socket_win32>
+=item C<INTVAL Parrot_io_socket_win32>
 
 Uses C<socket()> to create a socket with the specified address family,
 socket type and protocol number.
@@ -72,7 +72,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-PMC *
+INTVAL
 Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto)
 {
     ASSERT_ARGS(Parrot_io_socket_win32)
@@ -82,9 +82,9 @@
         setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i));
         Parrot_io_set_os_handle(interp, s, sock);
         SOCKADDR_REMOTE(io)->sin_family = fam;
-        return io;
+        return 0;
     }
-    return PMCNULL;
+    return -1;
 }
 
 /*


More information about the parrot-commits mailing list