Add opt_ffinv pass.
[yosys.git] / misc / py_wrap_generator.py
index c60a1f2680cb6383bc86f180b37f1531fef3167b..4d9a60113267991aee9e2d63d94f423c5776378e 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  yosys -- Yosys Open SYnthesis Suite
 #
-#  Copyright (C) 2012  Clifford Wolf <clifford@clifford.at>
+#  Copyright (C) 2012  Claire Xenia Wolf <claire@yosyshq.com>
 #
 #  Permission to use, copy, modify, and/or distribute this software for any
 #  purpose with or without fee is hereby granted, provided that the above
@@ -312,16 +312,16 @@ class PythonListTranslator(Translator):
                        text += prefix + "\t" + known_containers[types[0].name].typename + " " + tmp_name + " = boost::python::extract<" + known_containers[types[0].name].typename + ">(" + varname + "[" + cntr_name + "]);"
                        text += known_containers[types[0].name].translate(tmp_name, types[0].cont.args, prefix+"\t")
                        tmp_name = tmp_name + "___tmp"
-                       text += prefix + "\t" + varname + "___tmp." + c.insert_name + "(" + tmp_name + ");"
+                       text += prefix + "\t" + varname + "___tmp" + c.insert_name + "(" + tmp_name + ");"
                elif types[0].name in classnames:
                        text += prefix + "\t" + types[0].name + "* " + tmp_name + " = boost::python::extract<" + types[0].name + "*>(" + varname + "[" + cntr_name + "]);"
                        if types[0].attr_type == attr_types.star:
-                               text += prefix + "\t" + varname + "___tmp." + c.insert_name + "(" + tmp_name + "->get_cpp_obj());"
+                               text += prefix + "\t" + varname + "___tmp" + c.insert_name + "(" + tmp_name + "->get_cpp_obj());"
                        else:
-                               text += prefix + "\t" + varname + "___tmp." + c.insert_name + "(*" + tmp_name + "->get_cpp_obj());"
+                               text += prefix + "\t" + varname + "___tmp" + c.insert_name + "(*" + tmp_name + "->get_cpp_obj());"
                else:
                        text += prefix + "\t" + types[0].name + " " + tmp_name + " = boost::python::extract<" + types[0].name + ">(" + varname + "[" + cntr_name + "]);"
-                       text += prefix + "\t" + varname + "___tmp." + c.insert_name + "(" + tmp_name + ");"
+                       text += prefix + "\t" + varname + "___tmp" + c.insert_name + "(" + tmp_name + ");"
                text += prefix + "}"
                return text
 
@@ -349,19 +349,24 @@ class PythonListTranslator(Translator):
                text += prefix + "}"
                return text
 
+class IDictTranslator(PythonListTranslator):
+       typename = "boost::python::list"
+       orig_name = "idict"
+       insert_name = ""
+
 #Sub-type for std::set
 class SetTranslator(PythonListTranslator):
-       insert_name = "insert"
+       insert_name = ".insert"
        orig_name = "std::set"
 
 #Sub-type for std::vector
 class VectorTranslator(PythonListTranslator):
-       insert_name = "push_back"
+       insert_name = ".push_back"
        orig_name = "std::vector"
 
 #Sub-type for pool
 class PoolTranslator(PythonListTranslator):
-       insert_name = "insert"
+       insert_name = ".insert"
        orig_name = "pool"
 
 #Translates dict-types (dict, std::map), that only differ in their name and
@@ -528,6 +533,7 @@ known_containers = {
        "std::set"              :       SetTranslator,
        "std::vector"   :       VectorTranslator,
        "pool"                  :       PoolTranslator,
+       "idict"                 :       IDictTranslator,
        "dict"                  :       DictTranslator,
        "std::pair"             :       TupleTranslator,
        "std::map"              :       MapTranslator
@@ -806,6 +812,8 @@ class WClass:
 
                        for con in self.found_constrs:
                                text += con.gen_decl()
+                       if self.base_class is not None:
+                               text += "\n\t\tvirtual ~" + self.name + "() { };"
                        for var in self.found_vars:
                                text += var.gen_decl()
                        for fun in self.found_funs:
@@ -910,15 +918,19 @@ class WClass:
 
        def gen_boost_py(self):
                body = self.gen_boost_py_body()
+               base_info = ""
+               if self.base_class is not None:
+                       base_info = ", bases<" + (self.base_class.name) + ">"
+
                if self.link_type == link_types.derive:
-                       text = "\n\t\tclass_<" + self.name + ">(\"Cpp" + self.name + "\""
+                       text = "\n\t\tclass_<" + self.name + base_info + ">(\"Cpp" + self.name + "\""
                        text += body
                        text += "\n\t\tclass_<" + self.name
                        text += "Wrap, boost::noncopyable"
                        text += ">(\"" + self.name + "\""
                        text += body
                else:
-                       text = "\n\t\tclass_<" + self.name + ">(\"" + self.name + "\""
+                       text = "\n\t\tclass_<" + self.name + base_info + ">(\"" + self.name + "\""
                        text += body
                return text
        
@@ -985,7 +997,7 @@ sources = [
        Source("kernel/cost",[])
        ]
 
-blacklist_methods = ["YOSYS_NAMESPACE::Pass::run_register", "YOSYS_NAMESPACE::Module::Pow", "YOSYS_NAMESPACE::Module::Bu0", "YOSYS_NAMESPACE::CaseRule::optimize"]
+blacklist_methods = ["YOSYS_NAMESPACE::Pass::run_register", "YOSYS_NAMESPACE::Module::Pow"]
 
 enum_names = ["State","SyncType","ConstFlags"]
 
@@ -1402,7 +1414,7 @@ class WFunction:
                        text += ", "
                if len(self.args) > 0:
                        text = text[:-2]
-               text += ") YS_OVERRIDE;\n"
+               text += ") override;\n"
                return text
 
        def gen_decl_hash_py(self):
@@ -2231,7 +2243,7 @@ def gen_wrappers(filename, debug_level_ = 0):
 """/*
  *  yosys -- Yosys Open SYnthesis Suite
  *
- *  Copyright (C) 2012  Clifford Wolf <clifford@clifford.at>
+ *  Copyright (C) 2012  Claire Xenia Wolf <claire@yosyshq.com>
  *
  *  Permission to use, copy, modify, and/or distribute this software for any
  *  purpose with or without fee is hereby granted, provided that the above