[svn:parrot] r39206 - in branches/io_rewiring/src: io pmc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Thu May 28 00:28:06 UTC 2009
Author: whiteknight
Date: Thu May 28 00:28:06 2009
New Revision: 39206
URL: https://trac.parrot.org/parrot/changeset/39206
Log:
[io_rewiring] convert the 'open' method to call Parrot_io_open, not the other way around. Initial prototype for how the rest of this branch will progress
Modified:
branches/io_rewiring/src/io/api.c
branches/io_rewiring/src/pmc/filehandle.pmc
Modified: branches/io_rewiring/src/io/api.c
==============================================================================
--- branches/io_rewiring/src/io/api.c Wed May 27 23:35:32 2009 (r39205)
+++ branches/io_rewiring/src/io/api.c Thu May 28 00:28:06 2009 (r39206)
@@ -26,6 +26,7 @@
#include "parrot/parrot.h"
#include "io_private.h"
#include "api.str"
+#include "../pmc/pmc_filehandle.h"
#include <stdarg.h>
@@ -114,17 +115,27 @@
ARGIN(STRING *path), ARGIN_NULLOK(STRING *mode))
{
ASSERT_ARGS(Parrot_io_open)
- PMC *new_filehandle;
+ PMC *new_filehandle, *filehandle;
+ INTVAL flags;
if (PMC_IS_NULL(pmc))
new_filehandle = pmc_new(interp, enum_class_FileHandle);
else
new_filehandle = pmc;
- Parrot_PCCINVOKE(interp, new_filehandle, CONST_STRING(interp, "open"), "SS->P",
- path, mode, &new_filehandle);
+ flags = Parrot_io_parse_open_flags(interp, mode);
+ filehandle = PIO_OPEN(interp, new_filehandle, path, flags);
- return new_filehandle;
+ if (PMC_IS_NULL(filehandle))
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
+ "Unable to open filehandle from path '%S'",
+ path);
+
+ SETATTR_FileHandle_flags(interp, new_filehandle, flags);
+ SETATTR_FileHandle_filename(interp, new_filehandle, path);
+ SETATTR_FileHandle_mode(interp, new_filehandle, mode);
+ Parrot_io_setbuf(interp, filehandle, PIO_UNBOUND);
+ return filehandle;
}
/*
Modified: branches/io_rewiring/src/pmc/filehandle.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/filehandle.pmc Wed May 27 23:35:32 2009 (r39205)
+++ branches/io_rewiring/src/pmc/filehandle.pmc Thu May 28 00:28:06 2009 (r39206)
@@ -272,10 +272,9 @@
*/
METHOD open(STRING *filename :optional, INTVAL got_filename :opt_flag,
- STRING *mode :optional, INTVAL got_mode :opt_flag) {
+ STRING *mode :optional, INTVAL got_mode :opt_flag) {
PMC *filehandle;
STRING *open_filename, *open_mode;
- INTVAL flags;
if (!Parrot_io_is_closed_filehandle(INTERP, SELF))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
@@ -302,16 +301,7 @@
SET_ATTR_mode(INTERP, SELF, open_mode);
}
- flags = Parrot_io_parse_open_flags(interp, open_mode);
- SET_ATTR_flags(INTERP, SELF, flags);
- filehandle = PIO_OPEN(INTERP, SELF, open_filename, flags);
-
- if (PMC_IS_NULL(filehandle))
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
- "Unable to open filehandle from path '%S'",
- open_filename);
-
- Parrot_io_setbuf(interp, filehandle, PIO_UNBOUND);
+ filehandle = Parrot_io_open(INTERP, SELF, open_filename, open_mode);
RETURN(PMC *filehandle);
}
More information about the parrot-commits
mailing list