Skip to content
Snippets Groups Projects
Commit ec0fe9e4 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Add my cgen extensions

parent cebdbb60
No related branches found
No related tags found
No related merge requests found
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment