public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Peter <craven@gmx.net>, kawa mailing list <kawa@sourceware.org>
Subject: Re: Problems with old kawa android code
Date: Mon, 7 Dec 2020 17:22:54 -0800	[thread overview]
Message-ID: <b04afaeb-3fcc-6d86-64db-ff5172904e3a@bothner.com> (raw)
In-Reply-To: <878sa9tif7.fsf@nexoid.at>

On 12/7/20 1:28 PM, Peter via Kawa wrote:

> foo.scm:3:17: warning - type android.app.Activity is incompatible with required type android.view.View
> foo.scm:3:46: warning - type android.content.Context is incompatible with required type android.view.View
> 
> I don't understand either of these.. The single parameter to the
> constructor on line 3 (android.widget.LinearLayout) is a Context, as it
> should be.. why does kawa want a *View* here?
> 
> Also, where does the Activity come from at all? I don't mention it
> anywhere, why does kawa *want* an Activity here?
> 
> Thanks for any help with this :-/

Short answer:

The simplest fix is probably to remove
    (require 'android-defs)
and add whatever aliases you need.

Long answer:

The android-defs import defines some "magic" features, and it would not
shock me if they no longer work with modern Android/Kawa/JDK.
I have not worked on or even tested the Android code in quite a while.

One of the things android-defs (gnu/kawa/android/defs.scm") does
is "sugar" the constructors of classes (such as LinearLayout) that extend View.
The idea was that the code to build a nested View object would be nested
in the same way as the View nesting.

 From what I can figure out, in old versions of Android a View constructor
would take an Activity initial argument.  This argument was conceptually redundant,
since the current Activity was redundant.   The magic provided by android-defs
was to provide the Activity argument automatically.

See:
https://www.gnu.org/software/kawa/Android-view-construction.html#View-object-allocation
https://www.gnu.org/software/kawa/Allocating-objects.html

This code in defs.scm:
(define-constant {gnu.kawa.reflect/ObjectBuilder}:android.view.View
   "gnu.kawa.android.ViewBuilder")
is to "customize" the object constructors for Android View objects,
using the ViewBuilder class (which is run at compile-time).
ViewBuilder is a sub-class of the generic ComplileBuildObject class,
which implements the general compile-time transformation described in:
https://www.gnu.org/software/kawa/Allocating-objects.html
CompileBuildObject has some "hooks" to customize this re-writing,
and those hooks are used by gnu.kawa.android.ViewBuilder.
I don't believe there is any documentation (except the code) for
how CompileBuildObject can be customized.

My guess is the Android View API at some point was changed so
the initial constructor argument was generalized from Activity to Context,
and this broke the logic in ViewBuilder.scm.  It's probably fixable without
too much effort, but I'm unlikely to do so.  Maybe a volunteer wants to
figure it out?
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

  reply	other threads:[~2020-12-08  1:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 21:28 Peter
2020-12-08  1:22 ` Per Bothner [this message]
2020-12-08  9:10   ` Peter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b04afaeb-3fcc-6d86-64db-ff5172904e3a@bothner.com \
    --to=per@bothner.com \
    --cc=craven@gmx.net \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).