Added support for cpythonize to generate auxillary info
to stdout. Also added check for of_message_parse to
print out error if wrong version is called.
diff --git a/tools/pylibopenflow/pylib/config.py b/tools/pylibopenflow/pylib/config.py
index bbf1528..b90f630 100644
--- a/tools/pylibopenflow/pylib/config.py
+++ b/tools/pylibopenflow/pylib/config.py
@@ -22,3 +22,8 @@
# Generate dictionary of enum strings to values
GEN_ENUM_DICTIONARY = 1
+
+# Auxilary info: Stuff written to stdout for additional processing
+# Currently generates a (python) map from a class to a list of
+# the data members; used for documentation
+GEN_AUX_INFO = 1
diff --git a/tools/pylibopenflow/pylib/cpythonize.py b/tools/pylibopenflow/pylib/cpythonize.py
index 6a66d7c..2fcdc9f 100644
--- a/tools/pylibopenflow/pylib/cpythonize.py
+++ b/tools/pylibopenflow/pylib/cpythonize.py
@@ -134,6 +134,8 @@
for name in struct_keys:
struct = self.cheader.structs[name]
code.append(self.pycode_struct_size(name, struct))
+ if GEN_AUX_INFO:
+ self.gen_struct_map()
return code
@@ -275,6 +277,27 @@
str(self.rules.get_default_value(struct_in.typename, member.name)))
return code
+ def gen_struct_map(self):
+ print
+ print "# Class to array member map"
+ print "class_to_members_map = {"
+ for name, struct in self.cheader.structs.items():
+ if not len(struct.members):
+ continue
+ s = " '" + name + "'"
+ print s + _space_to(36, s) + ": ["
+ prev = None
+ for member in struct.members:
+ if re.search('pad', member.name):
+ continue
+ if prev:
+ print _space_to(39, "") + "'" + prev + "',"
+ prev = member.name
+ print _space_to(39, "") + "'" + prev + "'"
+ print _space_to(38, "") + "],"
+ print " '_ignore' : []"
+ print "}"
+
def __structassert(self, cstruct, cstructname):
"""Return code to check for C array
"""