aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/android/ffi.rs
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-04-24 09:51:23 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-04-24 09:51:23 +0200
commit3ad7f9a58429b02b11b18f6a70ac011f698b6f4b (patch)
tree3061216335701a5faa8bd3c5c9ec0499a357be5a /src/api/android/ffi.rs
parentc1af76550f311e3da7a08d393b4ea9805cb61a7b (diff)
downloadglutin-3ad7f9a58429b02b11b18f6a70ac011f698b6f4b.tar.gz
glutin-3ad7f9a58429b02b11b18f6a70ac011f698b6f4b.zip
Create reorganization
Diffstat (limited to 'src/api/android/ffi.rs')
-rw-r--r--src/api/android/ffi.rs130
1 files changed, 130 insertions, 0 deletions
diff --git a/src/api/android/ffi.rs b/src/api/android/ffi.rs
new file mode 100644
index 0000000..111f670
--- /dev/null
+++ b/src/api/android/ffi.rs
@@ -0,0 +1,130 @@
+#![allow(dead_code)]
+#![allow(non_snake_case)]
+#![allow(non_camel_case_types)]
+#![allow(non_upper_case_globals)]
+
+use libc;
+
+pub mod egl {
+ pub type khronos_utime_nanoseconds_t = super::khronos_utime_nanoseconds_t;
+ pub type khronos_uint64_t = super::khronos_uint64_t;
+ pub type khronos_ssize_t = super::khronos_ssize_t;
+ pub type EGLNativeDisplayType = super::EGLNativeDisplayType;
+ pub type EGLNativePixmapType = super::EGLNativePixmapType;
+ pub type EGLNativeWindowType = super::EGLNativeWindowType;
+ pub type EGLint = super::EGLint;
+ pub type NativeDisplayType = super::EGLNativeDisplayType;
+ pub type NativePixmapType = super::EGLNativePixmapType;
+ pub type NativeWindowType = super::EGLNativeWindowType;
+
+ include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
+}
+
+pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
+pub type khronos_uint64_t = libc::uint64_t;
+pub type khronos_ssize_t = libc::c_long;
+pub type EGLint = libc::int32_t;
+pub type EGLNativeDisplayType = *const libc::c_void;
+pub type EGLNativePixmapType = *const libc::c_void; // FIXME: egl_native_pixmap_t instead
+pub type EGLNativeWindowType = *const ANativeWindow;
+
+#[link(name = "android")]
+#[link(name = "EGL")]
+#[link(name = "GLESv2")]
+extern {}
+
+/**
+ * asset_manager.h
+ */
+pub type AAssetManager = ();
+
+/**
+ * native_window.h
+ */
+pub type ANativeWindow = ();
+
+extern {
+ pub fn ANativeWindow_getHeight(window: *const ANativeWindow) -> libc::int32_t;
+ pub fn ANativeWindow_getWidth(window: *const ANativeWindow) -> libc::int32_t;
+}
+
+/**
+ * native_activity.h
+ */
+pub type JavaVM = ();
+pub type JNIEnv = ();
+pub type jobject = *const libc::c_void;
+
+pub type AInputQueue = (); // FIXME: wrong
+pub type ARect = (); // FIXME: wrong
+
+#[repr(C)]
+pub struct ANativeActivity {
+ pub callbacks: *mut ANativeActivityCallbacks,
+ pub vm: *mut JavaVM,
+ pub env: *mut JNIEnv,
+ pub clazz: jobject,
+ pub internalDataPath: *const libc::c_char,
+ pub externalDataPath: *const libc::c_char,
+ pub sdkVersion: libc::int32_t,
+ pub instance: *mut libc::c_void,
+ pub assetManager: *mut AAssetManager,
+ pub obbPath: *const libc::c_char,
+}
+
+#[repr(C)]
+pub struct ANativeActivityCallbacks {
+ pub onStart: extern fn(*mut ANativeActivity),
+ pub onResume: extern fn(*mut ANativeActivity),
+ pub onSaveInstanceState: extern fn(*mut ANativeActivity, *mut libc::size_t),
+ pub onPause: extern fn(*mut ANativeActivity),
+ pub onStop: extern fn(*mut ANativeActivity),
+ pub onDestroy: extern fn(*mut ANativeActivity),
+ pub onWindowFocusChanged: extern fn(*mut ANativeActivity, libc::c_int),
+ pub onNativeWindowCreated: extern fn(*mut ANativeActivity, *const ANativeWindow),
+ pub onNativeWindowResized: extern fn(*mut ANativeActivity, *const ANativeWindow),
+ pub onNativeWindowRedrawNeeded: extern fn(*mut ANativeActivity, *const ANativeWindow),
+ pub onNativeWindowDestroyed: extern fn(*mut ANativeActivity, *const ANativeWindow),
+ pub onInputQueueCreated: extern fn(*mut ANativeActivity, *mut AInputQueue),
+ pub onInputQueueDestroyed: extern fn(*mut ANativeActivity, *mut AInputQueue),
+ pub onContentRectChanged: extern fn(*mut ANativeActivity, *const ARect),
+ pub onConfigurationChanged: extern fn(*mut ANativeActivity),
+ pub onLowMemory: extern fn(*mut ANativeActivity),
+}
+
+/**
+ * looper.h
+ */
+pub type ALooper = ();
+
+#[link(name = "android")]
+extern {
+ pub fn ALooper_forThread() -> *const ALooper;
+ pub fn ALooper_acquire(looper: *const ALooper);
+ pub fn ALooper_release(looper: *const ALooper);
+ pub fn ALooper_prepare(opts: libc::c_int) -> *const ALooper;
+ pub fn ALooper_pollOnce(timeoutMillis: libc::c_int, outFd: *mut libc::c_int,
+ outEvents: *mut libc::c_int, outData: *mut *mut libc::c_void) -> libc::c_int;
+ pub fn ALooper_pollAll(timeoutMillis: libc::c_int, outFd: *mut libc::c_int,
+ outEvents: *mut libc::c_int, outData: *mut *mut libc::c_void) -> libc::c_int;
+ pub fn ALooper_wake(looper: *const ALooper);
+ pub fn ALooper_addFd(looper: *const ALooper, fd: libc::c_int, ident: libc::c_int,
+ events: libc::c_int, callback: ALooper_callbackFunc, data: *mut libc::c_void)
+ -> libc::c_int;
+ pub fn ALooper_removeFd(looper: *const ALooper, fd: libc::c_int) -> libc::c_int;
+}
+
+pub const ALOOPER_PREPARE_ALLOW_NON_CALLBACKS: libc::c_int = 1 << 0;
+
+pub const ALOOPER_POLL_WAKE: libc::c_int = -1;
+pub const ALOOPER_POLL_CALLBACK: libc::c_int = -2;
+pub const ALOOPER_POLL_TIMEOUT: libc::c_int = -3;
+pub const ALOOPER_POLL_ERROR: libc::c_int = -4;
+
+pub const ALOOPER_EVENT_INPUT: libc::c_int = 1 << 0;
+pub const ALOOPER_EVENT_OUTPUT: libc::c_int = 1 << 1;
+pub const ALOOPER_EVENT_ERROR: libc::c_int = 1 << 2;
+pub const ALOOPER_EVENT_HANGUP: libc::c_int = 1 << 3;
+pub const ALOOPER_EVENT_INVALID: libc::c_int = 1 << 4;
+
+pub type ALooper_callbackFunc = extern fn(libc::c_int, libc::c_int, *mut libc::c_void) -> libc::c_int;