Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change evhttp_set_cb interface...again

  • Loading branch information...
commit a7d664b42711542fcbdd2d602ca6cfe948a4ac21 1 parent fdeb1b3
@doublec authored
View
4 SATS/libevent.sats
@@ -366,7 +366,7 @@ fun evhttp_free {lh,lb:agz} (base: !event_base lb | http: evhttp (lh, lb)): void
// TODO: void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size);
fun evhttp_set_allowed_methods {lh,lb:agz} (http: !evhttp (lh, lb), methods: uint16):void = "mac#evhttp_set_allowed_methods"
-typedef evhttp_callback (t1:viewt@ype) = (evhttp_request1, !t1) -> void
+typedef evhttp_callback (a:viewt@ype) = (evhttp_request1, &a) -> void
typedef evhttp_callback_ref (t1:viewt@ype) = (!evhttp_request1, &t1) -> void
(* Set a callback that receives the base associated with the evhttp as an argument.
@@ -374,7 +374,7 @@ typedef evhttp_callback_ref (t1:viewt@ype) = (!evhttp_request1, &t1) -> void
*)
fun evhttp_set_cb_with_base {lh,lb:agz} (http: !evhttp (lh, lb), path: string, callback: {lhr:agz} (!evhttp_request lhr, !event_base lb) -> void, arg: !event_base lb): [n:int | n == ~2 || n == ~1 || n == 0] int n = "mac#evhttp_set_cb"
-fun evhttp_set_cb {a:viewt@ype} {l,lh,lb:agz} (pf: !a @ l | http: !evhttp (lh, lb), path: string, callback: evhttp_callback (a), arg: ptr l): [n:int | n == ~2 || n == ~1 || n == 0] int n = "mac#evhttp_set_cb"
+fun evhttp_set_cb {a:viewt@ype} {lh,lb:agz} (http: !evhttp (lh, lb), path: string, callback: evhttp_callback (a), arg: &a): [n:int | n == ~2 || n == ~1 || n == 0] int n = "mac#evhttp_set_cb"
fun evhttp_set_cb_null {lh,lb:agz} (http: !evhttp (lh, lb), path: string, callback: evhttp_callback (ptr), arg: ptr null): [n:int | n == ~2 || n == ~1 || n == 0] int n = "mac#evhttp_set_cb"
fun evhttp_del_cb {lh,lb:agz} (http: !evhttp (lh, lb), path: string): int = "mac#evhttp_del_cb"
View
4 TEST/http-server.dats
@@ -247,8 +247,8 @@ done:
macdef ignore (x) = let val _ = ,(x) in () end
-extern fun dump_request_cb (req: evhttp_request1, arg: !ptr): void = "mac#dump_request_cb"
-extern fun send_document_cb (req: evhttp_request1, arg: !string): void = "mac#send_document_cb"
+extern fun dump_request_cb (req: evhttp_request1, arg: &ptr): void = "mac#dump_request_cb"
+extern fun send_document_cb (req: evhttp_request1, arg: &string): void = "mac#send_document_cb"
fn http_server(docroot: string):void = let
val _ = signal(SIGPIPE, SIG_IGN)
View
8 TEST/http-server2.dats
@@ -3,7 +3,7 @@ staload "contrib/libevent/SATS/libevent.sats"
viewtypedef context (l1:addr) = @{ base= event_base l1 }
viewtypedef context = [l:agz] context l
-fun admin_callback {l:agz} (req: evhttp_request1, ctx: !context l): void = {
+fun admin_callback {l:agz} (req: evhttp_request1, ctx: &context l): void = {
val buffer = evbuffer_new ()
val () = assertloc (~buffer)
val () = evhttp_send_reply (req, 200, "OK", buffer)
@@ -13,7 +13,7 @@ fun admin_callback {l:agz} (req: evhttp_request1, ctx: !context l): void = {
val () = assertloc (r = 0)
}
-fun main_callback {l:agz} (req: evhttp_request1, ctx: !context l): void = {
+fun main_callback {l:agz} (req: evhttp_request1, ctx: &context l): void = {
val buffer = evbuffer_new ()
val () = assertloc (~buffer)
@@ -40,10 +40,10 @@ implement main () = {
var ctx = @{ base= base }
- val r = evhttp_set_cb {context lb} (view@ ctx | http, "/admin", admin_callback, &ctx)
+ val r = evhttp_set_cb {context lb} (http, "/admin", admin_callback, ctx)
val () = assertloc (r = 0)
- val r = evhttp_set_cb {context lb} (view@ ctx | http, "/", main_callback, &ctx)
+ val r = evhttp_set_cb {context lb} (http, "/", main_callback, ctx)
val () = assertloc (r = 0)
val r = evhttp_bind_socket(http, "0.0.0.0", uint16_of_int(8080))
Please sign in to comment.
Something went wrong with that request. Please try again.