Further adjustments

This commit is contained in:
Daniel Ziltener 2017-11-14 15:36:19 +00:00
parent 8c9f91782b
commit 168b1bce92
1 changed files with 17 additions and 9 deletions

View File

@ -42,10 +42,12 @@
(first (filter #(= class-str (last (str/split (pr-str %) #"\."))) imports))) (first (filter #(= class-str (last (str/split (pr-str %) #"\."))) imports)))
(defn init-class [pkg classname import-classes] (defn init-class [pkg classname import-classes]
(debug (str (str/replace pkg #"\." "/") "/" classname))
(let [cw (new org.objectweb.asm.ClassWriter 0) (let [cw (new org.objectweb.asm.ClassWriter 0)
clazz (.visit cw Opcodes/V1_8 clazz (.visit cw Opcodes/V1_8
(+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER) (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER)
(str pkg "/" classname) (str (str/replace pkg #"\." "/") "/" classname)
nil nil
"java/lang/Object" "java/lang/Object"
nil) nil)
@ -159,13 +161,14 @@
;; (gen-initializer clj-ns clj-fn) ;; (gen-initializer clj-ns clj-fn)
;; "\n}"))) ;; "\n}")))
(defn gen-fx-controller [fxmlzip fxmlpath [clj-ns clj-fn] [pkg classname]] (defn gen-fx-controller #^Byte [fxmlzip fxmlpath [clj-ns clj-fn] [pkg classname]]
(let [fxid-elems (get-fxid-elems fxmlzip) (let [fxid-elems (get-fxid-elems fxmlzip)
handler-fns (get-handler-fns fxmlzip) handler-fns (get-handler-fns fxmlzip)
import-classes (build-imports fxmlpath)] import-classes (build-imports fxmlpath)]
(-> (init-class pkg classname import-classes) (-> (init-class pkg classname import-classes)
(gen-props fxid-elems import-classes) (gen-props fxid-elems import-classes)
(gen-handlers handler-fns clj-ns)))) (gen-handlers handler-fns clj-ns)
.toByteArray)))
;; ;; Plumber ;; ;; Plumber
@ -180,11 +183,16 @@
;; (makeclass pkg classname (gen-fx-controller fxmlzip fxmlpath cljvec)))) ;; (makeclass pkg classname (gen-fx-controller fxmlzip fxmlpath cljvec))))
(defn gen-fx-controller-class [fxmlpath clj-fn] (defn gen-fx-controller-class [fxmlpath clj-fn]
(let [clj-fn (if (symbol? clj-fn) (let [clj-fn ^String (if (symbol? clj-fn)
(str (namespace clj-fn) "/" (name clj-fn)) (str (namespace clj-fn) "/" (name clj-fn))
clj-fn) clj-fn)
fxmlzip (zip-tree-seq (xml/parse (io/input-stream fxmlpath))) fxmlzip (zip-tree-seq (xml/parse (io/input-stream fxmlpath)))
clazz (get-controller-class fxmlzip) clazz (get-controller-class fxmlzip)
[pkg classname] (reverse (map str/reverse (str/split (str/reverse clazz) #"\." 2))) [pkg classname] (reverse (map str/reverse (str/split (str/reverse clazz) #"\." 2)))
cljvec (str/split clj-fn #"/")] cljvec (str/split clj-fn #"/")
(gen-fx-controller fxmlzip fxmlpath cljvec [pkg classname]))) controllerclass #^Byte (gen-fx-controller fxmlzip fxmlpath cljvec [pkg classname])
classloader (.getContextClassLoader (Thread/currentThread))]
(debug "Controllerclass array size is" (count controllerclass) "Byte")
(debug "Controllerclass of class" (str pkg "." classname) "has an array size of" (count controllerclass) "Byte")
(debug (type controllerclass))
(.defineClass classloader (str pkg "." classname) controllerclass 0 (count controllerclass))))