detached 8316da1

GIR: Don't use `unsafe.Pointer` where we don't have to

Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
commit
8316da1ba9b21825b2eb18365f69b5b706bfcf26
author
Felicitas Pojtinger · · 2025-11-18 03:08 UTC
committer
Jeroen Wijenbergh · · 2025-12-01 16:14 UTC
parent
42fe8d7
signature
unsigned
1 file · +4 -6
M internal/gir/types/template.go +4 -6
@@ -47,7 +47,7 @@ func (f *funcArgsTemplate) AddAPI(t string, n string, k Kind, ns string, nullabl
4747 // For primitive Go types we need to manually add the *
4848 t = "*" + t
4949 }
50- c = fmt.Sprintf("uintptr(unsafe.Pointer(%s))", n)
50+ c = n
5151 } else {
5252 switch k {
5353 case CallbackType:
@@ -96,14 +96,12 @@ func (f *funcArgsTemplate) AddPure(t string, n string, k Kind, isOut bool) {
9696 stars := strings.Count(t, "*")
9797
9898 if isOut {
99- // Out parameters are always pointers in C, so we can use uintptr for the type
100- goPointerType := t
99+ // Out parameters are always pointers in C
101100 if stars == 0 {
102101 // For primitive Go types we need to manually add the *
103- goPointerType = "*" + t
102+ t = "*" + t
104103 }
105- t = "uintptr"
106- c = fmt.Sprintf("(%s)(unsafe.Pointer(%s))", goPointerType, n)
104+ c = n
107105 } else {
108106 switch k {
109107 case RecordsType:
@@ -47,7 +47,7 @@ func (f *funcArgsTemplate) AddAPI(t string, n string, k Kind, ns string, nullabl
47 // For primitive Go types we need to manually add the *47 // For primitive Go types we need to manually add the *
48 t = "*" + t48 t = "*" + t
49 }49 }
50- c = fmt.Sprintf("uintptr(unsafe.Pointer(%s))", n)50+ c = n
51 } else {51 } else {
52 switch k {52 switch k {
53 case CallbackType:53 case CallbackType:
@@ -96,14 +96,12 @@ func (f *funcArgsTemplate) AddPure(t string, n string, k Kind, isOut bool) {
96 stars := strings.Count(t, "*")96 stars := strings.Count(t, "*")
97 97
98 if isOut {98 if isOut {
99- // Out parameters are always pointers in C, so we can use uintptr for the type99+ // Out parameters are always pointers in C
100- goPointerType := t
101 if stars == 0 {100 if stars == 0 {
102 // For primitive Go types we need to manually add the *101 // For primitive Go types we need to manually add the *
103- goPointerType = "*" + t102+ t = "*" + t
104 }103 }
105- t = "uintptr"104+ c = n
106- c = fmt.Sprintf("(%s)(unsafe.Pointer(%s))", goPointerType, n)
107 } else {105 } else {
108 switch k {106 switch k {
109 case RecordsType:107 case RecordsType:

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close