Skip to content

Commit

Permalink
Make it work in Cursive
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiesardo committed Apr 19, 2016
1 parent 64219ec commit 75595b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.boot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(set-env!
:resource-paths #{"src"}
:resource-paths #{"src/java" "src/clojure"}
:dependencies
'[[org.clojure/clojure "1.7.0"]
[com.google.auto.value/auto-value "1.2-rc1"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,21 @@ final class {{& class-name}} extends {{& class-to-extend}} {
}")

(defn- ->prop [[k v :as prop]]
{:name k
{:name k
:cast-type (.toString (.getReturnType v))})

(defn- add-last? [props]
(assoc-in props [(dec (count props)) :last?] true))
(cond-> props
(not-empty props) (assoc-in [(dec (count props)) :last?] true)))

(defn- generate [skeleton]
(mustache/render-string template skeleton))

(defn process [context class-name class-to-extend final?]
(let [skeleton {:package (.packageName context)
:class-name class-name
(let [skeleton {:package (.packageName context)
:class-name class-name
:class-to-extend class-to-extend
:props (->> (.properties context)
(mapv ->prop)
(add-last?))}]
:props (->> (.properties context)
(mapv ->prop)
(add-last?))}]
(generate skeleton)))
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class AutoParcelExtension extends AutoValueExtension {

private static IFn PROCESS;

static {
loadClojureFn();
}

private static void loadClojureFn() {
ClassLoader previous = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(AutoParcelExtension.class.getClassLoader());
Expand All @@ -29,11 +33,6 @@ private static void loadClojureFn() {
}
}

static {
loadClojureFn();
}


@Override
public boolean applicable(Context context) {
TypeElement parcelable = context.processingEnvironment().getElementUtils().getTypeElement("android.os.Parcelable");
Expand Down

0 comments on commit 75595b0

Please sign in to comment.