This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A seemingly simple problem with methods and Android


On 07/13/2011 07:32 AM, Colin Gan wrote:
I am trying to use the below:

(require 'android-defs)
(define-simple-class <RobotCanvas>  (android.view.View))

(activity KawaActivity
   (on-create-view
    (RobotCanvas (this)
     )))

The first problem is that Kawa doesn't think that the name RobotCanvas
refers to the class <RobotCanvas> - after all it's a different identifier.
It will work if you compile the define-simple-class <RobotCanvas> separately.
In that case, the define-simple-class will create a class named RobotCanvas.
Then the constructor call to RobotCanvas will fail to find RobotCanvas but
will find a class RobotCanvas in the class-path, so it works.


But you don't need to do separate compilation - just use the same name:

(require 'android-defs)
(define-simple-class RobotCanvas (android.view.View))

(activity KawaActivity
  (on-create-view
   (RobotCanvas (this)
    )))

The next problem is that RobotCanvas has no explicit constructor,
so Kawa tried generating a default constructor - which isn't
allowed, because android.view.View doesn't have a default constructor.
(I just checked in a fix to get a decent error mesage for this.)

So we add a constructor:

(define-simple-class RobotCanvas (android.view.View)
  ((*init* v::android.content.Context)
   (invoke-special android.view.View (this) '*init* v)))

This compiles.  I haven't tried running it.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]