Skip to content

Commit 18becdb

Browse files
committed
try manual __imp_ dereference
1 parent 06abb15 commit 18becdb

File tree

4 files changed

+19
-41
lines changed

4 files changed

+19
-41
lines changed

glib/gobject-sys/build.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

5-
mod build_manual;
6-
75
#[cfg(not(docsrs))]
86
use std::process;
97

@@ -16,6 +14,4 @@ fn main() {
1614
println!("cargo:warning={s}");
1715
process::exit(1);
1816
}
19-
20-
build_manual::main();
2117
}

glib/gobject-sys/build_manual.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

glib/gobject-sys/src/manual.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
use glib_sys::GType;
22

3-
// `g_param_spec_types` extern binding generated by build.rs
4-
include!(concat!(env!("OUT_DIR"), "/param_spec.rs"));
3+
#[cfg(not(target_os = "windows"))]
4+
type GParamSpecType = *const GType;
5+
6+
#[cfg(target_os = "windows")]
7+
type GParamSpecType = *const *const GType;
8+
9+
extern "C" {
10+
#[cfg_attr(target_os = "windows", link_name = "__imp_g_param_spec_types")]
11+
static g_param_spec_types: GParamSpecType;
12+
}
513

614
/// # Safety
715
/// This should be safe as long as the offset added to g_param_spec_types is in bounds.
816
pub unsafe fn g_param_spec_types_get_type(offset: usize) -> GType {
9-
*g_param_spec_types.add(offset)
17+
#[cfg(not(target_os = "windows"))]
18+
let ptr = g_param_spec_types;
19+
20+
// One more step of indirection on windows because of the __imp_ prefix
21+
#[cfg(target_os = "windows")]
22+
let ptr = *g_param_spec_types;
23+
24+
*ptr.add(offset)
1025
}

glib/src/param_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ macro_rules! define_param_spec {
302302
#[inline]
303303
fn static_type() -> Type {
304304
unsafe {
305-
from_glib(gobject_ffi::g_param_spec_types_get_type($rust_type_offset))
305+
from_glib(gobject_sys::g_param_spec_types_get_type($rust_type_offset))
306306
}
307307
}
308308
}

0 commit comments

Comments
 (0)