Skip to content

Commit

Permalink
Fixed problem with calling unimported method in R. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelBal authored Apr 20, 2021
1 parent e5fe9ee commit df2ae03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rClr
Type: Package
Title: Accessing the Common Language Runtime (.NET/Mono) from R
Version: 0.9.0
Version: 0.9.1
Date: 2020-21-01
Authors@R: c( person("Jean-Michel", "Perraud", email =
"jean-michel.perraud@csiro.au", role = c("aut", "cre")))
Expand All @@ -21,7 +21,8 @@ VignetteBuilder: knitr
Suggests:
testthat,
knitr,
xtable
xtable,
markdown
URL: https://github.com/jmp75/rClr
License: LGPL-3
Depends:
Expand Down
5 changes: 2 additions & 3 deletions configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ fi
## Find the location of the MSBuild.exe executable.
GET_MSBUILD_CMD=`echo ${RCLR_SRC_DIR}/get_msbuildpath.cmd | sed -e 's/\//\\\\/g'`
# Do note that this one returns a slashified path already. See get_msbuildpath
MSBUILD_EXE_SLASH=`cmd /c "$GET_MSBUILD_CMD"`
MSBUILD_EXE_SLASH=`"$GET_MSBUILD_CMD"`
# MSBUILD_EXE=`${RCLR_SRC_DIR}/get_msbuildpath.cmd`
echo "$MSBUILD_EXE_SLASH"
if [ $MSBUILD_EXE_SLASH != "MSBuild.exe" ]
then
if [ ! -e $MSBUILD_EXE_SLASH ]
Expand All @@ -75,7 +74,7 @@ else
# 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)
# Thanks to http://cygwin.com/ml/cygwin/2011-09/msg00232.html for how to call cmd files from sh.
CREATE_LIB_CMD=`echo ${RCLR_SRC_DIR}/create_lib.cmd | sed -e 's/\//\\\\/g'`
cmd /c "$CREATE_LIB_CMD"
"$CREATE_LIB_CMD"
fi

exit 0
38 changes: 19 additions & 19 deletions src/ClrFacade/RDotNetDataConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ private RDotNetDataConverter (string pathToNativeSharedObj)
string assmbPath = Assembly.GetAssembly(this.GetType()).Location;
assmbPath = Path.GetFullPath(assmbPath);
var libDir = Path.GetDirectoryName(assmbPath);

if (NativeUtility.IsUnix)
dllName = Path.Combine(libDir, "rClr.so");
else
{
dllName = Path.Combine(libDir, Environment.Is64BitProcess ? "x64" : "i386",
dllName = Path.Combine(libDir, Environment.Is64BitProcess ? "x64" : "i386",
(isMonoRuntime() ? "rClrMono.dll" : "rClrMs.dll")
);
}
Expand All @@ -40,7 +40,7 @@ private RDotNetDataConverter (string pathToNativeSharedObj)
DataConversionHelper.RclrNativeDll = new RclrUnmanagedDll(dllName);

SetupREngine ();
// The Mono API already has some unhandled exception reporting.
// The Mono API already has some unhandled exception reporting.
// TODO Use the following if it works well for both CLRuntimes.
#if !MONO
// OBSOLETE? SetupExceptionHandling();
Expand Down Expand Up @@ -201,15 +201,15 @@ public static void SetConvertAdvancedTypes(bool enable)
/// Convert an object, if possible, using RDotNet capabilities
/// </summary>
/// <remarks>
/// If a conversion to an RDotNet SymbolicExpression was possible,
/// If a conversion to an RDotNet SymbolicExpression was possible,
/// this returns the IntPtr SafeHandle.DangerousGetHandle() to be passed to R.
/// If the object is null or such that no known conversion is possible, the same object
/// If the object is null or such that no known conversion is possible, the same object
/// as the input parameter is returned.
/// </remarks>
public object ConvertToR (object obj)
{
ClearSexpHandles();
if (obj == null)
if (obj == null)
return null;
var sexp = obj as SymbolicExpression;
if (sexp != null)
Expand Down Expand Up @@ -239,7 +239,7 @@ private static void AddSexpHandle(SymbolicExpression sexp)
}

/// <summary>
/// A list to reference to otherwise transient SEXP created by this class.
/// A list to reference to otherwise transient SEXP created by this class.
/// This is to prevent .NET and R to trigger GC before rClr function calls have returned to R.
/// </summary>
private static List<SymbolicExpression> handles = new List<SymbolicExpression>();
Expand All @@ -256,21 +256,21 @@ public object ConvertFromR(IntPtr pointer, int sexptype)
public bool ConvertVectors { get; set; }

/// <summary>
/// Gets/sets whether to convert non-primitive value types and vector thereof, e.g. TimeSpan and DateTime.
/// Gets/sets whether to convert non-primitive value types and vector thereof, e.g. TimeSpan and DateTime.
/// Most users should never need to modify the default.
/// </summary>
public bool ConvertValueTypes
{
get;
set;
public bool ConvertValueTypes
{
get;
set;
}

private bool convertAdvancedTypes;

/// <summary>
/// Gets/sets whether to convert more complicated types such as dictionaries, arrays of reference types, etc.
/// </summary>
public bool ConvertAdvancedTypes
public bool ConvertAdvancedTypes
{
get { return convertAdvancedTypes; }
set
Expand Down Expand Up @@ -375,7 +375,7 @@ private GenericVector ConvertDictionary<U>(object obj)
{
var dict = (IDictionary<string, U>)obj;
if (!converterFunctions.ContainsKey(typeof(U[])))
throw new NotSupportedException("Cannot convert a dictionary of type " + dict.GetType());
throw new NotSupportedException("Cannot convert a dictionary of type " + dict.GetType());
var values = converterFunctions[typeof(U[])].Invoke(dict.Values.ToArray());
SetAttribute(values, dict.Keys.ToArray());
return values.AsList();
Expand Down Expand Up @@ -437,7 +437,7 @@ private SymbolicExpression ConvertArrayChar(object obj)
char[] array = (char[])obj;
return engine.CreateCharacterVector(Array.ConvertAll(array, x => x.ToString()));
}

private SymbolicExpression ConvertArrayDateTime(object obj)
{
if (!ConvertVectors) return null;
Expand All @@ -455,7 +455,7 @@ private SymbolicExpression ConvertArrayComplex(object obj)
if (!ConvertValueTypes) return null;
Complex[] array = (Complex[])obj;
return engine.CreateComplexVector(array);
}
}

private SymbolicExpression ConvertArrayTimeSpan(object obj)
{
Expand Down Expand Up @@ -564,7 +564,7 @@ private SymbolicExpression ConvertObject(object obj)
//var externalPtr = new ExternalPointer(engine, ptr);
// At this point, we have a loop from managed to unmanaged to managed memory.
// ExternalPointer -> externalptr -> ClrObjectHandle -> Variant(if Microsoft) -> obj
// This is not quite what we want to return: we need to produce an S4 object
// This is not quite what we want to return: we need to produce an S4 object
// S4Object -> ExternalPointer -> externalptr -> ClrObjectHandle -> Variant(if Microsoft) -> obj
// return CreateClrObj(externalPtr, obj.GetType().FullName);
}
Expand All @@ -586,7 +586,7 @@ public Function CreateClrS4Object
get
{
if (createClrS4Object == null)
createClrS4Object = engine.Evaluate("invisible(getCurrentConvertedObject)").AsFunction();
createClrS4Object = engine.Evaluate("invisible(rClr::getCurrentConvertedObject)").AsFunction();
return createClrS4Object;
}
}
Expand Down Expand Up @@ -810,4 +810,4 @@ private object ConvertSymbolicExpression(SymbolicExpressionWrapper sexpWrap)
return sexpWrap.ToClrEquivalent();
}
}
}
}

0 comments on commit df2ae03

Please sign in to comment.