From 8d2a4d24360a1a71bb006043eb4c2fb52048974c Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 6 May 2020 12:00:50 +0000 Subject: [PATCH] clipboard: make compile on linux --- vlib/clipboard/clipboard_linux.c.v | 4 ++++ vlib/v/gen/cgen.v | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/vlib/clipboard/clipboard_linux.c.v b/vlib/clipboard/clipboard_linux.c.v index d61925c93b..96028ff332 100644 --- a/vlib/clipboard/clipboard_linux.c.v +++ b/vlib/clipboard/clipboard_linux.c.v @@ -41,6 +41,9 @@ fn C.BlackPixel() voidptr fn C.WhitePixel() voidptr fn C.XFree() +fn todo_del(){} + +[typedef] struct C.XSelectionRequestEvent{ mut: selection C.Atom @@ -71,6 +74,7 @@ struct C.XSelectionClearEvent{ selection C.Atom } +[typedef] struct C.XDestroyWindowEvent { mut: window C.Window diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 919cd83174..ddf04c0570 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -300,6 +300,11 @@ fn (mut g Gen) typ(t table.Type) string { g.optionals << styp } } + /* + if styp.starts_with('C__') { + return styp[3..] + } + */ return styp } @@ -1175,12 +1180,16 @@ fn (mut g Gen) expr(node ast.Expr) { g.is_amp = false } ast.SizeOf { - if it.type_name != '' { - g.write('sizeof($it.type_name)') - } else { - styp := g.typ(it.typ) - g.write('sizeof(/*typ*/$styp)') + mut styp := it.type_name + if it.type_name == '' { + styp = g.typ(it.typ) } + /* + if styp.starts_with('C__') { + styp = styp[3..] + } + */ + g.write('sizeof($styp)') } ast.StringLiteral { if it.is_raw { @@ -2851,7 +2860,10 @@ fn (g Gen) type_default(typ table.Type) string { sym := g.table.get_type_symbol(typ) if sym.kind == .array { elem_sym := g.table.get_type_symbol(sym.array_info().elem_type) - elem_type_str := elem_sym.name.replace('.', '__') + mut elem_type_str := elem_sym.name.replace('.', '__') + if elem_type_str.starts_with('C__') { + elem_type_str = elem_type_str[3..] + } return '__new_array(0, 1, sizeof($elem_type_str))' } if sym.kind == .map {