dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pnet-developers] Question about pnetc access to Xwindows


From: Rhys Weatherley
Subject: Re: [Pnet-developers] Question about pnetc access to Xwindows
Date: Sun, 21 Nov 2004 11:07:28 +1000
User-agent: KMail/1.4.3

On Sunday 21 November 2004 09:47 am, James Michael DuPont wrote:
> Hi,
>
> I have restarted my effort to port the vcg graph layout tool to pnet
> (http://savannah.nongnu.org/projects/vcgdotgnu) and be able to run the
> graph layout engine and display with the xwindows. I hope to be able to
> use the great controls you have been working on to make nice C# driven
> GUIS for this tool.

In that case, you will need to use the Winforms API directly (with some kind 
of C wrapper around the C# classes presumably).  By-passing it to go direct 
to X11/Xsharp won't work.

> Currently I am able to compile now all the source from the project,
> including the access to the xwindows system after patching the compiler
> as described here (
> https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=11068)

Changing an error into a warning is not a fix.  The real fix would be to 
modify "BinarySem", "RelationalSem", and other similar functions in 
"c_oper.tc" to mark the output of an operator as a dynamic constant if either 
operand is a dynamic constant and the other is a normal or dynamic constant.  
A potential change will be needed wherever "ILNode_EvalConst" is called in 
that file (there are a lot of affected operators).  Please try again (and 
yes, I'm asking you to attempt this).

> Now, the problem is linking :
>
> When I compile the code that calls X from c, it produces a call like
> this :
>
> call       valuetype _XDisplay * '<ModuleExtern>'::XOpenDisplay(int8
> modopt([OpenSystem.C]OpenSystem.C.IsConst) *)
>
> But the code in the  libXSharp has the following bindings :
> .namespace Xsharp {.method public static hidebysig pinvokeimpl("X11"
> cdecl ) native int XOpenDisplay(class System.String display_name) cil
> managed {}}
>
> I have taken that to produces a new .Il Binding like this :
> .namespace '<ModuleExtern>'{
>       .method public static hidebysig pinvokeimpl("X11" cdecl ) valuetype
> _XDisplay *   XOpenDisplay(
>               int8 modopt([OpenSystem.C]OpenSystem.C.IsConst) *
>               )  cil managed {}
> }
>
> That is able to link.

<ModuleExtern> is a directive to the linker to find the C function in any 
properly-marked module.  It should "just work" with the straight pinvoke 
declaration if you have marked "libXsharp" properly.  Which in this case, you 
haven't.  The file "pnet/doc/c_language_abi.html" describes all the marker 
attributes that you will need.

Rather than mess with raw IL, I suggest that you use the pnetC compiler to 
generate the pinvoke library layer.  Create a .c file with declarations such 
as follows:

    extern Display *XOpenDisplay(const char *display)
        __attribute__((__pinvoke__("X11"), __cdecl__));

Then compile that into dll library form using the pnetC compiler.  The result 
should have all of the proper markings to link correctly.

> I would like to know if this is right way to proceed, and If so, I will
> create Il bindings for all the needed X windows functions.

As I indicated, you won't get access to Winforms controls this way.  But if 
your app is bare X, then it may work.  But only on X11 systems.

Cheers,

Rhys.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]