From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cc260587857d0c81,start X-Google-Attributes: gid103376,public From: Frode Tenneb� Subject: Thin binding of C++ classes Date: 2000/07/20 Message-ID: <964084369.995740@tornado.itea.ntnu.no>#1/1 X-Deja-AN: 648552136 Cache-Post-Path: tornado.itea.ntnu.no!frodet@hagbart.nvg.ntnu.no X-Complaints-To: usenet@itea.ntnu.no X-Trace: kopp.stud.ntnu.no 964087856 27508 129.241.190.18 (20 Jul 2000 10:10:56 GMT) Organization: Norwegian university of science and technology X-Cache: nntpcache 2.4.0b2 (see http://www.nntpcache.org/) User-Agent: tin/1.4.3-20000502 ("Marian") (UNIX) (Linux/2.2.12 (i686)) NNTP-Posting-Date: 20 Jul 2000 10:10:56 GMT Newsgroups: comp.lang.ada Date: 2000-07-20T10:10:56+00:00 List-Id: 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