Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
2be850ba
Commit
2be850ba
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add generic JSON-like default __repr__ to user types
parent
14b4ddee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
trans/transpiler/phases/emit_cpp/class_.py
trans/transpiler/phases/emit_cpp/class_.py
+15
-0
No files found.
trans/transpiler/phases/emit_cpp/class_.py
View file @
2be850ba
...
...
@@ -24,6 +24,21 @@ class ClassVisitor(NodeVisitor):
yield
"type() {}"
yield
"type(const type&) = delete;"
yield
"type(type&&) = delete;"
yield
"void py_repr(std::ostream &s) const {"
yield
"s << '{';"
for
i
,
(
name
,
memb
)
in
enumerate
(
node
.
type
.
members
.
items
()):
if
i
!=
0
:
yield
's << ", ";'
yield
f's << "
\
\
"
{
name
}\
\
": ";'
yield
f"repr_to(
{
name
}
, s);"
yield
"s << '}';"
yield
"}"
yield
"void py_print(std::ostream &s) const {"
yield
"py_repr(s);"
yield
"}"
yield
"};"
yield
"template<typename... T> auto operator()(T&&... args) {"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment