[libvirt] [PATCH 1/2] python: treat flags as default argument with value 0
Guannan Ren
gren at redhat.com
Fri Mar 22 03:24:56 UTC 2013
On 03/21/2013 06:47 PM, Osier Yang wrote:
> On 2013年03月21日 16:41, Guannan Ren wrote:
>> The following four functions have not changed because default arguments
>> have to come after positional arguments. Changing them will break the
>> the binding APIs.
>>
>> migrate(self, dconn, flags, dname, uri, bandwidth):
>> migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
>> migrateToURI(self, duri, flags, dname, bandwidth):
>> migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
>
> So how are they filtered? ...
>
If we add flags=0 to above four APIs, we have to move the
flags arguments
to the last position in the arguments list because the rule
"default arguments
have to come after positional arguments." Changing them will
break the binding
APIs. so I didn't touch them.
>>
>>
>> ---
>> python/generator.py | 2 ++
>> python/libvirt-override-virConnect.py | 14 +++++++-------
>> python/libvirt-override-virDomain.py | 2 +-
>> python/libvirt-override-virDomainSnapshot.py | 2 +-
>> python/libvirt-override-virStoragePool.py | 2 +-
>> python/libvirt-override.py | 2 +-
>> 6 files changed, 13 insertions(+), 11 deletions(-)
>>
>> diff --git a/python/generator.py b/python/generator.py
>> index d269e88..bb53fcf 100755
>> --- a/python/generator.py
>> +++ b/python/generator.py
>> @@ -1487,6 +1487,8 @@ def buildWrappers(module):
>> if n != index:
>> classes.write(", %s" % arg[0])
>> n = n + 1
>> + if arg[0] == "flags":
>> + classes.write("=0");
>
> ...As I see you write "flags=0" for all the automatically generated
> APIs here? And is there any risk to have other APIs of which flags
> doesn't default to 0? Except the ones you mentioned in commit log.
>
Yes, I am not sure if the 0 is appropriatefor every APIs.
I need more advice here.
According to my test, they can accept the 0 value all.
More information about the libvir-list
mailing list