Skip to content

Commit

Permalink
Fix several codetests
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed May 23, 2012
1 parent c93f492 commit 968bb3d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
33 changes: 28 additions & 5 deletions src/io/api.c
Expand Up @@ -159,7 +159,8 @@ PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_io_open_handle(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(STRING *path), ARGIN(STRING *mode))
Parrot_io_open_handle(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(STRING *path),
ARGIN(STRING *mode))
{
ASSERT_ARGS(Parrot_io_open_handle)
PMC *filehandle;
Expand Down Expand Up @@ -199,7 +200,8 @@ Parrot_io_open_handle(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(STRING *path), ARGIN
}
else {
if ((flags & (PIO_F_WRITE | PIO_F_READ)) == 0)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"Invalid mode for file open");

os_handle = PIO_OPEN(interp, path, flags);
Expand Down Expand Up @@ -294,7 +296,8 @@ PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_io_fdopen_flags(PARROT_INTERP, ARGMOD(PMC *filehandle), PIOHANDLE fd, INTVAL flags)
Parrot_io_fdopen_flags(PARROT_INTERP, ARGMOD(PMC *filehandle), PIOHANDLE fd,
INTVAL flags)
{
ASSERT_ARGS(Parrot_io_fdopen_flags)

Expand Down Expand Up @@ -583,10 +586,29 @@ Parrot_io_reads(PARROT_INTERP, ARGMOD(PMC *pmc), size_t length)
return result;
}

/*
=item C<PMC * Parrot_io_read_byte_buffer_pmc(PARROT_INTERP, PMC *handle, PMC
*buffer, INTVAL length)>
Read C<length> bytes from the C<handle> into the C<buffer> (ByteBuffer) PMC.
=item C<INTVAL Parrot_io_write_byte_buffer_pmc(PARROT_INTERP, PMC * handle, PMC
*buffer, INTVAL length)>
Write C<length> bytes (or the total length of C<buffer>, whichever is smaller)
from C<buffer> to the C<handle>
=cut
*/


PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_io_read_byte_buffer_pmc(PARROT_INTERP, ARGMOD(PMC *handle), ARGMOD_NULLOK(PMC *buffer), INTVAL length)
Parrot_io_read_byte_buffer_pmc(PARROT_INTERP, ARGMOD(PMC *handle),
ARGMOD_NULLOK(PMC *buffer), INTVAL length)
{
ASSERT_ARGS(Parrot_io_read_byte_buffer_pmc)
unsigned char *content;
Expand Down Expand Up @@ -634,7 +656,8 @@ Parrot_io_read_byte_buffer_pmc(PARROT_INTERP, ARGMOD(PMC *handle), ARGMOD_NULLOK
}

INTVAL
Parrot_io_write_byte_buffer_pmc(PARROT_INTERP, ARGMOD(PMC * handle), ARGMOD(PMC *buffer), INTVAL length)
Parrot_io_write_byte_buffer_pmc(PARROT_INTERP, ARGMOD(PMC * handle),
ARGMOD(PMC *buffer), INTVAL length)
{
ASSERT_ARGS(Parrot_io_write_byte_buffer_pmc)
unsigned char *content;
Expand Down
22 changes: 20 additions & 2 deletions src/io/socket_api.c
Expand Up @@ -167,8 +167,25 @@ Parrot_io_recv_handle(PARROT_INTERP, ARGMOD(PMC *pmc), size_t len)
return res;
}

/*
=item C<INTVAL Parrot_io_socket_recv_to_buffer(PARROT_INTERP, PMC *socket, char
* buffer, size_t len)>
Read C<len> bytes from C<socket> and add them to the C<buffer>.
=item C<INTVAL Parrot_io_socket_send_from_buffer(PARROT_INTERP, PMC *socket,
const char *buffer, size_t len)>
Write C<len> bytes from C<buffer> to C<socket>.
=cut
*/

INTVAL
Parrot_io_socket_recv_to_buffer(PARROT_INTERP, ARGMOD(PMC *socket), ARGOUT(char * buffer), size_t len)
Parrot_io_socket_recv_to_buffer(PARROT_INTERP, ARGMOD(PMC *socket),
ARGOUT(char * buffer), size_t len)
{
ASSERT_ARGS(Parrot_io_socket_recv_to_buffer)

Expand All @@ -182,7 +199,8 @@ Parrot_io_socket_recv_to_buffer(PARROT_INTERP, ARGMOD(PMC *socket), ARGOUT(char
}

INTVAL
Parrot_io_socket_send_from_buffer(PARROT_INTERP, ARGMOD(PMC *socket), ARGIN(const char *buffer), size_t len)
Parrot_io_socket_send_from_buffer(PARROT_INTERP, ARGMOD(PMC *socket),
ARGIN(const char *buffer), size_t len)
{
ASSERT_ARGS(Parrot_io_socket_send_from_buffer)
if (Parrot_io_socket_is_closed(interp, socket))
Expand Down

0 comments on commit 968bb3d

Please sign in to comment.