comp.lang.ada
 help / color / mirror / Atom feed
* Thin binding of C++ classes
@ 2000-07-20  0:00 Frode Tenneb�
  2000-07-20  0:00 ` Stephen Leake
  0 siblings, 1 reply; 2+ messages in thread
From: Frode Tenneb� @ 2000-07-20  0:00 UTC (permalink / raw)


I'm currently writing a binding to Tenet's MapLink (www.tenet.co.uk). This
is my first atempt on writing a 'serious' binding. I have just stared and
I'm already feeling stomped. :)

This is an example of a simpler class:

class TSLMotifSurface : public TSLDrawingSurface
{
public:
      TSLMotifSurface (Display* display, Window handle, long flags = 0);
      TSLMotifSurface (Display* display, Screen* screen, Colormap
colormap, Pixmap handle, long flags = 0);
      TSLMotifSurface (Display* display, TSLUNIXPrinter* printer);
      virtual ~TSLMotifSurface();
  protected:

  private:
};

I have though of using tagged types for the class representation, however,
I came across ada.finalization which could be benifitial here. But I have
not found any literature on this subject (though, I have just ordered an
update of my library). What is recomended?

My atempt looks like this:

with X_Lib;

package TSL_Drawing_Surface.TSL_Motif_Surface is

   type Object is tagged private;
   type Object_Ptr is access Object'Class;

   function TSL_Motif_Surface (Display : in X_Lib.Display_Pointer;
                             Handle  : in X_Lib.Window_ID;
                             Flags   : in Long_Integer := 1) return
Object_Ptr;

   function TSL_Motif_Surface (Display  : in X_Lib.Display_Pointer;
                             Screen   : in X_Lib.Screen_Pointer;
                             Colormap : in X_Lib.Colormap_ID;
                             Handle   : in X_Lib.Pixmap_ID;
                             Flags    : in Long_Integer := 1) return
Object_Ptr;

--  function Create (Display : in X_Lib.Display_Pointer;
--                 Printer : in TSLUNIXPrinter_Pointer) return Object_Ptr;

private
   pragma Import (C, TSL_Motif_Surface, "TSLMotifSurface");
   type Object is tagged with null record;

end TSL_Drawing_Surface.TSL_Motif_Surface;

However, trying to 

(15)   Ds       : TSL_Drawing_Surface.TSL_Motif_Surface.Object_Ptr;
(23)   Ds := TSL_Drawing_Surface.TSL_Motif_Surface.TSL_Motif_Surface 
         ( Display => Display,
           Handle  => X_Toolkit.XtWindow( toplevel ),
           Flags   => TSL_DOUBLE_BUFFERING);

gives:

example.adb:15:52: "Object_Ptr" not declared in "TSL_Motif_Surface"
example.adb:23:47: "TSL_Motif_Surface" not declared in "TSL_Motif_Surface"
gnatmake: "example.adb" compilation error


What can be wrong?

Then there is the case with the overloaded constructor. Will pragma Import 
handle this accordingly? Should I go for a thicker binding?

Furthermore, the parent class of this one (TSLDrawingSurface) uses friend.
How is that best dealt with?

Regards,
 -Frode




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

end of thread, other threads:[~2000-07-20  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-20  0:00 Thin binding of C++ classes Frode Tenneb�
2000-07-20  0:00 ` Stephen Leake

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