Skip to content

Commit 7bd563a

Browse files
committed
Reintroduce meat (#165)
1 parent 22fb5ab commit 7bd563a

File tree

9 files changed

+183
-67
lines changed

9 files changed

+183
-67
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2014-08-13 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/api/meat/meat.h: Reintroduce meat
4+
* inst/include/Rcpp/api/meat/proxy.h: Idem
5+
* inst/include/Rcpp/proxy/AttributeProxy.h: Idem
6+
* inst/include/Rcpp/proxy/Binding.h: Idem
7+
* inst/include/Rcpp/proxy/NamesProxy.h: Idem
8+
* inst/include/Rcpp/proxy/SlotProxy.h: Idem
9+
* inst/include/Rcpp/proxy/TagProxy.h: Idem
10+
* inst/include/Rcpp/proxy/proxy.h: Idem
11+
112
2014-08-03 Dirk Eddelbuettel <[email protected]>
213

314
* vignettes/Rcpp-FAQ.Rnw: Updated with respect to OS X installations

inst/include/Rcpp/api/meat/meat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <Rcpp/api/meat/S4.h>
3232
#include <Rcpp/api/meat/Environment.h>
3333

34+
#include <Rcpp/api/meat/proxy.h>
35+
3436
#include <Rcpp/api/meat/DottedPairImpl.h>
3537
#include <Rcpp/api/meat/StretchyList.h>
3638
#include <Rcpp/api/meat/Vector.h>

inst/include/Rcpp/api/meat/proxy.h

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2+
//
3+
// meat.h: Rcpp R/C++ interface class library --
4+
//
5+
// Copyright (C) 2014 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey
6+
//
7+
// This file is part of Rcpp.
8+
//
9+
// Rcpp is free software: you can redistribute it and/or modify it
10+
// under the terms of the GNU General Public License as published by
11+
// the Free Software Foundation, either version 2 of the License, or
12+
// (at your option) any later version.
13+
//
14+
// Rcpp is distributed in the hope that it will be useful, but
15+
// WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
// GNU General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU General Public License
20+
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21+
#ifndef RCPP_API_MEAT_PROXY_H
22+
#define RCPP_API_MEAT_PROXY_H
23+
24+
namespace Rcpp {
25+
26+
// Attribute Proxies
27+
template <typename CLASS>
28+
template <typename T>
29+
typename AttributeProxyPolicy<CLASS>::AttributeProxy&
30+
AttributeProxyPolicy<CLASS>::AttributeProxy::operator=(const T& rhs) {
31+
set( wrap(rhs) );
32+
return *this;
33+
}
34+
35+
template <typename CLASS>
36+
template <typename T>
37+
AttributeProxyPolicy<CLASS>::AttributeProxy::operator T() const {
38+
return as<T>(get());
39+
}
40+
41+
template <typename CLASS>
42+
AttributeProxyPolicy<CLASS>::AttributeProxy::operator SEXP() const {
43+
return get();
44+
}
45+
46+
template <typename CLASS>
47+
template <typename T>
48+
AttributeProxyPolicy<CLASS>::const_AttributeProxy::operator T() const {
49+
return as<T>(get());
50+
}
51+
52+
template <typename CLASS>
53+
AttributeProxyPolicy<CLASS>::const_AttributeProxy::operator SEXP() const {
54+
return get();
55+
}
56+
57+
// Names proxy
58+
59+
template <typename CLASS>
60+
template <typename T>
61+
typename NamesProxyPolicy<CLASS>::NamesProxy&
62+
NamesProxyPolicy<CLASS>::NamesProxy::operator=(const T& rhs) {
63+
set( wrap(rhs) );
64+
return *this;
65+
}
66+
67+
template <typename CLASS>
68+
template <typename T>
69+
NamesProxyPolicy<CLASS>::NamesProxy::operator T() const {
70+
return as<T>( get() );
71+
}
72+
73+
template <typename CLASS>
74+
template <typename T>
75+
NamesProxyPolicy<CLASS>::const_NamesProxy::operator T() const {
76+
return as<T>( get() );
77+
}
78+
79+
// Slot proxy
80+
81+
template <typename CLASS>
82+
template <typename T>
83+
typename SlotProxyPolicy<CLASS>::SlotProxy&
84+
SlotProxyPolicy<CLASS>::SlotProxy::operator=(const T& rhs) {
85+
set(wrap(rhs));
86+
return *this;
87+
}
88+
89+
template <typename CLASS>
90+
template <typename T>
91+
SlotProxyPolicy<CLASS>::SlotProxy::operator T() const {
92+
return as<T>(get());
93+
}
94+
95+
// Tag proxy
96+
97+
template <typename CLASS>
98+
template <typename T>
99+
typename TagProxyPolicy<CLASS>::TagProxy&
100+
TagProxyPolicy<CLASS>::TagProxy::operator=(const T& rhs) {
101+
set( wrap(rhs) );
102+
return *this;
103+
}
104+
105+
template <typename CLASS>
106+
template <typename T>
107+
TagProxyPolicy<CLASS>::TagProxy::operator T() const {
108+
return as<T>(get());
109+
}
110+
111+
template <typename CLASS>
112+
TagProxyPolicy<CLASS>::TagProxy::operator SEXP() const {
113+
return get();
114+
}
115+
116+
template <typename CLASS>
117+
template <typename T>
118+
TagProxyPolicy<CLASS>::const_TagProxy::operator T() const {
119+
return as<T>(get());
120+
}
121+
122+
template <typename CLASS>
123+
TagProxyPolicy<CLASS>::const_TagProxy::operator SEXP() const {
124+
return get();
125+
}
126+
127+
// Environment Binding
128+
129+
template <typename CLASS>
130+
template <typename T>
131+
typename BindingPolicy<CLASS>::Binding&
132+
BindingPolicy<CLASS>::Binding::operator=(const T& rhs) {
133+
set(wrap(rhs));
134+
return *this;
135+
}
136+
137+
template <typename CLASS>
138+
template <typename T>
139+
BindingPolicy<CLASS>::Binding::operator T() const {
140+
return as<T>(get());
141+
}
142+
143+
template <typename CLASS>
144+
template <typename T>
145+
BindingPolicy<CLASS>::const_Binding::operator T() const {
146+
return as<T>(get());
147+
}
148+
}
149+
150+
#endif

inst/include/Rcpp/proxy/AttributeProxy.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,11 @@ class AttributeProxyPolicy {
3535
return *this ;
3636
}
3737

38-
template <typename T> AttributeProxy& operator=(const T& rhs) {
39-
set( wrap( rhs ) );
40-
return *this;
41-
}
38+
template <typename T> AttributeProxy& operator=(const T& rhs);
4239

43-
template <typename T> operator T() const {
44-
return as<T>( get() );
45-
}
40+
template <typename T> operator T() const;
4641

47-
inline operator SEXP() const {
48-
return get() ;
49-
}
42+
inline operator SEXP() const;
5043

5144
private:
5245
CLASS& parent;
@@ -65,12 +58,8 @@ class AttributeProxyPolicy {
6558
const_AttributeProxy( const CLASS& v, const std::string& name)
6659
: parent(v), attr_name(Rf_install(name.c_str())){}
6760

68-
template <typename T> operator T() const {
69-
return as<T>( get() );
70-
}
71-
inline operator SEXP() const {
72-
return get() ;
73-
}
61+
template <typename T> operator T() const;
62+
inline operator SEXP() const;
7463

7564
private:
7665
const CLASS& parent;

inst/include/Rcpp/proxy/Binding.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ class BindingPolicy {
5050
return *this ;
5151
}
5252

53-
template <typename WRAPPABLE> Binding& operator=(const WRAPPABLE& rhs) {
54-
set( wrap(rhs) );
55-
return *this;
56-
}
57-
template <typename T> operator T() const {
58-
return as<T>( get() );
59-
}
53+
template <typename WRAPPABLE>
54+
Binding& operator=(const WRAPPABLE& rhs);
55+
56+
template <typename T> operator T() const;
6057

6158
private:
6259

@@ -86,9 +83,7 @@ class BindingPolicy {
8683
inline bool exists() const {
8784
return env.exists(name) ;
8885
}
89-
template <typename T> operator T() const {
90-
return as<T>( get() );
91-
}
86+
template <typename T> operator T() const;
9287

9388
private:
9489

inst/include/Rcpp/proxy/NamesProxy.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,9 @@ class NamesProxyPolicy{
3535
}
3636

3737
template <typename T>
38-
NamesProxy& operator=(const T& rhs) {
39-
set( wrap(rhs) );
40-
return *this;
41-
}
38+
NamesProxy& operator=(const T& rhs);
4239

43-
template <typename T> operator T() const {
44-
return as<T>( get() );
45-
}
40+
template <typename T> operator T() const;
4641

4742
private:
4843
CLASS& parent;
@@ -71,9 +66,7 @@ class NamesProxyPolicy{
7166
public:
7267
const_NamesProxy( const CLASS& v) : parent(v){} ;
7368

74-
template <typename T> operator T() const {
75-
return as<T>( get() );
76-
}
69+
template <typename T> operator T() const;
7770

7871
private:
7972
const CLASS& parent;

inst/include/Rcpp/proxy/SlotProxy.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ class SlotProxyPolicy {
3737
return *this ;
3838
}
3939

40-
template <typename T> SlotProxy& operator=(const T& rhs) {
41-
set( wrap(rhs) );
42-
return *this;
43-
}
40+
template <typename T> SlotProxy& operator=(const T& rhs);
4441

45-
template <typename T> operator T() const {
46-
return as<T>( get() );
47-
}
42+
template <typename T> operator T() const;
4843
inline operator SEXP() const {
4944
return get() ;
5045
}

inst/include/Rcpp/proxy/TagProxy.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,12 @@ namespace Rcpp{
2929
TagProxy( XPtrClass& xp_ ): xp(xp_){}
3030

3131
template <typename U>
32-
TagProxy& operator=( const U& u) {
33-
set( wrap( u ) ) ;
34-
return *this ;
35-
}
32+
TagProxy& operator=( const U& u);
3633

3734
template <typename U>
38-
operator U() const {
39-
return as<U>( get() ) ;
40-
}
35+
operator U() const;
4136

42-
operator SEXP() const {
43-
return get();
44-
}
37+
operator SEXP() const;
4538

4639

4740
private:
@@ -62,13 +55,9 @@ namespace Rcpp{
6255
const_TagProxy( XPtrClass& xp_ ): xp(xp_){}
6356

6457
template <typename U>
65-
operator U() const {
66-
return as<U>( get() );
67-
}
58+
operator U() const;
6859

69-
operator SEXP() const {
70-
return get();
71-
}
60+
operator SEXP() const;
7261

7362

7463
private:

inst/include/Rcpp/proxy/proxy.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717

1818
#ifndef Rcpp_proxy_proxy_h
1919

20-
// forward decl of as (should put this somewhere better)
21-
// similar for wrap
22-
namespace Rcpp {
23-
template <typename T> T as(SEXP);
24-
template <typename T> SEXP wrap(const T& object);
25-
inline SEXP wrap(const char* const v);
26-
}
27-
2820
#include <Rcpp/proxy/GenericProxy.h>
2921

3022
#include <Rcpp/proxy/NamesProxy.h>

0 commit comments

Comments
 (0)