Skip to content

Commit

Permalink
fix: graphics uses new definition of Rboolean.
Browse files Browse the repository at this point in the history
  • Loading branch information
CGMossa committed Jan 28, 2024
1 parent 2434595 commit 61eae64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions extendr-api/src/graphics/device_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ pub trait DeviceDriver: std::marker::Sized {

// It seems `NA` is just treated as `true`. Probably it doesn't matter much here.
// c.f. https://github.com/wch/r-source/blob/6b22b60126646714e0f25143ac679240be251dbe/src/library/grDevices/src/devPS.c#L4235
let winding = winding != 0;
let winding = winding != Rboolean::FALSE;

data.path(coords, winding, *gc, *dd);
}
Expand Down Expand Up @@ -519,7 +519,7 @@ pub trait DeviceDriver: std::marker::Sized {
rot,
// It seems `NA` is just treated as `true`. Probably it doesn't matter much here.
// c.f. https://github.com/wch/r-source/blob/6b22b60126646714e0f25143ac679240be251dbe/src/library/grDevices/src/devPS.c#L4062
interpolate != 0,
interpolate != Rboolean::FALSE,
*gc,
*dd,
);
Expand Down Expand Up @@ -753,12 +753,12 @@ pub trait DeviceDriver: std::marker::Sized {
(*p_dev_desc).gamma = 1.0;

(*p_dev_desc).canClip = match <T>::CLIPPING_STRATEGY {
ClippingStrategy::Engine => 0,
_ => 1,
ClippingStrategy::Engine => Rboolean::FALSE,
_ => Rboolean::TRUE,
};

// As described above, gamma is not supported.
(*p_dev_desc).canChangeGamma = 0;
(*p_dev_desc).canChangeGamma = Rboolean::FALSE;

(*p_dev_desc).canHAdj = CanHAdjOption::VariableAdjustment as _;

Expand All @@ -773,22 +773,22 @@ pub trait DeviceDriver: std::marker::Sized {
// A raw pointer to the data specific to the device.
(*p_dev_desc).deviceSpecific = deviceSpecific;

(*p_dev_desc).displayListOn = if <T>::USE_PLOT_HISTORY { 1 } else { 0 };
(*p_dev_desc).displayListOn = <T>::USE_PLOT_HISTORY.into();

// These are currently not used, so just set FALSE.
(*p_dev_desc).canGenMouseDown = 0;
(*p_dev_desc).canGenMouseMove = 0;
(*p_dev_desc).canGenMouseUp = 0;
(*p_dev_desc).canGenKeybd = 0;
(*p_dev_desc).canGenIdle = 0;
(*p_dev_desc).canGenMouseDown = Rboolean::FALSE;
(*p_dev_desc).canGenMouseMove = Rboolean::FALSE;
(*p_dev_desc).canGenMouseUp = Rboolean::FALSE;
(*p_dev_desc).canGenKeybd = Rboolean::FALSE;
(*p_dev_desc).canGenIdle = Rboolean::FALSE;

// The header file says:
//
// This is set while getGraphicsEvent is actively looking for events.
//
// It seems no implementation sets this, so this is probably what is
// modified on the engine's side.
(*p_dev_desc).gettingEvent = 0;
(*p_dev_desc).gettingEvent = Rboolean::FALSE;

(*p_dev_desc).activate = Some(device_driver_activate::<T>);
(*p_dev_desc).circle = Some(device_driver_circle::<T>);
Expand Down Expand Up @@ -829,7 +829,7 @@ pub trait DeviceDriver: std::marker::Sized {
(*p_dev_desc).newFrameConfirm = Some(device_driver_new_frame_confirm::<T>);

// UTF-8 support
(*p_dev_desc).hasTextUTF8 = if <T>::ACCEPT_UTF8_TEXT { 1 } else { 0 };
(*p_dev_desc).hasTextUTF8 = <T>::ACCEPT_UTF8_TEXT.into();
(*p_dev_desc).textUTF8 = if <T>::ACCEPT_UTF8_TEXT {
Some(device_driver_text::<T>)
} else {
Expand All @@ -840,7 +840,7 @@ pub trait DeviceDriver: std::marker::Sized {
} else {
None
};
(*p_dev_desc).wantSymbolUTF8 = if <T>::ACCEPT_UTF8_TEXT { 1 } else { 0 };
(*p_dev_desc).wantSymbolUTF8 = <T>::ACCEPT_UTF8_TEXT.into();

// R internals says:
//
Expand All @@ -850,7 +850,7 @@ pub trait DeviceDriver: std::marker::Sized {
//
// It seems this is used only by plot3d, so FALSE should be appropriate in
// most of the cases.
(*p_dev_desc).useRotatedTextInContour = 0;
(*p_dev_desc).useRotatedTextInContour = Rboolean::FALSE;

(*p_dev_desc).eventEnv = empty_env().get();
(*p_dev_desc).eventHelper = Some(device_driver_eventHelper::<T>);
Expand Down Expand Up @@ -900,8 +900,8 @@ pub trait DeviceDriver: std::marker::Sized {
(*p_dev_desc).deviceVersion = R_GE_definitions as _;

(*p_dev_desc).deviceClip = match <T>::CLIPPING_STRATEGY {
ClippingStrategy::Device => 1,
_ => 0,
ClippingStrategy::Device => Rboolean::TRUE,
_ => Rboolean::FALSE,
};
}

Expand Down
4 changes: 2 additions & 2 deletions extendr-api/src/graphics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl Device {
yptr,
nper.len() as std::os::raw::c_int,
nperptr,
if winding { 1 } else { 0 },
winding.into(),
gc.context(),
self.inner(),
)
Expand Down Expand Up @@ -724,7 +724,7 @@ impl Device {
let raster = pixels.as_ptr() as *mut u32;
let w = w as i32;
let h = h as i32;
let interpolate = if interpolate { 1 } else { 0 };
let interpolate = interpolate.into();
GERaster(
raster,
w,
Expand Down

0 comments on commit 61eae64

Please sign in to comment.