nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3d471e0
)
emscripten: add general features to lib
author
Alexis Laferrière
<alexis.laf@xymus.net>
Sat, 14 Jun 2014 11:27:48 +0000
(07:27 -0400)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Mon, 16 Jun 2014 16:24:23 +0000
(12:24 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/emscripten.nit
patch
|
blob
|
history
diff --git
a/lib/emscripten.nit
b/lib/emscripten.nit
index
65fe1f4
..
7fc5e76
100644
(file)
--- a/
lib/emscripten.nit
+++ b/
lib/emscripten.nit
@@
-15,3
+15,16
@@
# limitations under the License.
module emscripten is platform
+
+`{
+ #include <emscripten.h>
+`}
+
+redef class String
+ fun run_js do run_js_native(self.escape_to_js.to_cstring)
+ private fun run_js_native(script: NativeString) `{ emscripten_run_script(script); `}
+
+ fun escape_to_js: String do return self.replace('\n', "\\n")
+
+ fun alert do "alert('{self.escape_to_js}')".run_js
+end