From 0aecec095ff64c879d8753f9ade09ac47a7348d3 Mon Sep 17 00:00:00 2001 From: Stu Black Date: Mon, 30 Dec 2024 22:27:06 -0500 Subject: [PATCH] Okay, it builds! --- bazel/wrlib/BUILD.bazel | 1 + bazel/wrlib/wrlib.rs | 54 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/bazel/wrlib/BUILD.bazel b/bazel/wrlib/BUILD.bazel index 0897c4ae..ae593512 100644 --- a/bazel/wrlib/BUILD.bazel +++ b/bazel/wrlib/BUILD.bazel @@ -5,6 +5,7 @@ rust_library( srcs = ["wrlib.rs"], deps = [":wrlib"], visibility = ["//visibility:public"], + edition = "2021", ) cc_library( diff --git a/bazel/wrlib/wrlib.rs b/bazel/wrlib/wrlib.rs index fa2a7a12..fd82691f 100644 --- a/bazel/wrlib/wrlib.rs +++ b/bazel/wrlib/wrlib.rs @@ -1,6 +1,6 @@ -use std::os::raw::{c_char, c_int, c_uchar}; +use std::os::raw::{c_char, c_int, c_uchar, c_ulong}; -#[repr(u8)] +#[repr(C)] pub enum RImageFormat { RGBAFormat = 0, RRGBAFormat = 1, @@ -15,12 +15,60 @@ pub struct RImage { ref_count: c_int, } +#[repr(C)] +pub struct RContext { + // display: *mut Display, + display: usize, + screen_number: c_int, + // cmap: Colormap, + + // attribs: *mut RContextAttributes, + attribs: usize, + + // copy_gc: GC, + + // visual: *mut Visual, + visual: usize, + depth: c_int, + // drawable: Window, + vclass: c_int, + + black: c_ulong, + white: c_ulong, + + red_offset: c_int, + green_offset: c_int, + blue_offset: c_int, + + std_rgb_map: usize, + std_gray_map: usize, + // std_rgb_map: *mut XStandardColorMap, + // std_gray_map: *mut XStandardColorMap, + + ncolors: c_int, + colors: usize, + // colors: *mut XColor, + pixels: *mut c_ulong, + + flags: u8, +} + +#[repr(C)] +pub enum RScalingFilter { + RBoxFilter, + RTriangleFilter, + RBellFilter, + RBSplineFilter, + RLanczos3Filter, + RMitchellFilter, +} + extern "C" { pub fn r_destroy_conversion_tables() -> (); pub fn RLoadPPM(file: *const c_char) -> *mut RImage; - pub fn RLoadXPM(context: *mut RContext, file: *const c_char) -> mut *RImage; + pub fn RLoadXPM(context: *mut RContext, file: *const c_char) -> *mut RImage; pub fn RReleaseCache() -> ();