Skip to content

Commit 8970098

Browse files
committed
refactor: argument change
1 parent a36cb87 commit 8970098

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

dart_native/android/src/main/jni/dart_native.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,21 @@ extern "C"
169169
}
170170

171171
/// invoke native method
172-
void *invokeNativeMethod(void *objPtr, char *methodName, void **args, char **argTypes, int argCount, char *returnType, uint32_t stringTypeBitmask)
172+
void *invokeNativeMethod(void *objPtr, char *methodName, void **arguments, char **dataTypes, int argumentCount, char *returnType, uint32_t stringTypeBitmask)
173173
{
174174
void *nativeInvokeResult = nullptr;
175175
JNIEnv *env = _getEnv();
176176

177177
auto object = static_cast<jobject>(objPtr);
178178
jclass cls = objectGlobalCache[object];
179179

180-
auto *argValues = new jvalue[argCount];
181-
if (argCount > 0)
180+
auto *argValues = new jvalue[argumentCount];
181+
if (argumentCount > 0)
182182
{
183-
_fillArgs(args, argTypes, argValues, argCount, stringTypeBitmask);
183+
_fillArgs(arguments, dataTypes, argValues, argumentCount, stringTypeBitmask);
184184
}
185185

186-
char *methodSignature = generateSignature(argTypes, argCount, returnType);
186+
char *methodSignature = generateSignature(dataTypes, argumentCount, returnType);
187187
DNDebug("call method %s %s", methodName, methodSignature);
188188
jmethodID method = env->GetMethodID(cls, methodName, methodSignature);
189189

@@ -201,7 +201,9 @@ extern "C"
201201
{
202202
if (env->IsInstanceOf(obj, gStrCls))
203203
{
204-
*++argTypes = (char *)"1";
204+
/// mark the last pointer as string
205+
/// dart will check this pointer
206+
*++dataTypes = (char *) "java/lang/String";
205207
nativeInvokeResult = convertToDartUtf16(env, (jstring)obj);
206208
}
207209
else

dart_native/lib/src/android/common/pointer_encoding.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ dynamic loadValueFromPointer(Pointer<Void> ptr, String returnType,
142142
return;
143143
}
144144

145-
if (Utf8.fromUtf8(typePtr.value) == "1") {
145+
if (Utf8.fromUtf8(typePtr.value) == "java/lang/String") {
146146
return fromUtf16(ptr);
147147
}
148148

0 commit comments

Comments
 (0)