The R Project SVN R

Rev

Rev 50690 | Rev 50745 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 50690 Rev 50715
Line 877... Line 877...
877
 
877
 
878
    x = CAR(args);
878
    x = CAR(args);
879
    if(IS_S4_OBJECT(x))
879
    if(IS_S4_OBJECT(x))
880
      return do_S4inherits(x, CADR(args), CADDR(args));
880
      return do_S4inherits(x, CADR(args), CADDR(args));
881
    else
881
    else
882
      klass = R_data_class(x, FALSE);
882
      PROTECT(klass = R_data_class(x, FALSE));
883
    nclass = length(klass);
883
    nclass = length(klass);
884
 
884
 
885
    what = CADR(args);
885
    what = CADR(args);
886
    if(!isString(what))
886
    if(!isString(what))
887
	error(_("'what' must be a character vector"));
887
	error(_("'what' must be a character vector"));
Line 897... Line 897...
897
       !isNull(R_getClassDef(translateChar(STRING_ELT(what, 0)))))
897
       !isNull(R_getClassDef(translateChar(STRING_ELT(what, 0)))))
898
	warning(_("use 'is()' instead of 'inherits()' on S4 objects"));
898
	warning(_("use 'is()' instead of 'inherits()' on S4 objects"));
899
#endif
899
#endif
900
 
900
 
901
    if(isvec)
901
    if(isvec)
902
	rval = allocVector(INTSXP, nwhat);
902
	PROTECT(rval = allocVector(INTSXP, nwhat));
903
 
903
 
904
    for(j = 0; j < nwhat; j++) {
904
    for(j = 0; j < nwhat; j++) {
905
	const char *ss = translateChar(STRING_ELT(what, j));
905
	const char *ss = translateChar(STRING_ELT(what, j));
906
	for(i = 0; i < nclass; i++) {
906
	for(i = 0; i < nclass; i++) {
907
	    if(isvec)
907
	    if(isvec)
908
		INTEGER(rval)[j] = 0;
908
		INTEGER(rval)[j] = 0;
909
	    if(!strcmp(translateChar(STRING_ELT(klass, i)), ss)) {
909
	    if(!strcmp(translateChar(STRING_ELT(klass, i)), ss)) {
910
		if(isvec)
910
		if(isvec)
911
		   INTEGER(rval)[j] = i+1;
911
		   INTEGER(rval)[j] = i+1;
912
		else
912
		else {
-
 
913
		    UNPROTECT(1);
913
		    return mkTrue();
914
		    return mkTrue();
-
 
915
		}
914
		break;
916
		break;
915
	    }
917
	    }
916
	}
918
	}
917
    }
919
    }
918
    if(!isvec)
920
    if(!isvec) {
-
 
921
    	UNPROTECT(1);
919
	return mkFalse();
922
	return mkFalse();
-
 
923
    }
-
 
924
    UNPROTECT(2);
920
    return rval;
925
    return rval;
921
}
926
}
922
 
927
 
923
 
928
 
924
/*
929
/*