Skip to content

Commit cdd1cea

Browse files
committed
Add 'new_env' static function (#169)
1 parent 8ad9ae8 commit cdd1cea

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2014-08-30 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/Environment.h: Add 'new_env' function
4+
15
2014-08-30 Dirk Eddelbuettel <[email protected]>
26

37
* inst/include/Rcpp/vector/Vector.h: Mark two 'from string' ctors as

inst/include/Rcpp/Environment.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#ifndef Rcpp_Environment_h
2323
#define Rcpp_Environment_h
2424

25+
// From R/Defn.h
26+
extern "C" SEXP R_NewHashedEnv(SEXP, SEXP);
27+
2528
namespace Rcpp{
2629

2730
RCPP_API_CLASS(Environment_Impl),
@@ -311,6 +314,11 @@ namespace Rcpp{
311314
return Rcpp::internal::get_Rcpp_namespace() ;
312315
}
313316

317+
static Environment_Impl new_env(int size = 29) {
318+
Shield<SEXP> sizeSEXP(Rf_ScalarInteger(size));
319+
return R_NewHashedEnv(R_EmptyEnv, sizeSEXP);
320+
};
321+
314322
/**
315323
* @param name the name of the package of which we want the namespace
316324
*
@@ -349,7 +357,7 @@ namespace Rcpp{
349357
void update(SEXP){}
350358
};
351359

352-
typedef Environment_Impl<PreserveStorage> Environment ;
360+
typedef Environment_Impl<PreserveStorage> Environment ;
353361

354362

355363
} // namespace Rcpp

0 commit comments

Comments
 (0)