File: helperFunctions.R

package info (click to toggle)
r-cran-hdf5r 1.3.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,344 kB
  • sloc: ansic: 85,341; sh: 51; python: 32; makefile: 13
file content (43 lines) | stat: -rwxr-xr-x 1,153 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## function to create the names of objects
r_name <- function(cname) {
    if(length(cname)==0) {
        return(character(0))
    }
    ## check if the name already starts with an underscore
    ## we can't do double underscore as some of those variable names are reserved
    prepend <- rep("R_", length(cname))
    return(paste0(prepend, cname))
}

bool_dupl_name <- function(cname) {
    if(length(cname)==0) {
        return(character(0))
    }
    return(paste0("_dupl_", cname))
}


is_const <- function(type) {
    return(grepl("^const", type, perl=TRUE))
}

make_bare <- function(type) {
    return(gsub("(const\\s+|\\**)", "", type, perl=TRUE))
}

get_ref_depth <- function(type) {
    sapply(regmatches(type, gregexpr("*", type, fixed=TRUE)), length)
}

## names for wrapping and unwrapping structs; will also be used for the union (corner case)
unwrap_struct_func_name <- function(struct_name) {
    return(paste0("SEXP_to_", struct_name))
}

wrap_struct_func_name <- function(struct_name) {
    return(paste0(struct_name, "_to_SEXP"))
}

reset_alt_struct_func_name <- function(struct_name) {
    return(paste0("reset_alt_", struct_name))
}