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
8e1baff7
Commit
8e1baff7
authored
Jun 13, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define wrapper type for shared_ptr
parent
4ff63464
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
rt/include/python/builtins.hpp
rt/include/python/builtins.hpp
+20
-0
trans/transpiler/phases/emit_cpp/__init__.py
trans/transpiler/phases/emit_cpp/__init__.py
+1
-1
trans/transpiler/phases/emit_cpp/class_.py
trans/transpiler/phases/emit_cpp/class_.py
+1
-1
No files found.
rt/include/python/builtins.hpp
View file @
8e1baff7
...
...
@@ -23,6 +23,26 @@
using
namespace
std
::
literals
;
template
<
typename
T
>
concept
PyUserType
=
requires
{
typename
T
::
type
;
};
template
<
typename
T
>
struct
RealType
{
using
type
=
T
;
};
template
<
PyUserType
T
>
struct
RealType
<
T
>
{
using
type
=
typename
T
::
type
;
};
template
<
typename
T
>
using
PyObj
=
std
::
shared_ptr
<
typename
RealType
<
T
>::
type
>
;
template
<
typename
T
,
typename
...
Args
>
auto
pyobj
(
Args
&&
...
args
)
->
PyObj
<
T
>
{
return
std
::
make_shared
<
typename
RealType
<
T
>::
type
>
(
std
::
forward
<
Args
>
(
args
)...);
}
// typon_len
template
<
typename
T
>
...
...
trans/transpiler/phases/emit_cpp/__init__.py
View file @
8e1baff7
...
...
@@ -59,7 +59,7 @@ class NodeVisitor(UniversalVisitor):
elif
node
is
TY_STR
:
yield
"std::string"
elif
isinstance
(
node
,
UserType
):
yield
f"
std::shared_ptr<decltype(
{
node
.
name
}
)::type
>"
yield
f"
PyObj<decltype(
{
node
.
name
}
)
>"
elif
isinstance
(
node
,
TypeType
):
yield
"auto"
# TODO
elif
isinstance
(
node
,
Promise
):
...
...
trans/transpiler/phases/emit_cpp/class_.py
View file @
8e1baff7
...
...
@@ -24,7 +24,7 @@ class ClassVisitor(NodeVisitor):
yield
"};"
yield
"template<typename... T> auto operator()(T&&... args) {"
yield
"return
std::make_shared
<type>(std::forward<T>(args)...);"
yield
"return
pyobj
<type>(std::forward<T>(args)...);"
yield
"}"
outer
=
ClassOuterVisitor
(
node
.
inner_scope
)
...
...
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