From: "Alex R. Mosteo" <alejandro@mosteo.invalid>
Subject: Re: Ada 'hello world' for Android; success!
Date: Thu, 27 Oct 2011 09:12:44 +0200
Date: 2011-10-27T09:12:44+02:00 [thread overview]
Message-ID: <j8b099$kgf$1@dont-email.me> (raw)
In-Reply-To: 8239efcjuw.fsf@stephe-leake.org
Wow congrats! To me this is impressive. And having these patches available
in some place is definitely great.
Alex.
Stephen Leake wrote:
> I've managed to get an Ada 'hello world' working on Android. It follows
> the example at
> http://developer.android.com/resources/tutorials/hello-world.html
> translated to Ada.
>
> Here's the Ada 'main program':
>
> with Android.App.Activity;
> with Android.OS.Bundle;
> package Hello is
>
> -- <Ada package>$<Ada type> must match ../AndroidManifest.xml manifest
> | application | activity | android:name type Typ is new
> Android.App.Activity.Typ with null record;
>
> overriding procedure OnCreate
> (This : access Typ;
> savedInstanceState : access Standard.Android.Os.Bundle.Typ'Class);
> pragma Export (Java, OnCreate, "onCreate");
>
> end Hello;
> -- Prefix must match ../AndroidManifest.xml manifest | package
> pragma Export (Java, Hello, "net.example.helloada.hello");
>
> package body Hello is
>
> overriding procedure OnCreate
> (This : access Typ;
> savedInstanceState : access Standard.Android.Os.Bundle.Typ'class)
> is
> type Super_Ref is access all Android.App.Activity.Typ;
> begin
> Android.App.Activity.Oncreate (Super_Ref (This),
> savedInstanceState);
>
> -- FIXME: use R.layout
> --
> -- need to run jvm2ada on ../gen/net/example/R.java, but that's
> -- generated by the ant process that runs after this code is
> -- compiled, so we have to learn how to break that up or
> -- something.
> --
> -- until then, get this constant from R.java (value for 'layout')
> Android.App.Activity.SetContentView (Android.App.Activity.Ref
> (This), 16#7f030000#);
> end OnCreate;
>
> end Hello;
>
> It runs on the Android emulator provided with the Android SDK, and on my
> HTC Inspire.
>
> As you can see, there are still some rough edges in the build process. I
> could have hard-coded the 'hello' string here, but that's not what the
> Java program does; this demonstrates that the Ada code really is using
> all the Java GUI resources and classes properly.
>
> Mostly I didn't want to spend any more time figuring out how to
> customize the Android SDK build tools. They work really nicely if you
> are doing simple Java stuff, but really get in the way when you want to
> do something more complicated.
>
> I started with GNAT GPL 2011, jvm target. I had to fix two bugs in
> jvm2ada, one bug in the jvm-gnat backend (all reported to AdaCore with
> patches), and work around another bug in the gnat front end (also
> reported to AdaCore). Not too bad :).
>
> Any suggestions for where to post more info?
> wikibooks.org/wiki/Ada_Programming looks like a good place, but I'm not
> sure where this fits in that hierarchy.
>
> I can post a .tar.gz (or just the .apk :) on my own website if anyone is
> interested in getting a quick look now.
>
> There are some interesting issues in the Ada <-> Java mapping; for
> example, Ada packages map to Java nested classes, so you have to put the
> desired Java package name in the 'pragma Export' external name.
>
> Figuring out how to tell the SDK build tools exactly what was going on
> was the most frustrating; the documentation on those is totally
> inadequate. I managed to find some answers in the source code for the
> tools; at least it is all open source.
>
> Fixing the bugs in the GNAT tools was easy by comparison, once I had
> test cases.
>
> Now I can work on my music player app, and get away from Java ;).
>
next prev parent reply other threads:[~2011-10-27 7:12 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 1:18 Ada 'hello world' for Android; success! Stephen Leake
2011-10-27 7:12 ` Alex R. Mosteo [this message]
2011-10-28 12:51 ` Stephen Leake
2011-10-27 10:50 ` Jeffrey Creem
2011-10-28 13:01 ` Stephen Leake
2011-10-27 10:58 ` Brian Drummond
2011-10-28 1:37 ` Shark8
2011-10-28 12:22 ` Anatoly Chernyshev
2011-10-29 13:37 ` Stephen Leake
2011-10-29 14:46 ` Anatoly Chernyshev
2011-10-29 20:47 ` Brad Moore
2011-10-29 21:59 ` Anatoly Chernyshev
2011-10-30 3:51 ` Brad Moore
2011-10-30 7:20 ` Anatoly Chernyshev
2011-10-30 10:56 ` Stephen Leake
2011-10-30 17:32 ` Brad Moore
2011-10-29 15:32 ` Georg Bauhaus
2011-10-29 16:09 ` Simon Wright
2011-10-29 17:32 ` tmoran
2011-10-30 11:38 ` Stephen Leake
2011-10-29 20:51 ` Brad Moore
2011-10-30 11:32 ` Stephen Leake
2011-10-31 22:34 ` Randy Brukardt
2011-11-01 8:41 ` Stephen Leake
2011-11-01 9:30 ` Georg Bauhaus
2011-11-02 15:55 ` Stephen Leake
2011-11-02 17:37 ` Robert A Duff
2011-11-08 3:56 ` Randy Brukardt
2011-11-03 0:37 ` Georg Bauhaus
2011-11-03 11:36 ` Stephen Leake
2011-11-03 15:24 ` Robert A Duff
2011-11-03 18:43 ` Pascal Obry
2011-11-03 22:14 ` Georg Bauhaus
2011-11-04 8:48 ` Dmitry A. Kazakov
2011-11-04 12:18 ` Stephen Leake
2011-11-04 15:03 ` Georg Bauhaus
2011-11-05 16:56 ` Stephen Leake
2011-11-01 9:52 ` Dmitry A. Kazakov
2011-11-02 15:59 ` Stephen Leake
2011-11-02 16:27 ` Dmitry A. Kazakov
2011-11-02 17:38 ` Simon Wright
2011-11-10 17:25 ` Stephen Leake
2011-11-27 15:18 ` mockturtle
2011-11-28 22:35 ` Ada 'hello world' for Android; success! (but music player failure) Stephen Leake
2011-11-29 11:23 ` Georg Bauhaus
2011-11-30 3:33 ` Stephen Leake
2011-11-30 18:57 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox