RAPI
|
00001 /* 00002 * R : A Computer Language for Statistical Data Analysis 00003 * Copyright (C) 2001-12 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 C functions used to register compiled code in packages. 00022 00023 Those needed for that purpose are part of the API. 00024 */ 00025 00026 #ifndef R_EXT_DYNLOAD_H_ 00027 #define R_EXT_DYNLOAD_H_ 00028 00029 #include <R_ext/Boolean.h> 00030 00031 /* called with a variable argument set */ 00032 typedef void * (*DL_FUNC)(); 00033 00034 typedef unsigned int R_NativePrimitiveArgType; 00035 00036 #define SINGLESXP 302 /* Don't have a single type for this. */ 00037 00038 /* In the future, we will want to allow people register their own types 00039 and then refer to these in other contexts. Something like the Gtk type 00040 system may be appropriate. 00041 */ 00042 typedef unsigned int R_NativeObjectArgType; 00043 00044 00045 /* In the near future, we may support registering 00046 information about the arguments of native routines 00047 and whether they are used to return information. 00048 The hope is that we can minimize copying objects even 00049 further. Not currently in use. 00050 */ 00051 typedef enum {R_ARG_IN, R_ARG_OUT, R_ARG_IN_OUT, R_IRRELEVANT} R_NativeArgStyle; 00052 00053 00054 00055 /* 00056 These are very similar to those in unix/dynload.c 00057 but we maintain them separately to give us more freedom to do 00058 some computations on the internal versions that are derived from 00059 these definitions. 00060 */ 00061 typedef struct { 00062 const char *name; 00063 DL_FUNC fun; 00064 int numArgs; 00065 00066 R_NativePrimitiveArgType *types; 00067 R_NativeArgStyle *styles; 00068 00069 } R_CMethodDef; 00070 00071 typedef R_CMethodDef R_FortranMethodDef; 00072 00073 00074 00075 typedef struct { 00076 const char *name; 00077 DL_FUNC fun; 00078 int numArgs; 00079 /* In the future, we will put types in here for the different arguments. 00080 We need a richer type system to do this effectively so that one 00081 can specify types for new classes. 00082 */ 00083 } R_CallMethodDef; 00084 typedef R_CallMethodDef R_ExternalMethodDef; 00085 00086 00087 typedef struct _DllInfo DllInfo; 00088 00089 /* 00090 Currently ignore the graphics routines, accessible via .External.graphics() 00091 and .Call.graphics(). 00092 */ 00093 #ifdef __cplusplus 00094 extern "C" { 00095 #endif 00096 int R_registerRoutines(DllInfo *info, const R_CMethodDef * const croutines, 00097 const R_CallMethodDef * const callRoutines, 00098 const R_FortranMethodDef * const fortranRoutines, 00099 const R_ExternalMethodDef * const externalRoutines); 00100 00101 Rboolean R_useDynamicSymbols(DllInfo *info, Rboolean value); 00102 Rboolean R_forceSymbols(DllInfo *info, Rboolean value); 00103 00104 DllInfo *R_getDllInfo(const char *name); 00105 00106 /* to be used by applications embedding R to register their symbols 00107 that are not related to any dynamic module */ 00108 DllInfo *R_getEmbeddingDllInfo(void); 00109 00110 typedef struct Rf_RegisteredNativeSymbol R_RegisteredNativeSymbol; 00111 typedef enum {R_ANY_SYM=0, R_C_SYM, R_CALL_SYM, R_FORTRAN_SYM, R_EXTERNAL_SYM} NativeSymbolType; 00112 00113 00114 DL_FUNC R_FindSymbol(char const * name, char const * pkg, 00115 R_RegisteredNativeSymbol *symbol); 00116 00117 00118 /* Experimental interface for exporting and importing functions from 00119 one package for use from C code in a package. The registration 00120 part probably ought to be integrated with the other registrations. 00121 The naming of these routines may be less than ideal. */ 00122 00123 void R_RegisterCCallable(const char *package, const char *name, DL_FUNC fptr); 00124 DL_FUNC R_GetCCallable(const char *package, const char *name); 00125 00126 #ifdef __cplusplus 00127 } 00128 #endif 00129 00130 #endif /* R_EXT_DYNLOAD_H_ */