Skip to content

Commit 4b72834

Browse files
committed
refactor: simplify _jcall generation
1 parent 53a85f5 commit 4b72834

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/core.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -432,29 +432,29 @@ end
432432
# JField invoke
433433
(f::JField)(obj) = jfield(obj, f)
434434

435-
for (x, name) in [(:Type, "Object"),
436-
(:(Type{jboolean}), "Boolean"),
437-
(:(Type{jchar}), "Char" ),
438-
(:(Type{jbyte}), "Byte" ),
439-
(:(Type{jshort}), "Short" ),
440-
(:(Type{jint}), "Int" ),
441-
(:(Type{jlong}), "Long" ),
442-
(:(Type{jfloat}), "Float" ),
443-
(:(Type{jdouble}), "Double" ),
444-
(:(Type{jvoid}), "Void" )]
435+
for (x, name) in [(:(<:Any), :Object),
436+
(:jboolean, :Boolean),
437+
(:jchar, :Char ),
438+
(:jbyte, :Byte ),
439+
(:jshort, :Short ),
440+
(:jint, :Int ),
441+
(:jlong, :Long ),
442+
(:jfloat, :Float ),
443+
(:jdouble, :Double ),
444+
(:jvoid, :Void )]
445445
for (t, callprefix, getprefix) in [
446446
(:JavaObject, :Call, :Get ),
447447
(:JavaMetaClass, :CallStatic, :GetStatic )
448448
]
449449
callmethod = :(JNI.$(Symbol(callprefix, name, :MethodA)))
450450
fieldmethod = :(JNI.$(Symbol(getprefix, name, :Field)))
451451
m = quote
452-
function _jfield(obj::T, jfieldID::Ptr{Nothing}, fieldType::$x) where T <: $t
452+
function _jfield(obj::T, jfieldID::Ptr{Nothing}, fieldType::Type{$x}) where T <: $t
453453
result = $fieldmethod(Ptr(obj), jfieldID)
454454
geterror()
455455
return convert_result(fieldType, result)
456456
end
457-
function _jcall(obj::T, jmethodId::Ptr{Nothing}, rettype::$x,
457+
function _jcall(obj::T, jmethodId::Ptr{Nothing}, rettype::Type{$x},
458458
argtypes::Tuple, args...; callmethod=$callmethod) where T <: $t
459459
savedArgs, convertedArgs = convert_args(argtypes, args...)
460460
GC.@preserve savedArgs begin

0 commit comments

Comments
 (0)