Great way to make the Android API more Scala friendly. Love it!

Am Mittwoch, 27. Mai 2015 22:55:45 UTC+2 schrieb pfn:
>
> I just published a new library that automatically creates all implicit 
> conversions and extension functions for the Android SDK.
>
> The gist:
>
> It iterates android.jar to find all classes with single-abstract-methods. 
> For each of these methods, an implicit conversion is created for a function 
> to the class type. Once all the conversions have been generated, the 
> android.jar is iterated again to find all usages of these classes. For each 
> of these usages which takes these SAM classes as a single argument, an 
> extension function is generated (by removing any prefixed 'set' and 
> suffixed 'Listener') from the name. Any () => A function becomes => A for 
> by-name usage instead.
>
> Implementation:
>
> Mostly using asm and a little bit of java reflection where I got stuck, a 
> little bit of canned buggery where I got stuck even more. The technique 
> should be applicable to any other library used on android to generate 
> simple extensions like these.
>
> What it looks like:
>
> Generated code: https://gist.github.com/pfn/b4dc88b80e846f1fbac1
> github: https://github.com/pfn/android-conversions
>
> Use it from sbt:
>
> libraryDependencies += "com.hanhuy.android" %% "scala-conversions" % "1.0"
>
> Hope this helps anyone that's been wanting something like this.
>

-- 
You received this message because you are subscribed to the Google Groups 
"scala-on-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to scala-on-android+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to