Skip to content

Commit

Permalink
Unwrapping: clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Sep 20, 2024
1 parent 47067a1 commit 2795982
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/client/eliom_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//Provides: caml_unwrap_value_from_string
//Requires: caml_failwith, caml_marshal_constants
//Requires: caml_int64_float_of_bits, caml_int64_of_bytes, caml_new_string
//Requires: caml_jsbytes_of_string
//Requires: caml_jsbytes_of_string, caml_callback
var caml_unwrap_value_from_string = function (){
function StringReader (s, i) { this.s = caml_jsbytes_of_string(s); this.i = i; }
StringReader.prototype = {
Expand Down Expand Up @@ -222,7 +222,7 @@ var caml_unwrap_value_from_string = function (){
if (v[0] === 0 && size >= 2 &&
v[size] instanceof Array && v[size].length == 3 &&
v[size][2] === intern_obj_table[2] /*unwrap_mark*/) {
var unwrapped_v = apply_unwrapper(v[size], v);
var unwrapped_v = caml_callback(apply_unwrapper, [v[size], v]);
if (unwrapped_v === 0) {
// No unwrapper is registered, so replace the unwrap
// marker v[size] by a late_unwrap marker
Expand Down
7 changes: 4 additions & 3 deletions src/lib/eliom_unwrap.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ let apply_unwrapper unwrapper v =
let late_unwrap_value old_value new_value =
let old_value = Obj.repr old_value in
List.iter
(fun {parent; field} -> Js.Unsafe.set parent field new_value)
(fun {parent; field} ->
Obj.set_field parent (field - 1) (Obj.repr new_value))
(Obj.obj (Obj.field (Obj.field old_value (Obj.size old_value - 1)) 2))

external raw_unmarshal_and_unwrap :
(unit, unwrapper -> _ -> _ option) Js.meth_callback
(unwrapper -> _ -> _ option)
-> string
-> int
-> _
Expand All @@ -85,7 +86,7 @@ external raw_unmarshal_and_unwrap :
let unwrap s i =
if !Eliom_config.debug_timings
then Firebug.console ## (time (Js.string "unwrap"));
let res = raw_unmarshal_and_unwrap (Js.wrap_callback apply_unwrapper) s i in
let res = raw_unmarshal_and_unwrap apply_unwrapper s i in
if !Eliom_config.debug_timings
then Firebug.console ## (timeEnd (Js.string "unwrap"));
res
Expand Down

0 comments on commit 2795982

Please sign in to comment.