Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] stdlib: Updated bslSocket for plugins.

  • Loading branch information...
commit 89c16e1ac64ccc5c991569d3101c1bbbd14ea316 1 parent 25a2f7a
Norman Scaife nrs135 authored
1  opabsl/mlbsl/bslMongo.ml
View
@@ -26,6 +26,7 @@ open C.Ops
##extern-type cursorID = int64
##extern-type mailbox = (Buf.t * int ref)
##extern-type reply = (Buf.t * int * int)
+##extern-type Socket.connection = Scheduler.connection_info
##module Bson
2  plugins/socket/_tags
View
@@ -1 +1 @@
-<socket.opa_plugin>: use_qmlcps, use_libsecurity, use_libnet, use_appruntime
+<socket.opa_plugin>: use_qmlcps, use_libsecurity, use_libnet, use_appruntime, use_opabsl
28 plugins/socket/bslSocket.ml
View
@@ -18,6 +18,9 @@
module C = QmlCpsServerLib
open C.Ops
+open OpabslgenMLRuntime
+
+##opa-type outcome('a, 'b)
##property [mli]
##extern-type continuation('a) = 'a QmlCpsServerLib.continuation
@@ -26,6 +29,15 @@ open C.Ops
##extern-type Socket.connection = Scheduler.connection_info
+(*let temporary_hack o = wrap_opa_outcome (BslUtils.unwrap_opa_outcome o)
+
+# # register [cps-bypass] test : string, continuation(outcome(string, int)) \
+ -> void
+let test (s:string) k = QmlCpsServerLib.return k (temporary_hack (BslUtils.create_outcome (`success s)))*)
+
+let create_outcome outcome k =
+ QmlCpsServerLib.return k (wrap_opa_outcome (BslUtils.unwrap_opa_outcome (BslUtils.create_outcome outcome)))
+
let private_connect ?(secure_mode = Network.Unsecured) (addr: string) port
(cont: Scheduler.connection_info -> unit) =
let inet_addr = Network.inet_addr_of_name addr in
@@ -47,8 +59,8 @@ let private_connect_with_err_cont ?(secure_mode = Network.Unsecured) addr port c
let inet_addr = Network.inet_addr_of_name addr in
let port_spec = Network.make_port_spec ~socket_type:Network.TCP ~protocol:"raw" inet_addr port in
Network.connect Scheduler.default port_spec secure_mode
- ~err_cont:(fun exn -> BslUtils.create_outcome (`failure (Printexc.to_string exn)) |> cont)
- (fun conn -> BslUtils.create_outcome (`success conn) |> cont)
+ ~err_cont:(fun exn -> create_outcome (`failure (Printexc.to_string exn)) cont)
+ (fun conn -> create_outcome (`success conn) cont)
##register [cps-bypass] connect_with_err_cont: string, int,\
continuation(outcome(Socket.connection,string)) -> void
@@ -72,8 +84,8 @@ let write connection_info data k =
continuation(outcome(int,string)) -> void
let write_with_err_cont connection_info timeout data cont =
Scheduler.write Scheduler.default connection_info ~timeout:(Time.milliseconds timeout) data
- ~err_cont:(fun exn -> BslUtils.create_outcome (`failure (Printexc.to_string exn)) |> cont)
- (fun cnt -> BslUtils.create_outcome (`success cnt) |> cont)
+ ~err_cont:(fun exn -> create_outcome (`failure (Printexc.to_string exn)) cont)
+ (fun cnt -> create_outcome (`success cnt) cont)
##register [cps-bypass] write_len: Socket.connection, string, int,\
continuation(int) -> void
@@ -84,8 +96,8 @@ let write_len connection_info data len k =
continuation(outcome(int,string)) -> void
let write_len_with_err_cont connection_info timeout data len cont =
Scheduler.write Scheduler.default connection_info ~timeout:(Time.milliseconds timeout) data ~len
- ~err_cont:(fun exn -> BslUtils.create_outcome (`failure (Printexc.to_string exn)) |> cont)
- (fun cnt -> BslUtils.create_outcome (`success cnt) |> cont)
+ ~err_cont:(fun exn -> create_outcome (`failure (Printexc.to_string exn)) cont)
+ (fun cnt -> create_outcome (`success cnt) cont)
##register [cps-bypass] read : Socket.connection, continuation(string) -> void
let read connection_info k =
@@ -94,5 +106,5 @@ let read connection_info k =
##register [cps-bypass] read_with_err_cont : Socket.connection, int, continuation(outcome(string,string)) -> void
let read_with_err_cont connection_info timeout cont =
Scheduler.read Scheduler.default connection_info ~timeout:(Time.milliseconds timeout)
- ~err_cont:(fun exn -> BslUtils.create_outcome (`failure (Printexc.to_string exn)) |> cont)
- (fun (_,str) -> BslUtils.create_outcome (`success str) |> cont)
+ ~err_cont:(fun exn -> create_outcome (`failure (Printexc.to_string exn)) cont)
+ (fun (_,str) -> create_outcome (`success str) cont)
Please sign in to comment.
Something went wrong with that request. Please try again.