|
133 | 133 | (if (and (= (count opname) 1)
|
134 | 134 | (Character/isDigit ^Character (first opname)))
|
135 | 135 | form ;; Array/<n>
|
136 |
| - (if (or (.startsWith opname ".") |
137 |
| - (let [members (u/members target)] |
138 |
| - ;; TODO: only pick non-methods! |
139 |
| - (some #(when (and (= opname-sym (:name %)) |
140 |
| - (not (instance? clojure.reflect.Field %))) |
141 |
| - %) members))) |
| 136 | + (cond |
| 137 | + (= "new" opname) |
| 138 | + `(fn |
| 139 | + ([x#] (new ~(symbol sym-ns) x#)) |
| 140 | + ;; TODO: analyze method and return properly expanded fn |
| 141 | + ) |
| 142 | + (or (.startsWith opname ".") |
| 143 | + (let [members (u/members target)] |
| 144 | + ;; TODO: only pick non-methods! |
| 145 | + (some #(when (and (= opname-sym (:name %)) |
| 146 | + (not (instance? clojure.reflect.Field %))) |
| 147 | + %) members))) |
142 | 148 | `(fn
|
143 | 149 | ([x#] (~form x#))
|
144 | 150 | ;; TODO: analyze method and return properly expanded fn
|
145 | 151 | )
|
| 152 | + :else |
146 | 153 | (with-meta (list '. target (symbol (str "-" opname))) ;; transform to (. Class -field)
|
147 | 154 | (meta form)))))
|
148 | 155 | form)))
|
|
158 | 165 | (when-not (.startsWith opname ".")
|
159 | 166 | opns-class))] ; (class/field ..)
|
160 | 167 | (let [op (symbol opname)]
|
161 |
| - (with-meta (list '. target (if (zero? (count expr)) |
162 |
| - op |
163 |
| - (list* op expr))) |
164 |
| - (meta form))) |
| 168 | + (if (= 'new op) |
| 169 | + (with-meta (list* 'new (symbol opns) expr) |
| 170 | + (meta form)) |
| 171 | + (with-meta (list '. target (if (zero? (count expr)) |
| 172 | + op |
| 173 | + (list* op expr))) |
| 174 | + (meta form)))) |
165 | 175 |
|
166 | 176 | (cond
|
167 | 177 | (.startsWith opname ".") ; (.foo bar ..)
|
|
181 | 191 | (.endsWith opname ".") ;; (class. ..)
|
182 | 192 | (with-meta (list* 'new (symbol (subs opname 0 (dec (count opname)))) expr)
|
183 | 193 | (meta form))
|
184 |
| - |
185 | 194 | :else form)))
|
186 | 195 | form)))
|
187 | 196 |
|
|
659 | 668 | (String/.length x))))
|
660 | 669 |
|
661 | 670 | (macroexpand-1 'clojure.lang.Compiler/LOADER)
|
| 671 | + (macroexpand-1 '(String/new "foo")) |
| 672 | + (macroexpand-1 'String/new) |
662 | 673 | )
|
0 commit comments