comp.lang.ada
 help / color / mirror / Atom feed
* [wxAda] Problem with "limited with" in a *real* application
@ 2005-10-11 15:17 Lucretia
  2005-10-11 21:23 ` Randy Brukardt
  0 siblings, 1 reply; 9+ messages in thread
From: Lucretia @ 2005-10-11 15:17 UTC (permalink / raw)


I have a type hierarchy which is rooted at wx.Factory.Factory_Type,
inside this package there is a function which allows the programmer to
get the C++ pointer to the wx instance for any wxAda type
(Get_wxObject).

<wx.Factory>
package wx.Factory is

  -- This is the base type of all wxAda types.
  type Factory_Type is new Ada.Finalization.Limited_Controlled with
private;
  ...
  function Get_wxObject(Self : in Factory_Type) return System.Address;
  ...

end wx.Factory;
</wx.Factory>

Inside wx.Core.Sizer I have a Set_Sizer procedure which actually
belongs to the wxWindow class and thus should be inside wx.Core.Window.
It cannot go there currently, because of cyclic dependencies
(wx.Core.Sizer also requires access to wx.Core.Window). I have tried to
get this working using Ada 2005's "limited with" but for some reason I
just cannot get it to compile. I think wx.Core.Window needs to have the
full view of the Sizer_Type.

<wx.Core.Window>
limited with wx.Core.Sizer;

package wx.Core.Window is

  type Window_Type is new Event_Handler_Type with private;

  procedure Set_Sizer(
    Self : in Window_Type;
    Sizer : access wx.Core.Sizer.Sizer_Type;
    Delete_Old_Sizer : in Boolean := True);

end wx.Core.Window;


package body wx.Core.Window is

  procedure Set_Sizer(
    Self : in Window_Type;
    Sizer : access wx.Core.Sizer.Sizer_Type;
    Delete_Old_Sizer : in Boolean := True) is

    procedure wxWindow_SetSizer(
      Self, Sizer : in System.Address;
      Delete_Old_Sizer : in C.int);
    pragma Import(C, wxWindow_SetSizer, "wxWindow_SetSizer");

    Delete_Old_Sizer_Converted : C.int := 0;

  begin

    if Delete_Old_Sizer = True then

      Delete_Old_Sizer_Converted := 1;

    end if;

    wxWindow_SetSizer(Get_wxObject(Self), Get_wxObject(Sizer.all),
Delete_Old_Sizer_Converted);

  end Set_Sizer;

end wx.Core.Window;
</wx.Core.Window>

<log>
$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1-20050902/configure
--prefix=/opt/gcc-4.1-20050902 --enable-libada
--enable-languages=c,c++,objc,ada
Thread model: posix
gcc version 4.1.0 20050902 (experimental)

...

gcc -c -g -gnatf -gnatwj -gnat05 wx-core-window.adb
wx-core-window.adb:751:43: no candidate interpretations match the
actuals:
wx-core-window.adb:751:62: missing with_clause for scope of imported
type "Sizer.Sizer_Type"
wx-core-window.adb:751:62:   ==> in call to "get_wxobject" at
wx-core-window.ads:22(inherited)
wx-core-window.adb:751:62:   ==> in call to "get_wxobject" at
wx-core-colour.ads:9(inherited)
wx-core-window.adb:751:62:   ==> in call to "get_wxobject" at
wx-base-event_handler.ads:17(inherited)
wx-core-window.adb:751:62:   ==> in call to "get_wxobject" at
wx-base-event.ads:18(inherited)
wx-core-window.adb:751:62:   ==> in call to "get_wxobject" at
wx-base-object.ads:21(inherited)
wx-core-window.adb:751:62:   ==> in call to "Get_wxObject" at
wx-factory.ads:32
gnatmake: "wx-core-window.adb" compilation error

raised MAKE.COMPILATION_FAILED : make.adb:4791
</log>




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

end of thread, other threads:[~2005-10-15 13:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11 15:17 [wxAda] Problem with "limited with" in a *real* application Lucretia
2005-10-11 21:23 ` Randy Brukardt
2005-10-12 17:06   ` Lucretia
2005-10-13 14:50     ` Lucretia
2005-10-13 16:18       ` Lucretia
2005-10-14  0:36         ` Randy Brukardt
2005-10-14 15:03           ` Lucretia
2005-10-14 23:47             ` Randy Brukardt
2005-10-15 13:48               ` Lucretia

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