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
909e37a5
Commit
909e37a5
authored
Mar 27, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List interop
parent
9dc8cec5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
typon/include/python/builtins/list.hpp
typon/include/python/builtins/list.hpp
+9
-3
typon/trans/tests/a_a_call_py_1.py
typon/trans/tests/a_a_call_py_1.py
+3
-3
typon/trans/transpiler/phases/emit_cpp/visitors.py
typon/trans/transpiler/phases/emit_cpp/visitors.py
+2
-0
No files found.
typon/include/python/builtins/list.hpp
View file @
909e37a5
...
@@ -81,7 +81,7 @@ struct TyList__oo : classtype<_Base0, TyList__oo<>> {
...
@@ -81,7 +81,7 @@ struct TyList__oo : classtype<_Base0, TyList__oo<>> {
}
}
}
static
constexpr
oo__getitem__oo
{};
}
static
constexpr
oo__getitem__oo
{};
template
<
typename
T
>
struct
Obj
:
instanc
e
<
TyList__oo
<>
,
Obj
<
T
>>
{
template
<
typename
T
>
struct
Obj
:
valu
e
<
TyList__oo
<>
,
Obj
<
T
>>
{
using
value_type
=
T
;
using
value_type
=
T
;
std
::
shared_ptr
<
std
::
vector
<
T
>>
_v
;
std
::
shared_ptr
<
std
::
vector
<
T
>>
_v
;
...
@@ -93,14 +93,20 @@ struct TyList__oo : classtype<_Base0, TyList__oo<>> {
...
@@ -93,14 +93,20 @@ struct TyList__oo : classtype<_Base0, TyList__oo<>> {
:
_v
(
std
::
make_shared
<
std
::
vector
<
T
>>
(
std
::
move
(
v
)))
{}
:
_v
(
std
::
make_shared
<
std
::
vector
<
T
>>
(
std
::
move
(
v
)))
{}
Obj
()
:
_v
(
std
::
make_shared
<
std
::
vector
<
T
>>
())
{}
Obj
()
:
_v
(
std
::
make_shared
<
std
::
vector
<
T
>>
())
{}
void
clear
()
{
_v
->
clear
();
}
void
push_back
(
const
T
&
value
)
{
_v
->
push_back
(
value
);
}
size_t
size
()
const
{
return
_v
->
size
();
}
auto
begin
()
const
{
return
_v
->
begin
();
}
auto
end
()
const
{
return
_v
->
end
();
}
};
};
template
<
typename
T
>
auto
operator
()(
std
::
initializer_list
<
T
>
&&
v
)
const
{
template
<
typename
T
>
auto
operator
()(
std
::
initializer_list
<
T
>
&&
v
)
const
{
return
rc
(
Obj
(
std
::
move
(
v
)));
return
(
Obj
(
std
::
move
(
v
)));
}
}
template
<
typename
...
Args
>
auto
operator
()(
Args
&&
...
args
)
const
{
template
<
typename
...
Args
>
auto
operator
()(
Args
&&
...
args
)
const
{
return
rc
(
Obj
(
std
::
forward
<
Args
>
(
args
)...));
return
(
Obj
(
std
::
forward
<
Args
>
(
args
)...));
}
}
/*
/*
...
...
typon/trans/tests/a_a_call_py_1.py
View file @
909e37a5
# test numpy interop
# test numpy interop
#
from numpy import square
from
numpy
import
square
import
math
import
math
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
x
=
[
1
,
2
,
3
,
4
]
x
=
[
1
,
2
,
3
,
4
]
#
y: list[int] = square(x)
y
:
list
[
int
]
=
square
(
x
)
#
print(x, y)
print
(
x
,
y
)
f
:
int
=
math
.
factorial
(
5
)
f
:
int
=
math
.
factorial
(
5
)
print
(
"5! ="
,
f
)
print
(
"5! ="
,
f
)
\ No newline at end of file
typon/trans/transpiler/phases/emit_cpp/visitors.py
View file @
909e37a5
...
@@ -71,6 +71,8 @@ class NodeVisitor(UniversalVisitor):
...
@@ -71,6 +71,8 @@ class NodeVisitor(UniversalVisitor):
yield
"typon::TyNone"
yield
"typon::TyNone"
case
types
.
TY_STR
:
case
types
.
TY_STR
:
yield
'decltype(""_ps)'
yield
'decltype(""_ps)'
case
types
.
TY_LIST
:
yield
"typon::TyList__oo<>::Obj"
case
types
.
TypeVariable
(
name
,
emit_as_is
=
em
,
decltype_str
=
dt
):
case
types
.
TypeVariable
(
name
,
emit_as_is
=
em
,
decltype_str
=
dt
):
if
em
:
if
em
:
yield
name
yield
name
...
...
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