The R Project SVN R

Rev

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

Rev Author Line No. Line
29921 ripley 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
70260 ripley 3
 *  Copyright (C) 2001-2016 The R Core Team.
29921 ripley 4
 *
71657 plummer 5
 *  This header file is free software; you can redistribute it and/or modify
29921 ripley 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
 *
71657 plummer 10
 *  This file is part of R. R is distributed under the terms of the
11
 *  GNU General Public License, either Version 2, June 1991 or Version 3,
12
 *  June 2007. See doc/COPYRIGHTS for details of the copyright status of R.
13
 *
29921 ripley 14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Lesser General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Lesser General Public License
42308 ripley 20
 *  along with this program; if not, a copy is available at
68949 ripley 21
 *  https://www.R-project.org/Licenses/
29921 ripley 22
 */
23
 
60256 ripley 24
/* 
25
   Not part of the API, subject to change at any time.
26
*/
27
 
17134 duncan 28
#ifndef R_CALLBACKS_H
29
#define R_CALLBACKS_H
30
 
31
/**
32
  These structures are for C (and R function) top-level task handlers.
33
  Such routines are called at the end of every (successful) top-level task
34
  in the regular REPL. 
35
 */
36
 
19500 hornik 37
#include <Rinternals.h>
17134 duncan 38
/**
39
  The signature of the C routine that a callback must implement.
40
  expr - the expression for the top-level task that was evaluated.
41
  value - the result of the top-level task, i.e. evaluating expr.
42
  succeeded - a logical value indicating whether the task completed propertly.
43
  visible - a logical value indicating whether the result was printed to the R ``console''/stdout.
44
  data - user-level data passed to the registration routine.
45
 */
46
typedef Rboolean (*R_ToplevelCallback)(SEXP expr, SEXP value, Rboolean succeeded, Rboolean visible, void *);
47
 
48
typedef struct _ToplevelCallback  R_ToplevelCallbackEl;
49
/** 
50
 Linked list element for storing the top-level task callbacks.
51
 */
52
struct _ToplevelCallback {
53
    R_ToplevelCallback cb; /* the C routine to call. */
54
    void *data;            /* the user-level data to pass to the call to cb() */
55
    void (*finalizer)(void *data); /* Called when the callback is removed. */
56
 
57
    char *name;  /* a name by which to identify this element. */ 
58
 
59
    R_ToplevelCallbackEl *next; /* the next element in the linked list. */
60
};
61
 
62
#ifdef __cplusplus
63
extern "C" {
64
#endif
65
 
66
Rboolean Rf_removeTaskCallbackByIndex(int id);
67
Rboolean Rf_removeTaskCallbackByName(const char *name);
68
SEXP R_removeTaskCallback(SEXP which);
69
R_ToplevelCallbackEl* Rf_addTaskCallback(R_ToplevelCallback cb, void *data, void (*finalizer)(void *), const char *name, int *pos);
70
 
71
 
72
 
60256 ripley 73
/*
74
  The following definitions are for callbacks to R functions and
75
  methods related to user-level tables.  This was implemented in a
76
  separate package on Omegahat and these declarations allow the package
77
  to interface to the internal R code.
78
 
70260 ripley 79
  See https://developer.r-project.org/RObjectTables.pdf,
70250 ripley 80
  http://www.omegahat.net/RObjectTables/
60256 ripley 81
*/
17134 duncan 82
 
83
typedef struct  _R_ObjectTable R_ObjectTable;
84
 
60256 ripley 85
/* Do we actually need the exists() since it is never called but R
86
   uses get to see if the symbol is bound to anything? */
17134 duncan 87
typedef Rboolean (*Rdb_exists)(const char * const name, Rboolean *canCache, R_ObjectTable *);
88
typedef SEXP     (*Rdb_get)(const char * const name, Rboolean *canCache, R_ObjectTable *);
89
typedef int      (*Rdb_remove)(const char * const name, R_ObjectTable *);
90
typedef SEXP     (*Rdb_assign)(const char * const name, SEXP value, R_ObjectTable *);
91
typedef SEXP     (*Rdb_objects)(R_ObjectTable *);
92
typedef Rboolean (*Rdb_canCache)(const char * const name, R_ObjectTable *);
93
 
94
typedef void     (*Rdb_onDetach)(R_ObjectTable *);
95
typedef void     (*Rdb_onAttach)(R_ObjectTable *);
96
 
97
struct  _R_ObjectTable{
98
  int       type;
99
  char    **cachedNames;
100
  Rboolean  active;
101
 
102
  Rdb_exists   exists;
103
  Rdb_get      get;
104
  Rdb_remove   remove;
105
  Rdb_assign   assign;
106
  Rdb_objects  objects;
107
  Rdb_canCache canCache;
108
 
109
  Rdb_onDetach onDetach;
110
  Rdb_onAttach onAttach;
111
 
112
  void     *privateData;
113
};
114
 
115
 
116
#ifdef __cplusplus
117
}
118
#endif
119
 
120
#endif /* R_CALLBACKS_H */