comp.lang.ada
 help / color / mirror / Atom feed
* Help ! -  Problems with Ada/X (using Apex & Axi-Serc X-Bindings)
@ 1996-08-12  0:00 Bernie Rossi
  1996-08-13  0:00 ` Ted Dennison
  1996-08-13  0:00 ` Jon S Anthony
  0 siblings, 2 replies; 4+ messages in thread
From: Bernie Rossi @ 1996-08-12  0:00 UTC (permalink / raw)



Hi,
  I'm relatively new to Ada and am having some problems trying
to convert some working X code in 'C' (my language of choice) to Ada.
I would appreciate any source or help that anyone can provide.

1. Trying to get a Widgetlist.
In my program I would like to modify some attributes of some
children widgets, so I need to get the widgetlist so that I 
can access them.  The code in 'C' is;

WidgetList children;                /* Defining a pointer to a WidgetList
*/

XtVaGetValues(Form, XmNchildren, &children, NULL);  /* Get Ptr */

Now I can get/set attributes eg;

XtVaGetValues(children[0], XmNwidth, &width, NULL);  /* Get Value */
XtVaSetValues(children[1], XmNwidth, width*2, NULL); /* Set Value */

When I re-write this in Ada the results are un-predicatble & wrong
causing core dumps etc.  Note the problem is getting the WidgetList
only, I can successfully Get/Set values once I have a Widget.

2. Trying to Override the Resize of a Widget.
Due to a relatively complex window I am working on I need to be
able to control the positioning of widgets after a window resize.
The 'C' code is;

XtActionsRec rec;                               /* Defining Structure */

rec.string = "resize";                           /* Setting up of
structure */
rec.proc = resize;
XtAppAddActions(app, &rec, 1);         /* Overriding Resize actions */
XtOverrideTranslations(Form, 
       XtParseTranslationTable("<Configure>: resize()"));

static void resize(w, event, args, num_args)  /* Procedure to re-size */
CompositeWidget w;
XConfigureEvent *event;
String args[];
int *num_args;
{
  etc.
}

When I re-write this code in Ada it compiles and runs without a dump
but produces a message saying something like "Action: resize not found".
So obviously I haven't defined something properly?

Thanks in advance to all who reply.

Regards

Bernie Rossi
bernie@adam.com.au




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help ! -  Problems with Ada/X (using Apex & Axi-Serc X-Bindings)
  1996-08-12  0:00 Help ! - Problems with Ada/X (using Apex & Axi-Serc X-Bindings) Bernie Rossi
@ 1996-08-13  0:00 ` Ted Dennison
  1996-08-14  0:00   ` Paul Hussein
  1996-08-13  0:00 ` Jon S Anthony
  1 sibling, 1 reply; 4+ messages in thread
From: Ted Dennison @ 1996-08-13  0:00 UTC (permalink / raw)



Bernie Rossi wrote:
> 
> 1. Trying to get a Widgetlist.
> In my program I would like to modify some attributes of some
> children widgets, so I need to get the widgetlist so that I
> can access them.  The code in 'C' is;
> 
> WidgetList children;                /* Defining a pointer to a WidgetList
> */
> 
> XtVaGetValues(Form, XmNchildren, &children, NULL);  /* Get Ptr */
...
> 
> When I re-write this in Ada the results are un-predicatble & wrong
> causing core dumps etc.  Note the problem is getting the WidgetList
...

It might help if you posted the Ada code that isn't working, rather than
the C that is. Someone familiar with your compiler/binding combination 
might be able to spot the problem right away.


> 2. Trying to Override the Resize of a Widget.

> The 'C' code is;
> 
> XtActionsRec rec;                               /* Defining Structure */
> 
> rec.string = "resize";                           /* Setting up of
> structure */
> rec.proc = resize;
> XtAppAddActions(app, &rec, 1);         /* Overriding Resize actions */
> XtOverrideTranslations(Form,
>        XtParseTranslationTable("<Configure>: resize()"));
> 
> static void resize(w, event, args, num_args)  /* Procedure to re-size */
...
> 
> When I re-write this code in Ada it compiles and runs without a dump
> but produces a message saying something like "Action: resize not found".
> So obviously I haven't defined something properly?

Yes. Again it would be nice to see the _Ada_ code, but I highly suspect
that you left out the appropriate pragmas for the definition of your 
resize procedure that would make the symbol for it visible to the outside
world. Such pragmas are compiler-dependant things, and I don't know what
Apex uses, so you'll have to check your compiler docs yourself to find the
appropriate pragmas to use.

Also, many compilers have restrictions on how procedures can be defined if
they are to be externally-callable. ie: Your callback procedures may have to
be declared at the top level of a package body. Again, check your compiler
docs.

It may help if you check the material that came with your X Bindings. There
ought to be an example using callbacks or a discussion on how to code them 
somewhere in there.

-- 
T.E.D.          
                |  Work - mailto:dennison@escmail.orl.mmc.com  |
                |  Home - mailto:dennison@iag.net              |
                |  URL  - http://www.iag.net/~dennison         |




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help ! -  Problems with Ada/X (using Apex & Axi-Serc X-Bindings)
  1996-08-12  0:00 Help ! - Problems with Ada/X (using Apex & Axi-Serc X-Bindings) Bernie Rossi
  1996-08-13  0:00 ` Ted Dennison
@ 1996-08-13  0:00 ` Jon S Anthony
  1 sibling, 0 replies; 4+ messages in thread
From: Jon S Anthony @ 1996-08-13  0:00 UTC (permalink / raw)



In article <01bb87e1.6df84880$277c02cb@default> "Bernie Rossi" <bernie@adam.com.au> writes:

> to convert some working X code in 'C' (my language of choice) to Ada.

Use the Intermetrics X/Motif bindings:

-- X11/Motif
--
http://www.inmet.com/~mg/x11ada/x11ada.html

> I would appreciate any source or help that anyone can provide.

These bindings allow you to pretty much directly copy your C stuff into
Ada.

> WidgetList children;                /* Defining a pointer to a WidgetList
> */
> 
> XtVaGetValues(Form, XmNchildren, &children, NULL);  /* Get Ptr */

In Ada:

    function "&" is new Stdarg.Concat(Xt.Intrinsic.Widget);

    Children : aliased array(1..whatever) of aliased Xt.Intrinsic.Widget;

    Xt.Intrinsic.XtVaGetValues(
	Form, Stdarg.Empty &
	Motif.Xmstrdefs.XmNchildren & Children(1)'Access & Nulst );

You can, of course, use "use" if you don't like the qualified notation.


> Now I can get/set attributes eg;

Piece o'cake:

    Width : aliased Integer;

    Xt.Intrinsic.XtVaGetValues(
	Children(1), Stdarg.Empty &
	Motif.Xmstrdefs.XmNwidth & Width'Access &
	Nulst);
    Xt.Intrinsic.XtVaSetValues(
	Children(2), Stdarg.Empty &
	Motif.Xmstrdefs.XmNwidth & Width*2 &
	Nulst);
	
> 
> XtVaGetValues(children[0], XmNwidth, &width, NULL);  /* Get Value */
> XtVaSetValues(children[1], XmNwidth, width*2, NULL); /* Set Value */
> 
> When I re-write this in Ada the results are un-predicatble & wrong
> causing core dumps etc.  Note the problem is getting the WidgetList
> only, I can successfully Get/Set values once I have a Widget.

I do this all the time: No problemo.


> 2. Trying to Override the Resize of a Widget.

Same sort of thing.

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help ! -  Problems with Ada/X (using Apex & Axi-Serc X-Bindings)
  1996-08-13  0:00 ` Ted Dennison
@ 1996-08-14  0:00   ` Paul Hussein
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Hussein @ 1996-08-14  0:00 UTC (permalink / raw)



Ted Dennison <dennison@escmail.orl.mmc.com> wrote:

>Bernie Rossi wrote:
>> 
>> 1. Trying to get a Widgetlist.
>> In my program I would like to modify some attributes of some
>> children widgets, so I need to get the widgetlist so that I
>> can access them.  The code in 'C' is;
>> 
>> WidgetList children;                /* Defining a pointer to a WidgetList
>> */
>> 
>> XtVaGetValues(Form, XmNchildren, &children, NULL);  /* Get Ptr */
>...
>> 
>> When I re-write this in Ada the results are un-predicatble & wrong
>> causing core dumps etc.  Note the problem is getting the WidgetList
>...

>It might help if you posted the Ada code that isn't working, rather than
>the C that is. Someone familiar with your compiler/binding combination 
>might be able to spot the problem right away.


>> 2. Trying to Override the Resize of a Widget.

>> The 'C' code is;
>> 
>> XtActionsRec rec;                               /* Defining Structure */
>> 
>> rec.string = "resize";                           /* Setting up of
>> structure */
>> rec.proc = resize;
>> XtAppAddActions(app, &rec, 1);         /* Overriding Resize actions */
>> XtOverrideTranslations(Form,
>>        XtParseTranslationTable("<Configure>: resize()"));
>> 
>> static void resize(w, event, args, num_args)  /* Procedure to re-size */
>...
>> 
>> When I re-write this code in Ada it compiles and runs without a dump
>> but produces a message saying something like "Action: resize not found".
>> So obviously I haven't defined something properly?

>Yes. Again it would be nice to see the _Ada_ code, but I highly suspect
>that you left out the appropriate pragmas for the definition of your 
>resize procedure that would make the symbol for it visible to the outside
>world. Such pragmas are compiler-dependant things, and I don't know what
>Apex uses, so you'll have to check your compiler docs yourself to find the
>appropriate pragmas to use.

>Also, many compilers have restrictions on how procedures can be defined if
>they are to be externally-callable. ie: Your callback procedures may have to
>be declared at the top level of a package body. Again, check your compiler
>docs.

>It may help if you check the material that came with your X Bindings. There
>ought to be an example using callbacks or a discussion on how to code them 
>somewhere in there.

>-- 
>T.E.D.          
>                |  Work - mailto:dennison@escmail.orl.mmc.com  |
>                |  Home - mailto:dennison@iag.net              |
>                |  URL  - http://www.iag.net/~dennison         |


I agree, please post ADA code as this is more useful. Have you spoken
to bindingd suppliers or looked in another bindings suppliers bindings
to see how they perform call. It may even be something like a non
null-terminated string. 


If the ADA is correct, it could be that you are getting a storag_error
which is manifesting itself in a sigsegv. Try upping stack size of
caller task.

Also another good approach would be to write the problem bit in C and
pragma interface to it to check that everything else is working OK.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-08-14  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-12  0:00 Help ! - Problems with Ada/X (using Apex & Axi-Serc X-Bindings) Bernie Rossi
1996-08-13  0:00 ` Ted Dennison
1996-08-14  0:00   ` Paul Hussein
1996-08-13  0:00 ` Jon S Anthony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox