| 7747 |
ripley |
1 |
library(RGCCTranslationUnit)
|
|
|
2 |
curl.h = "/usr/local/include/curl/curl.h"
|
|
|
3 |
cpp = getCppDefines(curl.h)
|
|
|
4 |
defs = RGCCTranslationUnit:::processDefines(cpp, tu = tu, filter = NULL)
|
|
|
5 |
i = grep("CURLAUTH", names(defs$macros))
|
|
|
6 |
auth = defs$macros[i]
|
|
|
7 |
cat("#include <curl/curl.h>",
|
|
|
8 |
"#include <Rdefines.h>",
|
|
|
9 |
"SEXP R_getAuthValues()", "{",
|
|
|
10 |
sprintf("\tSEXP ans = NEW_NUMERIC(%d);", length(auth)),
|
|
|
11 |
"\tint i = 0;",
|
|
|
12 |
sprintf("\tREAL(ans)[i++] = %s;", names(auth)),
|
|
|
13 |
"\treturn(ans);",
|
|
|
14 |
"}", sep = '\n', file = "auth.c")
|
|
|
15 |
system("make auth.so")
|
|
|
16 |
dyn.load("auth.so")
|
|
|
17 |
vals = structure(.Call("R_getAuthValues"), names = names(auth))
|
|
|
18 |
|
|
|
19 |
con = textConnection("foo", 'w', local = TRUE)
|
|
|
20 |
dput(vals, con)
|
|
|
21 |
def = textConnectionValue(con)
|
|
|
22 |
close(con)
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
# Add this to 'setClass("CURLAuth", contains = "BitwiseValue")',
|
|
|
26 |
# bitClasses.R.
|
|
|
27 |
# We get a warning
|
|
|
28 |
# class "CURLAuth" is inheriting an inconsistent superclass structure from class "BitwiseValue", inconsistent with "SymbolicConstant"
|
|
|
29 |
# if we define the class CURLAuth after we source() xbits.R
|
|
|
30 |
code =
|
|
|
31 |
c(# 'setClass("CURLAuth", contains = "BitwiseValue")',
|
|
|
32 |
paste('CURLAUTHValues =', paste(def, collapse = " ")),
|
|
|
33 |
mapply(function(shortName, name, val)
|
|
|
34 |
sprintf("%s <- %s <- BitwiseValue(%s, '%s', 'CURLAuth')",
|
|
|
35 |
shortName, name, as.character(val), name),
|
|
|
36 |
gsub("^CURL", "", names(vals)), names(vals), vals)
|
|
|
37 |
)
|
|
|
38 |
|
|
|
39 |
cat(code, file = "../R/curlAuthConstants.R", sep = "\n")
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|