mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.openssl: add manual .str() methods for C.SSL and C.SSL_CTX, fix a bug in the V auto str generation as well.
This commit is contained in:
parent
522a9f5908
commit
36dc7faf2c
@ -42,6 +42,18 @@ pub struct C.SSL {
|
|||||||
pub struct C.SSL_CTX {
|
pub struct C.SSL_CTX {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The above C structs, have incomplete declarations in the OpenSSL headers.
|
||||||
|
// For this reason, we have to prevent the automatic str() generation for them,
|
||||||
|
// by adding manual implementations of their .str() methods, that are defined on
|
||||||
|
// pointers to them:
|
||||||
|
fn (s &C.SSL) str() string {
|
||||||
|
return 'C.SSL(0x${voidptr(s)})'
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (c &C.SSL_CTX) str() string {
|
||||||
|
return 'C.SSL_CTX(0x${voidptr(c)})'
|
||||||
|
}
|
||||||
|
|
||||||
fn C.BIO_new_ssl_connect(ctx &C.SSL_CTX) &C.BIO
|
fn C.BIO_new_ssl_connect(ctx &C.SSL_CTX) &C.BIO
|
||||||
|
|
||||||
fn C.BIO_set_conn_hostname(b &C.BIO, name &char) int
|
fn C.BIO_set_conn_hostname(b &C.BIO, name &char) int
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
import net.openssl
|
import net.openssl
|
||||||
|
|
||||||
|
struct Abc {
|
||||||
|
x &C.SSL_CTX
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_printing_struct_with_reference_field_of_type_ssl_ctx() {
|
||||||
|
a := Abc{&C.SSL_CTX(123)}
|
||||||
|
dump(a)
|
||||||
|
sa := a.str()
|
||||||
|
assert sa.contains('&C.SSL_CTX(0x7b)')
|
||||||
|
}
|
||||||
|
|
||||||
fn test_openssl_compiles() {
|
fn test_openssl_compiles() {
|
||||||
assert openssl.is_used == 1
|
assert openssl.is_used == 1
|
||||||
assert true
|
assert true
|
||||||
|
@ -912,7 +912,6 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, styp string, typ_str string,
|
|||||||
} else {
|
} else {
|
||||||
g.get_str_fn(ftyp_noshared)
|
g.get_str_fn(ftyp_noshared)
|
||||||
}
|
}
|
||||||
|
|
||||||
// with floats we use always the g representation:
|
// with floats we use always the g representation:
|
||||||
if sym.kind !in [.f32, .f64] {
|
if sym.kind !in [.f32, .f64] {
|
||||||
fn_body.write_string('{_SLIT("${quote_str}"), ${int(base_fmt)}, {.${data_str(base_fmt)}=')
|
fn_body.write_string('{_SLIT("${quote_str}"), ${int(base_fmt)}, {.${data_str(base_fmt)}=')
|
||||||
|
@ -435,6 +435,9 @@ fn (mut g Gen) c_fn_name(node &ast.FnDecl) !string {
|
|||||||
return error('none')
|
return error('none')
|
||||||
}
|
}
|
||||||
name = g.cc_type(node.receiver.typ, false) + '_' + name
|
name = g.cc_type(node.receiver.typ, false) + '_' + name
|
||||||
|
if unwrapped_rec_sym.language == .c {
|
||||||
|
name = name.replace_once('C__', '')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if node.language == .c {
|
if node.language == .c {
|
||||||
name = util.no_dots(name)
|
name = util.no_dots(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user