Re: [PATCH 1/2] python: treat flags as default argument with value 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]