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] |
Well, now there is. The attached patch (against r7055) adds a new special form, #!native, which (like #!abstract) can take the place of a method body. The compiler will set the ACC_NATIVE access flag on that method (which gnu.bytecode already knew how to do), and will not try to interpret #!native as a return value.
$ cat native.scm (define-simple-class native_math () (allocation: 'static init: (com.sun.jna.Native:register "m")) ((cos (x ::double)) ::double allocation: 'static #!native) ((sin (x ::double)) ::double allocation: 'static #!native))
(format #t "cos(0)=~A~%" (native_math:cos 0)) (format #t "sin(0)=~A~%" (native_math:sin 0)) $ java kawa.repl -f native.scm cos(0)=1.0 sin(0)=0.0
The modified files are: Special.java: new public static final Special nativeSpecial QuoteExp.java: new static public QuoteExp nativeExp LispReader.java: reads "#!native" as the new nativeSpecial Translator.java: rewrites Special.nativeSpecial as QuoteExp.nativeExp Method.java: new method isNative() ClassExp.java compileMembers(): treat native methods like abstract ones (i.e. bodiless) LambdaExp.java: new method isNative(); treat native methods similarly to abstract methods (set the appropriate Access flag, don't coerce #!native to a return value, etc.)
-- Jamison Hope The PTR Group www.theptrgroup.com
Attachment:
native.patch
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |