[rkward-cvs] SF.net SVN: rkward-code:[4654] trunk/rkward/rkward/rbackend/ rkstructuregetter.cpp

tfry at users.sf.net tfry at users.sf.net
Mon Apr 1 15:40:29 UTC 2013


Revision: 4654
          http://sourceforge.net/p/rkward/code/4654
Author:   tfry
Date:     2013-04-01 15:40:28 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
Make do without R_data_class

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rkstructuregetter.cpp

Modified: trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2013-04-01 15:37:15 UTC (rev 4653)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2013-04-01 15:40:28 UTC (rev 4654)
@@ -193,22 +193,27 @@
 
 	// get classes
 	SEXP classes_s;
+	QStringList classes;
 
 	if ((TYPEOF (value) == LANGSXP) || (TYPEOF (value) == SYMSXP)) {	// if it's a call, we should NEVER send it through eval
-		extern SEXP R_data_class (SEXP, Rboolean);
-		classes_s = R_data_class (value, (Rboolean) 0);
+		// stripped down and adjusted from R_data_class
+		classes = RKRSupport::SEXPToStringList(Rf_getAttrib (value, R_ClassSymbol));
+		if (classes.isEmpty ()) {
+			if (TYPEOF (value) == LANGSXP) {
+				QString cl = RKRSupport::SEXPToString (PRINTNAME (value));
+				if ((cl != "if") && (cl != "while") && (cl != "for") && (cl != "=") && (cl != "<-") && (cl != "(") && (cl != "{")) cl = "call";
+				classes = QStringList (cl);
+			} else {
+				classes = QStringList ("name");
+			}
+		}
 
 		REPROTECT (value = Rf_coerceVector (value, EXPRSXP), value_index);	// make sure the object is safe for everything to come
-
-		PROTECT (classes_s);
 	} else {
 		classes_s = RKRSupport::callSimpleFun (class_fun, value, baseenv);
-		PROTECT (classes_s);
+		classes = RKRSupport::SEXPToStringList (classes_s);
 	}
 
-	QStringList classes = RKRSupport::SEXPToStringList (classes_s);
-	UNPROTECT (1);	/* classes_s */
-
 	// store classes
 	RData *classdata = new RData;
 	classdata->setData (classes);





More information about the rkward-tracker mailing list