summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-05-26 14:31:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-05-26 14:31:03 (GMT)
commitff98b3b125c4a9b171f4e810c4724bd5f80dad26 (patch)
treee7908de5676ce4270f1031f8135f76ff298a5d05
parente50bfa3ef78703fbb073cc1fc61327a7f9f5f822 (diff)
downloadtk-ff98b3b125c4a9b171f4e810c4724bd5f80dad26.zip
tk-ff98b3b125c4a9b171f4e810c4724bd5f80dad26.tar.gz
tk-ff98b3b125c4a9b171f4e810c4724bd5f80dad26.tar.bz2
Convert "testwinevent", "testmetrics" and "testdeleteapps" for using the Tcl_Obj API.
-rw-r--r--generic/tkTest.c48
-rw-r--r--win/tkWinTest.c59
2 files changed, 49 insertions, 58 deletions
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 562b2c8..b7621c7 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -153,8 +153,9 @@ static int TestcolorObjCmd(ClientData dummy,
static int TestcursorObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
-static int TestdeleteappsCmd(ClientData dummy,
- Tcl_Interp *interp, int argc, const char **argv);
+static int TestdeleteappsObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj * const objv[]);
static int TestfontObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -165,8 +166,9 @@ static int TestmenubarCmd(ClientData dummy,
Tcl_Interp *interp, int argc, const char **argv);
#endif
#if defined(_WIN32) || defined(MAC_OSX_TK)
-static int TestmetricsCmd(ClientData dummy,
- Tcl_Interp *interp, int argc, const char **argv);
+static int TestmetricsObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj * const objv[]);
#endif
static int TestobjconfigObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
@@ -244,7 +246,7 @@ Tktest_Init(
(ClientData) Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testcursor", TestcursorObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
- Tcl_CreateCommand(interp, "testdeleteapps", TestdeleteappsCmd,
+ Tcl_CreateObjCommand(interp, "testdeleteapps", TestdeleteappsObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
Tcl_CreateCommand(interp, "testembed", TkpTestembedCmd,
(ClientData) Tk_MainWindow(interp), NULL);
@@ -260,7 +262,7 @@ Tktest_Init(
(ClientData) Tk_MainWindow(interp), NULL);
#if defined(_WIN32) || defined(MAC_OSX_TK)
- Tcl_CreateCommand(interp, "testmetrics", TestmetricsCmd,
+ Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
#elif !defined(__CYGWIN__)
Tcl_CreateCommand(interp, "testmenubar", TestmenubarCmd,
@@ -436,7 +438,7 @@ TestcursorObjCmd(
/*
*----------------------------------------------------------------------
*
- * TestdeleteappsCmd --
+ * TestdeleteappsObjCmd --
*
* This function implements the "testdeleteapps" command. It cleans up
* all the interpreters left behind by the "testnewapp" command.
@@ -453,11 +455,11 @@ TestcursorObjCmd(
/* ARGSUSED */
static int
-TestdeleteappsCmd(
+TestdeleteappsObjCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
{
NewApp *nextPtr;
@@ -1747,7 +1749,7 @@ TestmenubarCmd(
/*
*----------------------------------------------------------------------
*
- * TestmetricsCmd --
+ * TestmetricsObjCmd --
*
* This function implements the testmetrics command. It provides a way to
* determine the size of various widget components.
@@ -1763,51 +1765,49 @@ TestmenubarCmd(
#if defined(_WIN32) || defined(MAC_OSX_TK)
static int
-TestmetricsCmd(
+TestmetricsObjCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
{
char buf[TCL_INTEGER_SPACE];
int val;
#ifdef _WIN32
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
- " option ?arg ...?\"", NULL);
+ if (objc < 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
#else
Tk_Window tkwin = (Tk_Window) clientData;
TkWindow *winPtr;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
- " option window\"", NULL);
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "option window");
return TCL_ERROR;
}
- winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin);
+ winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
if (winPtr == NULL) {
return TCL_ERROR;
}
#endif
- if (strcmp(argv[1], "cyvscroll") == 0) {
+ if (strcmp(Tcl_GetString(objv[1]), "cyvscroll") == 0) {
#ifdef _WIN32
val = GetSystemMetrics(SM_CYVSCROLL);
#else
val = ((TkScrollbar *) winPtr->instanceData)->width;
#endif
- } else if (strcmp(argv[1], "cxhscroll") == 0) {
+ } else if (strcmp(Tcl_GetString(objv[1]), "cxhscroll") == 0) {
#ifdef _WIN32
val = GetSystemMetrics(SM_CXHSCROLL);
#else
val = ((TkScrollbar *) winPtr->instanceData)->width;
#endif
} else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
+ Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]),
"\": must be cxhscroll or cyvscroll", NULL);
return TCL_ERROR;
}
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 6036995..9fa956c 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -27,8 +27,9 @@ HWND tkWinCurrentDialog;
static int TestclipboardObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
-static int TestwineventCmd(ClientData clientData,
- Tcl_Interp *interp, int argc, const char **argv);
+static int TestwineventObjCmd(ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
static int TestfindwindowObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -67,7 +68,7 @@ TkplatformtestInit(
Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
- Tcl_CreateCommand(interp, "testwinevent", TestwineventCmd,
+ Tcl_CreateObjCommand(interp, "testwinevent", TestwineventObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testfindwindow", TestfindwindowObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
@@ -220,7 +221,7 @@ TestclipboardObjCmd(
/*
*----------------------------------------------------------------------
*
- * TestwineventCmd --
+ * TestwineventObjCmd --
*
* This function implements the testwinevent command. It provides a way
* to send messages to windows dialogs.
@@ -235,11 +236,11 @@ TestclipboardObjCmd(
*/
static int
-TestwineventCmd(
+TestwineventObjCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
{
HWND hwnd = 0;
HWND child = 0;
@@ -258,33 +259,23 @@ TestwineventCmd(
{-1, NULL}
};
- if ((argc == 3) && (strcmp(argv[1], "debug") == 0)) {
+ if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) {
int b;
- if (Tcl_GetBoolean(interp, argv[2], &b) != TCL_OK) {
+ if (Tcl_GetBoolean(interp, Tcl_GetString(objv[2]), &b) != TCL_OK) {
return TCL_ERROR;
}
TkWinDialogDebug(b);
return TCL_OK;
}
- if (argc < 4) {
+ if (objc < 4) {
return TCL_ERROR;
}
-#if 0
- TkpScanWindowId(interp, argv[1], &id);
- if (
-#ifdef _WIN64
- (sscanf(string, "0x%p", &number) != 1) &&
-#endif /* _WIN64 */
- Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) {
- return TCL_ERROR;
- }
-#endif
- hwnd = INT2PTR(strtol(argv[1], &rest, 0));
- if (rest == argv[1]) {
- hwnd = FindWindowA(NULL, argv[1]);
+ hwnd = INT2PTR(strtol(Tcl_GetString(objv[1]), &rest, 0));
+ if (rest == Tcl_GetString(objv[1])) {
+ hwnd = FindWindowA(NULL, Tcl_GetString(objv[1]));
if (hwnd == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("no such window", -1));
return TCL_ERROR;
@@ -292,14 +283,14 @@ TestwineventCmd(
}
UpdateWindow(hwnd);
- id = strtol(argv[2], &rest, 0);
- if (rest == argv[2]) {
+ id = strtol(Tcl_GetString(objv[2]), &rest, 0);
+ if (rest == Tcl_GetString(objv[2])) {
char buf[256];
child = GetWindow(hwnd, GW_CHILD);
while (child != NULL) {
SendMessageA(child, WM_GETTEXT, (WPARAM) sizeof(buf), (LPARAM) buf);
- if (strcasecmp(buf, argv[2]) == 0) {
+ if (strcasecmp(buf, Tcl_GetString(objv[2])) == 0) {
id = GetDlgCtrlID(child);
break;
}
@@ -307,19 +298,19 @@ TestwineventCmd(
}
if (child == NULL) {
Tcl_AppendResult(interp, "could not find a control matching \"",
- argv[2], "\"", NULL);
+ Tcl_GetString(objv[2]), "\"", NULL);
return TCL_ERROR;
}
}
- message = TkFindStateNum(NULL, NULL, messageMap, argv[3]);
+ message = TkFindStateNum(NULL, NULL, messageMap, Tcl_GetString(objv[3]));
wParam = 0;
lParam = 0;
- if (argc > 4) {
- wParam = strtol(argv[4], NULL, 0);
+ if (objc > 4) {
+ wParam = strtol(Tcl_GetString(objv[4]), NULL, 0);
}
- if (argc > 5) {
- lParam = strtol(argv[5], NULL, 0);
+ if (objc > 5) {
+ lParam = strtol(Tcl_GetString(objv[5]), NULL, 0);
}
switch (message) {
@@ -337,7 +328,7 @@ TestwineventCmd(
Tcl_DString ds;
BOOL result;
- Tcl_UtfToExternalDString(NULL, argv[4], -1, &ds);
+ Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds);
result = SetDlgItemTextA(hwnd, id, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
if (result == 0) {
@@ -349,7 +340,7 @@ TestwineventCmd(
}
case WM_COMMAND: {
char buf[TCL_INTEGER_SPACE];
- if (argc < 5) {
+ if (objc < 5) {
wParam = MAKEWPARAM(id, 0);
lParam = (LPARAM)child;
}