@@ -73,20 +73,21 @@ deepstate_fun_create<-function(package_path,function_name,sep="infun"){
7373 comment <- paste0(" // AUTOMATICALLY GENERATED BY RCPPDEEPSTATE PLEASE DO NOT EDIT BY HAND, INSTEAD EDIT\n // " ,
7474 fun_name ," _DeepState_TestHarness_generation.cpp and " ,fun_name ," _DeepState_TestHarness_checks.cpp\n\n " )
7575
76- # write_to_file <-
7776 if (sep == " generation" || sep == " checks" ){
7877 write(headers ,file_path ,append = TRUE )
7978 }else {
8079 write(paste0(write_to_file ,comment ,headers ),file_path ,append = TRUE )
8180 }
81+
82+ write_to_file <- paste0(write_to_file ," RInside Rinstance;\n " ); # create a single RInside instance at the beginning
8283 write_to_file <- paste0(write_to_file ,pt [1 ,pt $ prototype ]," \n " )
8384 testname <- gsub(" ." ," " ,paste0(function_name ," _test" ,sep = " " ))
8485 unittest <- gsub(" ." ," " ,paste0(packagename ," _deepstate_test" ))
8586 write_to_file <- paste0(write_to_file ," \n " ," TEST(" ,unittest ," ," ,testname ," )" ," {" ," \n " )
8687 # obj <-gsub( "\\s+", " " ,paste(in_package,tolower(in_package),";","\n"))
8788 # write(obj,filename,append = TRUE)
8889 indent <- " "
89- write_to_file <- paste0(write_to_file ,indent ," RInside R; \n " , indent , " std::cout << #input starts# << std::endl;\n " )
90+ write_to_file <- paste0(write_to_file ,indent ," std::cout << #input starts# << std::endl;\n " )
9091 proto_args <- " "
9192 for (argument.i in 1 : nrow(functions.rows )){
9293 arg.type <- gsub(" " ," " ,functions.rows [argument.i ,argument.type ])
0 commit comments