CXXR (C++ R) API
PairList.h
Go to the documentation of this file.
1 /*CXXR $Id: PairList.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) 1995, 1996 Robert Gentleman and Ross Ihaka
20  * Copyright (C) 1999-2006 The R Development Core Team.
21  *
22  * This program is free software; you can redistribute it and/or modify
23  * it under the terms of the GNU General Public License as published by
24  * the Free Software Foundation; either version 2.1 of the License, or
25  * (at your option) any later version.
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  *
32  * You should have received a copy of the GNU General Public License
33  * along with this program; if not, a copy is available at
34  * http://www.r-project.org/Licenses/
35  */
36 
49 #ifndef RPAIRLIST_H
50 #define RPAIRLIST_H
51 
52 #include "CXXR/ConsCell.h"
53 
54 #ifdef __cplusplus
55 
56 extern "C" {
57  // Used in matching formal and actual arguments (within match.cpp
58  // and unique.cpp).
59  inline unsigned char ARGUSED(SEXP x)
60  {
61  using namespace CXXR;
62  return SEXP_downcast<PairList*>(x)->m_argused;
63  }
64 
65  // Used in matching formal and actual arguments (within match.cpp
66  // and unique.cpp).
67  inline void SET_ARGUSED(SEXP x, unsigned char v)
68  {
69  using namespace CXXR;
70  SEXP_downcast<PairList*>(x)->m_argused = v;
71  }
72 
73 #endif /* __cplusplus */
74 
83 #ifndef __cplusplus
84  Rboolean BINDING_IS_LOCKED(SEXP b);
85 #else
86  inline Rboolean BINDING_IS_LOCKED(SEXP b)
87  {
88  using namespace CXXR;
89  const PairList* pl = SEXP_downcast<PairList*>(b);
90  return Rboolean(pl->m_binding_locked);
91  }
92 #endif
93 
100 #ifndef __cplusplus
101  SEXP CDR(SEXP e);
102 #else
103  inline SEXP CDR(SEXP e)
104  {
105  using namespace CXXR;
106  return tail0(SEXP_downcast<ConsCell*>(e));
107  }
108 #endif
109 
113 #ifndef __cplusplus
114  SEXP CDAR(SEXP e);
115 #else
116  inline SEXP CDAR(SEXP e) {return CDR(CAR(e));}
117 #endif
118 
122 #ifndef __cplusplus
123  SEXP CADR(SEXP e);
124 #else
125  inline SEXP CADR(SEXP e)
126  {
127  using namespace CXXR;
128  return car0(tail0(SEXP_downcast<ConsCell*>(e)));
129  }
130 #endif
131 
135 #ifndef __cplusplus
136  SEXP CDDR(SEXP e);
137 #else
138  inline SEXP CDDR(SEXP e)
139  {
140  using namespace CXXR;
141  return tail0(tail0(SEXP_downcast<ConsCell*>(e)));
142  }
143 #endif
144 
148 #ifndef __cplusplus
149  SEXP CADDR(SEXP e);
150 #else
151  inline SEXP CADDR(SEXP e)
152  {
153  using namespace CXXR;
154  return car0(tail0(tail0(SEXP_downcast<ConsCell*>(e))));
155  }
156 #endif
157 
161 #ifndef __cplusplus
162  SEXP CADDDR(SEXP e);
163 #else
164  inline SEXP CADDDR(SEXP e)
165  {
166  using namespace CXXR;
167  return car0(tail0(tail0(tail0(SEXP_downcast<ConsCell*>(e)))));
168  }
169 #endif
170 
174 #ifndef __cplusplus
175  SEXP CAD4R(SEXP e);
176 #else
177  inline SEXP CAD4R(SEXP e)
178  {
179  using namespace CXXR;
180  return car0(tail0(tail0(tail0(tail0(SEXP_downcast<ConsCell*>(e))))));
181  }
182 #endif
183 
195  Rboolean IS_ACTIVE_BINDING(SEXP b);
196 
203 #ifndef __cplusplus
204  void LOCK_BINDING(SEXP b);
205 #else
206  inline void LOCK_BINDING(SEXP b)
207  {
208  using namespace CXXR;
209  PairList* pl = SEXP_downcast<PairList*>(b);
210  pl->m_binding_locked = true;}
211 #endif
212 
220 #ifndef __cplusplus
222 #else
224  {
225  using namespace CXXR;
226  PairList* pl = SEXP_downcast<PairList*>(b);
227  pl->m_active_binding = true;
228  }
229 #endif
230 
238  SEXP SETCDR(SEXP x, SEXP y);
239 
249  SEXP SETCADR(SEXP x, SEXP y);
250 
260  SEXP SETCADDR(SEXP x, SEXP y);
261 
271  SEXP SETCADDDR(SEXP x, SEXP y);
272 
282  SEXP SETCAD4R(SEXP x, SEXP y);
283 
290 #ifndef __cplusplus
291  void UNLOCK_BINDING(SEXP b);
292 #else
293  inline void UNLOCK_BINDING(SEXP b)
294  {
295  using namespace CXXR;
296  PairList* pl = SEXP_downcast<PairList*>(b);
297  pl->m_binding_locked = false;
298  }
299 #endif
300 
311  SEXP Rf_allocList(unsigned int n);
312 
324  SEXP Rf_cons(SEXP cr, SEXP tl);
325 
326 #ifdef __cplusplus
327 }
328 #endif
329 
330 #endif /* RPAIRLIST_H */