[PATCH] esx: Generate implicit _this macros

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

 



---
 src/Makefile.am             |    1 +
 src/esx/esx_vi_generator.py |   48 ++++++++++++++++++++++++------------------
 src/esx/esx_vi_methods.c    |   40 +++--------------------------------
 3 files changed, 32 insertions(+), 57 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 1eaa7d1..4fadc47 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -327,6 +327,7 @@ ESX_DRIVER_SOURCES =						\
 ESX_DRIVER_GENERATED =							\
 		esx/esx_vi_methods.generated.c				\
 		esx/esx_vi_methods.generated.h				\
+		esx/esx_vi_methods.generated.macro			\
 		esx/esx_vi_types.generated.c				\
 		esx/esx_vi_types.generated.h				\
 		esx/esx_vi_types.generated.typedef			\
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index ac15c7f..0c1c9e0 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -26,7 +26,6 @@ import os.path
 
 
 
-
 OCCURRENCE__REQUIRED_ITEM = "r"
 OCCURRENCE__REQUIRED_LIST = "rl"
 OCCURRENCE__OPTIONAL_ITEM = "o"
@@ -39,10 +38,19 @@ valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
                      OCCURRENCE__OPTIONAL_LIST,
                      OCCURRENCE__IGNORED]
 
+autobind_map = { "FileManager"        : "fileManager",
+                 "PerformanceManager" : "perfManager",
+                 "PropertyCollector"  : "propertyCollector",
+                 "SearchIndex"        : "searchIndex",
+                 "SessionManager"     : "sessionManager",
+                 "VirtualDiskManager" : "virtualDiskManager" }
+
+autobind_map_usage = set()
+
 
 
-def aligned(left, right):
-    while len(left) < 59:
+def aligned(left, right, length=59):
+    while len(left) < length:
         left += " "
 
     return left + right
@@ -50,13 +58,6 @@ def aligned(left, right):
 
 
 class Parameter:
-    autobind_map = { "FileManager"        : "fileManager",
-                     "PerformanceManager" : "perfManager",
-                     "PropertyCollector"  : "propertyCollector",
-                     "SearchIndex"        : "searchIndex",
-                     "SessionManager"     : "sessionManager",
-                     "VirtualDiskManager" : "virtualDiskManager" }
-
     def __init__(self, type, name, occurrence):
         self.type = type
         self.occurrence = occurrence
@@ -212,7 +213,8 @@ class Method:
         source += "ESX_VI__METHOD(%s," % self.name
 
         if self.autobind_parameter is not None:
-            source += " %s,\n" % Parameter.autobind_map[self.autobind_parameter.autobind_type]
+            autobind_map_usage.add(self.autobind_parameter.autobind_type)
+            source += " %s,\n" % autobind_map[self.autobind_parameter.autobind_type]
         else:
             source += " /* explicit _this */,\n"
 
@@ -1482,6 +1484,7 @@ types_header = open_and_print(os.path.join(output_dirname, "esx_vi_types.generat
 types_source = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.c"))
 methods_header = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.h"))
 methods_source = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.c"))
+methods_macro = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.macro"))
 helpers_header = open_and_print(os.path.join(output_dirname, "esx_vi.generated.h"))
 helpers_source = open_and_print(os.path.join(output_dirname, "esx_vi.generated.c"))
 
@@ -1586,8 +1589,6 @@ for obj in objects_by_name.values():
 
 
 
-
-
 for obj in managed_objects_by_name.values():
     for property in obj.properties:
         if property.occurrence != OCCURRENCE__IGNORED and \
@@ -1610,15 +1611,11 @@ for obj in managed_objects_by_name.values():
 
 
 
-
-
 for obj in objects_by_name.values():
     inherit_features(obj)
 
 
 
-
-
 types_typedef.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 types_typeenum.write("/* Generated by esx_vi_generator.py */\n\n")
 types_typetostring.write("/* Generated by esx_vi_generator.py */\n\n")
@@ -1627,10 +1624,12 @@ types_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 types_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 methods_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 methods_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+methods_macro.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 helpers_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 helpers_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
 
 
+
 # output enums
 types_typedef.write("/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
                     " * VI Enums\n" +
@@ -1658,8 +1657,6 @@ types_typeenum.write("\n")
 types_typetostring.write("\n")
 types_typefromstring.write("\n")
 
-
-
 names = objects_by_name.keys()
 names.sort()
 
@@ -1682,8 +1679,6 @@ types_typeenum.write("\n")
 types_typetostring.write("\n")
 types_typefromstring.write("\n")
 
-
-
 names = managed_objects_by_name.keys()
 names.sort()
 
@@ -1705,6 +1700,17 @@ for name in names:
     methods_header.write(methods_by_name[name].generate_header())
     methods_source.write(methods_by_name[name].generate_source())
 
+sorted_usage = list(autobind_map_usage)
+sorted_usage.sort()
+
+for usage in sorted_usage:
+    name = autobind_map[usage]
+    string = aligned("#define ESX_VI__METHOD__PARAMETER__THIS__%s " % name, "\\\n", 78)
+    string += "    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \\\n"
+    string += aligned("", "%s)\n\n\n\n" % name, 49)
+
+    methods_macro.write(string)
+
 
 
 # output helpers
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 5967088..1f1780f 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -175,42 +175,6 @@
 
 
 
-#define ESX_VI__METHOD__PARAMETER__THIS__fileManager                          \
-    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \
-                                                 fileManager)
-
-
-
-#define ESX_VI__METHOD__PARAMETER__THIS__perfManager                          \
-    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \
-                                                 perfManager)
-
-
-
-#define ESX_VI__METHOD__PARAMETER__THIS__propertyCollector                    \
-    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \
-                                                 propertyCollector)
-
-
-
-#define ESX_VI__METHOD__PARAMETER__THIS__searchIndex                          \
-    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \
-                                                 searchIndex)
-
-
-
-#define ESX_VI__METHOD__PARAMETER__THIS__sessionManager                       \
-    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \
-                                                 sessionManager)
-
-
-
-#define ESX_VI__METHOD__PARAMETER__THIS__virtualDiskManager                   \
-    ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference,      \
-                                                 virtualDiskManager)
-
-
-
 /*
  * A required parameter must be != 0 (NULL for pointers, "undefined" == 0 for
  * enumeration values).
@@ -248,6 +212,10 @@
 
 
 
+#include "esx_vi_methods.generated.macro"
+
+
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * VI Methods
  */
-- 
1.7.0.4

--
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]