From 1ebf2226c4d6682a48d5a2a8f4e64611da303840 Mon Sep 17 00:00:00 2001 From: matt rice Date: Sun, 8 Apr 2018 17:27:51 -0700 Subject: [PATCH] x.c:widget_values_get(), args_to_pairs(): restructure, rename xt_args_to_pairs. widget_values_get(): store values in an XtArgVal array initialized to zero. xt_args_to_pairs(): expect a pointer to a value, --- src/motif/_xm.sml | 2 +- src/rts/src/OS/Unix/x.c | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/motif/_xm.sml b/src/motif/_xm.sml index c901e394..054efbc6 100644 --- a/src/motif/_xm.sml +++ b/src/motif/_xm.sml @@ -1011,7 +1011,7 @@ functor Xm (structure List: LIST) : XM = | pairToRep (MESSAGE_WINDOW, WIDGET w) = ("messageWindow", ARGUNBOXED (ref (cast w))) | pairToRep (WIDTH, INT i) = - ("width", ARGSHORT (ref i)) + ("width", ARGSHORT (ref i )) | pairToRep (HEIGHT, INT i) = ("height", ARGSHORT (ref i)) | pairToRep (X, INT i) = diff --git a/src/rts/src/OS/Unix/x.c b/src/rts/src/OS/Unix/x.c index dea3584b..1da29bc5 100755 --- a/src/rts/src/OS/Unix/x.c +++ b/src/rts/src/OS/Unix/x.c @@ -1135,7 +1135,7 @@ static void pairs_to_args(Arg args[], Cardinal *nr_args_return, mlval list) -static void args_to_pairs(Arg args[], mlval list) +static void xt_args_to_pairs(Arg args[], mlval list) { Cardinal nr_args = 0; mlval ref= MLUNIT; @@ -1152,24 +1152,24 @@ static void args_to_pairs(Arg args[], mlval list) switch(FIELD(argument, 0)) { case mlw_x_arg_bool: /* Need to cast the pointer before dereferencing */ - mlw_ref_update(ref, MLBOOL(*(Boolean *)(&(args[nr_args].value)))); + mlw_ref_update(ref, MLBOOL(*(Boolean *)(args[nr_args].value))); break; case mlw_x_arg_boxed: { - mlval string = box((unsigned long int)args[nr_args].value); + mlval string = box(*(unsigned long int*)(args[nr_args].value)); mlw_ref_update(ref, string); } break; case mlw_x_arg_int: /* Need to cast the pointer before dereferencing */ - mlw_ref_update(ref, MLINT(*(int *)(&(args[nr_args].value)))); + mlw_ref_update(ref, MLINT(*(int *)(args[nr_args].value))); break; case mlw_x_arg_short: /* Need to cast the pointer before dereferencing */ - mlw_ref_update(ref, MLINT(*(short *)(&(args[nr_args].value)))); + mlw_ref_update(ref, MLINT(*(short *)(args[nr_args].value))); break; case mlw_x_arg_string: @@ -1180,11 +1180,11 @@ static void args_to_pairs(Arg args[], mlval list) break; case mlw_x_arg_unboxed: - mlw_ref_update(ref, (mlval)args[nr_args].value); + mlw_ref_update(ref, (mlval)*((XtArgVal *)args[nr_args].value)); break; default: - error("args_to_pairs: Illegal Argument constructor for resource `%s': 0x%X", + error("xt_args_to_pairs: Illegal Argument constructor for resource `%s': 0x%X", CSTRING(FIELD(head, 0)), FIELD(argument, 0)); } @@ -1885,24 +1885,16 @@ static mlval widget_values_set(mlval argument) static mlval widget_values_get(mlval argument) { Arg args[MAX_NR_ARGS]; + XtArgVal vals[MAX_NR_ARGS] = {0}; Cardinal nr_args, i; mlval list = FIELD(argument, 1); pairs_to_args(args, &nr_args, list); for(i=0; i