From d971a873916489e6619b758abd1d1c8370a2dbec Mon Sep 17 00:00:00 2001 From: "dziltener@lyrion.ch" Date: Wed, 11 Jan 2017 18:02:45 +0000 Subject: [PATCH] Prepararory changes for Reflection. --- src/clojurefx/factory.clj | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/clojurefx/factory.clj b/src/clojurefx/factory.clj index 57596d8..c99f2d6 100644 --- a/src/clojurefx/factory.clj +++ b/src/clojurefx/factory.clj @@ -1,10 +1,12 @@ (ns clojurefx.factory (:require [taoensso.timbre :as timbre] [clojure.java.io :as io] + [clojure.reflect :as reflect] [clojurefx.clojurefx :as fx] [clojurefx.protocols :refer :all]) (:import (javafx.scene Scene Node Parent) - (javafx.scene.layout Region))) + (javafx.scene.layout Region) + (clojure.reflect Constructor))) (timbre/refer-timbre) @@ -60,8 +62,17 @@ })) (def constructor-args - (atom {javafx.scene.Scene [:root] - javafx.stage.Stage [:style]})) + (atom {javafx.scene.Scene [(with-meta :root {:type javafx.scene.Parent})] + javafx.stage.Stage [(with-meta :style {:type javafx.stage.StageStyle})]})) + +(defn find-constructor [clazz cargs] + (->> (reflect/reflect clazz) + (filter #(= Constructor (class %))) + (map :parameter-types) + (filter #(= cargs %)) + first)) + + (declare compile-o-matic) (defn apply-props-to-node [node props]