File tree Expand file tree Collapse file tree 12 files changed +58
-19
lines changed
Expand file tree Collapse file tree 12 files changed +58
-19
lines changed Original file line number Diff line number Diff line change 1919#define Rcpp_proxy_AttributeProxy_h
2020
2121namespace Rcpp {
22-
22+
2323template <typename CLASS>
2424class AttributeProxyPolicy {
2525public:
2626
27- class AttributeProxy {
27+ class AttributeProxy : public GenericProxy <AttributeProxy> {
2828 public:
2929 AttributeProxy ( CLASS& v, const std::string& name)
3030 : parent(v), attr_name(Rf_install(name.c_str()))
@@ -55,7 +55,7 @@ class AttributeProxyPolicy {
5555 }
5656 } ;
5757
58- class const_AttributeProxy {
58+ class const_AttributeProxy : public GenericProxy <const_AttributeProxy> {
5959 public:
6060 const_AttributeProxy ( const CLASS& v, const std::string& name)
6161 : parent(v), attr_name(Rf_install(name.c_str())){}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ template <typename EnvironmentClass>
2424class BindingPolicy {
2525public:
2626
27- class Binding {
27+ class Binding : public GenericProxy <Binding> {
2828 public:
2929 Binding ( EnvironmentClass& env_, const std::string& name_) :
3030 env (env_), name(name_){}
@@ -67,7 +67,7 @@ class BindingPolicy {
6767 std::string name ;
6868 } ;
6969
70- class const_Binding {
70+ class const_Binding : public GenericProxy <const_Binding> {
7171 public:
7272 const_Binding ( const EnvironmentClass& env_, const std::string& name_) :
7373 env (env_), name(name_){}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ template <typename CLASS>
2424class DottedPairProxyPolicy {
2525public:
2626
27- class DottedPairProxy {
27+ class DottedPairProxy : public GenericProxy <DottedPairProxy> {
2828 public:
2929 DottedPairProxy ( CLASS& v, int index_ ): node(R_NilValue){
3030 if ( index_ >= v.length () ) throw index_out_of_bounds () ;
@@ -69,7 +69,7 @@ class DottedPairProxyPolicy {
6969 SEXP node ;
7070 } ;
7171
72- class const_DottedPairProxy {
72+ class const_DottedPairProxy : public GenericProxy <const_DottedPairProxy> {
7373 public:
7474 const_DottedPairProxy ( const CLASS& v, int index_ ): node(R_NilValue){
7575 if ( index_ >= v.length () ) throw index_out_of_bounds () ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ template <typename CLASS>
2424class FieldProxyPolicy {
2525public:
2626
27- class FieldProxy {
27+ class FieldProxy : public GenericProxy <FieldProxy> {
2828 public:
2929 FieldProxy ( CLASS& v, const std::string& name) :
3030 parent (v), field_name(name) {}
@@ -56,7 +56,7 @@ class FieldProxyPolicy {
5656 }
5757 } ;
5858
59- class const_FieldProxy {
59+ class const_FieldProxy : public GenericProxy <const_FieldProxy> {
6060 public:
6161 const_FieldProxy ( const CLASS& v, const std::string& name) :
6262 parent (v), field_name(name) {}
Original file line number Diff line number Diff line change 1+ // Copyright (C) 2013 Romain Francois
2+ //
3+ // This file is part of Rcpp.
4+ //
5+ // Rcpp is free software: you can redistribute it and/or modify it
6+ // under the terms of the GNU General Public License as published by
7+ // the Free Software Foundation, either version 2 of the License, or
8+ // (at your option) any later version.
9+ //
10+ // Rcpp is distributed in the hope that it will be useful, but
11+ // WITHOUT ANY WARRANTY; without even the implied warranty of
12+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ // GNU General Public License for more details.
14+ //
15+ // You should have received a copy of the GNU General Public License
16+ // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
17+
18+ #ifndef Rcpp_proxy_GenericProxy_h
19+ #define Rcpp_proxy_GenericProxy_h
20+
21+ namespace Rcpp {
22+
23+ template <typename Proxy>
24+ struct GenericProxy {
25+ inline SEXP get () const {
26+ return static_cast <const Proxy&>(*this ) ;
27+ }
28+ } ;
29+
30+ }
31+
32+ #endif
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ template <typename CLASS>
2424class NamesProxyPolicy {
2525public:
2626
27- class NamesProxy {
27+ class NamesProxy : public GenericProxy <NamesProxy> {
2828 public:
2929 NamesProxy ( CLASS& v) : parent(v){} ;
3030
@@ -62,7 +62,7 @@ class NamesProxyPolicy{
6262
6363 } ;
6464
65- class const_NamesProxy {
65+ class const_NamesProxy : public GenericProxy <const_NamesProxy> {
6666 public:
6767 const_NamesProxy ( const CLASS& v) : parent(v){} ;
6868
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ namespace Rcpp{
2424 class ProtectedProxyPolicy {
2525 public:
2626
27- class ProtectedProxy {
27+ class ProtectedProxy : public GenericProxy <ProtectedProxy> {
2828 public:
2929 ProtectedProxy ( XPtrClass& xp_ ): xp(xp_){}
3030
@@ -51,7 +51,7 @@ namespace Rcpp{
5151
5252 } ;
5353
54- class const_ProtectedProxy {
54+ class const_ProtectedProxy : public GenericProxy <const_ProtectedProxy> {
5555 public:
5656 const_ProtectedProxy ( const XPtrClass& xp_ ): xp(xp_){}
5757
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ template <typename CLASS>
2424class SlotProxyPolicy {
2525public:
2626
27- class SlotProxy {
27+ class SlotProxy : public GenericProxy <SlotProxy> {
2828 public:
2929 SlotProxy ( CLASS& v, const std::string& name) : parent(v), slot_name(Rf_install(name.c_str())) {
3030 if ( !R_has_slot ( v, slot_name) ){
@@ -56,7 +56,7 @@ class SlotProxyPolicy {
5656 }
5757 } ;
5858
59- class const_SlotProxy {
59+ class const_SlotProxy : public GenericProxy <const_SlotProxy> {
6060 public:
6161 const_SlotProxy ( const CLASS& v, const std::string& name) ;
6262 const_SlotProxy& operator =(const const_SlotProxy& rhs) ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ namespace Rcpp{
2424 class TagProxyPolicy {
2525 public:
2626
27- class TagProxy {
27+ class TagProxy : public GenericProxy <TagProxy> {
2828 public:
2929 TagProxy ( XPtrClass& xp_ ): xp(xp_){}
3030
@@ -52,7 +52,7 @@ namespace Rcpp{
5252
5353 } ;
5454
55- class const_TagProxy {
55+ class const_TagProxy : public GenericProxy <const_TagProxy> {
5656 public:
5757 const_TagProxy ( XPtrClass& xp_ ): xp(xp_){}
5858
Original file line number Diff line number Diff line change 1717
1818#ifndef Rcpp_proxy_proxy_h
1919
20+ #include <Rcpp/proxy/GenericProxy.h>
21+
2022#include <Rcpp/proxy/NamesProxy.h>
2123#include <Rcpp/proxy/RObjectMethods.h>
2224#include <Rcpp/proxy/AttributeProxy.h>
You can’t perform that action at this time.
0 commit comments