Frank A. Christoph <[EMAIL PROTECTED]> writes: 
> 
> Has anyone created an IDL file for Xlib? Alternatively, has 
> anyone created one for H/Direct?
> 
> I know that someone is working on GTK, but I'm interested in 
> Xlib specifically. Also, I'm aware of Sigbjorn's Xlib 
> interface in Haggis, but that one's reportedly still for GHC 0.29. :(
> 

You could write a Haskell to IDL tysig translator, I suppose ;-)
I've got a ghc-3.xx translation of these Xlib stubs, which I 
no doubt could dig up and distribute to interested parties.

> BTW, it's not urgent---I don't have any experience with 
> either Xlib or H/Direct yet; I just want to play around with 
> them. Having unsuccessfully checked the net for a suitable 
> IDL description, I'm taking a shot at writing one myself, and 
> I have a couple questions. (If I ever get this into a usable 
> form, I'll notify you all.)
> 

I like this - such an IDL spec would have the potential of
being compilable with CamlIDL as well, which is Really Great
(and the very reason why IDL was introduced in the first place).

> First, judging from the DCE grammar it looks like you can't 
> specify attributes for constants. In a constant definition like
> 
>   const char *XNCursor = "cursor";
> 
> will H/Direct figure out the right interpretation for char *?
> 

Yes.

> Do I need to specify an attribute (ref, ptr, unique, ..) for 
> every occurrence of a * type in a struct field, or is there a 
> default? The user manual seems to imply that translation of 
> char * types default to [string], but I didn't see any 
> mention of this in my perusal of the DCE spec. The technical 
> report on H/Direct mentions a "pointer default" in connection 
> with the internal translation into core IDL; the DCE spec 
> mentions that you can set a pointer default by setting it on 
> an interface. What about at top level? Is the default just 
> [ptr] for non-char * cases?
> 

As far as I know, there's no mechanism for giving global pointer
defaults. However, if you embed the 'const' inside a module {}
declaration, you can give it a pointer default.

The default-default annotation is [unique] for struct ptrs. However,
HDirect honours [pointer_default()] on structs, 

  struct tagList;
  typedef [pointer_default(ref)]struct tagList {
     valUnion* val;
     [unique]struct tagList* next;
  } LList;


> There is a function which takes an argument that is a pointer 
> to an allocated struct, and deallocates it. What is the 
> correct annotation for this behavior?
> 

If I understand correctly,

  void freeStruct([in,ptr]Struct* p);


> xlib.h has a macro:
> 
>   #define Bool int
> 
> Is it safe to translate this as
> 
>   typedef boolean Bool;
> 
> ? Apparently the "recommended" C-translation for boolean is char...
> 

Yes, I'd suggest just doing a literal translation of the #define,

  typedef int Bool;

and avoid the booleans-in-C debacle.

> Finally, any ideas on how to handle callbacks...? Any other 
> special provisos or advice on dealing with Xlib?
> 

A couple of things:

- parked on my HDD is a version of HDirect that handles IDL function
  types correctly and automatically; to be released shortly.

- The Concurrent Haskell implementation in ghc-4.xx doesn't currently
  have support for doing non-blocking waits on I/O from file descriptors,
  which means that you may have to busy wait on incoming events from
  the X server.

- support Manuel's GTK+ efforts, if possible; Xlib is low-level, and GTK+
  (and its Glib) does hold out the promise of being cross-platform one
  day soon.

- I've been meaning to write a cheap&cheerful header file to IDL
  pre-processor, but have never gotten around to actually doing it. This
  would be of some help to you here, I suppose.

hth,
--sigbjorn

Reply via email to