The R Project SVN R

Rev

Rev 89696 | 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
89942 luke 3
 *  Copyright (C) 2001-2026 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
/* 
89942 luke 25
   Part of the experimental API, subject to change at any time.
60256 ripley 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.
84150 maechler 42
  succeeded - a logical value indicating whether the task completed properly.
17134 duncan 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
 */
87945 ripley 46
typedef Rboolean (*R_ToplevelCallback)(SEXP expr, SEXP value, Rboolean succeeded, Rboolean visible, void *);
17134 duncan 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
 
87945 ripley 66
Rboolean Rf_removeTaskCallbackByIndex(int id);
67
Rboolean Rf_removeTaskCallbackByName(const char *name);
17134 duncan 68
R_ToplevelCallbackEl* Rf_addTaskCallback(R_ToplevelCallback cb, void *data, void (*finalizer)(void *), const char *name, int *pos);
69
 
70
#ifdef __cplusplus
71
}
72
#endif
73
 
74
#endif /* R_CALLBACKS_H */