summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-26 09:45:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-26 09:45:09 +0000
commit05da25f297c4d26b6bb454a9649b1dd63a102910 (patch)
tree568d1118ca9c2c7bfbcaf2d2132a7e870367d407 /ext
parent839f4c5f3fdb4ea6b270fce17f1c3881060087d4 (diff)
980626
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/Setup2
-rw-r--r--ext/socket/socket.c33
-rw-r--r--ext/tcltklib/tcltklib.c87
3 files changed, 91 insertions, 31 deletions
diff --git a/ext/Setup b/ext/Setup
index 4258bd4873..9e3a2474c3 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -1,7 +1,7 @@
#option nodynamic
#GD
-curses
+#curses
#dbm
#etc
#fcntl
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 6748655ff3..18ab8bc9f6 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -10,6 +10,7 @@
#include "ruby.h"
#include "rubyio.h"
+#include "rubysig.h"
#include <stdio.h>
#include <sys/types.h>
#ifndef NT
@@ -24,7 +25,7 @@
#ifdef USE_CWGUSI
extern int fileno(FILE *stream); /* <unix.mac.h> */
-extern int thred_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thread.c */
+extern int thread_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thread.c */
# include <sys/errno.h>
# include <GUSI.h>
#endif
@@ -41,9 +42,6 @@ extern int thred_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thr
#define EWOULDBLOCK EAGAIN
#endif
-extern VALUE cIO;
-extern VALUE cInteger;
-
VALUE cBasicSocket;
VALUE cIPsocket;
VALUE cTCPsocket;
@@ -55,7 +53,6 @@ VALUE cUNIXserver;
#endif
VALUE cSocket;
-extern VALUE eStandardError;
static VALUE eSocket;
#ifdef SOCKS
@@ -243,7 +240,7 @@ bsock_send(argc, argv, sock)
fd = fileno(f);
retry:
#ifdef THREAD
- thred_fd_writable(fd);
+ thread_fd_writable(fd);
#endif
m = str2cstr(msg, &mlen);
if (RTEST(to)) {
@@ -262,7 +259,7 @@ bsock_send(argc, argv, sock)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -309,7 +306,7 @@ s_recv(sock, argc, argv, from)
GetOpenFile(sock, fptr);
fd = fileno(fptr->f);
#ifdef THREAD
- thred_wait_fd(fd);
+ thread_wait_fd(fd);
#endif
TRAP_BEG;
retry:
@@ -325,7 +322,7 @@ s_recv(sock, argc, argv, from)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -370,7 +367,7 @@ bsock_recv(argc, argv, sock)
#if defined(THREAD) && defined(HAVE_FCNTL)
static int
-thred_connect(fd, sockaddr, len, type)
+thread_connect(fd, sockaddr, len, type)
int fd;
struct sockaddr *sockaddr;
int len;
@@ -412,9 +409,9 @@ thred_connect(fd, sockaddr, len, type)
FD_ZERO(&fds);
FD_SET(fd, &fds);
#ifndef USE_CWGUSI
- thred_select(fd+1, 0, &fds, 0, 0, 0);
+ thread_select(fd+1, 0, &fds, 0, 0, 0);
#else
- thred_select(fd+1, 0, &fds, 0, 0);
+ thread_select(fd+1, 0, &fds, 0, 0);
#endif
continue;
#endif
@@ -535,7 +532,7 @@ open_inet(class, h, serv, type)
}
else {
#if defined(THREAD) && defined(HAVE_FCNTL)
- status = thred_connect(fd, (struct sockaddr*)&sockaddr,
+ status = thread_connect(fd, (struct sockaddr*)&sockaddr,
sizeof(sockaddr), type);
#else
#ifdef SOCKS
@@ -611,7 +608,7 @@ s_accept(class, fd, sockaddr, len)
retry:
#ifdef THREAD
- thred_wait_fd(fd);
+ thread_wait_fd(fd);
#endif
TRAP_BEG;
fd2 = accept(fd, sockaddr, len);
@@ -624,7 +621,7 @@ s_accept(class, fd, sockaddr, len)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -889,7 +886,7 @@ udp_connect(sock, host, port)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -948,7 +945,7 @@ udp_send(argc, argv, sock)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -1203,7 +1200,7 @@ sock_connect(sock, addr)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 1eb2a48c55..ada4c7a96e 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -52,7 +52,7 @@ void _timer_for_tcl (ClientData clientData)
timer->flag = 0;
CHECK_INTS;
#ifdef THREAD
- if (!thred_critical) thred_schedule();
+ if (!thread_critical) thread_schedule();
#endif
timer->token = Tk_CreateTimerHandler(200, _timer_for_tcl,
@@ -102,22 +102,36 @@ ip_eval_rescue(VALUE *failed, VALUE einfo)
}
static int
+#if TCL_MAJOR_VERSION >= 8
+ip_ruby(ClientData clientData, Tcl_Interp *interp,
+ int argc, Tcl_Obj *CONST argv[])
+#else
ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
+#endif
{
VALUE res;
int old_trapflg;
VALUE failed = 0;
+ char *arg;
+ int dummy;
/* ruby command has 1 arg. */
if (argc != 2) {
ArgError("wrong # of arguments (%d for 1)", argc);
}
+ /* get C string from Tcl object */
+#if TCL_MAJOR_VERSION >= 8
+ arg = Tcl_GetStringFromObj(argv[1], &dummy);
+#else
+ arg = argv[1];
+#endif
+
/* evaluate the argument string by ruby */
- DUMP2("rb_eval_string(%s)", argv[1]);
+ DUMP2("rb_eval_string(%s)", arg);
old_trapflg = trap_immediate;
trap_immediate = 0;
- res = rb_rescue(rb_eval_string, (VALUE)argv[1], ip_eval_rescue, (VALUE)&failed);
+ res = rb_rescue(rb_eval_string, (VALUE)arg, ip_eval_rescue, (VALUE)&failed);
trap_immediate = old_trapflg;
Tcl_ResetResult(interp);
@@ -178,9 +192,15 @@ ip_new(VALUE self)
(Tcl_PackageInitProc *) NULL);
/* add ruby command to the interpreter */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"ruby\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby, (ClientData *)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+#else
DUMP1("Tcl_CreateCommand(\"ruby\")");
Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby, (ClientData *)NULL,
(Tcl_CmdDeleteProc *)NULL);
+#endif
return obj;
}
@@ -216,28 +236,71 @@ ip_invoke(int argc, VALUE *argv, VALUE obj)
{
struct tcltkip *ptr; /* tcltkip data struct */
int i;
+ int object = 0;
Tcl_CmdInfo info;
- char **av;
+ char *cmd;
+ char **av = (char **)NULL;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **ov = (Tcl_Obj **)NULL;
+ Tcl_Obj *resultPtr;
+#endif
/* get the data struct */
Data_Get_Struct(obj, struct tcltkip, ptr);
- av = (char **)ALLOCA_N(char **, argc+1);
- for (i = 0; i < argc; ++i) {
+ /* get the command name string */
+ cmd = STR2CSTR(argv[0]);
+
+ /* map from the command name to a C procedure */
+ if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) {
+ NameError("invalid command name `%s'", cmd);
+ }
+#if TCL_MAJOR_VERSION >= 8
+ object = info.isNativeObjectProc;
+#endif
+
+ /* memory allocation for arguments of this command */
+ if (object) {
+#if TCL_MAJOR_VERSION >= 8
+ /* object interface */
+ ov = (Tcl_Obj **)ALLOCA_N(Tcl_Obj *, argc+1);
+ for (i = 0; i < argc; ++i) {
+ char *s = STR2CSTR(argv[i]);
+ ov[i] = Tcl_NewStringObj(s, strlen(s));
+ }
+ ov[argc] = (Tcl_Obj *)NULL;
+#endif
+ } else {
+ /* string interface */
+ av = (char **)ALLOCA_N(char *, argc+1);
+ for (i = 0; i < argc; ++i) {
char *s = STR2CSTR(argv[i]);
av[i] = ALLOCA_N(char, strlen(s)+1);
strcpy(av[i], s);
+ }
+ av[argc] = (char *)NULL;
}
- av[argc] = NULL;
- if (!Tcl_GetCommandInfo(ptr->ip, av[0], &info)) {
- NameError("invalid command name `%s'", av[0]);
+ Tcl_ResetResult(ptr->ip);
+
+ /* Invoke the C procedure */
+ if (object) {
+#if TCL_MAJOR_VERSION >= 8
+ int dummy;
+ ptr->return_value = (*info.objProc)(info.objClientData,
+ ptr->ip, argc, ov);
+
+ /* get the string value from the result object */
+ resultPtr = Tcl_GetObjResult(ptr->ip);
+ Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy),
+ TCL_VOLATILE);
+#endif
+ } else {
+ ptr->return_value = (*info.proc)(info.clientData,
+ ptr->ip, argc, av);
}
- Tcl_ResetResult(ptr->ip);
- ptr->return_value = (*info.proc)(info.clientData,
- ptr->ip, argc, av);
if (ptr->return_value == TCL_ERROR) {
Fail(ptr->ip->result);
}