nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Enforce namespace rules
[nit.git]
/
contrib
/
pep8analysis
/
src
/
pep8analysis_web.nit
diff --git
a/contrib/pep8analysis/src/pep8analysis_web.nit
b/contrib/pep8analysis/src/pep8analysis_web.nit
index
7e72e89
..
dacc9ff
100644
(file)
--- a/
contrib/pep8analysis/src/pep8analysis_web.nit
+++ b/
contrib/pep8analysis/src/pep8analysis_web.nit
@@
-19,7
+19,10
@@
# Takes the entire Pep/8 source code as argument and prints out the
# analysis results. The result graph will be sent to the JavaScript function
# `show_graph` with the source of the graph in Graphviz's dot.
# Takes the entire Pep/8 source code as argument and prints out the
# analysis results. The result graph will be sent to the JavaScript function
# `show_graph` with the source of the graph in Graphviz's dot.
-module pep8analysis_web
+module pep8analysis_web is
+ cpp_compiler_option("--std=c++11 --bind")
+ c_linker_option("--bind")
+end
import emscripten
import emscripten
@@
-28,10
+31,22
@@
import ast
import model
import cfg
import flow_analysis
import model
import cfg
import flow_analysis
+intrude import standard::stream
+import cpp
+
+in "C++" `{
+ #include <bind.h>
+
+ using namespace emscripten;
+
+ EMSCRIPTEN_BINDINGS(my_module) {
+ function("run_analysis", &NativeString_run_analysis, allow_raw_pointers());
+ }
+`}
redef class AnalysisManager
redef class AnalysisManager
- fun run(src: String)
+ fun run_web(src: String)
do
sys.suggest_garbage_collection
do
sys.suggest_garbage_collection
@@
-93,14
+108,11
@@
redef class AnalysisManager
fun show_graph(content: String) do "show_graph('{content.escape_to_c}');".run_js
end
fun show_graph(content: String) do "show_graph('{content.escape_to_c}');".run_js
end
-class StringIStream
- super BufferedIStream
-
- init(str: String) do _buffer = new FlatBuffer.from(str)
-
- redef fun fill_buffer do end_reached = true
- redef var end_reached: Bool = false
+redef class NativeString
+ fun run_analysis do manager.run_web to_s
end
end
+fun dummy_set_callbacks import NativeString.run_analysis in "C++" `{
+`}
-manager.run args.first
+dummy_set_callbacks