This uses uses implicit fortran conventions

gen_registration(pkg_name, fun_list, callEntries = NULL)

Arguments

pkg_name

the package name as character

fun_list

the list of fortran function prototypes, see example

callEntries

a character vector defining code that will be included verbatim that will define the C array CallEntries[], default NULL

Value

lines that can be written into an init file for the package

Examples

## Most common use
fns <- c("subroutine pclasso(no,ni,x,y,w,theta,ng,mg,aa,ne,nx,nlam,ulam,thr,maxit,verbose,ao,ia,kin,nlp,jerr)", "subroutine logpclasso(no,ni,x,y,w,theta,ng,mg,aa,ne,nx,nlam,ulam,thr,maxit,verbose,a0,ao,ia,kin,nlp,jerr)")
# Generate lines that can be written into pcLasso/src/pcLasso_init.c for example
gen_registration("pcLasso", fns)
#> Generating Init function for package pcLasso 
#>   [1] "// Automatically generated by SUtools, editing not advised."                                               
#>   [2] "#ifndef R_PCLASSO_H"                                                                                       
#>   [3] "#define R_PCLASSO_H"                                                                                       
#>   [4] "#include <R.h>"                                                                                            
#>   [5] "#include <Rinternals.h>"                                                                                   
#>   [6] "#include <R_ext/Rdynload.h>"                                                                               
#>   [7] "#ifdef ENABLE_NLS"                                                                                         
#>   [8] "#include <libintl.h>"                                                                                      
#>   [9] "#define _(String) dgettext (\"pcLasso\", String)"                                                          
#>  [10] "#else"                                                                                                     
#>  [11] "#define _(String) (String)"                                                                                
#>  [12] "#endif"                                                                                                    
#>  [13] ""                                                                                                          
#>  [14] ""                                                                                                          
#>  [15] "#define FDEF(name)  {#name, (DL_FUNC) &F77_SUB(name), sizeof(name ## _t)/sizeof(name ## _t[0]), name ##_t}"
#>  [16] "void F77_SUB(pclasso)("                                                                                    
#>  [17] "int *no,"                                                                                                  
#>  [18] "int *ni,"                                                                                                  
#>  [19] "double *x,"                                                                                                
#>  [20] "double *y,"                                                                                                
#>  [21] "double *w,"                                                                                                
#>  [22] "double *theta,"                                                                                            
#>  [23] "int *ng,"                                                                                                  
#>  [24] "int *mg,"                                                                                                  
#>  [25] "double *aa,"                                                                                               
#>  [26] "int *ne,"                                                                                                  
#>  [27] "int *nx,"                                                                                                  
#>  [28] "int *nlam,"                                                                                                
#>  [29] "double *ulam,"                                                                                             
#>  [30] "double *thr,"                                                                                              
#>  [31] "int *maxit,"                                                                                               
#>  [32] "double *verbose,"                                                                                          
#>  [33] "double *ao,"                                                                                               
#>  [34] "int *ia,"                                                                                                  
#>  [35] "int *kin,"                                                                                                 
#>  [36] "int *nlp,"                                                                                                 
#>  [37] "int *jerr"                                                                                                 
#>  [38] ");"                                                                                                        
#>  [39] " "                                                                                                         
#>  [40] "static R_NativePrimitiveArgType pclasso_t[] = {"                                                           
#>  [41] "INTSXP,"                                                                                                   
#>  [42] "INTSXP,"                                                                                                   
#>  [43] "REALSXP,"                                                                                                  
#>  [44] "REALSXP,"                                                                                                  
#>  [45] "REALSXP,"                                                                                                  
#>  [46] "REALSXP,"                                                                                                  
#>  [47] "INTSXP,"                                                                                                   
#>  [48] "INTSXP,"                                                                                                   
#>  [49] "REALSXP,"                                                                                                  
#>  [50] "INTSXP,"                                                                                                   
#>  [51] "INTSXP,"                                                                                                   
#>  [52] "INTSXP,"                                                                                                   
#>  [53] "REALSXP,"                                                                                                  
#>  [54] "REALSXP,"                                                                                                  
#>  [55] "INTSXP,"                                                                                                   
#>  [56] "REALSXP,"                                                                                                  
#>  [57] "REALSXP,"                                                                                                  
#>  [58] "INTSXP,"                                                                                                   
#>  [59] "INTSXP,"                                                                                                   
#>  [60] "INTSXP,"                                                                                                   
#>  [61] "INTSXP"                                                                                                    
#>  [62] "};"                                                                                                        
#>  [63] "void F77_SUB(logpclasso)("                                                                                 
#>  [64] "int *no,"                                                                                                  
#>  [65] "int *ni,"                                                                                                  
#>  [66] "double *x,"                                                                                                
#>  [67] "double *y,"                                                                                                
#>  [68] "double *w,"                                                                                                
#>  [69] "double *theta,"                                                                                            
#>  [70] "int *ng,"                                                                                                  
#>  [71] "int *mg,"                                                                                                  
#>  [72] "double *aa,"                                                                                               
#>  [73] "int *ne,"                                                                                                  
#>  [74] "int *nx,"                                                                                                  
#>  [75] "int *nlam,"                                                                                                
#>  [76] "double *ulam,"                                                                                             
#>  [77] "double *thr,"                                                                                              
#>  [78] "int *maxit,"                                                                                               
#>  [79] "double *verbose,"                                                                                          
#>  [80] "double *a0,"                                                                                               
#>  [81] "double *ao,"                                                                                               
#>  [82] "int *ia,"                                                                                                  
#>  [83] "int *kin,"                                                                                                 
#>  [84] "int *nlp,"                                                                                                 
#>  [85] "int *jerr"                                                                                                 
#>  [86] ");"                                                                                                        
#>  [87] " "                                                                                                         
#>  [88] "static R_NativePrimitiveArgType logpclasso_t[] = {"                                                        
#>  [89] "INTSXP,"                                                                                                   
#>  [90] "INTSXP,"                                                                                                   
#>  [91] "REALSXP,"                                                                                                  
#>  [92] "REALSXP,"                                                                                                  
#>  [93] "REALSXP,"                                                                                                  
#>  [94] "REALSXP,"                                                                                                  
#>  [95] "INTSXP,"                                                                                                   
#>  [96] "INTSXP,"                                                                                                   
#>  [97] "REALSXP,"                                                                                                  
#>  [98] "INTSXP,"                                                                                                   
#>  [99] "INTSXP,"                                                                                                   
#> [100] "INTSXP,"                                                                                                   
#> [101] "REALSXP,"                                                                                                  
#> [102] "REALSXP,"                                                                                                  
#> [103] "INTSXP,"                                                                                                   
#> [104] "REALSXP,"                                                                                                  
#> [105] "REALSXP,"                                                                                                  
#> [106] "REALSXP,"                                                                                                  
#> [107] "INTSXP,"                                                                                                   
#> [108] "INTSXP,"                                                                                                   
#> [109] "INTSXP,"                                                                                                   
#> [110] "INTSXP"                                                                                                    
#> [111] "};"                                                                                                        
#> [112] ""                                                                                                          
#> [113] "static R_FortranMethodDef fMethods[] = {"                                                                  
#> [114] "FDEF(pclasso) ,"                                                                                           
#> [115] "FDEF(logpclasso) ,"                                                                                        
#> [116] "{NULL, NULL, 0}"                                                                                           
#> [117] "};"                                                                                                        
#> [118] ""                                                                                                          
#> [119] "void R_init_pcLasso(DllInfo *dll){"                                                                        
#> [120] "  R_registerRoutines(dll, NULL, NULL, fMethods, NULL);"                                                    
#> [121] "  R_useDynamicSymbols(dll, FALSE);"                                                                        
#> [122] "}"                                                                                                         
#> [123] "#endif"                                                                                                    

## Example using callEntries
callEntries <- c(
  'extern SEXP store_rfun(SEXP rfun);',
  'static const R_CallMethodDef CallEntries[] = {',
     '{"store_rfun", (DL_FUNC) &store_rfun, 1}',
     '{NULL, NULL, 0}',
  '};')
gen_registration("pcLasso", fns, callEntries = callEntries)
#> Generating Init function for package pcLasso 
#>   [1] "// Automatically generated by SUtools, editing not advised."                                               
#>   [2] "#ifndef R_PCLASSO_H"                                                                                       
#>   [3] "#define R_PCLASSO_H"                                                                                       
#>   [4] "#include <R.h>"                                                                                            
#>   [5] "#include <Rinternals.h>"                                                                                   
#>   [6] "#include <R_ext/Rdynload.h>"                                                                               
#>   [7] "#ifdef ENABLE_NLS"                                                                                         
#>   [8] "#include <libintl.h>"                                                                                      
#>   [9] "#define _(String) dgettext (\"pcLasso\", String)"                                                          
#>  [10] "#else"                                                                                                     
#>  [11] "#define _(String) (String)"                                                                                
#>  [12] "#endif"                                                                                                    
#>  [13] ""                                                                                                          
#>  [14] "extern SEXP store_rfun(SEXP rfun);"                                                                        
#>  [15] "static const R_CallMethodDef CallEntries[] = {"                                                            
#>  [16] "{\"store_rfun\", (DL_FUNC) &store_rfun, 1}"                                                                
#>  [17] "{NULL, NULL, 0}"                                                                                           
#>  [18] "};"                                                                                                        
#>  [19] ""                                                                                                          
#>  [20] "#define FDEF(name)  {#name, (DL_FUNC) &F77_SUB(name), sizeof(name ## _t)/sizeof(name ## _t[0]), name ##_t}"
#>  [21] "void F77_SUB(pclasso)("                                                                                    
#>  [22] "int *no,"                                                                                                  
#>  [23] "int *ni,"                                                                                                  
#>  [24] "double *x,"                                                                                                
#>  [25] "double *y,"                                                                                                
#>  [26] "double *w,"                                                                                                
#>  [27] "double *theta,"                                                                                            
#>  [28] "int *ng,"                                                                                                  
#>  [29] "int *mg,"                                                                                                  
#>  [30] "double *aa,"                                                                                               
#>  [31] "int *ne,"                                                                                                  
#>  [32] "int *nx,"                                                                                                  
#>  [33] "int *nlam,"                                                                                                
#>  [34] "double *ulam,"                                                                                             
#>  [35] "double *thr,"                                                                                              
#>  [36] "int *maxit,"                                                                                               
#>  [37] "double *verbose,"                                                                                          
#>  [38] "double *ao,"                                                                                               
#>  [39] "int *ia,"                                                                                                  
#>  [40] "int *kin,"                                                                                                 
#>  [41] "int *nlp,"                                                                                                 
#>  [42] "int *jerr"                                                                                                 
#>  [43] ");"                                                                                                        
#>  [44] " "                                                                                                         
#>  [45] "static R_NativePrimitiveArgType pclasso_t[] = {"                                                           
#>  [46] "INTSXP,"                                                                                                   
#>  [47] "INTSXP,"                                                                                                   
#>  [48] "REALSXP,"                                                                                                  
#>  [49] "REALSXP,"                                                                                                  
#>  [50] "REALSXP,"                                                                                                  
#>  [51] "REALSXP,"                                                                                                  
#>  [52] "INTSXP,"                                                                                                   
#>  [53] "INTSXP,"                                                                                                   
#>  [54] "REALSXP,"                                                                                                  
#>  [55] "INTSXP,"                                                                                                   
#>  [56] "INTSXP,"                                                                                                   
#>  [57] "INTSXP,"                                                                                                   
#>  [58] "REALSXP,"                                                                                                  
#>  [59] "REALSXP,"                                                                                                  
#>  [60] "INTSXP,"                                                                                                   
#>  [61] "REALSXP,"                                                                                                  
#>  [62] "REALSXP,"                                                                                                  
#>  [63] "INTSXP,"                                                                                                   
#>  [64] "INTSXP,"                                                                                                   
#>  [65] "INTSXP,"                                                                                                   
#>  [66] "INTSXP"                                                                                                    
#>  [67] "};"                                                                                                        
#>  [68] "void F77_SUB(logpclasso)("                                                                                 
#>  [69] "int *no,"                                                                                                  
#>  [70] "int *ni,"                                                                                                  
#>  [71] "double *x,"                                                                                                
#>  [72] "double *y,"                                                                                                
#>  [73] "double *w,"                                                                                                
#>  [74] "double *theta,"                                                                                            
#>  [75] "int *ng,"                                                                                                  
#>  [76] "int *mg,"                                                                                                  
#>  [77] "double *aa,"                                                                                               
#>  [78] "int *ne,"                                                                                                  
#>  [79] "int *nx,"                                                                                                  
#>  [80] "int *nlam,"                                                                                                
#>  [81] "double *ulam,"                                                                                             
#>  [82] "double *thr,"                                                                                              
#>  [83] "int *maxit,"                                                                                               
#>  [84] "double *verbose,"                                                                                          
#>  [85] "double *a0,"                                                                                               
#>  [86] "double *ao,"                                                                                               
#>  [87] "int *ia,"                                                                                                  
#>  [88] "int *kin,"                                                                                                 
#>  [89] "int *nlp,"                                                                                                 
#>  [90] "int *jerr"                                                                                                 
#>  [91] ");"                                                                                                        
#>  [92] " "                                                                                                         
#>  [93] "static R_NativePrimitiveArgType logpclasso_t[] = {"                                                        
#>  [94] "INTSXP,"                                                                                                   
#>  [95] "INTSXP,"                                                                                                   
#>  [96] "REALSXP,"                                                                                                  
#>  [97] "REALSXP,"                                                                                                  
#>  [98] "REALSXP,"                                                                                                  
#>  [99] "REALSXP,"                                                                                                  
#> [100] "INTSXP,"                                                                                                   
#> [101] "INTSXP,"                                                                                                   
#> [102] "REALSXP,"                                                                                                  
#> [103] "INTSXP,"                                                                                                   
#> [104] "INTSXP,"                                                                                                   
#> [105] "INTSXP,"                                                                                                   
#> [106] "REALSXP,"                                                                                                  
#> [107] "REALSXP,"                                                                                                  
#> [108] "INTSXP,"                                                                                                   
#> [109] "REALSXP,"                                                                                                  
#> [110] "REALSXP,"                                                                                                  
#> [111] "REALSXP,"                                                                                                  
#> [112] "INTSXP,"                                                                                                   
#> [113] "INTSXP,"                                                                                                   
#> [114] "INTSXP,"                                                                                                   
#> [115] "INTSXP"                                                                                                    
#> [116] "};"                                                                                                        
#> [117] ""                                                                                                          
#> [118] "static R_FortranMethodDef fMethods[] = {"                                                                  
#> [119] "FDEF(pclasso) ,"                                                                                           
#> [120] "FDEF(logpclasso) ,"                                                                                        
#> [121] "{NULL, NULL, 0}"                                                                                           
#> [122] "};"                                                                                                        
#> [123] ""                                                                                                          
#> [124] "void R_init_pcLasso(DllInfo *dll){"                                                                        
#> [125] "  R_registerRoutines(dll, NULL, callEntries, fMethods, NULL);"                                             
#> [126] "  R_useDynamicSymbols(dll, FALSE);"                                                                        
#> [127] "}"                                                                                                         
#> [128] "#endif"