The R Project SVN R

Rev

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

Rev 77188 Rev 77242
Line 2288... Line 2288...
2288
 
2288
 
2289
static void default_tryCatch_finally(void *data) { }
2289
static void default_tryCatch_finally(void *data) { }
2290
 
2290
 
2291
static SEXP trycatch_callback = NULL;
2291
static SEXP trycatch_callback = NULL;
2292
static const char* trycatch_callback_source =
2292
static const char* trycatch_callback_source =
2293
    "function(code, conds, fin) {\n"
2293
    "function(addr, classes, fin) {\n"
2294
    "    handler <- function(cond)\n"
2294
    "    handler <- function(cond)\n"
2295
    "        if (inherits(cond, conds))\n"
-
 
2296
    "            .Internal(C_tryCatchHelper(code, 1L, cond))\n"
2295
    "        .Internal(C_tryCatchHelper(addr, 1L, cond))\n"
2297
    "        else\n"
2296
    "    handlers <- rep_len(alist(handler), length(classes))\n"
2298
    "            signalCondition(cond)\n"
2297
    "    names(handlers) <- classes\n"
2299
    "    if (fin)\n"
2298
    "    if (fin)\n"
2300
    "        tryCatch(.Internal(C_tryCatchHelper(code, 0L)),\n"
-
 
2301
    "                 condition = handler,\n"
2299
    "	     handlers <- c(handlers,\n"
2302
    "                 finally = .Internal(C_tryCatchHelper(code, 2L)))\n"
2300
    "            alist(finally = .Internal(C_tryCatchHelper(addr, 2L))))\n"
2303
    "    else\n"
-
 
2304
    "        tryCatch(.Internal(C_tryCatchHelper(code, 0L)),\n"
2301
    "    args <- c(alist(.Internal(C_tryCatchHelper(addr, 0L))), handlers)\n"
2305
    "                 condition = handler)\n"
2302
    "    do.call('tryCatch', args)\n"
2306
    "}";
2303
    "}";
2307
 
2304
 
2308
SEXP R_tryCatch(SEXP (*body)(void *), void *bdata,
2305
SEXP R_tryCatch(SEXP (*body)(void *), void *bdata,
2309
		SEXP conds,
2306
		SEXP conds,
2310
		SEXP (*handler)(SEXP, void *), void *hdata,
2307
		SEXP (*handler)(SEXP, void *), void *hdata,
Line 2327... Line 2324...
2327
	.fdata = fdata,
2324
	.fdata = fdata,
2328
	.suspended = R_interrupts_suspended
2325
	.suspended = R_interrupts_suspended
2329
    };
2326
    };
2330
 
2327
 
2331
    /* Interrupts are suspended while in the infrastructure R code and
2328
    /* Interrupts are suspended while in the infrastructure R code and
2332
       enabled, if the were on entry to R_TryCatch, while calling the
2329
       enabled, if they were on entry to R_TryCatch, while calling the
2333
       body function in do_tryCatchHelper */
2330
       body function in do_tryCatchHelper */
2334
 
2331
 
2335
    R_interrupts_suspended = TRUE;
2332
    R_interrupts_suspended = TRUE;
2336
 
2333
 
2337
    if (conds == NULL) conds = allocVector(STRSXP, 0);
2334
    if (conds == NULL) conds = allocVector(STRSXP, 0);