-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
use glib_sys::GType; | ||
|
||
// `g_param_spec_types` extern binding generated by build.rs | ||
include!(concat!(env!("OUT_DIR"), "/param_spec.rs")); | ||
#[cfg(not(target_os = "windows"))] | ||
pub type GParamSpecType = *const GType; | ||
|
||
/// # Safety | ||
/// This should be safe as long as the offset added to g_param_spec_types is in bounds. | ||
pub unsafe fn g_param_spec_types_get_type(offset: usize) -> GType { | ||
*g_param_spec_types.add(offset) | ||
#[cfg(target_os = "windows")] | ||
pub type GParamSpecType = usize; | ||
|
||
#[repr(C)] | ||
pub struct GParamSpecTypesWrapper(&'static GParamSpecType); | ||
|
||
unsafe impl Sync for GParamSpecTypesWrapper {} | ||
|
||
impl GParamSpecTypesWrapper { | ||
unsafe fn get_ptr(&self) -> *const GType { | ||
if cfg!(target_os = "windows") { | ||
*(*self.0 as *const *const GType) | ||
} else { | ||
*self.0 as *const GType | ||
} | ||
} | ||
|
||
/// # Safety | ||
/// This should be safe as long as the offset added to g_param_spec_types is in bounds. | ||
pub unsafe fn get_type(&self, offset: usize) -> GType { | ||
*(self.get_ptr()).add(offset) | ||
} | ||
} | ||
|
||
extern "C" { | ||
#[cfg_attr(target_os = "windows", link_name = "__imp_g_param_spec_types")] | ||
static g_param_spec_types: GParamSpecType; | ||
} | ||
|
||
pub static g_param_spec_types_ref: GParamSpecTypesWrapper = | ||
unsafe { GParamSpecTypesWrapper(&g_param_spec_types) }; | ||
|
||
//#[cfg(all(target_env = "msvc", not(feature = "static")))] | ||
//pub static __imp_g_param_spec_types: &'static GParamSpecTypes = unsafe { &g_param_spec_types }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters