CXXR (C++ R)
Rdynload.h
1 /*CXXR $Id: Rdynload.h 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /*
18  * R : A Computer Language for Statistical Data Analysis
19  * Copyright (C) 2001-8 The R Core Team.
20  *
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU Lesser General Public License as published by
23  * the Free Software Foundation; either version 2.1 of the License, or
24  * (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  * GNU Lesser General Public License for more details.
30  *
31  * You should have received a copy of the GNU Lesser General Public License
32  * along with this program; if not, a copy is available at
33  * http://www.r-project.org/Licenses/
34  */
35 
36 #ifndef R_EXT_DYNLOAD_H_
37 #define R_EXT_DYNLOAD_H_
38 
39 #include <R_ext/Boolean.h>
40 
41 /* called with a variable argument set */
42 typedef void * (*DL_FUNC)();
43 
44 typedef unsigned int R_NativePrimitiveArgType;
45 
46 #define SINGLESXP 302 /* Don't have a single type for this. */
47 
48 /* In the future, we will want to allow people register their own types
49  and then refer to these in other contexts. Something like the Gtk type
50  system may be appropriate.
51 */
52 typedef unsigned int R_NativeObjectArgType;
53 
54 
55 /* In the near future, we may support registering
56  information about the arguments of native routines
57  and whether they are used to return information.
58  The hope is that we can minimize copying objects even
59  further. Not currently in use.
60 */
61 typedef enum {R_ARG_IN, R_ARG_OUT, R_ARG_IN_OUT, R_IRRELEVANT} R_NativeArgStyle;
62 
63 
64 
65 /*
66  These are very similar to those in unix/dynload.c
67  but we maintain them separately to give us more freedom to do
68  some computations on the internal versions that are derived from
69  these definitions.
70 */
71 typedef struct {
72  const char *name;
73  DL_FUNC fun;
74  int numArgs;
75 
76  R_NativePrimitiveArgType *types;
77  R_NativeArgStyle *styles;
78 
79 } R_CMethodDef;
80 
81 typedef R_CMethodDef R_FortranMethodDef;
82 
83 
84 
85 typedef struct {
86  const char *name;
87  DL_FUNC fun;
88  int numArgs;
89 /* In the future, we will put types in here for the different arguments.
90  We need a richer type system to do this effectively so that one
91  can specify types for new classes.
92 */
93 } R_CallMethodDef;
94 typedef R_CallMethodDef R_ExternalMethodDef;
95 
96 
97 typedef struct _DllInfo DllInfo;
98 
99 /*
100  Currently ignore the graphics routines, accessible via .External.graphics()
101  and .Call.graphics().
102  */
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 int R_registerRoutines(DllInfo *info, const R_CMethodDef * const croutines,
107  const R_CallMethodDef * const callRoutines,
108  const R_FortranMethodDef * const fortranRoutines,
109  const R_ExternalMethodDef * const externalRoutines);
110 
111 Rboolean R_useDynamicSymbols(DllInfo *info, Rboolean value);
112 
113 DllInfo *R_getDllInfo(const char *name);
114 
115 /* to be used by applications embedding R to register their symbols
116  that are not related to any dynamic module */
117 DllInfo *R_getEmbeddingDllInfo(void);
118 
119 typedef struct Rf_RegisteredNativeSymbol R_RegisteredNativeSymbol;
120 typedef enum {R_ANY_SYM=0, R_C_SYM, R_CALL_SYM, R_FORTRAN_SYM, R_EXTERNAL_SYM} NativeSymbolType;
121 
122 
123 DL_FUNC R_FindSymbol(char const *, char const *,
124  R_RegisteredNativeSymbol *symbol);
125 
126 int R_moduleCdynload(const char *module, int local, int now);
127 int R_cairoCdynload(int local, int now);
128 
129 
130 /* Experimental interface for exporting and importing functions from
131  one package for use from C code in a package. The registration
132  part probably ought to be integrated with the other registrations.
133  The naming of these routines may be less than ideal. */
134 
135 void R_RegisterCCallable(const char *package, const char *name, DL_FUNC fptr);
136 DL_FUNC R_GetCCallable(const char *package, const char *name);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* R_EXT_DYNLOAD_H_ */