~dobey/go-unityscopes/fix-typo

« back to all changes in this revision

Viewing changes to reply.go

  • Committer: Rodney Dawes
  • Author(s): James Henstridge
  • Date: 2016-10-03 20:26:39 UTC
  • mfrom: (73.1.11 v2)
  • Revision ID: rodney.dawes@canonical.com-20161003202639-6qnaojpfps0vk11q
Update code to work with Go 1.6's new cgo pointer handling rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "encoding/json"
8
8
        "runtime"
9
 
        "unsafe"
10
9
)
11
10
 
12
11
// SearchReply is used to send results of search queries to the client.
41
40
// with an error.
42
41
func (reply *SearchReply) Error(err error) {
43
42
        errString := err.Error()
44
 
        C.search_reply_error(&reply.r[0], unsafe.Pointer(&errString))
 
43
        C.search_reply_error(&reply.r[0], strData(errString))
45
44
}
46
45
 
47
46
// RegisterCategory registers a new results category with the client.
56
55
func (reply *SearchReply) RegisterCategory(id, title, icon, template string) *Category {
57
56
        cat := new(Category)
58
57
        runtime.SetFinalizer(cat, finalizeCategory)
59
 
        C.search_reply_register_category(&reply.r[0], unsafe.Pointer(&id), unsafe.Pointer(&title), unsafe.Pointer(&icon), unsafe.Pointer(&template), &cat.c[0])
 
58
        C.search_reply_register_category(&reply.r[0], strData(id), strData(title), strData(icon), strData(template), &cat.c[0])
60
59
        return cat
61
60
}
62
61
 
95
94
                return err
96
95
        }
97
96
        var errorString *C.char
98
 
        C.search_reply_push_filters(&reply.r[0], unsafe.Pointer(&filtersJson), unsafe.Pointer(&stateJson), &errorString)
 
97
        C.search_reply_push_filters(&reply.r[0], strData(filtersJson), strData(stateJson), &errorString)
99
98
        return checkError(errorString)
100
99
}
101
100
 
131
130
// with an error.
132
131
func (reply *PreviewReply) Error(err error) {
133
132
        errString := err.Error()
134
 
        C.preview_reply_error(&reply.r[0], unsafe.Pointer(&errString))
 
133
        C.preview_reply_error(&reply.r[0], strData(errString))
135
134
}
136
135
 
137
136
// PushWidgets sends one or more preview widgets to the client.
145
144
                widget_data[i] = string(data)
146
145
        }
147
146
        var errorString *C.char
148
 
        C.preview_reply_push_widgets(&reply.r[0], unsafe.Pointer(&widget_data[0]), C.int(len(widget_data)), &errorString)
 
147
        C.preview_reply_push_widgets(&reply.r[0], joinedStrData(widget_data), &errorString)
149
148
        return checkError(errorString)
150
149
}
151
150
 
162
161
        }
163
162
        json_value := string(data)
164
163
        var errorString *C.char
165
 
        C.preview_reply_push_attr(&reply.r[0], unsafe.Pointer(&attr), unsafe.Pointer(&json_value), &errorString)
 
164
        C.preview_reply_push_attr(&reply.r[0], strData(attr), strData(json_value), &errorString)
166
165
        return checkError(errorString)
167
166
}
168
167