Skip to content

Commit 98e1aa1

Browse files
authored
Support graphics engine version 17 (#839)
1 parent 3d42829 commit 98e1aa1

File tree

2 files changed

+255
-1
lines changed

2 files changed

+255
-1
lines changed

crates/ark/src/plots/graphics_device.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,10 @@ macro_rules! with_device {
723723
let $ge_name = $ge_value as *mut libr::GEDevDescVersion16;
724724
let $name = (*$ge_name).dev;
725725
$block;
726+
} else if version == 17 {
727+
let $ge_name = $ge_value as *mut libr::GEDevDescVersion17;
728+
let $name = (*$ge_name).dev;
729+
$block;
726730
} else {
727731
panic!(
728732
"R graphics engine version {} is not supported by this version of Positron.",

crates/libr/src/graphics.rs

Lines changed: 251 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// graphics.rs
33
//
4-
// Copyright (C) 2024 by Posit Software, PBC
4+
// Copyright (C) 2025 by Posit Software, PBC
55
//
66
//
77

@@ -129,6 +129,21 @@ pub struct GEDevDescVersion16 {
129129
pub appending: Rboolean,
130130
}
131131

132+
// Graphics Engine Wrapper version 17 (R 4.6.0)
133+
#[repr(C)]
134+
pub struct GEDevDescVersion17 {
135+
pub dev: pDevDescVersion17,
136+
pub displayListOn: Rboolean,
137+
pub displayList: SEXP,
138+
pub DLlastElt: SEXP,
139+
pub savedSnapshot: SEXP,
140+
pub dirty: Rboolean,
141+
pub recordGraphics: Rboolean,
142+
pub gesd: [*mut GESystemDesc; 24usize],
143+
pub ask: Rboolean,
144+
pub appending: Rboolean,
145+
}
146+
132147
// ---------------------------------------------------------------------------------------
133148

134149
// Per-version variants of `DevDesc`.
@@ -969,3 +984,238 @@ pub struct DevDescVersion16 {
969984
pub reserved: [std::ffi::c_char; 64usize],
970985
}
971986
pub type pDevDescVersion16 = *mut DevDescVersion16;
987+
988+
// Graphics Engine version 17 (R 4.6.0)
989+
#[repr(C)]
990+
pub struct DevDescVersion17 {
991+
pub left: f64,
992+
pub right: f64,
993+
pub bottom: f64,
994+
pub top: f64,
995+
pub clipLeft: f64,
996+
pub clipRight: f64,
997+
pub clipBottom: f64,
998+
pub clipTop: f64,
999+
pub xCharOffset: f64,
1000+
pub yCharOffset: f64,
1001+
pub yLineBias: f64,
1002+
pub ipr: [f64; 2usize],
1003+
pub cra: [f64; 2usize],
1004+
pub gamma: f64,
1005+
pub canClip: Rboolean,
1006+
pub canChangeGamma: Rboolean,
1007+
pub canHAdj: std::ffi::c_int,
1008+
pub startps: f64,
1009+
pub startcol: std::ffi::c_int,
1010+
pub startfill: std::ffi::c_int,
1011+
pub startlty: std::ffi::c_int,
1012+
pub startfont: std::ffi::c_int,
1013+
pub startgamma: f64,
1014+
pub deviceSpecific: *mut std::ffi::c_void,
1015+
pub displayListOn: Rboolean,
1016+
pub canGenMouseDown: Rboolean,
1017+
pub canGenMouseMove: Rboolean,
1018+
pub canGenMouseUp: Rboolean,
1019+
pub canGenKeybd: Rboolean,
1020+
pub canGenIdle: Rboolean,
1021+
pub gettingEvent: Rboolean,
1022+
pub activate: Option<unsafe extern "C-unwind" fn(arg1: pDevDesc)>,
1023+
pub circle:
1024+
Option<unsafe extern "C-unwind" fn(x: f64, y: f64, r: f64, gc: pGEcontext, dd: pDevDesc)>,
1025+
pub clip: Option<unsafe extern "C-unwind" fn(x0: f64, x1: f64, y0: f64, y1: f64, dd: pDevDesc)>,
1026+
pub close: Option<unsafe extern "C-unwind" fn(dd: pDevDesc)>,
1027+
pub deactivate: Option<unsafe extern "C-unwind" fn(arg1: pDevDesc)>,
1028+
pub locator:
1029+
Option<unsafe extern "C-unwind" fn(x: *mut f64, y: *mut f64, dd: pDevDesc) -> Rboolean>,
1030+
pub line: Option<
1031+
unsafe extern "C-unwind" fn(
1032+
x1: f64,
1033+
y1: f64,
1034+
x2: f64,
1035+
y2: f64,
1036+
gc: pGEcontext,
1037+
dd: pDevDesc,
1038+
),
1039+
>,
1040+
pub metricInfo: Option<
1041+
unsafe extern "C-unwind" fn(
1042+
c: std::ffi::c_int,
1043+
gc: pGEcontext,
1044+
ascent: *mut f64,
1045+
descent: *mut f64,
1046+
width: *mut f64,
1047+
dd: pDevDesc,
1048+
),
1049+
>,
1050+
pub mode: Option<unsafe extern "C-unwind" fn(mode: std::ffi::c_int, dd: pDevDesc)>,
1051+
pub newPage: Option<unsafe extern "C-unwind" fn(gc: pGEcontext, dd: pDevDesc)>,
1052+
pub polygon: Option<
1053+
unsafe extern "C-unwind" fn(
1054+
n: std::ffi::c_int,
1055+
x: *mut f64,
1056+
y: *mut f64,
1057+
gc: pGEcontext,
1058+
dd: pDevDesc,
1059+
),
1060+
>,
1061+
pub polyline: Option<
1062+
unsafe extern "C-unwind" fn(
1063+
n: std::ffi::c_int,
1064+
x: *mut f64,
1065+
y: *mut f64,
1066+
gc: pGEcontext,
1067+
dd: pDevDesc,
1068+
),
1069+
>,
1070+
pub rect: Option<
1071+
unsafe extern "C-unwind" fn(
1072+
x0: f64,
1073+
y0: f64,
1074+
x1: f64,
1075+
y1: f64,
1076+
gc: pGEcontext,
1077+
dd: pDevDesc,
1078+
),
1079+
>,
1080+
pub path: Option<
1081+
unsafe extern "C-unwind" fn(
1082+
x: *mut f64,
1083+
y: *mut f64,
1084+
npoly: std::ffi::c_int,
1085+
nper: *mut std::ffi::c_int,
1086+
winding: Rboolean,
1087+
gc: pGEcontext,
1088+
dd: pDevDesc,
1089+
),
1090+
>,
1091+
pub raster: Option<
1092+
unsafe extern "C-unwind" fn(
1093+
raster: *mut std::ffi::c_uint,
1094+
w: std::ffi::c_int,
1095+
h: std::ffi::c_int,
1096+
x: f64,
1097+
y: f64,
1098+
width: f64,
1099+
height: f64,
1100+
rot: f64,
1101+
interpolate: Rboolean,
1102+
gc: pGEcontext,
1103+
dd: pDevDesc,
1104+
),
1105+
>,
1106+
pub cap: Option<unsafe extern "C-unwind" fn(dd: pDevDesc) -> SEXP>,
1107+
pub size: Option<
1108+
unsafe extern "C-unwind" fn(
1109+
left: *mut f64,
1110+
right: *mut f64,
1111+
bottom: *mut f64,
1112+
top: *mut f64,
1113+
dd: pDevDesc,
1114+
),
1115+
>,
1116+
pub strWidth: Option<
1117+
unsafe extern "C-unwind" fn(
1118+
str: *const std::ffi::c_char,
1119+
gc: pGEcontext,
1120+
dd: pDevDesc,
1121+
) -> f64,
1122+
>,
1123+
pub text: Option<
1124+
unsafe extern "C-unwind" fn(
1125+
x: f64,
1126+
y: f64,
1127+
str: *const std::ffi::c_char,
1128+
rot: f64,
1129+
hadj: f64,
1130+
gc: pGEcontext,
1131+
dd: pDevDesc,
1132+
),
1133+
>,
1134+
pub onExit: Option<unsafe extern "C-unwind" fn(dd: pDevDesc)>,
1135+
pub getEvent:
1136+
Option<unsafe extern "C-unwind" fn(arg1: SEXP, arg2: *const std::ffi::c_char) -> SEXP>,
1137+
pub newFrameConfirm: Option<unsafe extern "C-unwind" fn(dd: pDevDesc) -> Rboolean>,
1138+
pub hasTextUTF8: Rboolean,
1139+
pub textUTF8: Option<
1140+
unsafe extern "C-unwind" fn(
1141+
x: f64,
1142+
y: f64,
1143+
str: *const std::ffi::c_char,
1144+
rot: f64,
1145+
hadj: f64,
1146+
gc: pGEcontext,
1147+
dd: pDevDesc,
1148+
),
1149+
>,
1150+
pub strWidthUTF8: Option<
1151+
unsafe extern "C-unwind" fn(
1152+
str: *const std::ffi::c_char,
1153+
gc: pGEcontext,
1154+
dd: pDevDesc,
1155+
) -> f64,
1156+
>,
1157+
pub wantSymbolUTF8: Rboolean,
1158+
pub useRotatedTextInContour: Rboolean,
1159+
pub eventEnv: SEXP,
1160+
pub eventHelper: Option<unsafe extern "C-unwind" fn(dd: pDevDesc, code: std::ffi::c_int)>,
1161+
pub holdflush: Option<
1162+
unsafe extern "C-unwind" fn(dd: pDevDesc, level: std::ffi::c_int) -> std::ffi::c_int,
1163+
>,
1164+
pub haveTransparency: std::ffi::c_int,
1165+
pub haveTransparentBg: std::ffi::c_int,
1166+
pub haveRaster: std::ffi::c_int,
1167+
pub haveCapture: std::ffi::c_int,
1168+
pub haveLocator: std::ffi::c_int,
1169+
pub setPattern: Option<unsafe extern "C-unwind" fn(pattern: SEXP, dd: pDevDesc) -> SEXP>,
1170+
pub releasePattern: Option<unsafe extern "C-unwind" fn(ref_: SEXP, dd: pDevDesc)>,
1171+
pub setClipPath:
1172+
Option<unsafe extern "C-unwind" fn(path: SEXP, ref_: SEXP, dd: pDevDesc) -> SEXP>,
1173+
pub releaseClipPath: Option<unsafe extern "C-unwind" fn(ref_: SEXP, dd: pDevDesc)>,
1174+
pub setMask: Option<unsafe extern "C-unwind" fn(path: SEXP, ref_: SEXP, dd: pDevDesc) -> SEXP>,
1175+
pub releaseMask: Option<unsafe extern "C-unwind" fn(ref_: SEXP, dd: pDevDesc)>,
1176+
pub deviceVersion: std::ffi::c_int,
1177+
pub deviceClip: Rboolean,
1178+
pub defineGroup: Option<
1179+
unsafe extern "C-unwind" fn(
1180+
source: SEXP,
1181+
op: std::ffi::c_int,
1182+
destination: SEXP,
1183+
dd: pDevDesc,
1184+
) -> SEXP,
1185+
>,
1186+
pub useGroup: Option<unsafe extern "C-unwind" fn(ref_: SEXP, trans: SEXP, dd: pDevDesc)>,
1187+
pub releaseGroup: Option<unsafe extern "C-unwind" fn(ref_: SEXP, dd: pDevDesc)>,
1188+
pub stroke: Option<unsafe extern "C-unwind" fn(path: SEXP, gc: pGEcontext, dd: pDevDesc)>,
1189+
pub fill: Option<
1190+
unsafe extern "C-unwind" fn(
1191+
path: SEXP,
1192+
rule: std::ffi::c_int,
1193+
gc: pGEcontext,
1194+
dd: pDevDesc,
1195+
),
1196+
>,
1197+
pub fillStroke: Option<
1198+
unsafe extern "C-unwind" fn(
1199+
path: SEXP,
1200+
rule: std::ffi::c_int,
1201+
gc: pGEcontext,
1202+
dd: pDevDesc,
1203+
),
1204+
>,
1205+
pub capabilities: Option<unsafe extern "C-unwind" fn(cap: SEXP) -> SEXP>,
1206+
pub glyph: Option<
1207+
unsafe extern "C-unwind" fn(
1208+
n: std::ffi::c_int,
1209+
glyphs: *mut std::ffi::c_int,
1210+
x: *mut f64,
1211+
y: *mut f64,
1212+
font: SEXP,
1213+
size: f64,
1214+
colour: std::ffi::c_int,
1215+
rot: f64,
1216+
dd: pDevDesc,
1217+
),
1218+
>,
1219+
pub reserved: [std::ffi::c_char; 64usize],
1220+
}
1221+
pub type pDevDescVersion17 = *mut DevDescVersion17;

0 commit comments

Comments
 (0)