提交 80547a2d 编写于 作者: J Jason Simmons

Dart/JNI: reflection-based wrapper for the raw JNI API

Example:
  JavaClass dateFormatClass = Java.getClass('java.text.SimpleDateFormat');
  JavaObject format = dateFormatClass.newInstance('yyyy.MM.dd');
  print(format.parse('2016.01.01').getYear());
上级 30cc1574
......@@ -63,6 +63,8 @@ action("generate_snapshot_bin") {
"//dart/runtime/tools/create_snapshot_bin.py",
"//sky/engine/bindings/internals.dart",
"//sky/engine/bindings/jni/jni.dart",
"//sky/engine/bindings/jni/jni_raw.dart",
"//sky/engine/bindings/jni/jni_helper.dart",
"snapshot.dart",
] + rebase_path(dart_mojo_internal_sdk_sources,
"",
......
......@@ -6,6 +6,8 @@ source_set("jni") {
sources = [
"dart_jni.cc",
"dart_jni.h",
"jni_api.cc",
"jni_api.h",
"jni_array.cc",
"jni_array.h",
"jni_class.cc",
......
......@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "sky/engine/bindings/jni/jni_api.h"
#include "sky/engine/bindings/jni/jni_array.h"
#include "sky/engine/bindings/jni/jni_class.h"
#include "sky/engine/bindings/jni/jni_object.h"
......@@ -93,6 +94,10 @@ bool CheckDartException(Dart_Handle result, Dart_Handle* exception) {
return true;
}
DART_NATIVE_CALLBACK_STATIC(JniApi, FromReflectedField);
DART_NATIVE_CALLBACK_STATIC(JniApi, FromReflectedMethod);
DART_NATIVE_CALLBACK_STATIC(JniApi, GetApplicationContext);
DART_NATIVE_CALLBACK_STATIC(JniApi, GetClassLoader);
DART_NATIVE_CALLBACK_STATIC(JniBooleanArray, Create);
DART_NATIVE_CALLBACK_STATIC(JniByteArray, Create);
DART_NATIVE_CALLBACK_STATIC(JniCharArray, Create);
......@@ -196,6 +201,10 @@ void DartJni::InitForGlobal() {
g_natives = new DartLibraryNatives();
g_natives->Register({
DART_REGISTER_NATIVE_STATIC(JniApi, FromReflectedField)
DART_REGISTER_NATIVE_STATIC(JniApi, FromReflectedMethod)
DART_REGISTER_NATIVE_STATIC(JniApi, GetApplicationContext)
DART_REGISTER_NATIVE_STATIC(JniApi, GetClassLoader)
DART_REGISTER_NATIVE_STATIC(JniBooleanArray, Create)
DART_REGISTER_NATIVE_STATIC(JniByteArray, Create)
DART_REGISTER_NATIVE_STATIC(JniCharArray, Create)
......@@ -306,6 +315,10 @@ jstring DartJni::DartToJavaString(JNIEnv* env, Dart_Handle dart_string,
return java_string;
}
jobject DartJni::class_loader() {
return g_jvm_data->class_loader.obj();
}
jclass DartJni::class_clazz() {
return g_jvm_data->class_clazz.obj();
}
......
......@@ -37,6 +37,7 @@ class DartJni {
static jstring DartToJavaString(JNIEnv* env, Dart_Handle dart_string,
Dart_Handle* exception);
static jobject class_loader();
static jclass class_clazz();
static Dart_Handle jni_object_type();
static Dart_Handle jni_float_type();
......
......@@ -7,262 +7,5 @@ library dart_jni;
import 'dart:collection';
import 'dart:nativewrappers';
/// Wrapper for a Java class accessed via JNI.
class JniClass extends NativeFieldWrapperClass2 {
static JniClass fromName(String name)
native 'JniClass_FromName';
static JniClass fromClassObject(JniObject classObject)
native 'JniClass_FromClassObject';
int getFieldId(String name, String sig)
native 'JniClass_GetFieldId';
int getStaticFieldId(String name, String sig)
native 'JniClass_GetStaticFieldId';
int getMethodId(String name, String sig)
native 'JniClass_GetMethodId';
int getStaticMethodId(String name, String sig)
native 'JniClass_GetStaticMethodId';
JniObject newObject(int methodId, List args)
native 'JniClass_NewObject';
JniObject getStaticObjectField(int fieldId)
native 'JniClass_GetStaticObjectField';
bool getStaticBooleanField(int fieldId)
native 'JniClass_GetStaticBooleanField';
int getStaticByteField(int fieldId)
native 'JniClass_GetStaticByteField';
int getStaticCharField(int fieldId)
native 'JniClass_GetStaticCharField';
int getStaticShortField(int fieldId)
native 'JniClass_GetStaticShortField';
int getStaticIntField(int fieldId)
native 'JniClass_GetStaticIntField';
int getStaticLongField(int fieldId)
native 'JniClass_GetStaticLongField';
double getStaticFloatField(int fieldId)
native 'JniClass_GetStaticFloatField';
double getStaticDoubleField(int fieldId)
native 'JniClass_GetStaticDoubleField';
void setStaticObjectField(int fieldId, JniObject value)
native 'JniClass_SetStaticObjectField';
void setStaticBooleanField(int fieldId, bool value)
native 'JniClass_SetStaticBooleanField';
void setStaticByteField(int fieldId, int value)
native 'JniClass_SetStaticByteField';
void setStaticCharField(int fieldId, int value)
native 'JniClass_SetStaticCharField';
void setStaticShortField(int fieldId, int value)
native 'JniClass_SetStaticShortField';
void setStaticIntField(int fieldId, int value)
native 'JniClass_SetStaticIntField';
void setStaticLongField(int fieldId, int value)
native 'JniClass_SetStaticLongField';
void setStaticFloatField(int fieldId, double value)
native 'JniClass_SetStaticFloatField';
void setStaticDoubleField(int fieldId, double value)
native 'JniClass_SetStaticDoubleField';
JniObject callStaticObjectMethod(int methodId, List args)
native 'JniClass_CallStaticObjectMethod';
bool callStaticBooleanMethod(int methodId, List args)
native 'JniClass_CallStaticBooleanMethod';
int callStaticByteMethod(int methodId, List args)
native 'JniClass_CallStaticByteMethod';
int callStaticCharMethod(int methodId, List args)
native 'JniClass_CallStaticCharMethod';
int callStaticShortMethod(int methodId, List args)
native 'JniClass_CallStaticShortMethod';
int callStaticIntMethod(int methodId, List args)
native 'JniClass_CallStaticIntMethod';
int callStaticLongMethod(int methodId, List args)
native 'JniClass_CallStaticLongMethod';
double callStaticFloatMethod(int methodId, List args)
native 'JniClass_CallStaticFloatMethod';
double callStaticDoubleMethod(int methodId, List args)
native 'JniClass_CallStaticDoubleMethod';
void callStaticVoidMethod(int methodId, List args)
native 'JniClass_CallStaticVoidMethod';
}
/// Wrapper for a Java object accessed via JNI.
class JniObject extends NativeFieldWrapperClass2 {
JniObject getObjectField(int fieldId)
native 'JniObject_GetObjectField';
bool getBooleanField(int fieldId)
native 'JniObject_GetBooleanField';
int getByteField(int fieldId)
native 'JniObject_GetByteField';
int getCharField(int fieldId)
native 'JniObject_GetCharField';
int getShortField(int fieldId)
native 'JniObject_GetShortField';
int getIntField(int fieldId)
native 'JniObject_GetIntField';
int getLongField(int fieldId)
native 'JniObject_GetLongField';
double getFloatField(int fieldId)
native 'JniObject_GetFloatField';
double getDoubleField(int fieldId)
native 'JniObject_GetDoubleField';
void setObjectField(int fieldId, JniObject value)
native 'JniObject_SetObjectField';
void setBooleanField(int fieldId, bool value)
native 'JniObject_SetBooleanField';
void setByteField(int fieldId, int value)
native 'JniObject_SetByteField';
void setCharField(int fieldId, int value)
native 'JniObject_SetCharField';
void setShortField(int fieldId, int value)
native 'JniObject_SetShortField';
void setIntField(int fieldId, int value)
native 'JniObject_SetIntField';
void setLongField(int fieldId, int value)
native 'JniObject_SetLongField';
void setFloatField(int fieldId, double value)
native 'JniObject_SetFloatField';
void setDoubleField(int fieldId, double value)
native 'JniObject_SetDoubleField';
JniObject callObjectMethod(int methodId, List args)
native 'JniObject_CallObjectMethod';
bool callBooleanMethod(int methodId, List args)
native 'JniObject_CallBooleanMethod';
int callByteMethod(int methodId, List args)
native 'JniObject_CallByteMethod';
int callCharMethod(int methodId, List args)
native 'JniObject_CallCharMethod';
int callShortMethod(int methodId, List args)
native 'JniObject_CallShortMethod';
int callIntMethod(int methodId, List args)
native 'JniObject_CallIntMethod';
int callLongMethod(int methodId, List args)
native 'JniObject_CallLongMethod';
double callFloatMethod(int methodId, List args)
native 'JniObject_CallFloatMethod';
double callDoubleMethod(int methodId, List args)
native 'JniObject_CallDoubleMethod';
void callVoidMethod(int methodId, List args)
native 'JniObject_CallVoidMethod';
}
/// Wrapper for a Java string.
class JniString extends JniObject {
static JniString create(String value)
native 'JniString_Create';
// Retrieve the value as a Dart string.
String get text native 'JniString_GetText';
}
/// Wrapper for a Java array.
class JniArray extends JniObject {
int get length native 'JniArray_GetLength';
}
class JniObjectArray extends JniArray {
static JniObjectArray create(JniClass clazz, int length)
native 'JniObjectArray_Create';
JniObject operator [](int index)
native 'JniObjectArray_GetArrayElement';
void operator []=(int index, JniObject value)
native 'JniObjectArray_SetArrayElement';
}
class JniBooleanArray extends JniArray {
static JniBooleanArray create(int length)
native 'JniBooleanArray_Create';
bool operator [](int index)
native 'JniBooleanArray_GetArrayElement';
void operator []=(int index, bool value)
native 'JniBooleanArray_SetArrayElement';
}
class JniByteArray extends JniArray {
static JniByteArray create(int length)
native 'JniByteArray_Create';
int operator [](int index)
native 'JniByteArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniByteArray_SetArrayElement';
}
class JniCharArray extends JniArray {
static JniCharArray create(int length)
native 'JniCharArray_Create';
int operator [](int index)
native 'JniCharArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniCharArray_SetArrayElement';
}
class JniShortArray extends JniArray {
static JniShortArray create(int length)
native 'JniShortArray_Create';
int operator [](int index)
native 'JniShortArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniShortArray_SetArrayElement';
}
class JniIntArray extends JniArray {
static JniIntArray create(int length)
native 'JniIntArray_Create';
int operator [](int index)
native 'JniIntArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniIntArray_SetArrayElement';
}
class JniLongArray extends JniArray {
static JniLongArray create(int length)
native 'JniLongArray_Create';
int operator [](int index)
native 'JniLongArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniLongArray_SetArrayElement';
}
class JniFloatArray extends JniArray {
static JniFloatArray create(int length)
native 'JniFloatArray_Create';
double operator [](int index)
native 'JniFloatArray_GetArrayElement';
void operator []=(int index, double value)
native 'JniFloatArray_SetArrayElement';
}
class JniDoubleArray extends JniArray {
static JniDoubleArray create(int length)
native 'JniDoubleArray_Create';
double operator [](int index)
native 'JniDoubleArray_GetArrayElement';
void operator []=(int index, double value)
native 'JniDoubleArray_SetArrayElement';
}
/// Used to pass arguments of type "float" to Java methods.
class JniFloat {
final double value;
JniFloat(this.value);
}
part 'jni_raw.dart';
part 'jni_helper.dart';
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/engine/bindings/jni/jni_api.h"
#include "sky/engine/bindings/jni/dart_jni.h"
namespace blink {
int64_t JniApi::FromReflectedField(const JniObject* field) {
Dart_Handle exception = nullptr;
{
ENTER_JNI();
jfieldID result = env->FromReflectedField(field->java_object());
if (CheckJniException(env, &exception)) goto fail;
return reinterpret_cast<int64_t>(result);
}
fail:
Dart_ThrowException(exception);
ASSERT_NOT_REACHED();
return 0;
}
int64_t JniApi::FromReflectedMethod(const JniObject* method) {
Dart_Handle exception = nullptr;
{
ENTER_JNI();
jmethodID result = env->FromReflectedMethod(method->java_object());
if (CheckJniException(env, &exception)) goto fail;
return reinterpret_cast<int64_t>(result);
}
fail:
Dart_ThrowException(exception);
ASSERT_NOT_REACHED();
return 0;
}
PassRefPtr<JniObject> JniApi::GetApplicationContext() {
ENTER_JNI();
return JniObject::Create(env, base::android::GetApplicationContext());
}
PassRefPtr<JniObject> JniApi::GetClassLoader() {
ENTER_JNI();
return JniObject::Create(env, DartJni::class_loader());
}
} // namespace blink
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_ENGINE_BINDINGS_JNI_JNI_API_H_
#define SKY_ENGINE_BINDINGS_JNI_JNI_API_H_
#include "sky/engine/bindings/jni/jni_object.h"
namespace blink {
// Dart wrappers for basic JNI APIs.
class JniApi {
public:
static int64_t FromReflectedField(const JniObject* field);
static int64_t FromReflectedMethod(const JniObject* method);
static PassRefPtr<JniObject> GetApplicationContext();
static PassRefPtr<JniObject> GetClassLoader();
};
} // namespace blink
#endif // SKY_ENGINE_BINDINGS_JNI_JNI_API_H_
......@@ -5,7 +5,6 @@
#include "sky/engine/bindings/jni/jni_class.h"
#include "sky/engine/bindings/jni/dart_jni.h"
#include "sky/engine/bindings/jni/jni_object.h"
namespace blink {
......@@ -14,8 +13,7 @@ using base::android::ScopedJavaLocalRef;
IMPLEMENT_WRAPPERTYPEINFO(jni, JniClass);
JniClass::JniClass(JNIEnv* env, jclass clazz)
: clazz_(env, clazz) {
}
: JniObject(env, clazz) {}
JniClass::~JniClass() {
}
......
......@@ -8,6 +8,7 @@
#include <jni.h>
#include "base/android/jni_android.h"
#include "sky/engine/bindings/jni/jni_object.h"
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefCounted.h"
......@@ -17,8 +18,9 @@ namespace blink {
class JniObject;
// Wrapper that exposes a JNI jclass to Dart
class JniClass : public RefCounted<JniClass>, public DartWrappable {
class JniClass : public JniObject {
DEFINE_WRAPPERTYPEINFO();
friend class JniObject;
public:
~JniClass() override;
......@@ -26,7 +28,7 @@ class JniClass : public RefCounted<JniClass>, public DartWrappable {
static PassRefPtr<JniClass> FromName(const char* className);
static PassRefPtr<JniClass> FromClassObject(const JniObject* clazz);
jclass java_class() const { return clazz_.obj(); }
jclass java_class() const { return static_cast<jclass>(object_.obj()); }
intptr_t GetFieldId(const char* name, const char* sig);
intptr_t GetStaticFieldId(const char* name, const char* sig);
......@@ -79,8 +81,6 @@ class JniClass : public RefCounted<JniClass>, public DartWrappable {
private:
JniClass(JNIEnv* env, jclass clazz);
base::android::ScopedJavaGlobalRef<jclass> clazz_;
};
} // namespace blink
......
此差异已折叠。
......@@ -30,6 +30,8 @@ PassRefPtr<JniObject> JniObject::Create(JNIEnv* env, jobject object) {
if (class_name == "java.lang.String") {
result = new JniString(env, static_cast<jstring>(object));
} else if (class_name == "java.lang.Class") {
result = new JniClass(env, static_cast<jclass>(object));
} else if (base::StartsWith(class_name, "[L", base::CompareCase::SENSITIVE)) {
result = new JniObjectArray(env, static_cast<jobjectArray>(object));
} else if (class_name == "[Z") {
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
part of dart_jni;
/// Invoke Java Native Interface APIs from Dart.
class JniApi {
static int fromReflectedField(JniObject field)
native 'JniApi_FromReflectedField';
static int fromReflectedMethod(JniObject method)
native 'JniApi_FromReflectedMethod';
static JniObject getApplicationContext()
native 'JniApi_GetApplicationContext';
static JniObject getClassLoader()
native 'JniApi_GetClassLoader';
}
/// Wrapper for a Java object accessed via JNI.
class JniObject extends NativeFieldWrapperClass2 {
JniObject getObjectField(int fieldId)
native 'JniObject_GetObjectField';
bool getBooleanField(int fieldId)
native 'JniObject_GetBooleanField';
int getByteField(int fieldId)
native 'JniObject_GetByteField';
int getCharField(int fieldId)
native 'JniObject_GetCharField';
int getShortField(int fieldId)
native 'JniObject_GetShortField';
int getIntField(int fieldId)
native 'JniObject_GetIntField';
int getLongField(int fieldId)
native 'JniObject_GetLongField';
double getFloatField(int fieldId)
native 'JniObject_GetFloatField';
double getDoubleField(int fieldId)
native 'JniObject_GetDoubleField';
void setObjectField(int fieldId, JniObject value)
native 'JniObject_SetObjectField';
void setBooleanField(int fieldId, bool value)
native 'JniObject_SetBooleanField';
void setByteField(int fieldId, int value)
native 'JniObject_SetByteField';
void setCharField(int fieldId, int value)
native 'JniObject_SetCharField';
void setShortField(int fieldId, int value)
native 'JniObject_SetShortField';
void setIntField(int fieldId, int value)
native 'JniObject_SetIntField';
void setLongField(int fieldId, int value)
native 'JniObject_SetLongField';
void setFloatField(int fieldId, double value)
native 'JniObject_SetFloatField';
void setDoubleField(int fieldId, double value)
native 'JniObject_SetDoubleField';
JniObject callObjectMethod(int methodId, List args)
native 'JniObject_CallObjectMethod';
bool callBooleanMethod(int methodId, List args)
native 'JniObject_CallBooleanMethod';
int callByteMethod(int methodId, List args)
native 'JniObject_CallByteMethod';
int callCharMethod(int methodId, List args)
native 'JniObject_CallCharMethod';
int callShortMethod(int methodId, List args)
native 'JniObject_CallShortMethod';
int callIntMethod(int methodId, List args)
native 'JniObject_CallIntMethod';
int callLongMethod(int methodId, List args)
native 'JniObject_CallLongMethod';
double callFloatMethod(int methodId, List args)
native 'JniObject_CallFloatMethod';
double callDoubleMethod(int methodId, List args)
native 'JniObject_CallDoubleMethod';
void callVoidMethod(int methodId, List args)
native 'JniObject_CallVoidMethod';
}
/// Wrapper for a Java class accessed via JNI.
class JniClass extends JniObject {
static JniClass fromName(String name)
native 'JniClass_FromName';
static JniClass fromClassObject(JniObject classObject)
native 'JniClass_FromClassObject';
int getFieldId(String name, String sig)
native 'JniClass_GetFieldId';
int getStaticFieldId(String name, String sig)
native 'JniClass_GetStaticFieldId';
int getMethodId(String name, String sig)
native 'JniClass_GetMethodId';
int getStaticMethodId(String name, String sig)
native 'JniClass_GetStaticMethodId';
JniObject newObject(int methodId, List args)
native 'JniClass_NewObject';
JniObject getStaticObjectField(int fieldId)
native 'JniClass_GetStaticObjectField';
bool getStaticBooleanField(int fieldId)
native 'JniClass_GetStaticBooleanField';
int getStaticByteField(int fieldId)
native 'JniClass_GetStaticByteField';
int getStaticCharField(int fieldId)
native 'JniClass_GetStaticCharField';
int getStaticShortField(int fieldId)
native 'JniClass_GetStaticShortField';
int getStaticIntField(int fieldId)
native 'JniClass_GetStaticIntField';
int getStaticLongField(int fieldId)
native 'JniClass_GetStaticLongField';
double getStaticFloatField(int fieldId)
native 'JniClass_GetStaticFloatField';
double getStaticDoubleField(int fieldId)
native 'JniClass_GetStaticDoubleField';
void setStaticObjectField(int fieldId, JniObject value)
native 'JniClass_SetStaticObjectField';
void setStaticBooleanField(int fieldId, bool value)
native 'JniClass_SetStaticBooleanField';
void setStaticByteField(int fieldId, int value)
native 'JniClass_SetStaticByteField';
void setStaticCharField(int fieldId, int value)
native 'JniClass_SetStaticCharField';
void setStaticShortField(int fieldId, int value)
native 'JniClass_SetStaticShortField';
void setStaticIntField(int fieldId, int value)
native 'JniClass_SetStaticIntField';
void setStaticLongField(int fieldId, int value)
native 'JniClass_SetStaticLongField';
void setStaticFloatField(int fieldId, double value)
native 'JniClass_SetStaticFloatField';
void setStaticDoubleField(int fieldId, double value)
native 'JniClass_SetStaticDoubleField';
JniObject callStaticObjectMethod(int methodId, List args)
native 'JniClass_CallStaticObjectMethod';
bool callStaticBooleanMethod(int methodId, List args)
native 'JniClass_CallStaticBooleanMethod';
int callStaticByteMethod(int methodId, List args)
native 'JniClass_CallStaticByteMethod';
int callStaticCharMethod(int methodId, List args)
native 'JniClass_CallStaticCharMethod';
int callStaticShortMethod(int methodId, List args)
native 'JniClass_CallStaticShortMethod';
int callStaticIntMethod(int methodId, List args)
native 'JniClass_CallStaticIntMethod';
int callStaticLongMethod(int methodId, List args)
native 'JniClass_CallStaticLongMethod';
double callStaticFloatMethod(int methodId, List args)
native 'JniClass_CallStaticFloatMethod';
double callStaticDoubleMethod(int methodId, List args)
native 'JniClass_CallStaticDoubleMethod';
void callStaticVoidMethod(int methodId, List args)
native 'JniClass_CallStaticVoidMethod';
}
/// Wrapper for a Java string.
class JniString extends JniObject {
static JniString create(String value)
native 'JniString_Create';
// Retrieve the value as a Dart string.
String get text native 'JniString_GetText';
static String unwrap(JniObject object) => (object as JniString).text;
}
/// Wrapper for a Java array.
class JniArray extends JniObject {
int get length native 'JniArray_GetLength';
void set length(int value) { throw new UnsupportedError("Not supported."); }
}
class JniObjectArray extends JniArray with ListMixin<JniObject> {
static JniObjectArray create(JniClass clazz, int length)
native 'JniObjectArray_Create';
JniObject operator [](int index)
native 'JniObjectArray_GetArrayElement';
void operator []=(int index, JniObject value)
native 'JniObjectArray_SetArrayElement';
}
class JniBooleanArray extends JniArray with ListMixin<bool> {
static JniBooleanArray create(int length)
native 'JniBooleanArray_Create';
bool operator [](int index)
native 'JniBooleanArray_GetArrayElement';
void operator []=(int index, bool value)
native 'JniBooleanArray_SetArrayElement';
}
class JniByteArray extends JniArray with ListMixin<int> {
static JniByteArray create(int length)
native 'JniByteArray_Create';
int operator [](int index)
native 'JniByteArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniByteArray_SetArrayElement';
}
class JniCharArray extends JniArray with ListMixin<int> {
static JniCharArray create(int length)
native 'JniCharArray_Create';
int operator [](int index)
native 'JniCharArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniCharArray_SetArrayElement';
}
class JniShortArray extends JniArray with ListMixin<int> {
static JniShortArray create(int length)
native 'JniShortArray_Create';
int operator [](int index)
native 'JniShortArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniShortArray_SetArrayElement';
}
class JniIntArray extends JniArray with ListMixin<int> {
static JniIntArray create(int length)
native 'JniIntArray_Create';
int operator [](int index)
native 'JniIntArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniIntArray_SetArrayElement';
}
class JniLongArray extends JniArray with ListMixin<int> {
static JniLongArray create(int length)
native 'JniLongArray_Create';
int operator [](int index)
native 'JniLongArray_GetArrayElement';
void operator []=(int index, int value)
native 'JniLongArray_SetArrayElement';
}
class JniFloatArray extends JniArray with ListMixin<double> {
static JniFloatArray create(int length)
native 'JniFloatArray_Create';
double operator [](int index)
native 'JniFloatArray_GetArrayElement';
void operator []=(int index, double value)
native 'JniFloatArray_SetArrayElement';
}
class JniDoubleArray extends JniArray with ListMixin<double> {
static JniDoubleArray create(int length)
native 'JniDoubleArray_Create';
double operator [](int index)
native 'JniDoubleArray_GetArrayElement';
void operator []=(int index, double value)
native 'JniDoubleArray_SetArrayElement';
}
/// Used to pass arguments of type "float" to Java methods.
class JniFloat {
final double value;
JniFloat(this.value);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册