]> granicus.if.org Git - vim/commitdiff
patch 7.4.1169 v7.4.1169
authorBram Moolenaar <Bram@vim.org>
Sun, 24 Jan 2016 19:36:41 +0000 (20:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 24 Jan 2016 19:36:41 +0000 (20:36 +0100)
Problem:    The socket I/O is intertwined with the netbeans code.
Solution:   Start refactoring the netbeans communication to split off the
            socket I/O.  Add the +channel feature.

22 files changed:
src/Make_bc5.mak
src/Make_cyg_ming.mak
src/Make_mvc.mak
src/auto/configure
src/channel.c [new file with mode: 0644]
src/config.aap.in
src/config.h.in
src/config.mk.in
src/configure.in
src/eval.c
src/feature.h
src/gui_w32.c
src/macros.h
src/netbeans.c
src/os_mswin.c
src/os_unix.c
src/proto.h
src/proto/channel.pro [new file with mode: 0644]
src/proto/netbeans.pro
src/ui.c
src/version.c
src/vim.h

index 8dcb6e8b4cf6714f4eaf1a2a6f48f42eb3a0aff8..cb48ce05a36575cc75c69ecfa2f2eb54b2cc8f30 100644 (file)
 #              (BIG for WIN32, SMALL for DOS16)
 # WINVER       0x0400 or 0x0500: minimum Win32 version to support (0x0400)
 # CSCOPE       no or yes: include support for Cscope interface (yes)
-# NETBEANS     no or yes: include support for Netbeans interface (yes if GUI
+# NETBEANS     no or yes: include support for Netbeans interface; also
+#              requires CHANNEL (yes if GUI
 #              is yes)
 # NBDEBUG      no or yes: include support for debugging Netbeans interface (no)
+# CHANNEL      no or yes: include support for inter process communication (yes
+#              if GUI is yes)
 # XPM          define to path to XPM dir to get support for loading XPM images.
 
 ### BOR: root of the BC installation
@@ -137,6 +140,11 @@ CSCOPE = yes
 NETBEANS = yes
 !endif
 
+### CHANNEL: yes to enable inter process communication, no to disable it
+!if ("$(CHANNEL)"=="") && ("$(GUI)"=="yes")
+CHANNEL = yes
+!endif
+
 ### LUA: uncomment this line if you want lua support in vim
 # LUA=c:\lua
 
@@ -466,6 +474,7 @@ LINK2 = -aa
 RESFILE = vim.res
 !else
 !undef NETBEANS
+!undef CHANNEL
 !undef XPM
 !undef VIMDLL
 !if ("$(DEBUG)"=="yes")
@@ -488,12 +497,21 @@ RESFILE = vim.res
 !endif
 
 !if ("$(NETBEANS)"=="yes")
+!if ("$(CHANNEL)"!="yes")
+# cannot use Netbeans without CHANNEL
+NETBEANS = no
+!else
 DEFINES = $(DEFINES) -DFEAT_NETBEANS_INTG
 !if ("$(NBDEBUG)"=="yes")
 DEFINES = $(DEFINES) -DNBDEBUG
 NBDEBUG_DEP = nbdebug.h nbdebug.c
 !endif
 !endif
+!endif
+
+!if ("$(CHANNEL)"=="yes")
+DEFINES = $(DEFINES) -DFEAT_CHANNEL
+!endif
 
 !ifdef XPM
 !if ("$(GUI)"=="yes")
@@ -673,6 +691,11 @@ vimobj = $(vimobj) \
     $(OBJDIR)\netbeans.obj
 !endif
 
+!if ("$(CHANNEL)"=="yes")
+vimobj = $(vimobj) \
+    $(OBJDIR)\channel.obj
+!endif
+
 !ifdef XPM
 vimobj = $(vimobj) \
     $(OBJDIR)\xpm_w32.obj
@@ -748,6 +771,9 @@ MSG = $(MSG) CSCOPE
 !if ("$(NETBEANS)"=="yes")
 MSG = $(MSG) NETBEANS
 !endif
+!if ("$(CHANNEL)"=="yes")
+MSG = $(MSG) CHANNEL
+!endif
 !ifdef XPM
 MSG = $(MSG) XPM
 !endif
@@ -1029,6 +1055,9 @@ $(OBJDIR)\xpm_w32.obj: xpm_w32.c xpm.lib
 $(OBJDIR)\netbeans.obj: netbeans.c $(NBDEBUG_DEP)
        $(CC) $(CCARG) $(CC1) $(CC2)$@ netbeans.c
 
+$(OBJDIR)\channel.obj: channel.c
+       $(CC) $(CCARG) $(CC1) $(CC2)$@ channel.c
+
 $(OBJDIR)\vim.res: vim.rc version.h tools.bmp tearoff.bmp \
                vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico
        $(BRC) -fo$(OBJDIR)\vim.res -i $(BOR)\include -w32 -r vim.rc @&&|
index 7c7acbd4b1fab5cd129478c968086ddf080c4b8c..5c7332e1c515a694ed7ea47c1bf61a4ed651827e 100644 (file)
@@ -64,8 +64,10 @@ WINVER = 0x0500
 endif
 # Set to yes to enable Cscope support.
 CSCOPE=yes
-# Set to yes to enable Netbeans support.
+# Set to yes to enable Netbeans support (requires CHANNEL).
 NETBEANS=$(GUI)
+# Set to yes to enable inter process communication.
+CHANNEL=$(GUI)
 
 
 # Link against the shared version of libstdc++ by default.  Set
@@ -526,6 +528,10 @@ endif
 endif
 endif
 
+ifeq ($(CHANNEL),yes)
+DEFINES += -DFEAT_CHANNEL
+endif
+
 # DirectWrite (DirectX)
 ifeq ($(DIRECTX),yes)
 # Only allow DirectWrite for a GUI build.
@@ -667,13 +673,28 @@ endif
 ifeq ($(CSCOPE),yes)
 OBJ += $(OUTDIR)/if_cscope.o
 endif
+
 ifeq ($(NETBEANS),yes)
+ifneq ($(CHANNEL),yes)
+# Cannot use Netbeans without CHANNEL
+NETBEANS=no
+else
 # Only allow NETBEANS for a GUI build.
 ifeq (yes, $(GUI))
 OBJ += $(OUTDIR)/netbeans.o
 LIB += -lwsock32
 endif
 endif
+endif
+
+ifeq ($(CHANNEL),yes)
+OBJ += $(OUTDIR)/channel.o
+ifneq ($(NETBEANS),yes)
+LIB += -lwsock32
+endif
+endif
+endif
+
 ifeq ($(DIRECTX),yes)
 # Only allow DIRECTX for a GUI build.
 ifeq (yes, $(GUI))
@@ -866,6 +887,9 @@ if_perl.c: if_perl.xs typemap
 $(OUTDIR)/netbeans.o:  netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
        $(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
 
+$(OUTDIR)/channel.o:   channel.c $(INCL)
+       $(CC) -c $(CFLAGS) channel.c -o $(OUTDIR)/channel.o
+
 $(OUTDIR)/regexp.o:            regexp.c regexp_nfa.c $(INCL)
        $(CC) -c $(CFLAGS) regexp.c -o $(OUTDIR)/regexp.o
 
index c009aa977700f585a790abcd348e1f58dd461e9d..c34a63ed6d55470094056c954e228cd29184fd50 100644 (file)
 #      PostScript printing: POSTSCRIPT=yes (default is no)
 #
 #      Netbeans Support: NETBEANS=[yes or no] (default is yes if GUI is yes)
+#      Requires CHANNEL.
+#
+#      Netbeans Debugging Support: NBDEBUG=[yes or no] (should be no, yes
+#      doesn't work)
+#
+#      Inter process communication: CHANNEL=[yes or no] (default is yes if GUI
+#      is yes)
 #
 #      XPM Image Support: XPM=[path to XPM directory]
 #      Default is "xpm", using the files included in the distribution.
 #        yes:   Write a normal mapfile.
 #        lines: Write a mapfile with line numbers (only for VC6 and later)
 #
-#      Netbeans Debugging Support: NBDEBUG=[yes or no] (should be no, yes
-#      doesn't work)
-#
 #      Static Code Analysis: ANALYZE=yes (works with VS2012 only)
 #
 # You can combine any of these interfaces
@@ -290,9 +294,13 @@ CSCOPE_DEFS  = -DFEAT_CSCOPE
 NETBEANS = $(GUI)
 !endif
 
-# Only allow NETBEANS and XPM for a GUI build.
+!ifndef CHANNEL
+CHANNEL = $(GUI)
+!endif
+
+# Only allow NETBEANS and XPM for a GUI build and CHANNEL.
 !if "$(GUI)" == "yes"
-!if "$(NETBEANS)" == "yes"
+!if "$(NETBEANS)" == "yes" && "$(CHANNEL)" == "yes"
 # NETBEANS - Include support for Netbeans integration
 NETBEANS_PRO   = proto/netbeans.pro
 NETBEANS_OBJ   = $(OBJDIR)/netbeans.obj
@@ -333,6 +341,14 @@ XPM_INC      = -I $(XPM)\include -I $(XPM)\..\include
 !endif
 !endif
 
+!if "$(CHANNEL)" == "yes"
+CHANNEL_PRO    = proto/channel.pro
+CHANNEL_OBJ    = $(OBJDIR)/channel.obj
+CHANNEL_DEFS   = -DFEAT_CHANNEL
+
+NETBEANS_LIB   = WSock32.lib
+!endif
+
 # Set which version of the CRT to use
 !if defined(USE_MSVCRT)
 # CVARS = $(cvarsdll)
@@ -365,7 +381,7 @@ WINVER = 0x0400
 #VIMRUNTIMEDIR = somewhere
 
 CFLAGS = -c /W3 /nologo $(CVARS) -I. -Iproto -DHAVE_PATHDEF -DWIN32 \
-               $(SNIFF_DEFS) $(CSCOPE_DEFS) $(NETBEANS_DEFS) \
+               $(SNIFF_DEFS) $(CSCOPE_DEFS) $(NETBEANS_DEFS) $(CHANNEL_DEFS) \
                $(NBDEBUG_DEFS) $(XPM_DEFS) \
                $(DEFINES) -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \
                /Fo$(OUTDIR)/ 
@@ -1005,12 +1021,12 @@ all:    $(VIM).exe \
 
 $(VIM).exe: $(OUTDIR) $(OBJ) $(GUI_OBJ) $(OLE_OBJ) $(OLE_IDL) $(MZSCHEME_OBJ) \
                $(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
-               $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(XPM_OBJ) \
+               $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) \
                version.c version.h
        $(CC) $(CFLAGS) version.c
        $(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(OLE_OBJ) \
                $(LUA_OBJ) $(MZSCHEME_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) \
-               $(TCL_OBJ) $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) \
+               $(TCL_OBJ) $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) \
                $(XPM_OBJ) $(OUTDIR)\version.obj $(LINKARGS2)
        if exist $(VIM).exe.manifest mt.exe -nologo -manifest $(VIM).exe.manifest -updateresource:$(VIM).exe;1
 
@@ -1227,6 +1243,8 @@ $(OUTDIR)/mbyte.obj: $(OUTDIR) mbyte.c  $(INCL)
 
 $(OUTDIR)/netbeans.obj: $(OUTDIR) netbeans.c $(NBDEBUG_SRC) $(INCL)
 
+$(OUTDIR)/channel.obj: $(OUTDIR) channel.c $(INCL)
+
 $(OUTDIR)/normal.obj:  $(OUTDIR) normal.c  $(INCL)
 
 $(OUTDIR)/option.obj:  $(OUTDIR) option.c  $(INCL)
@@ -1362,7 +1380,8 @@ proto.h: \
        proto/ui.pro \
        proto/undo.pro \
        proto/window.pro \
-       $(NETBEANS_PRO)
+       $(NETBEANS_PRO) \
+       $(CHANNEL_PRO)
 
 .SUFFIXES: .cod .i
 
index 96e50935ee0917422290c1c483f125af61d7b5cb..7ba3cc452805b1c53f965572a6a7aa33ac52cdf6 100755 (executable)
@@ -656,6 +656,8 @@ XMKMF
 xmkmfpath
 SNIFF_OBJ
 SNIFF_SRC
+CHANNEL_OBJ
+CHANNEL_SRC
 NETBEANS_OBJ
 NETBEANS_SRC
 WORKSHOP_OBJ
@@ -810,6 +812,7 @@ with_ruby_command
 enable_cscope
 enable_workshop
 enable_netbeans
+enable_channel
 enable_sniff
 enable_multibyte
 enable_hangulinput
@@ -1473,6 +1476,7 @@ Optional Features:
   --enable-cscope         Include cscope interface.
   --enable-workshop       Include Sun Visual Workshop support.
   --disable-netbeans      Disable NetBeans integration support.
+  --disable-channel      Disable process communication support.
   --enable-sniff          Include Sniff interface.
   --enable-multibyte      Include multibyte editing support.
   --enable-hangulinput    Include Hangul input support.
@@ -7227,6 +7231,29 @@ fi
 if test "$enable_netbeans" = "yes"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-channel argument" >&5
+$as_echo_n "checking --disable-channel argument... " >&6; }
+# Check whether --enable-channel was given.
+if test "${enable_channel+set}" = set; then :
+  enableval=$enable_channel;
+else
+  enable_channel="yes"
+fi
+
+if test "$enable_channel" = "yes"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
+if test "$enable_netbeans" = "yes" -o "$enable_channel" = "yes"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
 $as_echo_n "checking for socket in -lsocket... " >&6; }
 if ${ac_cv_lib_socket_socket+:} false; then :
@@ -7317,8 +7344,8 @@ _ACEOF
 
 fi
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling netbeans integration is possible" >&5
-$as_echo_n "checking whether compiling netbeans integration is possible... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling with process communication is possible" >&5
+$as_echo_n "checking whether compiling with process communication is possible... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -7358,13 +7385,10 @@ if ac_fn_c_try_link "$LINENO"; then :
 $as_echo "yes" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }; enable_netbeans="no"
+$as_echo "no" >&6; }; enable_netbeans="no"; enable_channel="no"
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
 fi
 if test "$enable_netbeans" = "yes"; then
   $as_echo "#define FEAT_NETBEANS_INTG 1" >>confdefs.h
@@ -7373,6 +7397,14 @@ if test "$enable_netbeans" = "yes"; then
 
   NETBEANS_OBJ="objects/netbeans.o"
 
+fi
+if test "$enable_channel" = "yes"; then
+  $as_echo "#define FEAT_CHANNEL 1" >>confdefs.h
+
+  CHANNEL_SRC="channel.c"
+
+  CHANNEL_OBJ="objects/channel.o"
+
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-sniff argument" >&5
diff --git a/src/channel.c b/src/channel.c
new file mode 100644 (file)
index 0000000..a108d7e
--- /dev/null
@@ -0,0 +1,187 @@
+/* vi:set ts=8 sts=4 sw=4:
+ *
+ * VIM - Vi IMproved   by Bram Moolenaar
+ *
+ * Do ":help uganda"  in Vim to read copying and usage conditions.
+ * Do ":help credits" in Vim to see a list of people who contributed.
+ */
+
+/*
+ * Implements communication through a socket or any file handle.
+ */
+
+#include "vim.h"
+
+#if defined(FEAT_CHANNEL) || defined(PROTO)
+
+typedef struct {
+    sock_T  ch_fd;
+    int            ch_idx;
+} channel_T;
+
+static channel_T *channels = NULL;
+static int channel_count = 0;
+
+/*
+ * Add a new channel slot, return the index.
+ * Returns -1 if out of space.
+ */
+    static int
+add_channel(void)
+{
+    int                idx;
+    channel_T  *new_channels;
+
+    if (channels != NULL)
+       for (idx = 0; idx < channel_count; ++idx)
+           if (channels[idx].ch_fd < 0)
+               /* re-use a closed channel slot */
+               return idx;
+    if (channel_count == MAX_OPEN_CHANNELS)
+       return -1;
+    new_channels = (channel_T *)alloc(sizeof(channel_T) * channel_count + 1);
+    if (new_channels == NULL)
+       return -1;
+    if (channels != NULL)
+       mch_memmove(new_channels, channels, sizeof(channel_T) * channel_count);
+    channels = new_channels;
+    channels[channel_count].ch_fd = (sock_T)-1;
+
+    return channel_count++;
+}
+
+#if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
+static int netbeans_channel = -1;
+
+/*
+ * Add the netbeans socket to the channels.
+ * Return the channel index.
+ */
+    int
+channel_add_netbeans(sock_T fd)
+{
+    int idx = add_channel();
+
+    if (idx >= 0)
+    {
+       channels[idx].ch_fd = fd;
+       netbeans_channel = idx;
+    }
+    return idx;
+}
+
+    void
+channel_remove_netbeans()
+{
+    channels[netbeans_channel].ch_fd = (sock_T)-1;
+    netbeans_channel = -1;
+}
+#endif
+
+    static void
+channel_read(int idx)
+{
+# ifdef FEAT_NETBEANS_INTG
+    if (idx == netbeans_channel)
+       netbeans_read();
+    else
+# endif
+    {
+       ; /* TODO: read */
+    }
+}
+
+#if (defined(UNIX) && !defined(HAVE_SELECT)) || defined(PROTO)
+/*
+ * Add open channels to the poll struct.
+ * Return the adjusted struct index.
+ * The type of "fds" is hidden to avoid problems with the function proto.
+ */
+    int
+channel_poll_setup(int nfd_in, void *fds_in)
+{
+    int nfd = nfd_in;
+    int i;
+    struct pollfd *fds = fds_in;
+
+    for (i = 0; i < channel_count; ++i)
+       if (channels[i].ch_fd >= 0)
+       {
+           channels[i].ch_idx = nfd;
+           fds[nfd].fd = channels[i].ch_fd;
+           fds[nfd].events = POLLIN;
+           nfd++;
+       }
+       else
+           channels[i].ch_idx = -1;
+
+    return nfd;
+}
+
+/*
+ * The type of "fds" is hidden to avoid problems with the function proto.
+ */
+    int
+channel_poll_check(int ret_in, void *fds_in)
+{
+    int ret = ret_in;
+    int i;
+    struct pollfd *fds = fds_in;
+
+    for (i = 0; i < channel_count; ++i)
+       if (ret > 0 && channels[i].ch_idx != -1
+                                && fds[channels[i].ch_idx].revents & POLLIN)
+       {
+           channel_read(i);
+           --ret;
+       }
+
+    return ret;
+}
+#endif /* UNIX && !HAVE_SELECT */
+
+#if (defined(UNIX) && defined(HAVE_SELECT)) || defined(PROTO)
+/*
+ * The type of "rfds" is hidden to avoid problems with the function proto.
+ */
+    int
+channel_select_setup(int maxfd_in, void *rfds_in)
+{
+    int            maxfd = maxfd_in;
+    int            i;
+    fd_set  *rfds = rfds_in;
+
+    for (i = 0; i < channel_count; ++i)
+       if (channels[i].ch_fd >= 0)
+       {
+           FD_SET(channels[i].ch_fd, rfds);
+           if (maxfd < channels[i].ch_fd)
+               maxfd = channels[i].ch_fd;
+       }
+
+    return maxfd;
+}
+
+/*
+ * The type of "rfds" is hidden to avoid problems with the function proto.
+ */
+    int
+channel_select_check(int ret_in, void *rfds_in)
+{
+    int            ret = ret_in;
+    int            i;
+    fd_set  *rfds = rfds_in;
+
+    for (i = 0; i < channel_count; ++i)
+       if (ret > 0 && channels[i].ch_fd >= 0
+                                      && FD_ISSET(channels[i].ch_fd, rfds))
+       {
+           channel_read(i);
+           --ret;
+       }
+
+    return ret;
+}
+#endif /* UNIX && HAVE_SELECT */
+
+#endif /* FEAT_CHANNEL */
index d398a193abde39999821954099faf1ebc22ec22a..819276feeac61799d6c3beebdfe76b0a2d43a7dc 100644 (file)
@@ -65,6 +65,8 @@ WORKSHOP_OBJ  = @WORKSHOP_OBJ@
 
 NETBEANS_SRC   = @NETBEANS_SRC@
 NETBEANS_OBJ   = @NETBEANS_OBJ@
+CHANNEL_SRC    = @CHANNEL_SRC@
+CHANNEL_OBJ    = @CHANNEL_OBJ@
 
 RUBY           = @vi_cv_path_ruby@
 RUBY_SRC       = @RUBY_SRC@
index d4fd50a3711100009c69db23df098375369e2235..9807bd23e970a43c35d59faf9f86630a29c0962f 100644 (file)
 /* Define if you want to include NetBeans integration. */
 #undef FEAT_NETBEANS_INTG
 
+/* Define if you want to include process communication. */
+#undef FEAT_CHANNEL
+
 /* Define default global runtime path */
 #undef RUNTIME_GLOBAL
 
index 9e16d1325eeeecb145834c7c26f1218cd53daa76..5f7f1d58cfef53e0052e64e872cb38dbcbd36fec 100644 (file)
@@ -89,6 +89,8 @@ WORKSHOP_OBJ  = @WORKSHOP_OBJ@
 
 NETBEANS_SRC   = @NETBEANS_SRC@
 NETBEANS_OBJ   = @NETBEANS_OBJ@
+CHANNEL_SRC    = @CHANNEL_SRC@
+CHANNEL_OBJ    = @CHANNEL_OBJ@
 
 RUBY           = @vi_cv_path_ruby@
 RUBY_SRC       = @RUBY_SRC@
index 4bb49a70af258996543322656802356a5b6fc743..90a17ac847dfc992deb52cbbf9b6cdb7543f8de5 100644 (file)
@@ -1938,10 +1938,30 @@ AC_ARG_ENABLE(netbeans,
        , [enable_netbeans="yes"])
 if test "$enable_netbeans" = "yes"; then
   AC_MSG_RESULT(no)
+else
+  AC_MSG_RESULT(yes)
+fi
+
+AC_MSG_CHECKING(--disable-channel argument)
+AC_ARG_ENABLE(channel,
+       [  --disable-channel      Disable process communication support.],
+       , [enable_channel="yes"])
+if test "$enable_channel" = "yes"; then
+  AC_MSG_RESULT(no)
+else
+  if test "$enable_netbeans" = "yes"; then
+    AC_MSG_RESULT(yes, netbeans also disabled)
+    enable_netbeans="no"
+  else
+    AC_MSG_RESULT(yes)
+  fi
+fi
+
+if "$enable_channel" = "yes"; then
   dnl On Solaris we need the socket and nsl library.
   AC_CHECK_LIB(socket, socket)
   AC_CHECK_LIB(nsl, gethostbyname)
-  AC_MSG_CHECKING(whether compiling netbeans integration is possible)
+  AC_MSG_CHECKING(whether compiling with process communication is possible)
   AC_TRY_LINK([
 #include <stdio.h>
 #include <stdlib.h>
@@ -1967,9 +1987,7 @@ if test "$enable_netbeans" = "yes"; then
                  (void)connect(1, (struct sockaddr *)&server, sizeof(server));
            ],
        AC_MSG_RESULT(yes),
-       AC_MSG_RESULT(no); enable_netbeans="no")
-else
-  AC_MSG_RESULT(yes)
+       AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
 fi
 if test "$enable_netbeans" = "yes"; then
   AC_DEFINE(FEAT_NETBEANS_INTG)
@@ -1978,6 +1996,13 @@ if test "$enable_netbeans" = "yes"; then
   NETBEANS_OBJ="objects/netbeans.o"
   AC_SUBST(NETBEANS_OBJ)
 fi
+if test "$enable_channel" = "yes"; then
+  AC_DEFINE(FEAT_CHANNEL)
+  CHANNEL_SRC="channel.c"
+  AC_SUBST(CHANNEL_SRC)
+  CHANNEL_OBJ="objects/channel.o"
+  AC_SUBST(CHANNEL_OBJ)
+fi
 
 AC_MSG_CHECKING(--enable-sniff argument)
 AC_ARG_ENABLE(sniff,
index 860bc358e7da0daf92d247f8d5854673a813b0ff..d08269fc922468586af135eb831da90e3c9ede5b 100644 (file)
@@ -13083,6 +13083,9 @@ f_has(argvars, rettv)
 #ifdef FEAT_BYTEOFF
        "byte_offset",
 #endif
+#ifdef FEAT_CHANNEL
+       "channel",
+#endif
 #ifdef FEAT_CINDENT
        "cindent",
 #endif
index 5de0fcec38cb332a6d220559b426d78264f4322e..dd18394c5376c67f5fdbbc27a3f99e30a41e3fc4 100644 (file)
  * +sniff              Sniff interface: "--enable-sniff"
  * +sun_workshop       Sun Workshop integration
  * +netbeans_intg      Netbeans integration
+ * +channel            Inter process communication
  */
 
 /*
 # undef FEAT_NETBEANS_INTG
 #endif
 
+/*
+ * The Channel feature requires +eval.
+ */
+#if !defined(FEAT_EVAL) && defined(FEAT_CHANNEL)
+# undef FEAT_CHANNEL
+#endif
+
 /*
  * +signs              Allow signs to be displayed to the left of text lines.
  *                     Adds the ":sign" command.
index db0a9d5bfaa618de3b2f47d7626ae6f69e51c15f..ecc1fab41f2532820d1e243a74082310b202466e 100644 (file)
@@ -553,7 +553,7 @@ typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
 static TMonitorFromWindow   pMonitorFromWindow = NULL;
 static TGetMonitorInfo     pGetMonitorInfo = NULL;
 static HANDLE              user32_lib = NULL;
-#ifdef FEAT_NETBEANS_INTG
+#ifdef FEAT_CHANNEL
 int WSInitialized = FALSE; /* WinSock is initialized */
 #endif
 /*
@@ -5048,12 +5048,14 @@ netbeans_draw_multisign_indicator(int row)
     SetPixel(s_hdc, x+3, y++, gui.currFgColor);
     SetPixel(s_hdc, x+2, y, gui.currFgColor);
 }
+#endif
 
+#if defined(FEAT_CHANNEL) || defined(PROTO)
 /*
  * Initialize the Winsock dll.
  */
     void
-netbeans_init_winsock()
+channel_init_winsock()
 {
     WSADATA wsaData;
     int wsaerr;
index c4d27f80dadf9038504539d50ede3f933b188b02..ec0cdc3f9f7803259f797aa6ad85149d0972af61 100644 (file)
 # define PLINES_NOFILL(x) plines(x)
 #endif
 
-#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_CLIENTSERVER)
+#if defined(FEAT_CHANNEL) || defined(FEAT_CLIENTSERVER)
 # define MESSAGE_QUEUE
 #endif
index 2c15227675f99522f181ebc3f30e584aa4e5a858..14f274df1098a2c6062bef134a874888795b346d 100644 (file)
@@ -106,13 +106,7 @@ static void nb_free __ARGS((void));
 # define NB_HAS_GUI (gui.in_use || gui.starting)
 #endif
 
-#ifdef WIN64
-typedef __int64 NBSOCK;
-#else
-typedef int NBSOCK;
-#endif
-
-static NBSOCK nbsock = -1;             /* socket fd for Netbeans connection */
+static sock_T nbsock = -1;             /* socket fd for Netbeans connection */
 #define NETBEANS_OPEN (nbsock != -1)
 
 #ifdef FEAT_GUI_X11
@@ -175,6 +169,7 @@ nb_close_socket(void)
 
     sock_close(nbsock);
     nbsock = -1;
+    channel_remove_netbeans();
 }
 
 /*
@@ -243,8 +238,7 @@ netbeans_connect(char *params, int doabort)
     if (*params == '=')
     {
        /* "=fname": Read info from specified file. */
-       if (getConnInfo(params + 1, &hostname, &address, &password)
-                                                                     == FAIL)
+       if (getConnInfo(params + 1, &hostname, &address, &password) == FAIL)
            return FAIL;
     }
     else
@@ -312,13 +306,13 @@ netbeans_connect(char *params, int doabort)
        goto theend;        /* out of memory */
 
 #ifdef FEAT_GUI_W32
-    netbeans_init_winsock();
+    channel_init_winsock();
 #endif
 
 #ifdef INET_SOCKETS
     port = atoi(address);
 
-    if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
+    if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1)
     {
        nbdebug(("error in socket() in netbeans_connect()\n"));
        PERROR("socket() in netbeans_connect()");
@@ -358,7 +352,7 @@ netbeans_connect(char *params, int doabort)
        {
            sock_close(sd);
 #ifdef INET_SOCKETS
-           if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
+           if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1)
            {
                SOCK_ERRNO;
                nbdebug(("socket()#2 in netbeans_connect()\n"));
@@ -423,6 +417,7 @@ netbeans_connect(char *params, int doabort)
     }
 
     nbsock = sd;
+    channel_add_netbeans(nbsock);
     vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
     nb_send(buf, "netbeans_connect");
 
@@ -2954,7 +2949,7 @@ netbeans_beval_cb(
 #endif
 
 /*
- * Return TRUE when the netbeans connection is closed.
+ * Return TRUE when the netbeans connection is active.
  */
     int
 netbeans_active(void)
@@ -2962,15 +2957,6 @@ netbeans_active(void)
     return NETBEANS_OPEN;
 }
 
-/*
- * Return netbeans file descriptor.
- */
-    int
-netbeans_filedesc(void)
-{
-    return nbsock;
-}
-
 #if defined(FEAT_GUI) || defined(PROTO)
 /*
  * Register our file descriptor with the gui event handling system.
index 698c210f4471b41ecbd5ccb9c18170504c93137c..ed7aa834d4e471743ba42cce3da5b22d83e366e8 100644 (file)
@@ -231,7 +231,7 @@ mch_exit(int r)
 # ifdef FEAT_OLE
     UninitOLE();
 # endif
-# ifdef FEAT_NETBEANS_INTG
+# ifdef FEAT_CHANNEL
     if (WSInitialized)
     {
        WSInitialized = FALSE;
index d2e1c79bd9a962dbdf7be7eaab6d2c9349ac47a4..0a73c8894188f021df0a988073405032f15b4f42 100644 (file)
@@ -5189,9 +5189,6 @@ RealWaitForChar(fd, msec, check_for_gpm)
     int                *check_for_gpm UNUSED;
 {
     int                ret;
-#ifdef FEAT_NETBEANS_INTG
-    int                nb_fd = netbeans_filedesc();
-#endif
 #if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
     static int busy = FALSE;
 
@@ -5241,7 +5238,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
 # endif
 #endif
 #ifndef HAVE_SELECT
-       struct pollfd   fds[6];
+       struct pollfd   fds[6 + MAX_OPEN_CHANNELS];
        int             nfd;
 # ifdef FEAT_XCLIPBOARD
        int             xterm_idx = -1;
@@ -5251,9 +5248,6 @@ RealWaitForChar(fd, msec, check_for_gpm)
 # endif
 # ifdef USE_XSMP
        int             xsmp_idx = -1;
-# endif
-# ifdef FEAT_NETBEANS_INTG
-       int             nb_idx = -1;
 # endif
        int             towait = (int)msec;
 
@@ -5306,14 +5300,8 @@ RealWaitForChar(fd, msec, check_for_gpm)
            nfd++;
        }
 # endif
-#ifdef FEAT_NETBEANS_INTG
-       if (nb_fd != -1)
-       {
-           nb_idx = nfd;
-           fds[nfd].fd = nb_fd;
-           fds[nfd].events = POLLIN;
-           nfd++;
-       }
+#ifdef FEAT_CHANNEL
+       nfd = channel_poll_setup(nfd, &fds);
 #endif
 
        ret = poll(fds, nfd, towait);
@@ -5368,12 +5356,9 @@ RealWaitForChar(fd, msec, check_for_gpm)
                finished = FALSE;       /* Try again */
        }
 # endif
-#ifdef FEAT_NETBEANS_INTG
-       if (ret > 0 && nb_idx != -1 && fds[nb_idx].revents & POLLIN)
-       {
-           netbeans_read();
-           --ret;
-       }
+#ifdef FEAT_CHANNEL
+       if (ret > 0)
+           ret = channel_poll_check(ret, &fds);
 #endif
 
 
@@ -5462,13 +5447,8 @@ select_eintr:
                maxfd = xsmp_icefd;
        }
 # endif
-# ifdef FEAT_NETBEANS_INTG
-       if (nb_fd != -1)
-       {
-           FD_SET(nb_fd, &rfds);
-           if (maxfd < nb_fd)
-               maxfd = nb_fd;
-       }
+# ifdef FEAT_CHANNEL
+       maxfd = channel_select_setup(maxfd, &rfds);
 # endif
 
        ret = select(maxfd + 1, &rfds, NULL, &efds, tvp);
@@ -5556,12 +5536,9 @@ select_eintr:
            }
        }
 # endif
-#ifdef FEAT_NETBEANS_INTG
-       if (ret > 0 && nb_fd != -1 && FD_ISSET(nb_fd, &rfds))
-       {
-           netbeans_read();
-           --ret;
-       }
+#ifdef FEAT_CHANNEL
+       if (ret > 0)
+           ret = channel_select_check(ret, &rfds);
 #endif
 
 #endif /* HAVE_SELECT */
index 5f52a314b2eb2c13bb9d40aca951db13f4e47fbf..7a48dc973aa5718e2365f4ebb534cc718c93bdfe 100644 (file)
@@ -209,6 +209,9 @@ void qsort __ARGS((void *base, size_t elm_count, size_t elm_size, int (*cmp)(con
 # ifdef FEAT_NETBEANS_INTG
 #  include "netbeans.pro"
 # endif
+# ifdef FEAT_CHANNEL
+#  include "channel.pro"
+# endif
 
 # ifdef FEAT_GUI
 #  include "gui.pro"
diff --git a/src/proto/channel.pro b/src/proto/channel.pro
new file mode 100644 (file)
index 0000000..d2e9b3a
--- /dev/null
@@ -0,0 +1,8 @@
+/* channel.c */
+int channel_add_netbeans(sock_T fd);
+void channel_remove_netbeans(void);
+int channel_poll_setup(int nfd_in, void *fds_in);
+int channel_poll_check(int ret_in, void *fds_in);
+int channel_select_setup(int maxfd_in, void *rfds_in);
+int channel_select_check(int ret_in, void *rfds_in);
+/* vim: set ft=c : */
index 7805baf20cb8ce8f1b99625cc4f27ddaf34cd6d2..c7e1f068893e523cd13d722ed4939689fd993ee5 100644 (file)
@@ -9,7 +9,6 @@ void ex_nbkey(exarg_T *eap);
 void ex_nbstart(exarg_T *eap);
 void netbeans_beval_cb(BalloonEval *beval, int state);
 int netbeans_active(void);
-int netbeans_filedesc(void);
 void netbeans_gui_register(void);
 void netbeans_open(char *params, int doabort);
 void netbeans_send_disconnect(void);
index f622f041899b887b5dc05a7a9c9acc6c2dabd3bb..9bcf80b3f97c5525acc546b32d7f946309293a3b 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -1562,7 +1562,7 @@ clip_gen_owner_exists(cbd)
  * descriptions which would otherwise overflow.  The buffer is considered full
  * when only this extra space (or part of it) remains.
  */
-#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
+#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_CHANNEL) \
        || defined(FEAT_CLIENTSERVER)
    /*
     * Sun WorkShop and NetBeans stuff debugger commands into the input buffer.
index 1ea136d0b4d5818e94bb1d522ab13a77341c7f89..61bc28495fe3aff5bd728c8cfd313cd8bb58282a 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1169,
 /**/
     1168,
 /**/
index 90a5353c3f269414b8f2291bd12a1ff6956b1374..e7a5f5842190e3e99b80ac9ac8d45eea657f04ea 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -1929,8 +1929,8 @@ typedef int proftime_T;       /* dummy for function prototypes */
 #  ifdef FEAT_OLE
 #   define WM_OLE (WM_APP+0)
 #  endif
-#  ifdef FEAT_NETBEANS_INTG
-    /* message for Netbeans socket event */
+#  ifdef FEAT_CHANNEL
+    /* message for channel socket event */
 #   define WM_NETBEANS (WM_APP+1)
 #  endif
 # endif
@@ -1979,6 +1979,14 @@ typedef int VimClipboard;        /* This is required for the prototypes. */
 # define stat(a,b) (access(a,0) ? -1 : stat(a,b))
 #endif
 
+#ifdef FEAT_CHANNEL
+# ifdef WIN64
+typedef __int64 sock_T;
+# else
+typedef int sock_T;
+# endif
+#endif
+
 #include "ex_cmds.h"       /* Ex command defines */
 #include "proto.h"         /* function prototypes */
 
@@ -2312,4 +2320,10 @@ typedef int VimClipboard;        /* This is required for the prototypes. */
 # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag)
 #endif
 
+#ifdef FEAT_CHANNEL
+# define MAX_OPEN_CHANNELS 10
+#else
+# define MAX_OPEN_CHANNELS 0
+#endif
+
 #endif /* VIM__H */