Commit 6ecf231b authored by Benoit Barbot's avatar Benoit Barbot

fix pb int_buff

parent b2257a1e
Pipeline #1783 passed with stage
in 29 seconds
......@@ -3,6 +3,9 @@ all:
ocamlbuild -use-ocamlfind ta_editor.byte
js_of_ocaml --no-inline ta_editor.byte -o website/ta_editor.js
server: all
cd website; python2.7 -m SimpleHTTPServer
clean:
ocamlbuild -clean
rm -rf ta_editor.byte website/ta_editor.js
......@@ -23,7 +23,7 @@ module Cosmosweb_app =
]
let canvas_elt =
canvas ~a:[a_width width; a_height height]
canvas ~a:[a_style "background-color: lightslategray; background-image: url(img/grid2.svg) "; a_width width; a_height height]
[txt "your browser doesn't support canvas"]
let attribute_list_div =
......
......@@ -114,7 +114,8 @@ module S (P:PREGRAPH) =
let _,(_,p) = Data.acca graph.state n in
p:= pos
let new_node graph _ pos =
let new_node graph _ ((a,b) as pos) =
Printf.printf "new node: %f; %f\n" a b;
let s = Data.addk ((),(ref (P.init_state ()), ref pos )) graph.state in
`State (s)
let get_new_node_choice graph =
......
......@@ -20,26 +20,31 @@ let print_buff s =
Printf.printf "[%i]" i
) s
;;
(1 lsl 10);;
let buff_int b i =
if i>=0 && i< 32 then add_char b (b64_of_ui i)
else if i>=0 && i< (1 lsl 10) then (
let i1 = i/32 + 32
and i2 = i mod 32 in
add_char b (b64_of_ui i1);
add_char b (b64_of_ui i2);
let i1 = i/32 + 32
and i2 = i mod 32 in
add_char b (b64_of_ui i1);
add_char b (b64_of_ui i2);
) else
let r = max 2 (int_of_float ((log @@ float @@ abs @@ i) /. log 2.0) / 5) in
let r = max 2 ((int_of_float ((log @@ float @@ abs @@ i) /. log 2.0)+1) / 5) in
(*Printf.printf "r:%i " r;*)
add_char b (b64_of_ui (32 + (if i<0 then 16 else 0) + ((abs i) lsr (r*5))));
let j = ref ((abs i) mod (1 lsl (5*r))) in
let r2 = ref (r*5) in
while !r2 > 0 do
(*print_string ((string_of_int !r2)^":");
(* print_string ((string_of_int !r2)^":");
print_endline (string_of_int !j);*)
r2:= !r2-5;
add_char b (b64_of_ui ((if !r2>0 then 32 else 0) + (!j lsr !r2)));
j:= !j mod (1 lsl !r2);
done
let int_buff s pos =
let r = ref 0 in
while ui_of_b64 s.[pos+ !r] >= 32 do incr r done;
......@@ -89,24 +94,31 @@ let check i =
let p1,i1= int_buff str 0 in
if i<>i1 then (
print_buff str;
print_endline (string_of_int i);
print_string ((string_of_int i)^":");
print_endline (string_of_int i1);
assert false
);;
let _ =
let i = ref 0 in
while true do
let i = ref (-1025) in
while !i < 10000000 do
check !i;
incr i;
done;;
check (10000)
check 1023;;
check 1024;;
check (16383);;
check 16384;;
*)
(*
let _ =
let t = Buffer.create 100 in
for i = -1025 to 1020 do
buff_int t i;
for i = 16300 to 17000 do
buff_int t (i);
done;
let str = (Bytes.to_string @@ Buffer.to_bytes t) in
print_buff str;
......@@ -115,8 +127,9 @@ let _ =
while !pos < String.length str do
let p1,i1= int_buff str !pos in
pos := p1;
print_endline (string_of_int i1);
done*)
print_string ((string_of_int i1)^"\t");
done
*)
let buff_string b str =
let n = String.length str in
......
......@@ -118,7 +118,7 @@ let text_input ?(class_ = "") ?(on_change = fun _ -> true) ?(_type="text") value
let update_link n f =
let link = Dom_html.(createA document) in
append_node link (txt n);
let currref = Js.to_string Dom_html.window##.location##.href in
let currref = Js.to_string Dom_html.window##.location##.pathname in
link##.onmouseover:= Dom.handler (fun _ ->
let string_value = f currref in
link##.href := Js.string string_value;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment