[Skencil-commits] r735 - skencil/branches/skencil-0.6/src/extensions/Pax

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 23 13:52:10 CEST 2010


Author: igor_n
Date: 2010-09-23 13:52:09 +0200 (Thu, 23 Sep 2010)
New Revision: 735

Modified:
   skencil/branches/skencil-0.6/src/extensions/Pax/paxmodule.c
   skencil/branches/skencil-0.6/src/extensions/Pax/paxtkinter.c
Log:
fixes for tk8.6

Modified: skencil/branches/skencil-0.6/src/extensions/Pax/paxmodule.c
===================================================================
--- skencil/branches/skencil-0.6/src/extensions/Pax/paxmodule.c	2010-09-23 02:04:20 UTC (rev 734)
+++ skencil/branches/skencil-0.6/src/extensions/Pax/paxmodule.c	2010-09-23 11:52:09 UTC (rev 735)
@@ -177,13 +177,13 @@
     PyObject * obj;
     if (!object_registry)
     {
-	interp->result = "object_registry not initialized";
+    Tcl_SetResult(interp, "object_registry not initialized", TCL_VOLATILE);
 	return TCL_ERROR;
     }
     obj = PyDict_GetItemString(object_registry, value);
     if (!obj)
     {
-	interp->result = "object not in registry";
+    Tcl_SetResult(interp, "object not in registry", TCL_VOLATILE);
 	return TCL_ERROR;
     }
 
@@ -330,7 +330,7 @@
 	return TCL_ERROR;
     }
 
-    interp->result = Tk_PathName(paxwidget->tkwin);
+    Tcl_SetResult(interp, Tk_PathName(paxwidget->tkwin), TCL_VOLATILE);
     return TCL_OK;
 }
 
@@ -427,7 +427,7 @@
     length = strlen(argv[1]);
     if (c == 'b' && strncmp(argv[1], "bgpixel", length) == 0)
     {
-	sprintf(interp->result, "%ld",
+	sprintf(Tcl_GetStringResult(interp), "%ld",
 		Tk_3DBorderColor(paxwidget->background)->pixel);
     }
     else if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0)
@@ -657,7 +657,7 @@
     tkwin = Tk_NameToWindow(interp, name, (ClientData)Tk_MainWindow(interp));
     if (!tkwin)
     {
-	PyErr_SetString(PyExc_ValueError, interp->result);
+	PyErr_SetString(PyExc_ValueError, Tcl_GetStringResult(interp));
 	return NULL;
     }
 
@@ -740,7 +740,7 @@
 
     if (argc < 3)
     {
-	interp->result = "object id and method name must be given";
+    Tcl_SetResult(interp, "object id and method name must be given", TCL_VOLATILE);
 	return TCL_ERROR;
     }
 
@@ -781,7 +781,7 @@
 	if (!string)
 	{
 	    Py_XDECREF(args);
-	    interp->result = "Cannot build argument tuple";
+	    Tcl_SetResult(interp, "Cannot build argument tuple", TCL_VOLATILE);
 	    return TCL_ERROR;
 	}
     }
@@ -794,7 +794,7 @@
     if (!result)
     {
 	/*PyErr_Clear();*/
-	interp->result = "Exception in python method";
+    Tcl_SetResult(interp, "Exception in python method", TCL_VOLATILE);
 	return TCL_ERROR;
     }
     Py_DECREF(result);

Modified: skencil/branches/skencil-0.6/src/extensions/Pax/paxtkinter.c
===================================================================
--- skencil/branches/skencil-0.6/src/extensions/Pax/paxtkinter.c	2010-09-23 02:04:20 UTC (rev 734)
+++ skencil/branches/skencil-0.6/src/extensions/Pax/paxtkinter.c	2010-09-23 11:52:09 UTC (rev 735)
@@ -79,7 +79,7 @@
 #ifdef WITH_THREAD
 /* define to get readline/EventHook to work in a single-threaded but
    thread-enabled program */
-#define PAX_THREAD_HACK 
+#define PAX_THREAD_HACK
 #endif
 /* turn off all other threading specific code here */
 #undef WITH_THREAD
@@ -182,7 +182,7 @@
    Py_END_ALLOW_THREADS.  They should be used whenever a call into Tcl is made
    that could call an event handler, or otherwise affect the state of a Tcl
    interpreter.  These assume that the surrounding code has the Python
-   interpreter lock; inside the brackets, the Python interpreter lock has been 
+   interpreter lock; inside the brackets, the Python interpreter lock has been
    released and the lock for Tcl has been acquired.
 
    Sometimes, it is necessary to have both the Python lock and the Tcl lock.
@@ -290,13 +290,13 @@
 
 #define Tkapp_Check(v) ((v)->ob_type == &Tkapp_Type)
 #define Tkapp_Interp(v) (((TkappObject *) (v))->interp)
-#define Tkapp_Result(v) (((TkappObject *) (v))->interp->result)
+#define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v))
 
 #define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \
 (void *) v, ((PyObject *) v)->ob_refcnt))
 
 
-
+
 /**** Error Handling ****/
 
 static PyObject *Tkinter_TclError;
@@ -307,7 +307,7 @@
 static PyObject *trbInCmd;
 
 
-
+
 static PyObject *
 Tkinter_Error(PyObject *v)
 {
@@ -316,7 +316,7 @@
 }
 
 
-
+
 /**** Utils ****/
 
 #ifdef WITH_THREAD
@@ -339,7 +339,7 @@
 #endif /* MS_WINDOWS */
 #endif /* WITH_THREAD */
 
-
+
 static char *
 AsString(PyObject *value, PyObject *tmp)
 {
@@ -354,7 +354,7 @@
 }
 
 
-
+
 #define ARGSZ 64
 
 static char *
@@ -428,7 +428,7 @@
 }
 
 
-
+
 static PyObject *
 Split(char *list)
 {
@@ -471,26 +471,26 @@
 }
 
 
-
+
 /**** Tkapp Object ****/
 
 int
 Tcl_AppInit(Tcl_Interp *interp)
 {
 	if (Tcl_Init(interp) == TCL_ERROR) {
-		PySys_WriteStderr("Tcl_Init error: %s\n", interp->result);
+		PySys_WriteStderr("Tcl_Init error: %s\n", Tcl_GetStringResult(interp));
 		return TCL_ERROR;
 	}
 	if (Tk_Init(interp) == TCL_ERROR) {
-		PySys_WriteStderr("Tk_Init error: %s\n", interp->result);
+		PySys_WriteStderr("Tk_Init error: %s\n", Tcl_GetStringResult(interp));
 		return TCL_ERROR;
 	}
 	return TCL_OK;
 }
 
 
-
 
+
 /* Initialize the Tk application; see the `main' function in
  * `tkMain.c'.
  */
@@ -503,7 +503,7 @@
 {
 	TkappObject *v;
 	char *argv0;
-  
+
 	v = PyObject_New(TkappObject, &Tkapp_Type);
 	if (v == NULL)
 		return NULL;
@@ -550,7 +550,7 @@
 }
 
 
-
+
 /** Tcl Eval **/
 
 static PyObject *
@@ -639,13 +639,13 @@
 	if (i == TCL_ERROR) {
 		if (Py_VerboseFlag >= 2)
 			PySys_WriteStderr("... error: '%s'\n",
-				interp->result);
+				Tcl_GetStringResult(interp));
 		Tkinter_Error(self);
 	}
 	else {
 		if (Py_VerboseFlag >= 2)
-			PySys_WriteStderr("-> '%s'\n", interp->result);
-		res = PyString_FromString(interp->result);
+			PySys_WriteStderr("-> '%s'\n", Tcl_GetStringResult(interp));
+		res = PyString_FromString(Tcl_GetStringResult(interp));
 	}
 	LEAVE_OVERLAP_TCL
 
@@ -705,7 +705,7 @@
 	char *script;
 	PyObject *res = NULL;
 	int err;
-  
+
 	if (!PyArg_ParseTuple(args, "s", &script))
 		return NULL;
 
@@ -800,7 +800,7 @@
 }
 
 
-
+
 /** Tcl Variable **/
 
 static PyObject *
@@ -827,7 +827,7 @@
 		if (PyArg_ParseTuple(args, "ssO", &name1, &name2, &newValue)) {
 			s = AsString (newValue, tmp);
 			ENTER_TCL
-			ok = Tcl_SetVar2(Tkapp_Interp(self), name1, name2, 
+			ok = Tcl_SetVar2(Tkapp_Interp(self), name1, name2,
 					 s, flags);
 			LEAVE_TCL
 		}
@@ -858,7 +858,7 @@
 }
 
 
-
+
 static PyObject *
 GetVar(PyObject *self, PyObject *args, int flags)
 {
@@ -897,7 +897,7 @@
 }
 
 
-
+
 static PyObject *
 UnsetVar(PyObject *self, PyObject *args, int flags)
 {
@@ -938,7 +938,7 @@
 }
 
 
-
+
 /** Tcl to Python **/
 
 static PyObject *
@@ -1066,7 +1066,7 @@
 }
 
 
-
+
 static PyObject *
 Tkapp_SplitList(PyObject *self, PyObject *args)
 {
@@ -1084,7 +1084,7 @@
 
 	if (!(v = PyTuple_New(argc)))
 		return NULL;
-	
+
 	for (i = 0; i < argc; i++) {
 		PyObject *s = PyString_FromString(argv[i]);
 		if (!s || PyTuple_SetItem(v, i, s)) {
@@ -1126,7 +1126,7 @@
 }
 
 
-
+
 /** Tcl Command **/
 
 /* Client data struct */
@@ -1206,7 +1206,7 @@
 }
 
 
-
+
 static PyObject *
 Tkapp_CreateCommand(PyObject *self, PyObject *args)
 {
@@ -1245,7 +1245,7 @@
 }
 
 
-
+
 static PyObject *
 Tkapp_DeleteCommand(PyObject *self, PyObject *args)
 {
@@ -1266,7 +1266,7 @@
 }
 
 
-
+
 #ifdef HAVE_CREATEFILEHANDLER
 /** File Handler **/
 
@@ -1300,8 +1300,8 @@
 DeleteFHCD(int id)
 {
 	FileHandler_ClientData *p, **pp;
-	
-	pp = &HeadFHCD; 
+
+	pp = &HeadFHCD;
 	while ((p = *pp) != NULL) {
 		if (p->id == id) {
 			*pp = p->next;
@@ -1416,7 +1416,7 @@
 	PyObject *file;
 	int id;
 	FHANDLE tfile;
-  
+
 	if (!PyArg_ParseTuple(args, "O", &file))
 		return NULL;
 	id = GetFileNo(file);
@@ -1435,7 +1435,7 @@
 }
 #endif /* HAVE_CREATEFILEHANDLER */
 
-
+
 /**** Tktt Object (timer token) ****/
 
 staticforward PyTypeObject Tktt_Type;
@@ -1477,7 +1477,7 @@
 Tktt_New(PyObject *func)
 {
 	TkttObject *v;
-  
+
 	v = PyObject_New(TkttObject, &Tktt_Type);
 	if (v == NULL)
 		return NULL;
@@ -1539,7 +1539,7 @@
 };
 
 
-
+
 /** Timer Handler **/
 
 static void
@@ -1591,7 +1591,7 @@
 	return (PyObject *) v;
 }
 
-
+
 /** Event Loop **/
 
 static PyObject *
@@ -1682,18 +1682,7 @@
 
 static PyObject *
 Tkapp_UTF8_to_Latin1 (PyObject *self, PyObject *args)
-#if TKMAJORMINOR < 8001
 {
-    PyObject * string;
-
-    if (!PyArg_ParseTuple(args, "S", &string))
-	return NULL;
-
-    Py_INCREF(string);
-    return string;
-}
-#else
-{
     PyObject * utf8;
     PyObject * latin1;
     Tcl_DString dstring;
@@ -1720,23 +1709,11 @@
 
     return latin1;
 }
-#endif
 
 
 static PyObject *
 Tkapp_UTF8_to_System (PyObject *self, PyObject *args)
-#if TKMAJORMINOR < 8001
 {
-    PyObject * string;
-
-    if (!PyArg_ParseTuple(args, "S", &string))
-	return NULL;
-
-    Py_INCREF(string);
-    return string;
-}
-#else
-{
     PyObject * utf8;
     PyObject * system;
     Tcl_DString dstring;
@@ -1753,8 +1730,28 @@
 
     return system;
 }
-#endif
 
+static PyObject *
+Tkapp_System_to_UTF8 (PyObject *self, PyObject *args)
+{
+    PyObject * utf8;
+    PyObject * system;
+    Tcl_DString dstring;
+
+    if (!PyArg_ParseTuple(args, "S", &system))
+	return NULL;
+
+    Tcl_ExternalToUtfDString(NULL, PyString_AsString(system),
+			     PyString_Size(system), &dstring);
+
+    utf8 = PyString_FromString(dstring.string);
+
+    Tcl_DStringFree(&dstring);
+
+    return utf8;
+}
+
+
 /* Yet another sketch specific hack: Starting with Python 2.3 Tkinter
  * calls the wantobjects method, so we provide one that doesn't do
  * anything.
@@ -1765,12 +1762,12 @@
     int wantobjects;
     if (!PyArg_ParseTuple(args, "i:wantobjects", &wantobjects))
 	return NULL;
-    
+
     Py_INCREF(Py_None);
     return Py_None;
 }
 
-
+
 /**** Tkapp Method List ****/
 
 static PyMethodDef Tkapp_methods[] =
@@ -1811,12 +1808,13 @@
 	{"interpaddr",         Tkapp_InterpAddr, 1},
 	{"utf8_to_latin1",     Tkapp_UTF8_to_Latin1, 1},
 	{"utf8_to_system",     Tkapp_UTF8_to_System, 1},
+	{"system_to_utf8",     Tkapp_System_to_UTF8, 1},
 	{"wantobjects",	       Tkapp_WantObjects, METH_VARARGS},
 	{NULL, 		       NULL}
 };
 
 
-
+
 /**** Tkapp Type Methods ****/
 
 static void
@@ -1855,7 +1853,7 @@
 };
 
 
-
+
 /**** Tkinter Module ****/
 
 static PyObject *
@@ -1875,14 +1873,14 @@
 	else
 		baseName = Py_GetProgramName();
 	className = "Tk";
-  
+
 	if (!PyArg_ParseTuple(args, "|zssiiiiz:create",
 			      &screenName, &baseName, &className,
 			      &interactive, &ignored_int, &ignored_int,
 			      &ignored_int, &ignored_charp))
 		return NULL;
 
-	return (PyObject *) Tkapp_New(screenName, baseName, className, 
+	return (PyObject *) Tkapp_New(screenName, baseName, className,
 				      interactive);
 }
 
@@ -2089,7 +2087,7 @@
 }
 
 
-
+
 #ifdef macintosh
 
 /*
@@ -2100,12 +2098,12 @@
 panic(char * format, ...)
 {
 	va_list varg;
-	
+
 	va_start(varg, format);
-	
+
 	vfprintf(stderr, format, varg);
 	(void) fflush(stderr);
-	
+
 	va_end(varg);
 
 	Py_FatalError("Tcl/Tk panic");
@@ -2161,7 +2159,7 @@
 	return TclMacSocketReady(file, mask);
     } else if (type == TCL_MAC_FILE) {
 	/*
-	 * Under the Macintosh, files are always ready, so we just 
+	 * Under the Macintosh, files are always ready, so we just
 	 * return the mask that was passed in.
 	 */
 
@@ -2169,19 +2167,19 @@
     } else if (type == TCL_UNIX_FD) {
 	fd_set readset, writeset, excset;
 	struct timeval tv;
-	
+
 	FD_ZERO(&readset);
 	FD_ZERO(&writeset);
 	FD_ZERO(&excset);
-	
+
 	if ( mask & TCL_READABLE ) FD_SET(fd, &readset);
 	if ( mask & TCL_WRITABLE ) FD_SET(fd, &writeset);
 	if ( mask & TCL_EXCEPTION ) FD_SET(fd, &excset);
-	
+
 	tv.tv_sec = tv.tv_usec = 0;
 	if ( select(fd+1, &readset, &writeset, &excset, &tv) <= 0 )
 		return 0;
-	
+
 	mask = 0;
 	if ( FD_ISSET(fd, &readset) ) mask |= TCL_READABLE;
 	if ( FD_ISSET(fd, &writeset) ) mask |= TCL_WRITABLE;
@@ -2189,7 +2187,7 @@
 
 	return mask;
     }
-    
+
     return 0;
 }
 #endif /* USE_GUSI */
@@ -2234,7 +2232,7 @@
 static
 mac_addlibresources()
 {
-	if ( !loaded_from_shlib ) 
+	if ( !loaded_from_shlib )
 		return;
 	(void)FSpOpenResFile(&library_fss, fsRdPerm);
 }



More information about the Skencil-commits mailing list