Commit 2355cf46 authored by Tom Niget's avatar Tom Niget

Builds now

parent 7fb2f104
...@@ -826,8 +826,8 @@ private: ...@@ -826,8 +826,8 @@ private:
template <typename T, typename O> struct instance : T { template <typename T, typename O> struct instance : T {
using type = T; using type = T;
/*static constexpr std::string_view repr = static constexpr std::string_view repr =
meta::join<object::object_of_, T::repr>;*/ meta::join<object::object_of_, T::repr>;
const O *operator->() const { return static_cast<const O *>(this); } const O *operator->() const { return static_cast<const O *>(this); }
O *operator->() { return static_cast<O *>(this); } O *operator->() { return static_cast<O *>(this); }
...@@ -839,7 +839,7 @@ template <typename B, typename T> struct classtype : B { ...@@ -839,7 +839,7 @@ template <typename B, typename T> struct classtype : B {
using base = B; using base = B;
using type = T; 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); } const T *operator->() const { return static_cast<const T *>(this); }
T *operator->() { return static_cast<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>; ...@@ -866,7 +866,7 @@ using rebase = typename rebase_s<std::remove_cvref_t<T>>::template type<Rebase>;
template <typename M> struct moduletype : object { template <typename M> struct moduletype : object {
using type = M; 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); } const M *operator->() const { return static_cast<const M *>(this); }
M *operator->() { return static_cast<M *>(this); } M *operator->() { return static_cast<M *>(this); }
......
...@@ -27,26 +27,24 @@ struct socket__oo : referencemodel::moduletype<socket__oo<>> { ...@@ -27,26 +27,24 @@ struct socket__oo : referencemodel::moduletype<socket__oo<>> {
template <typename _Base0 = object> template <typename _Base0 = object>
struct socket_t__oo : referencemodel::classtype<_Base0, socket_t__oo<>> { struct socket_t__oo : referencemodel::classtype<_Base0, socket_t__oo<>> {
static auto create_socket(auto fd) { template<typename T>
struct Obj : referencemodel::instance<socket_t__oo<>, Obj> { struct Obj : referencemodel::instance<socket_t__oo<>, Obj<T>> {
/*Obj(int fd = -1) : fd(fd) {} Obj(int fd = -1) : fd(fd) {}
Obj(const Obj &other) : fd(other.fd) {}*/ Obj(const Obj &other) : fd(other.fd) {}
int fd;
};
return Obj{fd};
}
int fd;
};
struct : referencemodel::method { struct : referencemodel::method {
template<typename T=void>
auto operator()(auto self) -> typon::Task< 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); int connfd = co_await typon::io::accept(self->fd, NULL, NULL);
if (connfd < 0) { if (connfd < 0) {
system_error(-connfd, "accept()"); system_error(-connfd, "accept()");
} }
co_return std::make_tuple(rc(create_socket(connfd)), co_return std::make_tuple(rc(Obj<T>{connfd}),
""_ps); // TODO ""_ps); // TODO
} }
} static constexpr accept{}; } static constexpr accept{};
...@@ -140,17 +138,14 @@ struct socket__oo : referencemodel::moduletype<socket__oo<>> { ...@@ -140,17 +138,14 @@ struct socket__oo : referencemodel::moduletype<socket__oo<>> {
} }
})*/ })*/
template<typename T=void>
auto operator()(int family, int type_) const { auto operator()(int family, int type_) const {
if (int fd = ::socket(family, type_, 0); fd >= 0) { if (int fd = ::socket(family, type_, 0); fd >= 0) {
return rc(create_socket(fd)); return rc(Obj<T>{fd});
} else { } else {
system_error(errno, "socket()"); system_error(errno, "socket()");
} }
} }
}; };
static constexpr socket_t__oo<> socket{}; static constexpr socket_t__oo<> socket{};
......
...@@ -47,11 +47,11 @@ def server_loop(sockfd, filepath): ...@@ -47,11 +47,11 @@ def server_loop(sockfd, filepath):
if __name__ == "__main__": if __name__ == "__main__":
PORT = 8000 PORT = 8000
# if len(sys.argv) > 2: if len(sys.argv) > 2:
# print("Usage: webserver [ filepath ]") print("Usage: webserver [ filepath ]")
# sys.exit(1) 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" filepath = "requirements.txt"
print("Serving", filepath, "on port", PORT) print("Serving", filepath, "on port", PORT)
......
...@@ -27,9 +27,9 @@ def emit_function(name: str, func: CallableInstanceType) -> Iterable[str]: ...@@ -27,9 +27,9 @@ def emit_function(name: str, func: CallableInstanceType) -> Iterable[str]:
yield rty yield rty
yield " {" yield " {"
for var, initval in func.block_data.scope.root_decls.items(): 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 from ExpressionVisitor(func.block_data.scope, mode).visit(initval)
yield ")" yield ")>::type"
yield var yield var
yield ";" yield ";"
yield from BlockVisitor(func.block_data.scope, generator=mode).visit(func.block_data.node.body) yield from BlockVisitor(func.block_data.scope, generator=mode).visit(func.block_data.node.body)
...@@ -212,9 +212,9 @@ class BlockVisitor(NodeVisitor): ...@@ -212,9 +212,9 @@ class BlockVisitor(NodeVisitor):
if allow_auto: if allow_auto:
yield "auto" yield "auto"
else: else:
yield "decltype(" yield "typename std::remove_reference<decltype("
yield from self.expr().visit(declare.initial_value) yield from self.expr().visit(declare.initial_value)
yield ")" yield ")>::type"
#yield from self.visit(lvalue.type) #yield from self.visit(lvalue.type)
yield name yield name
elif isinstance(lvalue, ast.Subscript): elif isinstance(lvalue, ast.Subscript):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment