From db890c8e6929d0fec0d6421e94a116d343a980a5 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 23 Oct 2022 12:45:32 +0200 Subject: [PATCH 1/2] minor --- src/sci/impl/interop.cljc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/sci/impl/interop.cljc b/src/sci/impl/interop.cljc index 3777631b..e9055157 100644 --- a/src/sci/impl/interop.cljc +++ b/src/sci/impl/interop.cljc @@ -1,10 +1,10 @@ (ns sci.impl.interop {:no-doc true} - #?(:clj (:import [sci.impl Reflector] - [java.lang.reflect Field Modifier])) + #?(:clj (:import + [java.lang.reflect Field Modifier] + [sci.impl Reflector])) (:require #?(:cljs [goog.object :as gobject]) #?(:cljs [clojure.string :as str]) - [sci.impl.vars :as vars] [sci.impl.utils :as utils])) ;; see https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java @@ -17,13 +17,13 @@ ;; gobject/get didn't work here (aget obj field-name)] :clj - [([obj ^Class target-class method] - (let [^Field field (.getField target-class method) - mod (.getModifiers field)] - (if (and (not (Modifier/isStatic mod)) - (Modifier/isPublic mod)) - (.get field obj) - (throw (ex-info (str "Not found or accessible instance field: " method) {})))))])) + [[obj ^Class target-class method] + (let [^Field field (.getField target-class method) + mod (.getModifiers field)] + (if (and (not (Modifier/isStatic mod)) + (Modifier/isPublic mod)) + (.get field obj) + (throw (ex-info (str "Not found or accessible instance field: " method) {}))))])) (defn invoke-instance-method #?@(:cljs [[obj _target-class method-name args] @@ -33,14 +33,14 @@ (js/Reflect.apply method obj (into-array args) #_(js-object-array args)) (throw (js/Error. (str "Could not find instance method: " method-name))))] :clj - [([obj ^Class target-class method args] - (if-not target-class - (Reflector/invokeInstanceMethod obj method (object-array args)) - (let [arg-count (count args) - methods (Reflector/getMethods target-class arg-count method false)] - (if (and (zero? arg-count) (.isEmpty ^java.util.List methods)) - (invoke-instance-field obj target-class method) - (Reflector/invokeMatchingMethod method methods obj (object-array args))))))])) + [[obj ^Class target-class method args] + (if-not target-class + (Reflector/invokeInstanceMethod obj method (object-array args)) + (let [arg-count (count args) + methods (Reflector/getMethods target-class arg-count method false)] + (if (and (zero? arg-count) (.isEmpty ^java.util.List methods)) + (invoke-instance-field obj target-class method) + (Reflector/invokeMatchingMethod method methods obj (object-array args)))))])) (defn get-static-field #?(:clj [[^Class class field-name-sym]] :cljs [[class field-name-sym]]) @@ -69,7 +69,7 @@ (cond (not field) (throw (js/Error. (str "Could not find static method " method-name))) - (clojure.string/ends-with? method-name ".") + (str/ends-with? method-name ".") (invoke-js-constructor field args) :else ;; why is this here?? From eb0044d01af893e613457d5125a2d2ce5523d322 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 23 Oct 2022 13:08:56 +0200 Subject: [PATCH 2/2] remove log --- src/sci/impl/evaluator.cljc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sci/impl/evaluator.cljc b/src/sci/impl/evaluator.cljc index 449d5af3..77bc0514 100644 --- a/src/sci/impl/evaluator.cljc +++ b/src/sci/impl/evaluator.cljc @@ -135,8 +135,7 @@ (let [instance-class-name #?(:clj (.getName ^Class instance-class) :cljs (.-name instance-class)) instance-class-symbol (symbol instance-class-name)] - (get class->opts instance-class-symbol)) - #?(:cljs (.log js/console (str method-str)))) + (get class->opts instance-class-symbol))) ^Class target-class (if allowed? instance-class (when-let [f (:public-class env)] (f instance-expr*)))]