[svn:parrot] r39686 - in branches/io_cleanups: include/parrot src/io src/pmc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sun Jun 21 10:44:47 UTC 2009
Author: whiteknight
Date: Sun Jun 21 10:44:46 2009
New Revision: 39686
URL: https://trac.parrot.org/parrot/changeset/39686
Log:
[io_rewiring] change Parrot_io_socket_is_closed to take an interp argument, and use GETATTR to access the os_handle (for future subclassability)
Modified:
branches/io_cleanups/include/parrot/io.h
branches/io_cleanups/src/io/api.c
branches/io_cleanups/src/io/socket_api.c
branches/io_cleanups/src/pmc/socket.pmc
Modified: branches/io_cleanups/include/parrot/io.h
==============================================================================
--- branches/io_cleanups/include/parrot/io.h Sun Jun 21 10:36:45 2009 (r39685)
+++ branches/io_cleanups/include/parrot/io.h Sun Jun 21 10:44:46 2009 (r39686)
@@ -608,7 +608,8 @@
__attribute__nonnull__(2);
PARROT_EXPORT
-INTVAL Parrot_io_get_flags(SHIM_INTERP, ARGIN(PMC *filehandle))
+INTVAL Parrot_io_get_flags(PARROT_INTERP, ARGIN(PMC *filehandle))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
@@ -648,7 +649,10 @@
__attribute__nonnull__(2);
PARROT_EXPORT
-void Parrot_io_set_flags(SHIM_INTERP, ARGIN(PMC *filehandle), INTVAL flags)
+void Parrot_io_set_flags(PARROT_INTERP,
+ ARGIN(PMC *filehandle),
+ INTVAL flags)
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
@@ -717,7 +721,8 @@
#define ASSERT_ARGS_Parrot_io_get_file_position __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_get_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(filehandle)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_get_last_file_position \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
@@ -736,7 +741,8 @@
#define ASSERT_ARGS_Parrot_io_set_file_position __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_set_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(filehandle)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_set_os_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(filehandle)
#define ASSERT_ARGS_Parrot_io_clear_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -844,8 +850,9 @@
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-INTVAL Parrot_io_socket_is_closed(ARGMOD(PMC *socket))
+INTVAL Parrot_io_socket_is_closed(PARROT_INTERP, ARGMOD(PMC *socket))
__attribute__nonnull__(1)
+ __attribute__nonnull__(2)
FUNC_MODIFIES(*socket);
#define ASSERT_ARGS_Parrot_io_accept __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -878,7 +885,8 @@
#define ASSERT_ARGS_Parrot_io_socket __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_io_socket_is_closed __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(socket)
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(socket)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/io/socket_api.c */
Modified: branches/io_cleanups/src/io/api.c
==============================================================================
--- branches/io_cleanups/src/io/api.c Sun Jun 21 10:36:45 2009 (r39685)
+++ branches/io_cleanups/src/io/api.c Sun Jun 21 10:44:46 2009 (r39686)
@@ -281,7 +281,7 @@
result = STRING_IS_NULL(stringhandle);
}
else if (pmc->vtable->base_type == enum_class_Socket)
- result = Parrot_io_socket_is_closed(pmc);
+ result = Parrot_io_socket_is_closed(interp, pmc);
else
Parrot_PCCINVOKE(interp, pmc, CONST_STRING(interp, "is_closed"), "->I", &result);
Modified: branches/io_cleanups/src/io/socket_api.c
==============================================================================
--- branches/io_cleanups/src/io/socket_api.c Sun Jun 21 10:36:45 2009 (r39685)
+++ branches/io_cleanups/src/io/socket_api.c Sun Jun 21 10:44:46 2009 (r39686)
@@ -29,7 +29,7 @@
/*
-=item C<INTVAL Parrot_io_socket_is_closed(PMC *socket)>
+=item C<INTVAL Parrot_io_socket_is_closed(PARROT_INTERP, PMC *socket)>
Returns 1 if the socket is closed, 0 if it is open.
@@ -110,17 +110,19 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
INTVAL
-Parrot_io_socket_is_closed(ARGMOD(PMC *socket))
+Parrot_io_socket_is_closed(PARROT_INTERP, ARGMOD(PMC *socket))
{
ASSERT_ARGS(Parrot_io_socket_is_closed)
+ PIOHANDLE os_handle;
+ GETATTR_Socket_os_handle(interp, socket, os_handle);
#ifdef PIO_OS_WIN32
- return (PARROT_SOCKET(socket)->os_handle == (PIOHANDLE)INVALID_HANDLE_VALUE);
+ return (os_handle == (PIOHANDLE)INVALID_HANDLE_VALUE);
#endif
#ifdef PIO_OS_UNIX
- return (PARROT_SOCKET(socket)->os_handle == (PIOHANDLE)-1);
+ return (os_handle == (PIOHANDLE)-1);
#endif
#ifdef PIO_OS_STDIO
- return (PARROT_SOCKET(socket)->os_handle == (PIOHANDLE)NULL);
+ return (os_handle == (PIOHANDLE)NULL);
#endif
}
@@ -210,7 +212,7 @@
Parrot_io_recv(PARROT_INTERP, ARGMOD(PMC *pmc), ARGOUT(STRING **buf))
{
ASSERT_ARGS(Parrot_io_recv)
- if (Parrot_io_socket_is_closed(pmc))
+ if (Parrot_io_socket_is_closed(interp, pmc))
return -1;
return PIO_RECV(interp, pmc, buf);
@@ -233,7 +235,7 @@
Parrot_io_send(PARROT_INTERP, ARGMOD(PMC *pmc), ARGMOD(STRING *buf))
{
ASSERT_ARGS(Parrot_io_send)
- if (Parrot_io_socket_is_closed(pmc))
+ if (Parrot_io_socket_is_closed(interp, pmc))
return -1;
return PIO_SEND(interp, pmc, buf);
@@ -254,7 +256,7 @@
Parrot_io_connect(PARROT_INTERP, ARGMOD(PMC *pmc), ARGMOD(PMC *address))
{
ASSERT_ARGS(Parrot_io_connect)
- if (Parrot_io_socket_is_closed(pmc))
+ if (Parrot_io_socket_is_closed(interp, pmc))
return -1;
return PIO_CONNECT(interp, pmc, address);
@@ -276,7 +278,7 @@
Parrot_io_bind(PARROT_INTERP, ARGMOD(PMC *pmc), ARGMOD(PMC *address))
{
ASSERT_ARGS(Parrot_io_bind)
- if (Parrot_io_socket_is_closed(pmc))
+ if (Parrot_io_socket_is_closed(interp, pmc))
return -1;
return PIO_BIND(interp, pmc, address);
@@ -298,7 +300,7 @@
Parrot_io_listen(PARROT_INTERP, ARGMOD(PMC *pmc), INTVAL backlog)
{
ASSERT_ARGS(Parrot_io_listen)
- if (Parrot_io_socket_is_closed(pmc))
+ if (Parrot_io_socket_is_closed(interp, pmc))
return -1;
return PIO_LISTEN(interp, pmc, backlog);
@@ -322,7 +324,7 @@
Parrot_io_accept(PARROT_INTERP, ARGMOD(PMC *pmc))
{
ASSERT_ARGS(Parrot_io_accept)
- if (Parrot_io_socket_is_closed(pmc))
+ if (Parrot_io_socket_is_closed(interp, pmc))
return PMCNULL;
return PIO_ACCEPT(interp, pmc);
Modified: branches/io_cleanups/src/pmc/socket.pmc
==============================================================================
--- branches/io_cleanups/src/pmc/socket.pmc Sun Jun 21 10:36:45 2009 (r39685)
+++ branches/io_cleanups/src/pmc/socket.pmc Sun Jun 21 10:44:46 2009 (r39686)
@@ -117,7 +117,7 @@
*/
VTABLE INTVAL get_bool() {
- return !Parrot_io_socket_is_closed(SELF);
+ return !Parrot_io_socket_is_closed(INTERP, SELF);
}
/*
More information about the parrot-commits
mailing list