public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Vasantha Ganesh <vasanthaganesh.k@gmail.com>
To: Per Bothner <per@bothner.com>
Cc: Sudarshan S Chawathe <chaw@eip10.org>, kawa@sourceware.org
Subject: Re: Help, writing kawa equivalent of java program
Date: Sat, 01 Apr 2017 20:51:00 -0000	[thread overview]
Message-ID: <CAL0TjKpZ3MoaGcb1RDBZ-wJa=__qmhpec3QHboegM5ab9eBiVQ@mail.gmail.com> (raw)
In-Reply-To: <eed21a30-f78f-952d-60b8-75b89da53f23@bothner.com>

Hello,
  It worked after making it a method and then making the method abstract.

Code for future users?

(define-alias library com.sun.jna.Library)
(define-alias native com.sun.jna.Native)

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

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


Thanks a lot!
Vasantha Ganesh K.

On Sun, Apr 2, 2017 at 1:55 AM, Per Bothner <per@bothner.com> wrote:
> 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/

  reply	other threads:[~2017-04-01 20:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01 15:54 Vasantha Ganesh
2017-04-01 16:28 ` Per Bothner
2017-04-01 19:44   ` Vasantha Ganesh
2017-04-01 19:52     ` Per Bothner
2017-04-01 19:59       ` Vasantha Ganesh
2017-04-01 20:00         ` Vasantha Ganesh
2017-04-01 20:20           ` Sudarshan S Chawathe
2017-04-01 20:25             ` Per Bothner
2017-04-01 20:51               ` Vasantha Ganesh [this message]
2017-04-02  5:39   ` Per Bothner

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='CAL0TjKpZ3MoaGcb1RDBZ-wJa=__qmhpec3QHboegM5ab9eBiVQ@mail.gmail.com' \
    --to=vasanthaganesh.k@gmail.com \
    --cc=chaw@eip10.org \
    --cc=kawa@sourceware.org \
    --cc=per@bothner.com \
    /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).