Make is-pressed? work with all keys

This commit is contained in:
oakes
2014-01-09 22:46:57 -05:00
parent 9bb4f0a1e4
commit f631626060
4 changed files with 34 additions and 39 deletions

View File

@@ -2,7 +2,7 @@
(:require [clojure.string :as s])
(:import [com.badlogic.gdx.utils Array]))
(def ^:const gdx-package "com.badlogic.gdx.")
(def ^:const gdx-package "com.badlogic.gdx")
(defn- split-key
[key]
@@ -10,14 +10,35 @@
(defn- join-keys
[keys]
(->> keys (map name) (s/join ".") (str gdx-package)))
(->> keys (map name) (s/join ".") (str gdx-package ".")))
(defn key->static-field
[key]
(->> (split-key key)
(map s/upper-case)
(s/join "_")
symbol))
(defn key->class
[key]
(->> (split-key key)
(map s/capitalize)
(s/join "")
symbol))
(defn key->method
[key]
(let [parts (split-key key)]
(->> (rest parts)
(map s/capitalize)
(cons (first parts))
(s/join "")
(str ".")
symbol)))
(defn gdx-static-field*
[args]
(->> (last args)
split-key
(map s/upper-case)
(s/join "_")
(->> (key->static-field (last args))
(str (join-keys (butlast args)) "/")
symbol))
@@ -29,23 +50,6 @@
[a]
(Array. true (into-array a) 1 (count a)))
(defn key->class
[k]
(->> (split-key k)
(map s/capitalize)
(s/join "")
symbol))
(defn key->method
[k]
(let [parts (split-key k)]
(->> (rest parts)
(map s/capitalize)
(cons (first parts))
(s/join "")
(str ".")
symbol)))
(defmacro call!
[obj k & args]
`(~(key->method k) ~obj ~@args))