From b417a6431e89ea4f57d48c1ca169c5cc3cc7a4cd Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 8 Jul 2015 11:28:30 +0200 Subject: Debugging; word sizes (Int -> pointer); fix CleanStrings --- Linux_C_12/Clean.h | 2 +- Linux_C_12/cCrossCallWindows_121.c | 65 ++++++++++++++++++-------------------- Linux_C_12/cCrossCall_121.c | 21 ++++++------ Linux_C_12/cCrossCall_121.h | 6 ++-- Linux_C_12/util_121.c | 17 +++++++--- clCCall_12.icl | 2 +- clCrossCall_12.icl | 16 +++++----- oswindow.icl | 10 ++++++ windowCrossCall_12.icl | 1 + windowevent.icl | 2 ++ 10 files changed, 80 insertions(+), 62 deletions(-) diff --git a/Linux_C_12/Clean.h b/Linux_C_12/Clean.h index d92e1a0..26513a0 100644 --- a/Linux_C_12/Clean.h +++ b/Linux_C_12/Clean.h @@ -15,7 +15,7 @@ typedef struct clean_string *CleanString; #define CleanStringLength(clean_string) (*(unsigned int *)(clean_string)) /* CleanStringCharacters(clean_string) returns a pointer to the characters of the clean_string */ -#define CleanStringCharacters(clean_string) ((char*)(1+(unsigned int *)(clean_string))) +#define CleanStringCharacters(clean_string) ((char*)(1+(unsigned int *)(clean_string))+4) /* CleanStringSizeInts(string_length) return size of CleanString in integers */ #define CleanStringSizeInts(string_length) (1+(((unsigned int)(string_length)+3)>>2)) diff --git a/Linux_C_12/cCrossCallWindows_121.c b/Linux_C_12/cCrossCallWindows_121.c index c0b2a22..88f70e0 100644 --- a/Linux_C_12/cCrossCallWindows_121.c +++ b/Linux_C_12/cCrossCallWindows_121.c @@ -802,46 +802,40 @@ void EvalCcRqSETWINDOWTITLE (CrossCallInfo *pcci) /* hwnd, textptr no result. gchar *title = (gchar *) pcci->p2; printf("EvalCcRqSETWINDOWTITLE\n"); + printf("Requested title (%p): %s\n", title, title); window = GTK_WIDGET(pcci->p1); if (GTK_IS_WINDOW(window)) { + printf("Setting for window.\n"); gtk_window_set_title(GTK_WINDOW(window), title); } + else if (GTK_IS_LABEL(window)) + { + printf("Setting for label.\n"); + gtk_label_set_text(GTK_LABEL(window), title); + } + else if (GTK_IS_BUTTON(window)) + { + printf("Setting for button.\n"); + title = createMnemonicString(title); + gtk_button_set_label(GTK_BUTTON(window), title); + rfree(title); + } + else if (GTK_IS_ENTRY(window)) + { + printf("Setting for entry.\n"); + gtk_entry_set_text(GTK_ENTRY(window), title); + } + else if (GTK_IS_TEXT_VIEW(window)) + { + printf("Setting for text view.\n"); + GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window)); + gtk_text_buffer_set_text (buffer, title, strlen(title)); + } else - { - if (GTK_IS_LABEL(window)) - { - gtk_label_set_text(GTK_LABEL(window), title); - } - else - { - if (GTK_IS_BUTTON(window)) - { - title = createMnemonicString(title); - gtk_button_set_label(GTK_BUTTON(window), title); - rfree(title); - } - else - { - if (GTK_IS_ENTRY(window)) - { - gtk_entry_set_text(GTK_ENTRY(window), title); - } - else - { - if (GTK_IS_TEXT_VIEW(window)) - { - GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window)); - gtk_text_buffer_set_text (buffer, title, strlen(title)); - } - else - { - printf("EvalCcRqSETWINDOWTITLE -> unknown widget type"); - } - } - } - } - } + { + printf("EvalCcRqSETWINDOWTITLE -> unknown widget type\n"); + } MakeReturn0Cci (pcci); } @@ -1425,6 +1419,7 @@ void EvalCcRqCREATEDIALOG (CrossCallInfo *pcci) // textptr,parentptr,behindPtr; gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), fixed, TRUE, TRUE, 0); gtk_widget_show(fixed); + rprintf("Sending dialog to clean: %p / %p\n", dialog, (int64_t) dialog); SendMessage1ToClean (CcWmINITDIALOG, (int64_t) dialog); x = gCci.p1; @@ -2167,7 +2162,7 @@ void EvalCcRqSHOWCONTROL (CrossCallInfo *pcci) // hwnd, bool; no result. printf("EvalCcRqSHOWCONTROL\n"); control = GTK_WIDGET(pcci->p1); - printf("Control: %ld\n", control); + printf("Control: %p; show: 0x%x\n", control, pcci->p2); if (control) { diff --git a/Linux_C_12/cCrossCall_121.c b/Linux_C_12/cCrossCall_121.c index 22a0ae7..83b1fa4 100644 --- a/Linux_C_12/cCrossCall_121.c +++ b/Linux_C_12/cCrossCall_121.c @@ -32,6 +32,7 @@ #include #include #include +#include char** global_argv; int global_argc = 0; @@ -290,15 +291,15 @@ OS WinKillOsThread (OS os) return os; } /*WinKillOsThread*/ -#undef PRINTCROSSCALLS +#define PRINTCROSSCALLS -void WinKickOsThread (int imess, - int ip1, int ip2, int ip3, - int ip4, int ip5, int ip6, +void WinKickOsThread (int64_t imess, + int64_t ip1, int64_t ip2, int64_t ip3, + int64_t ip4, int64_t ip5, int64_t ip6, OS ios, - int *omess, - int *op1, int *op2, int *op3, - int *op4, int *op5, int *op6, + int64_t *omess, + int64_t *op1, int64_t *op2, int64_t *op3, + int64_t *op4, int64_t *op5, int64_t *op6, OS *oos ) { @@ -337,9 +338,9 @@ void WinKickOsThread (int imess, *op5 = gCci.p5; *op6 = gCci.p6; *oos = ios; - /* printf("Data: %d, %d, %d, %d, %d, %d, %d", + printf("Data: %p, %p, %p, %p, %p, %p, %p\n", gCci.p1, gCci.p2, gCci.p3, gCci.p4, - gCci.p5, gCci.p6, ios); */ + gCci.p5, gCci.p6, ios); } else { @@ -447,7 +448,7 @@ void KickCleanThread (CrossCallInfo * pcci) #endif } /* KickCleanThread */ -void SendMessageToClean (int mess, int p1, int p2, int p3, int p4, int p5, int p6) +void SendMessageToClean (int64_t mess, int64_t p1, int64_t p2, int64_t p3, int64_t p4, int64_t p5, int64_t p6) { /* printf("SendMessageToClean -- Message: %d\n", mess); */ gCci.mess = mess; diff --git a/Linux_C_12/cCrossCall_121.h b/Linux_C_12/cCrossCall_121.h index 2111d22..fbd6f93 100644 --- a/Linux_C_12/cCrossCall_121.h +++ b/Linux_C_12/cCrossCall_121.h @@ -49,11 +49,11 @@ extern int CheckVirtualKeyCode (int keycode); extern void HandleCleanRequest( CrossCallInfo *pcci ); extern OS WinStartOsThread (OS); extern OS WinKillOsThread (OS); -extern void WinKickOsThread (int,int,int,int,int,int,int,OS,int*,int*,int*, - int*,int*,int*,int*,OS*); +extern void WinKickOsThread (int64_t,int64_t,int64_t,int64_t,int64_t,int64_t,int64_t,OS, + int64_t*,int64_t*,int64_t*,int64_t*,int64_t*,int64_t*,int64_t*,OS*); extern void KickCleanThread( CrossCallInfo *pcci ); -extern void SendMessageToClean( int mess, int p1,int p2,int p3, int p4,int p5,int p6 ); +extern void SendMessageToClean( int64_t mess, int64_t p1,int64_t p2,int64_t p3, int64_t p4,int64_t p5,int64_t p6 ); /* Shorthands for SendMessageToClean: */ #define SendMessage0ToClean(mess) SendMessageToClean((mess), 0,0,0,0,0,0) diff --git a/Linux_C_12/util_121.c b/Linux_C_12/util_121.c index f0a3de7..544cff6 100644 --- a/Linux_C_12/util_121.c +++ b/Linux_C_12/util_121.c @@ -9,6 +9,7 @@ Generally applicable utility routines. ********************************************************************************************/ #include "util_121.h" +#include "Clean.h" #include #include #include @@ -206,14 +207,22 @@ void WinGetCStringAndFree (PSTR cs, OS ios, CLEAN_STRING * cls, OS * oos) void WinMakeCString (CLEAN_STRING s, OS ios, PSTR * cs, OS * oos) { + char* chars = rmalloc(CleanStringLength(s) + 1); rprintf("(MCS: \""); - *cs = (char *) rmalloc ((s->length) + 1); + *cs = (char*) rmalloc (CleanStringLength(s) + 1 + sizeof(int)); - rsncopy (*cs, s->characters, s->length); - (*cs)[s->length] = 0; + rprintf("length: %d\n", CleanStringLength(s)); + + int i; + for (i = 0; i < CleanStringLength(s); i++) + chars[i] = CleanStringCharacters(s)[i]; + chars[i] = 0; + + rsncopy (*cs, chars, CleanStringLength(s) + 1); + (*cs)[CleanStringLength(s) + 1] = CleanStringLength(s); *oos = ios; - rprintf("\"%s)\n",*cs); + rprintf("\"%s)\n",chars); } /* WinMakeCString */ diff --git a/clCCall_12.icl b/clCCall_12.icl index f307960..07bc194 100644 --- a/clCCall_12.icl +++ b/clCCall_12.icl @@ -179,7 +179,7 @@ winMakeCString _ _ = code { .inline WinMakeCString - ccall WinMakeCString "SI-II" + ccall WinMakeCString "SI-pI" .end } diff --git a/clCrossCall_12.icl b/clCrossCall_12.icl index 8b331f3..6539748 100644 --- a/clCrossCall_12.icl +++ b/clCrossCall_12.icl @@ -90,13 +90,13 @@ where = handleCallBacks callback replyCci tb // PA: macros for returning proper number of arguments within a CrossCallInfo. -Rq0Cci msg :== {ccMsg=msg,p1=0,p2=0,p3=0,p4=0,p5=0,p6=0} -Rq1Cci msg v1 :== {ccMsg=msg,p1=v1,p2=0,p3=0,p4=0,p5=0,p6=0} -Rq2Cci msg v1 v2 :== {ccMsg=msg,p1=v1,p2=v2,p3=0,p4=0,p5=0,p6=0} -Rq3Cci msg v1 v2 v3 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=0,p5=0,p6=0} -Rq4Cci msg v1 v2 v3 v4 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=v4,p5=0,p6=0} -Rq5Cci msg v1 v2 v3 v4 v5 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=v4,p5=v5,p6=0} -Rq6Cci msg v1 v2 v3 v4 v5 v6 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=v4,p5=v5,p6=v6} +Rq0Cci msg :== {ccMsg=msg,p1=0, p2=0, p3=0, p4=0, p5=0, p6=0 } +Rq1Cci msg v1 :== {ccMsg=msg,p1=v1,p2=0, p3=0, p4=0, p5=0, p6=0 } +Rq2Cci msg v1 v2 :== {ccMsg=msg,p1=v1,p2=v2,p3=0, p4=0, p5=0, p6=0 } +Rq3Cci msg v1 v2 v3 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=0, p5=0, p6=0 } +Rq4Cci msg v1 v2 v3 v4 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=v4,p5=0, p6=0 } +Rq5Cci msg v1 v2 v3 v4 v5 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=v4,p5=v5,p6=0 } +Rq6Cci msg v1 v2 v3 v4 v5 v6 :== {ccMsg=msg,p1=v1,p2=v2,p3=v3,p4=v4,p5=v5,p6=v6} return0Cci :: CrossCallInfo return0Cci = Rq0Cci CcRETURN0 @@ -174,7 +174,7 @@ winKickOsThread _ _ = code { .inline WinKickOsThread - ccall WinKickOsThread "IIIIIIII-IIIIIIII" + ccall WinKickOsThread "pppppppp-pppppppp" .end } diff --git a/oswindow.icl b/oswindow.icl index 62a9989..54ac7ac 100644 --- a/oswindow.icl +++ b/oswindow.icl @@ -196,6 +196,7 @@ osGetSliderControlMinWidth _ = 0 /* Window creation functions. */ +import StdMisc osCreateDialog :: !Bool !Bool !String !(!Int,!Int) !(!Int,!Int) !OSWindowPtr !(u:s->*(OSWindowPtr,u:s)) !(OSWindowPtr->u:s->u:(*OSToolbox->*(u:s,*OSToolbox))) @@ -235,7 +236,9 @@ where = //trace_n "osCreateDialogCallback CcWmDEACTIVATE" (return0Cci, (control_info,[DelayDeactivatedWindow hwnd:delay_info]), tb) osCreateDialogCallback get_focus create_controls _ {ccMsg=CcWmINITDIALOG,p1=hwnd} (control_info,delay_info) tb + //| True = abort ("osCreateDialogCallback: " +++ toString hwnd +++ "; " +++ toString (2^62) +++ "\n") # (control_info,tb) = create_controls hwnd control_info tb + //| tb == tb = abort "callback, after create_controls\n" # (defhandle,control_info) = get_focus control_info (x,y) = pos (w,h) = size @@ -562,8 +565,15 @@ osCreateSliderControl parentWindow parentPos show able horizontal (x,y) (w,h) (m # tb = winShowControl sliderPtr show tb = (sliderPtr,tb) +instance toString (a,b) | toString a & toString b +where + toString (a,b) = "(" +++ toString a +++ "," +++ toString b +++")" +from StdMisc import abort osCreateTextControl :: !OSWindowPtr !(!Int,!Int) !String !Bool !(!Int,!Int) !(!Int,!Int) !*OSToolbox -> (!OSWindowPtr,!*OSToolbox) osCreateTextControl parentWindow parentPos text show (x,y) (w,h) tb + //| True = abort ("osCreateTextControl\n" +++ toString parentWindow +++ "\n" +++ + // toString parentPos +++ " - " +++ text +++ " - " +++ toString show +++ "\n" +++ + // "(" +++ toString x +++ "," +++ toString y +++ ") - (" +++ toString w +++ "," +++ toString h +++ ") - " +++ toString tb +++ "\n") # (x,y) = (x-fst parentPos,y-snd parentPos) createcci = Rq5Cci CcRqCREATESTATICTXT parentWindow x y w h # (returncci,tb)= issueCleanRequest2 osIgnoreCallback createcci tb diff --git a/windowCrossCall_12.icl b/windowCrossCall_12.icl index 0b725d7..8291f81 100644 --- a/windowCrossCall_12.icl +++ b/windowCrossCall_12.icl @@ -97,6 +97,7 @@ winObscureCursor tb winSetWindowTitle :: !HWND !String !*OSToolbox -> *OSToolbox winSetWindowTitle hwnd title tb # (textptr,tb) = winMakeCString title tb + //| True = abort ("CSTRING : " +++ title +++ "; " +++ toString textptr +++ "\n") # (_,tb) = issueCleanRequest2 (errorCallback2 "SetWindowTitle") (Rq2Cci CcRqSETWINDOWTITLE hwnd textptr) tb = winReleaseCString textptr tb diff --git a/windowevent.icl b/windowevent.icl index 72f0a30..da02c10 100644 --- a/windowevent.icl +++ b/windowevent.icl @@ -25,8 +25,10 @@ windoweventFatalError function error For the time being no timer controls are added, so these events are ignored. windowEvent assumes that it is not applied to an empty IOSt. */ +import StdMisc windowEvent :: !SchedulerEvent !(PSt .l) -> (!Bool,!Maybe DeviceEvent,!SchedulerEvent,!PSt .l) windowEvent schedulerEvent pState + //| True = abort "windowevent\n" # (hasDevice,pState) = accPIO (ioStHasDevice WindowDevice) pState | not hasDevice // This condition should never occur: WindowDevice must have been 'installed' = windoweventFatalError "windowFunctions.dEvent" "could not retrieve WindowSystemState from IOSt" -- cgit v1.2.3