The R Project SVN R

Rev

Rev 60255 | Rev 71657 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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