Skip to content

loading TCL / Tk symbols dynamically #6442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 24, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
RF: make dynamic loading of TCL the one true way
Remove ifdefs that allowed not-dynamic library resolution of TCL / Tk
symbols.
  • Loading branch information
matthew-brett committed May 18, 2016
commit fc5d0604e5313e772e77ee217de87120147f0b31
21 changes: 1 addition & 20 deletions src/_tkagg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ typedef struct
Tcl_Interp *interp;
} TkappObject;

#define DYNAMIC_TKINTER

#ifdef DYNAMIC_TKINTER
// Load TCL / Tk symbols from tkinter extension module at run-time.
// Typedefs, global vars for TCL / Tk library functions.
typedef Tcl_Command (*tcl_cc)(Tcl_Interp *interp,
Expand All @@ -66,15 +63,6 @@ typedef void (*tk_ppb_nc) (Tk_PhotoHandle handle,
static tk_ppb_nc TK_PHOTO_PUTBLOCK;
typedef void (*tk_pb) (Tk_PhotoHandle handle);
static tk_pb TK_PHOTO_BLANK;
#else
// Build-time linking against system TCL / Tk functions.
#define TCL_CREATE_COMMAND Tcl_CreateCommand
#define TCL_APPEND_RESULT Tcl_AppendResult
#define TK_MAIN_WINDOW Tk_MainWindow
#define TK_FIND_PHOTO Tk_FindPhoto
#define TK_PHOTO_PUTBLOCK Tk_PhotoPutBlock
#define TK_PHOTO_BLANK Tk_PhotoBlank
#endif

static int PyAggImagePhoto(ClientData clientdata, Tcl_Interp *interp, int argc, char **argv)
{
Expand Down Expand Up @@ -264,7 +252,6 @@ static PyMethodDef functions[] = {
{ NULL, NULL } /* sentinel */
};

#ifdef DYNAMIC_TKINTER
// Functions to fill global TCL / Tk function pointers from tkinter module.

#if PY3K
Expand Down Expand Up @@ -387,7 +374,6 @@ int load_tkinter_funcs(void)
Py_XDECREF(pString);
return ret;
}
#endif

#if PY3K
static PyModuleDef _tkagg_module = { PyModuleDef_HEAD_INIT, "_tkagg", "", -1, functions,
Expand All @@ -401,20 +387,15 @@ PyMODINIT_FUNC PyInit__tkagg(void)

import_array();

#ifdef DYNAMIC_TKINTER
return (load_tkinter_funcs() == 0) ? m : NULL;
#else
return m
#endif
}
#else
PyMODINIT_FUNC init_tkagg(void)
{
import_array();

Py_InitModule("_tkagg", functions);
#ifdef DYNAMIC_TKINTER

load_tkinter_funcs();
#endif
}
#endif