The R Project SVN R

Rev

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

Rev 10172 Rev 10587
Line 166... Line 166...
166
 
166
 
167
int usemethod(char *generic, SEXP obj, SEXP call, SEXP args,
167
int usemethod(char *generic, SEXP obj, SEXP call, SEXP args,
168
	      SEXP rho, SEXP *ans)
168
	      SEXP rho, SEXP *ans)
169
{
169
{
170
    SEXP class, method, sxp, t, s, matchedarg;
170
    SEXP class, method, sxp, t, s, matchedarg;
171
    SEXP op, formals, newrho, newcall;
171
    SEXP op, formals, newrho, newcall,tmp;
172
    char buf[512];
172
    char buf[512];
173
    int i, j, nclass, matched;
173
    int i, j, nclass, matched;
174
    RCNTXT *cptr;
174
    RCNTXT *cptr;
175
 
175
 
176
    /* Get the context which UseMethod was called from. */
176
    /* Get the context which UseMethod was called from. */
Line 223... Line 223...
223
	nclass = length(class);
223
	nclass = length(class);
224
	for (i = 0; i < nclass; i++) {
224
	for (i = 0; i < nclass; i++) {
225
	    sprintf(buf, "%s.%s", generic, CHAR(STRING_ELT(class, i)));
225
	    sprintf(buf, "%s.%s", generic, CHAR(STRING_ELT(class, i)));
226
	    method = install(buf);
226
	    method = install(buf);
227
	    sxp = findVar(method, rho);
227
	    sxp = findVar(method, rho);
-
 
228
	    /* autoloading requires that promises be evaluated <TSL>*/
-
 
229
	    if (TYPEOF(sxp)==PROMSXP){ 
-
 
230
		PROTECT(tmp=eval(sxp, rho)); 
-
 
231
		sxp=tmp;
-
 
232
		UNPROTECT(1);
-
 
233
	    }
228
	    if (isFunction(sxp)) {
234
	    if (isFunction(sxp)) {
229
		defineVar(install(".Generic"), mkString(generic), newrho);
235
		defineVar(install(".Generic"), mkString(generic), newrho);
230
		if (i > 0) {
236
		if (i > 0) {
231
		    PROTECT(t = allocVector(STRSXP, nclass - i));
237
		    PROTECT(t = allocVector(STRSXP, nclass - i));
232
		    for (j = 0; j < length(t); j++, i++)
238
		    for (j = 0; j < length(t); j++, i++)