diff --git a/moo/kernel/IO.moo b/moo/kernel/IO.moo new file mode 100644 index 0000000..bd0a972 --- /dev/null +++ b/moo/kernel/IO.moo @@ -0,0 +1,41 @@ +class(#limited) InputOutputStud(Object) from "io" +{ + var(#get) handle. // you must keep handle as the first field for consitency with the 'io' module. + + method(#primitive,#lenient) _close. + method(#primitive) _readBytesInto: buffer startingAt: offset for: count. + method(#primitive) _writeBytesFrom: buffer startingAt: offset for: count. +} + +class FileAccessor(InputOutputStud) from "io.file" +{ + method(#primitive,#lenient) _open: path flags: flags. + + method(#class) on: path for: flags + { + | fa | + fa := self new _open: path flags: flags. + if (fa isError) { self error: "unable to open file" }. + self addToBeFinalized. + ^fa. + } + + method close + { +"CLOSING HANDLLE>..................." dump. + self _close. + self removeToBeFinalized. + } + + method finalize + { + self close. + } +} + +/* +class UnixFileAccessor(FileAccessor) from "io.file.unix" +{ + method(#primitive) _open: path flags: flags mode: mode. +} +*/ diff --git a/moo/kernel/Moo.moo b/moo/kernel/Moo.moo index d7b277a..0ce7f5a 100644 --- a/moo/kernel/Moo.moo +++ b/moo/kernel/Moo.moo @@ -7,6 +7,7 @@ #include 'Collect.moo'. #include 'System.moo'. #include 'Process.moo'. +#include 'IO.moo'. #include 'Stream.moo'. /* -------------------------------------------------------------------------- */ diff --git a/moo/lib/Makefile.am b/moo/lib/Makefile.am index 2e30a53..ba2a93e 100644 --- a/moo/lib/Makefile.am +++ b/moo/lib/Makefile.am @@ -87,23 +87,31 @@ libmoo_la_SOURCES = \ libmoo_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) libmoo_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) libmoo_la_LIBADD = $(LIBADD_LIB_COMMON) +libmoo_la_DEPENDENCIES = if ENABLE_STATIC_MODULE -libmoo_la_LIBADD += -lmoo-stdio -libmoo_la_DEPENDENCIES = ../mod/libmoo-stdio.la if ENABLE_MOD_CON libmoo_la_LIBADD += -lmoo-con libmoo_la_DEPENDENCIES += ../mod/libmoo-con.la endif + if ENABLE_MOD_FFI libmoo_la_LIBADD += -lmoo-ffi libmoo_la_DEPENDENCIES += ../mod/libmoo-ffi.la endif + +libmoo_la_LIBADD += -lmoo-io +libmoo_la_DEPENDENCIES += ../mod/libmoo-io.la + if ENABLE_MOD_SCK libmoo_la_LIBADD += -lmoo-sck libmoo_la_DEPENDENCIES += ../mod/libmoo-sck.la endif + +libmoo_la_LIBADD += -lmoo-stdio +libmoo_la_DEPENDENCIES += ../mod/libmoo-stdio.la + if ENABLE_MOD_X11 libmoo_la_LIBADD += -lmoo-x11 libmoo_la_DEPENDENCIES += ../mod/libmoo-x11.la diff --git a/moo/lib/Makefile.in b/moo/lib/Makefile.in index d243c2c..2f438ea 100644 --- a/moo/lib/Makefile.in +++ b/moo/lib/Makefile.in @@ -89,27 +89,23 @@ build_triplet = @build@ host_triplet = @host@ @MACOSX_TRUE@@WIN32_FALSE@am__append_1 = -DMOO_DEFAULT_PFMODPOSTFIX=\".dylib\" @MACOSX_FALSE@@WIN32_FALSE@am__append_2 = -DMOO_DEFAULT_PFMODPOSTFIX=\".so\" -@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -lmoo-stdio -@ENABLE_STATIC_MODULE_FALSE@libmoo_la_DEPENDENCIES = \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) -@ENABLE_MOD_CON_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_4 = -lmoo-con -@ENABLE_MOD_CON_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_5 = ../mod/libmoo-con.la -@ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_6 = -lmoo-ffi -@ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_7 = ../mod/libmoo-ffi.la -@ENABLE_MOD_SCK_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_8 = -lmoo-sck -@ENABLE_MOD_SCK_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_9 = ../mod/libmoo-sck.la -@ENABLE_MOD_X11_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_10 = -lmoo-x11 -@ENABLE_MOD_X11_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_11 = ../mod/libmoo-x11.la -@WIN32_TRUE@am__append_12 = poll-msw.c poll-msw.h -@ENABLE_LIBLTDL_TRUE@am__append_13 = $(LTDL_LIBS) -@ENABLE_LIBLTDL_FALSE@am__append_14 = $(DL_LIBS) -@ENABLE_LIBUNWIND_TRUE@am__append_15 = $(UNWIND_LIBS) -@WIN32_TRUE@am__append_16 = -lpsapi $(SOCKET_LIBS) +@ENABLE_MOD_CON_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -lmoo-con +@ENABLE_MOD_CON_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_4 = ../mod/libmoo-con.la +@ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_5 = -lmoo-ffi +@ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_6 = ../mod/libmoo-ffi.la +@ENABLE_STATIC_MODULE_TRUE@am__append_7 = -lmoo-io +@ENABLE_STATIC_MODULE_TRUE@am__append_8 = ../mod/libmoo-io.la +@ENABLE_MOD_SCK_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_9 = -lmoo-sck +@ENABLE_MOD_SCK_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_10 = ../mod/libmoo-sck.la +@ENABLE_STATIC_MODULE_TRUE@am__append_11 = -lmoo-stdio +@ENABLE_STATIC_MODULE_TRUE@am__append_12 = ../mod/libmoo-stdio.la +@ENABLE_MOD_X11_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_13 = -lmoo-x11 +@ENABLE_MOD_X11_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_14 = ../mod/libmoo-x11.la +@WIN32_TRUE@am__append_15 = poll-msw.c poll-msw.h +@ENABLE_LIBLTDL_TRUE@am__append_16 = $(LTDL_LIBS) +@ENABLE_LIBLTDL_FALSE@am__append_17 = $(DL_LIBS) +@ENABLE_LIBUNWIND_TRUE@am__append_18 = $(UNWIND_LIBS) +@WIN32_TRUE@am__append_19 = -lpsapi $(SOCKET_LIBS) subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \ @@ -501,23 +497,22 @@ libmoo_la_SOURCES = \ libmoo_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) libmoo_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) libmoo_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_3) \ - $(am__append_4) $(am__append_6) $(am__append_8) \ - $(am__append_10) -@ENABLE_STATIC_MODULE_TRUE@libmoo_la_DEPENDENCIES = \ -@ENABLE_STATIC_MODULE_TRUE@ ../mod/libmoo-stdio.la \ -@ENABLE_STATIC_MODULE_TRUE@ $(am__append_5) $(am__append_7) \ -@ENABLE_STATIC_MODULE_TRUE@ $(am__append_9) $(am__append_11) + $(am__append_5) $(am__append_7) $(am__append_9) \ + $(am__append_11) $(am__append_13) +libmoo_la_DEPENDENCIES = $(am__append_4) $(am__append_6) \ + $(am__append_8) $(am__append_10) $(am__append_12) \ + $(am__append_14) ############################################################## # libmoox ############################################################## libmoox_la_SOURCES = moo-opt.h moo-std.h opt-impl.h opt.c std.c \ - $(am__append_12) + $(am__append_15) libmoox_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD) libmoox_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) libmoox_la_LIBADD = $(LIBADD_LIB_COMMON) -lmoo $(LIBM) $(PTHREAD_LIBS) \ - $(am__append_13) $(am__append_14) $(am__append_15) \ - $(am__append_16) + $(am__append_16) $(am__append_17) $(am__append_18) \ + $(am__append_19) libmoox_la_DEPENDENCIES = libmoo.la all: moo-cfg.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/moo/lib/exec.c b/moo/lib/exec.c index 10428e2..fe916c7 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -1576,7 +1576,7 @@ void moo_releaseiohandle (moo_t* moo, moo_ooi_t io_handle) { /* TODO: optimize io semapore unmapping. since i'm to close the handle, * i don't need to call delete_sem_from_sem_io_tuple() seperately for input - * and output. */ + * and output. */ if (io_handle < moo->sem_io_map_capa) { moo_ooi_t index; diff --git a/moo/lib/moo.c b/moo/lib/moo.c index 560f689..8153161 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -466,13 +466,19 @@ void moo_freemem (moo_t* moo, void* ptr) #if defined(MOO_ENABLE_MOD_CON) # include "../mod/_con.h" #endif + #if defined(MOO_ENABLE_MOD_FFI) # include "../mod/_ffi.h" #endif + +#include "../mod/_io.h" + #if defined(MOO_ENABLE_MOD_SCK) # include "../mod/_sck.h" #endif + #include "../mod/_stdio.h" + #if defined(MOO_ENABLE_MOD_X11) # include "../mod/_x11.h" #endif @@ -490,6 +496,8 @@ static_modtab[] = #if defined(MOO_ENABLE_MOD_FFI) { "ffi", moo_mod_ffi }, #endif + { "io", moo_mod_io }, + { "io.file", moo_mod_io_file }, #if defined(MOO_ENABLE_MOD_SCK) { "sck", moo_mod_sck }, { "sck.addr", moo_mod_sck_addr }, @@ -500,7 +508,7 @@ static_modtab[] = /*{ "x11.win", moo_mod_x11_win },*/ #endif }; -#endif +#endif /* MOO_ENABLE_STATIC_MODULE */ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namelen, int hints) { diff --git a/moo/mod/Makefile.am b/moo/mod/Makefile.am index 0966cbc..047773c 100644 --- a/moo/mod/Makefile.am +++ b/moo/mod/Makefile.am @@ -27,6 +27,8 @@ if ENABLE_MOD_FFI noinst_LTLIBRARIES += libmoo-ffi.la endif +noinst_LTLIBRARIES += libmoo-io.la + if ENABLE_MOD_SCK noinst_LTLIBRARIES += libmoo-sck.la endif @@ -56,6 +58,8 @@ if ENABLE_MOD_FFI pkgmodexec_LTLIBRARIES += libmoo-ffi.la endif +pkgmodexec_LTLIBRARIES += libmoo-io.la + if ENABLE_MOD_SCK pkgmodexec_LTLIBRARIES += libmoo-sck.la endif @@ -82,6 +86,11 @@ libmoo_ffi_la_LDFLAGS = $(LDFLAGS_COMMON) libmoo_ffi_la_LIBADD = $(LIBADD_COMMON) $(DYNCALL_LIBS) $(FFI_LIBS) endif +libmoo_io_la_SOURCES = io.c io-file.c _io.h +libmoo_io_la_CPPFLAGS = $(CPPFLAGS_COMMON) +libmoo_io_la_LDFLAGS = $(LDFLAGS_COMMON) +libmoo_io_la_LIBADD = $(LIBADD_COMMON) + if ENABLE_MOD_SCK libmoo_sck_la_SOURCES = sck.c sck-addr.c _sck.h libmoo_sck_la_CPPFLAGS = $(CPPFLAGS_COMMON) diff --git a/moo/mod/Makefile.in b/moo/mod/Makefile.in index 0eae471..ee16edd 100644 --- a/moo/mod/Makefile.in +++ b/moo/mod/Makefile.in @@ -172,6 +172,15 @@ libmoo_ffi_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_FALSE@ -rpath \ @ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir) @ENABLE_MOD_FFI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am_libmoo_ffi_la_rpath = +libmoo_io_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_libmoo_io_la_OBJECTS = libmoo_io_la-io.lo libmoo_io_la-io-file.lo +libmoo_io_la_OBJECTS = $(am_libmoo_io_la_OBJECTS) +libmoo_io_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libmoo_io_la_LDFLAGS) $(LDFLAGS) -o $@ +@ENABLE_STATIC_MODULE_FALSE@am_libmoo_io_la_rpath = -rpath \ +@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir) +@ENABLE_STATIC_MODULE_TRUE@am_libmoo_io_la_rpath = @ENABLE_MOD_SCK_TRUE@libmoo_sck_la_DEPENDENCIES = \ @ENABLE_MOD_SCK_TRUE@ $(am__DEPENDENCIES_1) \ @ENABLE_MOD_SCK_TRUE@ $(am__DEPENDENCIES_1) @@ -225,6 +234,8 @@ depcomp = $(SHELL) $(top_srcdir)/ac/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/libmoo_con_la-_con.Plo \ ./$(DEPDIR)/libmoo_ffi_la-ffi.Plo \ + ./$(DEPDIR)/libmoo_io_la-io-file.Plo \ + ./$(DEPDIR)/libmoo_io_la-io.Plo \ ./$(DEPDIR)/libmoo_sck_la-sck-addr.Plo \ ./$(DEPDIR)/libmoo_sck_la-sck.Plo \ ./$(DEPDIR)/libmoo_stdio_la-stdio.Plo \ @@ -249,10 +260,10 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libmoo_con_la_SOURCES) $(libmoo_ffi_la_SOURCES) \ - $(libmoo_sck_la_SOURCES) $(libmoo_stdio_la_SOURCES) \ - $(libmoo_x11_la_SOURCES) + $(libmoo_io_la_SOURCES) $(libmoo_sck_la_SOURCES) \ + $(libmoo_stdio_la_SOURCES) $(libmoo_x11_la_SOURCES) DIST_SOURCES = $(am__libmoo_con_la_SOURCES_DIST) \ - $(am__libmoo_ffi_la_SOURCES_DIST) \ + $(am__libmoo_ffi_la_SOURCES_DIST) $(libmoo_io_la_SOURCES) \ $(am__libmoo_sck_la_SOURCES_DIST) $(libmoo_stdio_la_SOURCES) \ $(am__libmoo_x11_la_SOURCES_DIST) am__can_run_installinfo = \ @@ -456,12 +467,14 @@ CPPFLAGS_COMMON = \ @ENABLE_STATIC_MODULE_FALSE@LIBADD_COMMON = -lmoo @ENABLE_STATIC_MODULE_TRUE@LIBADD_COMMON = @ENABLE_STATIC_MODULE_TRUE@noinst_LTLIBRARIES = $(am__append_1) \ -@ENABLE_STATIC_MODULE_TRUE@ $(am__append_2) $(am__append_3) \ -@ENABLE_STATIC_MODULE_TRUE@ libmoo-stdio.la $(am__append_4) +@ENABLE_STATIC_MODULE_TRUE@ $(am__append_2) libmoo-io.la \ +@ENABLE_STATIC_MODULE_TRUE@ $(am__append_3) libmoo-stdio.la \ +@ENABLE_STATIC_MODULE_TRUE@ $(am__append_4) @ENABLE_STATIC_MODULE_FALSE@pkgmodexecdir = $(libdir) @ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = $(am__append_5) \ -@ENABLE_STATIC_MODULE_FALSE@ $(am__append_6) $(am__append_7) \ -@ENABLE_STATIC_MODULE_FALSE@ libmoo-stdio.la $(am__append_8) +@ENABLE_STATIC_MODULE_FALSE@ $(am__append_6) libmoo-io.la \ +@ENABLE_STATIC_MODULE_FALSE@ $(am__append_7) libmoo-stdio.la \ +@ENABLE_STATIC_MODULE_FALSE@ $(am__append_8) @ENABLE_MOD_CON_TRUE@libmoo_con_la_SOURCES = _con.c _con.h @ENABLE_MOD_CON_TRUE@libmoo_con_la_CPPFLAGS = $(CPPFLAGS_COMMON) @ENABLE_MOD_CON_TRUE@libmoo_con_la_LDFLAGS = $(LDFLAGS_COMMON) @@ -470,6 +483,10 @@ CPPFLAGS_COMMON = \ @ENABLE_MOD_FFI_TRUE@libmoo_ffi_la_CPPFLAGS = $(CPPFLAGS_COMMON) @ENABLE_MOD_FFI_TRUE@libmoo_ffi_la_LDFLAGS = $(LDFLAGS_COMMON) @ENABLE_MOD_FFI_TRUE@libmoo_ffi_la_LIBADD = $(LIBADD_COMMON) $(DYNCALL_LIBS) $(FFI_LIBS) +libmoo_io_la_SOURCES = io.c io-file.c _io.h +libmoo_io_la_CPPFLAGS = $(CPPFLAGS_COMMON) +libmoo_io_la_LDFLAGS = $(LDFLAGS_COMMON) +libmoo_io_la_LIBADD = $(LIBADD_COMMON) @ENABLE_MOD_SCK_TRUE@libmoo_sck_la_SOURCES = sck.c sck-addr.c _sck.h @ENABLE_MOD_SCK_TRUE@libmoo_sck_la_CPPFLAGS = $(CPPFLAGS_COMMON) @ENABLE_MOD_SCK_TRUE@libmoo_sck_la_LDFLAGS = $(LDFLAGS_COMMON) @@ -568,6 +585,9 @@ libmoo-con.la: $(libmoo_con_la_OBJECTS) $(libmoo_con_la_DEPENDENCIES) $(EXTRA_li libmoo-ffi.la: $(libmoo_ffi_la_OBJECTS) $(libmoo_ffi_la_DEPENDENCIES) $(EXTRA_libmoo_ffi_la_DEPENDENCIES) $(AM_V_CCLD)$(libmoo_ffi_la_LINK) $(am_libmoo_ffi_la_rpath) $(libmoo_ffi_la_OBJECTS) $(libmoo_ffi_la_LIBADD) $(LIBS) +libmoo-io.la: $(libmoo_io_la_OBJECTS) $(libmoo_io_la_DEPENDENCIES) $(EXTRA_libmoo_io_la_DEPENDENCIES) + $(AM_V_CCLD)$(libmoo_io_la_LINK) $(am_libmoo_io_la_rpath) $(libmoo_io_la_OBJECTS) $(libmoo_io_la_LIBADD) $(LIBS) + libmoo-sck.la: $(libmoo_sck_la_OBJECTS) $(libmoo_sck_la_DEPENDENCIES) $(EXTRA_libmoo_sck_la_DEPENDENCIES) $(AM_V_CCLD)$(libmoo_sck_la_LINK) $(am_libmoo_sck_la_rpath) $(libmoo_sck_la_OBJECTS) $(libmoo_sck_la_LIBADD) $(LIBS) @@ -585,6 +605,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_con_la-_con.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_ffi_la-ffi.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_io_la-io-file.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_io_la-io.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_sck_la-sck-addr.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_sck_la-sck.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_stdio_la-stdio.Plo@am__quote@ # am--include-marker @@ -634,6 +656,20 @@ libmoo_ffi_la-ffi.lo: ffi.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_ffi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_ffi_la-ffi.lo `test -f 'ffi.c' || echo '$(srcdir)/'`ffi.c +libmoo_io_la-io.lo: io.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_io_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_io_la-io.lo -MD -MP -MF $(DEPDIR)/libmoo_io_la-io.Tpo -c -o libmoo_io_la-io.lo `test -f 'io.c' || echo '$(srcdir)/'`io.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_io_la-io.Tpo $(DEPDIR)/libmoo_io_la-io.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io.c' object='libmoo_io_la-io.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_io_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_io_la-io.lo `test -f 'io.c' || echo '$(srcdir)/'`io.c + +libmoo_io_la-io-file.lo: io-file.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_io_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_io_la-io-file.lo -MD -MP -MF $(DEPDIR)/libmoo_io_la-io-file.Tpo -c -o libmoo_io_la-io-file.lo `test -f 'io-file.c' || echo '$(srcdir)/'`io-file.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_io_la-io-file.Tpo $(DEPDIR)/libmoo_io_la-io-file.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io-file.c' object='libmoo_io_la-io-file.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_io_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_io_la-io-file.lo `test -f 'io-file.c' || echo '$(srcdir)/'`io-file.c + libmoo_sck_la-sck.lo: sck.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_sck_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_sck_la-sck.lo -MD -MP -MF $(DEPDIR)/libmoo_sck_la-sck.Tpo -c -o libmoo_sck_la-sck.lo `test -f 'sck.c' || echo '$(srcdir)/'`sck.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_sck_la-sck.Tpo $(DEPDIR)/libmoo_sck_la-sck.Plo @@ -798,6 +834,8 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ distclean: distclean-am -rm -f ./$(DEPDIR)/libmoo_con_la-_con.Plo -rm -f ./$(DEPDIR)/libmoo_ffi_la-ffi.Plo + -rm -f ./$(DEPDIR)/libmoo_io_la-io-file.Plo + -rm -f ./$(DEPDIR)/libmoo_io_la-io.Plo -rm -f ./$(DEPDIR)/libmoo_sck_la-sck-addr.Plo -rm -f ./$(DEPDIR)/libmoo_sck_la-sck.Plo -rm -f ./$(DEPDIR)/libmoo_stdio_la-stdio.Plo @@ -849,6 +887,8 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libmoo_con_la-_con.Plo -rm -f ./$(DEPDIR)/libmoo_ffi_la-ffi.Plo + -rm -f ./$(DEPDIR)/libmoo_io_la-io-file.Plo + -rm -f ./$(DEPDIR)/libmoo_io_la-io.Plo -rm -f ./$(DEPDIR)/libmoo_sck_la-sck-addr.Plo -rm -f ./$(DEPDIR)/libmoo_sck_la-sck.Plo -rm -f ./$(DEPDIR)/libmoo_stdio_la-stdio.Plo diff --git a/moo/mod/_io.h b/moo/mod/_io.h index c7662b1..9a735e0 100644 --- a/moo/mod/_io.h +++ b/moo/mod/_io.h @@ -33,7 +33,7 @@ typedef struct io_t* oop_io_t; struct io_t { MOO_OBJ_HEADER; - moo_oop_t handle; /* SmallInteger */ + moo_oop_t handle; /* SmallInteger or SmallPointer/LargePointer depending on operating systems */ /* there are more fields in the actual object */ }; @@ -42,8 +42,7 @@ extern "C" { #endif MOO_EXPORT int moo_mod_io (moo_t* moo, moo_mod_t* mod); -/*MOO_EXPORT int moo_mod_io_file (moo_t* moo, moo_mod_t* mod);*/ - +MOO_EXPORT int moo_mod_io_file (moo_t* moo, moo_mod_t* mod); #if defined(__cplusplus) } diff --git a/moo/mod/ffi.c b/moo/mod/ffi.c index 42cd207..02ad2fd 100644 --- a/moo/mod/ffi.c +++ b/moo/mod/ffi.c @@ -1191,15 +1191,6 @@ softfail: /* ------------------------------------------------------------------------ */ -typedef struct fnctab_t fnctab_t; -struct fnctab_t -{ - moo_method_type_t type; - moo_ooch_t mthname[15]; - int variadic; - moo_pfimpl_t handler; -}; - #define C MOO_METHOD_CLASS #define I MOO_METHOD_INSTANCE diff --git a/moo/mod/io-file.c b/moo/mod/io-file.c new file mode 100644 index 0000000..8a934c0 --- /dev/null +++ b/moo/mod/io-file.c @@ -0,0 +1,150 @@ +/* + * $Id$ + * + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "_io.h" +#include "../lib/moo-prv.h" +#include "../lib/moo-utl.h" + +#include +#include +#include +#include +#include + +static moo_pfrc_t pf_open_file (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) +{ + oop_io_t io; + moo_oop_t path, flags, mode; + int fd = -1, fl; + moo_bch_t* tmp; + + io = (oop_io_t)MOO_STACK_GETRCV(moo, nargs); + MOO_PF_CHECK_RCV (moo, + MOO_OOP_IS_POINTER(io) && + MOO_OBJ_BYTESOF(io) >= (MOO_SIZEOF(*io) - MOO_SIZEOF(moo_obj_t)) + ); + + if (nargs == 1) + { + /* special form of opening. the socket handle is given */ + io->handle = MOO_STACK_GETARG(moo, nargs, 0); + MOO_STACK_SETRETTORCV (moo, nargs); + return MOO_PF_SUCCESS; + } + + path = MOO_STACK_GETARG(moo, nargs, 0); + flags = MOO_STACK_GETARG(moo, nargs, 1); + mode = (nargs < 3)? MOO_SMOOI_TO_OOP(0644): MOO_STACK_GETARG(moo, nargs, 2); + + MOO_PF_CHECK_ARGS (moo, nargs, MOO_OBJ_IS_CHAR_POINTER(path) && MOO_OOP_IS_SMOOI(flags) && MOO_OOP_IS_SMOOI(mode)); + MOO_PF_CHECK_ARGS (moo, nargs, moo_count_oocstr(MOO_OBJ_GET_CHAR_SLOT(path)) == MOO_OBJ_GET_SIZE(path)); + +#if defined(MOO_OOCH_IS_UCH) + tmp = moo_dupootobcstr(moo, MOO_OBJ_GET_CHAR_SLOT(path), MOO_NULL); + if (!tmp) goto oops; + fd = open(tmp, MOO_OOP_TO_SMOOI(flags), MOO_OOP_TO_SMOOI(mode)); + moo_freemem (moo, tmp); +#else + fd = open(MOO_OBJ_GET_CHAR_SLOT(path), MOO_OOP_TO_SMOOI(flags), MOO_OOP_TO_SMOOI(mode)); +#endif + if (fd == -1) + { + moo_seterrwithsyserr (moo, 0, errno); + goto oops; + } + + if (!MOO_IN_SMOOI_RANGE(fd)) + { + /* the io descriptor is too big to be represented as a small integer */ + moo_seterrbfmt (moo, MOO_ERANGE, "IO handle %d not in the permitted range", fd); + goto oops; + } + + fl = fcntl(fd, F_GETFL, 0); + if (fl == -1) + { + fcntl_failure: + moo_seterrwithsyserr (moo, 0, errno); + goto oops; + } + + fl |= O_NONBLOCK; +#if defined(O_CLOEXEC) + fl |= O_CLOEXEC; +#endif + + if (fcntl(fd, F_SETFL, fl) == -1) goto fcntl_failure; + + io->handle = MOO_SMOOI_TO_OOP(fd); + MOO_STACK_SETRETTORCV (moo, nargs); + + return MOO_PF_SUCCESS; + +oops: + if (fd >= 0) close (fd); + return MOO_PF_FAILURE; +} + + +/* ------------------------------------------------------------------------ */ + +#define C MOO_METHOD_CLASS +#define I MOO_METHOD_INSTANCE + +#define MA MOO_TYPE_MAX(moo_oow_t) + +static moo_pfinfo_t pfinfos[] = +{ + { I, { 'o','p','e','n',':','f','l','a','g','s',':','\0' }, 0, { pf_open_file, 2, 2 } }, + { I, { 'o','p','e','n',':','f','l','a','g','s',':','m','o','d','e',':','\0' }, 0, { pf_open_file, 3, 3 } }, +}; + +/* ------------------------------------------------------------------------ */ + +static int import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class) +{ + /*if (moo_setclasstrsize(moo, _class, MOO_SIZEOF(io_t), MOO_NULL) <= -1) return -1;*/ + return 0; +} + +static moo_pfbase_t* query (moo_t* moo, moo_mod_t* mod, const moo_ooch_t* name, moo_oow_t namelen) +{ + return moo_findpfbase (moo, pfinfos, MOO_COUNTOF(pfinfos), name, namelen); +} + +static void unload (moo_t* moo, moo_mod_t* mod) +{ + /* TODO: anything? close open open dll handles? For that, pf_open must store the value it returns to mod->ctx or somewhere..*/ +} + +int moo_mod_io_file (moo_t* moo, moo_mod_t* mod) +{ + mod->import = import; + mod->query = query; + mod->unload = unload; + mod->ctx = MOO_NULL; + return 0; +} diff --git a/moo/mod/io.c b/moo/mod/io.c index 0287db5..f05a1ee 100644 --- a/moo/mod/io.c +++ b/moo/mod/io.c @@ -31,12 +31,6 @@ #include #include -typedef struct io_modctx_t io_modctx_t; -struct io_modctx_t -{ - moo_oop_class_t io_class; -}; - static moo_pfrc_t pf_close_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) { oop_io_t io; @@ -53,6 +47,7 @@ static moo_pfrc_t pf_close_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (fd >= 0) { moo_releaseiohandle (moo, MOO_OOP_TO_SMOOI(io->handle)); + /* TODO: win32 CloseHandle if handle is HANDLE */ if (close(MOO_OOP_TO_SMOOI(io->handle)) == -1) { moo_seterrwithsyserr (moo, 0, errno); @@ -70,8 +65,7 @@ static moo_pfrc_t pf_close_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) return MOO_PF_FAILURE; } -#if 0 -static moo_pfrc_t pf_read_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) +static moo_pfrc_t pf_read_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) { oop_io_t io; moo_oop_byte_t buf; @@ -89,7 +83,80 @@ static moo_pfrc_t pf_read_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) fd = MOO_OOP_TO_SMOOI(io->handle); if (fd <= -1) { - moo_seterrbfmt (moo, MOO_EINVAL, "bad socket handle - %d", fd); + moo_seterrbfmt (moo, MOO_EINVAL, "bad IO handle - %d", fd); + return MOO_PF_FAILURE; + } + + buf = (moo_oop_byte_t)MOO_STACK_GETARG (moo, nargs, 0); + if (!MOO_OBJ_IS_BYTE_POINTER(buf)) + { + moo_seterrbfmt (moo, MOO_EINVAL, "buffer not a byte array - %O", buf); + return MOO_PF_FAILURE; + } + + offset = 0; + maxlen = MOO_OBJ_GET_SIZE(buf); + length = maxlen; + + if (nargs >= 2) + { + moo_oop_t tmp; + + tmp = MOO_STACK_GETARG(moo, nargs, 1); + if (moo_inttooow(moo, tmp, &offset) <= 0) + { + moo_seterrbfmt (moo, MOO_EINVAL, "invalid offset - %O", tmp); + return MOO_PF_FAILURE; + } + + if (nargs >= 3) + { + tmp = MOO_STACK_GETARG(moo, nargs, 2); + if (moo_inttooow(moo, tmp, &length) <= 0) + { + moo_seterrbfmt (moo, MOO_EINVAL, "invalid length - %O", tmp); + return MOO_PF_FAILURE; + } + } + + if (offset >= maxlen) offset = maxlen - 1; + if (length > maxlen - offset) length = maxlen - offset; + } + + n = read(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length); + if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) + { + moo_seterrwithsyserr (moo, 0, errno); + return MOO_PF_FAILURE; + } + + /* [NOTE] on EWOULDBLOCK or EGAIN, -1 is returned */ + + MOO_ASSERT (moo, MOO_IN_SMOOI_RANGE(n)); + + MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(n)); + return MOO_PF_SUCCESS; +} + +static moo_pfrc_t pf_write_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) +{ + oop_io_t io; + moo_oop_byte_t buf; + moo_oow_t offset, length, maxlen; + int fd; + ssize_t n; + + io = (oop_io_t)MOO_STACK_GETRCV(moo, nargs); + MOO_PF_CHECK_RCV (moo, + MOO_OOP_IS_POINTER(io) && + MOO_OBJ_BYTESOF(io) >= (MOO_SIZEOF(*io) - MOO_SIZEOF(moo_obj_t)) && + MOO_OOP_IS_SMOOI(io->handle) + ); + + fd = MOO_OOP_TO_SMOOI(io->handle); + if (fd <= -1) + { + moo_seterrbfmt (moo, MOO_EINVAL, "bad IO handle - %d", fd); return MOO_PF_FAILURE; } @@ -129,80 +196,7 @@ static moo_pfrc_t pf_read_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) if (length > maxlen - offset) length = maxlen - offset; } - n = recv(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length, 0); - if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) - { - moo_seterrwithsyserr (moo, 0, errno); - return MOO_PF_FAILURE; - } - - /* [NOTE] on EWOULDBLOCK or EGAIN, -1 is returned */ - - MOO_ASSERT (moo, MOO_IN_SMOOI_RANGE(n)); - - MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(n)); - return MOO_PF_SUCCESS; -} - -static moo_pfrc_t pf_write_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) -{ - oop_io_t io; - moo_oop_byte_t buf; - moo_oow_t offset, length, maxlen; - int fd; - ssize_t n; - - io = (oop_io_t)MOO_STACK_GETRCV(moo, nargs); - MOO_PF_CHECK_RCV (moo, - MOO_OOP_IS_POINTER(io) && - MOO_OBJ_BYTESOF(io) >= (MOO_SIZEOF(*io) - MOO_SIZEOF(moo_obj_t)) && - MOO_OOP_IS_SMOOI(io->handle) - ); - - fd = MOO_OOP_TO_SMOOI(io->handle); - if (fd <= -1) - { - moo_seterrbfmt (moo, MOO_EINVAL, "bad socket handle - %d", fd); - return MOO_PF_FAILURE; - } - - buf = (moo_oop_byte_t)MOO_STACK_GETARG (moo, nargs, 0); - if (!MOO_OBJ_IS_BYTE_POINTER(buf)) - { - moo_seterrbfmt (moo, MOO_EINVAL, "buffer not a byte array - %O", buf); - return MOO_PF_FAILURE; - } - - offset = 0; - maxlen = MOO_OBJ_GET_SIZE(buf); - length = maxlen; - - if (nargs >= 2) - { - moo_oop_t tmp; - - tmp = MOO_STACK_GETARG(moo, nargs, 1); - if (moo_inttooow (moo, tmp, &offset) <= 0) - { - moo_seterrbfmt (moo, MOO_EINVAL, "invalid offset - %O", tmp); - return MOO_PF_FAILURE; - } - - if (nargs >= 3) - { - tmp = MOO_STACK_GETARG(moo, nargs, 2); - if (moo_inttooow(moo, tmp, &length) <= 0) - { - moo_seterrbfmt (moo, MOO_EINVAL, "invalid length - %O", tmp); - return MOO_PF_FAILURE; - } - } - - if (offset >= maxlen) offset = maxlen - 1; - if (length > maxlen - offset) length = maxlen - offset; - } - - n = send(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length, 0); + n = write(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length); if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) { moo_seterrwithsyserr (moo, 0, errno); @@ -215,18 +209,8 @@ static moo_pfrc_t pf_write_io (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(n)); return MOO_PF_SUCCESS; } -#endif /* ------------------------------------------------------------------------ */ - -typedef struct fnctab_t fnctab_t; -struct fnctab_t -{ - moo_method_type_t type; - moo_ooch_t mthname[15]; - int variadic; - moo_pfimpl_t handler; -}; #define C MOO_METHOD_CLASS #define I MOO_METHOD_INSTANCE @@ -235,7 +219,11 @@ struct fnctab_t static moo_pfinfo_t pfinfos[] = { - { I, { 'c','l','o','s','e','\0' }, 0, { pf_close_io, 0, 0 } }, + { I, { 'c','l','o','s','e','\0' }, 0, { pf_close_io, 0, 0 } }, + { I, { 'r','e','a','d','B','y','t','e','s','I','n','t','o',':','\0' }, 0, { pf_read_bytes, 1, 1 } }, + { I, { 'r','e','a','d','B','y','t','e','s','I','n','t','o',':','s','t','a','r','t','i','n','g','A','t',':','f','o','r',':','\0' }, 0, { pf_read_bytes, 3, 3 } }, + { I, { 'w','r','i','t','e','B','y','t','e','s','F','r','o','m',':','\0' }, 0, { pf_write_bytes, 1, 1 } }, + { I, { 'w','r','i','t','e','B','y','t','e','s','F','r','o','m',':','s','t','a','r','t','i','n','g','A','t',':','f','o','r',':','\0' }, 0, { pf_write_bytes, 3, 3 } } }; /* ------------------------------------------------------------------------ */ diff --git a/moo/mod/sck-addr.c b/moo/mod/sck-addr.c index 8f9228e..a671135 100644 --- a/moo/mod/sck-addr.c +++ b/moo/mod/sck-addr.c @@ -514,7 +514,7 @@ static int import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class) /* change the number of the fixed fields forcibly. * the check against the superclass is done by the main compiler * after this import. so i perform no check about the superclass. */ - spec = MOO_CLASS_SPEC_MAKE (MOO_SIZEOF(sockaddr_t), MOO_CLASS_SPEC_FLAGS(spec), MOO_CLASS_SPEC_INDEXED_TYPE(spec)); + spec = MOO_CLASS_SPEC_MAKE(MOO_SIZEOF(sockaddr_t), MOO_CLASS_SPEC_FLAGS(spec), MOO_CLASS_SPEC_INDEXED_TYPE(spec)); _class->spec = MOO_SMOOI_TO_OOP(spec); return 0; } diff --git a/moo/mod/sck.c b/moo/mod/sck.c index 314cab5..0d5b8d6 100644 --- a/moo/mod/sck.c +++ b/moo/mod/sck.c @@ -69,7 +69,6 @@ static moo_pfrc_t pf_open_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) dom = MOO_STACK_GETARG(moo, nargs, 0); type = MOO_STACK_GETARG(moo, nargs, 1); proto = (nargs < 3)? 0: MOO_STACK_GETARG(moo, nargs, 2); - MOO_PF_CHECK_ARGS (moo, nargs, MOO_OOP_IS_SMOOI(dom) && MOO_OOP_IS_SMOOI(type) && MOO_OOP_IS_SMOOI(proto)); @@ -79,7 +78,7 @@ static moo_pfrc_t pf_open_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) create_socket: #endif - fd = socket (MOO_OOP_TO_SMOOI(dom), typev, MOO_OOP_TO_SMOOI(proto)); + fd = socket(MOO_OOP_TO_SMOOI(dom), typev, MOO_OOP_TO_SMOOI(proto)); if (fd == -1) { #if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) @@ -569,15 +568,6 @@ static moo_pfrc_t pf_write_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) } /* ------------------------------------------------------------------------ */ - -typedef struct fnctab_t fnctab_t; -struct fnctab_t -{ - moo_method_type_t type; - moo_ooch_t mthname[15]; - int variadic; - moo_pfimpl_t handler; -}; #define C MOO_METHOD_CLASS #define I MOO_METHOD_INSTANCE