From: Herman B. <her...@us...> - 2003-12-11 19:06:31
|
Update of /cvsroot/gaim/gaim/plugins/tcl In directory sc8-pr-cvs1:/tmp/cvs-serv7998 Modified Files: .cvsignore tcl.c tcl_glib.c Added Files: tcl_win32.c Makefile.mingw Log Message: Using tcl and tk stubs for Windows tcl loader --- NEW FILE: tcl_win32.c --- /** * @file tcl_win32.c Gaim Tcl Windows Init * * gaim * * Copyright (C) 2003 Herman Bloggs <her...@ya...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "internal.h" #include "debug.h" #include <tcl.h> #ifdef HAVE_TK #include <tk.h> #endif typedef Tcl_Interp* (CALLBACK* LPFNTCLCREATEINTERP)(); typedef void (CALLBACK* LPFNTKINIT)(Tcl_Interp*); LPFNTCLCREATEINTERP wtcl_CreateInterp = NULL; LPFNTKINIT wtk_Init = NULL; BOOL tcl_win32_init() { if(!(wtcl_CreateInterp=(LPFNTCLCREATEINTERP)wgaim_find_and_loadproc("tcl84.dll", "Tcl_CreateInterp"))) { gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tcl_CreateInterp\n"); return FALSE; } if(!(wtk_Init=(LPFNTKINIT)wgaim_find_and_loadproc("tk84.dll", "Tk_Init"))) { gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tk_Init\n"); return FALSE; } return TRUE; } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch( fdwReason ) { case DLL_PROCESS_ATTACH: return tcl_win32_init(); case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; } return TRUE; } --- NEW FILE: Makefile.mingw --- # # Makefile.mingw # # Description: Makefile for tcl plugin loader plugin. # # # PATHS # GTK_TOP := ../../../win32-dev/gtk_2_0 GAIM_TOP := ../.. TCL_LIB_DIR := ../../../win32-dev/tcl-8.4.5 TCL_INC_DIR := $(TCL_LIB_DIR)/include GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins ## ## VARIABLE DEFINITIONS ## TARGET = tcl CC = gcc.exe # Compiler Options CFLAGS = DEFINES = -DHAVE_TK -DUSE_TCL_STUBS -DUSE_TK_STUBS ## ## INCLUDE MAKEFILES ## include $(GAIM_TOP)/src/win32/global.mak ## ## INCLUDE PATHS ## INCLUDE_PATHS += -I. \ -I$(GAIM_TOP) \ -I$(GAIM_TOP)/src \ -I$(GAIM_TOP)/src/win32 \ -I$(GTK_TOP)/include \ -I$(GTK_TOP)/include/gtk-2.0 \ -I$(GTK_TOP)/include/glib-2.0 \ -I$(GTK_TOP)/include/pango-1.0 \ -I$(GTK_TOP)/include/atk-1.0 \ -I$(GTK_TOP)/lib/glib-2.0/include \ -I$(GTK_TOP)/lib/gtk-2.0/include \ -I$(TCL_INC_DIR) LIB_PATHS = -L$(GTK_TOP)/lib \ -L$(GAIM_TOP)/src \ -L$(TCL_LIB_DIR) ## ## SOURCES, OBJECTS ## C_SRC = tcl.c \ tcl_cmds.c \ tcl_glib.c \ tcl_signals.c \ tcl_win32.c OBJECTS = $(C_SRC:%.c=%.o) ## ## LIBRARIES ## LIBS = -lgtk-win32-2.0 \ -lglib-2.0 \ -lgdk-win32-2.0 \ -lgmodule-2.0 \ -lgobject-2.0 \ -lws2_32 \ -lintl \ -lgaim \ -ltclstub84 \ -ltkstub84 ## ## RULES ## # How to make a C file %.o: %.c $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@ -c $< ## ## TARGET DEFINITIONS ## .PHONY: all clean all: $(TARGET).dll install: $(TARGET).dll cp $(TARGET).dll $(DLL_INSTALL_DIR) ## ## BUILD Dependencies ## $(GAIM_TOP)/src/gaim.lib: $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib ## ## BUILD DLL ## $(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll ## ## CLEAN RULES ## clean: rm -rf *.o rm -rf $(TARGET).dll Index: .cvsignore =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/tcl/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- .cvsignore 2 Sep 2003 03:34:37 -0000 1.1 +++ .cvsignore 11 Dec 2003 19:06:28 -0000 1.2 @@ -5,3 +5,4 @@ tcl.la .deps .libs *.lo +*.dll Index: tcl.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/tcl/tcl.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- tcl.c 10 Dec 2003 22:11:38 -0000 1.3 +++ tcl.c 11 Dec 2003 19:06:28 -0000 1.4 @@ -53,6 +53,8 @@ static GHashTable *tcl_plugins = NULL; GaimPlugin *_tcl_plugin; +static gboolean tcl_loaded = FALSE; + GaimPlugin *tcl_interp_get_plugin(Tcl_Interp *interp) { struct tcl_plugin_data *data; @@ -304,6 +306,8 @@ static void tcl_destroy_plugin(GaimPlugi static gboolean tcl_load(GaimPlugin *plugin) { + if(!tcl_loaded) + return FALSE; tcl_glib_init(); tcl_signal_init(); tcl_plugins = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -354,12 +358,47 @@ static GaimPluginInfo tcl_info = &tcl_loader_info }; +#ifdef _WIN32 +extern Tcl_Interp* (CALLBACK* wtcl_CreateInterp)(); +extern void (CALLBACK* wtk_Init)(Tcl_Interp*); +#undef Tcl_CreateInterp +#define Tcl_CreateInterp wtcl_CreateInterp +#undef Tk_Init +#define Tk_Init wtk_Init +#endif /* _WIN32 */ + static void tcl_init_plugin(GaimPlugin *plugin) { +#ifdef USE_TCL_STUBS + Tcl_Interp *interp=NULL; +#endif _tcl_plugin = plugin; +#ifdef USE_TCL_STUBS + if(!(interp=Tcl_CreateInterp())) + return; + + if(!Tcl_InitStubs(interp, TCL_VERSION, 0)) { + gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Tcl_InitStubs: %s\n", interp->result); + return; + } +#endif + Tcl_FindExecutable("gaim"); +#if defined(USE_TK_STUBS) && defined(HAVE_TK) + Tk_Init(interp); + + if(!Tk_InitStubs(interp, TK_VERSION, 0)) { + gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Error Tk_InitStubs: %s\n", interp->result); + Tcl_DeleteInterp(interp); + return; + } +#endif + tcl_loaded = TRUE; +#ifdef USE_TCL_STUBS + Tcl_DeleteInterp(interp); +#endif tcl_loader_info.exts = g_list_append(tcl_loader_info.exts, "tcl"); } Index: tcl_glib.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/tcl/tcl_glib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- tcl_glib.c 9 Dec 2003 23:34:54 -0000 1.2 +++ tcl_glib.c 11 Dec 2003 19:06:28 -0000 1.3 @@ -70,6 +70,8 @@ static gboolean tcl_kick(gpointer data); static gboolean tcl_file_callback(GIOChannel *source, GIOCondition condition, gpointer data); static int tcl_file_event_callback(Tcl_Event *event, int flags); +#undef Tcl_InitNotifier + ClientData Tcl_InitNotifier() { return NULL; |