RAPI
|
00001 /* 00002 * R : A Computer Language for Statistical Data Analysis 00003 * Copyright (C) 2001-2016 The R Core Team. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 2.1 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program; if not, a copy is available at 00017 * https://www.R-project.org/Licenses/ 00018 */ 00019 00020 /* 00021 Not part of the API, subject to change at any time. 00022 */ 00023 00024 #ifndef R_CALLBACKS_H 00025 #define R_CALLBACKS_H 00026 00033 #include <Rinternals.h> 00042 typedef Rboolean (*R_ToplevelCallback)(SEXP expr, SEXP value, Rboolean succeeded, Rboolean visible, void *); 00043 00044 typedef struct _ToplevelCallback R_ToplevelCallbackEl; 00048 struct _ToplevelCallback { 00049 R_ToplevelCallback cb; /* the C routine to call. */ 00050 void *data; /* the user-level data to pass to the call to cb() */ 00051 void (*finalizer)(void *data); /* Called when the callback is removed. */ 00052 00053 char *name; /* a name by which to identify this element. */ 00054 00055 R_ToplevelCallbackEl *next; /* the next element in the linked list. */ 00056 }; 00057 00058 #ifdef __cplusplus 00059 extern "C" { 00060 #endif 00061 00062 Rboolean Rf_removeTaskCallbackByIndex(int id); 00063 Rboolean Rf_removeTaskCallbackByName(const char *name); 00064 SEXP R_removeTaskCallback(SEXP which); 00065 R_ToplevelCallbackEl* Rf_addTaskCallback(R_ToplevelCallback cb, void *data, void (*finalizer)(void *), const char *name, int *pos); 00066 00067 00068 00069 /* 00070 The following definitions are for callbacks to R functions and 00071 methods related to user-level tables. This was implemented in a 00072 separate package on Omegahat and these declarations allow the package 00073 to interface to the internal R code. 00074 00075 See https://developer.r-project.org/RObjectTables.pdf, 00076 http://www.omegahat.net/RObjectTables/ 00077 */ 00078 00079 typedef struct _R_ObjectTable R_ObjectTable; 00080 00081 /* Do we actually need the exists() since it is never called but R 00082 uses get to see if the symbol is bound to anything? */ 00083 typedef Rboolean (*Rdb_exists)(const char * const name, Rboolean *canCache, R_ObjectTable *); 00084 typedef SEXP (*Rdb_get)(const char * const name, Rboolean *canCache, R_ObjectTable *); 00085 typedef int (*Rdb_remove)(const char * const name, R_ObjectTable *); 00086 typedef SEXP (*Rdb_assign)(const char * const name, SEXP value, R_ObjectTable *); 00087 typedef SEXP (*Rdb_objects)(R_ObjectTable *); 00088 typedef Rboolean (*Rdb_canCache)(const char * const name, R_ObjectTable *); 00089 00090 typedef void (*Rdb_onDetach)(R_ObjectTable *); 00091 typedef void (*Rdb_onAttach)(R_ObjectTable *); 00092 00093 struct _R_ObjectTable{ 00094 int type; 00095 char **cachedNames; 00096 Rboolean active; 00097 00098 Rdb_exists exists; 00099 Rdb_get get; 00100 Rdb_remove remove; 00101 Rdb_assign assign; 00102 Rdb_objects objects; 00103 Rdb_canCache canCache; 00104 00105 Rdb_onDetach onDetach; 00106 Rdb_onAttach onAttach; 00107 00108 void *privateData; 00109 }; 00110 00111 00112 #ifdef __cplusplus 00113 } 00114 #endif 00115 00116 #endif /* R_CALLBACKS_H */