Skip to content

Commit 463d4e9

Browse files
committed
Enhance is check for module object
1 parent 9642541 commit 463d4e9

File tree

1 file changed

+4
-1
lines changed
  • inst/include/Rcpp/api/meat

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,13 @@ namespace Rcpp {
150150

151151
inline bool is_module_object_internal(SEXP obj, const char* clazz){
152152
Environment env(obj);
153-
XPtr<class_Base> xp( env.get(".cppclass"));
153+
SEXP sexp = env.get(".cppclass");
154+
if (TYPEOF(sexp) != EXTPTRSXP) return false;
155+
XPtr<class_Base> xp(sexp);
154156
return xp->has_typeinfo_name(clazz);
155157
}
156158
template <typename T> bool is__module__object(SEXP x) {
159+
if (!is__simple<S4>(x)) return false;
157160
typedef typename Rcpp::traits::un_pointer<T>::type CLASS;
158161
return is_module_object_internal(x, typeid(CLASS).name());
159162
}

0 commit comments

Comments
 (0)