The R Project SVN R

Rev

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

Rev 76548 Rev 77354
Line 517... Line 517...
517
     Original code by Jean Meloche <jean@stat.ubc.ca> */
517
     Original code by Jean Meloche <jean@stat.ubc.ca> */
518
 
518
 
519
typedef SEXP (*R_ExternalRoutine)(SEXP);
519
typedef SEXP (*R_ExternalRoutine)(SEXP);
520
typedef SEXP (*R_ExternalRoutine2)(SEXP, SEXP, SEXP, SEXP);
520
typedef SEXP (*R_ExternalRoutine2)(SEXP, SEXP, SEXP, SEXP);
521
 
521
 
-
 
522
static void check_retval(SEXP call, SEXP val)
-
 
523
{
-
 
524
    static int inited = FALSE;
-
 
525
    static int check = FALSE;
-
 
526
 
-
 
527
    if (! inited) {
-
 
528
	inited = TRUE;
-
 
529
	const char *p = getenv("_R_CHECK_DOTCODE_RETVAL_");
-
 
530
	if (p != NULL && StringTrue(p))
-
 
531
	    check = TRUE;
-
 
532
    }
-
 
533
 
-
 
534
    if (check) {
-
 
535
	if (val == NULL)
-
 
536
	    errorcall(call, "NULL return value");
-
 
537
	else if (val < (SEXP) 16)
-
 
538
	    errorcall(call, "WEIRD RETURN VALUE");
-
 
539
    }
-
 
540
}
-
 
541
    
522
SEXP attribute_hidden do_External(SEXP call, SEXP op, SEXP args, SEXP env)
542
SEXP attribute_hidden do_External(SEXP call, SEXP op, SEXP args, SEXP env)
523
{
543
{
524
    DL_FUNC ofun = NULL;
544
    DL_FUNC ofun = NULL;
525
    SEXP retval;
545
    SEXP retval;
526
    R_RegisteredNativeSymbol symbol = {R_EXTERNAL_SYM, {NULL}, NULL};
546
    R_RegisteredNativeSymbol symbol = {R_EXTERNAL_SYM, {NULL}, NULL};
Line 546... Line 566...
546
    } else {
566
    } else {
547
	R_ExternalRoutine fun = (R_ExternalRoutine) ofun;
567
	R_ExternalRoutine fun = (R_ExternalRoutine) ofun;
548
	retval = fun(args);
568
	retval = fun(args);
549
    }
569
    }
550
    vmaxset(vmax);
570
    vmaxset(vmax);
-
 
571
    check_retval(call, retval);
551
    return retval;
572
    return retval;
552
}
573
}
553
 
574
 
554
#ifdef __cplusplus
575
#ifdef __cplusplus
555
typedef SEXP (*VarFun)(...);
576
typedef SEXP (*VarFun)(...);
Line 1286... Line 1307...
1286
	    R_Suicide("compiler constants were modified (in .Call?)!\n");
1307
	    R_Suicide("compiler constants were modified (in .Call?)!\n");
1287
	}
1308
	}
1288
	UNPROTECT(nargs + 1);
1309
	UNPROTECT(nargs + 1);
1289
    }
1310
    }
1290
    vmaxset(vmax);
1311
    vmaxset(vmax);
-
 
1312
    check_retval(call, retval);
1291
    return retval;
1313
    return retval;
1292
}
1314
}
1293
 
1315
 
1294
/*  Call dynamically loaded "internal" graphics functions
1316
/*  Call dynamically loaded "internal" graphics functions
1295
    .External.graphics (used in graphics) and  .Call.graphics (used in grid).
1317
    .External.graphics (used in graphics) and  .Call.graphics (used in grid).
Line 1321... Line 1343...
1321
	if (!GEcheckState(dd))
1343
	if (!GEcheckState(dd))
1322
	    errorcall(call, _("invalid graphics state"));
1344
	    errorcall(call, _("invalid graphics state"));
1323
	GErecordGraphicOperation(op, args, dd);
1345
	GErecordGraphicOperation(op, args, dd);
1324
    }
1346
    }
1325
    UNPROTECT(1);
1347
    UNPROTECT(1);
-
 
1348
    check_retval(call, retval);
1326
    return retval;
1349
    return retval;
1327
}
1350
}
1328
 
1351
 
1329
SEXP attribute_hidden do_dotcallgr(SEXP call, SEXP op, SEXP args, SEXP env)
1352
SEXP attribute_hidden do_dotcallgr(SEXP call, SEXP op, SEXP args, SEXP env)
1330
{
1353
{
Line 1338... Line 1361...
1338
	if (!GEcheckState(dd))
1361
	if (!GEcheckState(dd))
1339
	    errorcall(call, _("invalid graphics state"));
1362
	    errorcall(call, _("invalid graphics state"));
1340
	GErecordGraphicOperation(op, args, dd);
1363
	GErecordGraphicOperation(op, args, dd);
1341
    }
1364
    }
1342
    UNPROTECT(1);
1365
    UNPROTECT(1);
-
 
1366
    check_retval(call, retval);
1343
    return retval;
1367
    return retval;
1344
}
1368
}
1345
 
1369
 
1346
static SEXP
1370
static SEXP
1347
Rf_getCallingDLL(void)
1371
Rf_getCallingDLL(void)