Skip to content

Commit 67e7a18

Browse files
now compiles, still to deal with duplicate symbols
1 parent bea30d4 commit 67e7a18

12 files changed

Lines changed: 102 additions & 18 deletions

File tree

inst/include/Rcpp/Environment.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace Rcpp{
9797
* @return a SEXP (possibly R_NilValue)
9898
*/
9999
SEXP get(const std::string& name) const {
100-
SEXP env = Storage::get_() ;
100+
SEXP env = Storage::get__() ;
101101
SEXP nameSym = Rf_install(name.c_str());
102102
SEXP res = Rf_findVarInFrame( env, nameSym ) ;
103103

@@ -343,6 +343,8 @@ namespace Rcpp{
343343
return Environment_Impl( Rcpp_eval(Rf_lang3( newEnvSym, Rf_ScalarLogical(hashed), Storage::get__() )) );
344344
}
345345

346+
347+
void update(SEXP){}
346348
};
347349

348350
typedef Environment_Impl<PreserveStorage> Environment ;

inst/include/Rcpp/Module.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,12 @@ namespace Rcpp {
395395

396396
class CppClass : public S4{
397397
public:
398+
typedef XPtr<class_Base> XP_Class ;
398399
typedef Rcpp::XPtr<Rcpp::Module> XP ;
399400
CppClass( SEXP x) : S4(x){};
400401
CppClass( const CppClass& other) : S4(other.get__()){}
401402

402-
CppClass( Module* p, class_Base* clazz, std::string& ) S4("C++Class") {
403+
CppClass( Module* p, class_Base* cl, std::string& buffer ) : S4("C++Class") {
403404
XP_Class clxp( cl, false, R_NilValue, R_NilValue ) ;
404405
slot( "module" ) = XP( p, false ) ;
405406
slot( "pointer" ) = clxp ;
@@ -427,13 +428,13 @@ namespace Rcpp {
427428
class CppObject : public S4{
428429
public:
429430
typedef Rcpp::XPtr<Rcpp::Module> XP ;
430-
CppObject( Module* p, class_Base*, SEXP xp ) : S4("C++Object") {
431+
CppObject( Module* p, class_Base* clazz, SEXP xp ) : S4("C++Object") {
431432
slot( "module" ) = XP( p, false ) ;
432433
slot( "cppclass" ) = Rcpp::XPtr<class_Base>( clazz, false ) ;
433434
slot( "pointer" ) = xp ;
434435
}
435436
CppObject( const CppObject& other){
436-
Storage::copy( other ) ;
437+
Storage::copy__( other ) ;
437438
}
438439

439440
CppObject& operator=( const CppObject& other ) {

inst/include/Rcpp/RObject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace Rcpp{
5050
Storage::set__(other) ;
5151
}
5252

53+
void update(SEXP){}
5354
};
5455

5556
typedef RObject_Impl<PreserveStorage> RObject ;

inst/include/Rcpp/XPtr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class XPtr :
122122
return (T*)( R_ExternalPtrAddr( Storage::get__() )) ;
123123
}
124124

125-
125+
void update(SEXP){}
126126
};
127127

128128
} // namespace Rcpp

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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_api_meat_as_h
19+
#define Rcpp_api_meat_as_h
20+
21+
namespace Rcpp{
22+
namespace internal{
23+
24+
inline void* as_module_object_internal(SEXP obj){
25+
Environment env(obj) ;
26+
SEXP xp = env.get(".pointer") ;
27+
return R_ExternalPtrAddr(xp );
28+
}
29+
30+
}
31+
}
32+
33+
#endif

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <Rcpp/api/meat/Vector.h>
3939
#include <Rcpp/api/meat/Matrix.h>
4040
#include <Rcpp/api/meat/is.h>
41+
#include <Rcpp/api/meat/as.h>
4142
#include <Rcpp/api/meat/export.h>
4243
#include <Rcpp/api/meat/protection.h>
4344
#include <Rcpp/api/meat/wrap.h>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Module.h: Rcpp R/C++ interface class library -- Rcpp modules
2+
//
3+
// Copyright (C) 2013 Romain Francois
4+
//
5+
// This file is part of Rcpp.
6+
//
7+
// Rcpp is free software: you can redistribute it and/or modify it
8+
// under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, either version 2 of the License, or
10+
// (at your option) any later version.
11+
//
12+
// Rcpp is distributed in the hope that it will be useful, but
13+
// WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU General Public License
18+
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
19+
20+
#ifndef Rcpp_api_meat_Module_h
21+
#define Rcpp_api_meat_Module_h
22+
23+
namespace Rcpp {
24+
25+
inline List Module::classes_info(){
26+
int n = classes.size() ;
27+
CharacterVector names(n) ;
28+
List info(n);
29+
CLASS_MAP::iterator it = classes.begin() ;
30+
std::string buffer ;
31+
for( int i=0; i<n; i++, ++it){
32+
names[i] = it->first ;
33+
info[i] = CppClass( this , it->second, buffer ) ;
34+
}
35+
info.names() = names ;
36+
return info ;
37+
}
38+
39+
inline CppClass Module::get_class( const std::string& cl ){
40+
BEGIN_RCPP
41+
CLASS_MAP::iterator it = classes.find(cl) ;
42+
if( it == classes.end() ) throw std::range_error( "no such class" ) ;
43+
std::string buffer ;
44+
return CppClass( this, it->second, buffer ) ;
45+
END_RCPP
46+
}
47+
48+
}
49+
50+
#endif

inst/include/Rcpp/as.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,8 @@ namespace Rcpp{
8383
return exporter.get() ;
8484
}
8585

86-
inline void* as_module_object_internal(SEXP obj) {
87-
Environment env(obj) ;
88-
SEXP xp = env.get(".pointer") ;
89-
return R_ExternalPtrAddr(xp );
90-
}
86+
void* as_module_object_internal(SEXP obj) ;
87+
9188
template <typename T> object<T> as_module_object(SEXP x){
9289
return (T*) as_module_object_internal(x) ;
9390
}

inst/include/Rcpp/proxy/AttributeProxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ class AttributeProxyPolicy {
7474
} ;
7575

7676
AttributeProxy attr( const std::string& name){
77-
return AttributeProxy( static_cast<CLASS&>( *this ) ) ;
77+
return AttributeProxy( static_cast<CLASS&>( *this ), name ) ;
7878
}
7979
const_AttributeProxy attr( const std::string& name) const {
80-
return AttributeProxy( static_cast<const CLASS&>( *this ) ) ;
80+
return const_AttributeProxy( static_cast<const CLASS&>( *this ), name ) ;
8181
}
8282

8383
std::vector<std::string> attributeNames() const {

inst/include/Rcpp/proxy/Binding.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ class BindingPolicy {
9494
} ;
9595

9696
const_Binding operator[]( const std::string& name) const {
97-
return const_Binding( static_cast<EnvironmentClass&>(*this) ) ;
97+
return const_Binding( static_cast<const EnvironmentClass&>(*this), name ) ;
9898
}
9999
Binding operator[](const std::string& name){
100-
return Binding( static_cast<const EnvironmentClass&>(*this) ) ;
100+
return Binding( static_cast<EnvironmentClass&>(*this), name ) ;
101101
}
102102

103103
} ;

0 commit comments

Comments
 (0)