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

Builds now

parent 7fb2f104
......@@ -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); }
......
......@@ -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{};
......
......@@ -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)
......
......@@ -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):
......
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