Aurel Bílý %!s(int64=6) %!d(string=hai) anos
pai
achega
25e842b7f6
Modificáronse 3 ficheiros con 29 adicións e 0 borrados
  1. 2 0
      libs/uv/uv.ml
  2. 18 0
      libs/uv/uv_stubs.c
  3. 9 0
      src/macro/eval/evalStdLib.ml

+ 2 - 0
libs/uv/uv.ml

@@ -260,3 +260,5 @@ external pipe_init : t_loop -> bool -> t_pipe uv_result = "w_pipe_init"
 external pipe_accept : t_loop -> t_pipe -> t_pipe uv_result = "w_pipe_accept"
 external pipe_bind_ipc : t_pipe -> string -> unit uv_result = "w_pipe_bind_ipc"
 external pipe_connect_ipc : t_pipe -> string -> unit_cb -> unit uv_result = "w_pipe_connect_ipc"
+external pipe_getsockname : t_pipe -> string uv_result = "w_pipe_getsockname"
+external pipe_getpeername : t_pipe -> string uv_result = "w_pipe_getpeername"

+ 18 - 0
libs/uv/uv_stubs.c

@@ -1199,3 +1199,21 @@ CAMLprim value w_pipe_connect_ipc(value handle, value path, value cb) {
 	uv_pipe_connect(Connect_val(req), Pipe_val(handle), String_val(path), (void (*)(uv_connect_t *, int))handle_stream_cb);
 	UV_SUCCESS_UNIT;
 }
+
+CAMLprim value w_pipe_getsockname(value handle) {
+	CAMLparam1(handle);
+	char path[256];
+	size_t path_size = 255;
+	UV_ERROR_CHECK(uv_pipe_getsockname(Pipe_val(handle), path, &path_size));
+	path[path_size] = 0;
+	UV_SUCCESS(caml_copy_string(path));
+}
+
+CAMLprim value w_pipe_getpeername(value handle) {
+	CAMLparam1(handle);
+	char path[256];
+	size_t path_size = 255;
+	UV_ERROR_CHECK(uv_pipe_getpeername(Pipe_val(handle), path, &path_size));
+	path[path_size] = 0;
+	UV_SUCCESS(caml_copy_string(path));
+}

+ 9 - 0
src/macro/eval/evalStdLib.ml

@@ -3767,6 +3767,13 @@ module StdUv = struct
 			wrap_sync (Uv.pipe_connect_ipc this path (wrap_cb_unit cb));
 			vnull
 		)
+		let getName fn = vifun0 (fun vthis ->
+			let this = this vthis in
+			let path = wrap_sync (fn this) in
+			encode_enum_value key_nusys_net_SocketAddress 1 [|encode_string path|] None
+		)
+		let getSockName = getName Uv.pipe_getsockname
+		let getPeerName = getName Uv.pipe_getpeername
 		let asStream = vifun0 (fun vthis ->
 			let this = this vthis in
 			let stream = Uv.stream_of_handle this in
@@ -4619,6 +4626,8 @@ let init_standard_library builtins =
 		"accept",StdUv.Pipe.accept;
 		"bindIpc",StdUv.Pipe.bindIpc;
 		"connectIpc",StdUv.Pipe.connectIpc;
+		"getSockName",StdUv.Pipe.getSockName;
+		"getPeerName",StdUv.Pipe.getPeerName;
 		"asStream",StdUv.Pipe.asStream;
 	];
 	init_fields builtins (["eval";"uv"],"Stream") [] [