From 16c9435160426849d0694e9cfddf08f34c5a3f34 Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Sat, 12 Apr 2014 16:44:49 -0400 Subject: [PATCH 1/7] Make line endings in Ref.cs Unix line endings --- Clojure/Clojure/Lib/Ref.cs | 244 ++++++++++++++++++------------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/Clojure/Clojure/Lib/Ref.cs b/Clojure/Clojure/Lib/Ref.cs index 5e9d803bd..fc6aff95e 100644 --- a/Clojure/Clojure/Lib/Ref.cs +++ b/Clojure/Clojure/Lib/Ref.cs @@ -96,7 +96,7 @@ public TVal Next /// /// Construct a TVal, linked to a previous TVal. - /// + /// public TVal(object val, long point, TVal prior) { _val = val; @@ -109,7 +109,7 @@ public TVal(object val, long point, TVal prior) /// /// Construct a TVal, linked to itself. - /// + /// public TVal(object val, long point) { _val = val; @@ -126,7 +126,7 @@ public TVal(object val, long point) /// Set the value/point. /// /// - /// + /// public void SetValue(object val, long point) { _val = val; @@ -141,19 +141,19 @@ public void SetValue(object val, long point) #region Data /// - /// Values at points in time for this reference. + /// Values at points in time for this reference. /// TVal _tvals; /// - /// Values at points in time for this reference. - /// - internal TVal TVals - { - get { return _tvals; } - } - - /// + /// Values at points in time for this reference. + /// + internal TVal TVals + { + get { return _tvals; } + } + + /// /// Number of faults for the reference. /// readonly AtomicInteger _faults; @@ -196,8 +196,8 @@ public int MinHistory { get { return _minHistory; } set { _minHistory = value; } - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")] + } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")] public Ref setMinHistory(int minHistory) { _minHistory = minHistory; @@ -210,8 +210,8 @@ public int MaxHistory { get { return _maxHistory; } set { _maxHistory = value; } - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")] + } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")] public Ref setMaxHistory(int maxHistory) { _maxHistory = maxHistory; @@ -222,8 +222,8 @@ public Ref setMaxHistory(int maxHistory) /// /// Used to generate unique ids. /// - static readonly AtomicLong _ids = new AtomicLong(); - + static readonly AtomicLong _ids = new AtomicLong(); + bool _disposed = false; #endregion @@ -291,9 +291,9 @@ public Ref(object initval, IPersistentMap meta) #endregion - #region History counts - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get")] + #region History counts + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get")] public int getHistoryCount() { try @@ -337,7 +337,7 @@ public override object deref() //Console.WriteLine("Thr {0}, {1}: No-trans get => {2}", Thread.CurrentThread.ManagedThreadId,DebugStr(), ret); return ret; } - return t.DoGet(this); + return t.DoGet(this); } object currentVal() @@ -457,8 +457,8 @@ internal void SetValue(object val, long commitPoint) /// Set the value (must be in a transaction). /// /// The new value. - /// The new value. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")] + /// The new value. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")] public object set(object val) { return LockingTransaction.GetEx().DoSet(this, val); @@ -469,8 +469,8 @@ public object set(object val) /// /// The function to apply to the current state and additional arguments. /// Additional arguments. - /// The computed value. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "commute")] + /// The computed value. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "commute")] public object commute(IFn fn, ISeq args) { return LockingTransaction.GetEx().DoCommute(this, fn, args); @@ -481,18 +481,18 @@ public object commute(IFn fn, ISeq args) /// /// The function to apply to the current state and additional arguments. /// Additional arguments. - /// The computed value. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "alter")] + /// The computed value. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "alter")] public object alter(IFn fn, ISeq args) { LockingTransaction t = LockingTransaction.GetEx(); - return t.DoSet(this, fn.applyTo(RT.cons(t.DoGet(this), args))); + return t.DoSet(this, fn.applyTo(RT.cons(t.DoGet(this), args))); } /// /// Touch the reference. (Add to the tracking list in the current transaction.) - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "touch")] + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "touch")] public void touch() { LockingTransaction.GetEx().DoEnsure(this); @@ -500,10 +500,10 @@ public void touch() #endregion - #region IFn Members - - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "fn")] + #region IFn Members + + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "fn")] public IFn fn() { return (IFn)deref(); @@ -666,92 +666,92 @@ public int CompareTo(Ref other) return _id.CompareTo(other._id); } - #endregion - - #region object overrides - - public override bool Equals(object obj) - { - if (ReferenceEquals(this, obj)) - return true; - - Ref r = obj as Ref; - if (r == null) - return false; - - return _id == r._id; - } - - public override int GetHashCode() - { - return _id.GetHashCode(); - } - #endregion - - #region operator overrides - - public static bool operator ==(Ref x, Ref y) - { - if (ReferenceEquals(x, y)) - return true; - - if ((object)x == null) - return false; - - return x.CompareTo(y) == 0; - } - - public static bool operator !=(Ref x, Ref y) - { - return !(x == y); - } - - public static bool operator <(Ref x, Ref y) - { - if (ReferenceEquals(x, y)) - return false; - - if ( ReferenceEquals(x,null) ) - throw new ArgumentException("Cannot compare null","x"); - - return x.CompareTo(y) < 0; - } - - public static bool operator >(Ref x, Ref y) - { - if (ReferenceEquals(x, y)) - return false; - - if ( ReferenceEquals(x,null) ) - throw new ArgumentException("Cannot compare null","x"); - - return x.CompareTo(y) > 0; - } - - #endregion - - #region IDisposable - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (!_disposed) - { - if (disposing) - { - if ( _lock != null ) - _lock.Dispose(); - } - - _disposed = true; - } - } - - #endregion + #endregion + + #region object overrides + + public override bool Equals(object obj) + { + if (ReferenceEquals(this, obj)) + return true; + + Ref r = obj as Ref; + if (r == null) + return false; + + return _id == r._id; + } + + public override int GetHashCode() + { + return _id.GetHashCode(); + } + #endregion + + #region operator overrides + + public static bool operator ==(Ref x, Ref y) + { + if (ReferenceEquals(x, y)) + return true; + + if ((object)x == null) + return false; + + return x.CompareTo(y) == 0; + } + + public static bool operator !=(Ref x, Ref y) + { + return !(x == y); + } + + public static bool operator <(Ref x, Ref y) + { + if (ReferenceEquals(x, y)) + return false; + + if ( ReferenceEquals(x,null) ) + throw new ArgumentException("Cannot compare null","x"); + + return x.CompareTo(y) < 0; + } + + public static bool operator >(Ref x, Ref y) + { + if (ReferenceEquals(x, y)) + return false; + + if ( ReferenceEquals(x,null) ) + throw new ArgumentException("Cannot compare null","x"); + + return x.CompareTo(y) > 0; + } + + #endregion + + #region IDisposable + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + if ( _lock != null ) + _lock.Dispose(); + } + + _disposed = true; + } + } + + #endregion } } From 1353ef8e241ad566f864ff5042f7e39488911024 Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Sun, 13 Apr 2014 17:11:58 -0400 Subject: [PATCH 2/7] Patch RT.cs to use System.Environment.CurrentDirectory Unity sets System.AppDomain.CurrentDomain.BaseDirectory to null which causes all kinds of problems. --- Clojure/Clojure/Lib/RT.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Clojure/Clojure/Lib/RT.cs b/Clojure/Clojure/Lib/RT.cs index e63fc4d6c..0692fc03e 100644 --- a/Clojure/Clojure/Lib/RT.cs +++ b/Clojure/Clojure/Lib/RT.cs @@ -3407,8 +3407,8 @@ static IEnumerable GetFindFilePaths() static IEnumerable GetFindFilePathsRaw() { - yield return System.AppDomain.CurrentDomain.BaseDirectory; - yield return Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin"); + yield return System.Environment.CurrentDirectory; + yield return Path.Combine(System.Environment.CurrentDirectory, "bin"); yield return Directory.GetCurrentDirectory(); yield return Path.GetDirectoryName(typeof(RT).Assembly.Location); From 73b1a14606097f88689fdd53334ef3f8d16a087e Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Sun, 13 Apr 2014 17:13:05 -0400 Subject: [PATCH 3/7] Comment out any mention of ReaderWriterLockSlim Raises NotImplemented exceptions in Unity otherwise. Refs and MultiFns are broken as a result. --- Clojure/Clojure/Lib/MultiFn.cs | 34 +++++++++++++++++----------------- Clojure/Clojure/Lib/Ref.cs | 22 +++++++++++----------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Clojure/Clojure/Lib/MultiFn.cs b/Clojure/Clojure/Lib/MultiFn.cs index 0b4504166..c43208687 100644 --- a/Clojure/Clojure/Lib/MultiFn.cs +++ b/Clojure/Clojure/Lib/MultiFn.cs @@ -82,7 +82,7 @@ public IPersistentMap PreferTable /// volatile object _cachedHierarchy; - ReaderWriterLockSlim _rw; + // ReaderWriterLockSlim _rw; bool _disposed = false; //static readonly Var _assoc = RT.var("clojure.core", "assoc"); @@ -112,7 +112,7 @@ public MultiFn(string name, IFn dispatchFn, object defaultDispatchVal, IRef hier _preferTable = PersistentHashMap.EMPTY; _hierarchy = hierarchy; _cachedHierarchy = null; - _rw = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); + // _rw = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); } #endregion @@ -128,7 +128,7 @@ public MultiFn(string name, IFn dispatchFn, object defaultDispatchVal, IRef hier [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "add")] public MultiFn addMethod(object dispatchVal, IFn method) { - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); try { _methodTable = MethodTable.assoc(dispatchVal, method); @@ -137,7 +137,7 @@ public MultiFn addMethod(object dispatchVal, IFn method) } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } } @@ -150,7 +150,7 @@ public MultiFn addMethod(object dispatchVal, IFn method) [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "remove")] public MultiFn removeMethod(object dispatchVal) { - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); try { _methodTable = MethodTable.without(dispatchVal); @@ -159,7 +159,7 @@ public MultiFn removeMethod(object dispatchVal) } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } } @@ -172,7 +172,7 @@ public MultiFn removeMethod(object dispatchVal) [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "prefer")] public MultiFn preferMethod(object dispatchValX, object dispatchValY) { - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); try { if (Prefers(dispatchValY, dispatchValX)) @@ -185,7 +185,7 @@ public MultiFn preferMethod(object dispatchValX, object dispatchValY) } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } } @@ -242,7 +242,7 @@ private bool Dominates(object x, object y) /// private IPersistentMap ResetCache() { - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); try { _methodCache = MethodTable; @@ -251,7 +251,7 @@ private IPersistentMap ResetCache() } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } } @@ -294,7 +294,7 @@ private IFn GetFn(object dispatchVal) /// The mest method. private IFn FindAndCacheBestMethod(object dispatchVal) { - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); IMapEntry bestEntry; IPersistentMap mt = _methodTable; IPersistentMap pt = _preferTable; @@ -319,11 +319,11 @@ private IFn FindAndCacheBestMethod(object dispatchVal) } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } // ensure basis has stayed stable throughout, else redo - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); try { if (mt == _methodTable @@ -343,7 +343,7 @@ private IFn FindAndCacheBestMethod(object dispatchVal) } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } } @@ -375,7 +375,7 @@ public IPersistentMap getPreferTable() [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "reset")] public MultiFn reset() { - _rw.EnterWriteLock(); + // _rw.EnterWriteLock(); try { _methodTable = _methodCache = _preferTable = PersistentHashMap.EMPTY; @@ -384,7 +384,7 @@ public MultiFn reset() } finally { - _rw.ExitWriteLock(); + // _rw.ExitWriteLock(); } } @@ -787,7 +787,7 @@ private void Dispose(bool disposing) { if (disposing) { - ((IDisposable)_rw).Dispose(); + // ((IDisposable)_rw).Dispose(); } _disposed = true; diff --git a/Clojure/Clojure/Lib/Ref.cs b/Clojure/Clojure/Lib/Ref.cs index fc6aff95e..cedfc2229 100644 --- a/Clojure/Clojure/Lib/Ref.cs +++ b/Clojure/Clojure/Lib/Ref.cs @@ -161,7 +161,7 @@ internal TVal TVals /// /// Reader/writer lock for the reference. /// - readonly ReaderWriterLockSlim _lock; + // readonly ReaderWriterLockSlim _lock; /// /// Info on the transaction locking this ref. @@ -250,7 +250,7 @@ public Ref(object initval, IPersistentMap meta) { _id = _ids.getAndIncrement(); _faults = new AtomicInteger(); - _lock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); + // _lock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); _tvals = new TVal(initval, 0); } @@ -344,14 +344,14 @@ object currentVal() { try { - _lock.EnterReadLock(); + // _lock.EnterReadLock(); if (_tvals != null) return _tvals.Val; throw new InvalidOperationException(String.Format("{0} is unbound.", ToString())); } finally { - _lock.ExitReadLock(); + // _lock.ExitReadLock(); } } @@ -364,7 +364,7 @@ object currentVal() /// internal void EnterReadLock() { - _lock.EnterReadLock(); + // _lock.EnterReadLock(); } /// @@ -372,7 +372,7 @@ internal void EnterReadLock() /// internal void ExitReadLock() { - _lock.ExitReadLock(); + // _lock.ExitReadLock(); } /// @@ -380,7 +380,7 @@ internal void ExitReadLock() /// internal void EnterWriteLock() { - _lock.EnterWriteLock(); + // _lock.EnterWriteLock(); } @@ -389,7 +389,7 @@ internal void EnterWriteLock() /// internal bool TryEnterWriteLock(int msecTimeout) { - return _lock.TryEnterWriteLock(msecTimeout); + return true; // _lock.TryEnterWriteLock(msecTimeout); } /// @@ -397,7 +397,7 @@ internal bool TryEnterWriteLock(int msecTimeout) /// internal void ExitWriteLock() { - _lock.ExitWriteLock(); + // _lock.ExitWriteLock(); } /// @@ -744,8 +744,8 @@ private void Dispose(bool disposing) { if (disposing) { - if ( _lock != null ) - _lock.Dispose(); + // if ( _lock != null ) + // _lock.Dispose(); } _disposed = true; From 87b20e524f884bd5a93908d06a3c1d07a4f83f63 Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Sun, 13 Apr 2014 17:14:30 -0400 Subject: [PATCH 4/7] Add unity-build script to build Clojure using Unity's Mono distribution --- unity-build.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 unity-build.sh diff --git a/unity-build.sh b/unity-build.sh new file mode 100755 index 000000000..7d932b50a --- /dev/null +++ b/unity-build.sh @@ -0,0 +1 @@ +/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/mono /Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/lib/mono/2.0/xbuild.exe Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Debug 3.5" /p:Platform="Any CPU" \ No newline at end of file From 5e44e765c63a0c4e477bb9416b12af8d93d75554 Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Sun, 13 Apr 2014 20:06:26 -0400 Subject: [PATCH 5/7] Add terminal flag to fix broken build --- unity-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity-build.sh b/unity-build.sh index 7d932b50a..5b30c0e0f 100755 --- a/unity-build.sh +++ b/unity-build.sh @@ -1 +1 @@ -/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/mono /Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/lib/mono/2.0/xbuild.exe Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Debug 3.5" /p:Platform="Any CPU" \ No newline at end of file +EnableNuGetPackageRestore=true /Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/mono /Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/lib/mono/2.0/xbuild.exe Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Debug 3.5" /p:Platform="Any CPU" \ No newline at end of file From 44f3fa74ea7fcd729a5d98b6a4e7d54bd4e5a5c8 Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Mon, 14 Apr 2014 17:10:17 -0400 Subject: [PATCH 6/7] Update unity-build to use stock mono xbuild --- unity-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity-build.sh b/unity-build.sh index 5b30c0e0f..fce3e43b4 100755 --- a/unity-build.sh +++ b/unity-build.sh @@ -1 +1 @@ -EnableNuGetPackageRestore=true /Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/mono /Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/lib/mono/2.0/xbuild.exe Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Debug 3.5" /p:Platform="Any CPU" \ No newline at end of file +EnableNuGetPackageRestore=true xbuild Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Debug 3.5" /p:Platform="Any CPU" From 7b822ceb54696dd13ebfe53d2f2331c4f3cba251 Mon Sep 17 00:00:00 2001 From: atsuo yamada Date: Mon, 30 Jun 2014 00:38:08 +0900 Subject: [PATCH 7/7] DefineDynamicModule with emitSymbolInfo raise ExecutionEngineException on Unity player for Win/Mac --- unity-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity-build.sh b/unity-build.sh index fce3e43b4..dbfa27c42 100755 --- a/unity-build.sh +++ b/unity-build.sh @@ -1 +1 @@ -EnableNuGetPackageRestore=true xbuild Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Debug 3.5" /p:Platform="Any CPU" +EnableNuGetPackageRestore=true xbuild Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Release 3.5" /p:Platform="Any CPU"