1 /* 2 * RInternal.hpp 3 * 4 * Copyright (C) 2021 by RStudio, PBC 5 * 6 * Unless you have received this program directly from RStudio pursuant 7 * to the terms of a commercial license agreement with RStudio, then 8 * this program is licensed to you under the terms of version 3 of the 9 * GNU Affero General Public License. This program is distributed WITHOUT 10 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, 11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the 12 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 13 * 14 */ 15 16 #ifndef R_R_INTERNAL_HPP 17 #define R_R_INTERNAL_HPP 18 19 // IMPORTANT NOTE: If R internal functions (functions prefixed with R_ or Rf_, 20 // as distinct from simple SEXP accessor functions) are called from within a 21 // c++ execution context they must either: 22 // 23 // (a) be inspected to make sure they won't ever call error (longjump); or 24 // 25 // (b) be called from within a safe block (see r::exec::executeSafely) 26 // 27 // This is critical to prevent error (longjump) from being called. If it is 28 // called then execution will pop back to the top of the R stack (repl loop) 29 // and c++ stack unwinding will not occur! 30 // 31 // To prevent inadvertent use of R_ and Rf_ internal functions by clients 32 // they are only included if the R_INTERNAL_FUNCTIONS macro is defined. 33 // 34 // Note also that public functions and classes exposed from within the r 35 // namespace have an implicit guarantee not to allow an error/longjump to 36 // escape from them (they adhere to guideline a or b above). Therefore, 37 // if client code from outside the r namespace feels the need to call R 38 // internal functions a sounder approach might be to add a suitable function 39 // to the r namespace which performs the intended operation safely. 40 // 41 42 #define R_NO_REMAP 43 #include <Rinternals.h> 44 45 // Hide macros that are always unsafe for us to use, because their 46 // interface has changed between versions of R 47 #undef BODY_EXPR 48 #define BODY_EXPR UNSAFE_R_FUNCTION 49 50 #undef PREXPR 51 #define PREXPR UNSAFE_R_FUNCTION 52 53 #ifndef R_INTERNAL_FUNCTIONS 54 55 // force compiler error if the client tries to call an R internal function 56 #define Rf_asChar INTERNAL_R_FUNCTION 57 #define Rf_coerceVector INTERNAL_R_FUNCTION 58 #define Rf_PairToVectorList INTERNAL_R_FUNCTION 59 #define Rf_VectorToPairList INTERNAL_R_FUNCTION 60 #define Rf_asLogical INTERNAL_R_FUNCTION 61 #define Rf_asInteger INTERNAL_R_FUNCTION 62 #define Rf_asReal INTERNAL_R_FUNCTION 63 #define Rf_asComplex INTERNAL_R_FUNCTION 64 #define Rf_acopy_string INTERNAL_R_FUNCTION 65 #define Rf_alloc3DArray INTERNAL_R_FUNCTION 66 #define Rf_allocArray INTERNAL_R_FUNCTION 67 #define Rf_allocMatrix INTERNAL_R_FUNCTION 68 #define Rf_allocList INTERNAL_R_FUNCTION 69 #define Rf_allocS4Object INTERNAL_R_FUNCTION 70 #define Rf_allocSExp INTERNAL_R_FUNCTION 71 #define Rf_applyClosure INTERNAL_R_FUNCTION 72 #define Rf_arraySubscript INTERNAL_R_FUNCTION 73 #define Rf_asComplex INTERNAL_R_FUNCTION 74 #define Rf_asInteger INTERNAL_R_FUNCTION 75 #define Rf_asLogical INTERNAL_R_FUNCTION 76 #define Rf_asReal INTERNAL_R_FUNCTION 77 #define Rf_classgets INTERNAL_R_FUNCTION 78 #define Rf_cons INTERNAL_R_FUNCTION 79 #define Rf_copyMatrix INTERNAL_R_FUNCTION 80 #define Rf_copyMostAttrib INTERNAL_R_FUNCTION 81 #define Rf_copyVector INTERNAL_R_FUNCTION 82 #define Rf_CreateTag INTERNAL_R_FUNCTION 83 #define Rf_defineVar INTERNAL_R_FUNCTION 84 #define Rf_dimgets INTERNAL_R_FUNCTION 85 #define Rf_dimnamesgets INTERNAL_R_FUNCTION 86 #define Rf_DropDims INTERNAL_R_FUNCTION 87 #define Rf_duplicate INTERNAL_R_FUNCTION 88 #define Rf_duplicated INTERNAL_R_FUNCTION 89 #define Rf_eval INTERNAL_R_FUNCTION 90 #define Rf_findFun INTERNAL_R_FUNCTION 91 #define Rf_findVar INTERNAL_R_FUNCTION 92 #define Rf_findVarInFrame INTERNAL_R_FUNCTION 93 #define Rf_findVarInFrame3 INTERNAL_R_FUNCTION 94 #define Rf_getAttrib INTERNAL_R_FUNCTION 95 #define Rf_GetArrayDimnames INTERNAL_R_FUNCTION 96 #define Rf_GetColNames INTERNAL_R_FUNCTION 97 #define Rf_GetMatrixDimnames INTERNAL_R_FUNCTION 98 #define Rf_GetOption INTERNAL_R_FUNCTION 99 #define Rf_GetOptionDigits INTERNAL_R_FUNCTION 100 #define Rf_GetOptionWidth INTERNAL_R_FUNCTION 101 #define Rf_GetRowNames INTERNAL_R_FUNCTION 102 #define Rf_gsetVar INTERNAL_R_FUNCTION 103 #define Rf_install INTERNAL_R_FUNCTION 104 #define Rf_isFree INTERNAL_R_FUNCTION 105 #define Rf_isOrdered INTERNAL_R_FUNCTION 106 #define Rf_isUnordered INTERNAL_R_FUNCTION 107 #define Rf_isUnsorted INTERNAL_R_FUNCTION 108 #define Rf_lengthgets INTERNAL_R_FUNCTION 109 #define R_lsInternal INTERNAL_R_FUNCTION 110 #define Rf_match INTERNAL_R_FUNCTION 111 #define Rf_namesgets INTERNAL_R_FUNCTION 112 #define Rf_mkCharLen INTERNAL_R_FUNCTION 113 #define Rf_NonNullStringMatch INTERNAL_R_FUNCTION 114 #define Rf_ncols INTERNAL_R_FUNCTION 115 #define Rf_nrows INTERNAL_R_FUNCTION 116 #define Rf_nthcdr INTERNAL_R_FUNCTION 117 #define Rf_pmatch INTERNAL_R_FUNCTION 118 #define Rf_psmatch INTERNAL_R_FUNCTION 119 #define Rf_PrintValue INTERNAL_R_FUNCTION 120 #define Rf_protect INTERNAL_R_FUNCTION 121 #define Rf_setSVector INTERNAL_R_FUNCTION 122 #define Rf_setVar INTERNAL_R_FUNCTION 123 #define Rf_str2type INTERNAL_R_FUNCTION 124 #define Rf_StringBlank INTERNAL_R_FUNCTION 125 #define Rf_substitute INTERNAL_R_FUNCTION 126 #define Rf_translateChar INTERNAL_R_FUNCTION 127 #define Rf_translateCharUTF8 INTERNAL_R_FUNCTION 128 #define Rf_type2char INTERNAL_R_FUNCTION 129 #define Rf_type2str INTERNAL_R_FUNCTION 130 #define Rf_unprotect INTERNAL_R_FUNCTION 131 #define Rf_unprotect_ptr INTERNAL_R_FUNCTION 132 #define R_ProtectWithIndex INTERNAL_R_FUNCTION 133 #define R_Reprotect INTERNAL_R_FUNCTION 134 #define R_tryEval INTERNAL_R_FUNCTION 135 #define Rf_asS4 INTERNAL_R_FUNCTION 136 #define Rf_getCharCE INTERNAL_R_FUNCTION 137 #define Rf_mkCharCE INTERNAL_R_FUNCTION 138 #define Rf_mkCharLenCE INTERNAL_R_FUNCTION 139 #define Rf_reEnc INTERNAL_R_FUNCTION 140 #define R_MakeExternalPtr INTERNAL_R_FUNCTION 141 #define R_ExternalPtrAddr INTERNAL_R_FUNCTION 142 #define R_ExternalPtrTag INTERNAL_R_FUNCTION 143 #define R_ExternalPtrProtected INTERNAL_R_FUNCTION 144 #define R_ClearExternalPtr INTERNAL_R_FUNCTION 145 #define R_SetExternalPtrAddr INTERNAL_R_FUNCTION 146 #define R_SetExternalPtrTag INTERNAL_R_FUNCTION 147 #define R_SetExternalPtrProtected INTERNAL_R_FUNCTION 148 #define R_RegisterFinalizer INTERNAL_R_FUNCTION 149 #define R_RegisterCFinalizer INTERNAL_R_FUNCTION 150 #define R_RegisterFinalizerEx INTERNAL_R_FUNCTION 151 #define R_RegisterCFinalizerEx INTERNAL_R_FUNCTION 152 #define R_MakeWeakRef INTERNAL_R_FUNCTION 153 #define R_MakeWeakRefC INTERNAL_R_FUNCTION 154 #define R_WeakRefKey INTERNAL_R_FUNCTION 155 #define R_WeakRefValue INTERNAL_R_FUNCTION 156 #define R_RunWeakRefFinalizer INTERNAL_R_FUNCTION 157 #define R_PromiseExpr INTERNAL_R_FUNCTION 158 #define R_ClosureExpr INTERNAL_R_FUNCTION 159 #define R_initialize_bcode INTERNAL_R_FUNCTION 160 #define R_bcEncode INTERNAL_R_FUNCTION 161 #define R_bcDecode INTERNAL_R_FUNCTION 162 #define R_ToplevelExec INTERNAL_R_FUNCTION 163 #define R_RestoreHashCount INTERNAL_R_FUNCTION 164 #define R_IsPackageEnv INTERNAL_R_FUNCTION 165 #define R_PackageEnvName INTERNAL_R_FUNCTION 166 #define R_FindPackageEnv INTERNAL_R_FUNCTION 167 #define R_IsNamespaceEnv INTERNAL_R_FUNCTION 168 #define R_NamespaceEnvSpec INTERNAL_R_FUNCTION 169 #define R_FindNamespace INTERNAL_R_FUNCTION 170 #define R_LockEnvironment INTERNAL_R_FUNCTION 171 #define R_EnvironmentIsLocked INTERNAL_R_FUNCTION 172 #define R_LockBinding INTERNAL_R_FUNCTION 173 #define R_unLockBinding INTERNAL_R_FUNCTION 174 #define R_MakeActiveBinding INTERNAL_R_FUNCTION 175 #define R_BindingIsLocked INTERNAL_R_FUNCTION 176 #define R_BindingIsActive INTERNAL_R_FUNCTION 177 #define R_HasFancyBindings INTERNAL_R_FUNCTION 178 #define Rf_errorcall INTERNAL_R_FUNCTION 179 #define Rf_warningcall INTERNAL_R_FUNCTION 180 #define Rf_warningcall_immediate INTERNAL_R_FUNCTION 181 #define R_XDREncodeDouble INTERNAL_R_FUNCTION 182 #define R_XDRDecodeDouble INTERNAL_R_FUNCTION 183 #define R_XDREncodeInteger INTERNAL_R_FUNCTION 184 #define R_XDRDecodeInteger INTERNAL_R_FUNCTION 185 #define R_InitInPStream INTERNAL_R_FUNCTION 186 #define R_InitOutPStream INTERNAL_R_FUNCTION 187 #define R_InitFileInPStream INTERNAL_R_FUNCTION 188 #define R_InitFileOutPStream INTERNAL_R_FUNCTION 189 #define R_InitConnOutPStream INTERNAL_R_FUNCTION 190 #define R_InitConnInPStream INTERNAL_R_FUNCTION 191 #define R_Serialize INTERNAL_R_FUNCTION 192 #define R_Unserialize INTERNAL_R_FUNCTION 193 #define R_do_slot INTERNAL_R_FUNCTION 194 #define R_do_slot_assign INTERNAL_R_FUNCTION 195 #define R_has_slot INTERNAL_R_FUNCTION 196 #define R_do_MAKE_CLASS INTERNAL_R_FUNCTION 197 #define R_getClassDef INTERNAL_R_FUNCTION 198 #define R_do_new_object INTERNAL_R_FUNCTION 199 #define R_PreserveObject INTERNAL_R_FUNCTION 200 #define R_ReleaseObject INTERNAL_R_FUNCTION 201 #define R_dot_Last INTERNAL_R_FUNCTION 202 #define R_RunExitFinalizers INTERNAL_R_FUNCTION 203 #define R_popen INTERNAL_R_FUNCTION 204 #define R_system INTERNAL_R_FUNCTION 205 #define Rf_conformable INTERNAL_R_FUNCTION 206 #define Rf_elt INTERNAL_R_FUNCTION 207 #define Rf_inherits INTERNAL_R_FUNCTION 208 #define Rf_isArray INTERNAL_R_FUNCTION 209 #define Rf_isFactor INTERNAL_R_FUNCTION 210 #define Rf_isFrame INTERNAL_R_FUNCTION 211 #define Rf_isFunction INTERNAL_R_FUNCTION 212 #define Rf_isInteger INTERNAL_R_FUNCTION 213 #define Rf_isLanguage INTERNAL_R_FUNCTION 214 #define Rf_isList INTERNAL_R_FUNCTION 215 #define Rf_isMatrix INTERNAL_R_FUNCTION 216 #define Rf_isNewList INTERNAL_R_FUNCTION 217 #define Rf_isNumeric INTERNAL_R_FUNCTION 218 #define Rf_isPairList INTERNAL_R_FUNCTION 219 #define Rf_isPrimitive INTERNAL_R_FUNCTION 220 #define Rf_isTs INTERNAL_R_FUNCTION 221 #define Rf_isUserBinop INTERNAL_R_FUNCTION 222 #define Rf_isValidString INTERNAL_R_FUNCTION 223 #define Rf_isValidStringF INTERNAL_R_FUNCTION 224 #define Rf_isVector INTERNAL_R_FUNCTION 225 #define Rf_isVectorAtomic INTERNAL_R_FUNCTION 226 #define Rf_isVectorList INTERNAL_R_FUNCTION 227 #define Rf_isVectorizable INTERNAL_R_FUNCTION 228 #define Rf_lang1 INTERNAL_R_FUNCTION 229 #define Rf_lang2 INTERNAL_R_FUNCTION 230 #define Rf_lang3 INTERNAL_R_FUNCTION 231 #define Rf_lang4 INTERNAL_R_FUNCTION 232 #define Rf_lastElt INTERNAL_R_FUNCTION 233 #define Rf_lcons INTERNAL_R_FUNCTION 234 #define Rf_length INTERNAL_R_FUNCTION 235 #define Rf_list1 INTERNAL_R_FUNCTION 236 #define Rf_list2 INTERNAL_R_FUNCTION 237 #define Rf_list3 INTERNAL_R_FUNCTION 238 #define Rf_list4 INTERNAL_R_FUNCTION 239 #define Rf_listAppend INTERNAL_R_FUNCTION 240 #define Rf_mkString INTERNAL_R_FUNCTION 241 #define Rf_nlevels INTERNAL_R_FUNCTION 242 #define Rf_ScalarComplex INTERNAL_R_FUNCTION 243 #define Rf_ScalarInteger INTERNAL_R_FUNCTION 244 #define Rf_ScalarLogical INTERNAL_R_FUNCTION 245 #define Rf_ScalarRaw INTERNAL_R_FUNCTION 246 #define Rf_ScalarReal INTERNAL_R_FUNCTION 247 #define Rf_ScalarString INTERNAL_R_FUNCTION 248 249 #endif // R_INTERNAL_FUNCTIONS 250 251 #endif // R_R_INTERNAL_HPP 252 253