Mercurial > pidgin.yaz
diff plugins/tcl/tcl_cmds.c @ 10597:0e886a234d92
[gaim-migrate @ 12012]
This is a nontrivial change to the way signal handlers are implemented
and used in Tcl. This changes signal handlers to being standard Tcl
functions by way of a little bit of namespace glue. In addition,
in/out arguments to signals are now implemented via variables which
should be upvar'd; this is a little more verbose than the old method,
but it should fit people's Tcl expectations a little better, since
normally Tcl function arguments are not call-by-reference.
This still isn't 64-bit safe, and the documentation wasn't updated. I
expect there will be more nontrivial changes to Tcl before 2.0, so
those things are pending.
Ethan
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Mon, 14 Feb 2005 03:11:23 +0000 |
parents | 3e4ecbdf8d0a |
children | 55af3fa46329 |
line wrap: on
line diff
--- a/plugins/tcl/tcl_cmds.c Mon Feb 14 03:08:43 2005 +0000 +++ b/plugins/tcl/tcl_cmds.c Mon Feb 14 03:11:23 2005 +0000 @@ -36,6 +36,7 @@ #include "tcl_gaim.h" static gboolean tcl_validate_account(GaimAccount *account, Tcl_Interp *interp); +static gboolean tcl_validate_conversation(GaimConversation *convo, Tcl_Interp *interp); static gboolean tcl_validate_gc(GaimConnection *gc); static gboolean tcl_validate_account(GaimAccount *account, Tcl_Interp *interp) @@ -862,9 +863,9 @@ const char *cmds[] = { "connect", "disconnect", NULL }; enum { CMD_SIGNAL_CONNECT, CMD_SIGNAL_DISCONNECT } cmd; struct tcl_signal_handler *handler; - Tcl_Obj **elems, *result = Tcl_GetObjResult(interp); + Tcl_Obj *result = Tcl_GetObjResult(interp); void *instance; - int error, nelems, i; + int error; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); @@ -880,24 +881,14 @@ Tcl_WrongNumArgs(interp, 2, objv, "instance signal args proc"); return TCL_ERROR; } - if ((error = Tcl_ListObjGetElements(interp, objv[4], &nelems, &elems)) != TCL_OK) - return error; handler = g_new0(struct tcl_signal_handler, 1); if ((error = Tcl_GetIntFromObj(interp, objv[2], (int *)&handler->instance)) != TCL_OK) { g_free(handler); return error; } - handler->signal = g_strdup(Tcl_GetString(objv[3])); - if (nelems) { - handler->argnames = g_new0(char *, nelems); - for (i = 0; i < nelems; i++) { - handler->argnames[i] = g_strdup(Tcl_GetString(elems[i])); - } - } - handler->nnames = nelems; - handler->proc = Tcl_NewStringObj("namespace eval ::gaim::_callback { ", -1); - Tcl_AppendStringsToObj(handler->proc, Tcl_GetString(objv[5]), " }", NULL); - Tcl_IncrRefCount(handler->proc); + handler->signal = objv[3]; + handler->args = objv[4]; + handler->proc = objv[5]; handler->interp = interp; if (!tcl_signal_connect(handler)) { tcl_signal_handler_free(handler);