cgen: optimize/generalize typ method
parent
956bf23390
commit
d048bf66b0
|
@ -61,7 +61,8 @@ pub enum FormatDelimiter {
|
||||||
space
|
space
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct C.time_t {}
|
// TODO: C.time_t. works in v2
|
||||||
|
type time_t voidptr
|
||||||
|
|
||||||
pub struct C.timeval {
|
pub struct C.timeval {
|
||||||
tv_sec u64
|
tv_sec u64
|
||||||
|
@ -70,7 +71,7 @@ pub struct C.timeval {
|
||||||
|
|
||||||
fn C.localtime(int) &C.tm
|
fn C.localtime(int) &C.tm
|
||||||
|
|
||||||
fn C.time(int) C.time_t
|
fn C.time(int) time_t
|
||||||
|
|
||||||
// now returns current local time.
|
// now returns current local time.
|
||||||
pub fn now() Time {
|
pub fn now() Time {
|
||||||
|
|
|
@ -148,10 +148,9 @@ pub fn (g mut Gen) typ(t table.Type) string {
|
||||||
}
|
}
|
||||||
if styp.starts_with('C__') {
|
if styp.starts_with('C__') {
|
||||||
styp = styp[3..]
|
styp = styp[3..]
|
||||||
}
|
if sym.kind == .struct_ {
|
||||||
if styp in ['stat', 'dirent*', 'tm', 'tm*', 'winsize', 'sigaction', 'timeval'] {
|
styp = 'struct $styp'
|
||||||
// TODO perf and other C structs
|
}
|
||||||
styp = 'struct $styp'
|
|
||||||
}
|
}
|
||||||
if table.type_is_optional(t) {
|
if table.type_is_optional(t) {
|
||||||
styp = 'Option_' + styp
|
styp = 'Option_' + styp
|
||||||
|
|
Loading…
Reference in New Issue