CXXR (C++ R)
DotInternal.h
Go to the documentation of this file.
1 /*CXXR $Id: DotInternal.h 1397 2013-08-16 18:25:59Z 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 
42 #ifndef DOTINTERNAL_H
43 #define DOTINTERNAL_H
44 
45 #include "CXXR/RObject.h"
46 
47 #ifdef __cplusplus
48 
49 #include "CXXR/BuiltInFunction.h"
50 #include "CXXR/GCRoot.h"
51 #include "CXXR/SEXP_downcast.hpp"
52 #include "CXXR/StdFrame.hpp"
53 #include "CXXR/Symbol.h"
54 
55 namespace CXXR {
63  public:
72  static BuiltInFunction* get(const Symbol* sym)
73  {
74  map::iterator it = s_table->find(sym);
75  if (it == s_table->end())
76  return 0;
77  return (*it).second;
78  }
79 
89  static void set(const Symbol* sym, BuiltInFunction* fun);
90  private:
91  typedef
92  std::tr1::unordered_map<const Symbol*,
94  std::tr1::hash<const Symbol*>,
95  std::equal_to<const Symbol*>,
96  CXXR::Allocator<std::pair<const Symbol* const,
98  > map;
99 
100  static map* s_table;
101 
102  // Called from BuiltInFunction::initialize():
103  static void initialize();
104 
105  friend class BuiltInFunction;
106  };
107 } // namespace CXXR
108 
109 extern "C" {
110 #endif
111 
120 #ifndef __cplusplus
121  SEXP INTERNAL(SEXP x);
122 #else
123  inline SEXP INTERNAL(SEXP x)
124  {
125  using namespace CXXR;
126  const Symbol* sym = SEXP_downcast<Symbol*>(x);
127  return DotInternalTable::get(sym);
128  }
129 #endif
130 
140  void SET_INTERNAL(SEXP x, SEXP v);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* DOTINTERNAL_H */