Index: samples/android/src/org/dartlang/Dart.java |
diff --git a/samples/android/src/org/dartlang/Dart.java b/samples/android/src/org/dartlang/Dart.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4e1a1adb03291fdea7d4747c02cd5c4d940629a8 |
--- /dev/null |
+++ b/samples/android/src/org/dartlang/Dart.java |
@@ -0,0 +1,71 @@ |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+package org.dartlang; |
+ |
+/** |
+ * A static class that wraps access to the Dart VM shared library. |
+ * For expedience we pass the following types as Java primitives |
+ * |
+ * Dart_Handle <-> int. (It's a pointer.) |
+ * Dart_Isolate <-> int. (It's a pointer.) |
+ * |
+ */ |
+public class Dart { |
+ static { |
+ System.loadLibrary("dart_so"); |
+ } |
+ /** Start Dart runtime. |
+ * @return main isolate, or 0 if there was an error. |
+ */ |
+ public static native int dartStart(String[] args); |
+ public static native int dartFinish(int main_isolate); |
+ |
+ public static native boolean IsError(int handle); |
+ public static native boolean IsApiError(int handle); |
+ public static native boolean IsUnhandledExceptionError(int handle); |
+ public static native boolean IsCompilationError(int handle); |
+ public static native boolean IsFatalError(int handle); |
+ public static native String GetError(int handle); |
+ public static native boolean ErrorHasException(int handle); |
+ public static native int ErrorGetException(int handle); |
+ public static native int ErrorGetStacktrace(int handle); |
+ public static native int NewApiError(String message); |
+ |
+ public static native void EnterScope(); |
+ public static native void ExitScope(); |
+ public static native void ShutdownIsolate(); |
+ |
+ public static native int CurrentIsolate(); |
+ public static native void EnterIsolate(int isolate); |
+ public static native void ExitIsolate(); |
+ |
+ public static native int RootLibrary(); |
+ public static native int LoadLibrary(int url, int source); |
+ public static native int LoadSource(int library, int url, int source); |
+ |
+ public static native int New(int clazz, int constructor_name, int[] arguments); |
+ public static native int Invoke(int target, int name, int[] arguments); |
+ public static native int GetField(int container, int name); |
+ public static native int SetField(int container, int name, int value); |
+ |
+ public static native int ToString(int object); |
+ public static native String StringToJavaString(int str); |
+ |
+ public static native boolean IdentityEquals(int obj1, int obj2); |
+ |
+ public static native int RunLoop(); |
+ |
+ public static native int Null(); |
+ public static native boolean IsNull(int handle); |
+ |
+ public static native int NewString(String string); |
+ public static native int NewInteger(long value); |
+ public static native int NewBoolean(boolean value); |
+ public static native int NewDouble(double value); |
+ public static native int NewList(int length); |
+ public static native int ListLength(int list); |
+ public static native int ListGetAt(int list, int index); |
+ public static native int ListSetAt(int list, int index, int value); |
+} |