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
2355cf46
Commit
2355cf46
authored
Mar 15, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Builds now
parent
7fb2f104
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
28 deletions
+23
-28
typon/include/python/referencemodel.hpp
typon/include/python/referencemodel.hpp
+4
-4
typon/include/python/socket.hpp
typon/include/python/socket.hpp
+11
-16
typon/trans/tests/webserver.py
typon/trans/tests/webserver.py
+4
-4
typon/trans/transpiler/phases/emit_cpp/function.py
typon/trans/transpiler/phases/emit_cpp/function.py
+4
-4
No files found.
typon/include/python/referencemodel.hpp
View file @
2355cf46
...
...
@@ -826,8 +826,8 @@ private:
template
<
typename
T
,
typename
O
>
struct
instance
:
T
{
using
type
=
T
;
/*
static constexpr std::string_view repr =
meta::join<object::object_of_, T::repr>;
*/
static
constexpr
std
::
string_view
repr
=
meta
::
join
<
object
::
object_of_
,
T
::
repr
>
;
const
O
*
operator
->
()
const
{
return
static_cast
<
const
O
*>
(
this
);
}
O
*
operator
->
()
{
return
static_cast
<
O
*>
(
this
);
}
...
...
@@ -839,7 +839,7 @@ template <typename B, typename T> struct classtype : B {
using
base
=
B
;
using
type
=
T
;
//
static constexpr std::string_view repr = meta::join<object::class_, T::name>;
static
constexpr
std
::
string_view
repr
=
meta
::
join
<
object
::
class_
,
T
::
name
>
;
const
T
*
operator
->
()
const
{
return
static_cast
<
const
T
*>
(
this
);
}
T
*
operator
->
()
{
return
static_cast
<
T
*>
(
this
);
}
...
...
@@ -866,7 +866,7 @@ using rebase = typename rebase_s<std::remove_cvref_t<T>>::template type<Rebase>;
template
<
typename
M
>
struct
moduletype
:
object
{
using
type
=
M
;
//
static constexpr std::string_view repr = meta::join<object::module_, M::name>;
static
constexpr
std
::
string_view
repr
=
meta
::
join
<
object
::
module_
,
M
::
name
>
;
const
M
*
operator
->
()
const
{
return
static_cast
<
const
M
*>
(
this
);
}
M
*
operator
->
()
{
return
static_cast
<
M
*>
(
this
);
}
...
...
typon/include/python/socket.hpp
View file @
2355cf46
...
...
@@ -27,26 +27,24 @@ struct socket__oo : referencemodel::moduletype<socket__oo<>> {
template
<
typename
_Base0
=
object
>
struct
socket_t__oo
:
referencemodel
::
classtype
<
_Base0
,
socket_t__oo
<>>
{
static
auto
create_socket
(
auto
fd
)
{
struct
Obj
:
referencemodel
::
instance
<
socket_t__oo
<>
,
Obj
>
{
/*
Obj(int fd = -1) : fd(fd) {}
template
<
typename
T
>
struct
Obj
:
referencemodel
::
instance
<
socket_t__oo
<>
,
Obj
<
T
>
>
{
Obj
(
int
fd
=
-
1
)
:
fd
(
fd
)
{}
Obj(const Obj &other) : fd(other.fd) {}*/
int
fd
;
};
return
Obj
{
fd
};
}
Obj
(
const
Obj
&
other
)
:
fd
(
other
.
fd
)
{}
int
fd
;
};
struct
:
referencemodel
::
method
{
template
<
typename
T
=
void
>
auto
operator
()(
auto
self
)
->
typon
::
Task
<
std
::
tuple
<
decltype
(
rc
(
create_socket
(
-
1
)
)),
decltype
(
""
_ps
)
>>
const
{
std
::
tuple
<
decltype
(
rc
(
Obj
<
T
>
{
-
1
}
)),
decltype
(
""
_ps
)
>>
const
{
int
connfd
=
co_await
typon
::
io
::
accept
(
self
->
fd
,
NULL
,
NULL
);
if
(
connfd
<
0
)
{
system_error
(
-
connfd
,
"accept()"
);
}
co_return
std
::
make_tuple
(
rc
(
create_socket
(
connfd
)
),
co_return
std
::
make_tuple
(
rc
(
Obj
<
T
>
{
connfd
}
),
""
_ps
);
// TODO
}
}
static
constexpr
accept
{};
...
...
@@ -140,17 +138,14 @@ struct socket__oo : referencemodel::moduletype<socket__oo<>> {
}
})*/
template
<
typename
T
=
void
>
auto
operator
()(
int
family
,
int
type_
)
const
{
if
(
int
fd
=
::
socket
(
family
,
type_
,
0
);
fd
>=
0
)
{
return
rc
(
create_socket
(
fd
)
);
return
rc
(
Obj
<
T
>
{
fd
}
);
}
else
{
system_error
(
errno
,
"socket()"
);
}
}
};
static
constexpr
socket_t__oo
<>
socket
{};
...
...
typon/trans/tests/webserver.py
View file @
2355cf46
...
...
@@ -47,11 +47,11 @@ def server_loop(sockfd, filepath):
if
__name__
==
"__main__"
:
PORT
=
8000
#
if len(sys.argv) > 2:
#
print("Usage: webserver [ filepath ]")
#
sys.exit(1)
if
len
(
sys
.
argv
)
>
2
:
print
(
"Usage: webserver [ filepath ]"
)
sys
.
exit
(
1
)
#filepath = sys.argv[1] if len(sys.argv) == 2 else "requirements.txt"
#
filepath = sys.argv[1] if len(sys.argv) == 2 else "requirements.txt"
filepath
=
"requirements.txt"
print
(
"Serving"
,
filepath
,
"on port"
,
PORT
)
...
...
typon/trans/transpiler/phases/emit_cpp/function.py
View file @
2355cf46
...
...
@@ -27,9 +27,9 @@ def emit_function(name: str, func: CallableInstanceType) -> Iterable[str]:
yield
rty
yield
" {"
for
var
,
initval
in
func
.
block_data
.
scope
.
root_decls
.
items
():
yield
"
decltype("
yield
"
typename std::remove_reference<decltype("
# TODO: duplicate code in visit_lvalue
yield
from
ExpressionVisitor
(
func
.
block_data
.
scope
,
mode
).
visit
(
initval
)
yield
")"
yield
")
>::type
"
yield
var
yield
";"
yield
from
BlockVisitor
(
func
.
block_data
.
scope
,
generator
=
mode
).
visit
(
func
.
block_data
.
node
.
body
)
...
...
@@ -212,9 +212,9 @@ class BlockVisitor(NodeVisitor):
if
allow_auto
:
yield
"auto"
else
:
yield
"decltype("
yield
"
typename std::remove_reference<
decltype("
yield
from
self
.
expr
().
visit
(
declare
.
initial_value
)
yield
")"
yield
")
>::type
"
#yield from self.visit(lvalue.type)
yield
name
elif
isinstance
(
lvalue
,
ast
.
Subscript
):
...
...
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