search for: type_of_ret

Displaying 20 results from an estimated 24 matches for "type_of_ret".

2020 Sep 07
2
Re: [libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...function > | RBool | RErr | RFd | RInt | RInt64 | RCookie -> Some "-1" > | RStaticString | RString -> Some "NULL" > - | RUInt -> None (* errors not possible *) > + | RUInt | REnum (_) | RFlags (_) -> None (* errors not possible *) > > let type_of_ret = > function > - | RBool | RErr | RFd | RInt -> "int" > + | RBool | RErr | RFd | RInt | REnum (_) -> "int" This is good because Enum is passed as int. > [...] You used unsigned for RFlags, but shouldn't it be this instead? + | RFlags (_) -> &qu...
2020 Sep 07
0
Re: [libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...Bool | RErr | RFd | RInt | RInt64 | RCookie -> Some "-1" >> | RStaticString | RString -> Some "NULL" >> - | RUInt -> None (* errors not possible *) >> + | RUInt | REnum (_) | RFlags (_) -> None (* errors not possible *) >> >> let type_of_ret = >> function >> - | RBool | RErr | RFd | RInt -> "int" >> + | RBool | RErr | RFd | RInt | REnum (_) -> "int" > > This is good because Enum is passed as int. > >> [...] > > You used unsigned for RFlags, but shouldn't it b...
2023 May 02
1
[libnbd PATCH v2 2/2] generator/C: lib/api.c: indent arg list 2 spaces relative to function name
...he update to the preceding patch in the series generator/C.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generator/C.ml b/generator/C.ml index e68fd70382cf..f772117cd3c9 100644 --- a/generator/C.ml +++ b/generator/C.ml @@ -566,7 +566,8 @@ let let ret_c_type = type_of_ret ret and errcode = errcode_of_ret ret in pr "%s\n" ret_c_type; pr "nbd_%s " name; - print_arg_list ~wrap:true ~handle:true args optargs; + print_arg_list ~wrap:true ~handle:true ~parens:(ParensNewLineWithIndent 0) + args optargs; pr "\n";...
2020 Sep 07
1
Re: [libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...Int | RInt64 | RCookie -> Some "-1" > >> | RStaticString | RString -> Some "NULL" > >>- | RUInt -> None (* errors not possible *) > >>+ | RUInt | REnum (_) | RFlags (_) -> None (* errors not possible *) > >> > >> let type_of_ret = > >> function > >>- | RBool | RErr | RFd | RInt -> "int" > >>+ | RBool | RErr | RFd | RInt | REnum (_) -> "int" > > > >This is good because Enum is passed as int. > > > >>[...] > > > >You used unsigne...
2019 Aug 09
0
[PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
...s:bool -> arg list -> unit + val print_arg_list : ?handle:bool -> ?types:bool -> + arg list -> optarg list -> unit val print_cbarg_list : ?valid_flag:bool -> ?types:bool -> cbarg list -> unit val errcode_of_ret : ret -> string option val type_of_ret : ret -> string @@ -3157,17 +3169,14 @@ end = struct (* Check the API definition. *) let () = - (* Flags must only appear once in the final argument position. *) + (* Currently optargs can only be [] or [OFlags]. This condition + * will be relaxed later when we support more optional arg...
2023 May 02
4
[libnbd PATCH v2 0/2] continue wrapping generated C code harder
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 v1: https://listman.redhat.com/archives/libguestfs/2023-April/031375.html In v2, move the declaration of the "p" helper variable next to the top of the function. Thanks! Laszlo Laszlo Ersek (2): generator/C: print_wrapper: use helper variable for permitted state check generator/C: lib/api.c: indent arg list 2
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably make much sense on their own, but they are preparatory to better handling of enums, and or'd lists of flags. Rich.
2020 Sep 06
0
[libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...,15 @@ let errcode_of_ret = function | RBool | RErr | RFd | RInt | RInt64 | RCookie -> Some "-1" | RStaticString | RString -> Some "NULL" - | RUInt -> None (* errors not possible *) + | RUInt | REnum (_) | RFlags (_) -> None (* errors not possible *) let type_of_ret = function - | RBool | RErr | RFd | RInt -> "int" + | RBool | RErr | RFd | RInt | REnum (_) -> "int" | RInt64 | RCookie -> "int64_t" | RStaticString -> "const char *" | RString -> "char *" - | RUInt -> "unsigned...
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
...if (!py_%s) { PyErr_PrintEx (0); return -1; }\n" n; | CBString _ | CBUInt _ @@ -263,7 +264,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " PyObject *py_h;\n"; pr " struct nbd_handle *h;\n"; pr " %s ret;\n" (C.type_of_ret ret); - pr " PyObject *py_ret;\n"; + pr " PyObject *py_ret = NULL;\n"; List.iter ( function | Bool n -> pr " int %s;\n" n @@ -279,7 +280,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " struct py_aio_buf...
2019 Aug 14
0
[PATCH libnbd 2/2] ocaml: Remove NBD.Buffer.free function, use the completion callback instead.
...( + function + | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> + pr " completion_user_data->bufv = %sv;\n" n; + pr " caml_register_generational_global_root (&completion_user_data->bufv);\n" + | _ -> () + ) args; + let ret_c_type = C.type_of_ret ret and errcode = C.errcode_of_ret ret in pr " %s r;\n" ret_c_type; pr "\n"; @@ -5252,7 +5267,8 @@ let generate_ocaml_nbd_c () = pr " * and freed in the free_user_data function below.\n"; pr " */\n"; pr "struct user_data {\n"; - pr...
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...a:bool -> - ?types:bool -> arg list -> unit + val print_arg_list : ?handle:bool -> ?types:bool -> arg list -> unit + val print_cbarg_list : ?valid_flag:bool -> ?types:bool -> cbarg list -> unit val errcode_of_ret : ret -> string option val type_of_ret : ret -> string end = struct @@ -3278,7 +3285,6 @@ let type_of_ret = | RUInt -> "unsigned" let rec name_of_arg = function -| ArrayAndLen (arg, n) -> name_of_arg arg @ [n] | Bool n -> [n] | BytesIn (n, len) -> [n; len] | BytesOut (n, len) -> [n; len] @@ -3289,7...
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 Mar 17
0
[PATCH libnbd v2 3/3] golang: Add straightforward bindings, without callbacks.
...ose) to + * handle errors because cgo calls are sequence points and + * could result in us being rescheduled on another thread, + * but libnbd error handling means we must call nbd_get_error + * etc from the same thread. + *) +let print_wrapper (name, { args; optargs; ret }) = + let ret_c_type = C.type_of_ret ret and errcode = C.errcode_of_ret ret in + pr "static %s\n" ret_c_type; + pr "_nbd_%s_wrapper (struct error *err,\n" name; + pr " "; + C.print_arg_list ~wrap:true ~handle:true ~parens:false args optargs; + pr ")\n"; + pr "{\n"; + pr &...
2020 Sep 07
0
[libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
...uot; closure_mark cbname | OFlags (n, _) -> if types then pr "uint32_t "; pr "%s" n ) optargs -let print_call ?wrap ?maxcol name args optargs ret = +let print_call ?wrap ?maxcol ?closure_mark name args optargs ret = pr "%s nbd_%s " (type_of_ret ret) name; - print_arg_list ~handle:true ?wrap ?maxcol args optargs + print_arg_list ~handle:true ?wrap ?maxcol ?closure_mark args optargs -let print_extern ?wrap name args optargs ret = +let print_extern ?wrap ?closure_mark name args optargs ret = pr "extern "; - print_call ?wrap...
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
2020 Mar 17
5
[PATCH libnbd v2 0/3] Unfinished golang bindings.
These bindings get as far as running very simple connections. However there are many missing parts still: * No callbacks. * No functions which handle buffers (pread/pwrite!) This is posted just for general early interest, not even for review. Rich.
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...ool -> ?types:bool -> arg list -> optarg list -> unit - val print_cbarg_list : ?valid_flag:bool -> ?types:bool -> cbarg list -> unit + val print_cbarg_list : ?types:bool -> cbarg list -> unit val errcode_of_ret : ret -> string option val type_of_ret : ret -> string end = struct @@ -3430,13 +3430,8 @@ let print_extern name args optargs ret = print_call name args optargs ret; pr ";\n" -let print_cbarg_list ?(valid_flag = true) ?(types = true) cbargs = +let print_cbarg_list ?(types = true) cbargs = pr "("; - if...
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 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...ool -> ?types:bool -> arg list -> optarg list -> unit - val print_cbarg_list : ?valid_flag:bool -> ?types:bool -> cbarg list -> unit + val print_cbarg_list : ?types:bool -> cbarg list -> unit val errcode_of_ret : ret -> string option val type_of_ret : ret -> string end = struct @@ -3284,13 +3284,8 @@ let print_extern name args optargs ret = print_call name args optargs ret; pr ";\n" -let print_cbarg_list ?(valid_flag = true) ?(types = true) cbargs = +let print_cbarg_list ?(types = true) cbargs = pr "("; - if...
2020 Mar 25
3
[PATCH libnbd v4] Add Go language bindings (golang) (RHBZ#1814538).
Now runs a complete set of tests, notably including the AIO test. File descriptors are passed in and out as plain ints (instead of *os.File) for a couple of reasons: (1) We have to pass the plain int to syscall.Select. (2) Turning an fd into an os.File causes golang to set the blocking flag which is deeply unhelpful. Rich.