diff --git a/python/dune/perftool/cgen/__init__.py b/python/dune/perftool/cgen/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..de5710209bc084f8dba3f7e6eb0208530d9a11ff --- /dev/null +++ b/python/dune/perftool/cgen/__init__.py @@ -0,0 +1,22 @@ +from __future__ import absolute_import + +from cgen import * + +from dune.perftool.cgen.clazz import Class + + +class Namespace(PrivateNamespace): + """ + A namespace Generable that is provided the name of the namespace. + Normally, you would revert the inheritance here, but I do not want + to interfere with cgen and for some reason it does not provide + explicitly named namespace. + """ + def __init__(self, *args, **kwargs): + name = kwargs.pop("name") + PrivateNamespace.__init__(self, *args, **kwargs) + + self.name = name + + def get_namespace_name(self): + return self.name \ No newline at end of file diff --git a/python/dune/perftool/cgen/clazz.py b/python/dune/perftool/cgen/clazz.py new file mode 100644 index 0000000000000000000000000000000000000000..6b3b715761784ecad4685e736110d9fcb069742c --- /dev/null +++ b/python/dune/perftool/cgen/clazz.py @@ -0,0 +1,17 @@ +from cgen import Generable + +class Class(Generable): + """ Generator for a templated class """ + def __init__(self, name, public_methods = [], tparams=[], constructors=[]): + self.name = name + self.public_methods = public_methods + self.tparams = tparams + + assert isinstance(name, str) + + from cgen import FunctionBody + for m in self.methods: + assert isinstance(n, FunctionBody) + + def generate(self): + yield "class {}".format(self.name) \ No newline at end of file