extern "C" SEXP xaml_graphicsdevice_new(SEXP args) { args = CDR(args); SEXP file = CAR(args); args = CDR(args); SEXP width = CAR(args); args = CDR(args); SEXP height = CAR(args); const char *f = R_CHAR(STRING_ELT(file, 0)); double *w = REAL(width); double *h = REAL(height); int ver = R_GE_getVersion(); if (ver < R_32_GE_version || ver > R_33_GE_version) { Rf_error("Graphics API version %d is not supported.", ver); } R_CheckDeviceAvailable(); BEGIN_SUSPEND_INTERRUPTS{ auto dev = xaml_device::create(f, *w, *h); pGEDevDesc gdd = GEcreateDevDesc(dev->device_desc); GEaddDevice2f(gdd, "xaml", f); // Owner is DevDesc::deviceSpecific, and is released in close() dev.release(); } END_SUSPEND_INTERRUPTS; return R_NilValue; }
bool validateRequirements(std::string* pMessage) { // get engineVersion int engineVersion = R_GE_getVersion(); // version too old if (engineVersion < 5) { if (pMessage != NULL) { boost::format fmt( "R graphics engine version %1% is not supported by RStudio. " "The Plots tab will be disabled until a newer version of " "R is installed."); *pMessage = boost::str(fmt % engineVersion); } return false; } // version too new else if (engineVersion > s_compatibleEngineVersion) { if (pMessage != NULL) { boost::format fmt( "R graphics engine version %1% is not supported by this " "version of RStudio. The Plots tab will be disabled until " "a newer version of RStudio is installed."); *pMessage = boost::str(fmt % engineVersion); } return false; } // check for required devices else { return hasRequiredGraphicsDevices(pMessage); } }