search for: py_

Displaying 20 results from an estimated 74 matches for "py_".

Did you mean: py
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
..."static int\n"; + pr "%s_wrapper " cbname; + C.print_cbarg_list cbargs; + pr "\n"; + pr "{\n"; + pr " int ret = 0;\n"; + pr "\n"; + pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; + List.iter ( + function + | CBArrayAndLen (UInt32 n, len) -> + pr " PyObject *py_%s = PyList_New (%s);\n" n len; + pr " for (size_t i = 0; i < %s; ++i)\n" len...
2019 Jun 25
3
[PATCH libnbd] generator: Add Mutable type to the generator.
...| Opaque n -> pr "void *%s" n | Path n | String n -> pr "const char *%s" n @@ -3261,14 +3265,20 @@ let print_python_binding name { args; ret } = pr " for (size_t i = 0; i < %s; ++i)\n" len; pr " PyList_SET_ITEM (py_%s, i, PyLong_FromUnsignedLong (%s[i]));\n" n n | BytesIn _ -> () + | Mutable (Int n) -> + pr " PyObject *py_%s_dict = PyImport_GetModuleDict ();\n" n; + pr " PyObject *py_%s_mod = PyMapping_GetItemString (py_%s_dict, \"ctypes\...
2019 Jul 16
0
[libnbd PATCH 2/2] RFC: generator: Handle shared callbacks in Python
...e + let print_callback cb = + pr "static int\n"; + pr "%s_%s_wrapper " name cb.name; + print_c_arg_list ~handle:(Some "void *_data") cb.cbargs; + pr "\n"; + pr "{\n"; + pr " int ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; + pr " struct %s_data *data = _data;\n" name; + List.iter ( + function + | ArrayAndLen (UInt32 n, len) -> + pr " PyObject *py_%s = PyList_New (%s);\n" n len; +...
2019 Jul 16
3
[RFC libnbd PATCH 0/2] Start fixing python nbd.pread_structured_callback
Posting now that I got something to compile (at the expense of breaking OCaml bindings), but I'm open to ideas on how to improve it. Eric Blake (2): generator: Tweak print_c_arg_list to take alternate first arg RFC: generator: Handle shared callbacks in Python generator/generator | 556 ++++++++++++++++++++++---------------------- 1 file changed, 280 insertions(+), 276 deletions(-) --
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...-4226,26 +4218,25 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr "{\n"; pr " int ret = 0;\n"; pr "\n"; - pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; List.iter ( function | CBArrayAndLen (UInt32...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...REATE 1\n"; pr "\n"; @@ -4032,26 +4025,25 @@ let print_python_closure_wrapper { cbname; cbargs } = pr "{\n"; pr " int ret = 0;\n"; pr "\n"; - pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; + pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; + pr " PyObject *py_args, *py_ret;\n"; List.iter ( function | CBArrayAndLen (UInt32 n, len) -> - pr &quot...
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...(void *vp)\n" name cbname; pr "{\n"; - pr " struct %s_user_data *user_data = vp;\n" name; + pr " PyObject *user_data = vp;\n"; pr "\n"; - List.iter ( - fun { cbname } -> - pr " Py_DECREF (user_data->%s);\n" cbname - ) cls; - pr " free (user_data);\n"; + pr " Py_DECREF (user_data);\n"; pr "}\n"; pr "\n"; ); + pr "/* Wrapper for %s callback of %s. */\n" cbname...
2019 Jul 24
8
[PATCH libnbd v2 0/5] lib: Implement closure lifetimes.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00231 The changes address everything that Eric picked up in his review of the first two patches. I have also added two more patches (4 and 5) which respectively fix docs and change int status -> unsigned status, as discussed. Passes make, check, check-valgrind. Rich.
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...nt_arg_list ~valid_flag:true ~user_data:true cbargs; + C.print_cbarg_list cbargs; pr "\n"; pr "{\n"; pr " int ret = 0;\n"; @@ -4017,14 +4041,14 @@ let print_python_binding name { args; ret; may_set_error } = pr " PyObject *py_args, *py_ret;\n"; List.iter ( function - | ArrayAndLen (UInt32 n, len) -> + | CBArrayAndLen (UInt32 n, len) -> pr " PyObject *py_%s = PyList_New (%s);\n" n len; pr " for (size_t i = 0; i < %s; ++i)\n&quot...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...ta struct. - *) - if persistent then ( - pr "static void\n"; - pr "free_%s_%s_user_data (void *vp)\n" name cbname; - pr "{\n"; - pr " PyObject *user_data = vp;\n"; - pr "\n"; - pr " Py_DECREF (user_data);\n"; - pr "}\n"; - pr "\n"; - ); - + | Closure { cbname; cbargs } -> pr "/* Wrapper for %s callback of %s. */\n" cbname name; pr "static int\n"; pr "%s_%s_wrapper " name cbna...
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...pr "};\n"; pr "\n"; - pr "static int\n"; - pr "%s_%s_wrapper " name cb_name; - print_c_arg_list args; - pr "\n"; - pr "{\n"; - pr " int ret;\n"; - pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n"; - pr " PyObject *py_args, *py_ret;\n"; - List.iter ( - function - | ArrayAndLen (UInt32 n, len) -> - pr " PyObject *py_%s = PyList_New (%s);\n" n len; - pr " for (size_t i = 0; i &lt...
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
2019 Jul 24
0
[PATCH libnbd v2 5/5] lib: Use unsigned for pread_structured status parameter.
...; Closure { cbname="callback"; cbargs=[Int64 "cookie"; @@ -3789,8 +3789,8 @@ let print_python_binding name { args; ret } = pr " for (size_t i = 0; i < %s; ++i)\n" len; pr " PyList_SET_ITEM (py_%s, i, PyLong_FromUnsignedLong (%s[i]));\n" n n | BytesIn _ - | Int _ - | Int64 _ -> () + | Int _ + | Int64 _ -> () | Mutable (Int n) -> pr " PyObject *py_%s_modname = PyUnicode_FromString (\"ctypes\&quot...
2014 Aug 11
3
[PATCH] python: fix possible free on uninit memory with OStringList optargs
...ml b/generator/python.ml index 72bc8a0..a763104 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -511,7 +511,9 @@ put_table (char * const * const argv) function | OBool _ | OInt _ | OInt64 _ | OString _ -> () | OStringList n -> - pr " if (py_%s != Py_None)\n" n; + let uc_n = String.uppercase n in + pr " if (py_%s != Py_None && (optargs_s.bitmask |= %s_%s_BITMASK) != 0)\n" + n c_optarg_prefix uc_n; pr " free ((char **) optargs_s.%s);\n" n ) optargs; --...
2019 Jun 25
0
Re: [PATCH libnbd] generator: Add Mutable type to the generator.
...++++++++++++++++++++++++++++-------- > 1 file changed, 63 insertions(+), 12 deletions(-) > > @@ -3261,14 +3265,20 @@ let print_python_binding name { args; ret } = > pr " for (size_t i = 0; i < %s; ++i)\n" len; > pr " PyList_SET_ITEM (py_%s, i, PyLong_FromUnsignedLong (%s[i]));\n" n n > | BytesIn _ -> () > + | Mutable (Int n) -> > + pr " PyObject *py_%s_dict = PyImport_GetModuleDict ();\n" n; > + pr " PyObject *py_%s_mod = PyMapping_GetItemString (py_%s_...
2012 Aug 25
1
[PATCH] python: Fixed syntax errors in python/guestfs-py.c
...deletion(-) diff --git a/generator/generator_python.ml b/generator/generator_python.ml index dc9cbca..b11df6e 100644 --- a/generator/generator_python.ml +++ b/generator/generator_python.ml @@ -391,7 +391,7 @@ free_strings (char **argv) pr " optargs_s.%s = PyString_AsString (py_%s);\n" n n; pr "#else\n"; pr " PyObject *bytes;\n"; - pr " bytes = PyUnicode_AsUTF8String (py_%s));\n" n; + pr " bytes = PyUnicode_AsUTF8String (py_%s);\n" n; pr " op...
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...ions(+), 56 deletions(-) diff --git a/generator/Python.ml b/generator/Python.ml index 9a22f9e..3b86dc0 100644 --- a/generator/Python.ml +++ b/generator/Python.ml @@ -271,7 +271,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | BytesIn (n, _) -> pr " Py_buffer %s;\n" n | BytesOut (n, count) -> - pr " char *%s;\n" n; + pr " char *%s = NULL;\n" n; pr " Py_ssize_t %s;\n" count | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> @@ -279,11 +279,10 @@ let print_python_binding...
2019 Jul 16
2
[PATCH libnbd v2] generator: Define new Closure type
As before, but this one has working Python bindings. OCaml still TBD. Rich.
2019 Jun 29
0
[libnbd PATCH 3/6] generator: Allow Int64 in callbacks
...or/generator b/generator/generator index 45a030f..c5988e2 100755 --- a/generator/generator +++ b/generator/generator @@ -3508,7 +3508,8 @@ let print_python_binding name { args; ret } = pr " for (size_t i = 0; i < %s; ++i)\n" len; pr " PyList_SET_ITEM (py_%s, i, PyLong_FromUnsignedLong (%s[i]));\n" n n | BytesIn _ - | Int _ -> () + | Int _ + | Int64 _ -> () | Mutable (Int n) -> pr " PyObject *py_%s_modname = PyUnicode_FromString (\"ctypes\");\n" n;...
2019 Jun 27
1
[libnbd PATCH] python: Fix bindings for Path parameters
...rator @@ -3608,7 +3608,9 @@ let print_python_binding name { args; ret } = | Mutable arg -> pr " PyObject *%s;\n" (List.hd (name_of_arg arg)) | Opaque _ -> () - | Path n -> pr " char *%s = NULL;\n" n + | Path n -> + pr " PyObject *py_%s = NULL;\n" n; + pr " char *%s = NULL;\n" n | SockAddrAndLen (n, _) -> pr " /* XXX Complicated - Python uses a tuple of different\n"; pr " * lengths for the different socket types.\n"; @@ -3699,7 +3701,7 @@ let print_python_bindi...