[Rcpp-devel] [Rcpp-commits] r237 - pkg/src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 30 16:56:56 CET 2009
Author: edd
Date: 2009-12-30 16:56:56 +0100 (Wed, 30 Dec 2009)
New Revision: 237
Modified:
pkg/src/Rcpp/Environment.h
pkg/src/Rcpp/RObject.h
pkg/src/Rcpp/XPtr.h
Log:
most minor header cleanup and reindentation
Modified: pkg/src/Rcpp/Environment.h
===================================================================
--- pkg/src/Rcpp/Environment.h 2009-12-30 14:40:36 UTC (rev 236)
+++ pkg/src/Rcpp/Environment.h 2009-12-30 15:56:56 UTC (rev 237)
@@ -1,9 +1,8 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//
-// Rcpp_RObject.h: Rcpp R/C++ interface class library -- super class of all R objects wrapped in C++ classes
+// Environment.h: Rcpp R/C++ interface class library -- access R environments
//
-// Copyright (C) 2009 - 2010 Dirk Eddelbuettel
-// Copyright (C) 2009 - 2010 Romain Francois
+// Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
@@ -33,16 +32,16 @@
class Environment: public RObject{
public:
- /**
- * wraps the given environment
- *
- * if the SEXP is not an environment, and exception is thrown
- */
- Environment(SEXP m_sexp) ;
+ /**
+ * wraps the given environment
+ *
+ * if the SEXP is not an environment, and exception is thrown
+ */
+ Environment(SEXP m_sexp) ;
- /**
- * Nothing specific
- */
+ /**
+ * Nothing specific
+ */
~Environment() ;
/**
@@ -55,11 +54,11 @@
protected:
- /**
- * we cache whether this environment is a user defined database
- * or a standard environment
- */
- bool is_user_database ;
+ /**
+ * we cache whether this environment is a user defined database
+ * or a standard environment
+ */
+ bool is_user_database ;
};
} // namespace Rcpp
Modified: pkg/src/Rcpp/RObject.h
===================================================================
--- pkg/src/Rcpp/RObject.h 2009-12-30 14:40:36 UTC (rev 236)
+++ pkg/src/Rcpp/RObject.h 2009-12-30 15:56:56 UTC (rev 237)
@@ -1,9 +1,8 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//
-// Rcpp_RObject.h: Rcpp R/C++ interface class library -- super class of all R objects wrapped in C++ classes
+// RObject.h: Rcpp R/C++ interface class library -- general R object wrapper
//
-// Copyright (C) 2009 - 2010 Dirk Eddelbuettel
-// Copyright (C) 2009 - 2010 Romain Francois
+// Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
@@ -31,23 +30,23 @@
class RObject{
public:
- /**
- * wraps a SEXP. The SEXP is not automatically
- * protected from garbage collection because it might be
- * protected from elsewhere (e.g. if it comes from the
- * R side). See protect and release for ways to protect
- * the SEXP from garbage collection, and release to
- * remove the protection
- */
- RObject(SEXP m_sexp = R_NilValue) : m_sexp(m_sexp) {};
+ /**
+ * wraps a SEXP. The SEXP is not automatically
+ * protected from garbage collection because it might be
+ * protected from elsewhere (e.g. if it comes from the
+ * R side). See protect and release for ways to protect
+ * the SEXP from garbage collection, and release to
+ * remove the protection
+ */
+ RObject(SEXP m_sexp = R_NilValue) : m_sexp(m_sexp) {};
/**
- * if this object is protected rom R's GC, then it is released
- * and become subject to garbage collection. See protect
- * and release member functions.
- */
+ * if this object is protected rom R's GC, then it is released
+ * and become subject to garbage collection. See protect
+ * and release member functions.
+ */
~RObject() ;
-
+
RObject(const double & v);
RObject(const int & v);
RObject(const Rbyte & v);
@@ -81,40 +80,40 @@
/**
- * protects the wrapped SEXP from garbage collection. This
- * calls the R_PreserveObject function on the underlying SEXP.
- *
- * Note that this does not use the PROTECT/UNPROTECT dance
- */
- void protect();
+ * protects the wrapped SEXP from garbage collection. This
+ * calls the R_PreserveObject function on the underlying SEXP.
+ *
+ * Note that this does not use the PROTECT/UNPROTECT dance
+ */
+ void protect();
- /**
- * explicitely release this object to R garbage collection. This
- * calls the R_ReleaseObject function on the underlying SEXP.
- * This is automatically done by the destructor if we protected
- * the SEXP (using the protect member function)
- */
- void release();
+ /**
+ * explicitely release this object to R garbage collection. This
+ * calls the R_ReleaseObject function on the underlying SEXP.
+ * This is automatically done by the destructor if we protected
+ * the SEXP (using the protect member function)
+ */
+ void release();
+
+ /**
+ * implicit conversion to SEXP
+ */
+ inline operator SEXP() const {
+ return m_sexp ;
+ }
- /**
- * implicit conversion to SEXP
- */
- inline operator SEXP() const {
- return m_sexp ;
- }
+
+ /* attributes */
-
- /* attributes */
-
- /**
- * extracts the names of the attributes of the wrapped SEXP
- */
+ /**
+ * extracts the names of the attributes of the wrapped SEXP
+ */
std::vector<std::string> attributeNames() const ;
/**
* Identifies if the SEXP has the given attribute
*/
- bool hasAttribute( const std::string& attr) const ;
+ bool hasAttribute( const std::string& attr) const ;
/**
* extract the given attribute
@@ -136,27 +135,27 @@
}
/**
- * explicit conversion to SEXP
- */
- inline SEXP asSexp() const {
- return m_sexp ;
- }
+ * explicit conversion to SEXP
+ */
+ inline SEXP asSexp() const {
+ return m_sexp ;
+ }
protected:
- /**
- * The SEXP this is wrapping
- */
- SEXP m_sexp ;
+ /**
+ * The SEXP this is wrapping
+ */
+ SEXP m_sexp ;
- /**
- * true if this protects the SEXP from garbage collection
- * using R_ReleaseObject/R_PreserveObject strategy
- *
- * if this is true then the object will be release and become
- * subject to R garbage collection when this object is deleted
- */
- bool isProtected ;
+ /**
+ * true if this protects the SEXP from garbage collection
+ * using R_ReleaseObject/R_PreserveObject strategy
+ *
+ * if this is true then the object will be release and become
+ * subject to R garbage collection when this object is deleted
+ */
+ bool isProtected ;
};
Modified: pkg/src/Rcpp/XPtr.h
===================================================================
--- pkg/src/Rcpp/XPtr.h 2009-12-30 14:40:36 UTC (rev 236)
+++ pkg/src/Rcpp/XPtr.h 2009-12-30 15:56:56 UTC (rev 237)
@@ -29,99 +29,99 @@
template <typename T>
void delete_finalizer(SEXP p){
- if( TYPEOF(p) == EXTPTRSXP ){
- T* ptr = (T*) EXTPTR_PTR(p) ;
- delete ptr ;
- }
+ if( TYPEOF(p) == EXTPTRSXP ){
+ T* ptr = (T*) EXTPTR_PTR(p) ;
+ delete ptr ;
+ }
}
template <typename T>
class XPtr : public RObject {
- public:
+public:
- /**
- * constructs a XPtr wrapping the external pointer (EXTPTRSXP SEXP)
- *
- * @param xp external pointer to wrap
- */
- explicit XPtr(SEXP m_sexp) : RObject::RObject(m_sexp){} ;
+ /**
+ * constructs a XPtr wrapping the external pointer (EXTPTRSXP SEXP)
+ *
+ * @param xp external pointer to wrap
+ */
+ explicit XPtr(SEXP m_sexp) : RObject::RObject(m_sexp){} ;
- /**
- * creates a new external pointer wrapping the dumb pointer p.
- * This calls R_PreserveObject to prevent the external pointer
- * from R garbage collection
- *
- * @param p dumb pointer to some object
- * @param set_delete_finalizer if set to true, a finalizer will
- * be registered for the external pointer. The finalizer
- * is called when the xp is garbage collected. The finalizer
- * is merely a call to the delete operator or the pointer
- * so you need to make sure the pointer can be deleted.
- */
- explicit XPtr(T* p, bool set_delete_finalizer) ;
+ /**
+ * creates a new external pointer wrapping the dumb pointer p.
+ * This calls R_PreserveObject to prevent the external pointer
+ * from R garbage collection
+ *
+ * @param p dumb pointer to some object
+ * @param set_delete_finalizer if set to true, a finalizer will
+ * be registered for the external pointer. The finalizer
+ * is called when the xp is garbage collected. The finalizer
+ * is merely a call to the delete operator or the pointer
+ * so you need to make sure the pointer can be deleted.
+ */
+ explicit XPtr(T* p, bool set_delete_finalizer) ;
- /**
- * Returns a reference to the object wrapped. This allows this
- * object to look and feel like a dumb pointer to T
- */
- T& operator*() const ;
+ /**
+ * Returns a reference to the object wrapped. This allows this
+ * object to look and feel like a dumb pointer to T
+ */
+ T& operator*() const ;
- /**
- * Returns the dumb pointer. This allows to call the -> operator
- * on this as if it was the dumb pointer
- */
- T* operator->() const ;
+ /**
+ * Returns the dumb pointer. This allows to call the -> operator
+ * on this as if it was the dumb pointer
+ */
+ T* operator->() const ;
- /**
- * Returns the 'protected' part of the external pointer, this is
- * the SEXP that is passed in as the third argument of the
- * R_MakeExternalPointer function. See Writing R extensions
- */
- SEXP getProtected() ;
+ /**
+ * Returns the 'protected' part of the external pointer, this is
+ * the SEXP that is passed in as the third argument of the
+ * R_MakeExternalPointer function. See Writing R extensions
+ */
+ SEXP getProtected() ;
- /**
- * Returns the 'tag' part of the external pointer, this is the
- * SEXP that is passed in as the 2nd argument of the
- * R_MakeExternalPointer function. See Writing R extensions
- */
- SEXP getTag() ;
+ /**
+ * Returns the 'tag' part of the external pointer, this is the
+ * SEXP that is passed in as the 2nd argument of the
+ * R_MakeExternalPointer function. See Writing R extensions
+ */
+ SEXP getTag() ;
+
+ void setDeleteFinalizer() ;
- void setDeleteFinalizer() ;
-
};
template<typename T>
XPtr<T>::XPtr(T* p, bool set_delete_finalizer = true) : RObject::RObject() {
- m_sexp = R_MakeExternalPtr( (void*)p , R_NilValue, R_NilValue) ;
- if( set_delete_finalizer ){
- setDeleteFinalizer() ;
- }
- protect() ;
+ m_sexp = R_MakeExternalPtr( (void*)p , R_NilValue, R_NilValue) ;
+ if( set_delete_finalizer ){
+ setDeleteFinalizer() ;
+ }
+ protect() ;
}
template<typename T>
void XPtr<T>::setDeleteFinalizer(){
- R_RegisterCFinalizerEx( m_sexp, delete_finalizer<T> , FALSE) ;
+ R_RegisterCFinalizerEx( m_sexp, delete_finalizer<T> , FALSE) ;
}
template<typename T>
T& XPtr<T>::operator*() const {
- return *((T*)EXTPTR_PTR( m_sexp )) ;
+ return *((T*)EXTPTR_PTR( m_sexp )) ;
}
template<typename T>
T* XPtr<T>::operator->() const {
- return (T*)(EXTPTR_PTR(m_sexp));
+ return (T*)(EXTPTR_PTR(m_sexp));
}
template<typename T>
SEXP XPtr<T>::getProtected(){
- return EXTPTR_PROT(m_sexp) ;
+ return EXTPTR_PROT(m_sexp) ;
}
template<typename T>
SEXP XPtr<T>::getTag(){
- return EXTPTR_TAG(m_sexp) ;
+ return EXTPTR_TAG(m_sexp) ;
}
} // namespace Rcpp
_______________________________________________
Rcpp-commits mailing list
Rcpp-commits at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-commits
More information about the Rcpp-devel
mailing list