bill@gothamcity.jsc.nasa.GOV (Bill Shirley [CSC]) (04/17/91)
Hello World, Are you out there? Is this the X SIG electronic mailing list? Q: I am writing a resource conversion routine. How can I call an Xt conversion routine from my converter? There are, basically, two functions to call converters with: XtCallConverter (XtDirectConvert in R3), and XtConvertAndStore (XtConvert in R3). XtCallConverter needs the pointer to the function. The Xt Cvt functions, in Convert.c, are defined statically and thus their pointers aren't available. XtConvertAndStore takes a Widget as a parameter. There is not a Widget to use in my conversion routine. I tried passing a pointer to the core.self field as a parameter and then casting this into a Widget (it is the first field of the instance structure of all Widgets). This gave my the lovely result of a 'Bus error'. I'm not sure what caused it, but the execution stack looked like this: (dbx) where warning: object file read error: text address not found XtStringConversionWarning() at 0xf770335c XtCallConverter() at 0xf7701ecc _XtConvert() at 0xf77020d0 XtConvertAndStore() at 0xf770231c XmyCvtStringToPixelList(display = 0xad50, args = 0xf7ffdfa0, num_args = 0xf7ffdf90, fromVal = 0xf7ffe6a4, toVal = 0xf7ffe6b0, dest_data = 0xf7ffdf38), line 91 in "MyConverters.c" XtCallConverter() at 0xf7701ecc _XtConvert() at 0xf77020d0 _XtCreateIndirectionTable() at 0xf7714930 _XtGetResources() at 0xf7714c08 XtInitializeWidgetClass() at 0xf7705ae8 _XtCreateWidget() at 0xf7705f20 XtCreateWidget() at 0xf7705fb8 XtCreateManagedWidget() at 0xf7705fe4 main(argc = 1, argv = 0xf7fffaac), line 27 in "test.c" Is there a good way to do this? Am I overlooking something? Or will I have to total reimplement the functionality of the XtConversion routines? Someone please help me! Bill Shirley bill@gothamcity.jsc.nasa.gov (713)282-1714 w. Computer Sciences Corp MC:M30 16511 Space Center Blvd. Houston, TX 77058 P.S. Could somebody add me to this mailing list or tell me who to contact to do so, thanks.
aw@jello.bae.bellcore.com (Andrew Wason) (04/18/91)
In article <9104162110.AA25496@gothamcity.jsc.nasa.gov>, bill@gothamcity.jsc.nasa.GOV (Bill Shirley [CSC]) writes: > > Q: I am writing a resource conversion routine. How can I call an Xt > conversion routine from my converter? There are, basically, two functions > to call converters with: XtCallConverter (XtDirectConvert in R3), and > XtConvertAndStore (XtConvert in R3). > > XtCallConverter needs the pointer to the function. The Xt Cvt functions, > in Convert.c, are defined statically and thus their pointers aren't > available. You mean Converters.c. > XtConvertAndStore takes a Widget as a parameter. There is not a Widget to > use in my conversion routine. I tried passing a pointer to the core.self > field as a parameter and then casting this into a Widget (it is the first > field of the instance structure of all Widgets). This gave my the lovely > result of a 'Bus error'. I'm not sure what the correct solution is, but take a look at XmuCvtStringToCursor() in lib/Xmu/StrToCurs.c. It needs to invoke the StringToFont converter. It does the following (old style interface): WidgetRec widgetRec; [...] /* widgetRec is stupid; we should just use XtDirectConvert, * but the names in Xt/Converters aren't public. */ widgetRec.core.screen = screen; fromString.addr = source_name; fromString.size = strlen(source_name); XtConvert(&widgetRec, XtRString, &fromString, XtRFont, &toFont); This seems dangerous, but off hand I can't think of another way. Andrew _______________________________________________________________________________ Andrew Wason Bell Communications Research aw@bae.bellcore.com Piscataway, NJ bellcore!bae!aw