1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: check (mut f Foo) syntax

This commit is contained in:
yuyi
2020-05-17 19:51:18 +08:00
committed by GitHub
parent b138cadbcb
commit 7f4cf08516
87 changed files with 492 additions and 480 deletions

View File

@@ -6,22 +6,22 @@ pub fn new() &Clipboard {
}
// copy some text into the clipboard
pub fn (cb mut Clipboard) copy(text string) bool {
pub fn (mut cb Clipboard) copy(text string) bool {
return cb.set_text(text)
}
// get the text from the clipboard
pub fn (cb mut Clipboard) paste() string {
pub fn (mut cb Clipboard) paste() string {
return cb.get_text()
}
// clear the clipboard
pub fn (cb mut Clipboard) clear_all() {
pub fn (mut cb Clipboard) clear_all() {
cb.clear()
}
// destroy the clipboard
pub fn (cb mut Clipboard) destroy() {
pub fn (mut cb Clipboard) destroy() {
cb.free()
}

View File

@@ -25,12 +25,12 @@ fn (cb &Clipboard) check_availability() bool {
return cb.pb != C.NULL
}
fn (cb mut Clipboard) clear(){
fn (mut cb Clipboard) clear(){
cb.foo = 0
#[cb->pb clearContents];
}
fn (cb mut Clipboard) free(){
fn (mut cb Clipboard) free(){
cb.foo = 0
//nothing to free
}
@@ -43,7 +43,7 @@ fn (cb &Clipboard) has_ownership() bool {
fn C.OSAtomicCompareAndSwapLong()
fn (cb mut Clipboard) set_text(text string) bool {
fn (mut cb Clipboard) set_text(text string) bool {
cb.foo = 0
#NSString *ns_clip;
ret := false
@@ -59,7 +59,7 @@ fn (cb mut Clipboard) set_text(text string) bool {
return ret
}
fn (cb mut Clipboard) get_text() string {
fn (mut cb Clipboard) get_text() string {
cb.foo = 0
#NSString *ns_clip;
utf8_clip := byteptr(0)

View File

@@ -172,14 +172,14 @@ fn (cb &Clipboard) check_availability() bool {
return cb.display != C.NULL
}
fn (cb mut Clipboard) free() {
fn (mut cb Clipboard) free() {
C.XDestroyWindow(cb.display, cb.window)
cb.window = C.Window(C.None)
//FIX ME: program hangs when closing display
//XCloseDisplay(cb.display)
}
fn (cb mut Clipboard) clear(){
fn (mut cb Clipboard) clear(){
cb.mutex.lock()
C.XSetSelectionOwner(cb.display, cb.selection, C.Window(C.None), C.CurrentTime)
C.XFlush(cb.display)
@@ -197,7 +197,7 @@ fn (cb &Clipboard) take_ownership(){
C.XFlush(cb.display)
}
fn (cb mut Clipboard) set_text(text string) bool {
fn (mut cb Clipboard) set_text(text string) bool {
if cb.window == C.Window(C.None) {return false}
cb.mutex.lock()
cb.text = text
@@ -210,7 +210,7 @@ fn (cb mut Clipboard) set_text(text string) bool {
return cb.is_owner
}
fn (cb mut Clipboard) get_text() string {
fn (mut cb Clipboard) get_text() string {
if cb.window == C.Window(C.None) {return ""}
if cb.is_owner {
return cb.text
@@ -232,7 +232,7 @@ fn (cb mut Clipboard) get_text() string {
// this function is crucial to handling all the different data types
// if we ever support other mimetypes they should be handled here
fn (cb mut Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
fn (mut cb Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
if xse.target == cb.get_atom(.targets) {
targets := cb.get_supported_targets()
C.XChangeProperty(xse.display, xse.requestor, xse.property, cb.get_atom(.xa_atom), 32, C.PropModeReplace, targets.data, targets.len)
@@ -246,7 +246,7 @@ fn (cb mut Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
return true
}
fn (cb mut Clipboard) start_listener(){
fn (mut cb Clipboard) start_listener(){
event := C.XEvent{}
mut sent_request := false
mut to_be_requested := C.Atom(0)
@@ -325,7 +325,7 @@ fn (cb mut Clipboard) start_listener(){
// Helpers
// Initialize all the atoms we need
fn (cb mut Clipboard) intern_atoms(){
fn (mut cb Clipboard) intern_atoms(){
cb.atoms << C.Atom(4) //XA_ATOM
cb.atoms << C.Atom(31) //XA_STRING
for i, name in atom_names{

View File

@@ -17,23 +17,23 @@ pub fn new_primary() &Clipboard {
return &Clipboard{}
}
fn (cb mut Clipboard) set_text(text string) bool {
fn (mut cb Clipboard) set_text(text string) bool {
cb.text = text
cb.is_owner = true
cb.got_text = true
return true
}
fn (cb mut Clipboard) get_text() string {
fn (mut cb Clipboard) get_text() string {
return cb.text
}
fn (cb mut Clipboard) clear(){
fn (mut cb Clipboard) clear(){
cb.text = ''
cb.is_owner = false
}
fn (cb mut Clipboard) free(){
fn (mut cb Clipboard) free(){
}
fn (cb &Clipboard) has_ownership() bool {
@@ -41,7 +41,7 @@ fn (cb &Clipboard) has_ownership() bool {
}
fn (cb &Clipboard) check_availability() bool {
// This is a dummy clipboard implementation,
// This is a dummy clipboard implementation,
// which can be always used, although it does not do much...
return true
}