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: Help, writing kawa equivalent of java program


On 04/01/2017 01:20 PM, Sudarshan S Chawathe wrote:
(define-alias library com.sun.jna.Library)
(define-alias native com.sun.jna.Native)

(define-simple-class libc (library)
  interface: #t
  (getpid::long))

(define inst::libc (native:loadLibrary "c" libc:class))
(display (inst:getpid))

I think you need to define the interface to have a getpid method with
the proper signature.  Here is a small example, somewhat similar to your
code, that I tried a while back and that works:

(define-simple-class clib (com.sun.jna.Library)
  interface: #t
  ((puts (s ::String)) ::void #!abstract))

Kawa should be able to infer the signature, so I believe you can write:

    ((puts (s)) #!abstract))

The problem is that:
   (getpid::long)
defines a field, not a method (and non-statuc fields aren't allowed in interfaces).

Kawa should probably catch this error.
--
	--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]