From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45422 invoked by alias); 1 Apr 2017 20:51:30 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 45409 invoked by uid 89); 1 Apr 2017 20:51:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:1493 X-HELO: mail-vk0-f47.google.com Received: from mail-vk0-f47.google.com (HELO mail-vk0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 01 Apr 2017 20:51:28 +0000 Received: by mail-vk0-f47.google.com with SMTP id z204so111670180vkd.1 for ; Sat, 01 Apr 2017 13:51:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DS5lZsc8KI/GLKTFuSVtrkqMojpIo/JqGhxTzidgu1U=; b=bP8dJGHbfWfq+EOnI7ola3x8a5SFxPb6fP7uO155gxrOYZzqIqOxhvWLNH6p3mA4// Hyt6KxrQ4uXBEviIvKmW1hg755OoLEmHX+eibb7QliKzlDeLWSRQaoseHeZfEDAOCoUY z9zRg0qBBYYOMPn13ZwDZysWB/4FFMmb8u2fHGdAA/S+1CIWkWdAGPm/1Ma98/d4tqF5 D1J1+taruWj1gB83tjcv3tZuG9E+GbPJ4QkB3mdg2btxt9qKouNRiQVGcV+cqLahXewh aKO6tWmy3dFFg/kemSbcnZwxzPeflWnJYwPt0XAh72ZgSj0G7wTft1uPkq5dr024M/4p mEKg== X-Gm-Message-State: AFeK/H02NvC9bI54Lynlq5St4PlI3OpcLBZdtf0lm5wsCaXCr6QA1YpkViJlgFzTkPfRcjbDkcWdgSRBH5OCjg== X-Received: by 10.31.62.6 with SMTP id l6mr3807592vka.74.1491079888312; Sat, 01 Apr 2017 13:51:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.81.136 with HTTP; Sat, 1 Apr 2017 13:51:27 -0700 (PDT) In-Reply-To: References: <29747.1491078000@vereq.eip10.org> From: Vasantha Ganesh Date: Sat, 01 Apr 2017 20:51:00 -0000 Message-ID: Subject: Re: Help, writing kawa equivalent of java program To: Per Bothner Cc: Sudarshan S Chawathe , kawa@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2017-q2/txt/msg00014.txt.bz2 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 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/