This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function registerOnLoad(fn) { | |
| var prev = window.onload; | |
| window.onload = !prev ? fn : function() { | |
| var prevResult = prev(); | |
| return prevResult instanceof Promise ? prevResult.then(fn) : fn(); | |
| }; | |
| } | |
| if (!this['Proxy']) { | |
| var PolyfillProxy = function(target, handlers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link rel="import" href="../core-icon-button/core-icon-button.html"> | |
| <link rel="import" href="../core-toolbar/core-toolbar.html"> | |
| <link rel="import" href="../core-header-panel/core-header-panel.html"> | |
| <link rel="import" href="../paper-tabs/paper-tabs.html"> | |
| <link rel="import" href="../paper-tabs/paper-tab.html"> | |
| <link rel="import" href="../chart-js/chart-js.html"> | |
| <link rel="import" href="../ace-element/ace-element.html"> | |
| <link rel="import" href="../core-scaffold/core-scaffold.html"> | |
| <link rel="import" href="../core-menu/core-menu.html"> | |
| <link rel="import" href="../core-item/core-item.html"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.nativelibs4java.opencl.*; | |
| import org.bridj.*; | |
| import static org.bridj.Pointer.*; | |
| /* | |
| Put these lines in `build.sbt`, and run with `sbt ~run`: | |
| fork := true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @scalaxy.extension[Any] | |
| def quoted(quote: String): String = macro { | |
| // `c` is defined as the macro Context. | |
| // `quote` and `self` are in scope, defined as `c.Expr[Any]` and `c.Expr[String]`. | |
| println(s"Currently expanding ${c.prefix}.quoted(${quote.tree})") | |
| // `c.universe._` is automatically imported, so `reify` is in scope. | |
| reify({ | |
| // Make sure we're not evaluating quote twice, in case it's a complex expression! | |
| val q = quote.splice | |
| q + self.splice + q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @scalaxy.extension[Any] | |
| def quoted(quote: String) = quote + self + quote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @extend(Any) def quoted(quote: String) = quote + self + quote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implicit def Extensions(self: Any) = new Extensions(self) | |
| class Extensions(self: Any) { | |
| def quoted(quote: String) = quote + self + quote | |
| } | |
| println(10.quoted("'")) // prints "'10'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implicit class Extensions(self: Any) { | |
| def quoted(quote: String) = quote + self + quote | |
| } | |
| println(10.quoted("'")) // prints "'10'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Absolutely need to annotate return type! | |
| @extend(URL) def secure: URL = macro | |
| reify(new URL(s"https://${self.splice.getHost}${self.splice.getPath}")) | |
| // Gets desugared to: | |
| import scala.language.experimental.macros | |
| import scala.reflect.macros.Context | |
| implicit class secure(self: URL) { | |
| def secure = macro secureImpl.secureImpl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| replace( | |
| { | |
| // $vparamss($x) are special variables that capture all parameter groups. | |
| // $vparams($x) would only capture one group | |
| @extend($type) def $someMethod($vparamss: $) = $body | |
| }, | |
| { | |
| implicit class $someMethod(self: $type) extends AnyRef { | |
| def $someMethod($vparamss: $) = $body | |
| // $fresh$x is a special variable that picks a fresh name with fresh("x") |