Skip to content

Commit

Permalink
Merge branch 'setzer22-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nasser committed Apr 5, 2019
2 parents 488e64b + ddd4826 commit c848606
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 44 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Arcadia Changelog

## Beta 1.0.6

- Fixed issue [#351](https://github.com/arcadia-unity/Arcadia/issues/351).

## Beta 1.0.5

- Fixed issue [#346](https://github.com/arcadia-unity/Arcadia/issues/346).

## Beta 1.0.4

- Fixed issue [#345](https://github.com/arcadia-unity/Arcadia/issues/345).

## Beta 1.0.3
- Fixed MAGIC issue [#35](https://github.com/nasser/magic/issues/35) with a compiler built from [arcadia-unity/clojure-clr@9e5b7330](https://github.com/arcadia-unity/clojure-clr/commit/9e5b7330c7e46ac7e5978bd289a869199c2f6e53)

Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
* Pedro Martins - [pjago](https://github.com/pjago)
* Vincent Cantin - [green-coder](https://github.com/green-coder)
* Jeremy Kross - [jeremykross](https://github.com/jeremykross)
* Artur Dębkowski - [ekhart](https://github.com/ekhart)
* Artur Dębkowski - [ekhart](https://github.com/ekhart)
* Josep Sànchez - [setzer22](https://github.com/setzer22)
2 changes: 1 addition & 1 deletion Components/ArcadiaState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ private static void InitializeOwnVars ()
var arcadiaLiteralsNs = "arcadia.data";
Arcadia.Util.require(arcadiaLiteralsNs);
Arcadia.Util.getVar(ref serializeVar, arcadiaLiteralsNs, "*serialize*");
Arcadia.Util.getVar(ref printReadablyVar, arcadiaLiteralsNs, "*print-compactly*");
Arcadia.Util.getVar(ref objectDbVar, arcadiaLiteralsNs, "*object-db*");

var coreNs = "clojure.core";
Arcadia.Util.getVar(ref printReadablyVar, coreNs, "*print-readably*");
Arcadia.Util.getVar(ref prStrVar, coreNs, "pr-str");

Arcadia.Util.getVar(ref readStringVar, "clojure.edn", "read-string");
Expand Down
48 changes: 46 additions & 2 deletions Editor/NRepl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public override void Flush ()
private static Var star3Var;
private static Var starEVar;
private static Var errorStringVar;
private static Var metaVar;
private static Var nsResolveVar;
private static Var findNsVar;
private static Var symbolVar;

private static Namespace shimsNS;

Expand All @@ -109,7 +113,12 @@ static NRepl ()
star2Var = RT.var("clojure.core", "*2");
star3Var = RT.var("clojure.core", "*3");
starEVar = RT.var("clojure.core", "*e");


metaVar = RT.var("clojure.core", "meta");
nsResolveVar = RT.var("clojure.core", "ns-resolve");
findNsVar = RT.var("clojure.core", "find-ns");
symbolVar = RT.var("clojure.core", "symbol");

readStringOptions = PersistentHashMap.EMPTY.assoc(Keyword.intern("read-cond"), Keyword.intern("allow"));

shimsNS = Namespace.findOrCreate(Symbol.intern("arcadia.nrepl.shims"));
Expand Down Expand Up @@ -290,8 +299,10 @@ static void HandleMessage (BDictionary message, TcpClient client)
new BDictionary
{
{"eval", 1},
{"load-file", 1},
{"describe", 1},
{"clone", 1},
{"info", 1},
}
},
{
Expand Down Expand Up @@ -323,6 +334,39 @@ static void HandleMessage (BDictionary message, TcpClient client)
var fn = new EvalFn(message, client);
addCallbackVar.invoke(fn);
break;
case "load-file":
message["code"] = new BString("(do " + message["file"].ToString() + " )");
var loadFn = new EvalFn(message, client);
addCallbackVar.invoke(loadFn);
break;
case "info":
var symbolMetadata = (IPersistentMap)metaVar.invoke(nsResolveVar.invoke(
findNsVar.invoke(symbolVar.invoke(message["ns"].ToString())),
symbolVar.invoke(message["symbol"].ToString())));

if (symbolMetadata != null) {
var resultMessage = new BDictionary {
{"id", message["id"]},
{"session", session.ToString()},
{"status", new BList {"done"}}
};
foreach (var entry in symbolMetadata) {
if (entry.val() != null) {
resultMessage[entry.key().ToString().Substring(1)] =
new BString(entry.val().ToString());
}
}
SendMessage(resultMessage, client);
} else {
SendMessage(
new BDictionary
{
{"id", message["id"]},
{"session", session.ToString()},
{"status", new BList {"done", "no-info"}}
}, client);
}
break;
default:
SendMessage(
new BDictionary
Expand Down Expand Up @@ -483,4 +527,4 @@ public static void StartServer ()
}).Start();
}
}
}
}
5 changes: 2 additions & 3 deletions Helpers/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,10 @@ public static bool IsNull (object obj)
public static object TrueNil (object obj)
{
UnityEngine.Object obj2 = obj as UnityEngine.Object;
if (obj2 == null) {
if (obj2 == null && obj is UnityEngine.Object) {
return null;
}

return obj;
return obj;
}

// ==================================================================
Expand Down
9 changes: 7 additions & 2 deletions Source/arcadia/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
^{:doc "Determines whether objects should print in a manner that can be read back in by the edn reader. Defaults to false."}
*serialize* false)

(def
^:dynamic
*print-compactly*
false)

;; ============================================================
;; object database
;; ============================================================
Expand Down Expand Up @@ -279,7 +284,7 @@
(str sb)))))))

(defmethod serialize ::unity-value-type [x w]
(if *print-readably*
(if *print-compactly*
(vt-serialize-map x w)
(vt-serialize-vec x w)))

Expand Down Expand Up @@ -369,7 +374,7 @@

(defmethod serialize ~type-sym [^UnityEngine.Vector3 ~value-sym, ^TextWriter w#]
(.Write w#
(if *print-readably*
(if *print-compactly*
(lit-str
~(str "#unity/value{:arcadia.data/type \"" shortname "\"")
~@(apply concat
Expand Down
68 changes: 34 additions & 34 deletions Source/arcadia/internal/filewatcher.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[arcadia.internal.array-utils :as au]
[clojure.data :as d])
(:import [Arcadia StringHelper ArrayHelper]
[System.Collections Queue]
[System.Collections Queue]
[System.IO FileSystemInfo DirectoryInfo FileInfo Path File]
[System DateTime]
[System.Threading Thread ThreadStart]
Expand Down Expand Up @@ -76,12 +76,12 @@
;; (s/keys :req [::g ::fsis])))
)

(s/fdef merge-file-graphs
:args (s/alt
:0 #{[]}
:1 ::file-graph
:2 (s/cat :g1 ::file-graph, :g2 ::file-graph))
:ret ::file-graph)
;; (s/fdef merge-file-graphs
;; :args (s/alt
;; :0 #{[]}
;; :1 ::file-graph
;; :2 (s/cat :g1 ::file-graph, :g2 ::file-graph))
;; :ret ::file-graph)

(defn- merge-file-graphs
([] {::g {}, ::fsis {}, ::type ::file-graph})
Expand Down Expand Up @@ -115,8 +115,8 @@

(def empty-set #{}) ;;omg

(s/fdef info-children
:args (s/cat :info ::info))
;; (s/fdef info-children
;; :args (s/cat :info ::info))

(defn- info-children [info]
;;{:pre [(as/loud-valid? ::info info)]}
Expand Down Expand Up @@ -151,10 +151,10 @@
(catch System.ArgumentException e))
:else (throw (System.ArgumentException. "Expects DirectoryInfo or String."))))

(s/fdef info
:args (s/cat :arg ::info-path)
:ret (s/or :info ::info
:nil nil?))
;; (s/fdef info
;; :args (s/cat :arg ::info-path)
;; :ret (s/or :info ::info
;; :nil nil?))

;; !!!!THIS SOMETIMES RETURNS NIL!!!!
(defn- info ^FileSystemInfo [x]
Expand All @@ -170,14 +170,14 @@
:else (throw (System.ArgumentException. "Expects FileSystemInfo or String."))))


(s/fdef file-graph
:args (s/alt
:no-opts (s/cat :root ::path)
:with-opts (s/cat
:path ::path
:opts map?))
:ret (s/or :info ::info
:nil nil?))
;; (s/fdef file-graph
;; :args (s/alt
;; :no-opts (s/cat :root ::path)
;; :with-opts (s/cat
;; :path ::path
;; :opts (s/nilable map?)))
;; :ret (s/or :info ::info
;; :nil nil?))

;; this might screw up symlinks
(defn file-graph
Expand Down Expand Up @@ -375,17 +375,17 @@
(s/def ::listener
(s/keys :req [::listener-key ::func ::event-type ::re-filter]))

(s/fdef apply-listener
:args (s/cat :listener ::listener, :event ::event))
;; (s/fdef apply-listener
;; :args (s/cat :listener ::listener, :event ::event))

(defn- apply-listener [{:keys [::func] :as listener} event]
(func event))

(s/fdef run-listeners
:args (s/cat
:watch-data ::watch-data
:changes (s/every ::event))
:ret nil?)
;; (s/fdef run-listeners
;; :args (s/cat
;; :watch-data ::watch-data
;; :changes (s/every ::event))
;; :ret nil?)

(defn- re-filter-matches? [re-filter path]
(or (= :directory re-filter)
Expand Down Expand Up @@ -480,9 +480,9 @@
;; ------------------------------------------------------------
;; updating topology

(s/fdef update-history
:args (s/cat :history ::history, :changes (s/every ::event))
:ret ::history)
;; (s/fdef update-history
;; :args (s/cat :history ::history, :changes (s/every ::event))
;; :ret ::history)

(defn- update-history [history changes]
(reduce (fn [history {:keys [::path ::event-type] :as change}]
Expand All @@ -503,9 +503,9 @@

(defonce ws-weirdness-log (atom []))

(s/fdef watch-step
:args (s/cat :watch-data ::watch-data)
:ret ::watch-data)
;; (s/fdef watch-step
;; :args (s/cat :watch-data ::watch-data)
;; :ret ::watch-data)

(defn- watch-step [{:keys [::event-type->listeners] :as watch-data}]
(if-let [chs (seq (changes watch-data))]
Expand Down
1 change: 1 addition & 0 deletions Source/arcadia/introspection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

(def inclusive-binding-flag
(enum-or
BindingFlags/FlattenHierarchy
BindingFlags/Static
BindingFlags/Instance
BindingFlags/Public
Expand Down
17 changes: 16 additions & 1 deletion Tests/arcadia/arcadia_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@

;; ------------------------------------------------------------


(at/deftest scene-graph-system t
(as-sub-closing [t "GameObject traversal"]
(with-temp-objects :lit [x y z]
Expand Down Expand Up @@ -568,6 +569,17 @@
;; core-namespace

(at/deftest core-namespace t
(as-sub-closing [t "null->nil"]
(with-temp-objects :lit [obj]
(t (at/is (= obj (ac/null->nil obj))
"non-destroyed object null->nil value is original object")))
(with-temp-objects :lit [obj]
(ac/destroy-immediate obj)
(t (at/is (= nil (ac/null->nil obj))
"destroyed object null->nil value is nil")))
(t
(at/is (= :not-a-unity-object (ac/null->nil :not-a-unity-object)))
(at/is (= nil (ac/null->nil nil)))))
(as-sub-closing [t "instantiate"]
(with-temp-objects :lit [original]
(let [position (al/v3 (rand) (rand) (rand))
Expand All @@ -592,7 +604,10 @@
"3-ary instantiate uses new position"))
(t (at/is (= (.. clone-2 transform rotation)
rotation)
"3-ary instantiate uses new rotation"))))))
"3-ary instantiate uses new rotation"))))))

;; ------------------------------------------------------------


;; ------------------------------------------------------------
;; linear-namespace
Expand Down

0 comments on commit c848606

Please sign in to comment.