-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Robert McIntosh <[email protected]> Co-authored-by: Félix MIL <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
57aa1e8
commit 4efe9a0
Showing
30 changed files
with
449 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,57 @@ | ||
# Environment that holds various global variables and settings for the package. | ||
# It is not exported and should not be directly manipulated by other packages. | ||
rSharpEnv <- new.env(parent = emptyenv()) | ||
|
||
# name of the package. This will be used to retrieve information on the package at run time | ||
rSharpEnv$packageName <- "rSharp" | ||
# Name of the C++ redistributable library | ||
rSharpEnv$msvcrFileName <- "msvcp140.dll" | ||
# The name of the native (C++) library | ||
rSharpEnv$nativePkgName <- "rSharp" | ||
# Name of the .NET library | ||
rSharpEnv$dotnetPkgName <- "ClrFacade" | ||
|
||
# Full type name of the main facade to the interop code written in C# | ||
rSharpEnv$clrFacadeTypeName <- "ClrFacade.ClrFacade" | ||
# Full type name of the test cases | ||
rSharpEnv$testCasesTypeName <- "ClrFacade.TestCases" | ||
# Full name of test object class | ||
rSharpEnv$testObjectTypeName <- "ClrFacade.TestObject" | ||
rSharpEnv$testMethodBindingTypeName <- "ClrFacade.TestMethodBinding" | ||
|
||
|
||
#' Names of the settings stored in rSharpEnv Can be used with `getRSharpSetting()` | ||
#' @export | ||
rSharpSettingNames <- names(rSharpEnv) | ||
|
||
#' @title getRSharpSetting | ||
#' @description Get the value of a global rSharp setting. | ||
#' | ||
#' @param settingName String name of the setting | ||
#' | ||
#' @return Value of the setting stored in rSharpEnv. If the setting does not exist, an error is thrown. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' getRSharpSetting("nativePkgName") | ||
getRSharpSetting <- function(settingName) { | ||
if (!(any(names(rSharpEnv) == settingName))) { | ||
stop(messages$errorPackageSettingNotFound(settingName, rSharpEnv)) | ||
} | ||
|
||
obj <- rSharpEnv[[settingName]] | ||
# Evaluate if the object is a function. This is required since some properties are defined as function reference | ||
if (is.function(obj)) { | ||
return(obj()) | ||
} | ||
|
||
return(obj) | ||
} | ||
# Environment that holds various global variables and settings for the package. | ||
# It is not exported and should not be directly manipulated by other packages. | ||
rSharpEnv <- new.env(parent = emptyenv()) | ||
|
||
# name of the package. This will be used to retrieve information on the package at run time | ||
rSharpEnv$packageName <- "rSharp" | ||
# Name of the C++ redistributable library | ||
rSharpEnv$msvcrFileName <- "msvcp140.dll" | ||
# The name of the package | ||
rSharpEnv$pkgName <- "rSharp" | ||
|
||
# The name of the native (C++) library | ||
rSharpEnv$nativePkgName <- | ||
switch(Sys.info()[['sysname']], | ||
Windows = rSharpEnv$pkgName, | ||
Linux = {paste0(rSharpEnv$pkgName, ".linux")}, | ||
Darwin = {paste0(rSharpEnv$pkgName,".mac")}) | ||
|
||
# Name of the .NET library | ||
rSharpEnv$dotnetPkgName <- "ClrFacade" | ||
|
||
# Full type name of the main facade to the interop code written in C# | ||
rSharpEnv$clrFacadeTypeName <- "ClrFacade.ClrFacade" | ||
# Full type name of the test cases | ||
rSharpEnv$testCasesTypeName <- "ClrFacade.TestCases" | ||
# Full name of test object class | ||
rSharpEnv$testObjectTypeName <- "ClrFacade.TestObject" | ||
rSharpEnv$testMethodBindingTypeName <- "ClrFacade.TestMethodBinding" | ||
|
||
|
||
#' Names of the settings stored in rSharpEnv Can be used with `getRSharpSetting()` | ||
#' @export | ||
rSharpSettingNames <- names(rSharpEnv) | ||
|
||
#' @title getRSharpSetting | ||
#' @description Get the value of a global rSharp setting. | ||
#' | ||
#' @param settingName String name of the setting | ||
#' | ||
#' @return Value of the setting stored in rSharpEnv. If the setting does not exist, an error is thrown. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' getRSharpSetting("nativePkgName") | ||
getRSharpSetting <- function(settingName) { | ||
if (!(any(names(rSharpEnv) == settingName))) { | ||
stop(messages$errorPackageSettingNotFound(settingName, rSharpEnv)) | ||
} | ||
|
||
obj <- rSharpEnv[[settingName]] | ||
# Evaluate if the object is a function. This is required since some properties are defined as function reference | ||
if (is.function(obj)) { | ||
return(obj()) | ||
} | ||
|
||
return(obj) | ||
} |
Oops, something went wrong.