The R Project SVN R

Rev

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

Rev 35948 Rev 36047
Line 83... Line 83...
83
   a) a string,
83
   a) a string,
84
   b) an external pointer giving the address of the routine
84
   b) an external pointer giving the address of the routine
85
      (e.g. getNativeSymbolInfo("foo")$address)
85
      (e.g. getNativeSymbolInfo("foo")$address)
86
   c) or a NativeSymbolInfo itself  (e.g. getNativeSymbolInfo("foo"))
86
   c) or a NativeSymbolInfo itself  (e.g. getNativeSymbolInfo("foo"))
87
 
87
 
88
   NB: in the last two cases it set fun as well!
88
   NB: in the last two cases it sets fun as well!
89
 */
89
 */
90
static void
90
static void
91
checkValidSymbolId(SEXP op, SEXP call, DL_FUNC *fun)
91
checkValidSymbolId(SEXP op, SEXP call, DL_FUNC *fun)
92
{
92
{
93
    if (isValidString(op)) return;
93
    if (isValidString(op)) return;
Line 701... Line 701...
701
}
701
}
702
 
702
 
703
SEXP do_isloaded(SEXP call, SEXP op, SEXP args, SEXP env)
703
SEXP do_isloaded(SEXP call, SEXP op, SEXP args, SEXP env)
704
{
704
{
705
    SEXP ans;
705
    SEXP ans;
706
    char *sym, *pkg= "";
706
    char *sym, *pkg= "", *type="";
707
    int val = 1, nargs = length(args);
707
    int val = 1, nargs = length(args);
-
 
708
    R_RegisteredNativeSymbol symbol = {R_FORTRAN_SYM, {NULL}, NULL};
708
 
709
 
709
    if (nargs < 1) errorcall(call, _("no arguments supplied"));
710
    if (nargs < 1) errorcall(call, _("no arguments supplied"));
710
    if (nargs > 2) errorcall(call, _("too many arguments"));
711
    if (nargs > 3) errorcall(call, _("too many arguments"));
711
 
712
 
712
    if(!isValidString(CAR(args)))
713
    if(!isValidString(CAR(args)))
713
	errorcall(call, R_MSG_IA);
714
	errorcall(call, R_MSG_IA);
714
    sym = CHAR(STRING_ELT(CAR(args), 0));
715
    sym = CHAR(STRING_ELT(CAR(args), 0));
715
    if(nargs == 2) {
716
    if(nargs >= 2) {
716
	if(!isValidString(CADR(args)))
717
	if(!isValidString(CADR(args)))
717
	    errorcall(call, R_MSG_IA);
718
	    errorcall(call, R_MSG_IA);
718
	pkg = CHAR(STRING_ELT(CADR(args), 0));
719
	pkg = CHAR(STRING_ELT(CADR(args), 0));
719
    }
720
    }
-
 
721
    if(nargs >= 3) {
-
 
722
	if(!isValidString(CADDR(args)))
-
 
723
	    errorcall(call, R_MSG_IA);
-
 
724
	type = CHAR(STRING_ELT(CADDR(args), 0));
-
 
725
	if(strcmp(type, "C") == 0) symbol.type = R_C_SYM;
-
 
726
	else if(strcmp(type, "Fortran") == 0) symbol.type = R_FORTRAN_SYM;
-
 
727
	else if(strcmp(type, "Call") == 0) symbol.type = R_CALL_SYM;
-
 
728
	else if(strcmp(type, "External") == 0) symbol.type = R_EXTERNAL_SYM;
-
 
729
    }
-
 
730
    if(strlen(type)) {
-
 
731
	if(!(R_FindSymbol(sym, pkg, &symbol))) val = 0;
-
 
732
    } else {
-
 
733
	if (!(R_FindSymbol(sym, pkg, NULL)) && 
720
    if (!(R_FindSymbol(sym, pkg, NULL))) val = 0;
734
	    !(R_FindSymbol(sym, pkg, &symbol))) val = 0;
-
 
735
    }
721
    ans = allocVector(LGLSXP, 1);
736
    ans = allocVector(LGLSXP, 1);
722
    LOGICAL(ans)[0] = val;
737
    LOGICAL(ans)[0] = val;
723
    return ans;
738
    return ans;
724
}
739
}
725
 
740