Displaying 20 results from an estimated 26 matches for "enum_prefix".
2019 Aug 10
0
[PATCH libnbd 3/9] generator: Add Enum type for enumerated types / unions.
...all int *)
| Int64 of string (* 64 bit signed int *)
| Path of string (* filename or path *)
@@ -890,6 +891,10 @@ and cbarg =
| CBString of string (* like String *)
| CBUInt of string (* like UInt *)
| CBUInt64 of string (* like UInt64 *)
+and enum = {
+ enum_prefix : string; (* prefix of each enum variant *)
+ enums : (string * int) list (* enum names and their values in C *)
+}
and flags = {
flag_prefix : string; (* prefix of each flag name *)
flags : (string * int) list (* flag names and their values in C *)
@@ -910,6 +915,17 @@ let non_blocki...
2020 Sep 07
0
[libnbd PATCH v2 3/3] ocaml: Typesafe returns for REnum/RFlags
...OCaml.ml
index db7003c..4bcd450 100644
--- a/generator/OCaml.ml
+++ b/generator/OCaml.ml
@@ -66,8 +66,8 @@ and ocaml_ret_to_string = function
| RCookie -> "cookie"
| RString -> "string"
| RUInt -> "int"
- | REnum _ -> "int" (* XXX return enum_prefix.t instead *)
- | RFlags _ -> "int" (* XXX return flag_prefix.t list instead *)
+ | REnum { enum_prefix } -> enum_prefix ^ ".t"
+ | RFlags { flag_prefix } -> flag_prefix ^ ".t list"
and ocaml_optarg_to_string = function
| OClosure { cbname; cbargs } -&g...
2020 Sep 06
0
[libnbd PATCH 3/3] ocaml: Typesafe returns for REnum/RFlags
...aml.ml
index 4a835b0..cb6633c 100644
--- a/generator/OCaml.ml
+++ b/generator/OCaml.ml
@@ -66,8 +66,8 @@ and ocaml_ret_to_string = function
| RCookie -> "cookie"
| RString -> "string"
| RUInt -> "int"
- | REnum (_) -> "int" (* XXX return enum_prefix.t instead *)
- | RFlags (_) -> "int" (* XXX return flag_prefix.t list instead *)
+ | REnum ({ enum_prefix }) -> enum_prefix ^ ".t"
+ | RFlags ({ flag_prefix }) -> flag_prefix ^ ".t list"
and ocaml_optarg_to_string = function
| OClosure { cbname; cbargs...
2020 Sep 06
8
[libnbd PATCH 0/3] Improve type-safety of ocaml/golang getters
Natural fallout after my recent testsuite additions that fixed a
couple of ocaml bugs in the setters. However, on at least the OCaml
code, I'm not sure what we should do if a newer libnbd ever returns a
bit that an older NBD.mli was not expecting at the time the OCaml
compiler ran (see below). I'm also not sure if there is a more
efficient way to avoid outputting Val_FOO() converters for
2020 Sep 07
4
[libnbd PATCH v2 0/3] Improve type-safety of ocaml/golang getters
Well, the golang changes (patch 1 and 2/3 of v1) were already
committed, all that was left was the OCaml changes. I'm a lot happier
with how things turned out with an UNKNOWN constructor in the OCaml
variants.
Eric Blake (3):
tests: Enhance coverage of enum/flag range checking
ocaml: Support unknown values for Enum/Flags
ocaml: Typesafe returns for REnum/RFlags
generator/OCaml.ml
2020 Sep 06
0
[libnbd PATCH 2/3] golang: Typesafe returns for REnum/RFlags
...99,8 @@ let go_ret_type = function
* always nil unless h is closed
*)
| RUInt -> Some "uint"
- | REnum (_) -> Some "uint" (* XXX return typed constant instead? *)
- | RFlags (_) -> Some "uint" (* XXX return typed constant instead? *)
+ | REnum ({ enum_prefix}) -> Some (camel_case enum_prefix)
+ | RFlags ({ flag_prefix}) -> Some (camel_case flag_prefix)
let go_ret_error = function
| RErr -> None
@@ -393,10 +393,10 @@ let print_binding (name, { args; optargs; ret; shortdesc }) =
pr " return &r, nil\n"
| RUInt -&...
2019 Aug 10
17
[PATCH libnbd 0/9] Add Enum and Flags types.
This largish series adds several new features to the generator.
Enum maps to enumerated types (like enum in C). The only current use
for this is replacing the nbd_set_tls (nbd, 0/1/2) parameter with
LIBNBD_TLS_DISABLE, LIBNBD_TLS_ALLOW, LIBNBD_TLS_REQUIRE (and natural
equivalents in other programming languages).
Flags maps to any uint32_t bitmask. It is basically a non-optional,
generalized
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
..._) -> n
+ | Flags (n, _) -> n
| Int n -> n
| Int64 n -> n
| Path n -> n
@@ -4706,6 +4723,7 @@ and ocaml_arg_to_string = function
| Closure { cbargs } ->
sprintf "(%s)" (ocaml_closuredecl_to_string cbargs)
| Enum (_, { enum_prefix }) -> sprintf "%s.t" enum_prefix
+ | Flags (_, { flag_prefix }) -> sprintf "%s.t" flag_prefix
| Int _ -> "int"
| Int64 _ -> "int64"
| Path _ -> "string"
@@ -4753,6 +4771,7 @@ let ocaml_name_of_arg = function
| BytesPersis...
2019 Oct 04
0
[PATCH libnbd 3/4] api: Add nbd_connect_socket.
...| Int64 n -> n, None, None
| Path n -> n, None, None
| SockAddrAndLen (n, _) -> n, None, None
@@ -5431,6 +5469,7 @@ and ocaml_arg_to_string = function
| Closure { cbargs } ->
sprintf "(%s)" (ocaml_closuredecl_to_string cbargs)
| Enum (_, { enum_prefix }) -> sprintf "%s.t" enum_prefix
+ | Fd _ -> "Unix.file_descr"
| Flags (_, { flag_prefix }) -> sprintf "%s.t" flag_prefix
| Int _ -> "int"
| Int64 _ -> "int64"
@@ -5482,6 +5521,7 @@ let ocaml_name_of_arg = function
| Byte...
2019 Aug 10
0
[PATCH libnbd 5/9] generator: On entry to API functions, check Enum parameters.
..., 17 insertions(+)
diff --git a/generator/generator b/generator/generator
index 73b8b79..2b37cea 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3686,6 +3686,23 @@ let generate_lib_api_c () =
(* Check parameters are valid. *)
List.iter (
function
+ | Enum (n, { enum_prefix; enums }) ->
+ let value = match errcode with
+ | Some value -> value
+ | None -> assert false in
+ pr " switch (%s) {\n" n;
+ List.iter (
+ fun (enum, _) ->
+ pr " case LIBNBD_%s_%s:\n" enum_prefix...
2019 Aug 12
0
[PATCH libnbd 5/7] ocaml: Use free callback to free closure root, instead of valid_flag == FREE.
..._%s_wrapper;\n" cbname name cbname;
+ pr " if (nbd_add_free_callback (h, %s_user_data,\n" cbname;
+ pr " free_root, %s_user_data) == -1)\n"
+ cbname;
+ pr " caml_raise_out_of_memory ();\n"
| Enum (n, { enum_prefix }) ->
pr " int %s = %s_val (%sv);\n" n enum_prefix n
| Flags (n, { flag_prefix }) ->
--
2.22.0
2020 Sep 06
0
[libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...; optargs; ret;
pr "This call returns a string. The caller must free the\n";
pr "returned string to avoid a memory leak.\n";
| RUInt ->
- pr "This call returns a bitmask.\n"
+ pr "This call returns a bitmask.\n";
+ | REnum ({ enum_prefix }) ->
+ pr "This call returns one of the LIBNBD_%s_* values.\n" enum_prefix;
+ | RFlags ({ flag_prefix }) ->
+ pr "This call returns a bitmask of LIBNBD_%s_* values.\n" flag_prefix;
);
pr "\n";
diff --git a/generator/GoLang.ml b/generator/GoLan...
2019 Aug 14
4
[PATCH libnbd 0/2] Use free callback to dereference NBD.Buffer.
In this patch series we use the newly introduced free callback
on the completion function to dererence the OCaml NBD.Buffer.
I will make the same kind of change for Python later in a
separate series.
The completion function is always called at the C level, even
if the OCaml program didn't use the optional argument. That's
because the free callback doesn't run otherwise.
There is a
2019 Oct 04
4
[PATCH libnbd 1/4] generator: Allow long ‘name - shortdesc’ in man pages.
For commands with long names and/or short descriptors, you can end up
going over 72 characters in the first line of the man page (causing
podwrapper to complain). Wrap these lines.
---
generator/generator | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/generator/generator b/generator/generator
index 7d3f656..ad1cb6b 100755
--- a/generator/generator
+++ b/generator/generator
2019 Aug 14
0
[PATCH libnbd 2/2] ocaml: Remove NBD.Buffer.free function, use the completion callback instead.
...ot; %s_callback.callback = %s_wrapper;\n" cbname cbname;
- pr " %s_callback.user_data = user_data;\n" cbname;
+ pr " %s_callback.user_data = %s_user_data;\n" cbname cbname;
pr " %s_callback.free = free_user_data;\n" cbname
| Enum (n, { enum_prefix }) ->
pr " int %s = %s_val (%sv);\n" n enum_prefix n
@@ -5154,6 +5156,19 @@ let print_ocaml_binding (name, { args; optargs; ret }) =
pr " uint64_t %s = Int64_val (%sv);\n" n n
) args;
+ (* If there is a BytesPersistIn/Out parameter then we need to
+...
2019 Aug 10
0
[PATCH libnbd 7/9] generator: On entry to API functions, check Flags and OFlags parameters.
...r flag: %%d\",\n";
+ pr " \"%s\", %s);\n" n n;
+ pr " ret = %s;\n" value;
+ pr " goto out;\n";
+ pr " }\n";
+ need_out_label := true
+ in
List.iter (
function
| Enum (n, { enum_prefix; enums }) ->
@@ -3708,6 +3721,8 @@ let generate_lib_api_c () =
pr " goto out;\n";
pr " }\n";
need_out_label := true
+ | Flags (n, flags) ->
+ print_flags_check n flags
| String n ->
let value = match errcod...
2019 Aug 13
0
[PATCH libnbd 4/6] lib: Check Closure parameter is not NULL.
...quot; cbname;
+ pr " set_error (EFAULT, \"%%s cannot be NULL\", \"%s\");\n" cbname;
+ pr " ret = %s;\n" value;
+ pr " goto out;\n";
+ pr " }\n";
+ need_out_label := true
| Enum (n, { enum_prefix; enums }) ->
let value = match errcode with
| Some value -> value
--
2.22.0
2020 Mar 24
1
[PATCH libnbd v3] Add Go language bindings (golang) (RHBZ#1814538).
This feature is roughly finished now, although it needs a few more
tests and some examples.
It's pretty much up to par with all the other bindings, but it lacks a
completely safe AIO buffer. It won't stop you from freeing the buffer
too early) because golang's GC inexplicably lacks a way to declare a
root from C. I can probably do it with a global variable and ref
counting on the
2019 Aug 15
13
[PATCH libnbd v2 00/10] Callbacks and OCaml and Python persistent buffers.
This is a combination of these two earlier series:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
https://www.redhat.com/archives/libguestfs/2019-August/msg00240.html
plus changes to allow .callback = NULL / .free != NULL, and to reduce
the complexity of freeing callbacks.
Although it's rather long there's nothing complex here. We might
consider squashing some
2019 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring
and IMHO we should just push them. Possibly 1-3 should be squashed
together, but I posted them separately so they are easier to review.
Patches 5 and 6 together implement OClosure. Patch 5 adds the feature
and is simple to understand.
Patch 6 changes the Closure completion callbacks into OClosure, but
because it doesn't