Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move out of libc in profit of std::os::raw #42

Merged
merged 3 commits into from
Jan 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scanner/src/client_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn generate_client_api<O: Write>(protocol: Protocol, out: &mut O) {
writeln!(out, "use std::ptr;").unwrap();
writeln!(out, "use std::sync::Arc;").unwrap();
writeln!(out, "use std::sync::atomic::{{AtomicBool, Ordering}};").unwrap();
writeln!(out, "use libc::{{c_void, c_char}};").unwrap();
writeln!(out, "use std::ow::raw::{{c_void, c_char}};").unwrap();

// envent handling

Expand Down
4 changes: 2 additions & 2 deletions scanner/src/interface_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn generate_interfaces<O: Write>(protocol: Protocol, out: &mut O) {
}

writeln!(out, "use wayland_sys::common::*;\n").unwrap();
writeln!(out, "use libc::{{c_void, c_char}};\n").unwrap();
writeln!(out, "use std::os::raw::{{c_void, c_char}};\n").unwrap();

//
// null types array
Expand Down Expand Up @@ -132,4 +132,4 @@ pub fn generate_interfaces<O: Write>(protocol: Protocol, out: &mut O) {

writeln!(out, "").unwrap();
}
}
}
2 changes: 1 addition & 1 deletion wayland-client/src/egl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use libc::c_void;
use std::os::raw::c_void;
use std::ops::Deref;

use wayland_sys::egl::*;
Expand Down
4 changes: 2 additions & 2 deletions wayland-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ license = "MIT"

[dependencies]
dlib = "0.2"
libc = "0.2"
libc = { version = "0.2", optional = true }
lazy_static = { version = "0.1", optional = true }

[features]
dlopen = ["dlib/dlopen", "lazy_static"]
client = []
cursor = []
egl = []
server = []
server = ["libc"]
16 changes: 8 additions & 8 deletions wayland-sys/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! The generated handle is named `WAYLAND_CLIENT_HANDLE`

use {c_char, c_void, c_int, size_t, uint32_t};
use std::os::raw::{c_char, c_void, c_int};

use super::common::*;

Expand All @@ -26,7 +26,7 @@ external_library!(WaylandClient, "wayland-client",
fn wl_display_dispatch_pending(*mut wl_display) -> c_int,
// error handling
fn wl_display_get_error(*mut wl_display) -> c_int,
fn wl_display_get_protocol_error(*mut wl_display, *mut *mut wl_interface, *mut uint32_t) -> uint32_t,
fn wl_display_get_protocol_error(*mut wl_display, *mut *mut wl_interface, *mut u32) -> u32,
// requests handling
fn wl_display_flush(*mut wl_display) -> c_int,

Expand All @@ -44,12 +44,12 @@ external_library!(WaylandClient, "wayland-client",
fn wl_proxy_add_listener(*mut wl_proxy, *mut extern fn(), *mut c_void) -> c_int,
fn wl_proxy_get_listener(*mut wl_proxy) -> *const c_void,
fn wl_proxy_add_dispatcher(*mut wl_proxy, wl_dispatcher_func_t, *const c_void, *mut c_void) -> c_int,
fn wl_proxy_marshal_array_constructor(*mut wl_proxy, uint32_t, *mut wl_argument, *const wl_interface) -> c_int,
fn wl_proxy_marshal_array_constructor(*mut wl_proxy, u32, *mut wl_argument, *const wl_interface) -> c_int,

fn wl_proxy_marshal_array(*mut wl_proxy, uint32_t, *mut wl_argument ) -> (),
fn wl_proxy_marshal_array(*mut wl_proxy, u32, *mut wl_argument ) -> (),
fn wl_proxy_set_user_data(*mut wl_proxy, *mut c_void) -> (),
fn wl_proxy_get_user_data(*mut wl_proxy) -> *mut c_void,
fn wl_proxy_get_id(*mut wl_proxy) -> uint32_t,
fn wl_proxy_get_id(*mut wl_proxy) -> u32,
fn wl_proxy_get_class(*mut wl_proxy) -> *const c_char,
fn wl_proxy_set_queue(*mut wl_proxy, *mut wl_event_queue) -> (),

Expand All @@ -67,12 +67,12 @@ external_library!(WaylandClient, "wayland-client",
// arrays
fn wl_array_init(*mut wl_array) -> (),
fn wl_array_release(*mut wl_array) -> (),
fn wl_array_add(*mut wl_array,size_t) -> (),
fn wl_array_add(*mut wl_array,usize) -> (),
fn wl_array_copy(*mut wl_array, *mut wl_array) -> ()

varargs:
fn wl_proxy_marshal_constructor(*mut wl_proxy, uint32_t, *const wl_interface ...) -> *mut wl_proxy,
fn wl_proxy_marshal(*mut wl_proxy, uint32_t ...) -> ()
fn wl_proxy_marshal_constructor(*mut wl_proxy, u32, *const wl_interface ...) -> *mut wl_proxy,
fn wl_proxy_marshal(*mut wl_proxy, u32 ...) -> ()
);

#[cfg(feature = "dlopen")]
Expand Down
10 changes: 5 additions & 5 deletions wayland-sys/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Various types and functions that are used by both the client and the server
//! libraries.

use {c_char, c_void, c_int, size_t};
use std::os::raw::{c_char, c_void, c_int};

#[repr(C)]
pub struct wl_message {
Expand All @@ -28,8 +28,8 @@ pub struct wl_list {

#[repr(C)]
pub struct wl_array {
pub size: size_t,
pub alloc: size_t,
pub size: usize,
pub alloc: usize,
pub data: *mut c_void
}

Expand All @@ -54,7 +54,7 @@ pub fn wl_fixed_from_int(i: i32) -> wl_fixed_t {
// must be the appropriate size
// can contain i32, u32 and pointers
#[repr(C)]
pub struct wl_argument { _f: size_t }
pub struct wl_argument { _f: usize }

pub type wl_dispatcher_func_t = extern "C" fn(*const c_void, *mut c_void, u32, *const wl_message, *const wl_argument);
pub type wl_log_func_t = extern "C" fn(*const c_char, ...);
pub type wl_log_func_t = extern "C" fn(*const c_char, ...);
18 changes: 9 additions & 9 deletions wayland-sys/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
//!
//! The created handle is named `WAYLAND_CURSOR_HANDLE`.

use {uint32_t, c_uint, c_char, c_int};
use std::os::raw::{c_uint, c_char, c_int};
use client::wl_proxy;

pub enum wl_cursor_theme { }

#[repr(C)]
pub struct wl_cursor_image {
/// actual width
pub width: uint32_t,
pub width: u32,
/// actual height
pub height: uint32_t,
pub height: u32,
/// hot spot x (must be inside image)
pub hotspot_x: uint32_t,
pub hotspot_x: u32,
/// hot spot y (must be inside image)
pub hotspot_y: uint32_t,
pub hotspot_y: u32,
/// animation delay to next frame
pub delay: uint32_t
pub delay: u32
}

#[repr(C)]
Expand All @@ -34,8 +34,8 @@ external_library!(WaylandCursor, "wayland-cursor",
fn wl_cursor_theme_destroy(*mut wl_cursor_theme) -> (),
fn wl_cursor_theme_get_cursor(*mut wl_cursor_theme, *const c_char) -> *mut wl_cursor,
fn wl_cursor_image_get_buffer(*mut wl_cursor_image) -> *mut wl_proxy,
fn wl_cursor_frame(*mut wl_cursor, uint32_t) -> c_int,
fn wl_cursor_frame_and_duration(*mut wl_cursor, uint32_t, *mut uint32_t) -> c_int
fn wl_cursor_frame(*mut wl_cursor, u32) -> c_int,
fn wl_cursor_frame_and_duration(*mut wl_cursor, u32, *mut u32) -> c_int
);

#[cfg(feature = "dlopen")]
Expand All @@ -51,4 +51,4 @@ lazy_static!(
#[cfg(not(feature = "dlopen"))]
pub fn is_lib_available() -> bool { true }
#[cfg(feature = "dlopen")]
pub fn is_lib_available() -> bool { WAYLAND_CURSOR_OPTION.is_some() }
pub fn is_lib_available() -> bool { WAYLAND_CURSOR_OPTION.is_some() }
4 changes: 2 additions & 2 deletions wayland-sys/src/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! The created handle is named `WAYLAND_EGl_HANDLE`.

use c_int;
use std::os::raw::c_int;
use client::wl_proxy;

pub enum wl_egl_window { }
Expand All @@ -30,4 +30,4 @@ lazy_static!(
#[cfg(not(feature = "dlopen"))]
pub fn is_lib_available() -> bool { true }
#[cfg(feature = "dlopen")]
pub fn is_lib_available() -> bool { WAYLAND_EGL_OPTION.is_some() }
pub fn is_lib_available() -> bool { WAYLAND_EGL_OPTION.is_some() }
8 changes: 3 additions & 5 deletions wayland-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern crate dlib;
#[macro_use]
extern crate lazy_static;

#[cfg(feature = "server")]
extern crate libc;

pub mod common;
Expand All @@ -55,11 +56,8 @@ pub mod egl;
#[cfg(all(feature = "cursor", feature = "client"))]
pub mod cursor;

pub use libc::{c_char, c_void, c_int, size_t, uint32_t};
#[cfg(feature = "server")]
pub use libc::{pid_t, uid_t, gid_t, int32_t};
#[cfg(feature = "cursor")]
pub use libc::c_uint;
pub use libc::{pid_t, uid_t, gid_t};

// Small hack while #[macro_reexport] is not stable

Expand All @@ -77,4 +75,4 @@ macro_rules! ffi_dispatch(
($handle: ident, $func: ident, $($arg: expr),*) => (
$func($($arg),*)
)
);
);
45 changes: 23 additions & 22 deletions wayland-sys/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//!
//! The generated handle is named `WAYLAND_SERVER_HANDLE`

use {c_char, c_void, c_int, size_t, uint32_t, int32_t, uid_t, pid_t, gid_t};
use std::os::raw::{c_char, c_void, c_int};
use libc::{uid_t, pid_t, gid_t};

use super::common::*;

Expand All @@ -15,11 +16,11 @@ pub enum wl_listener { }
pub enum wl_resource { }
pub enum wl_shm_buffer { }

pub type wl_event_loop_fd_func_t = extern "C" fn(c_int, uint32_t, *mut c_void) -> c_int;
pub type wl_event_loop_fd_func_t = extern "C" fn(c_int, u32, *mut c_void) -> c_int;
pub type wl_event_loop_timer_func_t = extern "C" fn(*mut c_void) -> c_int;
pub type wl_event_loop_signal_func_t = extern "C" fn(c_int, *mut c_void) -> c_int;
pub type wl_event_loop_idle_func_t = extern "C" fn(*mut c_void) -> ();
pub type wl_global_bind_func_t = extern "C" fn(*mut wl_client, *mut c_void, uint32_t, uint32_t) -> ();
pub type wl_global_bind_func_t = extern "C" fn(*mut wl_client, *mut c_void, u32, u32) -> ();
pub type wl_notify_func_t = extern "C" fn(*mut wl_listener, *mut c_void) -> ();
pub type wl_resource_destroy_func_t = extern "C" fn(*mut wl_resource) -> ();

Expand All @@ -30,20 +31,20 @@ external_library!(WaylandServer, "wayland-server",
fn wl_client_destroy(*mut wl_client) -> (),
fn wl_client_get_display(*mut wl_client) -> *mut wl_display,
fn wl_client_get_credentials(*mut wl_client, *mut pid_t, *mut uid_t, *mut gid_t) -> (),
fn wl_client_get_object(*mut wl_client, uint32_t) -> *mut wl_resource,
fn wl_client_get_object(*mut wl_client, u32) -> *mut wl_resource,
fn wl_client_add_destroy_listener(*mut wl_client, *mut wl_listener) -> (),
fn wl_client_get_destroy_listener(*mut wl_client, wl_notify_func_t) -> *mut wl_listener,
fn wl_client_post_no_memory(*mut wl_client) -> (),
fn wl_resource_create(*mut wl_client, *const wl_interface, c_int, uint32_t) -> *mut wl_resource,
fn wl_resource_create(*mut wl_client, *const wl_interface, c_int, u32) -> *mut wl_resource,
// wl_display
fn wl_client_create(*mut wl_display, c_int) -> *mut wl_client,
fn wl_display_create() -> *mut wl_display,
fn wl_display_destroy(*mut wl_display) -> (),
fn wl_display_get_serial(*mut wl_display) -> uint32_t,
fn wl_display_next_serial(*mut wl_display) -> uint32_t,
fn wl_display_get_serial(*mut wl_display) -> u32,
fn wl_display_next_serial(*mut wl_display) -> u32,
fn wl_display_add_socket(*mut wl_display, *const c_char) -> c_int,
fn wl_display_add_socket_auto(*mut wl_display) -> *const c_char,
fn wl_display_add_shm_format(*mut wl_display, uint32_t) -> *mut uint32_t,
fn wl_display_add_shm_format(*mut wl_display, u32) -> *mut u32,
fn wl_display_get_additional_shm_formats(*mut wl_display) -> *mut wl_array,
fn wl_display_get_event_loop(*mut wl_display) -> *mut wl_event_loop,
fn wl_display_terminate(*mut wl_display) -> (),
Expand All @@ -56,8 +57,8 @@ external_library!(WaylandServer, "wayland-server",
// wl_event_loop
fn wl_event_loop_create() -> *mut wl_event_loop,
fn wl_event_loop_destroy(*mut wl_event_loop) -> (),
fn wl_event_loop_add_fd(*mut wl_event_loop, c_int, uint32_t, wl_event_loop_fd_func_t, *mut c_void) -> *mut wl_event_source,
fn wl_event_loop_fd_update(*mut wl_event_source, uint32_t) -> c_int,
fn wl_event_loop_add_fd(*mut wl_event_loop, c_int, u32, wl_event_loop_fd_func_t, *mut c_void) -> *mut wl_event_source,
fn wl_event_loop_fd_update(*mut wl_event_source, u32) -> c_int,
fn wl_event_lopp_add_timer(*mut wl_event_loop, wl_event_loop_timer_func_t, *mut c_void) -> *mut wl_event_source,
fn wl_event_loop_add_signal(*mut wl_event_loop, c_int, wl_event_loop_signal_func_t, *mut c_void) -> *mut wl_event_source,
fn wl_event_loop_dispatch(*mut wl_event_loop, c_int) -> c_int,
Expand All @@ -73,13 +74,13 @@ external_library!(WaylandServer, "wayland-server",
// wl_global
fn wl_global_destroy(*mut wl_global) -> (),
// wl_resource
fn wl_resource_post_event_array(*mut wl_resource, uint32_t, *mut wl_argument) -> (),
fn wl_resource_queue_event_array(*mut wl_resource, uint32_t, *mut wl_argument) -> (),
fn wl_resource_post_event_array(*mut wl_resource, u32, *mut wl_argument) -> (),
fn wl_resource_queue_event_array(*mut wl_resource, u32, *mut wl_argument) -> (),
fn wl_resource_post_no_memory(*mut wl_resource) -> (),
fn wl_resource_set_implementation(*mut wl_resource, *const c_void, *mut c_void, wl_resource_destroy_func_t) -> (),
fn wl_resource_set_dispatcher(*mut wl_resource, wl_dispatcher_func_t, *const c_void, *mut c_void, wl_resource_destroy_func_t) -> (),
fn wl_resource_destroy(*mut wl_resource) -> (),
fn wl_resource_get_id(*mut wl_resource) -> uint32_t,
fn wl_resource_get_id(*mut wl_resource) -> u32,
fn wl_resource_get_link(*mut wl_resource) -> *mut wl_list,
fn w_resource_from_link(*mut wl_list) -> *mut wl_resource,
fn wl_resource_find_for_client(*mut wl_list, *mut wl_client) -> (),
Expand All @@ -91,15 +92,15 @@ external_library!(WaylandServer, "wayland-server",
fn wl_resource_add_destroy_listener(*mut wl_resource, wl_notify_func_t) -> (),
fn wl_resource_get_destroy_listener(*mut wl_resource,wl_notify_func_t) -> *mut wl_listener,
// wl_shm
fn wl_shm_buffer_create(*mut wl_client, uint32_t, int32_t, int32_t, int32_t, uint32_t) -> (),
fn wl_shm_buffer_create(*mut wl_client, u32, i32, i32, i32, u32) -> (),
fn wl_shm_buffer_begin_access(*mut wl_shm_buffer) -> (),
fn wl_shm_buffer_end_access(*mut wl_shm_buffer) -> (),
fn wl_shm_buffer_get(*mut wl_resource) -> *mut wl_shm_buffer,
fn wl_shm_buffer_get_data(*mut wl_shm_buffer) -> *mut c_void,
fn wl_shm_buffer_get_stride(*mut wl_shm_buffer) -> int32_t,
fn wl_shm_buffer_get_format(*mut wl_shm_buffer) -> uint32_t,
fn wl_shm_buffer_get_width(*mut wl_shm_buffer) -> int32_t,
fn wl_shm_buffer_get_heigth(*mut wl_shm_buffer) -> int32_t,
fn wl_shm_buffer_get_stride(*mut wl_shm_buffer) -> i32,
fn wl_shm_buffer_get_format(*mut wl_shm_buffer) -> u32,
fn wl_shm_buffer_get_width(*mut wl_shm_buffer) -> i32,
fn wl_shm_buffer_get_heigth(*mut wl_shm_buffer) -> i32,
// wl_log
fn wl_log_set_handler_server(wl_log_func_t) -> (),
// wl_list
Expand All @@ -113,12 +114,12 @@ external_library!(WaylandServer, "wayland-server",
// arrays
fn wl_array_init(*mut wl_array) -> (),
fn wl_array_release(*mut wl_array) -> (),
fn wl_array_add(*mut wl_array,size_t) -> (),
fn wl_array_add(*mut wl_array,usize) -> (),
fn wl_array_copy(*mut wl_array, *mut wl_array) -> ()
varargs:
fn wl_resource_post_event(*mut wl_resource, uint32_t ...) -> (),
fn wl_resource_queue_event(*mut wl_resource, uint32_t ...) -> (),
fn wl_resource_post_error(*mut wl_resource, uint32_t, *const c_char ...) -> ()
fn wl_resource_post_event(*mut wl_resource, u32 ...) -> (),
fn wl_resource_queue_event(*mut wl_resource, u32 ...) -> (),
fn wl_resource_post_error(*mut wl_resource, u32, *const c_char ...) -> ()
);

#[cfg(feature = "dlopen")]
Expand Down