mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 11:37:06 +08:00
[ocaml] support display of formatted string in messages
this should close #796 to display an integer (or array of integer) in HEX, just add format="%x" to the field in messages.xml
This commit is contained in:
@@ -168,10 +168,15 @@ let rec string_of_value = function
|
||||
let magic = fun x -> (Obj.magic x:('a,'b,'c) Pervasives.format)
|
||||
|
||||
|
||||
let formatted_string_of_value = fun format v ->
|
||||
let rec formatted_string_of_value = fun format v ->
|
||||
match v with
|
||||
Float x -> sprintf (magic format) x
|
||||
| v -> string_of_value v
|
||||
| Int x -> sprintf (magic format) x
|
||||
| Float x -> sprintf (magic format) x
|
||||
| Int32 x -> sprintf (magic format) x
|
||||
| Int64 x -> sprintf (magic format) x
|
||||
| Char x -> sprintf (magic format) x
|
||||
| String x -> sprintf (magic format) x
|
||||
| Array a -> "|"^(String.concat separator (Array.to_list (Array.map (formatted_string_of_value format) a)))^"|"
|
||||
|
||||
|
||||
let sizeof = fun f ->
|
||||
|
||||
@@ -63,6 +63,7 @@ val is_fixed_array_type : string -> bool
|
||||
|
||||
val size_of_field : field -> int
|
||||
val string_of_value : value -> string
|
||||
val formatted_string_of_value : 'a -> value -> string
|
||||
val int_of_value : value -> int (* May raise Invalid_argument *)
|
||||
type type_descr = {
|
||||
format : string ;
|
||||
|
||||
Reference in New Issue
Block a user