The R Project SVN R

Rev

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

Rev 29297 Rev 33817
Line 1... Line 1...
1
#include <Rinternals.h>
1
#include <Rinternals.h>
2
#include "embeddedRCall.h"
2
#include "embeddedRCall.h"
3
 
3
 
4
static void doCtestExample();
4
static void doSplinesExample();
5
static void doMVAExample();
-
 
6
extern int Rf_initEmbeddedR(int argc, char *argv[]);
5
extern int Rf_initEmbeddedR(int argc, char *argv[]);
7
 
6
 
8
 
7
 
9
int
8
int
10
main(int argc, char *argv[])
9
main(int argc, char *argv[])
11
{
10
{
12
  Rf_initEmbeddedR(argc, argv);
11
  Rf_initEmbeddedR(argc, argv);
13
  doCtestExample();
12
  doSplinesExample();
14
  doMVAExample();
-
 
15
  return(0);
13
  return(0);
16
}
14
}
17
 
15
 
18
static void
16
static void
19
doCtestExample()
17
doSplinesExample()
20
{
18
{
21
  SEXP e, tmp;
19
  SEXP e;
22
  int errorOccurred;
20
  int errorOccurred;
23
 
21
 
24
  PROTECT(e = allocVector(LANGSXP, 2));
22
  PROTECT(e = allocVector(LANGSXP, 2));
25
  SETCAR(e, Rf_install("example"));
-
 
26
  SETCAR(CDR(e),  tmp = allocVector(STRSXP, 1));
-
 
27
  SET_STRING_ELT(tmp, 0, mkChar("t.test"));
-
 
28
   
-
 
29
  Test_tryEval(e, &errorOccurred);
-
 
30
 
-
 
31
  UNPROTECT(1);
-
 
32
}
-
 
33
 
-
 
34
static void
-
 
35
doMVAExample()
-
 
36
{
-
 
37
  SEXP e, tmp;
-
 
38
 
-
 
39
  PROTECT(e = allocVector(LANGSXP, 2));
-
 
40
  SETCAR(e, Rf_install("library"));
23
  SETCAR(e, Rf_install("library"));
41
  SETCAR(CDR(e), tmp = allocVector(STRSXP, 1));
24
  SETCAR(CDR(e), mkString("splines"));
42
  SET_STRING_ELT(tmp, 0, mkChar("mva"));
-
 
43
 
25
 
44
  Test_tryEval(e, NULL);
26
  Test_tryEval(e, NULL);
45
  UNPROTECT(1);
27
  UNPROTECT(1);
46
 
28
 
47
  PROTECT(e = allocVector(LANGSXP, 2));
29
  PROTECT(e = allocVector(LANGSXP, 2));
48
  SETCAR(e, Rf_install("example"));
30
  SETCAR(e, Rf_install("example"));
49
  SETCAR(CDR(e),  tmp = allocVector(STRSXP, 1));
31
  SETCAR(CDR(e), mkString("ns"));
50
  SET_STRING_ELT(tmp, 0, mkChar("dist"));
-
 
51
   
32
   
52
  Rf_PrintValue(e);
33
  Test_tryEval(e, &errorOccurred);
53
 
34
 
54
  Test_tryEval(e, NULL);
-
 
55
  UNPROTECT(1);
35
  UNPROTECT(1);
56
}
36
}