Fix method too long errors from JVM on Kawa

This commit is contained in:
retropikzel 2024-08-23 09:30:47 +03:00
parent 1218972deb
commit a049f359f5
1 changed files with 12 additions and 14 deletions

View File

@ -55,20 +55,18 @@
(syntax-rules () (syntax-rules ()
((pffi-define scheme-name shared-object c-name return-type argument-types) ((pffi-define scheme-name shared-object c-name return-type argument-types)
(define scheme-name (define scheme-name
(let* ((of-void (class-methods java.lang.foreign.FunctionDescriptor 'ofVoid)) (lambda vals
(of (class-methods java.lang.foreign.FunctionDescriptor 'of)) (invoke (invoke (cdr (assoc 'linker shared-object))
(function-descriptor (if (equal? return-type 'void) 'downcallHandle
(apply of-void (map pffi-type->native-type argument-types)) (invoke (invoke (cdr (assoc 'lookup shared-object))
(apply of (append (list (pffi-type->native-type return-type)) (map pffi-type->native-type argument-types))))) 'find
(method-handle (invoke (cdr (assoc 'linker shared-object)) (symbol->string c-name))
'downcallHandle 'orElseThrow)
(invoke (invoke (cdr (assoc 'lookup shared-object)) (if (equal? return-type 'void)
'find (apply (class-methods java.lang.foreign.FunctionDescriptor 'ofVoid) (map pffi-type->native-type argument-types))
(symbol->string c-name)) (apply (class-methods java.lang.foreign.FunctionDescriptor 'of) (cons (pffi-type->native-type return-type) (map pffi-type->native-type argument-types)))))
'orElseThrow) 'invokeWithArguments
function-descriptor))) (map value->object vals argument-types)))))))
(lambda vals
(invoke method-handle 'invokeWithArguments (map value->object vals argument-types))))))))