Changeset 45 in project


Ignore:
Timestamp:
11/25/05 14:56:37 (13 years ago)
Author:
daishi
Message:

jni: emit-jni-method (experimental)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jni/jni-base.scm

    r44 r45  
    640640  `(lambda ,llist (checked-return (begin ,@body) name))) ; yes, `name' is captured
    641641
     642(define-macro (emit-jni-method mtype has-inst has-class)
     643  (unless (string=? mtype "") (set! mtype (string-append mtype "-")))
     644  `(define (,(string->symbol (sprintf "jni:~amethod" mtype))
     645            rtype class name tlist #!optional safe)
     646     (let* ((md (string-append "(" (jni:type-list->signature tlist) ")" (jni:type->descriptor rtype)))
     647            (mid (or (,(string->symbol (sprintf "jni:get-~amethod-id" mtype))
     648                      class (->string name) md)
     649                     (error ,(sprintf "jni:~amethod" mtype) "no such method" class name md)))
     650            (len (length tlist)) )
     651       (case rtype
     652         ,@(map (lambda (x)
     653                  `(,(car x)
     654                    (if safe
     655                        ,@(map (lambda (y)
     656                                 `(checked-lambda ,(if has-inst '(inst . args) 'args) (,(string->symbol (sprintf "invoke-call-~a~a-method~a" mtype (cdr x) y)) ,@(if has-inst '(inst) '()) ,@(if has-class '(class) '()) md mid args len)))
     657                               '("" "-safe")))))
     658                '(((void) . void) ((boolean) . boolean) ((byte) . byte)
     659                  ((char) . char) ((short) . short) ((int) . int)
     660                  ((long) . long) ((float) . float) ((double) . double)
     661                  (else . object)))))))
     662
     663(emit-jni-method "" #t #f)
     664(emit-jni-method "static" #f #t)
     665(emit-jni-method "nonvirtual" #t #t)
     666
     667
     668#|
     669
    642670(define (jni:method rtype class name tlist #!optional safe)
    643671  (let* ((md (string-append "(" (jni:type-list->signature tlist) ")" (jni:type->descriptor rtype)))
     
    781809           (checked-lambda (inst . args) (invoke-call-nonvirtual-object-method inst class md mid args len)) ) ) ) ) )
    782810
     811|#
     812
    783813(define (jni:constructor class tlist #!optional safe)
    784814  (let* ((md (string-append "(" (jni:type-list->signature tlist) ")V"))
Note: See TracChangeset for help on using the changeset viewer.