├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── INSTALL ├── NAMESPACE ├── NEWS ├── R ├── 00classDefinitions.R ├── rClr-exported.R ├── rClr-internal.R ├── rClr-package.r └── zzz.R ├── README.md ├── cleanup ├── cleanup.win ├── configure ├── configure.win ├── inst └── extras │ └── performance_profiling.r ├── man ├── clrCall.Rd ├── clrCallStatic.Rd ├── clrCobj.Rd ├── clrGet.Rd ├── clrGetConstructors.Rd ├── clrGetEnumNames.Rd ├── clrGetExtPtr.Rd ├── clrGetFields.Rd ├── clrGetInnerPkgName.Rd ├── clrGetLoadedAssemblies.Rd ├── clrGetMemberSignature.Rd ├── clrGetMethods.Rd ├── clrGetNativeLibName.Rd ├── clrGetProperties.Rd ├── clrGetStaticFields.Rd ├── clrGetStaticMemberSignature.Rd ├── clrGetStaticMembers.Rd ├── clrGetStaticMethods.Rd ├── clrGetStaticProperties.Rd ├── clrGetType.Rd ├── clrGetTypesInAssembly.Rd ├── clrInit.Rd ├── clrIs.Rd ├── clrLoadAssembly.Rd ├── clrNew.Rd ├── clrReflect.Rd ├── clrSet.Rd ├── clrSetEnumProperty.Rd ├── clrShutdown.Rd ├── clrToString.Rd ├── clrTraceback.Rd ├── clrTypeNameExtPtr.Rd ├── clrTypename.Rd ├── clrVT.Rd ├── dotOnAttach.Rd ├── dotOnLoad.Rd ├── getClrVersionString.Rd ├── getCurrentConvertedObject.Rd ├── getNativeLibsPath.Rd ├── getSexpType.Rd ├── inspectArgs.Rd ├── mkClrObjRef.Rd ├── peekClrArgs.Rd ├── rClr-package.Rd ├── rToClrType.Rd ├── setClrRefClass.Rd ├── setConvertAdvancedTypes.Rd └── setRDotNet.Rd ├── src ├── ClrFacade │ ├── ClassDiagram.cd │ ├── ClrFacade.cs │ ├── ClrFacade.csproj │ ├── DataConversionHelper.cs │ ├── DataConverterExtensions.cs │ ├── HelloWorld.cs │ ├── IDataConverter.cs │ ├── PerformanceProfiling.cs │ ├── RDotNetDataConverter.cs │ ├── RclrBinder.cs │ ├── RclrUnmanagedDll.cs │ ├── RdotnetDataConverterTests.cs │ ├── ReflectionHelper.cs │ ├── TestArrayMemoryHandling.cs │ ├── TestArrayMemoryHandling.tt │ ├── TestCases.cs │ ├── TestClassesDiagram.cd │ ├── TestMethodBinding.cs │ ├── TestMethodBinding.tt │ ├── Tests │ │ ├── RefClasses │ │ │ ├── BaseAbstractClassOne.cs │ │ │ ├── InterfaceOne.cs │ │ │ ├── LevelOneClass.cs │ │ │ ├── LevelThreeClass.cs │ │ │ └── LevelTwoClass.cs │ │ └── TestUtilities.cs │ └── app.config ├── Makefile.win.in ├── Makevars.in ├── R.def ├── RDotNetDataConverter │ └── DummyApp │ │ ├── AssemblyInfo.cs │ │ ├── DummyApp.csproj │ │ └── Main.cs ├── RclrTests │ ├── RclrTests.csproj │ ├── RdotnetTests.cs │ ├── ReflectionTests.cs │ ├── TestApp │ │ ├── Program.cs │ │ ├── TestApp.csproj │ │ └── packages.config │ ├── TestMethodBindings.cs │ └── TestMethodBindings.tt ├── create_lib.cmd ├── get_monosdk.cmd ├── get_msbuildpath.cmd ├── get_winsdk.cmd ├── mono.def ├── rClr-Cpp.sln ├── rClr-Cs.sln ├── rClr-mono.def ├── rClr-win.def ├── rClr.cpp ├── rClr.h ├── rClr.props.in ├── rClr.sln ├── rClr.vcxproj ├── rClr_monodev.sln ├── rdotnet │ └── Readme.txt ├── setup_vcpp.cmd ├── testrdn.sln └── win_cp.cmd ├── tests ├── testthat.R └── testthat │ ├── datetime-functions.r │ ├── load_libs.r │ ├── test-basic.r │ ├── test-datetime.r │ └── test-objwrap.r └── vignettes ├── rclr_intro.Rmd ├── rclr_techdoc.Rmd └── rclr_troubleshooting.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | .*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.RData$ 4 | ^\.gitignore$ 5 | ^\.git/ 6 | .*\.gitignore 7 | .*\.git 8 | .*\.tlog 9 | .*\.ilk 10 | .*\.exp 11 | .*\.idb 12 | .*\.obj 13 | .*\.sdf 14 | .*\.suo 15 | .*ipch.* 16 | .*\.lastbuildstate 17 | .*\.intermediate\..* 18 | .*/Debug/.* 19 | .*/Release/.* 20 | .*/MonoDebug/.* 21 | .*/MonoInstallDebug/.* 22 | .*/MonoInstall/.* 23 | .*/bin/.* 24 | .*/obj/.* 25 | .*src/packages/.* 26 | .*src/libfiles/.* 27 | .*src/rClr.opensdf 28 | ./src/RclrTests/bin 29 | ./src/RclrTests/obj/.* 30 | ./inst/libs/.* 31 | .*/.vs/.* 32 | ./src/.vs/.* 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Nuget integration - need to override file ignore patterns 2 | !src/.nuget/*.* 3 | 4 | 5 | 6 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 7 | [Bb]in/ 8 | [Oo]bj/ 9 | 10 | # mstest test results 11 | TestResults 12 | 13 | ## Ignore Visual Studio temporary files, build results, and 14 | ## files generated by popular Visual Studio add-ons. 15 | 16 | # J-M added from prior .hgignore 17 | *.rds 18 | *.FileListAbsolute.txt 19 | *.bak 20 | *.exp 21 | *.dll.mdb 22 | *.pdb 23 | *.suo 24 | *.lastbuildstate 25 | # tarballs for coverity and R CMD build 26 | *.tar.gz 27 | *.tgz 28 | *.zip 29 | *.rds 30 | *.FileListAbsolute.txt 31 | *TemporaryGeneratedFile* 32 | *rClr.Rcheck* 33 | *.tlog 34 | */obj/* 35 | */bin/* 36 | */Debug/* 37 | */Mono*/* 38 | *_ReSharper* 39 | *.ipch 40 | *.opensdf 41 | *sdf 42 | */src-i386/* 43 | */src-x64/* 44 | # Coverity scan folder (customizable - may need change) 45 | */cov-int/* 46 | 47 | # the .win and .props files in rClr are generated from .in files. 48 | *.win 49 | *.props 50 | 51 | # User-specific files 52 | *.suo 53 | *.user 54 | *.userprefs 55 | *.sln.docstates 56 | 57 | # Build results 58 | [Dd]ebug/ 59 | [Rr]elease/ 60 | x64/ 61 | *_i.c 62 | *_p.c 63 | *.ilk 64 | *.meta 65 | *.obj 66 | *.pch 67 | *.pdb 68 | *.pgc 69 | *.pgd 70 | *.rsp 71 | *.sbr 72 | *.tlb 73 | *.tli 74 | *.tlh 75 | *.tmp 76 | *.log 77 | *.vspscc 78 | *.vssscc 79 | .builds 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | 88 | # Visual Studio profiler 89 | *.psess 90 | *.vsp 91 | *.vspx 92 | 93 | # Guidance Automation Toolkit 94 | *.gpState 95 | 96 | 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper* 100 | 101 | # NCrunch 102 | *.ncrunch* 103 | .*crunch*.local.xml 104 | 105 | # Installshield output folder 106 | [Ee]xpress 107 | 108 | # DocProject is a documentation generator add-in 109 | DocProject/buildhelp/ 110 | DocProject/Help/*.HxT 111 | DocProject/Help/*.HxC 112 | DocProject/Help/*.hhc 113 | DocProject/Help/*.hhk 114 | DocProject/Help/*.hhp 115 | DocProject/Help/Html2 116 | DocProject/Help/html 117 | 118 | # Click-Once directory 119 | publish 120 | 121 | # Publish Web Output 122 | *.Publish.xml 123 | 124 | # NuGet Packages Directory 125 | packages 126 | 127 | # Windows Azure Build Output 128 | csx 129 | *.build.csdef 130 | 131 | # Windows Store app package directory 132 | AppPackages/ 133 | 134 | # Others 135 | [Bb]in 136 | [Oo]bj 137 | sql 138 | TestResults 139 | [Tt]est[Rr]esult* 140 | *.Cache 141 | ClientBin 142 | [Ss]tyle[Cc]op.* 143 | ~$* 144 | *.dbmdl 145 | Generated_Code #added for RIA/Silverlight projects 146 | 147 | # Backup & report files from converting an old project file to a newer 148 | # Visual Studio version. Backup files are not needed, because we have git ;-) 149 | _UpgradeReport_Files/ 150 | Backup*/ 151 | UpgradeLog*.XML 152 | 153 | 154 | src/\.vs/ 155 | \.vs/ 156 | \.vscode/ 157 | src/libfiles 158 | 159 | inst/libs/*.* 160 | inst/libs/i386/*.* 161 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: rClr 2 | Type: Package 3 | Title: Accessing the Common Language Runtime (.NET/Mono) from R 4 | Version: 0.8.3 5 | Date: 2019-05-09 6 | Authors@R: c( person("Jean-Michel", "Perraud", email = 7 | "jean-michel.perraud@csiro.au", role = c("aut", "cre"))) 8 | Author: Jean-Michel Perraud [aut, cre], Kosei Abe, [aut] (R.NET), Nigel 9 | [ctb] (fix for 10 | finding the path to package libraries), R Core team [ctb] (showArgs 11 | extracted from R extension manual) 12 | Maintainer: J-M 13 | Description: rClr is a package for low-level access from R to a Common Language 14 | Runtime (CLR). The supported CLR implementations are Microsoft '.NET' 15 | framework on Windows and Mono on several platforms, currently Windows and 16 | at least Debian Linux. rClr has been used at least in scientific modelling 17 | work since 2013-06. Running it on Mono has been relatively experimental, 18 | but as of November 2014 several factors have enabled very near functional 19 | parity with the Windows/.NET. 20 | VignetteBuilder: knitr 21 | Suggests: 22 | testthat, 23 | knitr, 24 | xtable 25 | URL: https://github.com/jmp75/rClr 26 | License: LGPL-3 27 | Depends: 28 | R (>= 2.15.0), 29 | methods 30 | RoxygenNote: 6.1.1 31 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Requirements 3 | ------------ 4 | 5 | * On Windows you must have the RTools installed, see the R extensions manual 6 | * You need at least one of: 7 | ** Visual Studio 2013 (Express for Windows, or the full version), with the C# and C++ compilers installed. 8 | ** A recent Mono installation (www.mono-project.com). As of 2014-04 the latest 3.2.x or 3.4.x series is recommended 9 | 10 | Instructions 11 | ------------- 12 | 13 | 14 | "cmd" 15 | ``` 16 | set R="c:\Program Files\R\R-3.0.1\bin\x64\R.exe" 17 | 18 | set BuildConfiguration=Debug 19 | set MonoBuildConfiguration=MonoInstallDebug 20 | :: or 21 | set BuildConfiguration=Release 22 | set MonoBuildConfiguration=MonoInstall 23 | 24 | %R% CMD check rClr 25 | %R% CMD REMOVE rClr 26 | %R% CMD INSTALL rClr 27 | :: or if you encounter some issues when testing the load, you may bypass it with 28 | %R% CMD INSTALL --no-test-load rClr 29 | ``` 30 | 31 | 32 | Instructions for releases (to update the documentation) 33 | 34 | ``` 35 | library(rClr) 36 | perfMeasureFile <- list.files(system.file("tests", package = "rClr"), pattern = "performance_profiling", 37 | full.names = TRUE) 38 | stopifnot(file.exists(perfMeasureFile)) 39 | source(perfMeasureFile) 40 | library(rClrDevtools) # https://github.com/jmp75/rClr-devtools 41 | # rClrDevtools::roxyRclr() 42 | rClrDevtools::vignettesRclr() 43 | ``` 44 | 45 | Then rebuild/reinstall the package. 46 | 47 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(clrCall) 4 | export(clrCallStatic) 5 | export(clrGet) 6 | export(clrGetConstructors) 7 | export(clrGetEnumNames) 8 | export(clrGetExtPtr) 9 | export(clrGetFields) 10 | export(clrGetInnerPkgName) 11 | export(clrGetLoadedAssemblies) 12 | export(clrGetMemberSignature) 13 | export(clrGetMethods) 14 | export(clrGetNativeLibName) 15 | export(clrGetProperties) 16 | export(clrGetStaticFields) 17 | export(clrGetStaticMemberSignature) 18 | export(clrGetStaticMembers) 19 | export(clrGetStaticMethods) 20 | export(clrGetStaticProperties) 21 | export(clrGetType) 22 | export(clrGetTypesInAssembly) 23 | export(clrIs) 24 | export(clrLoadAssembly) 25 | export(clrNew) 26 | export(clrReflect) 27 | export(clrSet) 28 | export(clrSetEnumProperty) 29 | export(clrShutdown) 30 | export(clrToString) 31 | export(clrTraceback) 32 | export(clrTypeNameExtPtr) 33 | export(clrTypename) 34 | export(clrVT) 35 | export(getClrVersionString) 36 | export(getCurrentConvertedObject) 37 | export(getNativeLibsPath) 38 | export(getSexpType) 39 | export(inspectArgs) 40 | export(peekClrArgs) 41 | export(rToClrType) 42 | export(setConvertAdvancedTypes) 43 | export(setRDotNet) 44 | import(methods) 45 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | NEWS/ChangeLog for rClr 2 | -------------------------- 3 | 4 | 0.8-01 2019-04-08 beta 5 | o pre-release, test on R 3.5.x which has significant underlying changes. Most of the changes required appeared to be in R.NET though rather than rClr. 6 | o Move csproj to netstandard2 format and target. 7 | 8 | 0.8-0 2015-11-01 beta 9 | o Tidy up build process and upgrade to latest recommended practices, notably with testthat 10 | 11 | 0.7-9 2015-08-30 beta 12 | o Update to use R.NET 1.6.5. Following up on a few requests, 13 | allow for backward compatibility down to 14 | R 2.15.3 - While all relevant tests work, note that the level 15 | of testing is not on par with that on R 3.2.x. 16 | 17 | 0.7-8 2015-08-04 beta 18 | o Update to use R.NET 1.6.5. Following up on a few requests, 19 | allow for backward compatibility down to 20 | R 2.15.3 - While all relevant tests work, note that the level 21 | of testing is not on par with that on R 3.2.x. 22 | 23 | 0.7-4 2015-03-26 beta 24 | o Quite a few months and internal versions later, more than 25 | enough has been done to have a public release. The main change 26 | under the hood is the use by default of R.NET in preference to C, 27 | which has opened the conversion of more complicated data structures. 28 | 29 | 0.7-3 2015-01-15 beta 30 | o Make data conversion using R.NET the default. 31 | o Feature parity on Linux and Windows 32 | 33 | 0.7-1 2014-12-11 beta 34 | o Quite a few months and internal versions later, more than 35 | enough has been done to have a public release. The main change 36 | under the hood is the use by default of R.NET in preference to C, 37 | which has opened the conversion of more complicated data structures. 38 | o One particularly noteworthy feature is the possibility to convert 39 | .NET objects into R data frames in pure C# (or any other .NET language). 40 | This is not directly apparent as a feature in rClr itself, but it supports the 41 | use case. More on these capabilities will come in the form of 42 | additional documentation in subsequent releases. 43 | o Not quite ready functional on Mono, but expected to be at 44 | parity in upcoming releases. 45 | 46 | 0.6-1 2014-04-29 beta 47 | o Update to use R.NET 1.5.11. This brings lots of performance 48 | improvements as well as fixes done over the past months to R.NET. 49 | While not all benefits will be immediately apparent, this is a 50 | more solid foundation for future rClr versions. 51 | 52 | 0.5-2 2013-09-21 beta 5 53 | o Fix memory leaks for vectors created in R converted to .NET 54 | arrays. Proper memory release is confirmed for at least numeric, 55 | integer and character vector types. Part of this exercise, 56 | rClr has been accepted by Coverity Scan (https://scan.coverity.com). 57 | I acknowledge Coverity for some helpful insights tracking defects in rClr. 58 | o Useful exception handling on MS.NET CLR: print out the details 59 | of the innermost exception. This is a big improvement on the 60 | unhelpful HRESULT codes previously reported. 61 | o The hosting for the Mono runtime on Windows is included 62 | in this release. Do note that date-time handling is not 63 | passing many tests with the Mono CLR. 64 | 65 | 0.5-1 2013-06-16 beta 4 66 | o Adding package documentation using knitr and R-markdown 67 | o clrNew now with arguments 68 | o Some support for 'enum' types 69 | o Date-time handling is now using POSIXct classes instead of Date. 70 | The temporal resolution is thus much better, however beware that 71 | POSIXct is effectively a UTC time with a timezone conversion. 72 | A lot of unit tests are in place around it, but date and time 73 | zone is a complicated topic. 74 | o This release does not include Mono support; unfortunately 75 | this is not yet usable as it is too unstable. There has 76 | actually been major progress, but some new issues still 77 | emerged. -------------------------------------------------------------------------------- /R/00classDefinitions.R: -------------------------------------------------------------------------------- 1 | # Declares the S4 class that is used to hold references to CLR objects. 2 | setClass("cobjRef", representation(clrobj="externalptr", clrtype="character"), prototype=list(clrobj=NULL, clrtype="System.Object")) 3 | 4 | -------------------------------------------------------------------------------- /R/rClr-internal.R: -------------------------------------------------------------------------------- 1 | # Full type name of the reflection helper the interop code written in C# 2 | reflectionHelperTypeName <- 'Rclr.ReflectionHelper' 3 | 4 | # Full type name of the main facade to the interop code written in C# 5 | clrFacadeTypeName <- 'Rclr.ClrFacade' 6 | 7 | #' Initialize a new CLR application domain 8 | #' 9 | #' Initialize a new CLR application domain 10 | #' 11 | #' @param debug If using Mono, should the CLR be initialised to try to hook up to the mono soft debugger in MonoDevelop. This parameter has no effect if using MS.NET. 12 | #' @return nothing is returned by this function 13 | #' @examples 14 | #' \dontrun{ 15 | #' library(rClr) 16 | #' } 17 | clrInit <- function(debug=FALSE) { 18 | pkgLibsDir <- getLibsPath('rClr') 19 | f <- file.path(pkgLibsDir, 'ClrFacade.dll') 20 | f <- path.expand(f) 21 | stopifnot( file.exists(f) ) 22 | result <- .C("rclr_create_domain", pkgLibsDir, f, as.integer(debug), PACKAGE=nativePkgName) 23 | } 24 | 25 | checkIsExtPtr <- function(extPtr) { 26 | stopifnot("externalptr" %in% class(extPtr)) 27 | } 28 | 29 | getLibsPath <- function(pkgName) { 30 | libLocation<-system.file(package=pkgName) 31 | file.path(libLocation, 'libs') 32 | } 33 | 34 | #' Create if possible an S4 CLR object. 35 | #' 36 | #' Create if possible and adequate the S4 object that wraps the external pointer to a CLR object. 37 | #' Currently not exported, as this is unlikely to be recommended for use outside of unit tests and internal to rClr. 38 | #' 39 | #' @param obj the presumed external pointer. 40 | #' @param clrtype character; the name of the CLR type for the object. If NULL, rClr retrieves the type name. 41 | #' @return a cobjRef S4 object if the argument is indeed an external pointer, 42 | #' otherwise returned unchanged if null or not an external pointer. 43 | #' @import methods 44 | mkClrObjRef <- function(obj, clrtype=NULL) { 45 | if(is(obj, 'cobjRef')) return(obj) 46 | if( is.null(obj) == TRUE ) { 47 | return(NULL) 48 | } else if ("externalptr" %in% class(obj)) { 49 | if(is.null(clrtype)) { clrtype <- clrTypeNameExtPtr(obj) } 50 | return(new("cobjRef", clrobj=obj, clrtype=clrtype)) 51 | } else { 52 | return(obj) 53 | } 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /R/rClr-package.r: -------------------------------------------------------------------------------- 1 | 2 | ## Note to self: see the roxygen vignette for examples 3 | 4 | #' Accessing the Common Language Runtime (.NET/Mono) from R 5 | #' 6 | #' \tabular{ll}{ 7 | #' Package: \tab rClr\cr 8 | #' Type: \tab Package\cr 9 | #' Version: \tab 0.8.3\cr 10 | #' Notes: \tab Works with R 3.5.x series. .NET code targets netstandard2.0.\cr 11 | #' Date: \tab 2019-05-09\cr 12 | #' License: \tab LGPL 3\cr 13 | #' } 14 | #' 15 | #' rClr is a package for low-level access from R to a Common Language Runtime (CLR). The supported CLR implementations are Microsoft '.NET' 16 | #' framework on Windows and Mono on several platforms, currently Windows and at least Debian Linux. rClr has been used in scientific modelling work since 17 | #' 2013-06. Running it on Mono has been relatively experimental, but as of November 2014 several factors have enabled very near functional parity with the Windows/.NET. 18 | #' 19 | #' \tabular{lll}{ 20 | #' Version \tab Date \tab Notes \cr 21 | #' 0.8.2: \tab 2019-04-09 \tab preview release - work on R 3.5.x, which has significant changes under the hood. \cr 22 | #' 0.8.1: \tab 2019-04-08 \tab preview release - work on R 3.5.x, which has significant changes under the hood. \cr 23 | #' 0.8.0: \tab 2015-11-01 \tab Tidy up build process and upgrade to latest recommended practices, notably with testthat. \cr 24 | #' 0.7-9: \tab 2015-08-30 \tab allow compilation against boehm and SGen versions of mono lib. minor build improvements. \cr 25 | #' 0.7-8: \tab 2015-08-04 \tab Update to use R.NET 1.6.5. Allow for backward compatibility down to R 2.15.3 - While all relevant tests work, note that the level of testing is not on par with tests on R 3.2.x. \cr 26 | #' 0.7-7: \tab 2015-06-18 \tab Update to use R.NET 1.6.4. Functionally unchanged otherwise. Not a public release \cr 27 | #' 0.7-6: \tab 2015-05-07 \tab update the R Markdown vignettes to work with the latest version of knitr. Not a public release \cr 28 | #' 0.7-5: \tab 2015-04-06 \tab Internal release for work project. Compile against mono sgen rather than boehm. \cr 29 | #' } 30 | #' 31 | #' I gratefully acknowledge Kosei Abe and others for their work on the dependency R.NET (see https://github.com/jmp75/rdotnet/graphs/contributors) 32 | #' 33 | #' @name rClr-package 34 | #' @aliases rClr 35 | #' @docType package 36 | #' @title R accessing .NET/Mono 37 | #' @author Jean-Michel Perraud \email{jean-michel.perraud_at_csiro.au} 38 | #' @keywords package CLR Mono .NET 39 | NULL 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | # An internal variable that is set ot the name of the native library depending on its use of the Mono or MS.NET CLR 2 | nativePkgName <- '' 3 | 4 | # An internal variable to buffer startup messages 5 | startupMsg <- '' 6 | 7 | #' rClr .onLoad 8 | #' 9 | #' Function called when loading the rClr package with 'library'. 10 | #' 11 | #' The function looks by default for the rClr native library for the Mono runtime. 12 | #' If the platform is Linux, this is the only option. If the platform is Windows, using the 13 | #' Microsoft .NET runtime is an option. If the rClr native library for MS.NET is detected, 14 | #' the Microsoft .NET runtime is loaded in preference to Mono. 15 | #' 16 | #' @param libname the path to the library from which the package is loaded 17 | #' @param pkgname the name of the package. 18 | #' @rdname dotOnLoad 19 | #' @name dotOnLoad 20 | .onLoad <- function(libname='~/R', pkgname='rClr') { 21 | rclr_env=Sys.getenv('RCLR') 22 | monoexepath <- Sys.which('mono') 23 | ext <- .Platform$dynlib.ext 24 | nativeLibsNames <- paste(c('rClrMono', 'rClrMs'), ext, sep='') 25 | monoDll <- nativeLibsNames[1] 26 | msDll <- nativeLibsNames[2] 27 | getFnameNoExt <- function(x) {strsplit(x, '\\.')[[1]][1]} 28 | rClrPkgDir <- file.path(libname, pkgname) 29 | archLibPath <- file.path(rClrPkgDir, 'libs', Sys.getenv('R_ARCH')) 30 | srcPkgLibPath <- NULL 31 | if(!file.exists(archLibPath)) { 32 | # It may be because this is loaded through the 'document' and 'load_all' functions from devtools, 33 | # in which case libname is something like "f:/codeplex" 34 | # try to cater for load_all behavior. 35 | if( 'rclr' %in% tolower(list.files(libname))) { 36 | libname <- file.path(rClrPkgDir, 'inst') 37 | archLibPath <- file.path(rClrPkgDir, 'inst/libs', Sys.getenv('R_ARCH')) 38 | srcPkgLibPath <- archLibPath 39 | if(!file.exists(archLibPath)) {stop(paste('Looked like rClr source code directory, but directory not found:', archLibPath))} 40 | } else { 41 | stop(paste("Trying to work around devtools, but could not find a folder with lowercase name 'rclr' under ", archLibPath)) 42 | } 43 | } 44 | dlls <- list.files(archLibPath, pattern=ext) 45 | if ( Sys.info()[['sysname']] == 'Windows') { 46 | if ( rclr_env!='Mono') { 47 | msvcrFileName <- 'msvcp140.dll' 48 | if( Sys.which(msvcrFileName) == '') { 49 | stop(paste(msvcrFileName, "was not found on this Windows system.", 50 | "You are probably missing the Visual C++ Redistributable for Visual Studio 2019.", 51 | "Go to https://visualstudio.microsoft.com/downloads/ and dowload 'Microsoft Visual C++ Redistributable for Visual Studio 2019'", 52 | sep="\n")) 53 | } 54 | if(!(msDll %in% dlls)) { 55 | stop(paste('rClr library .NET framework not found - looked under', archLibPath, 'but not found in', paste(dlls, collapse=','))) 56 | } 57 | appendStartupMsg('Loading the dynamic library for Microsoft .NET runtime...') 58 | chname <- getFnameNoExt(msDll) 59 | loadAndInit(chname, pkgname, libname, srcPkgLibPath) 60 | } else if ( rclr_env=='Mono') { 61 | # on Windows, but we are requesting to load Mono. 62 | appendStartupMsg('Loading the dynamic library for Mono runtime...') 63 | if(!(monoDll %in% dlls)) { 64 | stop(paste('rClr library for Mono not found - looked under', archLibPath, 'but not found in', paste(dlls, collapse=','))) 65 | } else if (monoexepath=='') { 66 | stop("mono.exe was not found by 'Sys.which'. You must add the mono bin directory (e.g. c:\\Program Files\\Mono-3.0.6\\bin) to your PATH environment variable") 67 | } else { 68 | chname <- getFnameNoExt(monoDll) 69 | loadAndInit(chname, pkgname, libname, srcPkgLibPath) 70 | } 71 | } 72 | } else { # not on Windows. 73 | appendStartupMsg('Loading the dynamic library for Mono runtime...') 74 | chname <- "rClr" 75 | loadAndInit(chname, pkgname, libname, srcPkgLibPath) 76 | } 77 | } 78 | 79 | loadAndInit <- function(chname, pkgname, libname, srcPkgLibPath=NULL) { 80 | assign("nativePkgName", chname, inherits=TRUE) 81 | # cater for devtools 'load_all'; library.dynam fails otherwise. 82 | if(!is.null(srcPkgLibPath)) { 83 | ext <- .Platform$dynlib.ext 84 | f <- paste(file.path(srcPkgLibPath, chname), ext, sep='') 85 | dyn.load(f) 86 | } else { 87 | library.dynam(chname, pkgname, libname) 88 | } 89 | # should the init of the mono runtime try to attach to a Monodevelop debugger? 90 | debug_flag=Sys.getenv('RCLR_DEBUG') 91 | clrInit(debug_flag!="") 92 | appendStartupMsg(paste('Loaded Common Language Runtime version', getClrVersionString())) 93 | setRDotNet(TRUE) 94 | } 95 | 96 | appendStartupMsg <- function(msg) { 97 | startupMsg <<- paste0(startupMsg, msg, '\n') 98 | } 99 | 100 | #' Gets the version of the common language runtime in use 101 | #' 102 | #' Gets the version of the common language runtime in use. 103 | #' 104 | #' @return the version of the common language runtime in use 105 | #' @export 106 | getClrVersionString <- function() { 107 | v <- clrGet('System.Environment', 'Version') 108 | clrCall(v, 'ToString') 109 | } 110 | 111 | #' rClr .onAttach 112 | #' 113 | #' Print startup messages from package onLoad 114 | #' 115 | #' Print startup messages from package onLoad (prevents a 'NOTE' on package check) 116 | #' 117 | #' @rdname dotOnAttach 118 | #' @name dotOnAttach 119 | #' @param libname the path to the library from which the package is loaded 120 | #' @param pkgname the name of the package. 121 | .onAttach <- function(libname='~/R', pkgname='rClr') { 122 | if(startupMsg!='') { 123 | packageStartupMessage(startupMsg) 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rClr 2 | 3 | ## R package for accessing .NET 4 | 5 | Accessing the Common Language Runtime (.NET or Mono) from the R statistical software, in-process. 6 | 7 | ## Prerequisites 8 | 9 | As of May 2019, on Windows Clr requires the .NET Framework (4.6.1+, 4.7.2+ recommended). Groundwork towards running on .NET Core started but it is unclear how to embed the .NET Core runtime into R. 10 | 11 | As of September 2015 using Mono on Windows is not maintained. 12 | 13 | ## Installing 14 | 15 | As of 2019-04, releases can be found via the [release tab of the rClr GitHub repository](https://github.com/jmp75/rClr/releases). 16 | 17 | ### Pre-compiled binaries 18 | 19 | You can install pre-compiled rClr for Windows via the [release tab of the rClr GitHub repository](https://github.com/jmp75/rClr/releases). May 2019 has binary packages for R 3.4 and 3.5. 20 | 21 | `7z a rClr_windows_pkgs.7z` then `cd R_pkgs\bin\windows\contrib\3.5\` for R 3.5.x. 22 | 23 | You can use from the command line `R CMD INSTALL rclr_0.8.zip` where `R` points to one of the R.exe installed on your machine, or from R itself `install.packages('c:/path/to/rclr_0.8.zip')` 24 | 25 | ### From source 26 | 27 | If you want to compile from source, you may be interested in using the [testing branch](https://github.com/jmp75/rClr/tree/testing). 28 | 29 | rClr is not your average R package and requires a few more tools than is typical for most R packages. 30 | 31 | #### Windows 32 | 33 | On Windows you will need a C# and C and/or Visual C++ compiler. Using the Visual Studio 2019 toolchain is recommended as of April 2019. Check the [visual studio download page](https://visualstudio.microsoft.com/downloads/) for options. 34 | 35 | Under construction as of 2019-04: 36 | 37 | You should work from the windows command prompt. I normally use and love ConEmu but for odd reasons the package install fails with `/Rtools/bin/sh: ./configure.win: No such file or directory`. 38 | 39 | ```bat 40 | REM IMPORTANT to not have nuget.exe or other commands under c:\bin; RTools mingw cannot find these commands 41 | set PATH=C:\cmd_bin;%PATH% 42 | set SRC_ROOT=c:\src\github_jm 43 | 44 | cd %SRC_ROOT% 45 | rm rClr*.zip rClr*.tar.gz 46 | 47 | set PKG_VERSION=0.8.3 48 | ``` 49 | 50 | Make sure we use a recent msbuild, otherwise there may be issues with targetting .NET netstandard2.0. `.\rClr\src\setup_vcpp.cmd` may help detect the most recent `msbuild.exe` you have if you have installed visual studio (unsure it works for Build Tools for Visual Studio). You can start a development prompt as a fallback if setup_vcpp fails to work on your machine. 51 | 52 | ```bat 53 | REM https://github.com/jmp75/rClr/issues/42 may need to use VS2019 54 | .\rClr\src\setup_vcpp.cmd 55 | ``` 56 | 57 | After that `where msbuild` returns e.g. `C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe` 58 | 59 | Optionally to `roxygenize` the package, launch R but from the same command prompt e.g.: 60 | 61 | ```bat 62 | Rgui.bat 63 | ``` 64 | 65 | ```R 66 | library(devtools) 67 | install_github("jmp75/rclr-devtools/packages/rClrDevtools") 68 | library(rClrDevtools) # https://github.com/jmp75/rClr-devtools 69 | roxyRclr('c:/src/github_jm/rClr') 70 | ``` 71 | 72 | back to windows cmd, to build the tarball: 73 | 74 | ```bat 75 | set R_EXE="c:\Program Files\R\R-3.5.2\bin\x64\R.exe" 76 | set R_VANILLA=%R_EXE% --no-save --no-restore-data 77 | %R_VANILLA% CMD build rClr 78 | ``` 79 | 80 | ```bat 81 | set R_REPO_DIR=c:\build\software\R_pkgs\ 82 | ``` 83 | 84 | ```bat 85 | set R_WINBIN_REPO_DIR=%R_REPO_DIR%bin\windows\contrib\3.5\ 86 | if not exist %R_WINBIN_REPO_DIR% mkdir %R_WINBIN_REPO_DIR% 87 | cd %R_WINBIN_REPO_DIR% 88 | rm * 89 | %R_VANILLA% CMD INSTALL --build %SRC_ROOT%\rClr_%PKG_VERSION%.tar.gz 90 | ``` 91 | 92 | and to build for R 3.4: 93 | 94 | ```bat 95 | set R_WINBIN_REPO_DIR=%R_REPO_DIR%bin\windows\contrib\3.4\ 96 | if not exist %R_WINBIN_REPO_DIR% mkdir %R_WINBIN_REPO_DIR% 97 | set R_EXE="c:\Program Files\R\R-3.4.4\bin\x64\R.exe" 98 | set R_VANILLA=%R_EXE% --no-save --no-restore-data 99 | cd %R_WINBIN_REPO_DIR% 100 | rm * 101 | %R_VANILLA% CMD INSTALL --build %SRC_ROOT%\rClr_%PKG_VERSION%.tar.gz 102 | 103 | cd %R_REPO_DIR%.. 104 | 7z a rClr_windows_pkgs.7z R_pkgs 105 | ``` 106 | 107 | #### Linux 108 | 109 | Installing on Linux is always installing from source anyway, be it from a tarball, cloning the repo, or using `devtools`. 110 | 111 | A Linux distribution with R, g++ and the Mono toolchain (including xbuild) should work. Note that while a range of Mono versions in the 3.X series may work, I recommend you use versions 3.8 or above. This may require you to look for adequate versions (for instance Debian is lagging behind currently). You may want to have a look at the instructions at the [mono download page for Linux](http://www.mono-project.com/download/#download-lin) and use the Xamarin packages. 112 | 113 | #### Using devtools 114 | 115 | You should be able to install the package using the `install_github` function of the package `devtools`. The following commands have been tested successfully on Windows with VS2013 and Linux with Mono 3.10, on 2014-12-19. 116 | 117 | ```R 118 | ## Optionally you may remove a prior package 119 | remove.packages('rClr') 120 | library(devtools) 121 | install_github("jmp75/rClr", build_vignettes=TRUE) 122 | ``` 123 | 124 | NOTE: you must have a fully working devtools package. If devtools, on loading, reports a warning about not finding a suitable version of RTools (on Windows), this may prevent it from installing rClr. The issue has been seen for instance using devtools 1.7.0, installed from CRAN, via R 3.2.2. Package devtools 1.7.0 seems to require RTools 3.1, even when run from R 3.2.2. One way to overcome this is to install devtools from a more recent download, from its github repository. 125 | 126 | ## Getting started 127 | 128 | The package contains documentation, code sample and a vignette to get started. 129 | 130 | ```S 131 | library(rClr) 132 | ?rClr 133 | ## There is an HTML vignette: 134 | browseVignettes('rClr') 135 | ``` 136 | 137 | OBSOLETE: You will otherwise find some documentation at [https://r2clr.codeplex.com/documentation](https://r2clr.codeplex.com/documentation) 138 | 139 | ## Feedback and contributions 140 | 141 | While this package is sometimes used for the author's paid day job, this is largely a personal endeavour. Support is appreciated in many forms. 142 | 143 | * Citations: As of December 2014, [A presentation given at the R user conference 2013](https://publications.csiro.au/rpr/pub?list=ASE&pid=csiro:EP132284&expert=false&sb=RECENT&n=6&rpp=50&page=17&tr=3274&dr=all&csiro.affiliation=B3800). A journal paper will, hmm, "soon" follow. 144 | * Documentation: reporting issues, feature requests or discussion threads as such can be very valuable material if done well. 145 | * Consulting or contract work is an option that may be arranged. 146 | 147 | ## Related work 148 | 149 | A few packages using rClr are publicly accessible, and may be of interest if you want to build your own package with dependencies on rClr. 150 | 151 | * If you are interested in environmental modelling: [RtoTIME](https://github.com/jmp75/RtoTIME) is a package that depends on rClr 152 | * [rsqlserver](https://github.com/agstudy/rsqlserver) is an Sql Server driver database interface (DBI) driver for R 153 | * [A package to access optimization tools on .NET](https://github.com/jmp75/metaheuristics/tree/master/R/pkgs/mh) 154 | -------------------------------------------------------------------------------- /cleanup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # TODO: can cleanup.win just call clean (avoid duplications) 4 | if ["$RCLR_SRC_DIR" = ""] 5 | then 6 | RCLR_SRC_DIR=./src 7 | if [ ! -e ${RCLR_SRC_DIR} ] 8 | then 9 | echo "error: no suitable package src dir found - last tried ${RCLR_SRC_DIR}" 10 | CURDIR=`pwd` 11 | echo "Current directory (pwd) is $CURDIR" 12 | exit 1 13 | fi 14 | fi 15 | 16 | MAKEVARS_FILE=$RCLR_SRC_DIR/Makevars 17 | 18 | if [ -e $MAKEVARS_FILE ] 19 | then 20 | echo "note: removing existing $MAKEVARS_FILE" 21 | rm $MAKEVARS_FILE 22 | fi 23 | 24 | rm -f $RCLR_SRC_DIR/*.o 25 | rm -f $RCLR_SRC_DIR/*.rds 26 | rm -f $RCLR_SRC_DIR/rClr.dll 27 | rm -rf $RCLR_SRC_DIR/x64 28 | rm -rf $RCLR_SRC_DIR/Debug 29 | rm -rf $RCLR_SRC_DIR/MonoInstall 30 | rm -rf $RCLR_SRC_DIR/MonoInstallDebug 31 | rm -rf $RCLR_SRC_DIR/Release 32 | rm -rf $RCLR_SRC_DIR/RDotNetDataConverter/obj 33 | rm -rf $RCLR_SRC_DIR/ClrFacade/obj 34 | rm -rf $RCLR_SRC_DIR/rdotnet/RDotNet.NativeLibrary/bin 35 | rm -rf $RCLR_SRC_DIR/rdotnet/RDotNet.NativeLibrary/obj 36 | rm -rf $RCLR_SRC_DIR/rdotnet/R.NET/bin 37 | rm -rf $RCLR_SRC_DIR/rdotnet/R.NET/obj 38 | -------------------------------------------------------------------------------- /cleanup.win: -------------------------------------------------------------------------------- 1 | 2 | if ["$RCLR_SRC_DIR" = ""] 3 | then 4 | RCLR_SRC_DIR=./src 5 | if [ ! -e ${RCLR_SRC_DIR} ] 6 | then 7 | echo "error: no suitable package src dir found - last tried ${RCLR_SRC_DIR}" 8 | CURDIR=`pwd` 9 | echo "Current directory (pwd) is $CURDIR" 10 | exit 1 11 | fi 12 | fi 13 | 14 | WINMAKE_FILE=$RCLR_SRC_DIR/Makefile.win 15 | MAKEVARS_FILE=$RCLR_SRC_DIR/Makevars 16 | RCLR_PROPS_FILE=$RCLR_SRC_DIR/rClr.props 17 | 18 | if [ -e $MAKEVARS_FILE ] 19 | then 20 | echo "note: removing existing $MAKEVARS_FILE" 21 | rm $MAKEVARS_FILE 22 | fi 23 | 24 | if [ -e $WINMAKE_FILE ] 25 | then 26 | echo "note: removing existing $WINMAKE_FILE" 27 | rm $WINMAKE_FILE 28 | fi 29 | 30 | if [ -e $RCLR_PROPS_FILE ] 31 | then 32 | echo "note: removing existing $RCLR_PROPS_FILE" 33 | rm $RCLR_PROPS_FILE 34 | fi 35 | 36 | if [ -e ${RCLR_SRC_DIR}/../inst/libs ] 37 | then 38 | rm -rf $RCLR_SRC_DIR/../inst/libs/* 39 | fi 40 | 41 | rm -f $RCLR_SRC_DIR/rClr.dll 42 | rm -f $RCLR_SRC_DIR/rClrMono* 43 | rm -f $RCLR_SRC_DIR/rClrMs* 44 | rm -rf $RCLR_SRC_DIR/x64 45 | rm -rf $RCLR_SRC_DIR/Debug 46 | rm -rf $RCLR_SRC_DIR/MonoInstall 47 | rm -rf $RCLR_SRC_DIR/MonoInstallDebug 48 | rm -rf $RCLR_SRC_DIR/Release 49 | rm -rf $RCLR_SRC_DIR/RDotNetDataConverter/obj 50 | rm -rf $RCLR_SRC_DIR/RDotNetDataConverter/DummyApp/bin/ 51 | rm -rf $RCLR_SRC_DIR/RDotNetDataConverter/DummyApp/obj/ 52 | rm -rf $RCLR_SRC_DIR/ClrFacade/obj 53 | rm -rf $RCLR_SRC_DIR/rdotnet/RDotNet.NativeLibrary/bin 54 | rm -rf $RCLR_SRC_DIR/rdotnet/RDotNet.NativeLibrary/obj 55 | rm -rf $RCLR_SRC_DIR/rdotnet/R.NET/bin 56 | rm -rf $RCLR_SRC_DIR/rdotnet/R.NET/obj 57 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | RCLR_SRC_DIR=./src 4 | RCLR_NUGET_EXE=${RCLR_SRC_DIR}/.nuget/NuGet.exe 5 | if [ ! -e ${RCLR_SRC_DIR} ] 6 | then 7 | echo "error: no suitable package src dir found - last tried ${RCLR_SRC_DIR}" 8 | CURDIR=`pwd` 9 | echo "Current directory (pwd) is $CURDIR" 10 | exit 1 11 | fi 12 | 13 | # if this variable is defined, no Makefile.win will be generated, 14 | # and the visual studio compilers are ignored even if installed. 15 | # IGNORE_VISUALSTUDIO=1 16 | 17 | ./cleanup 18 | MAKEVARS_FILE=$RCLR_SRC_DIR/Makevars 19 | MAKEVARS_INFILE=$MAKEVARS_FILE.in 20 | 21 | # In order to write dos-style paths to the generated Makefile.win and co, needs multiple backslashes... 22 | # R_HOME will be something like f:/path/to/R 23 | # bash has the option of R_HOME_BSLASH=${R_HOME//\//\\\\} and it works as expected 24 | # in ash behavior seems to differ from bash, hence the 8 backslashes needed for the substitution to work 25 | slash_to_eight_bslash() { 26 | RESULT=`echo $1 | sed -e 's/\//\\\\\\\\/g'` 27 | } 28 | # slash_to_eight_bslash c:/tmp/blah 29 | # echo $RESULT 30 | # blah=$RESULT 31 | # echo $blah 32 | 33 | # A substitute for cygpath, not present in RTools 34 | # does not work as function (??): sed: -e expression #1, char 8: unterminated `s' command 35 | # dos_to_cyg() { 36 | # RESULT=`echo $1 | sed -e 's/\\/\//g'` 37 | # } 38 | 39 | double_backslash() { 40 | RESULT=`echo $1 | sed -e 's/\\/\\\\/g'` 41 | } 42 | 43 | MONO_CFLAGS=`pkg-config --cflags mono-2` 44 | GLIB_CFLAGS=`pkg-config --cflags glib-2.0` 45 | echo "MONO_CFLAGS=$MONO_CFLAGS" 46 | echo "GLIB_CFLAGS=$GLIB_CFLAGS" 47 | 48 | if [ ${#MONO_CFLAGS} -eq 0 ] 49 | then 50 | echo "error: mono-2 not found" 51 | exit 1 52 | fi 53 | 54 | if [ ${#GLIB_CFLAGS} -eq 0 ] 55 | then 56 | echo "error: glib-2.0 not found" 57 | exit 1 58 | fi 59 | 60 | # I do not think the following is needed. The solution file would trigger a Target RestorePackages: 61 | #if [ -e ${RCLR_NUGET_EXE} ] 62 | #then 63 | # echo "Found ${RCLR_NUGET_EXE}" 64 | # echo "Trying nuget package restore..." 65 | # mono ${RCLR_NUGET_EXE} restore -NonInteractive ${RCLR_SRC_DIR}/rClr_monodev.sln 66 | #fi 67 | 68 | subst_1="s|@MONO_INSTALL_PATH@|$MONO_INSTALL_PATH|g" 69 | subst_2="s|@MONO_INSTALL_PATH64@|$MONO_INSTALL_PATH64|g" 70 | sed -e "$subst_1" -e "$subst_2" $MAKEVARS_INFILE > $MAKEVARS_FILE 71 | echo "Created $MAKEVARS_FILE" 72 | exit 0 73 | 74 | -------------------------------------------------------------------------------- /configure.win: -------------------------------------------------------------------------------- 1 | 2 | RCLR_SRC_DIR=./src 3 | if [ ! -e ${RCLR_SRC_DIR} ] 4 | then 5 | echo "error: no suitable package src dir found - last tried ${RCLR_SRC_DIR}" 6 | CURDIR=`pwd` 7 | echo "Current directory (pwd) is $CURDIR" 8 | exit 1 9 | fi 10 | 11 | # On Windows the Mono installer contains the 32 bit architecture only. 12 | # It is nevertheless possible to compile for 64 bits, including with Visual Studio, 13 | # but this is a manual process to set this up. 14 | MONO_INSTALL_PATH64=F:/bin/mono_built/x64 15 | 16 | # if this variable is defined, no Makefile.win will be generated, 17 | # and the visual studio compilers are ignored even if installed. 18 | # IGNORE_VISUALSTUDIO=1 19 | 20 | ./cleanup.win 21 | WINMAKE_FILE=$RCLR_SRC_DIR/Makefile.win 22 | WINMAKE_INFILE=$WINMAKE_FILE.in 23 | MAKEVARS_FILE=$RCLR_SRC_DIR/Makevars 24 | MAKEVARS_INFILE=$MAKEVARS_FILE.in 25 | RCLR_PROPS_INFILE=$RCLR_SRC_DIR/rClr.props.in 26 | RCLR_PROPS_FILE=$RCLR_SRC_DIR/rClr.props 27 | 28 | NOT_FOUND="not found" 29 | # In order to write dos-style paths to the generated Makefile.win and co, needs multiple backslashes... 30 | # R_HOME will be something like f:/path/to/R 31 | # bash has the option of R_HOME_BSLASH=${R_HOME//\//\\\\} and it works as expected 32 | # in ash behavior seems to differ from bash, hence the 8 backslashes needed for the substitution to work 33 | slash_to_eight_bslash() { 34 | RESULT=`echo $1 | sed -e 's/\//\\\\\\\\/g'` 35 | } 36 | # slash_to_eight_bslash c:/tmp/blah 37 | # echo $RESULT 38 | # blah=$RESULT 39 | # echo $blah 40 | 41 | # A substitute for cygpath, not present in RTools 42 | # does not work as function (??): sed: -e expression #1, char 8: unterminated `s' command 43 | # dos_to_cyg() { 44 | # RESULT=`echo $1 | sed -e 's/\\/\//g'` 45 | # } 46 | 47 | double_backslash() { 48 | RESULT=`echo $1 | sed -e 's/\\/\\\\/g'` 49 | } 50 | 51 | if [ "$MONO_INSTALL_PATH" = "" ] 52 | then 53 | ## Find the location of the Mono binary installation on Windows. 54 | if [ ! -e ${RCLR_SRC_DIR}/get_monosdk.cmd ] 55 | then 56 | echo "error: batch file not found: ${RCLR_SRC_DIR}/get_monosdk.cmd" 57 | exit 1 58 | fi 59 | GET_MONO_SDK_CMD=`echo ${RCLR_SRC_DIR}/get_monosdk.cmd | sed -e 's/\//\\\\/g'` 60 | # echo "cmd /c $CREATE_LIB_CMD" > blah.txt 61 | MONO_INSTALL_PATH=`cmd /c "$GET_MONO_SDK_CMD"` 62 | if [ "$MONO_INSTALL_PATH" = "$NOT_FOUND" ] 63 | then 64 | echo "warning: Path to the Mono SDK not found by querying the Windows registry. Mono support will be disabled" 65 | # echo "error: Path to the Mono SDK not found by querying the Windows registry" 66 | # exit 1 67 | fi 68 | fi # if [ "$MONO_INSTALL_PATH" = "" ] 69 | 70 | 71 | ## Location of the sources of the mono codebase 72 | # there is no way to detect a potential src installation of the Mono codebase. 73 | # Likely to be too advanced for the vast majority - let this be set by the user. 74 | if [ "$MONO_SRC_PATH" = "" ] 75 | then 76 | MONO_SRC_PATH="c:/path_to_be_set_manually" 77 | fi 78 | 79 | # Give info to the R pkg install log 80 | echo "R_HOME=$R_HOME" 81 | if [ "$MONO_INSTALL_PATH" != "$NOT_FOUND" ] 82 | then 83 | echo "MONO_INSTALL_PATH=$MONO_INSTALL_PATH" 84 | fi 85 | 86 | 87 | ## Update the rClr.props file, so that the build process finds the correct R.dll and mono-2.0.dll 88 | 89 | # For debugging purposes of this script, you need to set R_HOME 90 | # R_HOME=c:/PROGRA~1/R/R-30~1.0 91 | 92 | slash_to_eight_bslash "$R_HOME" # quotes essential for spaces in paths 93 | R_HOME_BSLASH=$RESULT 94 | # echo "R_HOME_BSLASH=$R_HOME_BSLASH" 95 | 96 | slash_to_eight_bslash "$MONO_INSTALL_PATH" # quotes essential for spaces in paths 97 | MONO_INSTALL_PATH_BSLASH=$RESULT 98 | # echo $MONO_INSTALL_PATH_BSLASH 99 | 100 | slash_to_eight_bslash "$MONO_SRC_PATH" # quotes essential for spaces in paths 101 | MONO_SRC_PATH_BSLASH=$RESULT 102 | # echo $MONO_SRC_PATH_BSLASH 103 | 104 | sed -e "s/@R_INSTALL_PATH@/$R_HOME_BSLASH/" -e "s/@MONO_SRC_PATH@/$MONO_SRC_PATH_BSLASH/" \ 105 | -e "s/@MONO_INSTALL_PATH@/$MONO_INSTALL_PATH_BSLASH/" $RCLR_PROPS_INFILE > $RCLR_PROPS_FILE 106 | 107 | USE_GCC=0 108 | if [ "$IGNORE_VISUALSTUDIO" != "" ] 109 | then 110 | USE_GCC=1 111 | echo "note: Found the flag IGNORE_VISUALSTUDIO. Build will be made with gcc, Mono and xbuild" 112 | fi 113 | 114 | VS_COMNTOOLS=${VS120COMNTOOLS} 115 | # echo "$VS_COMNTOOLS" 116 | if [ "$VS_COMNTOOLS" = "" ] 117 | then 118 | VS_COMNTOOLS=${VS110COMNTOOLS} 119 | fi 120 | 121 | if [ "$VS_COMNTOOLS" = "" ] 122 | then 123 | USE_GCC=1 124 | echo "note: No VS120COMNTOOLS or VS110COMNTOOLS environment variable. Build will be made with gcc, Mono and xbuild" 125 | fi 126 | 127 | # echo "Passed detection of VS_COMNTOOLS" 128 | 129 | if [ $USE_GCC = 1 ] 130 | then 131 | subst_1="s|@MONO_INSTALL_PATH@|$MONO_INSTALL_PATH|g" 132 | subst_2="s|@MONO_INSTALL_PATH64@|$MONO_INSTALL_PATH64|g" 133 | sed -e "$subst_1" -e "$subst_2" $MAKEVARS_INFILE > $MAKEVARS_FILE 134 | echo "Created $MAKEVARS_FILE" 135 | exit 0 136 | fi 137 | 138 | 139 | ## Detect if a sufficient toolchain is present to compile with visual studio 140 | 141 | ## Find the location of the MSBuild.exe executable. Typically: 142 | # C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe or 143 | # C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe 144 | GET_MSBUILD_CMD=`echo ${RCLR_SRC_DIR}/get_msbuildpath.cmd | sed -e 's/\//\\\\/g'` 145 | # echo $GET_MSBUILD_CMD 146 | 147 | # Do note that this one returns a slashified path already. See get_msbuildpath 148 | MSBUILD_EXE_SLASH=`cmd /c "$GET_MSBUILD_CMD"` 149 | # MSBUILD_EXE=`${RCLR_SRC_DIR}/get_msbuildpath.cmd` 150 | echo "$MSBUILD_EXE_SLASH" 151 | if [ $MSBUILD_EXE_SLASH != "MSBuild.exe" ] 152 | then 153 | if [ ! -e $MSBUILD_EXE_SLASH ] 154 | # if [ "" != "" ] 155 | then 156 | echo "error: Msbuild.exe not found at required location ${MSBUILD_TOOLS_PATH}" 157 | exit 1 158 | fi 159 | fi # end check on "${MSBUILD_EXE}" 160 | 161 | # Check the compiler and dependencies required for buliding on Windows 162 | # VS2012 Express edition 163 | # Note: == seems not supported in sh (ash??) 164 | if [ "$VS_COMNTOOLS" = "" ] 165 | then 166 | echo "note: No VS120COMNTOOLS or VS110COMNTOOLS environment variable. Build will be made with gcc, Mono and xbuild" 167 | # exit 1 168 | else 169 | # echo $WINMAKE_FILE 170 | subst="s|@MSBUILD_EXE_PATH@|$MSBUILD_EXE_SLASH|" 171 | # echo $subst 172 | sed -e $subst $WINMAKE_INFILE > $WINMAKE_FILE 173 | ################# 174 | # create the RDll.lib and Mono.lib files for compiling with VC++. Do not assume they are set up (even if very likely for the CRAN winbuilder) 175 | # Thanks to http://cygwin.com/ml/cygwin/2011-09/msg00232.html for how to call cmd files from sh. 176 | CREATE_LIB_CMD=`echo ${RCLR_SRC_DIR}/create_lib.cmd | sed -e 's/\//\\\\/g'` 177 | cmd /c "$CREATE_LIB_CMD" 178 | fi # if [ "$VS_COMNTOOLS" = "" ] 179 | 180 | exit 0 -------------------------------------------------------------------------------- /inst/extras/performance_profiling.r: -------------------------------------------------------------------------------- 1 | ############## 2 | # This file contains code used in a vignette. The code is not included directly in the vignette 3 | # as it is fairly advanced compared to the purpose of the vignette. 4 | ############## 5 | 6 | # library(utils) 7 | library(ggplot2) 8 | # Sys.setenv(RCLR='Mono') 9 | 10 | library(rClr) 11 | 12 | profClassName <- 'Rclr.PerformanceProfiling' 13 | prof <- clrNew(profClassName) 14 | nRepsColname <- 'numReps' 15 | arrayLenColname <- 'arrLen' 16 | 17 | clrToRDataTransferFUNGEN <- function(numArray, arrLen) { 18 | stopifnot(length(numArray) == 1) 19 | clrCall(prof, 'SetDoubleArrays', as.integer(0), as.integer(arrLen), as.integer(numArray)) 20 | clrToRDataTransfer <- function() { clrCall(prof, 'GetNextArrayDouble') } 21 | clrToRDataTransfer 22 | } 23 | 24 | rToClrDataTransferFUNGEN <- function(numArray, arrLen) { 25 | set.seed(0) 26 | if(arrLen <= 1) {stop("Not designed to cope with array length less than two")} 27 | num_vec = rnorm(arrLen) 28 | rToClrDataTransfer <- function() { clrCall(prof, 'CallMethodWithArrayDouble', num_vec) } 29 | rToClrDataTransfer 30 | } 31 | 32 | sw <- clrNew('System.Diagnostics.Stopwatch') 33 | startSw <- function () { clrCall(sw,'Stop'); clrCall(sw,'Reset'); clrCall(sw, 'Start') } 34 | stopSw <- function () { clrCall(sw,'Stop'); clrCallStatic('Rclr.PerformanceProfiling', 'GetElapsedSeconds', sw) } 35 | 36 | measure <- function(numReps, FUN, normalize=TRUE) { 37 | blah = numeric(0) 38 | if(numReps>1) { 39 | startSw() 40 | for (i in 1:numReps) { 41 | blah <- FUN() 42 | } 43 | e = stopSw() 44 | delta = e 45 | # Fiendish: the for() construct is surprisingly expensive compared to rClr... 46 | startSw() 47 | for (i in 1:numReps) { 48 | blah <- 0 49 | } 50 | e = stopSw() 51 | delta = delta - e 52 | } else { 53 | startSw() 54 | blah <- FUN() 55 | e = stopSw() 56 | delta = e 57 | # Remove the measurement. 58 | startSw() 59 | e = stopSw() 60 | delta = delta - e 61 | } 62 | delta <- as.numeric(delta) 63 | if(normalize) {delta <- delta / normalize} 64 | delta 65 | } 66 | 67 | doMeasure <- function(trials, trow, FUNGEN, dataClass,direction,tag=NA) { 68 | nReps <- trials[trow,nRepsColname] 69 | innerReps <- 1 70 | arrLen <- trials[trow,arrayLenColname] 71 | # if(arrLen < 1000) { 72 | # innerReps <- 100 73 | # } else if (arrLen < 10000) { 74 | # innerReps <- 50 75 | # # } else if (arrLen < 100000) { 76 | # # innerReps <- 10 77 | # } 78 | FUN = FUNGEN(nReps, arrLen) 79 | deltas <- numeric(0) 80 | for (i in 1:nReps) { 81 | deltas <- c(deltas, measure(numReps=innerReps, FUN=FUN)) 82 | } 83 | data.frame(dataClass=dataClass, arrayLen=as.integer(arrLen),direction,tag=as.character(tag), delta=deltas) 84 | } 85 | 86 | doMeasureFun <- function(trials, FUNGEN, dataClass,direction,tag=NA) { 87 | clrCallStatic('Rclr.TestCases', 'CallGC') # minimize the risk of cases such that we end up with negative runtimes... 88 | res <- doMeasure(trials, 1, FUNGEN=FUNGEN, dataClass, direction, tag) 89 | for (trow in 2:nrow(trials)) { 90 | res <- rbind(res, doMeasure(trials, trow, FUNGEN=FUNGEN, dataClass, direction, tag)) 91 | } 92 | # dataClass arrayLen direction tag delta 93 | # 1 numeric 1 CLR->R no.r.net 0.005999804 94 | # 2 numeric 1 CLR->R no.r.net 0.004001141 95 | res$rate <- res$arrayLen / res$delta # items/second 96 | res 97 | } 98 | 99 | # We want to obtain plots of effective transfer rates: X axis is the length of the arrays, Y axis is the transfer rate in MB/s 100 | # we may want to measure with/without R.NET loaded, so there is at least one category. 101 | # We may as well have a single data frame for 102 | # So the high-level result from the measurement should be a data frame with columns: 103 | # dataClass,array_len,direction,tag 104 | # 'integer',5000,'CLR->R',no.r.net 105 | 106 | # repetitions,array_len 107 | 108 | createCases <- function(numReps=10, maxArrayLen=7.5e6) { 109 | # May want to tailor to whether this is 32 or 64 bits; use: 110 | # clrGet('System.Environment', 'Is64BitProcess') 111 | cases <- c(2,5,7.5) 112 | trials <- expand.grid ( numReps = numReps, arrLen = as.integer(cases) ) 113 | mult <- c(1,2,5,7.5) 114 | cases <- expand.grid(mult, 10**(1:7)) 115 | cases <- as.integer(cases[,1]*cases[,2]) # 1 2 5 10 20 50 etc. 116 | trials <- rbind(trials, expand.grid ( numReps = numReps, arrLen = cases )) 117 | return(subset(trials, arrLen <= maxArrayLen)) 118 | } 119 | 120 | 121 | rclrNumericPerf <- function(trials, tag) { 122 | fgen <- clrToRDataTransferFUNGEN 123 | bench <- doMeasureFun(trials, FUNGEN=fgen, dataClass='numeric', direction="CLR->R",tag=tag) 124 | bench <- rbind(bench, doMeasureFun(trials, FUNGEN=fgen, dataClass='numeric', direction="R->CLR",tag=tag)) 125 | bench 126 | } 127 | 128 | rclrNumericPerfAll <- function(numReps=10, maxArrayLen=7.5e6) { 129 | trials <- createCases(numReps=numReps, maxArrayLen=maxArrayLen) 130 | setRDotNet(FALSE) 131 | bench <- doMeasureFun(trials, FUNGEN=clrToRDataTransferFUNGEN, dataClass='numeric', direction="CLR->R",tag="no.r.net") 132 | bench <- rbind(bench, doMeasureFun(trials, FUNGEN=rToClrDataTransferFUNGEN, dataClass='numeric', direction="R->CLR",tag="no.r.net")) 133 | setRDotNet(TRUE) 134 | bench <- rbind(doMeasureFun(trials, FUNGEN=clrToRDataTransferFUNGEN, dataClass='numeric', direction="CLR->R",tag="r.net")) 135 | bench <- rbind(bench, doMeasureFun(trials, FUNGEN=rToClrDataTransferFUNGEN, dataClass='numeric', direction="R->CLR",tag="r.net")) 136 | } 137 | 138 | ##################################### 139 | # Plotting 140 | plotRate <- function(bench, case = 'R->CLR', dataType='numeric', logy=TRUE) { 141 | bench <- subset(bench, direction==case) 142 | p <- qplot(x=bench$arrayLen, y=bench$rate) + 143 | ylab('Items/sec') + xlab('Array size') + 144 | ggtitle(paste(dataType, 'vector conversion rate', case)) 145 | p <- p + scale_x_log10() 146 | if(logy) { 147 | p <- p + scale_y_log10() + annotation_logticks(sides='bl') 148 | } else { 149 | p <- p + annotation_logticks(sides='b') 150 | } 151 | p 152 | } 153 | ##################################### 154 | 155 | 156 | # options(error=recover) 157 | # trials <- createCases(numReps=10, maxArrayLen=7.5e6) 158 | # bench <- rclrNumericPerf(trials, tag='no.r.net') 159 | 160 | ## REPRO: this crashes Rgui. All in R.dll, and likely related to R.NET; unclear where/why 161 | # behaves for a length of 100000; above, trouble start. 162 | # trials <- createCases(maxArrayLen=50000) 163 | # setRDotNet(TRUE) 164 | # bench <- doMeasureFun(trials, FUNGEN=clrToRDataTransferFUNGEN, dataClass='numeric', direction="CLR->R",tag="r.net") 165 | ## bench <- rbind(bench, doMeasureFun(trials, FUNGEN=rToClrDataTransferFUNGEN, dataClass='numeric', direction="R->CLR",tag="r.net")) 166 | 167 | #bench$measure = apply(measures, MARGIN=1,FUN=mean) 168 | # plotRate(bench, case = 'CLR->R') 169 | # + scale_y_log10() + annotation_logticks() 170 | # plotRate(bench, case = 'CLR->R') + annotation_logticks(sides='b') 171 | # 172 | # bench <- doMeasureFun(trials, FUNGEN=rToClrDataTransferFUNGEN, dataClass='numeric', direction="R->CLR",tag="no.r.net") 173 | # plotRate(bench, case = 'R->CLR') + scale_y_log10() + annotation_logticks() 174 | 175 | 176 | # With the MS implementation (x64): 177 | # > rate 178 | # [1] 103785.2 204040.8 370295.1 463226.1 595119.1 702986.7 769077.6 784153.1 964098.6 1034270.3 2157841.3 4490122.2 179 | # [13] 8062899.1 25856885.5 34571239.5 36067822.5 36660757.6 180 | 181 | # With the MS implementation (R i386): 182 | 183 | #and the winner Mono (on i386): 184 | -------------------------------------------------------------------------------- /man/clrCall.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrCall} 4 | \alias{clrCall} 5 | \title{Call a method on an object} 6 | \usage{ 7 | clrCall(obj, methodName, ...) 8 | } 9 | \arguments{ 10 | \item{obj}{an object} 11 | 12 | \item{methodName}{the name of a method of the object} 13 | 14 | \item{...}{additional method arguments passed to .External} 15 | } 16 | \value{ 17 | an object resulting from the call. May be a CLR object, or a native R object for common types. Can be NULL. 18 | } 19 | \description{ 20 | Call a method on an object 21 | } 22 | \examples{ 23 | \dontrun{ 24 | library(rClr) 25 | testClassName <- "Rclr.TestObject"; 26 | (testObj <- clrNew(testClassName)) 27 | clrCall(testObj, 'GetFieldIntegerOne') 28 | ## derived from unit test for matching the right method (function) to call. 29 | f <- function(...){ paste( 'This called a method with arguments:', 30 | paste(clrCallStatic('Rclr.TestMethodBinding', 'SomeStaticMethod', ...), collapse=', ')) } 31 | f(1:3) 32 | f(3) 33 | f('a') 34 | f('a', 3) 35 | f(3, 'a') 36 | f(list('a', 3)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /man/clrCallStatic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrCallStatic} 4 | \alias{clrCallStatic} 5 | \title{Call a static method on a CLR type} 6 | \usage{ 7 | clrCallStatic(typename, methodName, ...) 8 | } 9 | \arguments{ 10 | \item{typename}{type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{methodName}{the name of a static method of the type} 13 | 14 | \item{...}{additional method arguments passed to .External} 15 | } 16 | \value{ 17 | an object resulting from the call. May be a CLR object, or a native R object for common types. Can be NULL. 18 | } 19 | \description{ 20 | Call a static method on a CLR type 21 | } 22 | \examples{ 23 | \dontrun{ 24 | library(rClr) 25 | cTypename <- "Rclr.TestCases" 26 | clrCallStatic(cTypename, "IsTrue", TRUE) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /man/clrCobj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrCobj} 4 | \alias{clrCobj} 5 | \title{Create a reference object wrapper around a CLR object} 6 | \usage{ 7 | clrCobj(obj, envClassWhere = .GlobalEnv) 8 | } 9 | \arguments{ 10 | \item{obj}{an object of S4 class clrObj} 11 | 12 | \item{envClassWhere}{environment where the new generator is created.} 13 | } 14 | \value{ 15 | the reference object. 16 | } 17 | \description{ 18 | (EXPERIMENTAL) Create a reference object wrapper around a CLR object 19 | } 20 | -------------------------------------------------------------------------------- /man/clrGet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGet} 4 | \alias{clrGet} 5 | \title{Gets the value of a field or property of an object or class} 6 | \usage{ 7 | clrGet(objOrType, name) 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{name}{the name of a field/property of the object} 13 | } 14 | \value{ 15 | an object resulting from the call. May be a CLR object, or a native R object for common types. Can be NULL. 16 | } 17 | \description{ 18 | Gets the value of a field or property of an object or class 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | testClassName <- "Rclr.TestObject"; 24 | testObj <- clrNew(testClassName) 25 | clrReflect(testObj) 26 | clrGet(testObj, 'FieldIntegerOne') 27 | clrGet(testClassName, 'StaticPropertyIntegerOne') 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /man/clrGetConstructors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetConstructors} 4 | \alias{clrGetConstructors} 5 | \title{List the public constructors of a CLR Type} 6 | \usage{ 7 | clrGetConstructors(type) 8 | } 9 | \arguments{ 10 | \item{type}{CLR Type, or a (character) type name that can be successfully parsed} 11 | } 12 | \value{ 13 | a list of constructor signatures 14 | } 15 | \description{ 16 | List the public constructors of a CLR Type 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | testClassName <- "Rclr.TestObject"; 22 | clrGetConstructors(testClassName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /man/clrGetEnumNames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetEnumNames} 4 | \alias{clrGetEnumNames} 5 | \title{Gets the names of a CLR Enum value type} 6 | \usage{ 7 | clrGetEnumNames(enumType) 8 | } 9 | \arguments{ 10 | \item{enumType}{a CLR object, System.Type or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | } 12 | \value{ 13 | a character vector of the names for the enum 14 | } 15 | \description{ 16 | Gets the names of a CLR Enum value type 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | clrGetEnumNames('Rclr.TestEnum') 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/clrGetExtPtr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetExtPtr} 4 | \alias{clrGetExtPtr} 5 | \title{Gets the external pointer CLR object.} 6 | \usage{ 7 | clrGetExtPtr(clrObject) 8 | } 9 | \arguments{ 10 | \item{clrObject}{a S4 object of class clrobj} 11 | } 12 | \value{ 13 | the external pointer to the CLR object 14 | } 15 | \description{ 16 | Gets the external pointer CLR object. End user are unlikely to need this. 17 | } 18 | -------------------------------------------------------------------------------- /man/clrGetFields.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetFields} 4 | \alias{clrGetFields} 5 | \title{List the instance fields of a CLR object} 6 | \usage{ 7 | clrGetFields(clrobj, contains = "") 8 | } 9 | \arguments{ 10 | \item{clrobj}{CLR object} 11 | 12 | \item{contains}{a string that the field names returned must contain} 13 | } 14 | \value{ 15 | a list of names of the fields of the CLR object 16 | } 17 | \description{ 18 | List the instance fields of a CLR object 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | testClassName <- "Rclr.TestObject"; 24 | testObj <- clrNew(testClassName) 25 | clrGetFields(testObj) 26 | clrGetFields(testObj, 'ieldInt') 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /man/clrGetInnerPkgName.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetInnerPkgName} 4 | \alias{clrGetInnerPkgName} 5 | \title{Gets the inner name used for the package} 6 | \usage{ 7 | clrGetInnerPkgName() 8 | } 9 | \value{ 10 | the short name of the library currently loaded, depending on the runtime used (Mono or Microsoft .NET) 11 | } 12 | \description{ 13 | Gets the inner name used for the package (rClrMono or rClrMs). This is not intented for use by most users. 14 | } 15 | -------------------------------------------------------------------------------- /man/clrGetLoadedAssemblies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetLoadedAssemblies} 4 | \alias{clrGetLoadedAssemblies} 5 | \title{List the names of loaded CLR assemblies} 6 | \usage{ 7 | clrGetLoadedAssemblies(fullname = FALSE, filenames = FALSE) 8 | } 9 | \arguments{ 10 | \item{fullname}{should the full name of the assemblies be returned} 11 | 12 | \item{filenames}{if TRUE, return a data frame where the second column is the URI (usually file path) of the loaded assembly.} 13 | } 14 | \value{ 15 | the names of loaded CLR assemblies 16 | } 17 | \description{ 18 | List the names of loaded CLR assemblies 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | clrGetLoadedAssemblies() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/clrGetMemberSignature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetMemberSignature} 4 | \alias{clrGetMemberSignature} 5 | \title{Gets the signature of a CLI object member} 6 | \usage{ 7 | clrGetMemberSignature(clrobj, memberName) 8 | } 9 | \arguments{ 10 | \item{clrobj}{CLR object} 11 | 12 | \item{memberName}{The exact name of the member (i.e. field, property, method) to search for} 13 | } 14 | \value{ 15 | a character vector with summary information on the method/member signatures 16 | } 17 | \description{ 18 | Gets a string representation of the signature of a member (i.e. field, property, method). 19 | Mostly used to interactively search for what arguments to pass to a method. 20 | } 21 | \examples{ 22 | \dontrun{ 23 | library(rClr) 24 | testClassName <- "Rclr.TestObject"; 25 | testObj <- clrNew(testClassName) 26 | clrReflect(testObj) 27 | clrGetMemberSignature(testObj, 'set_PropertyIntegerOne') 28 | clrGetMemberSignature(testObj, 'FieldIntegerOne') 29 | clrGetMemberSignature(testObj, 'PropertyIntegerTwo') 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /man/clrGetMethods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetMethods} 4 | \alias{clrGetMethods} 5 | \title{List the instance methods of a CLR object} 6 | \usage{ 7 | clrGetMethods(clrobj, contains = "") 8 | } 9 | \arguments{ 10 | \item{clrobj}{CLR object} 11 | 12 | \item{contains}{a string that the methods names returned must contain} 13 | } 14 | \value{ 15 | a list of names of the methods of the CLR object 16 | } 17 | \description{ 18 | List the instance methods of a CLR object 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | testClassName <- "Rclr.TestObject"; 24 | testObj <- clrNew(testClassName) 25 | clrGetMethods(testObj) 26 | clrGetMethods(testObj, 'Get') 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /man/clrGetNativeLibName.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetNativeLibName} 4 | \alias{clrGetNativeLibName} 5 | \title{Gets the name of the native library currently loaded.} 6 | \usage{ 7 | clrGetNativeLibName() 8 | } 9 | \value{ 10 | the name of the native library currently loaded: rClrMs or rClrMono 11 | } 12 | \description{ 13 | Gets the name of the native library currently loaded. Used only for unit tests. 14 | } 15 | -------------------------------------------------------------------------------- /man/clrGetProperties.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetProperties} 4 | \alias{clrGetProperties} 5 | \title{List the instance properties of a CLR object} 6 | \usage{ 7 | clrGetProperties(clrobj, contains = "") 8 | } 9 | \arguments{ 10 | \item{clrobj}{CLR object} 11 | 12 | \item{contains}{a string that the property names returned must contain} 13 | } 14 | \value{ 15 | a list of names of the properties of the CLR object 16 | } 17 | \description{ 18 | List the instance properties of a CLR object 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | testClassName <- "Rclr.TestObject"; 24 | testObj <- clrNew(testClassName) 25 | clrGetProperties(testObj) 26 | clrGetProperties(testObj, 'One') 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /man/clrGetStaticFields.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetStaticFields} 4 | \alias{clrGetStaticFields} 5 | \title{Gets the static fields for a type} 6 | \usage{ 7 | clrGetStaticFields(objOrType, contains = "") 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{contains}{a string that the property names returned must contain} 13 | } 14 | \description{ 15 | Gets the static fields for a type 16 | } 17 | -------------------------------------------------------------------------------- /man/clrGetStaticMemberSignature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetStaticMemberSignature} 4 | \alias{clrGetStaticMemberSignature} 5 | \title{Gets the signature of a static member of a type} 6 | \usage{ 7 | clrGetStaticMemberSignature(typename, memberName) 8 | } 9 | \arguments{ 10 | \item{typename}{type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{memberName}{The exact name of the member (i.e. field, property, method) to search for} 13 | } 14 | \description{ 15 | Gets the signature of a static member of a type 16 | } 17 | -------------------------------------------------------------------------------- /man/clrGetStaticMembers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetStaticMembers} 4 | \alias{clrGetStaticMembers} 5 | \title{Gets the static members for a type} 6 | \usage{ 7 | clrGetStaticMembers(objOrType) 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | } 12 | \description{ 13 | Gets the static members for a type 14 | } 15 | \examples{ 16 | \dontrun{ 17 | library(rClr) 18 | cTypename <- "Rclr.TestCases" 19 | clrGetStaticMembers(cTypename) 20 | testClassName <- "Rclr.TestObject"; 21 | testObj <- clrNew(testClassName) 22 | clrGetStaticMembers(testObj) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /man/clrGetStaticMethods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetStaticMethods} 4 | \alias{clrGetStaticMethods} 5 | \title{Gets the static members for a type} 6 | \usage{ 7 | clrGetStaticMethods(objOrType, contains = "") 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{contains}{a string that the property names returned must contain} 13 | } 14 | \description{ 15 | Gets the static members for a type 16 | } 17 | -------------------------------------------------------------------------------- /man/clrGetStaticProperties.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetStaticProperties} 4 | \alias{clrGetStaticProperties} 5 | \title{Gets the static members for a type} 6 | \usage{ 7 | clrGetStaticProperties(objOrType, contains = "") 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{contains}{a string that the property names returned must contain} 13 | } 14 | \description{ 15 | Gets the static members for a type 16 | } 17 | -------------------------------------------------------------------------------- /man/clrGetType.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetType} 4 | \alias{clrGetType} 5 | \title{Gets the type of a CLR object given its type name} 6 | \usage{ 7 | clrGetType(objOrTypename) 8 | } 9 | \arguments{ 10 | \item{objOrTypename}{a character vector of length one. It can be the full file name of the assembly to load, or a fully qualified assembly name, or as a last resort a partial name.} 11 | } 12 | \value{ 13 | the CLR Type. 14 | } 15 | \description{ 16 | Gets the type of a CLR object given its type name 17 | } 18 | -------------------------------------------------------------------------------- /man/clrGetTypesInAssembly.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrGetTypesInAssembly} 4 | \alias{clrGetTypesInAssembly} 5 | \title{Get a list of CLR type names exported by an assembly} 6 | \usage{ 7 | clrGetTypesInAssembly(assemblyName) 8 | } 9 | \arguments{ 10 | \item{assemblyName}{the name of the assembly} 11 | } 12 | \value{ 13 | the names of the types exported by the assembly 14 | } 15 | \description{ 16 | Get a list of CLR type names exported by an assembly 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | clrGetLoadedAssemblies() 22 | clrGetTypesInAssembly('ClrFacade') 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /man/clrInit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-internal.R 3 | \name{clrInit} 4 | \alias{clrInit} 5 | \title{Initialize a new CLR application domain} 6 | \usage{ 7 | clrInit(debug = FALSE) 8 | } 9 | \arguments{ 10 | \item{debug}{If using Mono, should the CLR be initialised to try to hook up to the mono soft debugger in MonoDevelop. This parameter has no effect if using MS.NET.} 11 | } 12 | \value{ 13 | nothing is returned by this function 14 | } 15 | \description{ 16 | Initialize a new CLR application domain 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /man/clrIs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrIs} 4 | \alias{clrIs} 5 | \title{Check whether an object is of a certain type} 6 | \usage{ 7 | clrIs(obj, type) 8 | } 9 | \arguments{ 10 | \item{obj}{an object} 11 | 12 | \item{type}{the object type to check for. It can be a character, of a object of CLR type System.RuntimeType} 13 | } 14 | \value{ 15 | TRUE or FALSE 16 | } 17 | \description{ 18 | Check whether an object is of a certain type. This function is meant to match the behavior of the 'is' keyword in C#. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | testClassName <- "Rclr.TestObject"; 24 | (testObj <- clrNew(testClassName)) 25 | clrIs(testObj, testClassName) 26 | clrIs(testObj, 'System.Object') 27 | clrIs(testObj, 'System.Double') 28 | (testObj <- clrNew('Rclr.TestMethodBinding')) 29 | # Test for interface definitions 30 | clrIs(testObj, 'Rclr.ITestMethodBindings') 31 | clrIs(testObj, clrGetType('Rclr.ITestMethodBindings')) 32 | clrIs(testObj, clrGetType('Rclr.TestMethodBinding')) 33 | clrIs(testObj, clrGetType('System.Reflection.Assembly')) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /man/clrLoadAssembly.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrLoadAssembly} 4 | \alias{clrLoadAssembly} 5 | \title{Loads a Common Language assembly.} 6 | \usage{ 7 | clrLoadAssembly(name) 8 | } 9 | \arguments{ 10 | \item{name}{a character vector of length one. It can be the full file name of the assembly to load, or a fully qualified assembly name, or as a last resort a partial name.} 11 | } 12 | \description{ 13 | Loads an assembly. Note that this is loaded in the single application domain that is created by rClr, not a separate application domain. 14 | } 15 | \examples{ 16 | \dontrun{ 17 | library(rClr) 18 | clrGetLoadedAssemblies() 19 | f <- file.path('SomeDirectory', 'YourDotNetBinaryFile.dll') 20 | f <- path.expand(f) 21 | stopifnot( file.exists(f) ) 22 | clrLoadAssembly(f) 23 | # Load an assembly from the global assembly cache (GAC) 24 | clrLoadAssembly("System.Windows.Presentation, 25 | Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") 26 | # The use of partial assembly names is discouraged; nevertheless it is supported 27 | clrLoadAssembly("System.Web.Services") 28 | clrGetLoadedAssemblies() 29 | } 30 | } 31 | \seealso{ 32 | \code{\link{.C}} which this function wraps 33 | } 34 | -------------------------------------------------------------------------------- /man/clrNew.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrNew} 4 | \alias{clrNew} 5 | \title{Create a new CLR object} 6 | \usage{ 7 | clrNew(typename, ...) 8 | } 9 | \arguments{ 10 | \item{typename}{type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{...}{additional method arguments passed to the object constructor via the call to .External} 13 | } 14 | \value{ 15 | a CLR object 16 | } 17 | \description{ 18 | Create a new CLR object 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(rClr) 23 | testClassName <- "Rclr.TestObject"; 24 | (testObj <- clrNew(testClassName)) 25 | # object with a constructor that has parameters 26 | (testObj <- clrNew(testClassName, as.integer(123))) 27 | clrLoadAssembly("System.Windows.Forms, Version=2.0.0.0, 28 | Culture=neutral, PublicKeyToken=b77a5c561934e089") 29 | f <- clrNew('System.Windows.Forms.Form') 30 | clrSet(f, 'Text', "Hello from '.NET'") 31 | clrCall(f, 'Show') 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /man/clrReflect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrReflect} 4 | \alias{clrReflect} 5 | \title{List the instance members of a CLR object} 6 | \usage{ 7 | clrReflect(clrobj) 8 | } 9 | \arguments{ 10 | \item{clrobj}{CLR object} 11 | } 12 | \value{ 13 | a list of methods, fields and properties of the CLR object 14 | } 15 | \description{ 16 | List the instance members of a CLR object, i.e. its methods, fields and properties. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | testClassName <- "Rclr.TestObject"; 22 | testObj <- clrNew(testClassName) 23 | clrReflect(testObj) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/clrSet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrSet} 4 | \alias{clrSet} 5 | \title{Sets the value of a field or property of an object or class} 6 | \usage{ 7 | clrSet(objOrType, name, value) 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{name}{the name of a field/property of the object} 13 | 14 | \item{value}{the value to set the field with} 15 | } 16 | \description{ 17 | Sets the value of a field or property of an object or class 18 | } 19 | \examples{ 20 | \dontrun{ 21 | library(rClr) 22 | testClassName <- "Rclr.TestObject"; 23 | testObj <- clrNew(testClassName) 24 | clrReflect(testObj) 25 | clrSet(testObj, 'FieldIntegerOne', 42) 26 | clrSet(testClassName, 'StaticPropertyIntegerOne', 42) 27 | 28 | # Using 'good old' Windows forms to say hello: 29 | clrLoadAssembly("System.Windows.Forms, Version=2.0.0.0, 30 | Culture=neutral, PublicKeyToken=b77a5c561934e089") 31 | f <- clrNew('System.Windows.Forms.Form') 32 | clrSet(f, 'Text', "Hello from '.NET'") 33 | clrCall(f, 'Show') 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /man/clrSetEnumProperty.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrSetEnumProperty} 4 | \alias{clrSetEnumProperty} 5 | \title{Sets the value of an enum field or property of an object or class} 6 | \usage{ 7 | clrSetEnumProperty(objOrType, name, enumtype, enumval) 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{name}{the name of a field/property of the object} 13 | 14 | \item{enumtype}{type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 15 | 16 | \item{enumval}{the value to set the field with} 17 | } 18 | \description{ 19 | Sets the value of an enum field or property of an object or class 20 | } 21 | -------------------------------------------------------------------------------- /man/clrShutdown.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrShutdown} 4 | \alias{clrShutdown} 5 | \title{Shuts down the current runtime.} 6 | \usage{ 7 | clrShutdown() 8 | } 9 | \value{ 10 | nothing is returned by this function 11 | } 12 | \description{ 13 | Shuts down the current runtime. 14 | } 15 | -------------------------------------------------------------------------------- /man/clrToString.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrToString} 4 | \alias{clrToString} 5 | \title{Calls the ToString method of an object} 6 | \usage{ 7 | clrToString(x) 8 | } 9 | \arguments{ 10 | \item{x}{any R object, which is converted to a CLR object on which to call ToString} 11 | } 12 | \value{ 13 | the string representation of the object in the CLR 14 | } 15 | \description{ 16 | Calls the ToString method of an object as represented in the CLR. 17 | This function is here to help quickly test object equivalence from the R interpreter, for instance on the tricky topic of date-time conversions 18 | } 19 | \examples{ 20 | \dontrun{ 21 | library(rClr) 22 | dt <- as.POSIXct('2001-01-01 02:03:04', tz='UTC') 23 | clrToString(dt) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/clrTraceback.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrTraceback} 4 | \alias{clrTraceback} 5 | \title{Prints the last CLR exception} 6 | \usage{ 7 | clrTraceback() 8 | } 9 | \description{ 10 | Prints the last CLR exception. This is roughly the equivalent of the traceback function of R. 11 | } 12 | \examples{ 13 | \dontrun{ 14 | clrCallStatic("Rclr.TestCases", "ThrowException", 10L) # will be truncated by the Rf_error API 15 | clrTraceback() # prints the full stack trace 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /man/clrTypeNameExtPtr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrTypeNameExtPtr} 4 | \alias{clrTypeNameExtPtr} 5 | \title{Gets the type name of an object} 6 | \usage{ 7 | clrTypeNameExtPtr(extPtr) 8 | } 9 | \arguments{ 10 | \item{extPtr}{external pointer to a CLR object (not a cobjRef S4 object)} 11 | } 12 | \value{ 13 | a character string, the type name 14 | } 15 | \description{ 16 | Gets the type name of an object, given the SEXP external pointer to this CLR object. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | testClassName <- "Rclr.TestObject"; 22 | testObj <- clrNew(testClassName) 23 | clrTypeNameExtPtr(clrGetExtPtr(testObj)) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/clrTypename.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrTypename} 4 | \alias{clrTypename} 5 | \title{Gets the type name of an object} 6 | \usage{ 7 | clrTypename(clrobj) 8 | } 9 | \arguments{ 10 | \item{clrobj}{CLR object} 11 | } 12 | \value{ 13 | type name 14 | } 15 | \description{ 16 | Gets the CLR type name of an object, given an S4 clrobj object 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | testClassName <- "Rclr.TestObject"; 22 | testObj <- clrNew(testClassName) 23 | clrTypename(testObj) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/clrVT.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{clrVT} 4 | \alias{clrVT} 5 | \title{Get the COM variant type of a CLR object} 6 | \usage{ 7 | clrVT(objOrType, methodName, ...) 8 | } 9 | \arguments{ 10 | \item{objOrType}{a CLR object, or type name, possibly namespace and assembly qualified type name, e.g. 'My.Namespace.MyClass,MyAssemblyName'.} 11 | 12 | \item{methodName}{the name of the method called on the object or class specified with objOrType} 13 | 14 | \item{...}{one or more arguments to pass to the function call} 15 | } 16 | \value{ 17 | A string 18 | } 19 | \description{ 20 | Get the COM variant type of a CLR object, e.g. "VT_ARRAY | VT_I8". This function only works when run on the Microsoft implementation of the CLR. 21 | This function is useful for advanced diagnosis; most users should never have to use it. 22 | } 23 | \examples{ 24 | \dontrun{ 25 | library(rClr) 26 | cTypename <- "Rclr.TestCases" 27 | # public static bool IsTrue(bool arg) 28 | clrVT(cTypename, 'IsTrue', TRUE) 29 | clrVT('System.Convert', 'ToInt64', 123L) 30 | clrVT('System.Convert', 'ToUInt64', 123L) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /man/dotOnAttach.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{dotOnAttach} 4 | \alias{dotOnAttach} 5 | \alias{.onAttach} 6 | \title{rClr .onAttach} 7 | \usage{ 8 | .onAttach(libname = "~/R", pkgname = "rClr") 9 | } 10 | \arguments{ 11 | \item{libname}{the path to the library from which the package is loaded} 12 | 13 | \item{pkgname}{the name of the package.} 14 | } 15 | \description{ 16 | Print startup messages from package onLoad 17 | } 18 | \details{ 19 | Print startup messages from package onLoad (prevents a 'NOTE' on package check) 20 | } 21 | -------------------------------------------------------------------------------- /man/dotOnLoad.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{dotOnLoad} 4 | \alias{dotOnLoad} 5 | \alias{.onLoad} 6 | \title{rClr .onLoad} 7 | \usage{ 8 | .onLoad(libname = "~/R", pkgname = "rClr") 9 | } 10 | \arguments{ 11 | \item{libname}{the path to the library from which the package is loaded} 12 | 13 | \item{pkgname}{the name of the package.} 14 | } 15 | \description{ 16 | Function called when loading the rClr package with 'library'. 17 | } 18 | \details{ 19 | The function looks by default for the rClr native library for the Mono runtime. 20 | If the platform is Linux, this is the only option. If the platform is Windows, using the 21 | Microsoft .NET runtime is an option. If the rClr native library for MS.NET is detected, 22 | the Microsoft .NET runtime is loaded in preference to Mono. 23 | } 24 | -------------------------------------------------------------------------------- /man/getClrVersionString.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{getClrVersionString} 4 | \alias{getClrVersionString} 5 | \title{Gets the version of the common language runtime in use} 6 | \usage{ 7 | getClrVersionString() 8 | } 9 | \value{ 10 | the version of the common language runtime in use 11 | } 12 | \description{ 13 | Gets the version of the common language runtime in use. 14 | } 15 | -------------------------------------------------------------------------------- /man/getCurrentConvertedObject.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{getCurrentConvertedObject} 4 | \alias{getCurrentConvertedObject} 5 | \title{System function to get a direct access to an object} 6 | \usage{ 7 | getCurrentConvertedObject() 8 | } 9 | \value{ 10 | a CLR object 11 | } 12 | \description{ 13 | This function needs to be exported, but is highly unlikely to be of any use to an end user, even an advanced one. 14 | This is indirectly needed to unlock the benefits of using R.NET convert data structures between R and .NET. 15 | Using this function is a critical part of solving the rather complicated issue rClr #33. 16 | } 17 | -------------------------------------------------------------------------------- /man/getNativeLibsPath.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{getNativeLibsPath} 4 | \alias{getNativeLibsPath} 5 | \title{Architecture dependent path to the rClr native library} 6 | \usage{ 7 | getNativeLibsPath(pkgName) 8 | } 9 | \arguments{ 10 | \item{pkgName}{the name of a package, e.g. 'rClr'} 11 | } 12 | \value{ 13 | the prospective path in which a native library would be found, e.g. c:/R/library/rClr/libs/x64 14 | } 15 | \description{ 16 | Guess the directory where to expect the architecture dependent native library of a specified package 17 | e.g. for the package rClr, ${R_HOME}/library/rClr/libs/x64 18 | This is a utility that is not specific to the rClr package 19 | } 20 | -------------------------------------------------------------------------------- /man/getSexpType.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{getSexpType} 4 | \alias{getSexpType} 5 | \title{Get the type code for a SEXP} 6 | \usage{ 7 | getSexpType(sexp) 8 | } 9 | \arguments{ 10 | \item{sexp}{an R object} 11 | } 12 | \value{ 13 | the type code, an integer, as defined in Rinternals.h 14 | } 15 | \description{ 16 | Get the type code for a SEXP, as returned by the TYPEOF macro 17 | } 18 | -------------------------------------------------------------------------------- /man/inspectArgs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{inspectArgs} 4 | \alias{inspectArgs} 5 | \title{Peek into the structure of R objects 'as seen from C code'} 6 | \usage{ 7 | inspectArgs(...) 8 | } 9 | \arguments{ 10 | \item{...}{one or more R objects} 11 | } 12 | \value{ 13 | NULL. Information is printed, not returned. 14 | } 15 | \description{ 16 | Inspect one or more R object to get information on its representation in the engine. 17 | This function is mostly useful for R/rClr developers. It is derived from the 'showArgs' 18 | example in the R extension manual 19 | } 20 | -------------------------------------------------------------------------------- /man/mkClrObjRef.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-internal.R 3 | \name{mkClrObjRef} 4 | \alias{mkClrObjRef} 5 | \title{Create if possible an S4 CLR object.} 6 | \usage{ 7 | mkClrObjRef(obj, clrtype = NULL) 8 | } 9 | \arguments{ 10 | \item{obj}{the presumed external pointer.} 11 | 12 | \item{clrtype}{character; the name of the CLR type for the object. If NULL, rClr retrieves the type name.} 13 | } 14 | \value{ 15 | a cobjRef S4 object if the argument is indeed an external pointer, 16 | otherwise returned unchanged if null or not an external pointer. 17 | } 18 | \description{ 19 | Create if possible and adequate the S4 object that wraps the external pointer to a CLR object. 20 | Currently not exported, as this is unlikely to be recommended for use outside of unit tests and internal to rClr. 21 | } 22 | -------------------------------------------------------------------------------- /man/peekClrArgs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{peekClrArgs} 4 | \alias{peekClrArgs} 5 | \title{Peek into the types of CLR objects arguments are converted to by rClr} 6 | \usage{ 7 | peekClrArgs(...) 8 | } 9 | \arguments{ 10 | \item{...}{method arguments passed to .External} 11 | } 12 | \value{ 13 | a character message with type information about each argument. 14 | } 15 | \description{ 16 | Advanced use only, to diagnose unexpected conditions in CLR method calls. Most users would not ever need it. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(rClr) 21 | peekClrArgs("a", numeric(0)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/rClr-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-package.r 3 | \docType{package} 4 | \name{rClr-package} 5 | \alias{rClr-package} 6 | \alias{rClr} 7 | \title{R accessing .NET/Mono} 8 | \description{ 9 | Accessing the Common Language Runtime (.NET/Mono) from R 10 | } 11 | \details{ 12 | \tabular{ll}{ 13 | Package: \tab rClr\cr 14 | Type: \tab Package\cr 15 | Version: \tab 0.8.3\cr 16 | Notes: \tab Works with R 3.5.x series. .NET code targets netstandard2.0.\cr 17 | Date: \tab 2019-05-09\cr 18 | License: \tab LGPL 3\cr 19 | } 20 | 21 | rClr is a package for low-level access from R to a Common Language Runtime (CLR). The supported CLR implementations are Microsoft '.NET' 22 | framework on Windows and Mono on several platforms, currently Windows and at least Debian Linux. rClr has been used in scientific modelling work since 23 | 2013-06. Running it on Mono has been relatively experimental, but as of November 2014 several factors have enabled very near functional parity with the Windows/.NET. 24 | 25 | \tabular{lll}{ 26 | Version \tab Date \tab Notes \cr 27 | 0.8.2: \tab 2019-04-09 \tab preview release - work on R 3.5.x, which has significant changes under the hood. \cr 28 | 0.8.1: \tab 2019-04-08 \tab preview release - work on R 3.5.x, which has significant changes under the hood. \cr 29 | 0.8.0: \tab 2015-11-01 \tab Tidy up build process and upgrade to latest recommended practices, notably with testthat. \cr 30 | 0.7-9: \tab 2015-08-30 \tab allow compilation against boehm and SGen versions of mono lib. minor build improvements. \cr 31 | 0.7-8: \tab 2015-08-04 \tab Update to use R.NET 1.6.5. Allow for backward compatibility down to R 2.15.3 - While all relevant tests work, note that the level of testing is not on par with tests on R 3.2.x. \cr 32 | 0.7-7: \tab 2015-06-18 \tab Update to use R.NET 1.6.4. Functionally unchanged otherwise. Not a public release \cr 33 | 0.7-6: \tab 2015-05-07 \tab update the R Markdown vignettes to work with the latest version of knitr. Not a public release \cr 34 | 0.7-5: \tab 2015-04-06 \tab Internal release for work project. Compile against mono sgen rather than boehm. \cr 35 | } 36 | 37 | I gratefully acknowledge Kosei Abe and others for their work on the dependency R.NET (see https://github.com/jmp75/rdotnet/graphs/contributors) 38 | } 39 | \author{ 40 | Jean-Michel Perraud \email{jean-michel.perraud_at_csiro.au} 41 | } 42 | \keyword{.NET} 43 | \keyword{CLR} 44 | \keyword{Mono} 45 | \keyword{package} 46 | -------------------------------------------------------------------------------- /man/rToClrType.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{rToClrType} 4 | \alias{rToClrType} 5 | \title{Gets the type of a CLR object resulting from converting an R object} 6 | \usage{ 7 | rToClrType(x) 8 | } 9 | \arguments{ 10 | \item{x}{An R objects} 11 | } 12 | \value{ 13 | A list, with columns including mode, type,class,length and the string of the corresponding CLR type. 14 | } 15 | \description{ 16 | Gets the type of a CLR object resulting from converting an R object. This function is mostly for documentation purposes, but may be of use to end users. 17 | } 18 | -------------------------------------------------------------------------------- /man/setClrRefClass.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{setClrRefClass} 4 | \alias{setClrRefClass} 5 | \title{Create reference classes for an object hierarchy} 6 | \usage{ 7 | setClrRefClass(typeName, env = topenv(parent.frame())) 8 | } 9 | \arguments{ 10 | \item{typeName}{a CLR type name, recognizable by clrGetType} 11 | 12 | \item{env}{environment where the new generator is created.} 13 | } 14 | \value{ 15 | the object generator function 16 | } 17 | \description{ 18 | EXPERIMENTAL Create reference classes for an object hierarchy. Gratefully acknowledge Peter D. and its rJavax work. 19 | } 20 | -------------------------------------------------------------------------------- /man/setConvertAdvancedTypes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{setConvertAdvancedTypes} 4 | \alias{setConvertAdvancedTypes} 5 | \title{Turn on/off the conversion of advanced data types with R.NET} 6 | \usage{ 7 | setConvertAdvancedTypes(enable = TRUE) 8 | } 9 | \arguments{ 10 | \item{enable}{if true enable, otherwise disable} 11 | } 12 | \description{ 13 | Turn on/off the conversion of advanced data types with R.NET. This will turn off the conversion of classes such as dictionaries into R lists, 14 | as these are not bidirectional and you may want to see and manipulate external pointers to dictionaries in some circumstances. 15 | } 16 | \examples{ 17 | \dontrun{ 18 | library(rClr) 19 | cTypename <- "Rclr.TestCases" 20 | clrCallStatic(cTypename, "CreateStringDictionary") 21 | setConvertAdvancedTypes(FALSE) 22 | clrCallStatic(cTypename, "CreateStringDictionary") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /man/setRDotNet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rClr-exported.R 3 | \name{setRDotNet} 4 | \alias{setRDotNet} 5 | \title{Turn on/off R.NET} 6 | \usage{ 7 | setRDotNet(setit = TRUE) 8 | } 9 | \arguments{ 10 | \item{setit}{if true enable, otherwise disable} 11 | } 12 | \description{ 13 | Turn on or off the usage of the R.NET assemblies to convert CLR objects to R data structures. As of version 0.7.0, R.NET is the preferred way to convert data and is enabled by default. 14 | } 15 | \examples{ 16 | \dontrun{ 17 | library(rClr) 18 | ## R.NET is currently used to convert complicated CLR types to sensible R equivalents 19 | setRDotNet() 20 | cTypename <- "Rclr.TestCases" 21 | clrCallStatic(cTypename, "CreateStringDictionary") 22 | setRDotNet(FALSE) 23 | clrCallStatic(cTypename, "CreateStringDictionary") 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ClrFacade/ClassDiagram.cd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | gAE7BAAQIAAFAEiE8gSQhSAgQFYUQAlQFAQACoQAWRA= 10 | ClrFacade.cs 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | DataConversionHelper.cs 19 | 20 | 21 | 22 | 23 | AlQAAAACAAAAFAAQAAAAAAgAAAAAgAAAAEEAAAAggAA= 24 | DataConversionHelper.cs 25 | 26 | 27 | 28 | 29 | 30 | AAAAAAAAAAAAAAAABAAAAAAAAACAAAAAABAQAAIAAAA= 31 | DataConverterExtensions.cs 32 | 33 | 34 | 35 | 36 | 37 | QAHCiKCEgDiAlAMQEAgAYBKEkAEQEhAUCYEAAFEgRpA= 38 | ReflectionHelper.cs 39 | 40 | 41 | 42 | 43 | 44 | DIOQsgQB5yUWAywAAQQwgSgQBSISlARAAJAckkYJSIA= 45 | RDotNetDataConverter.cs 46 | 47 | 48 | 49 | 50 | 51 | 52 | AAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAABAA= 53 | RclrUnmanagedDll.cs 54 | 55 | 56 | 57 | 58 | 59 | 60 | AAAAoAAAAAAEAQAAAAAAAAAAAAAAAAAAAAAIAgIAAAA= 61 | IDataConverter.cs 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/ClrFacade/ClrFacade.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {024B0C26-BED0-467D-B332-E9796B756133} 7 | Library 8 | netstandard2.0 9 | 0.8.1 10 | (c) 2014-2019 Jean-Michel Perraud 11 | .NET interoperability on top of R.NET for the rClr package 12 | rClr 13 | 14 | Jean-Michel Perraud 15 | ClrFacade; embed .NET in R 16 | https://github.com/jmp75/rclr/blob/master/License.txt 17 | https://github.com/jmp75/rclr 18 | https://github.com/jmp75/rclr 19 | Migration to .NET Standard 2.0 and supporting R 3.5.x 20 | 21 | true 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/ClrFacade/DataConverterExtensions.cs: -------------------------------------------------------------------------------- 1 | using RDotNet.Utilities; 2 | 3 | namespace Rclr 4 | { 5 | /// 6 | /// Extension methods to facilitate data marshalling between R and the CLR 7 | /// 8 | public static class DataConverterExtensions 9 | { 10 | public static double[][] ToDouble(this float[][] array) 11 | { 12 | return ArrayConverter.ArrayConvertAll(array, x => (double)x); 13 | } 14 | 15 | public static double[,] ToDoubleRect(this float[][] array) 16 | { 17 | return array.ToDouble().ToRect(); 18 | } 19 | 20 | public static bool IsRectangular(this T[][] array) 21 | { 22 | if (array.Length == 0) 23 | return true; 24 | else 25 | { 26 | if (array[0] == null) 27 | return false; 28 | int firstLen = array[0].Length; 29 | for (int i = 1; i < array.Length; i++) 30 | { 31 | if (array[i] == null) return false; 32 | else if (array[i].Length != firstLen) return false; 33 | } 34 | } 35 | return true; 36 | } 37 | 38 | public static T[,] ToRect(this T[][] array) 39 | { 40 | var result = new T[array.Length, array[0].Length]; 41 | for (int i = 0; i < array.Length; i++) 42 | for (int j = 0; j < array[0].Length; j++) 43 | result[i, j] = array[i][j]; 44 | return result; 45 | } 46 | 47 | public static double[,] ToDoubleRect(this float[,] array) 48 | { 49 | return ArrayConverter.ArrayConvertAll(array, x => (double)x); 50 | } 51 | 52 | public static float[,] ToFloatRect(this float[][] array) 53 | { 54 | var result = new float[array.Length, array[0].Length]; 55 | for (int i = 0; i < array.Length; i++) 56 | for (int j = 0; j < array[0].Length; j++) 57 | result[i, j] = array[i][j]; 58 | return result; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/ClrFacade/HelloWorld.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr 7 | { 8 | /// 9 | /// Support for the package vignette 10 | /// 11 | public class HelloWorld 12 | { 13 | public static string Hello() { return "Hello, World!"; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ClrFacade/IDataConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using RDotNet; 5 | 6 | namespace Rclr 7 | { 8 | /// 9 | /// Interface for objects that are convering CLR objects to a representation in R 10 | /// 11 | /// Currently the only concrete implementation is a data converter that uses RDotNet 12 | /// to expose CLR objects to R 13 | public interface IDataConverter 14 | { 15 | object ConvertToR(object obj); 16 | object ConvertFromR(IntPtr pointer, int sexptype); 17 | 18 | /// 19 | /// Return a reference to the object currently handled by the custom data converter, if any is in use. 20 | /// 21 | /// 22 | /// See https://rclr.codeplex.com/workitem/33 for why we need this. 23 | /// 24 | object CurrentObject { get; } 25 | 26 | // TODO: this should not be here, but for now a convenient way to access Rf_error via R.NET 27 | void Error(string msg); 28 | 29 | SymbolicExpression CreateSymbolicExpression(IntPtr sexp); 30 | 31 | object[] ConvertSymbolicExpressions(object[] arguments); 32 | 33 | object ConvertSymbolicExpression(object obj); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/ClrFacade/PerformanceProfiling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Rclr 5 | { 6 | /// 7 | /// A class to use in order to measure the time cost of rClr features. 8 | /// 9 | public class PerformanceProfiling 10 | { 11 | public static double GetElapsedSeconds(Stopwatch sw) 12 | { 13 | long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency; 14 | var deltaNano = sw.ElapsedTicks * nanosecPerTick; 15 | return deltaNano / 1e9; 16 | } 17 | 18 | public void SetDoubleArrays(int seed, int length, int numArrays) 19 | { 20 | doubleArray = new double[numArrays][]; 21 | Random r = new Random(seed); 22 | for (int i = 0; i < doubleArray.Length; i++) 23 | { 24 | doubleArray[i] = new double[length]; 25 | for (int j = 0; j < length; j++) 26 | doubleArray[i][j] = r.NextDouble(); 27 | } 28 | counterDouble = 0; 29 | } 30 | 31 | private double[][] doubleArray; 32 | private int counterDouble; 33 | public double[] GetNextArrayDouble() 34 | { 35 | var res = doubleArray[counterDouble % doubleArray.Length]; 36 | counterDouble++; 37 | return res; 38 | } 39 | 40 | public void CallMethodWithArrayDouble(double[] someParameter) 41 | { 42 | // nothing 43 | } 44 | 45 | public void ArrayDoubleSink(double[] ignored) 46 | { 47 | // nothing. 48 | } 49 | 50 | public void DoNothing() 51 | { 52 | // nothing. 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/ClrFacade/RclrBinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace Rclr 8 | { 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// https://rclr.codeplex.com/workitem/15 14 | /// 15 | internal class RclrBinder : Binder 16 | { 17 | private Binder defaultBinder = System.Type.DefaultBinder; 18 | 19 | public override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, System.Globalization.CultureInfo culture) 20 | { 21 | return defaultBinder.BindToField(bindingAttr, match, value, culture); 22 | } 23 | 24 | public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] names, out object state) 25 | { 26 | return defaultBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state); 27 | } 28 | 29 | public override object ChangeType(object value, Type type, System.Globalization.CultureInfo culture) 30 | { 31 | return defaultBinder.ChangeType(value, type, culture); 32 | } 33 | 34 | public override void ReorderArgumentArray(ref object[] args, object state) 35 | { 36 | defaultBinder.ReorderArgumentArray(ref args, state); 37 | } 38 | 39 | public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers) 40 | { 41 | var defaultMatch = defaultBinder.SelectMethod(bindingAttr, match, types, modifiers); 42 | if (defaultMatch != null) 43 | return defaultMatch; 44 | // otherwise, let's have a parameter matching that accepts double[] to float[] conversions. 45 | // KLUDGE Note that this is likely to not be stringent enough and missing some things. 46 | // Unfortunately there is is no easy way in the Binder API to inject a specific type conversion, 47 | // which would be very convenient here. 48 | List results = new List(); 49 | for (int i = 0; i < match.Length; i++) 50 | { 51 | ParameterInfo[] pInfos = match[i].GetParameters(); 52 | if (pInfos.Length != types.Length) 53 | continue; 54 | bool accepted = true; 55 | for (int j = 0; j < types.Length; j++) 56 | { 57 | Type paramType = pInfos[j].ParameterType; 58 | if (paramType == types[j]) 59 | continue; 60 | if (paramType == typeof(Object)) 61 | continue; 62 | if (paramType == typeof(float[]) && types[j] == typeof(double[])) 63 | continue; 64 | else 65 | { 66 | if (!paramType.IsAssignableFrom(types[j])) 67 | { 68 | accepted = false; 69 | break; 70 | } 71 | } 72 | } 73 | if (accepted) 74 | results.Add(match[i]); 75 | } 76 | if (results.Count > 0) 77 | return results[0]; 78 | else 79 | return null; 80 | } 81 | 82 | public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers) 83 | { 84 | return defaultBinder.SelectProperty(bindingAttr, match, returnType, indexes, modifiers); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/ClrFacade/RclrUnmanagedDll.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using RDotNet.NativeLibrary; 3 | using System.Runtime.InteropServices; 4 | using System.Reflection; 5 | using System.IO; 6 | using DynamicInterop; 7 | 8 | namespace Rclr 9 | { 10 | public class RclrUnmanagedDll : IUnmanagedDll 11 | { 12 | public RclrUnmanagedDll(string dllName) 13 | { 14 | if (!File.Exists(dllName)) 15 | { 16 | throw new FileNotFoundException(dllName); 17 | } 18 | this.dll = new UnmanagedDll(dllName); 19 | this.ClrObjectToSexp = dll.GetFunction("clr_object_to_SEXP"); 20 | } 21 | 22 | public ClrObjectToSexpDelegate ClrObjectToSexp { get; set; } 23 | 24 | private UnmanagedDll dll; 25 | 26 | 27 | public IntPtr GetFunctionAddress(string entryPointName) 28 | { 29 | return dll.GetFunctionAddress(entryPointName); 30 | } 31 | } 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/ClrFacade/RdotnetDataConverterTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using RDotNet; 6 | 7 | namespace Rclr 8 | { 9 | public class RdotnetDataConverterTests 10 | { 11 | public class MemTestObjectRDotnet : RDotNet.NumericVector 12 | { 13 | public static int counter = 0; 14 | public MemTestObjectRDotnet(double[] values) 15 | : base(RdotnetDataConverterTests.REngine, values) 16 | { 17 | counter++; 18 | } 19 | ~MemTestObjectRDotnet() { counter--; } 20 | } 21 | 22 | public static int GetMemTestObjCounterRDotnet() 23 | { 24 | return MemTestObjectRDotnet.counter; 25 | } 26 | 27 | public static object CreateMemTestObjRDotnet() 28 | { 29 | return new MemTestObjectRDotnet(Rclr.TestCases.CreateNumArray()); 30 | } 31 | 32 | internal static REngine REngine 33 | { 34 | get 35 | { 36 | var rdotnetconverter = ClrFacade.DataConverter as RDotNetDataConverter; 37 | if (rdotnetconverter == null) 38 | return null; 39 | else 40 | return RDotNetDataConverter.GetEngine(); 41 | } 42 | } 43 | 44 | private static Tuple tc(string name, double[] values) 45 | { 46 | return Tuple.Create(name, REngine.CreateNumericVector(values)); 47 | } 48 | 49 | private static Tuple tc(string name, string[] values) 50 | { 51 | return Tuple.Create(name, REngine.CreateCharacterVector(values)); 52 | } 53 | 54 | public static SymbolicExpression CreateTestDataFrame() 55 | { 56 | var dfFun = REngine.Evaluate("data.frame").AsFunction(); 57 | var result = dfFun.InvokeNamed( 58 | tc("name", new[] {"a","b","c"}), 59 | tc("a", new[] {1.0, 2.0, 3.0}) 60 | ); 61 | return result; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/ClrFacade/TestArrayMemoryHandling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Rclr; 4 | 5 | namespace Rclr 6 | { 7 | /// 8 | /// Do not modify the .cs file: T4 generated class to support the unit tests for method binding 9 | /// 10 | /// 11 | /// Added initially as a basis for unit test for issue https://r2clr.codeplex.com/workitem/70 12 | /// 13 | public class TestArrayMemoryHandling 14 | { 15 | 16 | public object[] FieldArray_object; 17 | public static object[] CreateArray_object(int size) 18 | { 19 | return (object[])Array.CreateInstance(typeof(object), size); 20 | } 21 | public static object[] CreateArray_object(int size, object value) 22 | { 23 | var result = (object[])Array.CreateInstance(typeof(object), size); 24 | for(int i = 0; i < result.Length; i++) result[i] = value; 25 | return result; 26 | } 27 | 28 | public string[] FieldArray_string; 29 | public static string[] CreateArray_string(int size) 30 | { 31 | return (string[])Array.CreateInstance(typeof(string), size); 32 | } 33 | public static string[] CreateArray_string(int size, string value) 34 | { 35 | var result = (string[])Array.CreateInstance(typeof(string), size); 36 | for(int i = 0; i < result.Length; i++) result[i] = value; 37 | return result; 38 | } 39 | 40 | public double[] FieldArray_double; 41 | public static double[] CreateArray_double(int size) 42 | { 43 | return (double[])Array.CreateInstance(typeof(double), size); 44 | } 45 | public static double[] CreateArray_double(int size, double value) 46 | { 47 | var result = (double[])Array.CreateInstance(typeof(double), size); 48 | for(int i = 0; i < result.Length; i++) result[i] = value; 49 | return result; 50 | } 51 | 52 | public float[] FieldArray_float; 53 | public static float[] CreateArray_float(int size) 54 | { 55 | return (float[])Array.CreateInstance(typeof(float), size); 56 | } 57 | public static float[] CreateArray_float(int size, float value) 58 | { 59 | var result = (float[])Array.CreateInstance(typeof(float), size); 60 | for(int i = 0; i < result.Length; i++) result[i] = value; 61 | return result; 62 | } 63 | 64 | public int[] FieldArray_int; 65 | public static int[] CreateArray_int(int size) 66 | { 67 | return (int[])Array.CreateInstance(typeof(int), size); 68 | } 69 | public static int[] CreateArray_int(int size, int value) 70 | { 71 | var result = (int[])Array.CreateInstance(typeof(int), size); 72 | for(int i = 0; i < result.Length; i++) result[i] = value; 73 | return result; 74 | } 75 | 76 | public long[] FieldArray_long; 77 | public static long[] CreateArray_long(int size) 78 | { 79 | return (long[])Array.CreateInstance(typeof(long), size); 80 | } 81 | public static long[] CreateArray_long(int size, long value) 82 | { 83 | var result = (long[])Array.CreateInstance(typeof(long), size); 84 | for(int i = 0; i < result.Length; i++) result[i] = value; 85 | return result; 86 | } 87 | 88 | public bool[] FieldArray_bool; 89 | public static bool[] CreateArray_bool(int size) 90 | { 91 | return (bool[])Array.CreateInstance(typeof(bool), size); 92 | } 93 | public static bool[] CreateArray_bool(int size, bool value) 94 | { 95 | var result = (bool[])Array.CreateInstance(typeof(bool), size); 96 | for(int i = 0; i < result.Length; i++) result[i] = value; 97 | return result; 98 | } 99 | 100 | public DateTime[] FieldArray_DateTime; 101 | public static DateTime[] CreateArray_DateTime(int size) 102 | { 103 | return (DateTime[])Array.CreateInstance(typeof(DateTime), size); 104 | } 105 | public static DateTime[] CreateArray_DateTime(int size, DateTime value) 106 | { 107 | var result = (DateTime[])Array.CreateInstance(typeof(DateTime), size); 108 | for(int i = 0; i < result.Length; i++) result[i] = value; 109 | return result; 110 | } 111 | 112 | public TimeSpan[] FieldArray_TimeSpan; 113 | public static TimeSpan[] CreateArray_TimeSpan(int size) 114 | { 115 | return (TimeSpan[])Array.CreateInstance(typeof(TimeSpan), size); 116 | } 117 | public static TimeSpan[] CreateArray_TimeSpan(int size, TimeSpan value) 118 | { 119 | var result = (TimeSpan[])Array.CreateInstance(typeof(TimeSpan), size); 120 | for(int i = 0; i < result.Length; i++) result[i] = value; 121 | return result; 122 | } 123 | 124 | public byte[] FieldArray_byte; 125 | public static byte[] CreateArray_byte(int size) 126 | { 127 | return (byte[])Array.CreateInstance(typeof(byte), size); 128 | } 129 | public static byte[] CreateArray_byte(int size, byte value) 130 | { 131 | var result = (byte[])Array.CreateInstance(typeof(byte), size); 132 | for(int i = 0; i < result.Length; i++) result[i] = value; 133 | return result; 134 | } 135 | 136 | public char[] FieldArray_char; 137 | public static char[] CreateArray_char(int size) 138 | { 139 | return (char[])Array.CreateInstance(typeof(char), size); 140 | } 141 | public static char[] CreateArray_char(int size, char value) 142 | { 143 | var result = (char[])Array.CreateInstance(typeof(char), size); 144 | for(int i = 0; i < result.Length; i++) result[i] = value; 145 | return result; 146 | } 147 | 148 | public Type[] FieldArray_Type; 149 | public static Type[] CreateArray_Type(int size) 150 | { 151 | return (Type[])Array.CreateInstance(typeof(Type), size); 152 | } 153 | public static Type[] CreateArray_Type(int size, Type value) 154 | { 155 | var result = (Type[])Array.CreateInstance(typeof(Type), size); 156 | for(int i = 0; i < result.Length; i++) result[i] = value; 157 | return result; 158 | } 159 | // To test the type of empty vectors: 160 | public static bool CheckElementType(Array array, Type expectedElementType) 161 | { 162 | return (array.GetType().GetElementType() == expectedElementType); 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /src/ClrFacade/TestArrayMemoryHandling.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var arrayTypes = new Dictionary 9 | { 10 | { "object", "object[]" }, 11 | { "string", "string[]" }, 12 | { "double", "double[]" }, 13 | { "float", "float[]" }, 14 | { "int", "int[]" }, 15 | { "long", "long[]" }, 16 | { "bool", "bool[]" }, 17 | { "DateTime", "DateTime[]" }, 18 | { "TimeSpan", "TimeSpan[]" }, 19 | { "byte", "byte[]" }, 20 | { "char", "char[]" }, 21 | { "Type", "Type[]" }, 22 | }; 23 | 24 | #> 25 | using System; 26 | using System.Reflection; 27 | using Rclr; 28 | 29 | namespace Rclr 30 | { 31 | /// 32 | /// Do not modify the .cs file: T4 generated class to support the unit tests for method binding 33 | /// 34 | /// 35 | /// Added initially as a basis for unit test for issue https://r2clr.codeplex.com/workitem/70 36 | /// 37 | public class TestArrayMemoryHandling 38 | { 39 | <# 40 | foreach (var item in arrayTypes) 41 | { 42 | #> 43 | 44 | public <#=item.Value#> FieldArray_<#=item.Key#>; 45 | public static <#=item.Value#> CreateArray_<#=item.Key#>(int size) 46 | { 47 | return (<#=item.Value#>)Array.CreateInstance(typeof(<#=item.Key#>), size); 48 | } 49 | public static <#=item.Value#> CreateArray_<#=item.Key#>(int size, <#=item.Key#> value) 50 | { 51 | var result = (<#=item.Value#>)Array.CreateInstance(typeof(<#=item.Key#>), size); 52 | for(int i = 0; i < result.Length; i++) result[i] = value; 53 | return result; 54 | } 55 | <# 56 | } // end foreach 57 | #> 58 | // To test the type of empty vectors: 59 | public static bool CheckElementType(Array array, Type expectedElementType) 60 | { 61 | return (array.GetType().GetElementType() == expectedElementType); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/ClrFacade/TestClassesDiagram.cd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= 7 | HelloWorld.cs 8 | 9 | 10 | 11 | 12 | 13 | AAAAAQQCAAAAAAAAAAAAAAAAAAAQAAACEAAAAAIEAAA= 14 | PerformanceProfiling.cs 15 | 16 | 17 | 18 | 19 | 20 | AAAAAIAAAAAAAAAAAAEAAQAAAEABAAAAAEAAIAAAAAA= 21 | RclrBinder.cs 22 | 23 | 24 | 25 | 26 | 27 | ABAARAEAIIAAAAUBAAgAIAgAAAAAEBEAAEGAAADEACQ= 28 | TestArrayMemoryHandling.cs 29 | 30 | 31 | 32 | 33 | 34 | gBAAMC0h5AwiyogQlEAAECEhhBM0AQCqAExhIFKhFEE= 35 | TestCases.cs 36 | 37 | 38 | 39 | 40 | 41 | AAAAAAEQEAABABAAIAEIYQIABAAAAAoIgCAAAFACACA= 42 | TestCases.cs 43 | 44 | 45 | 46 | 47 | 48 | AAKAAAAAAAEAAAAAAAAAAAAAACAAAAAAAAAAAAIAAAE= 49 | TestMethodBinding.cs 50 | 51 | 52 | 53 | 54 | 55 | 56 | AAAAAAAAAAAAAAAAgAAAAAAAAAAAAEQAAAAAAAAAAAA= 57 | Tests\RefClasses\BaseAbstractClassOne.cs 58 | 59 | 60 | 61 | 62 | 63 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAEACAAAAAAAA= 64 | Tests\RefClasses\LevelOneClass.cs 65 | 66 | 67 | 68 | 69 | 70 | 71 | AAAAAAAAAAAAABAAgAAAAAAAAAAAAAQAAAAAAAAAAAA= 72 | Tests\RefClasses\LevelThreeClass.cs 73 | 74 | 75 | 76 | 77 | 78 | AAAAAAAAAAAAABAAAAAQAAAAACAAAAAAAAAAAAAAAAA= 79 | Tests\RefClasses\LevelTwoClass.cs 80 | 81 | 82 | 83 | 84 | 85 | 86 | EAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAA= 87 | Tests\TestUtilities.cs 88 | 89 | 90 | 91 | 92 | 93 | AAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= 94 | TestMethodBinding.cs 95 | 96 | 97 | 98 | 99 | 100 | AAAAAAAAAAAAAAAAAAIAAAAAAAAAAACAAAAAAAAAAAA= 101 | Tests\RefClasses\InterfaceOne.cs 102 | 103 | 104 | 105 | 106 | 107 | AAAAAAAAAAAAAAAAAAAQAAAAACAAAAAAAAAAAAAAAAA= 108 | Tests\RefClasses\InterfaceOne.cs 109 | 110 | 111 | 112 | 113 | 114 | AAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= 115 | Tests\RefClasses\InterfaceOne.cs 116 | 117 | 118 | 119 | 120 | 121 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= 122 | Tests\RefClasses\InterfaceOne.cs 123 | 124 | 125 | 126 | 127 | 128 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAEAAAA= 129 | TestCases.cs 130 | 131 | 132 | 133 | 134 | 135 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAEAAAA= 136 | TestCases.cs 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /src/ClrFacade/TestMethodBinding.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | string[] methodParameters = new string[]{ 9 | "object obj","string x","double x","float x","int x","bool x","DateTime x","byte x", "char x", 10 | "object obj1, object obj2","string x1, string x2","double x1, double x2","float x1, float x2","int x1, int x2","bool x1, bool x2","DateTime x1, DateTime x2","byte x1, byte x2", "char x1, char x2", 11 | "object[] obj","string[] x","double[] x","float[] x","int[] x","bool[] x","DateTime[] x","byte[] x", "char[] x", 12 | "object[,] obj","string[,] x","double[,] x","float[,] x","int[,] x","bool[,] x","DateTime[,] x","byte[,] x", "char[,] x", 13 | "object[][] obj","string[][] x","double[][] x","float[][] x","int[][] x","bool[][] x","DateTime[][] x","byte[][] x", "char[][] x", 14 | // Let's pay particular attention to strings, as there is an odd behavior with the MS CLR hosting API, inconsistent with other value types. 15 | "double x, string y", "double x, string y, string z", "double x, string[] y", 16 | "string x, string[] y", "string[] x, string y", "string[] x, string[] y" 17 | }; 18 | #> 19 | using System; 20 | using System.Reflection; 21 | using Rclr; 22 | using System.Collections.Generic; 23 | using Rclr.Tests.RefClasses; 24 | 25 | namespace Rclr 26 | { 27 | /// 28 | /// Do not modify the .cs file: T4 generated class to support the unit tests for method binding 29 | /// 30 | public class TestMethodBinding : ITestMethodBindings 31 | { 32 | <# 33 | foreach (var item in methodParameters) 34 | { 35 | #> 36 | public static string[] SomeStaticMethod(<#=item#>) { return ReflectionHelper.GetMethodParameterTypes(MethodBase.GetCurrentMethod()); } 37 | public string[] SomeInstanceMethod(<#=item#>) { return ReflectionHelper.GetMethodParameterTypes(MethodBase.GetCurrentMethod()); } 38 | string[] ITestMethodBindings.SomeExplicitlyImplementedMethod(<#=item#>) { return ReflectionHelper.GetMethodParameterTypes(MethodBase.GetCurrentMethod()); } 39 | <# 40 | } // end foreach 41 | #> 42 | 43 | 44 | <# 45 | 46 | string[] methodParametersVarArgs = new string[]{ 47 | "int p1, int p2, params int [] p3", 48 | "object p1, int p2, params int [] p3", 49 | "int p1, object p2, params int [] p3", 50 | "object p1, object p2, params int [] p3", 51 | "int p1, int p2, params object [] p3", 52 | "object p1, int p2, params object [] p3", 53 | "int p1, object p2, params object [] p3", 54 | "object p1, object p2, params object [] p3", 55 | "object p1", 56 | "int p1" 57 | }; 58 | 59 | #> 60 | public static string[] GetOptionalParamsTestCases() { 61 | var list = new List(); 62 | <# 63 | foreach (var item in methodParametersVarArgs) 64 | { 65 | #> 66 | list.Add("<#=item#>"); 67 | <# 68 | } // end foreach 69 | #> 70 | return list.ToArray(); 71 | } 72 | <# 73 | 74 | 75 | foreach (var item in methodParametersVarArgs) 76 | { 77 | #> 78 | public static string SomeMethodWithVarArgs(<#=item#>) 79 | { 80 | return "<#=item#>"; 81 | } 82 | <# 83 | } // end foreach 84 | #> 85 | 86 | //========== Next section is to test the support (or lack thereof) with the most ambiguous cases with optional parameters 87 | 88 | <# 89 | 90 | string[] assignableCases = new string[]{ 91 | "InterfaceOne", 92 | "InterfaceTwo", 93 | "InterfaceBaseOne", 94 | "InterfaceBaseTwo", 95 | "BaseAbstractClassOne", 96 | "LevelOneClass", 97 | "LevelTwoClass" 98 | // "LevelThreeClass" // leave aside for tests in the RclrTests assembly for ambiguous matches 99 | }; 100 | 101 | 102 | foreach (var item in assignableCases) 103 | { 104 | #> 105 | public static string MultipleMatchVarArgs(object p1, <#=item#> p2, params object[] p3) 106 | { 107 | return "<#=item#>"; 108 | } 109 | <# 110 | } // end foreach 111 | #> 112 | 113 | } 114 | 115 | public interface ITestMethodBindings 116 | { 117 | <# 118 | foreach (var item in methodParameters) 119 | { 120 | #> 121 | string[] SomeExplicitlyImplementedMethod(<#=item#>); 122 | <# 123 | } // end foreach 124 | #> 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/ClrFacade/Tests/RefClasses/BaseAbstractClassOne.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr.Tests.RefClasses 7 | { 8 | public abstract class BaseAbstractClassOne 9 | { 10 | protected BaseAbstractClassOne(int someInt) 11 | { 12 | this.SomeInt = someInt; 13 | } 14 | protected BaseAbstractClassOne() 15 | { 16 | } 17 | 18 | public int SomeInt { get; private set; } 19 | 20 | public abstract string AbstractMethod(); 21 | public abstract string AbstractMethod(string arg); 22 | 23 | public virtual string VirtualMethod() { return "BaseAbstractClassOne.VirtualMethod"; } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ClrFacade/Tests/RefClasses/InterfaceOne.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr.Tests.RefClasses 7 | { 8 | public interface InterfaceOne 9 | { 10 | string IfOneString { get; set; } 11 | string IfOneStringGetter { get; } 12 | } 13 | 14 | public interface InterfaceBaseTwo 15 | { 16 | string IfBaseTwoString { get; set; } 17 | string IfBaseTwoMethod(); 18 | string IfBaseTwoMethod(string par); 19 | } 20 | 21 | public interface InterfaceBaseOne 22 | { 23 | string IfBaseOneString { get; set; } 24 | } 25 | 26 | public interface InterfaceTwo : InterfaceBaseOne, InterfaceBaseTwo 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/ClrFacade/Tests/RefClasses/LevelOneClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr.Tests.RefClasses 7 | { 8 | public class LevelOneClass : BaseAbstractClassOne, InterfaceOne 9 | { 10 | public override string AbstractMethod() 11 | { 12 | return "LevelOneClass::AbstractMethod()"; 13 | } 14 | 15 | public override string AbstractMethod(string arg) 16 | { 17 | return "LevelOneClass::AbstractMethod(string)"; 18 | } 19 | 20 | string InterfaceOne.IfOneString 21 | { 22 | get ; set ; 23 | } 24 | 25 | string InterfaceOne.IfOneStringGetter 26 | { 27 | get { return "Explicit LevelOneClass::InterfaceOne.IfOneStringGetter"; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/ClrFacade/Tests/RefClasses/LevelThreeClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr.Tests.RefClasses 7 | { 8 | public class LevelThreeClass : LevelTwoClass 9 | { 10 | public override string AbstractMethod() 11 | { 12 | return "LevelThreeClass::AbstractMethod()"; 13 | } 14 | 15 | public override string VirtualMethod() 16 | { 17 | return "LevelThreeClass::VirtualMethod()"; 18 | } 19 | 20 | public override string IfBaseOneString 21 | { 22 | get 23 | { 24 | return base.IfBaseOneString; 25 | } 26 | set 27 | { 28 | base.IfBaseOneString = "Overriden LevelThreeClass::IfBaseOneString " + value; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/ClrFacade/Tests/RefClasses/LevelTwoClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr.Tests.RefClasses 7 | { 8 | public class LevelTwoClass : LevelOneClass, InterfaceTwo 9 | { 10 | public virtual string IfBaseOneString { get; set; } 11 | 12 | public virtual string IfBaseTwoString { get; set; } 13 | 14 | public string IfBaseTwoMethod() 15 | { 16 | return "LevelTwoClass::IfBaseTwoMethod()"; 17 | } 18 | 19 | public string IfBaseTwoMethod(string par) 20 | { 21 | return "LevelTwoClass::IfBaseTwoMethod(string)"; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ClrFacade/Tests/TestUtilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Rclr.Tests 7 | { 8 | /// 9 | /// Utilities used for testing purposes. 10 | /// 11 | public static class TestUtilities 12 | { 13 | /// 14 | /// A string concatenator 15 | /// 16 | /// 17 | /// 18 | /// 19 | public static string Concat(IEnumerable values, string sep) 20 | { 21 | var strs = values.ToArray(); 22 | StringBuilder sb = new StringBuilder(); 23 | for (int i = 0; i < strs.Length - 1; i++) 24 | { 25 | sb.Append(strs[i]); sb.Append(sep); 26 | } 27 | sb.Append(strs[strs.Length - 1]); 28 | return sb.ToString(); 29 | } 30 | 31 | public static string[] BuildCombinatorialTestCases(string valForTrue, string valForFalse, int np = 5, string sep=", ") 32 | { 33 | int cases = (int)Math.Pow(2, np); 34 | var result = new string[cases]; 35 | for (int i = 0; i < cases; i++) 36 | { 37 | bool[] s = Convert.ToString(i, 2).ToCharArray().Select(x => x == '1').ToArray(); 38 | bool[] b = new bool[np]; 39 | Array.Copy(s, 0, b, b.Length - s.Length, s.Length); 40 | string[] paramsArray = Array.ConvertAll(b, x => (x ? valForTrue : valForFalse)); 41 | string paramsBody = TestUtilities.Concat(paramsArray, sep); 42 | result[i] = paramsBody; 43 | } 44 | return result; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/ClrFacade/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Makefile.win.in: -------------------------------------------------------------------------------- 1 | # Emacs please make this -*- mode: makefile; tab-width: 8 -*- 2 | # 3 | # rClr makefile specific for compilation on Windows, using the Visual CPP compiler. 4 | 5 | # defaults the build configurations to the 'release' ones (i.e. no debug symbols) 6 | BuildConfiguration ?= Release 7 | MonoBuildConfiguration ?= MonoInstall 8 | MODE ?= Build 9 | BuildMonoSupport ?= False 10 | MSB_OPTIONS_CONSOLELOGGER ?= //consoleloggerparameters:ErrorsOnly 11 | ## /consoleloggerparameters:ErrorsOnly;WarningsOnly;Verbosity=minimal 12 | 13 | SLN= rClr.sln 14 | 15 | # NOTE: do NOT use a nuget.exe under c:\bin\ even if in your path 16 | # somehow nuget would not be found because /bin has a special meaning in RTools. 17 | NUGET_CMD=nuget.exe 18 | 19 | MSB=@MSBUILD_EXE_PATH@ 20 | 21 | INSTDIR= ../inst 22 | 23 | # This can be helpful to diagnose the msbuild procedure 24 | # DEBUG_BUILD_CMD=/v:diag 25 | DEBUG_BUILD_CMD ?= 26 | 27 | MSB_OPTIONS_EXTRA=$(DEBUG_BUILD_CMD) $(MSB_OPTIONS_CONSOLELOGGER) 28 | ifneq "$(VS120COMNTOOLS)" "" 29 | # work around issue with VS2013, see https://rclr.codeplex.com/workitem/9 30 | MSB_OPTIONS_EXTRA=$(DEBUG_BUILD_CMD) //p:VisualStudioVersion=12.0 $(MSB_OPTIONS_CONSOLELOGGER) 31 | endif 32 | 33 | CLR_FACADE_BINS=ClrFacade.* 34 | RDOTNET_BINS=RDotNet.* DynamicInterop.* 35 | RCLRMS=rClrMs 36 | 37 | # I needed to use the -u -p options at some point to avoid odd cases where copying failed. 38 | # For some odd reasons the files under /libs/ are copied with access rights such that they fail to load with dyn.load 39 | # and R CMD check would fail with a misleading error message about not being a valid Win32 application. 40 | # CP_CMD=cp -u -p -f 41 | 42 | ROBOCP_CMD=cmd /c win_cp.cmd 43 | 44 | 45 | # all: configinfo instdir rClrLib 46 | 47 | all: diagnose 48 | 49 | diagnose: detailedconfiginfo instdir rClrLib 50 | 51 | configinfo: 52 | -@echo Build configuration "$(BuildConfiguration)" 53 | 54 | detailedconfiginfo: 55 | -@echo **Variable information only for diagnosis purposes** 56 | -@echo Windows architecture "$(R_ARCH)" 57 | -@echo "env variable TEMP is $(TEMP)" 58 | -@echo "env variable TMP is $(TMP)" 59 | -@echo BuildConfiguration=$(BuildConfiguration) 60 | -@echo BuildMonoSupport=$(BuildMonoSupport) 61 | -@echo Mono Build configuration "$(MonoBuildConfiguration)" 62 | -@echo R_ARCH=$(R_ARCH) 63 | -@echo OBJECTS=$(OBJECTS) 64 | -@echo SHLIB_EXT=$(SHLIB_EXT) 65 | -@echo CC=$(CC) 66 | -@echo CXX=$(CXX) 67 | -@echo ALL_CFLAGS=$(ALL_CFLAGS) 68 | -@echo ALL_CPPFLAGS=$(ALL_CPPFLAGS) 69 | -@echo build cmd line: $(MSB) $(SLN) //t:$(MODE) //p:Configuration=$(BuildConfiguration) //p:Platform="replaced_tgt_platform" $(MSB_OPTIONS_EXTRA); 70 | -@echo **END Variable** 71 | 72 | rClrNugetRestore: rClr.cpp 73 | -$(NUGET_CMD) restore $(SLN) ; 74 | 75 | rClrLibComp: rClrNugetRestore 76 | @for tgt_platform in x64 Win32; do \ 77 | $(MSB) $(SLN) //t:$(MODE) //p:Configuration=$(BuildConfiguration) //p:Platform="$$tgt_platform" $(MSB_OPTIONS_EXTRA); \ 78 | done; \ 79 | if [ "$(BuildMonoSupport)" = "True" ] ; then $(MSB) $(SLN) /t:$(MODE) //p:Configuration=$(MonoBuildConfiguration) ///p:Platform="Win32" $(MSB_OPTIONS_EXTRA) ; fi 80 | 81 | instdir: 82 | @for r_architecture in x64 i386; do \ 83 | rm -rf $(INSTDIR)/libs/$$r_architecture ; \ 84 | mkdir -p $(INSTDIR) 2>/dev/null ; \ 85 | mkdir -p $(INSTDIR)/libs/$$r_architecture 2>/dev/null ; \ 86 | done; 87 | 88 | rClrLib: rClrLibComp 89 | r_architecture=x64;\ 90 | RCLRBINDIR=./x64/$(BuildConfiguration);\ 91 | bin_dir=$$RCLRBINDIR; \ 92 | RCLRBINS="$(RCLRMS).dll $(RCLRMS).exp $(RCLRMS).lib $(RCLRMS).pdb" ; \ 93 | $(ROBOCP_CMD) $$bin_dir $(INSTDIR)/libs/$$r_architecture/ $$RCLRBINS; 94 | r_architecture=i386;\ 95 | RCLRBINDIR=./$(BuildConfiguration);\ 96 | bin_dir=$$RCLRBINDIR; \ 97 | RCLRBINS="$(RCLRMS).dll $(RCLRMS).exp $(RCLRMS).lib $(RCLRMS).pdb" ; \ 98 | $(ROBOCP_CMD) $$bin_dir $(INSTDIR)/libs/$$r_architecture/ $$RCLRBINS; 99 | bin_dir=./$(MonoBuildConfiguration); \ 100 | RCLRBINS="$$bin_dir/rClrMono.dll $$bin_dir/rClrMono.exp $$bin_dir/rClrMono.lib $$bin_dir/rClrMono.pdb" ; \ 101 | if [ "$(BuildMonoSupport)" = "True" ] ; then $(ROBOCP_CMD) $$RCLRBINS $(INSTDIR)/libs/i386/ ; fi ; 102 | -$(ROBOCP_CMD) ./ClrFacade/bin/$(BuildConfiguration)/netstandard2.0/ $(INSTDIR)/libs/ $(CLR_FACADE_BINS) 103 | -$(ROBOCP_CMD) ./ClrFacade/bin/$(BuildConfiguration)/netstandard2.0/ $(INSTDIR)/libs/ $(RDOTNET_BINS) 104 | 105 | clean: 106 | $(MSB) $(SLN) //t:Clean 107 | 108 | distclean: clean 109 | -rm -rf $(INSTDIR) 110 | 111 | .PHONY: all 112 | -------------------------------------------------------------------------------- /src/Makevars.in: -------------------------------------------------------------------------------- 1 | # Emacs please make this -*- mode: makefile; tab-width: 8 -*- 2 | # 3 | # 4 | # Copyright (C) 2013-2015 5 | # 6 | 7 | # WARNING: Makevars is generated from Makevars.in 8 | # You may loose direct modifications to the file Makevars! 9 | 10 | BUILDTYPE ?= Release 11 | 12 | # as of mono 4.0.3 on Debian, using monosgen fails. Need to offer the option to revert to boehm GC. 13 | MONO_LIB ?= monosgen-2 14 | # other acceptable option is MONO_LIB = mono-2 15 | 16 | TGTPLATFORM=Any CPU 17 | 18 | PKG_CPPFLAGS = --std=c++11 -lsupc++ 19 | 20 | MONO_INSTALL_PATH=@MONO_INSTALL_PATH@ 21 | MONO_INSTALL_PATH64=@MONO_INSTALL_PATH64@ 22 | OBJECTS=rClrMono.o 23 | ifeq "$(MONO_INSTALL_PATH)" "" 24 | XBUILD=xbuild 25 | else 26 | XBUILD=$(MONO_INSTALL_PATH)/bin/xbuild 27 | endif 28 | 29 | # May 2019: >>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<< 30 | XBUILD=msbuild 31 | 32 | NUGET_CMD=nuget 33 | 34 | SLN=rClr_monodev.sln 35 | 36 | ######## O/S dependent config 37 | ifeq "$(R_OSTYPE)" "windows" 38 | ## Note that as of 2015-08, the section for windows is not in active use. 39 | 40 | ifeq "$(BUILDTYPE)" "Release" 41 | BuildConfiguration=MonoInstall 42 | else 43 | BuildConfiguration=MonoInstallDebug 44 | endif # ifeq "$(BUILDTYPE)" "Release" 45 | 46 | RCLR_LIBS=rClrMono$(SHLIB_EXT) 47 | 48 | # On a Win7 machine, 'pkg-config --cflags mono-2 glib-2.0' returns 49 | # -mno-cygwin -mms-bitfields -mwindows -IF:/bin/Mono/include/mono-2.0 -IF:/bin/Mono/include/glib-2.0 -IF:/bin/Mono/lib/glib-2.0/include 50 | # however 'which pkg-config' is in /cygdrive/f/bin/Mono/bin/pkg-config, something unusual for windows machines (?). 51 | # Not sure what is to be expected on CRAN winbuilder. 52 | # -mno-cygwin is a trouble flag somehow, not to be included. 53 | # pkg-config --libs mono-2 glib-2.0 54 | # -Wl,--export-all-symbols -mno-cygwin -mms-bitfields -mwindows -LF:/bin/Mono/lib 55 | # -lmono-2.0 -lws2_32 -lpsapi -lole32 -lwinmm -loleaut32 -ladvapi32 -lversion -lgl 56 | # ib-2.0 -lintl 57 | PKG_CFLAGS = -mms-bitfields -mwindows -I"$(MONO_INSTALL_PATH)/include/mono-2.0" -I"$(MONO_INSTALL_PATH)/include/glib-2.0" -I"$(MONO_INSTALL_PATH)/lib/glib-2.0/include" -D MONO_CLR -D MONO_INST 58 | PKG_LIBS = -mms-bitfields -mwindows -L"$(MONO_INSTALL_PATH)/lib" -lmono-2.0 -lws2_32 -lpsapi -lole32 -lwinmm -loleaut32 -ladvapi32 -lversion 59 | ifeq "$(R_ARCH)" "/x64" 60 | PKG_LIBS = -mms-bitfields -mwindows -L"$(MONO_INSTALL_PATH64)/" -lmono-2.0 -lws2_32 -lpsapi -lole32 -lwinmm -loleaut32 -ladvapi32 -lversion 61 | # PKG_LIBS = -mms-bitfields -mwindows -LF:/bin/mono_built/lib -LF:/bin/mono_built/bin -lmono-2.0 -lws2_32 -lpsapi -lole32 -lwinmm -loleaut32 -ladvapi32 -lversion 62 | endif ## ifeq "$(R_ARCH)" "/x64" 63 | 64 | RCLRBINDIRFACADE= ./$(BuildConfiguration) 65 | 66 | else ## the OS is not 'windows' 67 | ifeq "$(BUILDTYPE)" "Release" 68 | BuildConfiguration=Unix 69 | else 70 | BuildConfiguration=UnixDebug 71 | endif ## ifeq "$(BUILDTYPE)" "Release" 72 | 73 | PKG_CFLAGS_LOCAL=`pkg-config --cflags $(MONO_LIB) glib-2.0` 74 | PKG_LIBS_LOCAL=`pkg-config --libs $(MONO_LIB) glib-2.0` 75 | PKG_CFLAGS = $(PKG_CFLAGS_LOCAL) -g -D MONO_CLR -D MONO_INST 76 | PKG_LIBS=$(PKG_LIBS_LOCAL) 77 | # TODO: can I avoid having this platform dependent? Why did I not use BuildConfiguration folder under Linux? 78 | RCLRBINDIRFACADE= ./$(BUILDTYPE) 79 | endif ## end if statement testing on "$(R_OSTYPE)" is "windows" or not 80 | 81 | CLR_FACADE_BINS=$(RCLRBINDIRFACADE)/*.dll* 82 | 83 | INSTDIR= ../inst 84 | 85 | MODE=Rebuild 86 | # Note: consoleloggerparameters:ErrorsOnly works with msbuild.exe, but xbuild does not support it 87 | SLNPROPERTIES=/p:Configuration=$(BuildConfiguration) /p:Platform="$(TGTPLATFORM)" /nologo /consoleloggerparameters:ErrorsOnly /verbosity:minimal 88 | 89 | RM = rm -f 90 | 91 | # .PHONY: all clean 92 | 93 | #all: printarch rClrMono$(SHLIB_EXT) instdir rClrInstRclrMono rClrLib 94 | all: printarch $(SHLIB) instdir rClrLib 95 | 96 | clean: 97 | ${RM} $(OBJECTS) $(SHLIB) $(RCLR_LIBS) 98 | 99 | rClrMono.o: 100 | $(CXX) -std=c++11 $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c rClr.cpp -o rClrMono.o -lsupc++ 101 | ###### NOTE: 102 | # On a CentOS OS, I needed to use the following. The CPP and C flags would otherwise return two options not understood: 103 | # -xHOST -fp-model precise 104 | # @echo ALL_CPPFLAGS=$(ALL_CPPFLAGS) 105 | # @echo ALL_CFLAGS=$(ALL_CFLAGS) 106 | # $(CXX) -std=c++11 -I/apps/R/3.1.1/lib64/R/include -DNDEBUG -I/usr/local/include `pkg-config --cflags mono-2 glib-2.0` -g -D MONO_CLR -D MONO_INST -fpic -O3 -openmp -c rClr.cpp -o rClrMono.o -lsupc++ 107 | 108 | rClrMono$(SHLIB_EXT): rClrMono.o 109 | $(CXX) -std=c++11 -shared -Wl,-z,relro -o rClrMono$(SHLIB_EXT) rClrMono.o $(ALL_LIBS) 110 | 111 | printarch: 112 | -@echo **Variable information only for diagnosis purposes** 113 | -@echo R_ARCH=$(R_ARCH) 114 | -@echo OBJECTS=$(OBJECTS) 115 | -@echo SHLIB_EXT=$(SHLIB_EXT) 116 | -@echo CC=$(CC) 117 | -@echo CXX=$(CXX) 118 | -@echo **END Variable** 119 | 120 | instdir: 121 | -@rm -rf $(INSTDIR)/libs$(R_ARCH) 122 | -@mkdir -p $(INSTDIR) 2>/dev/null 123 | -@mkdir -p $(INSTDIR)/libs$(R_ARCH) 2>/dev/null 124 | 125 | # Note: see explanation for -u -p in Makefile.win. May be unnecessary on Linux? 126 | rClrInstRclrMono: 127 | cp -u -p rClrMono$(SHLIB_EXT) $(INSTDIR)/libs$(R_ARCH) 128 | 129 | rClrLib: rClrLibComp 130 | if [ -e symbols.rds ] ; then cp -u -p symbols.rds $(INSTDIR)/libs$(R_ARCH) ; fi 131 | # using rm -f to prevent the following, which seems to occur even when these should not be write-protected 132 | # cp: cannot create regular file `../inst/libs/ClrFacade.dll': Permission denied 133 | -rm -f $(INSTDIR)/libs/*.* 134 | -cp -u -p $(CLR_FACADE_BINS) $(INSTDIR)/libs 135 | 136 | rClrNugetRestore: rClr.cpp 137 | -$(NUGET_CMD) restore $(SLN) ; 138 | 139 | rClrLibComp: rClrNugetRestore 140 | "$(XBUILD)" $(SLN) /t:$(MODE) $(SLNPROPERTIES) 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /src/R.def: -------------------------------------------------------------------------------- 1 | LIBRARY R.dll 2 | EXPORTS 3 | R_RegisterCFinalizerEx 4 | R_MakeExternalPtr 5 | R_ExternalPtrAddr 6 | R_NilValue 7 | TYPEOF 8 | Rf_protect 9 | Rf_unprotect 10 | SET_STRING_ELT 11 | Rf_mkChar 12 | Rf_mkString 13 | R_NaString 14 | Rf_allocVector 15 | CAR 16 | Rf_length 17 | Rf_error 18 | Rf_warning 19 | Rprintf 20 | R_CHAR 21 | STRING_ELT 22 | Rf_coerceVector 23 | LENGTH 24 | CDR 25 | COMPLEX 26 | INTEGER 27 | LOGICAL 28 | RAW 29 | REAL 30 | PRINTNAME 31 | Rf_isNull 32 | TAG 33 | Rf_getAttrib 34 | Rf_type2char 35 | Rf_setAttrib 36 | R_NamesSymbol 37 | R_ClassSymbol 38 | Rf_translateCharUTF8 39 | VECTOR_ELT 40 | Rf_isS4 41 | Rf_duplicate 42 | NAMED 43 | R_BaseEnv 44 | R_GlobalEnv 45 | R_UnboundValue 46 | CDDR 47 | R_FlushConsole 48 | R_PreserveObject 49 | R_ReleaseObject 50 | R_ToplevelExec 51 | REprintf 52 | Rf_asChar 53 | Rf_eval 54 | Rf_findVarInFrame 55 | Rf_install 56 | Rf_isEnvironment 57 | Rf_isString 58 | Rf_lang1 59 | Rf_lang2 60 | Rf_lang3 61 | Rf_onintr 62 | Rf_ScalarLogical 63 | Rf_ScalarString 64 | SET_TAG 65 | SET_VECTOR_ELT 66 | CDDR 67 | GetRNGstate 68 | PutRNGstate 69 | R_do_MAKE_CLASS 70 | R_do_new_object 71 | R_do_slot_assign 72 | R_has_slot 73 | R_ProtectWithIndex 74 | R_RegisterCCallable 75 | R_registerRoutines 76 | R_ReleaseObject 77 | R_Reprotect 78 | R_SetExternalPtrProtected 79 | R_SetExternalPtrTag 80 | R_ToplevelExec 81 | Rf_cons 82 | Rf_defineVar 83 | Rf_inherits 84 | Rf_lcons -------------------------------------------------------------------------------- /src/RDotNetDataConverter/DummyApp/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("DummyApp")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("per202")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /src/RDotNetDataConverter/DummyApp/DummyApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.0 7 | 2.0 8 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4} 9 | Exe 10 | DummyApp 11 | DummyApp 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | true 22 | 23 | 24 | none 25 | true 26 | bin\Release 27 | prompt 28 | 4 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {0923E1A0-2032-4997-AB73-49E42C4034A9} 43 | RDotNet 44 | 45 | 46 | {2A089A59-0F22-4484-B442-0FE8BDA10879} 47 | RDotNet.NativeLibrary 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/RDotNetDataConverter/DummyApp/Main.cs: -------------------------------------------------------------------------------- 1 | #define RDN15 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Linq; 6 | using System.Text; 7 | using RDotNet; 8 | using Environment = System.Environment; 9 | 10 | namespace DummyApp 11 | { 12 | class MainClass 13 | { 14 | static void Main(string[] args) 15 | { 16 | 17 | var rHome = "/usr/lib/R"; 18 | string path = Environment.GetEnvironmentVariable("PATH") ?? String.Empty; 19 | // Note that using /usr/lib where a libR.so symlink exists is not good enough 20 | path = string.Concat(path, ":","/usr/lib/R/lib"); 21 | Environment.SetEnvironmentVariable("R_HOME", rHome); 22 | Environment.SetEnvironmentVariable("PATH", path); 23 | 24 | Console.WriteLine("R init: creating R engine"); 25 | REngine rEngine = REngine.CreateInstance("RDotNet"); 26 | rEngine.Initialize(); 27 | Console.WriteLine("Created rEngine: " + rEngine.ToString()); 28 | 29 | // simple arithmetic test 30 | const string arithmeticExpression = "2 + 14 * 7"; 31 | var result = rEngine.Evaluate(arithmeticExpression).AsNumeric().ToArray(); 32 | Console.WriteLine(arithmeticExpression + " = " + result[0]); 33 | 34 | // test the problematic CreateNumericVector method 35 | // Missing method RDotNet.REngineExtension::CreateNumericVector(REngine,IEnumerable`1) in assembly /data/col52j/calibration-files/bin/Release/R.NET.dll 36 | // values <- 0:99 37 | double[] values = new double[100]; 38 | for (int i = 0; i < values.Length; i++) 39 | values[i] = i; 40 | rEngine.SetSymbol("values", rEngine.CreateNumericVector(values)); 41 | // calculate the sum 42 | // sum(values) # 4950 43 | string sum = "sum(values)"; 44 | #if RDN15 45 | result = rEngine.Evaluate(sum).AsNumeric().ToArray(); 46 | #else 47 | result = rEngine.EagerEvaluate(sum).AsNumeric().ToArray(); 48 | #endif 49 | Console.WriteLine("Sum of integer range 0:99 = " + result[0]); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/RclrTests/RclrTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {D07290EB-5755-453C-8CD6-5CDDED3400BE} 7 | Library 8 | netcoreapp2.0 9 | 0.8.1 10 | (c) 2014-2019 Jean-Michel Perraud 11 | .NET interoperability on top of R.NET for the rClr package 12 | rClr 13 | 14 | Jean-Michel Perraud 15 | RclrTests; embed .NET in R 16 | https://github.com/jmp75/rclr/blob/master/License.txt 17 | https://github.com/jmp75/rclr 18 | https://github.com/jmp75/rclr 19 | Migration to .NET Standard 2.0 and supporting R 3.5.x 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/RclrTests/RdotnetTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using RDotNet; 4 | using Rclr; 5 | 6 | namespace RclrTests 7 | { 8 | public class RdotnetTests 9 | { 10 | [Fact] 11 | public void TestSexpWrapper() 12 | { 13 | var e = REngine.GetInstance(); 14 | var pi = e.CreateNumeric(3.1415); 15 | var sxpw = new SymbolicExpressionWrapper(pi); 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/RclrTests/ReflectionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using Rclr; 7 | using Xunit; 8 | 9 | namespace RclrTests 10 | { 11 | public class ReflectionTests 12 | { 13 | 14 | private class MyTestClass 15 | { 16 | public void NoParams() { } 17 | public void IntParams(params int []p) { } 18 | public void DoubleIntParams(double d, params int[] p) { } 19 | 20 | public void StringSameNameParams(string s, params int[] p) { } 21 | public void StringSameNameParams(string s, params double[] p) { } 22 | 23 | public void UniqueNameStrStrParams(string s, string s2, params double[] p) { } 24 | 25 | public void NoDiffSameNameParams(params int[] p) { } 26 | public void NoDiffSameNameParams(params double[] p) { } 27 | 28 | public void OptionalInt(int i = 0) { } 29 | public void IntOptionalInt(int blah, int i = 0) { } 30 | public void DoubleOptionalInt(double blah, int i = 0) { } 31 | public void DoubleOptionalIntDoubleString(double blah, int i = 0, double d2 = 5.6, string tag = "tag") { } 32 | 33 | public string OptionalArgsMatch(IMyInterface anInterface, int i = 0) { return "IMyInterface";} 34 | public string OptionalArgsMatch(LevelOneClass anInterface, int i = 0) { return "LevelOneClass";} 35 | public string OptionalArgsMatch(LevelTwoClass anInterface, int i = 0) { return "LevelTwoClass"; } 36 | } 37 | 38 | private interface IMyInterface { } 39 | private class LevelOneClass : IMyInterface { } 40 | private class OtherLevelOneClass : IMyInterface { } 41 | private class LevelTwoClass : LevelOneClass { } 42 | 43 | 44 | [Fact] 45 | public void TestVariableArgumentMethodBinding() 46 | { 47 | BindingFlags bf = BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod; 48 | var t = typeof(MyTestClass); 49 | Assert.False(ReflectionHelper.HasVarArgs(GetSingleMethod(t, "NoParams", bf))); 50 | Assert.True(ReflectionHelper.HasVarArgs(GetSingleMethod(t, "IntParams", bf))); 51 | 52 | var tint = typeof(int); 53 | var td = typeof(double); 54 | var to = typeof(object); 55 | var ts = typeof(string); 56 | 57 | Assert.NotNull(ReflectionHelper.GetMethod(t, "IntParams", null, bf, new[] { tint, tint, tint, tint })); 58 | Assert.NotNull(ReflectionHelper.GetMethod(t, "IntParams", null, bf, new[] { tint })); 59 | Assert.NotNull(ReflectionHelper.GetMethod(t, "IntParams", null, bf, Type.EmptyTypes)); 60 | Assert.Null(ReflectionHelper.GetMethod(t, "IntParams", null, bf, new[] { to, to })); 61 | 62 | Assert.NotNull(ReflectionHelper.GetMethod(t, "StringSameNameParams", null, bf, new[] { ts, tint, tint, tint })); 63 | Assert.NotNull(ReflectionHelper.GetMethod(t, "StringSameNameParams", null, bf, new[] { ts, td, td, td })); 64 | 65 | Assert.NotNull(ReflectionHelper.GetMethod(t, "NoDiffSameNameParams", null, bf, new[] { tint, tint, tint })); 66 | Assert.NotNull(ReflectionHelper.GetMethod(t, "NoDiffSameNameParams", null, bf, new[] { td, td, td })); 67 | } 68 | 69 | [Fact] 70 | public void TestReflectionTypeLoadException() 71 | { 72 | var rtle = new ReflectionTypeLoadException(new[]{this.GetType()}, new[]{new Exception("some inner message")}, "rtle message"); 73 | string s = ClrFacade.FormatExceptionInnermost(rtle); 74 | Assert.Contains("some inner message", s); 75 | Assert.Contains("rtle message", s); 76 | } 77 | 78 | [Fact] 79 | public void TestParamsLengthZero() 80 | { 81 | var obj = new MyTestClass(); 82 | // Check that passing no parameters to the 'params' parameter (empty array) works 83 | var result = ClrFacade.CallInstanceMethod(obj, "UniqueNameStrStrParams", new[] { "", "" }); 84 | // However, if it means that there are more than one candidate methods: 85 | Assert.Throws(() => { ClrFacade.CallInstanceMethod(obj, "StringSameNameParams", new[] { "" }); }); 86 | } 87 | 88 | [Fact] 89 | public void TestOptionalParametersMethodBinding() 90 | { 91 | BindingFlags bf = BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod; 92 | var t = typeof(MyTestClass); 93 | Assert.False(ReflectionHelper.HasOptionalParams(GetSingleMethod(t, "NoParams", bf))); 94 | Assert.True(ReflectionHelper.HasOptionalParams(GetSingleMethod(t, "OptionalInt", bf))); 95 | Assert.True(ReflectionHelper.HasOptionalParams(GetSingleMethod(t, "IntOptionalInt", bf))); 96 | 97 | var tint = typeof(int); 98 | var td = typeof(double); 99 | var to = typeof(object); 100 | var ts = typeof(string); 101 | 102 | Assert.NotNull(ReflectionHelper.GetMethod(t, "OptionalInt", null, bf, new[] { tint })); 103 | Assert.NotNull(ReflectionHelper.GetMethod(t, "OptionalInt", null, bf, Type.EmptyTypes)); 104 | Assert.Null(ReflectionHelper.GetMethod(t, "OptionalInt", null, bf, new[] { tint, tint })); 105 | Assert.Null(ReflectionHelper.GetMethod(t, "OptionalInt", null, bf, new[] { td, tint })); 106 | Assert.Null(ReflectionHelper.GetMethod(t, "OptionalInt", null, bf, new[] { tint, td })); 107 | 108 | Assert.NotNull(ReflectionHelper.GetMethod(t, "IntOptionalInt", null, bf, new[] { tint })); 109 | Assert.NotNull(ReflectionHelper.GetMethod(t, "IntOptionalInt", null, bf, new[] { tint, tint })); 110 | Assert.Null(ReflectionHelper.GetMethod(t, "IntOptionalInt", null, bf, new[] { tint, tint, tint })); 111 | 112 | Assert.NotNull(ReflectionHelper.GetMethod(t, "DoubleOptionalInt", null, bf, new[] { td })); 113 | Assert.NotNull(ReflectionHelper.GetMethod(t, "DoubleOptionalInt", null, bf, new[] { td, tint })); 114 | Assert.Null(ReflectionHelper.GetMethod(t, "DoubleOptionalInt", null, bf, new[] { td, tint, tint })); 115 | 116 | Assert.NotNull(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td, tint, td, ts })); 117 | Assert.NotNull(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td, tint, td })); 118 | Assert.NotNull(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td, tint })); 119 | Assert.NotNull(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td })); 120 | 121 | Assert.Null(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td, tint, td, ts, to })); 122 | Assert.Null(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td, tint, td, to })); 123 | Assert.Null(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, new[] { td, to })); 124 | Assert.Null(ReflectionHelper.GetMethod(t, "DoubleOptionalIntDoubleString", null, bf, Type.EmptyTypes)); 125 | 126 | } 127 | 128 | [Fact] 129 | public void TestOptionalParametersMethodInvocation() 130 | { 131 | // TODO tighter checks. Start with: it does not bomb... 132 | var obj = new MyTestClass(); 133 | ClrFacade.CallInstanceMethod(obj, "OptionalInt", new object[] { }); 134 | ClrFacade.CallInstanceMethod(obj, "OptionalInt", new object[] { 3 }); 135 | 136 | ClrFacade.CallInstanceMethod(obj, "IntOptionalInt", new object[] { 3 }); 137 | ClrFacade.CallInstanceMethod(obj, "IntOptionalInt", new object[] { 3, 5 }); 138 | 139 | ClrFacade.CallInstanceMethod(obj, "DoubleOptionalInt", new object[] { 3.0 }); 140 | ClrFacade.CallInstanceMethod(obj, "DoubleOptionalInt", new object[] { 3.0, 5 }); 141 | 142 | ClrFacade.CallInstanceMethod(obj, "DoubleOptionalIntDoubleString", new object[] { 3.0, 5, 4.5, "blah" }); 143 | ClrFacade.CallInstanceMethod(obj, "DoubleOptionalIntDoubleString", new object[] { 3.0, 5, 4.5 }); 144 | ClrFacade.CallInstanceMethod(obj, "DoubleOptionalIntDoubleString", new object[] { 3.0, 5 }); 145 | ClrFacade.CallInstanceMethod(obj, "DoubleOptionalIntDoubleString", new object[] { 3.0 }); 146 | 147 | Assert.Equal("LevelOneClass", ClrFacade.CallInstanceMethod(obj, "OptionalArgsMatch", new object[] { new LevelOneClass() })); 148 | Assert.Equal("LevelTwoClass", ClrFacade.CallInstanceMethod(obj, "OptionalArgsMatch", new object[] { new LevelTwoClass() })); 149 | Assert.Equal("IMyInterface", ClrFacade.CallInstanceMethod(obj, "OptionalArgsMatch", new object[] { new OtherLevelOneClass() })); 150 | } 151 | 152 | private MethodInfo GetSingleMethod(Type classType, string methodName, BindingFlags bf, Binder binder=null, Type[] types=null) 153 | { 154 | if (types == null) types = System.Type.EmptyTypes; 155 | var method = classType.GetMethod(methodName, bf, binder, types, null); 156 | if (method != null) return method; 157 | return classType.GetMethod(methodName); 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/RclrTests/TestApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Rclr; 3 | using RDotNet; 4 | 5 | namespace TestApp 6 | { 7 | class MainClass 8 | { 9 | public static void Main(string[] args) 10 | { 11 | // An application with an entry point. 12 | // This is (seems) required by MonoDevelop to run the debugger in listen mode from a solution 13 | var tzIdR_AUest = "Australia/Sydney"; 14 | 15 | var timeZoneId = tzIdR_AUest; 16 | var tz = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); 17 | 18 | var e = REngine.GetInstance(); 19 | var pi = e.CreateNumeric(3.1415); 20 | var sxpw = new SymbolicExpressionWrapper(pi); 21 | var obj = sxpw.ToClrEquivalent(); 22 | 23 | var yep = (obj is double); 24 | Console.WriteLine((double)obj); 25 | 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/RclrTests/TestApp/TestApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {00CD413A-C00E-45D5-940D-2C6C6F65F520} 7 | Exe 8 | netcoreapp2.0 9 | 0.8.1 10 | (c) 2014-2019 Jean-Michel Perraud 11 | .NET interoperability on top of R.NET for the rClr package 12 | rClr 13 | 14 | Jean-Michel Perraud 15 | RclrTests; embed .NET in R 16 | https://github.com/jmp75/rclr/blob/master/License.txt 17 | https://github.com/jmp75/rclr 18 | https://github.com/jmp75/rclr 19 | Migration to .NET Standard 2.0 and supporting R 3.5.x 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/RclrTests/TestApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src/RclrTests/TestMethodBindings.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ assembly name="$(SolutionDir)Debug\ClrFacade.dll" #> 4 | <#@ import namespace="System.Linq" #> 5 | <#@ import namespace="System.Text" #> 6 | <#@ import namespace="System.Collections.Generic" #> 7 | <#@ import namespace="Rclr" #> 8 | <#@ import namespace="Rclr.Tests" #> 9 | <#@ output extension=".cs" #> 10 | using System; 11 | using System.Reflection; 12 | using Rclr; 13 | using System.Collections.Generic; 14 | using Xunit; 15 | using Rclr.Tests.RefClasses; 16 | 17 | namespace RclrTests 18 | { 19 | /// 20 | /// Do not modify the .cs file: T4 generated class to support the unit tests for method binding 21 | /// 22 | public class TestMethodBindings 23 | { 24 | 25 | <# 26 | 27 | //string[] methodParametersOptArgs = TestMethodBinding.GetOptionalParamsTestCases(); 28 | List cases = new List(); 29 | cases.AddRange(TestUtilities.BuildCombinatorialTestCases("anInt", "anObject", np: 5, sep:", ")); 30 | cases.AddRange(TestUtilities.BuildCombinatorialTestCases("anInt", "aDouble", np: 5, sep:", ")); 31 | 32 | #> 33 | 34 | [Fact] 35 | public void TestMethodBindingOptionalParameters() 36 | { 37 | var tname = typeof(TestMethodBinding).FullName; 38 | int anInt = 1; 39 | double aDouble = Math.PI; 40 | object anObject = new Object(); 41 | 42 | <# 43 | 44 | for (int i = 0; i < cases.Count(); i++) 45 | { 46 | string paramsBody = cases[i]; 47 | #> 48 | Assert.Equal( 49 | TestMethodBinding.SomeMethodWithVarArgs(<#=paramsBody#>), 50 | ClrFacade.CallStaticMethod(tname, "SomeMethodWithVarArgs", new object[] { <#=paramsBody#> }) ); 51 | <# 52 | } // end for loop on cases 53 | 54 | string[] exactMatches = new string[]{ 55 | "LevelOneClass", 56 | "LevelTwoClass", 57 | }; 58 | 59 | string[] ambiguousMatch = new string[]{ 60 | "LevelThreeClass" 61 | }; 62 | 63 | for (int i = 0; i < exactMatches.Length; i++) 64 | { 65 | string t = "new "+exactMatches[i]+"()"; 66 | #> 67 | 68 | Assert.Equal( 69 | TestMethodBinding.MultipleMatchVarArgs(anObject, <#=t#>, anObject, anObject, anObject), 70 | ClrFacade.CallStaticMethod(tname, "MultipleMatchVarArgs", new object[] { anObject, <#=t#>, anObject, anObject, anObject }) ); 71 | <# 72 | } // end for loop on cases 73 | 74 | for (int i = 0; i < ambiguousMatch.Length; i++) 75 | { 76 | string t = "new "+ambiguousMatch[i]+"()"; 77 | #> 78 | 79 | Assert.Throws( 80 | () => { ClrFacade.CallStaticMethod(tname, "MultipleMatchVarArgs", new object[] { anObject, <#=t#>, anObject, anObject, anObject }); } ); 81 | 82 | <# 83 | } // end for loop on cases 84 | #> 85 | 86 | 87 | 88 | } 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/create_lib.cmd: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | REM creates .lib files required for compiling against mono-2.0.dll and R.dll 3 | 4 | @set THIS_DIR=%~d0%~p0 5 | 6 | REM is there a return code for errors from cmd executions? 7 | REM @if not exist %THIS_DIR%setup_vcpp.cmd xcopy %THIS_DIR%setup_vcpp.in %THIS_DIR%setup_vcpp.cmd /Y /R 8 | @call %THIS_DIR%setup_vcpp.cmd 9 | 10 | @set LIBDIR32=%THIS_DIR%libfiles\i386 11 | @set LIBDIR64=%THIS_DIR%libfiles\x64 12 | @if not exist %LIBDIR32% mkdir %LIBDIR32% 13 | @if not exist %LIBDIR64% mkdir %LIBDIR64% 14 | 15 | @set LIB_EXE=lib 16 | 17 | %LIB_EXE% /nologo /def:%THIS_DIR%R.def /out:%LIBDIR64%\Rdll.lib /machine:x64 18 | %LIB_EXE% /nologo /def:%THIS_DIR%R.def /out:%LIBDIR32%\Rdll.lib /machine:x86 19 | 20 | %LIB_EXE% /nologo /def:%THIS_DIR%mono.def /out:%LIBDIR32%\mono-2.0.lib /machine:x86 21 | -------------------------------------------------------------------------------- /src/get_monosdk.cmd: -------------------------------------------------------------------------------- 1 | @REM =============================================== 2 | @REM Query the windows registry to get the installation folder for the Mono SDK 3 | @REM =============================================== 4 | @set defaultClrVersion= 5 | @set MonoHKey32bitsWin7=HKEY_LOCAL_MACHINE\SOFTWARE\Novell\Mono 6 | @set monoSDKPath= 7 | @set MonoHKey64bitsWin7=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Novell\Mono 8 | @REM TODO check on a Win server 9 | 10 | @set defaultClrVersion= 11 | @call :GetDefaultMonoCLRVersion %MonoHKey32bitsWin7% > nul 2>&1 12 | @if errorlevel 1 call :GetDefaultMonoCLRVersion %MonoHKey64bitsWin7% > nul 2>&1 13 | @REM if "%defaultClrVersion%" == "" echo "DefaultCLR not found" 14 | @if "%defaultClrVersion%" == "" goto install_path_not_found 15 | 16 | @set monoSDKPath= 17 | @call :GetSdkInstallRoot %MonoHKey32bitsWin7% > nul 2>&1 18 | @if errorlevel 1 call :GetSdkInstallRoot %MonoHKey64bitsWin7% > nul 2>&1 19 | 20 | @if "%monoSDKPath%" == "" goto install_path_not_found 21 | 22 | @REM It proved easier to substitute in DOS than with ash+sed. Sigh. 23 | @set monoSDKPath=%monoSDKPath:\=/% 24 | @echo %monoSDKPath% 25 | @goto end 26 | 27 | :GetDefaultMonoCLRVersion 28 | for /F "tokens=1,2*" %%i in ('reg query %1 /v "DefaultCLR"') DO ( 29 | if "%%i"=="DefaultCLR" ( 30 | @SET "defaultClrVersion=%%k" 31 | ) 32 | ) 33 | @if "%defaultClrVersion%"=="" exit /B 1 34 | @exit /B 0 35 | 36 | :GetSdkInstallRoot 37 | for /F "tokens=1,2*" %%i in ('reg query %1\%defaultClrVersion% /v "SdkInstallRoot"') DO ( 38 | if "%%i"=="SdkInstallRoot" ( 39 | @SET "monoSDKPath=%%k" 40 | ) 41 | ) 42 | @if "%monoSDKPath%"=="" exit /B 1 43 | @exit /B 0 44 | 45 | :install_path_not_found 46 | @echo not found 47 | @goto end 48 | 49 | :end 50 | -------------------------------------------------------------------------------- /src/get_msbuildpath.cmd: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | REM: note that this is a duplicate of material under https://github.com/jmp75/config-utils/ 3 | 4 | @set exit_code=0 5 | 6 | where /Q MSBuild.exe 7 | set MSBuild_where=%errorlevel% 8 | if %MSBuild_where%==0 set MSBuildPath=MSBuild.exe 9 | if %MSBuild_where%==0 goto vcpp_ok 10 | 11 | REM =============================================== 12 | REM Query the windows registry to get the location of MsBuild.exe. 13 | REM Note that this returns a cygwin style path with slashes, to workaround an oddity with ash+sed in configure.win 14 | REM =============================================== 15 | set MSBuildToolsPath="" 16 | for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" /v "MSBuildToolsPath"') DO ( 17 | if "%%i"=="MSBuildToolsPath" ( 18 | @SET "MSBuildToolsPath=%%k" 19 | ) 20 | ) 21 | REM Remove a trailing '\' that causes grief in configure.win 22 | REM @if not "%MSBuildToolsPath%"=="" set MSBuildToolsPath=%MSBuildToolsPath:~0,-1% 23 | 24 | set MSBuildPath=%MSBuildToolsPath%MSBuild.exe 25 | 26 | :vcpp_ok 27 | REM If the path is returned with backslash, then ash seems to receive it with an oddity: 28 | REM C:\Windows\Microsoft.NET\Framework 4.0.30319\MSBuild.exe 29 | REM It proved easier to substitute in DOS than with ash+sed. Sigh. 30 | set MSBuildPath=%MSBuildPath:\=/% 31 | @echo %MSBuildPath% 32 | 33 | :end 34 | exit /b %exit_code% 35 | -------------------------------------------------------------------------------- /src/get_winsdk.cmd: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | REM =============================================== 3 | REM Query the windows registry to get the installation folder for the Windows SDK 4 | REM =============================================== 5 | set WindowsSdkDir="" 6 | for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0" /v "InstallationFolder"') DO ( 7 | if "%%i"=="InstallationFolder" ( 8 | @SET "WindowsSdkDir=%%k" 9 | ) 10 | ) 11 | @echo %WindowsSdkDir% -------------------------------------------------------------------------------- /src/rClr-Cpp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rClr", "rClr.vcxproj", "{1EE5689F-F71E-49E1-874A-0DF63E174635}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "monotests", "..\monotests\monotests.vcxproj", "{2583ED84-98AD-4365-AC29-09369C885A8A}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmdline_rClr", "..\..\..\..\..\hydropackage\branches\rClrDev\packages\rClr\src\cmdline_rClr\cmdline_rClr.vcxproj", "{0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|Mixed Platforms = Debug|Mixed Platforms 14 | Debug|Win32 = Debug|Win32 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | MonoDebug|Any CPU = MonoDebug|Any CPU 18 | MonoDebug|Mixed Platforms = MonoDebug|Mixed Platforms 19 | MonoDebug|Win32 = MonoDebug|Win32 20 | MonoDebug|x64 = MonoDebug|x64 21 | MonoDebug|x86 = MonoDebug|x86 22 | MonoInstallDebug|Any CPU = MonoInstallDebug|Any CPU 23 | MonoInstallDebug|Mixed Platforms = MonoInstallDebug|Mixed Platforms 24 | MonoInstallDebug|Win32 = MonoInstallDebug|Win32 25 | MonoInstallDebug|x64 = MonoInstallDebug|x64 26 | MonoInstallDebug|x86 = MonoInstallDebug|x86 27 | Release|Any CPU = Release|Any CPU 28 | Release|Mixed Platforms = Release|Mixed Platforms 29 | Release|Win32 = Release|Win32 30 | Release|x64 = Release|x64 31 | Release|x86 = Release|x86 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|Any CPU.ActiveCfg = Debug|Win32 35 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 36 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|Mixed Platforms.Build.0 = Debug|Win32 37 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|Win32.Build.0 = Debug|Win32 39 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|x64.ActiveCfg = Debug|x64 40 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|x64.Build.0 = Debug|x64 41 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|x86.ActiveCfg = Debug|Win32 42 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Debug|x86.Build.0 = Debug|Win32 43 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|Any CPU.ActiveCfg = MonoDebug|Win32 44 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|Mixed Platforms.ActiveCfg = MonoDebug|Win32 45 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|Mixed Platforms.Build.0 = MonoDebug|Win32 46 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|Win32.ActiveCfg = MonoDebug|Win32 47 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|Win32.Build.0 = MonoDebug|Win32 48 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|x64.ActiveCfg = MonoDebug|x64 49 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|x64.Build.0 = MonoDebug|x64 50 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|x86.ActiveCfg = MonoDebug|Win32 51 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoDebug|x86.Build.0 = MonoDebug|Win32 52 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|Any CPU.ActiveCfg = MonoInstallDebug|Win32 53 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|Mixed Platforms.ActiveCfg = MonoInstallDebug|Win32 54 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|Mixed Platforms.Build.0 = MonoInstallDebug|Win32 55 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|Win32.ActiveCfg = MonoInstallDebug|Win32 56 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|Win32.Build.0 = MonoInstallDebug|Win32 57 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|x64.ActiveCfg = MonoInstallDebug|x64 58 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|x64.Build.0 = MonoInstallDebug|x64 59 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|x86.ActiveCfg = MonoInstallDebug|Win32 60 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.MonoInstallDebug|x86.Build.0 = MonoInstallDebug|Win32 61 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|Any CPU.ActiveCfg = Release|Win32 62 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|Mixed Platforms.ActiveCfg = Release|Win32 63 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|Mixed Platforms.Build.0 = Release|Win32 64 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|Win32.ActiveCfg = Release|Win32 65 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|Win32.Build.0 = Release|Win32 66 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|x64.ActiveCfg = Release|x64 67 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|x64.Build.0 = Release|x64 68 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|x86.ActiveCfg = Release|Win32 69 | {1EE5689F-F71E-49E1-874A-0DF63E174635}.Release|x86.Build.0 = Release|Win32 70 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|Any CPU.ActiveCfg = Debug|Win32 71 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 72 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|Mixed Platforms.Build.0 = Debug|Win32 73 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|Win32.ActiveCfg = Debug|Win32 74 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|Win32.Build.0 = Debug|Win32 75 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|x64.ActiveCfg = Debug|Win32 76 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Debug|x86.ActiveCfg = Debug|Win32 77 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|Any CPU.ActiveCfg = Debug|Win32 78 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|Mixed Platforms.ActiveCfg = Debug|Win32 79 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|Mixed Platforms.Build.0 = Debug|Win32 80 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|Win32.ActiveCfg = Debug|Win32 81 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|Win32.Build.0 = Debug|Win32 82 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|x64.ActiveCfg = Debug|Win32 83 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoDebug|x86.ActiveCfg = Debug|Win32 84 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|Any CPU.ActiveCfg = Debug|Win32 85 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|Mixed Platforms.ActiveCfg = Debug|Win32 86 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|Mixed Platforms.Build.0 = Debug|Win32 87 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|Win32.ActiveCfg = MonoInstallDebug|Win32 88 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|Win32.Build.0 = MonoInstallDebug|Win32 89 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|x64.ActiveCfg = Debug|Win32 90 | {2583ED84-98AD-4365-AC29-09369C885A8A}.MonoInstallDebug|x86.ActiveCfg = Debug|Win32 91 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|Any CPU.ActiveCfg = Release|Win32 92 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|Mixed Platforms.ActiveCfg = Release|Win32 93 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|Mixed Platforms.Build.0 = Release|Win32 94 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|Win32.ActiveCfg = Release|Win32 95 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|Win32.Build.0 = Release|Win32 96 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|x64.ActiveCfg = Release|Win32 97 | {2583ED84-98AD-4365-AC29-09369C885A8A}.Release|x86.ActiveCfg = Release|Win32 98 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|Any CPU.ActiveCfg = Debug|x64 99 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 100 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|Mixed Platforms.Build.0 = Debug|x64 101 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|Win32.ActiveCfg = Debug|Win32 102 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|Win32.Build.0 = Debug|Win32 103 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|x64.ActiveCfg = Debug|x64 104 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|x64.Build.0 = Debug|x64 105 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Debug|x86.ActiveCfg = Debug|x64 106 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|Any CPU.ActiveCfg = MonoDebug|x64 107 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|Mixed Platforms.ActiveCfg = MonoDebug|x64 108 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|Mixed Platforms.Build.0 = MonoDebug|x64 109 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|Win32.ActiveCfg = MonoDebug|Win32 110 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|Win32.Build.0 = MonoDebug|Win32 111 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|x64.ActiveCfg = MonoDebug|x64 112 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|x64.Build.0 = MonoDebug|x64 113 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoDebug|x86.ActiveCfg = MonoDebug|x64 114 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|Any CPU.ActiveCfg = MonoInstallDebug|x64 115 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|Mixed Platforms.ActiveCfg = MonoInstallDebug|x64 116 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|Mixed Platforms.Build.0 = MonoInstallDebug|x64 117 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|Win32.ActiveCfg = MonoInstallDebug|Win32 118 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|Win32.Build.0 = MonoInstallDebug|Win32 119 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|x64.ActiveCfg = MonoInstallDebug|x64 120 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|x64.Build.0 = MonoInstallDebug|x64 121 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.MonoInstallDebug|x86.ActiveCfg = MonoInstallDebug|x64 122 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|Any CPU.ActiveCfg = Release|x64 123 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|Mixed Platforms.ActiveCfg = Release|x64 124 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|Mixed Platforms.Build.0 = Release|x64 125 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|Win32.ActiveCfg = Release|Win32 126 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|Win32.Build.0 = Release|Win32 127 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|x64.ActiveCfg = Release|x64 128 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|x64.Build.0 = Release|x64 129 | {0E42E7A3-0BE2-05B2-C555-6B6FAE5C301C}.Release|x86.ActiveCfg = Release|x64 130 | EndGlobalSection 131 | GlobalSection(SolutionProperties) = preSolution 132 | HideSolutionNode = FALSE 133 | EndGlobalSection 134 | EndGlobal 135 | -------------------------------------------------------------------------------- /src/rClr-Cs.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual C# Express 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClrFacade", "ClrFacade\ClrFacade.csproj", "{024B0C26-BED0-467D-B332-E9796B756133}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Debug|Mixed Platforms = Debug|Mixed Platforms 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | MonoDebug|Any CPU = MonoDebug|Any CPU 14 | MonoDebug|Mixed Platforms = MonoDebug|Mixed Platforms 15 | MonoDebug|Win32 = MonoDebug|Win32 16 | MonoDebug|x64 = MonoDebug|x64 17 | MonoDebug|x86 = MonoDebug|x86 18 | MonoInstallDebug|Any CPU = MonoInstallDebug|Any CPU 19 | MonoInstallDebug|Mixed Platforms = MonoInstallDebug|Mixed Platforms 20 | MonoInstallDebug|Win32 = MonoInstallDebug|Win32 21 | MonoInstallDebug|x64 = MonoInstallDebug|x64 22 | MonoInstallDebug|x86 = MonoInstallDebug|x86 23 | Release|Any CPU = Release|Any CPU 24 | Release|Mixed Platforms = Release|Mixed Platforms 25 | Release|Win32 = Release|Win32 26 | Release|x64 = Release|x64 27 | Release|x86 = Release|x86 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 33 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 34 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Win32.ActiveCfg = Debug|Any CPU 35 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Win32.Build.0 = Debug|Any CPU 36 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|x64.ActiveCfg = Debug|Any CPU 37 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|x64.Build.0 = Debug|Any CPU 38 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|x86.ActiveCfg = Debug|Any CPU 39 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Any CPU.ActiveCfg = MonoDebug|Any CPU 40 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Any CPU.Build.0 = MonoDebug|Any CPU 41 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Mixed Platforms.ActiveCfg = MonoDebug|Any CPU 42 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Mixed Platforms.Build.0 = MonoDebug|Any CPU 43 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Win32.ActiveCfg = MonoDebug|Any CPU 44 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|x64.ActiveCfg = MonoDebug|Any CPU 45 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|x64.Build.0 = MonoDebug|Any CPU 46 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|x86.ActiveCfg = MonoDebug|Any CPU 47 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Any CPU.ActiveCfg = MonoInstallDebug|Any CPU 48 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Any CPU.Build.0 = MonoInstallDebug|Any CPU 49 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Mixed Platforms.ActiveCfg = MonoInstallDebug|Any CPU 50 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Mixed Platforms.Build.0 = MonoInstallDebug|Any CPU 51 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Win32.ActiveCfg = MonoInstallDebug|Any CPU 52 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|x64.ActiveCfg = MonoInstallDebug|Any CPU 53 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|x86.ActiveCfg = MonoInstallDebug|Any CPU 54 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|x86.Build.0 = MonoInstallDebug|Any CPU 55 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Any CPU.ActiveCfg = Release|Any CPU 56 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Any CPU.Build.0 = Release|Any CPU 57 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 58 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Mixed Platforms.Build.0 = Release|Any CPU 59 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Win32.ActiveCfg = Release|Any CPU 60 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|x64.ActiveCfg = Release|Any CPU 61 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|x86.ActiveCfg = Release|Any CPU 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | EndGlobal 67 | -------------------------------------------------------------------------------- /src/rClr-mono.def: -------------------------------------------------------------------------------- 1 | LIBRARY rClr.dll 2 | EXPORTS 3 | rclr_create_domain 4 | rclr_load_assembly 5 | r_create_clr_object 6 | r_call_method 7 | r_get_typename_externalptr 8 | r_get_type_name 9 | r_call_static_method 10 | r_diagnose_parameters 11 | r_get_sexp_type 12 | r_show_args 13 | clr_object_to_SEXP 14 | r_get_object_direct 15 | clr_object_to_SEXP 16 | is_microsoft_clr 17 | use_rdotnet 18 | -------------------------------------------------------------------------------- /src/rClr-win.def: -------------------------------------------------------------------------------- 1 | LIBRARY rClr.dll 2 | EXPORTS 3 | rclr_create_domain 4 | rclr_load_assembly 5 | r_create_clr_object 6 | r_call_method 7 | r_get_typename_externalptr 8 | r_get_type_name 9 | r_call_static_method 10 | r_diagnose_parameters 11 | r_get_sexp_type 12 | r_show_args 13 | r_get_object_direct 14 | clr_object_to_SEXP 15 | is_microsoft_clr 16 | use_rdotnet 17 | -------------------------------------------------------------------------------- /src/rClr.props.in: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | @MONO_INSTALL_PATH@ 6 | @MONO_SRC_PATH@ 7 | @R_INSTALL_PATH@ 8 | 9 | 10 | 11 | 12 | 13 | $(MonoSrcPath) 14 | true 15 | 16 | 17 | $(MonoInstallPath) 18 | true 19 | 20 | 21 | $(RInstallPath) 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/rClr_monodev.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClrFacade", "ClrFacade\ClrFacade.csproj", "{024B0C26-BED0-467D-B332-E9796B756133}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "RclrTests\TestApp\TestApp.csproj", "{00CD413A-C00E-45D5-940D-2C6C6F65F520}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RclrTests", "RclrTests\RclrTests.csproj", "{D07290EB-5755-453C-8CD6-5CDDED3400BE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | MonoDebug|Any CPU = MonoDebug|Any CPU 14 | MonoInstall|Any CPU = MonoInstall|Any CPU 15 | MonoInstallDebug|Any CPU = MonoInstallDebug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | Unix|Any CPU = Unix|Any CPU 18 | UnixDebug|Any CPU = UnixDebug|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU 25 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.MonoInstall|Any CPU.ActiveCfg = Debug|Any CPU 26 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.MonoInstall|Any CPU.Build.0 = Debug|Any CPU 27 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.MonoInstallDebug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.MonoInstallDebug|Any CPU.Build.0 = Debug|Any CPU 29 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.Unix|Any CPU.ActiveCfg = Release|Any CPU 32 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.Unix|Any CPU.Build.0 = Release|Any CPU 33 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.UnixDebug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {00CD413A-C00E-45D5-940D-2C6C6F65F520}.UnixDebug|Any CPU.Build.0 = Debug|Any CPU 35 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {024B0C26-BED0-467D-B332-E9796B756133}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Any CPU.ActiveCfg = MonoDebug|Any CPU 38 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoDebug|Any CPU.Build.0 = MonoDebug|Any CPU 39 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstall|Any CPU.ActiveCfg = MonoInstall|Any CPU 40 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstall|Any CPU.Build.0 = MonoInstall|Any CPU 41 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Any CPU.ActiveCfg = MonoInstallDebug|Any CPU 42 | {024B0C26-BED0-467D-B332-E9796B756133}.MonoInstallDebug|Any CPU.Build.0 = MonoInstallDebug|Any CPU 43 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {024B0C26-BED0-467D-B332-E9796B756133}.Release|Any CPU.Build.0 = Release|Any CPU 45 | {024B0C26-BED0-467D-B332-E9796B756133}.Unix|Any CPU.ActiveCfg = Release|Any CPU 46 | {024B0C26-BED0-467D-B332-E9796B756133}.Unix|Any CPU.Build.0 = Release|Any CPU 47 | {024B0C26-BED0-467D-B332-E9796B756133}.UnixDebug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {024B0C26-BED0-467D-B332-E9796B756133}.UnixDebug|Any CPU.Build.0 = Debug|Any CPU 49 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 50 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.Debug|Any CPU.Build.0 = Debug|Any CPU 51 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU 52 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU 53 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.MonoInstall|Any CPU.ActiveCfg = Debug|Any CPU 54 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.MonoInstall|Any CPU.Build.0 = Debug|Any CPU 55 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.MonoInstallDebug|Any CPU.ActiveCfg = Debug|Any CPU 56 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.MonoInstallDebug|Any CPU.Build.0 = Debug|Any CPU 57 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.Unix|Any CPU.ActiveCfg = Release|Any CPU 60 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.Unix|Any CPU.Build.0 = Release|Any CPU 61 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.UnixDebug|Any CPU.ActiveCfg = Debug|Any CPU 62 | {D07290EB-5755-453C-8CD6-5CDDED3400BE}.UnixDebug|Any CPU.Build.0 = Debug|Any CPU 63 | EndGlobalSection 64 | GlobalSection(MonoDevelopProperties) = preSolution 65 | StartupItem = RclrTests\TestApp\TestApp.csproj 66 | Policies = $0 67 | $0.TextStylePolicy = $1 68 | $1.inheritsSet = VisualStudio 69 | $1.inheritsScope = text/plain 70 | $1.scope = text/x-csharp 71 | $0.CSharpFormattingPolicy = $2 72 | $2.IndentSwitchBody = True 73 | $2.AnonymousMethodBraceStyle = NextLine 74 | $2.PropertyBraceStyle = NextLine 75 | $2.PropertyGetBraceStyle = NextLine 76 | $2.PropertySetBraceStyle = NextLine 77 | $2.EventBraceStyle = NextLine 78 | $2.EventAddBraceStyle = NextLine 79 | $2.EventRemoveBraceStyle = NextLine 80 | $2.StatementBraceStyle = NextLine 81 | $2.ElseNewLinePlacement = NewLine 82 | $2.CatchNewLinePlacement = NewLine 83 | $2.FinallyNewLinePlacement = NewLine 84 | $2.WhileNewLinePlacement = DoNotCare 85 | $2.ArrayInitializerWrapping = DoNotChange 86 | $2.ArrayInitializerBraceStyle = NextLine 87 | $2.BeforeMethodDeclarationParentheses = False 88 | $2.BeforeMethodCallParentheses = False 89 | $2.BeforeConstructorDeclarationParentheses = False 90 | $2.BeforeDelegateDeclarationParentheses = False 91 | $2.NewParentheses = False 92 | $2.SpacesBeforeBrackets = False 93 | $2.inheritsSet = Mono 94 | $2.inheritsScope = text/x-csharp 95 | $2.scope = text/x-csharp 96 | EndGlobalSection 97 | GlobalSection(SolutionProperties) = preSolution 98 | HideSolutionNode = FALSE 99 | EndGlobalSection 100 | EndGlobal 101 | -------------------------------------------------------------------------------- /src/rdotnet/Readme.txt: -------------------------------------------------------------------------------- 1 | 2014-06-01 2 | This folder used to version source code for R.NET. rClr now uses updated packages at NuGet.org instead. -------------------------------------------------------------------------------- /src/setup_vcpp.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM ------------------------------------- 4 | REM NOTE: This file is a copy of 5 | REM https://github.com/jmp75/config-utils/blob/master/R/packages/msvs/exec/setup_vcpp.cmd 6 | REM ------------------------------------- 7 | 8 | @set exit_code=0 9 | 10 | 11 | REM load Visual Studio 2017 developer command prompt setup has changed compared to previous versions. 12 | REM Inspired from: https://github.com/ctaggart via https://github.com/Microsoft/visualfsharp/pull/2690/commits/bf52776167fe6a9f2354ea96094a025191dbd3e7 13 | 14 | set VsDevCmdFile=\Common7\Tools\VsDevCmd.bat 15 | 16 | set progf=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\ 17 | if exist "%progf%" ( 18 | goto foundVsDevCmdFile 19 | ) 20 | 21 | set progf=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\ 22 | 23 | :foundVsDevCmdFile 24 | 25 | if exist "%progf%Enterprise%VsDevCmdFile%" ( 26 | call "%progf%Enterprise%VsDevCmdFile%" 27 | goto end 28 | ) 29 | if exist "%progf%Professional%VsDevCmdFile%" ( 30 | call "%progf%Professional%VsDevCmdFile%" 31 | goto end 32 | ) 33 | if exist "%progf%Community%VsDevCmdFile%" ( 34 | call "%progf%Community%VsDevCmdFile%" 35 | goto end 36 | ) 37 | if exist "%progf%BuildTools%VsDevCmdFile%" ( 38 | call "%progf%BuildTools%VsDevCmdFile%" 39 | goto end 40 | ) 41 | 42 | REM for instance C:\bin\VS2012\Common7\Tools\ 43 | if defined VSCOMNTOOLS ( 44 | goto found 45 | ) 46 | 47 | if defined VS140COMNTOOLS set VSCOMNTOOLS=%VS140COMNTOOLS% 48 | if defined VS140COMNTOOLS goto found 49 | if defined VS120COMNTOOLS set VSCOMNTOOLS=%VS140COMNTOOLS% 50 | if defined VS120COMNTOOLS goto found 51 | if defined VS110COMNTOOLS set VSCOMNTOOLS=%VS140COMNTOOLS% 52 | if defined VS110COMNTOOLS goto found 53 | 54 | @echo ERROR: Could not locate command prompt devenv setup for anything between VS2012 and VS2017 55 | @set exit_code=127 56 | @goto end 57 | 58 | :found 59 | set VSDEVENV=%VSCOMNTOOLS%..\..\VC\vcvarsall.bat 60 | @if not exist "%VSDEVENV%" goto error_no_vcvarsall 61 | @call "%VSDEVENV%" 62 | @goto end 63 | 64 | :error_no_VS110COMNTOOLSDIR 65 | @echo ERROR: setup_vcpp cannot determine the location of the VS Common Tools folder. 66 | @set exit_code=1 67 | @goto end 68 | 69 | :error_no_vcvarsall 70 | @echo ERROR: Cannot find file %VSDEVENV%. 71 | @set exit_code=1 72 | @goto end 73 | 74 | :end 75 | exit /b %exit_code% 76 | 77 | -------------------------------------------------------------------------------- /src/testrdn.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RDotNet.NativeLibrary", "rdotnet\RDotNet.NativeLibrary\RDotNet.NativeLibrary.csproj", "{2A089A59-0F22-4484-B442-0FE8BDA10879}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RDotNet", "rdotnet\R.NET\RDotNet.csproj", "{0923E1A0-2032-4997-AB73-49E42C4034A9}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DummyApp", "RDotNetDataConverter\DummyApp\DummyApp.csproj", "{5BAEA594-B688-46DC-9CC3-A794DB5375D4}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | MonoDebug|Any CPU = MonoDebug|Any CPU 14 | MonoInstall|Any CPU = MonoInstall|Any CPU 15 | MonoInstallDebug|Any CPU = MonoInstallDebug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | Unix|Any CPU = Unix|Any CPU 18 | UnixDebug|Any CPU = UnixDebug|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU 25 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.MonoInstall|Any CPU.ActiveCfg = Debug|Any CPU 26 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.MonoInstall|Any CPU.Build.0 = Debug|Any CPU 27 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.MonoInstallDebug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.MonoInstallDebug|Any CPU.Build.0 = Debug|Any CPU 29 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.Unix|Any CPU.ActiveCfg = Unix|Any CPU 32 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.Unix|Any CPU.Build.0 = Unix|Any CPU 33 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.UnixDebug|Any CPU.ActiveCfg = UnixDebug|Any CPU 34 | {0923E1A0-2032-4997-AB73-49E42C4034A9}.UnixDebug|Any CPU.Build.0 = UnixDebug|Any CPU 35 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU 39 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.MonoInstall|Any CPU.ActiveCfg = Debug|Any CPU 40 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.MonoInstall|Any CPU.Build.0 = Debug|Any CPU 41 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.MonoInstallDebug|Any CPU.ActiveCfg = Debug|Any CPU 42 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.MonoInstallDebug|Any CPU.Build.0 = Debug|Any CPU 43 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.Release|Any CPU.Build.0 = Release|Any CPU 45 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.Unix|Any CPU.ActiveCfg = Unix|Any CPU 46 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.Unix|Any CPU.Build.0 = Unix|Any CPU 47 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.UnixDebug|Any CPU.ActiveCfg = UnixDebug|Any CPU 48 | {2A089A59-0F22-4484-B442-0FE8BDA10879}.UnixDebug|Any CPU.Build.0 = UnixDebug|Any CPU 49 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 50 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.Debug|Any CPU.Build.0 = Debug|Any CPU 51 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU 52 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU 53 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.MonoInstall|Any CPU.ActiveCfg = Debug|Any CPU 54 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.MonoInstall|Any CPU.Build.0 = Debug|Any CPU 55 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.MonoInstallDebug|Any CPU.ActiveCfg = Debug|Any CPU 56 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.Unix|Any CPU.ActiveCfg = Debug|Any CPU 59 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.Unix|Any CPU.Build.0 = Debug|Any CPU 60 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.UnixDebug|Any CPU.ActiveCfg = Debug|Any CPU 61 | {5BAEA594-B688-46DC-9CC3-A794DB5375D4}.UnixDebug|Any CPU.Build.0 = Debug|Any CPU 62 | EndGlobalSection 63 | GlobalSection(MonoDevelopProperties) = preSolution 64 | StartupItem = RDotNetDataConverter\DummyApp\DummyApp.csproj 65 | EndGlobalSection 66 | GlobalSection(SolutionProperties) = preSolution 67 | HideSolutionNode = FALSE 68 | EndGlobalSection 69 | EndGlobal 70 | -------------------------------------------------------------------------------- /src/win_cp.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM This utility uses the native windows xcopy to overcome an issue that can arise with 'cp' coming with MinGW. 3 | set unix_args=%* 4 | set dos_paths=%unix_args:/=\% 5 | robocopy /MT:1 /R:2 /NJS /NJH %dos_paths% 6 | @set exit_code=0 7 | 8 | REM http://ss64.com/nt/robocopy-exit.html 9 | @if errorlevel 0 goto exit 10 | @if errorlevel 1 goto exit 11 | 12 | goto robocopy_fail 13 | 14 | :robocopy_fail 15 | @echo ERROR: robocopy exit code %errorlevel%. See http://ss64.com/nt/robocopy-exit.html for details. 16 | @set exit_code=1 17 | @goto exit 18 | 19 | :exit 20 | exit /b %exit_code% 21 | 22 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(rClr) 3 | 4 | debug_test = FALSE 5 | # debug_test = TRUE 6 | 7 | test_check("rClr") 8 | -------------------------------------------------------------------------------- /tests/testthat/datetime-functions.r: -------------------------------------------------------------------------------- 1 | ######################## 2 | # Define a few test helper functions 3 | ######################## 4 | 5 | clrDateEquals <- function(d, isoDateTimeStr, tzIdClr) { clrCallStatic(cTypename, "UtcDateEquals", d, isoDateTimeStr, tzIdClr) } 6 | createDotNetDate <- function(...) { clrCallStatic(cTypename, "CreateDate", ...) } 7 | createUtcDate <- function(isoDateTimeStr, tzIdClr) { clrCallStatic(cTypename, "UtcDateForTimeZone", isoDateTimeStr, tzIdClr) } 8 | # convertClrTime <- function(isoDateTimeStr, tzIdClr_from, tzIdClr_to ) { clrCallStatic(cTypename, "ConvertTime", isoDateTimeStr, tzIdClr_from, tzIdClr_to) } 9 | 10 | 11 | # ?Sys.timezone, See the examples 12 | tzIdR_AUest = "Australia/Sydney" 13 | 14 | # IronPython: tz = [x for x in TimeZoneInfo.GetSystemTimeZones()] 15 | tzId_AUest <- 16 | ifelse( tolower(Sys.info()['sysname'])== 'windows', 17 | ifelse(clrGetNativeLibName()=='rClrMono', 18 | # As of Mono 3.8.0, and probably earlier releases including 3.4.0, the time zone names have changed. Not Olson DB anymore. Not MS.NET either. *Sigh* 19 | 'E. Australia Standard Time', 20 | # I think even on Linux Mono does not use the Olson DB names. If still, use something like the following line 21 | # 'E. Australia Standard Time', tzIdR_AUest), 22 | "AUS Eastern Standard Time") # TODO: is 'Australia/Sydney' also OK for MS.NET? 23 | , 24 | tzIdR_AUest # on Linux, use the Olson DB. 25 | ) 26 | # Help with unit test labels 27 | pctToString <- function(d) { paste(paste(as.character(d), attr(d, 'tzone')), collapse=';') } 28 | 29 | # Creates a POSIXct in the time zone of Canberra 30 | AUest <- function(dateStr) { 31 | as.POSIXct(dateStr, tz=tzIdR_AUest) 32 | } 33 | 34 | pctToUtc <- function(dtPosixct) { 35 | stopifnot("POSIXct" %in% class(dtPosixct)) 36 | result <- dtPosixct 37 | attr(result, 'tzone') <- 'UTC' 38 | result 39 | } 40 | 41 | # Given a date ISO 8601 string formatted, check that the marshalling is as expected. 42 | # Equality tests are done in the CLR, not in R, for this function, so this function tests the R POSIXt to CLR conversion 43 | testRtoClr <- function(dateStr, pfun=as.POSIXct, tzIdR=tzIdR_AUest, tzId=tzId_AUest) { 44 | 45 | #### First, a whole day. Test that Date object, then POSIXt objects are converted to the right .NET value 46 | # Date objects: from R to .NET: 47 | rdate <- as.Date(dateStr) 48 | dayComponent <- format(rdate, '%Y-%m-%d') 49 | # when converting an R Date to a POSIXct it becomes encoded as the date plus 00:00:00 UTC. 50 | # Let's check this is the equivalent seen from the CLR 51 | expect_that( clrDateEquals(rdate, dayComponent, tzIdClr='UTC'), is_true(), label=paste('R Date',rdate,'becomes UTC DateTime',dayComponent)); 52 | 53 | # if an R POSIXct date is created for a timezone, it is equal to a DateTime time zone 54 | dr <- pfun(dateStr, tz=tzIdR) 55 | expect_that( clrDateEquals( dr, dateStr, tzIdClr=tzId ), is_true(), label=paste('R POSIXct',pctToString(dr),'becomes',tzId,'DateTime',dateStr)); 56 | } 57 | 58 | expect_posixct_equal <- function(actual, expected, mAct='Actual', mExp='Expected') { 59 | expect_equal(actual, expected, label=paste(mAct,':', pctToString(actual)), expected.label=paste(mExp,':', pctToString(expected))) 60 | } 61 | 62 | testDotNetToR <- function(testDateStr) { 63 | d <- createUtcDate(testDateStr, tzId_AUest) 64 | dr <- pctToUtc(as.POSIXct(testDateStr, tz=tzIdR_AUest)) 65 | expect_posixct_equal(d, dr, mAct='From CLR', mExp='Expected') 66 | 67 | # The following was the initial intent; however this will take some time to get there, if feasible. 68 | # clrDate <- createDotNetDate( testDateStr) 69 | # expect_that( clrDate, equals(as.POSIXct(testDateStr)) ); 70 | # clrDate <- createDotNetDate( testDateStr, 'Local') 71 | # expect_that( clrDate, equals(as.POSIXct(testDateStr)) ); 72 | # clrDate <- createDotNetDate( testDateStr, 'Utc') 73 | # expect_that( clrDate, equals(as.POSIXct(testDateStr, tz='UTC')) ); 74 | } 75 | 76 | testDotNetToRUTC <- function(testDateStr) { 77 | d <- createUtcDate(testDateStr, 'UTC') 78 | dr <- pctToUtc(as.POSIXct(testDateStr, tz='UTC')) 79 | expect_posixct_equal(d, dr, mAct='From CLR', mExp='Expected') 80 | } 81 | 82 | testPosixToDotNet <- function(dateStr) { 83 | testRtoClr(dateStr, pfun=as.POSIXct) 84 | # demand POSIXct UTC dates only 85 | expect_error(testRtoClr(dateStr, pfun=as.POSIXlt)) 86 | } 87 | 88 | testBothDirections <- function(dateStr) { 89 | testPosixToDotNet(dateStr) 90 | testDotNetToR(dateStr) 91 | } 92 | 93 | # All times in pseudo code for Time zone "Australia/Sydney" in R , identifier "AUS Eastern Standard Time" in .NET TimeZoneInfo (name "Canberra, Melbourne, Sydney") 94 | # change from no DST to DST: 95 | # bidirectional '2013-10-06 01:59' proper conversion then true for every minute for over 62 minutes. 96 | # bidirectional '2013-04-07 01:59' proper conversion then true for every minute for over 62 minutes. 97 | # In the CLR and R respectively, what is: '2013-10-06 03:01' - '2013-10-06 01:59'. In .NET, what is the result for a DateTime that is Local 98 | 99 | # Define dates of interest, to iterate over and test 100 | 101 | post1971_DateStr <- c('2001-01-01', 102 | '2001-01-01 23:22:21', 103 | # Testing proper function around a daylight saving time 104 | # http://www.timeanddate.com/worldclock/clockchange.html?n=57 105 | # Daylight savings time changes in Australia for 2013 106 | 107 | # Sunday, 7 April 2013 2:59:57 AM +1h UTC+11h AEDT 108 | # 2:59:58 AM +1h UTC+11h AEDT 109 | # 2:59:59 AM +1h UTC+11h AEDT 110 | # 3:00:00 AM ? 2:00:00 AM No UTC+10h AEST 111 | # 2:00:01 AM No UTC+10h AEST 112 | # 2:00:02 AM No UTC+10h AEST 113 | 114 | # Sunday, 6 October 2013 1:59:57 AM No UTC+10h AEST 115 | # 1:59:58 AM No UTC+10h AEST 116 | # 1:59:59 AM No UTC+10h AEST 117 | # 2:00:00 AM ? 3:00:00 AM +1h UTC+11h AEDT 118 | # 3:00:01 AM +1h UTC+11h AEDT 119 | # 3:00:02 AM +1h UTC+11h AEDT 120 | '2013-10-06 01:59', # DST starts in Canberra 121 | '2013-10-06 03:01', 122 | '2013-04-07 01:59', # DST ends in Canberra. See also notes below for peculiarities over the twice run over 02:00 to 03:00 123 | '2013-04-07 02:33', 124 | '2013-04-07 03:00', 125 | # Around one of the leap seconds (that is, when the UTC/GMT is tested 126 | '1994-06-30 23:00:00', 127 | '1994-06-30 23:59:59', 128 | '1994-07-01 00:00:00', 129 | '1994-07-01 00:00:01', 130 | '1994-07-01 01:00:00', 131 | '3000-01-01' 132 | ) 133 | 134 | # The origin of the POSIXct structure, '1970-01-01 00:00', 'UTC' is zero 135 | posixct_orig_str <- '1970-01-01 00:00:00' 136 | 137 | pre1971_DateStr <- c( 138 | # Around the origin for POSIXct 139 | '1970-01-01 10:00', 140 | posixct_orig_str, 141 | '1970-01-01 01:00:00', 142 | '1969-12-31 23:00:00', 143 | # Further ago/ahead 144 | # First we do want to test around the date of the origin of the VT_DATE thing in the COM world; see 145 | # http://blogs.msdn.com/b/ericlippert/archive/2003/09/16/eric-s-complete-guide-to-vt-date.aspx 146 | # Scary, huh? 147 | '1899-12-29', 148 | '1899-12-29 23:59:59', 149 | '1899-12-30', 150 | '1899-12-30 00:00:01', 151 | '1899-12-31', 152 | '1789-07-14', 153 | '0200-01-01' 154 | ) 155 | 156 | problem_DateStr <- c( 157 | '0020-01-01', # MS CLR hosting method invokation fails if such a DateTime is returned. 158 | '0001-01-01' # MS CLR hosting in C shows an OLEAUT VT_DATE of numeric value 0.0. Supposed to be for 1899-12-30 159 | ) 160 | 161 | testDatesStr <- c(post1971_DateStr, pre1971_DateStr) 162 | 163 | testSameInteger <- function(datestr) { 164 | expect_equal( as.integer(createUtcDate(datestr, 'UTC')), as.integer((as.POSIXct(datestr, tz='UTC')))) 165 | } 166 | 167 | # See issue #45; I do not think this could be passing but by chance 168 | testRtoClrAestTz <- function(dateStr) { 169 | testRtoClr(dateStr, pfun=as.POSIXct, tzIdR=tzIdR_AUest, tzId=tzId_AUest) 170 | } 171 | 172 | testRtoClrNoTz <- function(dateStr) { 173 | testRtoClr(dateStr, pfun=as.POSIXct, tzIdR="", tzId="") 174 | } 175 | 176 | testRtoClrUtc <- function(dateStr) { 177 | testRtoClr(dateStr, pfun=as.POSIXct, tzIdR='Utc', tzId='UTC') 178 | } 179 | 180 | 181 | # testDotNetToR('2013-04-07 02:32') 182 | -------------------------------------------------------------------------------- /tests/testthat/load_libs.r: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(rClr) 3 | cTypename <- "Rclr.TestCases" 4 | testClassName <- "Rclr.TestObject" 5 | -------------------------------------------------------------------------------- /tests/testthat/test-objwrap.r: -------------------------------------------------------------------------------- 1 | # testDir <- system.file('tests', package='rClr') 2 | # stopifnot(file.exists(testDir)) 3 | # source(file.path(testDir, 'load_libs.r')) 4 | 5 | # context("rClr wrappers using R references classes") 6 | 7 | # test_that("Object constructors calls work", { 8 | # tName <- testClassName 9 | # i1 <- 23L ; i2 <- 42L 10 | # d1 <- 1.234; d2 <- 2.345; 11 | # obj <- clrNew(tName, i1) 12 | # obj <- clrCobj(obj) 13 | # # > class(w) 14 | # # [1] "Rcpp_World" 15 | # # attr(,"package") 16 | # # [1] "rcppf" 17 | # # > 18 | # expect_equal(as.character(class(obj)), tName) 19 | # expect_equal(attributes(class(obj)), list(package='rClr')) 20 | # expect_equal(obj$FieldIntegerOne, i1 ); 21 | # }) 22 | 23 | # test_that("Basic types of length one are marshalled correctly", { 24 | # tNameLOne <- 'Rclr.Tests.RefClasses.LevelOneClass' 25 | # tNameLTwo <- 'Rclr.Tests.RefClasses.LevelTwoClass' 26 | # tNameLThree <- 'Rclr.Tests.RefClasses.LevelThreeClass' 27 | 28 | # obj <- clrNew(tNameLTwo) 29 | # obj <- clrCobj(obj) 30 | # # obj <- refgen$new() 31 | # expect_equal(as.character(class(obj)), tNameLTwo) 32 | # expect_true(inherits(obj,tNameLOne)) 33 | 34 | # expect_equal(obj$AbstractMethod(), "LevelOneClass::AbstractMethod()") 35 | # expect_equal(obj$AbstractMethod('some_string'), "LevelOneClass::AbstractMethod(string)") 36 | # expect_equal(obj$VirtualMethod(), "BaseAbstractClassOne::VirtualMethod()") 37 | # expect_equal(obj$IfBaseTwoMethod(), "LevelTwoClass::IfBaseTwoMethod()") 38 | 39 | # s <- "test string" 40 | # obj$IfBaseOneString <- s 41 | # expect_equal(obj$IfBaseOneString, s) 42 | 43 | # # Check that explicit interface implementations are working 44 | # expect_equal(obj$IfOneStringGetter, "Explicit LevelOneClass::InterfaceOne.IfOneStringGetter") 45 | 46 | 47 | # obj <- clrNew(tNameLThree) 48 | # obj <- clrCobj(obj) 49 | # expect_equal(as.character(class(obj)), tNameLTwo) 50 | # expect_true(inherits(obj,tNameLOne)) 51 | # expect_true(inherits(obj,tNameLTwo)) 52 | 53 | # expect_equal(obj$AbstractMethod(), "LevelThreeClass::AbstractMethod()") 54 | # expect_equal(obj$AbstractMethod('some_string'), "LevelOneClass::AbstractMethod(string)") 55 | # expect_equal(obj$VirtualMethod(), "LevelThreeClass::VirtualMethod()") 56 | 57 | # s <- "test string" 58 | # obj$IfBaseOneString <- s 59 | # expect_equal(obj$IfBaseOneString, paste( "Overriden LevelThreeClass::IfBaseOneString", s)) 60 | 61 | # }) 62 | -------------------------------------------------------------------------------- /vignettes/rclr_techdoc.Rmd: -------------------------------------------------------------------------------- 1 | 5 | 6 | Technical reference documentation 7 | ======================================= 8 | 9 | ```{r setup, include=FALSE} 10 | library(knitr) 11 | opts_chunk$set(out.extra='style="display:block; margin: auto"', fig.align="center") 12 | ``` 13 | 14 | Introduction 15 | ------------ 16 | 17 | This page gathers some more technical aspects of the **rClr** package, and is not meant to be read by most users. 18 | One aim is to document a few processes such as the build process. 19 | 20 | Build process 21 | ---------------------------- 22 | 23 | ## .Rd file documentation 24 | 25 | ```{r, eval=FALSE} 26 | library(devtools) 27 | install_github("jmp75/rclr-devtools/packages/rClrDevtools") 28 | library(rClrDevtools) # https://github.com/jmp75/rClr-devtools 29 | roxyRclr() 30 | # roxyRclr(pkgDir='~/src/codeplex/rClr') 31 | ``` 32 | 33 | ## Vignettes 34 | You should start from a new R session; if you have regenerated doc from Roxygen, there may be some surprises with the result of the `system.file` function. 35 | 36 | ```{r, eval=FALSE} 37 | library(rClrDevtools) # https://github.com/jmp75/rClr-devtools 38 | library(rClr) 39 | pkgDir <- tryFindPkgDir() 40 | # seem to need to move working directory. Oddities with knitr figure output otherwise 41 | originalDir <- getwd() 42 | docDir <- file.path(pkgDir, 'inst', 'doc') 43 | setwd(docDir) 44 | vignettesRclr() 45 | ``` 46 | 47 | ``` 48 | set R="c:\Program Files\R\R-3.1.2\bin\x64\R.exe" 49 | if not exist %R% set R="c:\Program Files\R\R-3.1.2\bin\i386\R.exe" 50 | cd F:\src\codeplex 51 | :: set BuildConfiguration=Debug 52 | rm -rf rClr.Rcheck 53 | del rClr_0.*.tar.gz 54 | del rClr_0.*.zip 55 | ``` 56 | 57 | Note that a call to R CMD build will now build the vignettes too, so maybe vignettesRclr is redundant. 58 | 59 | ``` 60 | %R% CMD build rClr > logbuild.txt 2>&1 61 | %R% CMD check --as-cran rClr_0.*.tar.gz > logcheck.txt 2>&1 62 | %R% CMD INSTALL --build rClr_0.*.tar.gz 63 | ``` 64 | 65 | ```{r, eval=FALSE} 66 | > setwd('c:/src/codeplex/rClr') 67 | > tools::buildVignettes(dir='.', tangle=TRUE) 68 | Quitting from lines 224-232 (rclr_intro.Rmd) 69 | Error: processing vignette 'rclr_intro.Rmd' failed with diagnostics: 70 | argument is of length zero 71 | ``` 72 | 73 | ```{r, eval=FALSE} 74 | library(rClrDevtools) 75 | cpDebugBins() 76 | library(testthat) 77 | test_package('rClr') 78 | ``` 79 | 80 | Diagnosing 81 | --------------- 82 | 83 | Have warnings, but by defaults could not see where, what. The following treats warnings as errors: 84 | ```{r, eval=FALSE} 85 | options(warn=2) 86 | test_package('rClr') 87 | # restore: 88 | options(warn=0) 89 | ``` 90 | 91 | Had an issue with memory footprint on 2015-03-26. A way to diagnose things: 92 | 93 | ```{r, eval=FALSE} 94 | library(rClr) 95 | cTypename <- "Rclr.TestCases" 96 | testClassName <- "Rclr.TestObject" 97 | callGcMethname <- "CallGC" 98 | forceDotNetGc <- function() { callTestCase( callGcMethname) } 99 | forceGc <- function() {gc() ; forceDotNetGc() ; gc() ; forceDotNetGc() ; } 100 | 101 | callTestCase <- function(...) { 102 | clrCallStatic(cTypename, ...) 103 | } 104 | 105 | blah <- clrCallStatic(cTypename, "CreateArrayMemFootprint", 100L * 1024L * 1024L) 106 | forceGc() 107 | forceGc() 108 | clrCallStatic(cTypename, "SinkLargeObject", blah) 109 | forceGc() 110 | forceGc() 111 | rm(blah) 112 | forceGc() 113 | forceGc() 114 | ``` 115 | 116 | ## Investigating issues with Mono. 117 | 118 | While investigating [rClr issue 7](https://github.com/jmp75/rClr/issues/7) 119 | 120 | ``` 121 | git reset --hard HEAD 122 | git pull 123 | git branch mono-4.0.2.5 mono-4.0.2.5 124 | git checkout mono-4.0.2.5 125 | git submodule foreach git submodule init && git submodule update --recursive 126 | ``` 127 | 128 | Follow instructions on [Linux](http://www.mono-project.com/docs/compiling-mono/linux/) 129 | 130 | ``` 131 | PREFIX=/usr/local 132 | PATH=$PREFIX/bin:$PATH 133 | ./autogen.sh --prefix=$PREFIX 134 | make 135 | make install 136 | ``` 137 | -------------------------------------------------------------------------------- /vignettes/rclr_troubleshooting.Rmd: -------------------------------------------------------------------------------- 1 | 5 | 6 | ```{r setup, include=FALSE} 7 | library(knitr) 8 | opts_chunk$set(out.extra='style="display:block; margin: auto"', fig.align="center") 9 | ``` 10 | 11 | Troubleshooting issues 12 | ======================================= 13 | 14 | # Package building issues 15 | 16 | ## "Package glib-2.0 was not found in the pkg-config search path" when building on Linux 17 | 18 | You get this error message when doing: 19 | 20 | ``` 21 | R CMD build rClr 22 | ``` 23 | 24 | You are missing the development files for the GLib library (On debian and related distributions, package `libglib2.0-dev`) 25 | 26 | ## "Package monosgen-2 was not found in the pkg-config search path." 27 | 28 | You are missing the development files "Mono JIT libraries - Development files (SGen GC)" (On debian and related distributions, package `libmonosgen2.0-dev`) 29 | 30 | 31 | ## Assertion at sgen-alloc.c:XXX, condition XXXXXXXXXXX not met 32 | 33 | For instance: 34 | 35 | ``` 36 | ** testing if installed package can be loaded 37 | * Assertion at sgen-alloc.c:774, condition `tlab_next_addr_offset != -1' not met 38 | ``` 39 | 40 | --------------------------------------------------------------------------------