[svn:parrot] r39277 - branches/io_rewiring/src/pmc
Infinoid at svn.parrot.org
Infinoid at svn.parrot.org
Sat May 30 16:20:26 UTC 2009
Author: Infinoid
Date: Sat May 30 16:20:26 2009
New Revision: 39277
URL: https://trac.parrot.org/parrot/changeset/39277
Log:
[io] Clean up Pipe and PipeHandle some more.
Modified:
branches/io_rewiring/src/pmc/pipe.pmc
branches/io_rewiring/src/pmc/pipehandle.pmc
Modified: branches/io_rewiring/src/pmc/pipe.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/pipe.pmc Sat May 30 15:55:02 2009 (r39276)
+++ branches/io_rewiring/src/pmc/pipe.pmc Sat May 30 16:20:26 2009 (r39277)
@@ -23,8 +23,8 @@
#include "pmc_pipehandle.h"
pmclass Pipe {
- ATTR PMC* reader; /* Readable IO handle */
- ATTR PMC* writer; /* Writable IO handle */
+ ATTR PMC *r; /* Readable IO handle */
+ ATTR PMC *w; /* Writable IO handle */
/*
@@ -38,24 +38,24 @@
VTABLE void init() {
PIOHANDLE reader, writer;
- Parrot_Pipe_attributes *data_struct =
+ Parrot_Pipe_attributes *attrs =
mem_allocate_zeroed_typed(Parrot_Pipe_attributes);
- PMC_data(SELF) = data_struct;
+ PMC_data(SELF) = attrs;
if(PIO_PIPE(interp, &reader, &writer) < 0) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
"Cannot open pipe");
}
- data_struct->reader = pmc_new(interp, enum_class_PipeHandle);
- data_struct->writer = pmc_new(interp, enum_class_PipeHandle);
- if(!data_struct->reader || !data_struct->writer) {
+ attrs->r = pmc_new(interp, enum_class_PipeHandle);
+ attrs->w = pmc_new(interp, enum_class_PipeHandle);
+ if(!attrs->r || !attrs->w) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
"Cannot create PipeHandle PMCs");
}
- PARROT_PIPEHANDLE(data_struct->reader)->os_handle = reader;
- PARROT_PIPEHANDLE(data_struct->writer)->os_handle = writer;
- PARROT_PIPEHANDLE(data_struct->reader)->reader = 1;
- PARROT_PIPEHANDLE(data_struct->writer)->writer = 1;
+ PARROT_PIPEHANDLE(attrs->r)->os_handle = reader;
+ PARROT_PIPEHANDLE(attrs->w)->os_handle = writer;
+ PARROT_PIPEHANDLE(attrs->r)->reader = 1;
+ PARROT_PIPEHANDLE(attrs->w)->writer = 1;
PObj_custom_mark_SET(SELF);
}
@@ -77,8 +77,8 @@
Parrot_Pipe_attributes * const old_struct = PARROT_PIPE(SELF);
Parrot_Pipe_attributes * const data_struct = PARROT_PIPE(copy);
- data_struct->reader = old_struct->reader;
- data_struct->writer = old_struct->writer;
+ data_struct->r = old_struct->r;
+ data_struct->w = old_struct->w;
return SELF;
}
@@ -95,14 +95,14 @@
*/
VTABLE void mark() {
- Parrot_Pipe_attributes * const data = PARROT_PIPE(SELF);
+ Parrot_Pipe_attributes * const attrs = PARROT_PIPE(SELF);
- if (data) {
- if (data->reader)
- Parrot_gc_mark_PObj_alive(interp, (PObj *)data->reader);
+ if (attrs) {
+ if (attrs->r)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->r);
- if (data->writer)
- Parrot_gc_mark_PObj_alive(interp, (PObj *)data->writer);
+ if (attrs->w)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->w);
}
}
@@ -125,8 +125,10 @@
METHOD reader() {
- Parrot_Pipe_attributes * const attr = PARROT_PIPE(SELF);
- RETURN(PMC *attr->reader);
+ PMC *rv;
+ Parrot_Pipe_attributes * const attrs = PARROT_PIPE(SELF);
+ rv = attrs->r;
+ RETURN(PMC *rv);
}
/*
@@ -141,8 +143,10 @@
METHOD writer() {
- Parrot_Pipe_attributes * const attr = PARROT_PIPE(SELF);
- RETURN(PMC *attr->writer);
+ PMC *rv;
+ Parrot_Pipe_attributes * const attrs = PARROT_PIPE(SELF);
+ rv = attrs->w;
+ RETURN(PMC *rv);
}
/*
Modified: branches/io_rewiring/src/pmc/pipehandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/pipehandle.pmc Sat May 30 15:55:02 2009 (r39276)
+++ branches/io_rewiring/src/pmc/pipehandle.pmc Sat May 30 16:20:26 2009 (r39277)
@@ -113,14 +113,15 @@
=item C<INTVAL get_bool()>
-Returns whether the Socket is currently open.
+Returns whether the Pipe is currently open.
=cut
*/
VTABLE INTVAL get_bool() {
- return !Parrot_io_socket_is_closed(SELF);
+ Parrot_PipeHandle_attributes * const attrs = PARROT_PIPEHANDLE(SELF);
+ return (attrs->os_handle != PIO_INVALID_HANDLE);
}
@@ -128,180 +129,6 @@
=back
-=head2 Methods
-
-=over 4
-
-=item C<socket>
-
-=cut
-
-*/
-
-
- METHOD socket(INTVAL fam, INTVAL type, INTVAL proto) {
- if (Parrot_io_socket(interp, SELF, fam, type, proto) < 0)
- RETURN(PMC * PMCNULL);
- RETURN(PMC * SELF);
- }
-
-
-/*
-
-=item C<sockaddr>
-
-C<sockaddr> returns an object representing a socket address, generated
-from a port number (integer) and an address (string).
-
-=cut
-
-*/
-
- METHOD sockaddr(STRING * address, INTVAL port) {
- PMC * res = Parrot_io_sockaddr_in(interp, address, port);
- RETURN(PMC * res);
- }
-
-
-/*
-
-=item C<connect>
-
-Connects a socket object to an address.
-
-The asynchronous version takes an additional final PMC callback
-argument, and only returns a status object. When the socket operation is
-complete, it invokes the callback, passing it a status object and the
-socket object it was called on. [If you want notification when a connect
-operation is completed, you probably want to do something with that
-connected socket object.]
-
-=cut
-
-*/
-
- METHOD connect(PMC * address) {
- INTVAL res = Parrot_io_connect(INTERP, SELF, address);
- RETURN(INTVAL res);
- }
-
-
-/*
-
-=item C<recv>
-
-Receives a message from a connected socket object. It returns
-the message in a string.
-
-The asynchronous version takes an additional final PMC callback
-argument, and only returns a status object. When the recv operation is
-complete, it invokes the callback, passing it a status object and a
-string containing the received message.
-
-=cut
-
-*/
-
- METHOD recv() {
- STRING * result;
- INTVAL read = Parrot_io_recv(INTERP, SELF, &result);
- RETURN(STRING * result);
- }
-
-
-/*
-
-=item C<send>
-
-Sends a message string to a connected socket object.
-
-The asynchronous version takes an additional final PMC callback
-argument, and only returns a status object. When the send operation is
-complete, it invokes the callback, passing it a status object.
-
-=cut
-
-*/
-
- METHOD send(STRING *buf) {
- INTVAL res = Parrot_io_send(INTERP, SELF, buf);
- RETURN(INTVAL res);
- }
-
-
-/*
-
-=item C<bind>
-
-C<bind> binds a socket object to the port and address specified by an
-address object (the packed result of C<sockaddr>).
-
-The asynchronous version takes an additional final PMC callback
-argument, and only returns a status object. When the bind operation is
-complete, it invokes the callback, passing it a status object and the
-socket object it was called on. [If you want notification when a bind
-operation is completed, you probably want to do something with that
-bound socket object.]
-
-=cut
-
-*/
-
- METHOD bind(PMC *host) {
- INTVAL res = Parrot_io_bind(INTERP, SELF, host);
- RETURN(INTVAL res);
- }
-
-
-/*
-
-=item C<listen>
-
-C<listen> specifies that a socket object is willing to accept incoming
-connections. The integer argument gives the maximum size of the queue
-for pending connections.
-
-There is no asynchronous version. C<listen> marks a set of attributes on
-the socket object.
-
-=cut
-
-*/
-
- METHOD listen(INTVAL backlog) {
- INTVAL res = Parrot_io_listen(INTERP, SELF, backlog);
- RETURN(INTVAL res);
- }
-
-
-/*
-
-=item C<accept>
-
-C<accept> accepts a new connection on a given socket object, and returns
-a newly created socket object for the connection.
-
-The asynchronous version takes an additional final PMC callback
-argument, and only returns a status object. When the accept operation
-receives a new connection, it invokes the callback, passing it a status
-object and a newly created socket object for the connection. [While the
-synchronous C<accept> has to be called repeatedly in a loop (once for
-each connection received), the asynchronous version is only called once,
-but continues to send new connection events until the socket is closed.]
-
-=cut
-
-*/
-
- METHOD accept() {
- PMC * res = Parrot_io_accept(INTERP, SELF);
- RETURN(PMC * res);
- }
-
-/*
-
-=back
-
=cut
*/
More information about the parrot-commits
mailing list