search for: snake2caml

Displaying 20 results from an estimated 22 matches for "snake2caml".

2019 Aug 05
0
[PATCH 1/2] Rust bindings: Add Event structs, Clarify Handle lifetime
...ust.ml index a1735602c..1f5cefa62 100644 --- a/generator/rust.ml +++ b/generator/rust.ml @@ -72,6 +72,42 @@ extern \"C\" { } "; + (* event enum *) + pr "\n"; + pr "pub enum Event {\n"; + List.iter ( + fun (name, _) -> + pr " %s,\n" (snake2caml name) + ) events; + pr "}\n\n"; + + pr "impl Event {\n"; + pr " pub fn to_u64(&self) -> u64 {\n"; + pr " match self {\n"; + List.iter ( + fun (name, i) -> + pr " Event::%s => %d,\n" (snake2caml name) i...
2019 Jul 29
0
Re: [PATCH] Rust bindings: Add Rust bindings
...c = Str.split (Str.regexp (String.make 1 c)) > > The generator uses the internal mlstdutils shared code, see > common/mlstdutils. One of the things provided are extra functions for > the String module, and one in particular can help here: String.nsplit. > Also... > > > +let snake2caml name = > > + let l = split_on_char '_' name in > > + let l = List.map (fun x -> String.capitalize_ascii x) l in > > + String.concat "" l > > ... this can be simplified a bit using String.nsplit, and currying: > > let snake2caml name = > let...
2019 Jun 27
0
[PATCH 5/9] Rust bindings: Add generator of structs for optional arguments
...be placed in utils.ml? *) let rec indent n = match n with | x when x > 0 -> pr " "; indent (x - 1) | _ -> () +(* split_on_char exists since OCaml 4.04 *) +(* but current requirements: >=4.01 *) +let split_on_char c = Str.split (Str.regexp (String.make 1 c)) + +let snake2caml name = + let l = split_on_char '_' name in + let l = List.map (fun x -> String.capitalize_ascii x) l in + String.concat "" l + + +(* because there is a function which contains 'unsafe' field *) +let black_list = ["unsafe"] + +let translate_bad_symbols s = +...
2019 Jul 26
4
Re: [PATCH] Rust bindings: Add Rust bindings
...=4.01 *) > +let split_on_char c = Str.split (Str.regexp (String.make 1 c)) The generator uses the internal mlstdutils shared code, see common/mlstdutils. One of the things provided are extra functions for the String module, and one in particular can help here: String.nsplit. Also... > +let snake2caml name = > + let l = split_on_char '_' name in > + let l = List.map (fun x -> String.capitalize_ascii x) l in > + String.concat "" l ... this can be simplified a bit using String.nsplit, and currying: let snake2caml name = let l = String.nsplit "_" name...
2019 Aug 05
3
Re: [PATCH] Rust bindings: Implement Event features
I fixed based on comments. I'll send these two patches to this mailing list. - Fix Handle -> Handle<'a> - Add events Regards, Hiroyuki 2019年8月1日(木) 0:01 Pino Toscano <ptoscano@redhat.com>: > Hi Hiroyuki, > > On Tuesday, 30 July 2019 07:51:37 CEST Hiroyuki Katsura wrote: > > This patch includes: > > > > - Event callback handlers > > -
2019 Jul 23
2
Re: [PATCH] Rust bindings: Add Rust bindings
...concat ", " (List.map f (String.explode s))) > + ) args; > + if !needs_comma then pr ", "; > + (match optargs with > + | None -> pr "Default::default()" > + | Some optargs -> > + pr "%sOptArgs{" (Rust.snake2caml f); > + needs_comma := false; > + List.iter ( > + fun optarg -> > + if !needs_comma then pr ", "; > + needs_comma := true; > + match optarg with > + | CallOBool (n, v) -> > +...
2019 Jun 27
4
Re: [PATCH 9/9] Rust bindings: Complete bindings
Patch 9 is a kind of dumping ground of all kinds of stuff. It may be better to spend some time with git rebase -i trying to work this into more coherent patches. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live
2019 Aug 11
5
[PATCH 1/2] Rust bindings: Add long description
...esc in + List.iter (fun x -> + indent indent_depth; + pr "/// %s\n" x; + ) l + let generate_rust () = generate_header ~copyrights CStyle LGPLv2plus; @@ -398,6 +406,8 @@ extern \"C\" { style = (ret, args, optargs) } as f) -> let cname = snake2caml name in pr " /// %s\n" shortdesc; + pr " ///\n"; + pr_longdesc name longdesc 1; pr " #[allow(non_snake_case)]\n"; pr " pub fn %s" name; -- 2.20.1 (Apple Git-117)
2019 Jun 27
0
Re: [PATCH 08/11] Rust bindings: Fix memory management and format the file
...be avoided, + * but it is complex to handle freeing memories manually in Rust because of + * panic/?/etc. + *) + (* generate structs for optional arguments *) List.iter ( fun ({ name = name; shortdesc = shortdesc; style = (ret, args, optargs) }) -> let cname = snake2caml name in + let rec contains_ptr args = match args with + | [] -> false + | OString _ ::_ + | OStringList _::_ -> true + | _::xs -> contains_ptr xs + in + let opt_life_parameter = if contains_ptr optargs then "<'a>" else "&q...
2019 Jul 17
2
[PATCH] Rust bindings: Add Rust bindings
..." + (String.concat ", " (List.map f (String.explode s))) + ) args; + if !needs_comma then pr ", "; + (match optargs with + | None -> pr "Default::default()" + | Some optargs -> + pr "%sOptArgs{" (Rust.snake2caml f); + needs_comma := false; + List.iter ( + fun optarg -> + if !needs_comma then pr ", "; + needs_comma := true; + match optarg with + | CallOBool (n, v) -> + pr "%s: Some(%b)" n v +...
2019 Jul 20
2
Re: [PATCH] Rust bindings: Add Rust bindings
...| x when x > 0 -> pr " "; indent (x - 1) > >+ | _ -> () > >+ > >+(* split_on_char exists since OCaml 4.04 *) > >+(* but current requirements: >=4.01 *) > >+let split_on_char c = Str.split (Str.regexp (String.make 1 c)) > >+ > >+let snake2caml name = > >+ let l = split_on_char '_' name in > >+ let l = List.map (fun x -> String.capitalize_ascii x) l in > >+ String.concat "" l > >+ > >+(* because there is a function which contains 'unsafe' field *) > >+let black_list = [&q...
2019 Jul 20
0
[PATCH] Rust bindings: Add Rust bindings
..." + (String.concat ", " (List.map f (String.explode s))) + ) args; + if !needs_comma then pr ", "; + (match optargs with + | None -> pr "Default::default()" + | Some optargs -> + pr "%sOptArgs{" (Rust.snake2caml f); + needs_comma := false; + List.iter ( + fun optarg -> + if !needs_comma then pr ", "; + needs_comma := true; + match optarg with + | CallOBool (n, v) -> + pr "%s: Some(%b)" n v +...
2019 Jul 23
0
Re: [PATCH] Rust bindings: Add Rust bindings
..." + (String.concat ", " (List.map f (String.explode s))) + ) args; + if !needs_comma then pr ", "; + (match optargs with + | None -> pr "Default::default()" + | Some optargs -> + pr "%sOptArgs{" (Rust.snake2caml f); + needs_comma := false; + List.iter ( + fun optarg -> + if !needs_comma then pr ", "; + needs_comma := true; + match optarg with + | CallOBool (n, v) -> + pr "%s: Some(%b)" n v +...
2019 Jun 27
16
[PATCH 1/9] Rust bindings: Add Rust bindings
From: Hiroyuki_Katsura <hiroyuki.katsura.0513@gmail.com> --- Makefile.am | 4 ++++ configure.ac | 3 +++ generator/Makefile.am | 3 +++ generator/bindtests.ml | 3 +++ generator/bindtests.mli | 1 + generator/main.ml | 5 +++++ generator/rust.ml | 34 ++++++++++++++++++++++++++++++++++ generator/rust.mli | 19 +++++++++++++++++++
2019 Jul 08
2
Re: [PATCH] Add Rust bindings
On Mon, Jul 08, 2019 at 10:04:57AM +0100, Richard W.M. Jones wrote: >On Mon, Jul 08, 2019 at 10:49:55AM +0200, Martin Kletzander wrote: >> On Mon, Jul 08, 2019 at 10:10:10AM +0200, Pino Toscano wrote: >> >On Saturday, 6 July 2019 13:03:24 CEST Martin Kletzander wrote: >> >>Just one thing, the Cargo.toml includes a version under which the crate would be >>
2019 Jun 27
0
[PATCH 6/9] Rust bindings: Add generator of function signatures
...@@ -275,3 +295,120 @@ impl UUID { pr "}\n\n"; ); ) (actions |> external_functions |> sort); + + pr "impl Handle {\n"; + List.iter ( + fun ({ name = name; shortdesc = shortdesc; + style = (ret, args, optargs) } as f) -> + let cname = snake2caml name in + pr " /// %s \n" shortdesc; + pr " pub fn %s" name; + + (* generate arguments *) + pr "(&self, "; + let comma = ref false in + List.iter ( + fun arg -> + if !comma then pr ", "; + co...
2019 Jul 29
1
Re: [PATCH] Rust bindings: Add Rust bindings
..." + (String.concat ", " (List.map f (String.explode s))) + ) args; + if !needs_comma then pr ", "; + (match optargs with + | None -> pr "Default::default()" + | Some optargs -> + pr "%sOptArgs{" (Rust.snake2caml f); + needs_comma := false; + List.iter ( + fun optarg -> + if !needs_comma then pr ", "; + needs_comma := true; + match optarg with + | CallOBool (n, v) -> + pr "%s: Some(%b)" n v +...
2019 Jul 30
4
[PATCH] Rust bindings: Implement Event features
...ust.ml index a1735602c..1f5cefa62 100644 --- a/generator/rust.ml +++ b/generator/rust.ml @@ -72,6 +72,42 @@ extern \"C\" { } "; + (* event enum *) + pr "\n"; + pr "pub enum Event {\n"; + List.iter ( + fun (name, _) -> + pr " %s,\n" (snake2caml name) + ) events; + pr "}\n\n"; + + pr "impl Event {\n"; + pr " pub fn to_u64(&self) -> u64 {\n"; + pr " match self {\n"; + List.iter ( + fun (name, i) -> + pr " Event::%s => %d,\n" (snake2caml name) i...
2019 Jul 02
16
[PATCH] Add Rust bindings
I fixed the patch I submitted before based on comments, and there are some commits which are merged or divided. So, I will re-send all the patches. Regards, Hiroyuki Katsura
2019 Jun 27
0
[PATCH 9/9] Rust bindings: Complete bindings
..." + (String.concat ", " (List.map f (String.explode s))) + ) args; + if !needs_comma then pr ", "; + (match optargs with + | None -> pr "Default::default()" + | Some optargs -> + pr "%sOptArgs{" (Rust.snake2caml f); + needs_comma := false; + List.iter ( + fun optarg -> + if !needs_comma then pr ", "; + needs_comma := true; + match optarg with + | CallOBool (n, v) -> + pr "%s: Some(%b)" n v +...