Skip to content

Commit 227e0c6

Browse files
committed
more improvements
1 parent 30d2465 commit 227e0c6

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

gtwrap/template_instantiator/function.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class InstantiatedGlobalFunction(parser.GlobalFunction):
1414
template<T = {double}>
1515
T add(const T& x, const T& y);
1616
"""
17+
1718
def __init__(self, original, instantiations=(), new_name=''):
1819
self.original = original
1920
self.instantiations = instantiations
@@ -54,16 +55,14 @@ def __init__(self, original, instantiations=(), new_name=''):
5455
def to_cpp(self):
5556
"""Generate the C++ code for wrapping."""
5657
if self.original.template:
57-
instantiated_names = [
58+
instantiated_params = [
5859
"::".join(inst.namespaces + [inst.instantiated_name()])
5960
for inst in self.instantiations
6061
]
61-
ret = "{}<{}>".format(self.original.name,
62-
",".join(instantiated_names))
62+
ret = f"{self.original.name}<{','.join(instantiated_params)}>"
6363
else:
6464
ret = self.original.name
6565
return ret
6666

6767
def __repr__(self):
68-
return "Instantiated {}".format(
69-
super(InstantiatedGlobalFunction, self).__repr__())
68+
return f"Instantiated {self.__repr__}"

gtwrap/template_instantiator/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def instantiate_type(
6363
ctype.typename.instantiations[idx].name =\
6464
instantiations[template_idx]
6565

66-
6766
str_arg_typename = str(ctype.typename)
6867

6968
# Check if template is a scoped template e.g. T::Value where T is the template
@@ -88,6 +87,7 @@ def instantiate_type(
8887
is_ref=ctype.is_ref,
8988
is_basic=ctype.is_basic,
9089
)
90+
9191
# Check for exact template match.
9292
elif str_arg_typename in template_typenames:
9393
idx = template_typenames.index(str_arg_typename)
@@ -228,6 +228,7 @@ class InstantiationHelper:
228228
parent=parent)
229229
```
230230
"""
231+
231232
def __init__(self, instantiation_type: InstantiatedMembers):
232233
self.instantiation_type = instantiation_type
233234

0 commit comments

Comments
 (0)