This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Alternate syntax for field access/method calls
Per Bothner wrote:
Chris Dean wrote:
(define-namespace jframe <javax.swing.JFrame>)
;; ...
(let ((frame (jframe:new "Kawa App")))
(jframe:get-content-pane frame))
Though at the cost of extra run-time casts, at least until
Kawa does better data-flow/type-inference.
I just checked in a fix for this:
If the variable in a let doesn't have a declared type,
and it is not re-assigned, then it gets the type of
the initial value.
There is still a bug in the handling of:
(define-namespace jframe <javax.swing.JFrame>)
I'll have a fix for that later today; until then,
you can try:
(define-namespace jframe "class:javax.swing.JFrame")
(define (foo x)
(let ((frame (jframe:new "Kawa App")))
(jframe:getContentPane frame)))
This generates:
Method name:"foo" public static Signature:
(java.lang.Object)java.awt.Container
Attribute "Code", length:71, max_stack:3, max_locals:2, code_length:15
0: new <Class javax.swing.JFrame>
3: dup
4: ldc <String "Kawa App">
6: invokespecial <Method javax.swing.JFrame.<init>
(java.lang.String)void>
9: astore_1
10: aload_1
11: invokevirtual <Method javax.swing.JFrame.getContentPane
()java.awt.Container>
14: areturn
Attribute "LineNumberTable", length:10, count: 2
line: 3 at pc: 0
line: 4 at pc: 10
Attribute "LocalVariableTable", length:22, count: 2
slot#0: name: x, type: java.lang.Object (pc: 0 length: 15)
slot#1: name: frame, type: javax.swing.JFrame (pc: 9 length: 5)
--
--Per Bothner
per@bothner.com http://per.bothner.com/