From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aibo.runbox.com (aibo.runbox.com [91.220.196.211]) by sourceware.org (Postfix) with ESMTPS id 9D1C73858020 for ; Tue, 8 Dec 2020 01:23:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D1C73858020 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bothner.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=per@bothner.com Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1kmRid-0007ft-9S; Tue, 08 Dec 2020 02:23:07 +0100 Received: by submission01.runbox with esmtpsa [Authenticated alias (524175)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1kmRiU-00041k-7O; Tue, 08 Dec 2020 02:22:58 +0100 Subject: Re: Problems with old kawa android code To: Peter , kawa mailing list References: <878sa9tif7.fsf@nexoid.at> From: Per Bothner Message-ID: Date: Mon, 7 Dec 2020 17:22:54 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <878sa9tif7.fsf@nexoid.at> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2020 01:23:11 -0000 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/