mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 12:23:23 +08:00
[ocaml] use Array.make instaed of Array.create
using create has been deprecated for a long time, and make is available at least since ocaml 3.12
This commit is contained in:
@@ -39,7 +39,7 @@ let arc = fun n r start stop ->
|
|||||||
|
|
||||||
let floats_of_points = fun ps ->
|
let floats_of_points = fun ps ->
|
||||||
let n = Array.length ps in
|
let n = Array.length ps in
|
||||||
let a = Array.create (2*n) 0. in
|
let a = Array.make (2*n) 0. in
|
||||||
for i = 0 to n - 1 do
|
for i = 0 to n - 1 do
|
||||||
let (x, y) = ps.(i) in
|
let (x, y) = ps.(i) in
|
||||||
a.(2*i)<-x;
|
a.(2*i)<-x;
|
||||||
@@ -56,7 +56,7 @@ let ruler = fun ?(index_on_right=false) ~text_props ~max ~scale ~w ~index_width
|
|||||||
let props = (text_props@[`ANCHOR `EAST]) in
|
let props = (text_props@[`ANCHOR `EAST]) in
|
||||||
|
|
||||||
(* One step drawer *)
|
(* One step drawer *)
|
||||||
let tab = Array.create (max/step) false in
|
let tab = Array.make (max/step) false in
|
||||||
let draw = fun i ->
|
let draw = fun i ->
|
||||||
let i = i * step in
|
let i = i * step in
|
||||||
let y = -. scale *. float i in
|
let y = -. scale *. float i in
|
||||||
|
|||||||
@@ -1339,7 +1339,7 @@ let get_svsinfo = fun alarm _sender vs ->
|
|||||||
and flagss = Str.split list_separator (Pprz.string_assoc "flags" vs)
|
and flagss = Str.split list_separator (Pprz.string_assoc "flags" vs)
|
||||||
and ages = Str.split list_separator (Pprz.string_assoc "msg_age" vs) in
|
and ages = Str.split list_separator (Pprz.string_assoc "msg_age" vs) in
|
||||||
|
|
||||||
let a = Array.create (List.length svids) (0,0,0,0) in
|
let a = Array.make (List.length svids) (0,0,0,0) in
|
||||||
let rec loop = fun i s c f ages ->
|
let rec loop = fun i s c f ages ->
|
||||||
match (s, c, f, ages) with
|
match (s, c, f, ages) with
|
||||||
[], [], [], [] -> ()
|
[], [], [], [] -> ()
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ end
|
|||||||
class vgauge = fun ?(color="#00ff00") ?(history_len=50) gauge_da v_min v_max ->
|
class vgauge = fun ?(color="#00ff00") ?(history_len=50) gauge_da v_min v_max ->
|
||||||
object (self)
|
object (self)
|
||||||
inherit gauge gauge_da
|
inherit gauge gauge_da
|
||||||
val history = Array.create history_len 0
|
val history = Array.make history_len 0
|
||||||
val mutable history_index = -1
|
val mutable history_index = -1
|
||||||
method set = fun ?arrow ?(background="orange") value strings ->
|
method set = fun ?arrow ?(background="orange") value strings ->
|
||||||
let {Gtk.width=width; height=height} = gauge_da#misc#allocation in
|
let {Gtk.width=width; height=height} = gauge_da#misc#allocation in
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ let new_aircraft = fun id name fp airframe ->
|
|||||||
cam = { phi = 0.; theta = 0. ; target=(0.,0.)};
|
cam = { phi = 0.; theta = 0. ; target=(0.,0.)};
|
||||||
fbw = { rc_status = "???"; rc_mode = "???"; rc_rate=0; pprz_mode_msgs_since_last_fbw_status_msg=0 };
|
fbw = { rc_status = "???"; rc_mode = "???"; rc_rate=0; pprz_mode_msgs_since_last_fbw_status_msg=0 };
|
||||||
svinfo = svsinfo_init;
|
svinfo = svsinfo_init;
|
||||||
dl_setting_values = Array.create max_nb_dl_setting_values None;
|
dl_setting_values = Array.make max_nb_dl_setting_values None;
|
||||||
nb_dl_setting_values = 0;
|
nb_dl_setting_values = 0;
|
||||||
horiz_mode = UnknownHorizMode;
|
horiz_mode = UnknownHorizMode;
|
||||||
horizontal_mode = 0;
|
horizontal_mode = 0;
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ module XB = struct (** XBee module *)
|
|||||||
false))
|
false))
|
||||||
|
|
||||||
(* Array of sent packets for retry: (packet, nb of retries) *)
|
(* Array of sent packets for retry: (packet, nb of retries) *)
|
||||||
let packets = Array.create 256 ("", -1)
|
let packets = Array.make 256 ("", -1)
|
||||||
|
|
||||||
(* Frame id generation > 0 and < 256 *)
|
(* Frame id generation > 0 and < 256 *)
|
||||||
let gen_frame_id =
|
let gen_frame_id =
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ type wind_ac = {
|
|||||||
let h = Hashtbl.create 17
|
let h = Hashtbl.create 17
|
||||||
|
|
||||||
let create_wind_ac max_nb_sample =
|
let create_wind_ac max_nb_sample =
|
||||||
{speeds = Array.create max_nb_sample None ; wind_init = null_vector; index = 0; length = 0}
|
{speeds = Array.make max_nb_sample None ; wind_init = null_vector; index = 0; length = 0}
|
||||||
|
|
||||||
let new_ac = fun id max_nb_sample ->
|
let new_ac = fun id max_nb_sample ->
|
||||||
Hashtbl.add h id (create_wind_ac max_nb_sample)
|
Hashtbl.add h id (create_wind_ac max_nb_sample)
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ let in_tesselation_fans l =
|
|||||||
add_val p1; add_val p2; add_val p3) l ;
|
add_val p1; add_val p2; add_val p3) l ;
|
||||||
let lst = List.fast_sort (fun (_, n1) (_, n2) -> n2-n1) (Array.to_list tt) in
|
let lst = List.fast_sort (fun (_, n1) (_, n2) -> n2-n1) (Array.to_list tt) in
|
||||||
|
|
||||||
let tt2 = Array.create (Array.length tt) (0, []) in
|
let tt2 = Array.make (Array.length tt) (0, []) in
|
||||||
let i = ref 0 in
|
let i = ref 0 in
|
||||||
List.iter (fun (x, _) -> tt2.(x) <- (!i, []); incr i) lst ;
|
List.iter (fun (x, _) -> tt2.(x) <- (!i, []); incr i) lst ;
|
||||||
List.iter (fun (p1, p2, p3) ->
|
List.iter (fun (p1, p2, p3) ->
|
||||||
|
|||||||
@@ -733,8 +733,8 @@ class widget = fun ?(height=800) ?(srtm=false) ?width ?projection ?georef () ->
|
|||||||
LL.utm_zone = u0.LL.utm_zone;
|
LL.utm_zone = u0.LL.utm_zone;
|
||||||
LL.utm_y = align u0.LL.utm_y 1000 } in
|
LL.utm_y = align u0.LL.utm_y 1000 } in
|
||||||
for i = -size_utm_grid to size_utm_grid do
|
for i = -size_utm_grid to size_utm_grid do
|
||||||
let h = Array.create (2*(2*size_utm_grid+1)) 0.
|
let h = Array.make (2*(2*size_utm_grid+1)) 0.
|
||||||
and v = Array.create (2*(2*size_utm_grid+1)) 0. in
|
and v = Array.make (2*(2*size_utm_grid+1)) 0. in
|
||||||
for j = -size_utm_grid to size_utm_grid do
|
for j = -size_utm_grid to size_utm_grid do
|
||||||
let k = 2*(j+size_utm_grid) in
|
let k = 2*(j+size_utm_grid) in
|
||||||
let p = fun i j ->
|
let p = fun i j ->
|
||||||
|
|||||||
@@ -236,11 +236,11 @@ class flight_plan = fun ?format_attribs ?editable ~show_moved geomap color fp_dt
|
|||||||
(** The graphical waypoints *)
|
(** The graphical waypoints *)
|
||||||
let wpts_group = new MapWaypoints.group ~show_moved ~color ?editable geomap in
|
let wpts_group = new MapWaypoints.group ~show_moved ~color ?editable geomap in
|
||||||
|
|
||||||
let array_of_waypoints = ref (Array.create 13 None) in
|
let array_of_waypoints = ref (Array.make 13 None) in
|
||||||
let add_wp_to_array = fun index w ->
|
let add_wp_to_array = fun index w ->
|
||||||
let n = Array.length !array_of_waypoints in
|
let n = Array.length !array_of_waypoints in
|
||||||
if index >= n then begin
|
if index >= n then begin
|
||||||
let new_array = Array.create (n*2) None in
|
let new_array = Array.make (n*2) None in
|
||||||
Array.blit !array_of_waypoints 0 new_array 0 n;
|
Array.blit !array_of_waypoints 0 new_array 0 n;
|
||||||
array_of_waypoints := new_array
|
array_of_waypoints := new_array
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type tiles_tree =
|
|||||||
Empty
|
Empty
|
||||||
| Tile
|
| Tile
|
||||||
| Node of tiles_tree array
|
| Node of tiles_tree array
|
||||||
let gm_tiles = Node (Array.create 4 Empty)
|
let gm_tiles = Node (Array.make 4 Empty)
|
||||||
|
|
||||||
(** Google Maps paths in the quadtree are coded with q,r,s and t*)
|
(** Google Maps paths in the quadtree are coded with q,r,s and t*)
|
||||||
let index_of = function
|
let index_of = function
|
||||||
@@ -61,7 +61,7 @@ let add_tile = fun tile_key ->
|
|||||||
if i < String.length tile_key then
|
if i < String.length tile_key then
|
||||||
match tree.(j) with
|
match tree.(j) with
|
||||||
Empty ->
|
Empty ->
|
||||||
let sons = Array.create 4 Empty in
|
let sons = Array.make 4 Empty in
|
||||||
tree.(j) <- Node sons;
|
tree.(j) <- Node sons;
|
||||||
loop (i+1) sons (index_of tile_key.[i])
|
loop (i+1) sons (index_of tile_key.[i])
|
||||||
| Tile -> () (* Already there *)
|
| Tile -> () (* Already there *)
|
||||||
@@ -142,7 +142,7 @@ let fill_window = fun (geomap:MapCanvas.widget) zoomlevel ->
|
|||||||
display_the_tile geomap tile image level;
|
display_the_tile geomap tile image level;
|
||||||
raise (New_displayed (zoomlevel+1-String.length tile.Gm.key))
|
raise (New_displayed (zoomlevel+1-String.length tile.Gm.key))
|
||||||
else begin
|
else begin
|
||||||
trees.(i) <- Node (Array.create 4 Empty);
|
trees.(i) <- Node (Array.make 4 Empty);
|
||||||
loop twest tsouth tsize trees i zoom key
|
loop twest tsouth tsize trees i zoom key
|
||||||
end
|
end
|
||||||
| Node sons ->
|
| Node sons ->
|
||||||
|
|||||||
@@ -107,10 +107,10 @@ class track = fun ?(name="Noname") ?(icon="fixedwing") ?(size = 500) ?(color="re
|
|||||||
object (self)
|
object (self)
|
||||||
val mutable top = 0
|
val mutable top = 0
|
||||||
val mutable color = color
|
val mutable color = color
|
||||||
val mutable segments = Array.create size empty
|
val mutable segments = Array.make size empty
|
||||||
val mutable v_segments = Array.create size empty
|
val mutable v_segments = Array.make size empty
|
||||||
val mutable v_top = 0
|
val mutable v_top = 0
|
||||||
val mutable v_path = Array.create 10 v_empty
|
val mutable v_path = Array.make 10 v_empty
|
||||||
val mutable last = None
|
val mutable last = None
|
||||||
val mutable last_heading = 0.0
|
val mutable last_heading = 0.0
|
||||||
val mutable last_altitude = 0.0
|
val mutable last_altitude = 0.0
|
||||||
@@ -319,7 +319,7 @@ object (self)
|
|||||||
aircraft#affine_absolute a
|
aircraft#affine_absolute a
|
||||||
|
|
||||||
method resize = fun new_size ->
|
method resize = fun new_size ->
|
||||||
let a = Array.create new_size empty in
|
let a = Array.make new_size empty in
|
||||||
let size = Array.length segments in
|
let size = Array.length segments in
|
||||||
let m = min new_size size in
|
let m = min new_size size in
|
||||||
let j = ref ((top - m + size) mod size) in
|
let j = ref ((top - m + size) mod size) in
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ let make_1st_order_noise_generator = fun ?(init = 0.) k sigma ->
|
|||||||
!x
|
!x
|
||||||
|
|
||||||
let shifter = fun n default ->
|
let shifter = fun n default ->
|
||||||
let a = Array.create n default
|
let a = Array.make n default
|
||||||
and i = ref 0 in
|
and i = ref 0 in
|
||||||
fun new_value ->
|
fun new_value ->
|
||||||
let old_value = a.(!i) in
|
let old_value = a.(!i) in
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
let flatten = fun s a ->
|
let flatten = fun s a ->
|
||||||
let n = Array.length a in
|
let n = Array.length a in
|
||||||
let b = Array.create (2*n) 0. in
|
let b = Array.make (2*n) 0. in
|
||||||
for i = 0 to n - 1 do
|
for i = 0 to n - 1 do
|
||||||
let (x, y) = a.(i) in
|
let (x, y) = a.(i) in
|
||||||
b.(2*i) <- float x *. s;
|
b.(2*i) <- float x *. s;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ type values = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let create_values = fun size color ->
|
let create_values = fun size color ->
|
||||||
{ array = Array.create size None; index = 0; color = color;
|
{ array = Array.make size None; index = 0; color = color;
|
||||||
average = GData.adjustment ~value:0. (); discrete = false;
|
average = GData.adjustment ~value:0. (); discrete = false;
|
||||||
stdev = GData.adjustment ~value:0. ()}
|
stdev = GData.adjustment ~value:0. ()}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ class plot = fun ~size ~update_time ~width ~height ~packing () ->
|
|||||||
method set_size = fun new_size ->
|
method set_size = fun new_size ->
|
||||||
if new_size <> size && new_size > 0 then begin
|
if new_size <> size && new_size > 0 then begin
|
||||||
Hashtbl.iter (fun _ a ->
|
Hashtbl.iter (fun _ a ->
|
||||||
let new_array = Array.create new_size None in
|
let new_array = Array.make new_size None in
|
||||||
for i = 0 to Pervasives.min size new_size - 1 do
|
for i = 0 to Pervasives.min size new_size - 1 do
|
||||||
new_array.(new_size - 1 - i) <- a.array.((a.index-i+size) mod size)
|
new_array.(new_size - 1 - i) <- a.array.((a.index-i+size) mod size)
|
||||||
done;
|
done;
|
||||||
|
|||||||
+1
-1
@@ -140,7 +140,7 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct
|
|||||||
|
|
||||||
let _reset = fun () -> state := initial_state in
|
let _reset = fun () -> state := initial_state in
|
||||||
|
|
||||||
let commands = Array.create FM.nb_commands 0 in
|
let commands = Array.make FM.nb_commands 0 in
|
||||||
|
|
||||||
Aircraft.commands commands;
|
Aircraft.commands commands;
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ module Syntax = struct
|
|||||||
{ id = id; name = name; fields = fields }
|
{ id = id; name = name; fields = fields }
|
||||||
|
|
||||||
let check_single_ids = fun msgs ->
|
let check_single_ids = fun msgs ->
|
||||||
let tab = Array.create 256 false (* TODO remove limitation to 256 msg not needed here *)
|
let tab = Array.make 256 false (* TODO remove limitation to 256 msg not needed here *)
|
||||||
and last_id = ref 0 in
|
and last_id = ref 0 in
|
||||||
List.iter (fun msg ->
|
List.iter (fun msg ->
|
||||||
if tab.(msg.id) then
|
if tab.(msg.id) then
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ module Syntax = struct
|
|||||||
{ id=id; name = name; period = period; fields = fields }
|
{ id=id; name = name; period = period; fields = fields }
|
||||||
|
|
||||||
let check_single_ids = fun msgs ->
|
let check_single_ids = fun msgs ->
|
||||||
let tab = Array.create 256 false
|
let tab = Array.make 256 false
|
||||||
and last_id = ref 0 in
|
and last_id = ref 0 in
|
||||||
List.iter (fun msg ->
|
List.iter (fun msg ->
|
||||||
if tab.(msg.id) then
|
if tab.(msg.id) then
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ module Syntax = struct
|
|||||||
{ id=id; name = name; period = period; fields = fields }
|
{ id=id; name = name; period = period; fields = fields }
|
||||||
|
|
||||||
let check_single_ids = fun msgs ->
|
let check_single_ids = fun msgs ->
|
||||||
let tab = Array.create 256 false
|
let tab = Array.make 256 false
|
||||||
and last_id = ref 0 in
|
and last_id = ref 0 in
|
||||||
List.iter (fun msg ->
|
List.iter (fun msg ->
|
||||||
if tab.(msg.id) then
|
if tab.(msg.id) then
|
||||||
|
|||||||
Reference in New Issue
Block a user