From: lanzo@tekelec.com (Mark Lanzo)
Subject: Any way to use va_list with XtVa type functions?
Keywords: X11-R4, Motif 1.1.2
Organization: Tekelec Inc., Raleigh NC
Date: Thu, 21 Jan 1993 21:37:53 GMT

Is there any way to use a nested varargs list (specified as a va_list)
with the toolkit varargs interface routines?

I'll concoct a simple example here to clarify what I mean ...
let's say I want to do something along these lines:

  | #include <stdarg.h> and other headers ...
  | 
  | Widget newRadioButton(char * name, Widget parent, ...)
  |     {
  |     va_list stack;
  |     Widget button;
  | 
  |     va_start(stack, parent);
  |     button = XtVaCreateWidget(        name, 
  |         xmToggleButtonGadgetClass,    parent, 
  |         XmNvisibleWhenOff,            True,
  |         XmNindicatorType,             XmONE_OF_MANY,
  |         nested_varargs_list,          stack,         <-- HOW?
  |         NULL);
  | 
  |     va_end(stack);
  |     return(button);
  |     }

It would be sufficient if I could simply specify a nested ArgList;
provided that there is a public routine to take a "va_list" variable
and convert it into an ArgList and count, e.g.:

  |     Cardinal numArgs;
  |     ArgList  moreArgs;
  |
  |     va_start(stack, parent);
  |
  |     ConvertVaListToArgList(stack, &moreArgs, &numArgs);
  |
  |     button = XtVaCreateWidget(        name, 
  |         xmToggleButtonGadgetClass,    parent, 
  |         XmNvisibleWhenOff,            True,
  |         XmNindicatorType,             XmONE_OF_MANY,
  |         nested_ArgList,               moreArgs,      <-- HOW? and how
  |                                                      to supply "numArgs"?
  |         NULL);
  | 
  |     XtFree(moreArgs);
  |     va_end(stack);

A solution of this second form would be acceptable, although the 
first form would be preferable, being cleaner and simpler.

The only *documented* routine which I could find that even relates
to this is XtVaCreateArgsList(), but this isn't helpful because it
takes an actual variadic list, NOT a "va_list" item.  

Is there any *legitimate* way to accomplish this?  
I know that it may be possible if I delve into the realm of 
Routines You Aren't Supposed To Know About, like _XtCountVaList() 
or _XtVaToArgList(), but I'm looking for a better way, especially since:

  (a) I have no information about these hidden routines beyond 
      that which I've seen posted to the various comp.windows.*
      newsgroups, and;

  (b) I don't want something which is nonportable or breaks on 
      the next Xt release because I used an undocumented, non-endorsed
      method.

Incidentally, how does one use XtVaCreateArgsList()?  I would 
guess that the XtVarArgsList object it returns is a pointer to a 
structure containing an ArgList and count, and that maybe it is
used in a fashion something like:

  |     XtVarArgsList moreArgs;
  |     moreArgs = XtVaCreateArgsList(...);
  |
  |     button = XtVaCreateWidget(        name, 
  |         xmToggleButtonGadgetClass,    parent, 
  |         XmNvisibleWhenOff,            True,
  |         XmNindicatorType,             XmONE_OF_MANY,
  |         XtVaNestedList,               moreArgs;

but I could not find this documented anywhere.

Any help will be greatly appreciated,

	--Mark

+--------------------------------------------------------+------- /// -----+
| Mark Lanzo   KD4QLZ   lanzo@tekelec.com   919-460-5576 |    \\\///       |
+--------------------------------------------------------+---- \XX/ -------+

Newsgroups: comp.windows.x.intrinsics