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
4827539e
Commit
4827539e
authored
Apr 10, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix assignment for class types
parent
f5b67d50
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
+4
-5
typon/trans/tests/usertype.py
typon/trans/tests/usertype.py
+3
-5
typon/trans/transpiler/phases/emit_cpp/class_.py
typon/trans/transpiler/phases/emit_cpp/class_.py
+1
-0
No files found.
typon/trans/tests/usertype.py
View file @
4827539e
# coding: utf-8
# coding: utf-8
# norun
# https://lab.nexedi.com/xavier_thompson/typon-snippets/tree/master/references
# https://lab.nexedi.com/xavier_thompson/typon-snippets/tree/master/references
class
Person
:
class
Person
:
name
:
str
name
:
str
...
@@ -13,13 +12,12 @@ class Person:
...
@@ -13,13 +12,12 @@ class Person:
def
afficher
(
self
):
def
afficher
(
self
):
print
(
"afficher"
,
self
.
name
,
self
.
age
)
print
(
"afficher"
,
self
.
name
,
self
.
age
)
#
def creer():
def
creer
():
#
return Person("jean", 123)
return
Person
(
"jean"
,
123
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
y
=
Person
y
=
Person
#x = creer()
x
=
creer
()
x
=
Person
(
"jean"
,
123
)
print
(
"name"
,
x
.
name
)
print
(
"name"
,
x
.
name
)
print
(
"age"
,
x
.
age
)
print
(
"age"
,
x
.
age
)
x
.
afficher
()
x
.
afficher
()
...
...
typon/trans/transpiler/phases/emit_cpp/class_.py
View file @
4827539e
...
@@ -28,6 +28,7 @@ def emit_class(name: str, node: ConcreteType) -> Iterable[str]:
...
@@ -28,6 +28,7 @@ def emit_class(name: str, node: ConcreteType) -> Iterable[str]:
yield
">"
yield
">"
yield
f"struct
{
name
}
__oo : referencemodel::classtype<_Base0,
{
name
}
__oo<>> {{"
yield
f"struct
{
name
}
__oo : referencemodel::classtype<_Base0,
{
name
}
__oo<>> {{"
yield
f"static constexpr std::string_view name =
\
"
{
name
}\
"
;"
yield
f"static constexpr std::string_view name =
\
"
{
name
}\
"
;"
yield
f"auto operator=(const
{
name
}
__oo&) const {{ return *this; }}"
# inner = ClassInnerVisitor2(node.inner_scope)
# inner = ClassInnerVisitor2(node.inner_scope)
# for stmt in node.body:
# for stmt in node.body:
...
...
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