refactor(c/libuv): Use cgo alias replace struct assertion in fs
refactro(c/libuv): Use cgo alias avoid implicit struct member declaration
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
package libuv
|
package libuv
|
||||||
|
|
||||||
|
//#cgo pkg-config: libuv
|
||||||
|
//#include <uv.h>
|
||||||
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "unsafe"
|
_ "unsafe"
|
||||||
|
|
||||||
@@ -68,9 +72,7 @@ type File c.Int
|
|||||||
|
|
||||||
/* Handle types. */
|
/* Handle types. */
|
||||||
|
|
||||||
type Fs struct {
|
type Fs C.uv_fs_t
|
||||||
Unused [440]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type FsEvent struct {
|
type FsEvent struct {
|
||||||
Unused [0]byte
|
Unused [0]byte
|
||||||
|
|||||||
@@ -71,17 +71,9 @@ type UdpFlags c.Int
|
|||||||
|
|
||||||
type Tcp C.uv_tcp_t
|
type Tcp C.uv_tcp_t
|
||||||
|
|
||||||
// TODO(spongehah): Handle
|
type Handle C.uv_handle_t
|
||||||
type Handle struct {
|
|
||||||
Data c.Pointer
|
|
||||||
Unused [88]byte
|
|
||||||
// TODO(spongehah): Stream
|
|
||||||
}
|
|
||||||
|
|
||||||
type Stream struct {
|
type Stream C.uv_stream_t
|
||||||
Data c.Pointer
|
|
||||||
Unused [256]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type Shutdown struct {
|
type Shutdown struct {
|
||||||
Unused [0]byte
|
Unused [0]byte
|
||||||
@@ -101,17 +93,9 @@ type UdpSend struct {
|
|||||||
Unused [0]byte
|
Unused [0]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(spongehah): Connect
|
type Connect C.uv_connect_t
|
||||||
type Connect struct {
|
|
||||||
Data c.Pointer
|
|
||||||
Unused [88]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(spongehah): Write
|
type Write C.uv_write_t
|
||||||
type Write struct {
|
|
||||||
Data c.Pointer
|
|
||||||
Unused [184]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetAddrInfo struct {
|
type GetAddrInfo struct {
|
||||||
Unused [0]byte
|
Unused [0]byte
|
||||||
@@ -153,6 +137,12 @@ type ShutdownCb func(req *Shutdown, status c.Int)
|
|||||||
|
|
||||||
/* Handle related function and method */
|
/* Handle related function and method */
|
||||||
|
|
||||||
|
//go:linkname HandleSize C.uv_handle_size
|
||||||
|
func HandleSize(handleType HandleType) uintptr
|
||||||
|
|
||||||
|
//go:linkname HandleTypeName C.uv_handle_type_name
|
||||||
|
func HandleTypeName(handleType HandleType) *c.Char
|
||||||
|
|
||||||
// llgo:link (*Handle).Ref C.uv_ref
|
// llgo:link (*Handle).Ref C.uv_ref
|
||||||
func (handle *Handle) Ref() {}
|
func (handle *Handle) Ref() {}
|
||||||
|
|
||||||
@@ -164,17 +154,11 @@ func (handle *Handle) HasRef() c.Int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname HandleSize C.uv_handle_size
|
|
||||||
func HandleSize(handleType HandleType) uintptr
|
|
||||||
|
|
||||||
// llgo:link (*Handle).GetType C.uv_handle_get_type
|
// llgo:link (*Handle).GetType C.uv_handle_get_type
|
||||||
func (handle *Handle) GetType() HandleType {
|
func (handle *Handle) GetType() HandleType {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname HandleTypeName C.uv_handle_type_name
|
|
||||||
func HandleTypeName(handleType HandleType) *c.Char
|
|
||||||
|
|
||||||
// llgo:link (*Handle).GetData C.uv_handle_get_data
|
// llgo:link (*Handle).GetData C.uv_handle_get_data
|
||||||
func (handle *Handle) GetData() c.Pointer {
|
func (handle *Handle) GetData() c.Pointer {
|
||||||
return nil
|
return nil
|
||||||
@@ -211,16 +195,6 @@ func (handle *Handle) Fileno(fd *OsFd) c.Int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname Pipe C.uv_pipe
|
|
||||||
func Pipe(fds [2]File, readFlags c.Int, writeFlags c.Int) c.Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
//go:linkname Socketpair C.uv_socketpair
|
|
||||||
func Socketpair(_type c.Int, protocol c.Int, socketVector [2]OsSock, flag0 c.Int, flag1 c.Int) c.Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// llgo:link (*Handle).IsClosing C.uv_is_closing
|
// llgo:link (*Handle).IsClosing C.uv_is_closing
|
||||||
func (handle *Handle) IsClosing() c.Int {
|
func (handle *Handle) IsClosing() c.Int {
|
||||||
return 0
|
return 0
|
||||||
@@ -236,6 +210,16 @@ func (handle *Handle) IsWritable() c.Int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:linkname Pipe C.uv_pipe
|
||||||
|
func Pipe(fds [2]File, readFlags c.Int, writeFlags c.Int) c.Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname Socketpair C.uv_socketpair
|
||||||
|
func Socketpair(_type c.Int, protocol c.Int, socketVector [2]OsSock, flag0 c.Int, flag1 c.Int) c.Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
|
|
||||||
/* Req related function and method */
|
/* Req related function and method */
|
||||||
@@ -243,6 +227,9 @@ func (handle *Handle) IsWritable() c.Int {
|
|||||||
//go:linkname ReqSize C.uv_req_size
|
//go:linkname ReqSize C.uv_req_size
|
||||||
func ReqSize(reqType ReqType) uintptr
|
func ReqSize(reqType ReqType) uintptr
|
||||||
|
|
||||||
|
//go:linkname TypeName C.uv_req_type_name
|
||||||
|
func TypeName(reqType ReqType) *c.Char
|
||||||
|
|
||||||
// llgo:link (*Req).GetData C.uv_req_get_data
|
// llgo:link (*Req).GetData C.uv_req_get_data
|
||||||
func (req *Req) GetData() c.Pointer {
|
func (req *Req) GetData() c.Pointer {
|
||||||
return nil
|
return nil
|
||||||
@@ -256,9 +243,6 @@ func (req *Req) GetType() ReqType {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname TypeName C.uv_req_type_name
|
|
||||||
func TypeName(reqType ReqType) *c.Char
|
|
||||||
|
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
|
|
||||||
/* Stream related function and method */
|
/* Stream related function and method */
|
||||||
@@ -378,14 +362,14 @@ func (tcp *Tcp) CloseReset(closeCb CloseCb) c.Int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname TcpConnect C.uv_tcp_connect
|
|
||||||
func TcpConnect(req *Connect, tcp *Tcp, addr *net.SockAddr, connectCb ConnectCb) c.Int
|
|
||||||
|
|
||||||
func (tcp *Tcp) GetIoWatcherFd() c.Int {
|
func (tcp *Tcp) GetIoWatcherFd() c.Int {
|
||||||
tcp_s := (*C.uv_tcp_t)(c.Pointer(tcp))
|
tcp_s := (*C.uv_tcp_t)(c.Pointer(tcp))
|
||||||
return c.Int(tcp_s.io_watcher.fd)
|
return c.Int(tcp_s.io_watcher.fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:linkname TcpConnect C.uv_tcp_connect
|
||||||
|
func TcpConnect(req *Connect, tcp *Tcp, addr *net.SockAddr, connectCb ConnectCb) c.Int
|
||||||
|
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
|
|
||||||
/* Udp related function and method */
|
/* Udp related function and method */
|
||||||
@@ -456,9 +440,6 @@ func (udp *Udp) SetTTL(ttl c.Int) c.Int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname Send C.uv_udp_send
|
|
||||||
func Send(req *UdpSend, udp *Udp, bufs *Buf, nbufs c.Uint, addr *net.SockAddr, sendCb UdpSendCb) c.Int
|
|
||||||
|
|
||||||
// llgo:link (*Udp).TrySend C.uv_udp_try_send
|
// llgo:link (*Udp).TrySend C.uv_udp_try_send
|
||||||
func (udp *Udp) TrySend(bufs *Buf, nbufs c.Uint, addr *net.SockAddr) c.Int {
|
func (udp *Udp) TrySend(bufs *Buf, nbufs c.Uint, addr *net.SockAddr) c.Int {
|
||||||
return 0
|
return 0
|
||||||
@@ -489,8 +470,13 @@ func (udp *Udp) GetSendQueueCount() uintptr {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:linkname Send C.uv_udp_send
|
||||||
|
func Send(req *UdpSend, udp *Udp, bufs *Buf, nbufs c.Uint, addr *net.SockAddr, sendCb UdpSendCb) c.Int
|
||||||
|
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
|
|
||||||
|
/* DNS related function and method */
|
||||||
|
|
||||||
//go:linkname Ip4Addr C.uv_ip4_addr
|
//go:linkname Ip4Addr C.uv_ip4_addr
|
||||||
func Ip4Addr(ip *c.Char, port c.Int, addr *net.SockaddrIn) c.Int
|
func Ip4Addr(ip *c.Char, port c.Int, addr *net.SockaddrIn) c.Int
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user