Skip to content

Commit 5d9a1f0

Browse files
authored
codegen: returnWraper does not need FuncDefs arg anymore (#68)
1 parent 442a106 commit 5d9a1f0

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

cmd/codegen/gengo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ import "unsafe"
435435
continue
436436
}
437437

438-
returnType, _ := returnWrapper(f)
438+
returnType, _ := returnWrapper()
439439

440440
sb.WriteString(funcSignatureFunc(f.FuncName, args[1:], returnType))
441441

@@ -479,7 +479,7 @@ import "unsafe"
479479
convertedFuncCount += 1
480480
default:
481481
if rf, ok := returnWrapperMap[f.Ret]; ok {
482-
returnType, returnStmt := rf(f)
482+
returnType, returnStmt := rf()
483483

484484
sb.WriteString(funcSignatureFunc(f.FuncName, args, returnType))
485485

cmd/codegen/return_wrapper.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,123 @@
11
package main
22

33
// Wrapper for return value
4-
type returnWrapper func(f FuncDef) (returnType string, returnStmt string)
4+
type returnWrapper func() (returnType string, returnStmt string)
55

6-
func boolReturnW(f FuncDef) (returnType string, returnStmt string) {
6+
func boolReturnW() (returnType string, returnStmt string) {
77
returnType = "bool"
88
returnStmt = "return %s == C.bool(true)\n"
99
return
1010
}
1111

12-
func constCharReturnW(f FuncDef) (returnType string, returnStmt string) {
12+
func constCharReturnW() (returnType string, returnStmt string) {
1313
returnType = "string"
1414
returnStmt = "return C.GoString(%s)"
1515
return
1616
}
1717

18-
func floatReturnW(f FuncDef) (returnType string, returnStmt string) {
18+
func floatReturnW() (returnType string, returnStmt string) {
1919
returnType = "float32"
2020
returnStmt = "return float32(%s)"
2121
return
2222
}
2323

24-
func doubleReturnW(f FuncDef) (returnType string, returnStmt string) {
24+
func doubleReturnW() (returnType string, returnStmt string) {
2525
returnType = "float64"
2626
returnStmt = "return float64(%s)"
2727
return
2828
}
2929

30-
func intReturnW(f FuncDef) (returnType string, returnStmt string) {
30+
func intReturnW() (returnType string, returnStmt string) {
3131
returnType = "int"
3232
returnStmt = "return int(%s)"
3333
return
3434
}
3535

36-
func constWCharPtrReturnW(f FuncDef) (returnType string, returnStmt string) {
36+
func constWCharPtrReturnW() (returnType string, returnStmt string) {
3737
returnType = "*ImWchar"
3838
returnStmt = "return (*ImWchar)(%s)"
3939
return
4040
}
4141

42-
func imVec4PtrReturnW(f FuncDef) (returnType string, returnStmt string) {
42+
func imVec4PtrReturnW() (returnType string, returnStmt string) {
4343
returnType = "ImVec4"
4444
returnStmt = "return newImVec4FromCPtr(%s)"
4545
return
4646
}
4747

48-
func imVec4ReturnW(f FuncDef) (returnType string, returnStmt string) {
48+
func imVec4ReturnW() (returnType string, returnStmt string) {
4949
returnType = "ImVec4"
5050
returnStmt = "return newImVec4FromC(%s)"
5151
return
5252
}
5353

54-
func imVec2ReturnW(f FuncDef) (returnType string, returnStmt string) {
54+
func imVec2ReturnW() (returnType string, returnStmt string) {
5555
returnType = "ImVec2"
5656
returnStmt = "return newImVec2FromC(%s)"
5757
return
5858
}
5959

60-
func imColorReturnW(f FuncDef) (returnType string, returnStmt string) {
60+
func imColorReturnW() (returnType string, returnStmt string) {
6161
returnType = "ImColor"
6262
returnStmt = "return newImColorFromC(%s)"
6363
return
6464
}
6565

66-
func imPlotPointReturnW(f FuncDef) (returnType string, returnStmt string) {
66+
func imPlotPointReturnW() (returnType string, returnStmt string) {
6767
returnType = "ImPlotPoint"
6868
returnStmt = "return newImPlotPointFromC(%s)"
6969
return
7070
}
7171

72-
func imRectReturnW(f FuncDef) (returnType string, returnStmt string) {
72+
func imRectReturnW() (returnType string, returnStmt string) {
7373
returnType = "ImRect"
7474
returnStmt = "return newImRectFromC(%s)"
7575
return
7676
}
7777

78-
func imTableColumnIdxReturnW(f FuncDef) (returnType string, returnStmt string) {
78+
func imTableColumnIdxReturnW() (returnType string, returnStmt string) {
7979
returnType = "ImGuiTableColumnIdx"
8080
returnStmt = "return ImGuiTableColumnIdx(%s)"
8181
return
8282
}
8383

84-
func imTableDrawChannelIdxReturnW(f FuncDef) (returnType string, returnStmt string) {
84+
func imTableDrawChannelIdxReturnW() (returnType string, returnStmt string) {
8585
returnType = "ImGuiTableDrawChannelIdx"
8686
returnStmt = "return ImGuiTableDrawChannelIdx(%s)"
8787
return
8888
}
8989

90-
func voidPtrReturnW(f FuncDef) (returnType string, returnStmt string) {
90+
func voidPtrReturnW() (returnType string, returnStmt string) {
9191
returnType = "unsafe.Pointer"
9292
returnStmt = "return unsafe.Pointer(%s)"
9393
return
9494
}
9595

96-
func u32ReturnW(f FuncDef) (returnType string, returnStmt string) {
96+
func u32ReturnW() (returnType string, returnStmt string) {
9797
returnType = "uint32"
9898
returnStmt = "return uint32(%s)"
9999
return
100100
}
101101

102-
func uintReturnW(f FuncDef) (returnType string, returnStmt string) {
102+
func uintReturnW() (returnType string, returnStmt string) {
103103
returnType = "uint32"
104104
returnStmt = "return uint32(%s)"
105105
return
106106
}
107107

108-
func uint64ReturnW(f FuncDef) (returnType string, returnStmt string) {
108+
func uint64ReturnW() (returnType string, returnStmt string) {
109109
returnType = "uint64"
110110
returnStmt = "return uint64(%s)"
111111
return
112112
}
113113

114-
func idReturnW(f FuncDef) (returnType string, returnStmt string) {
114+
func idReturnW() (returnType string, returnStmt string) {
115115
returnType = "ImGuiID"
116116
returnStmt = "return ImGuiID(%s)"
117117
return
118118
}
119119

120-
func textureIdReturnW(f FuncDef) (returnType string, returnStmt string) {
120+
func textureIdReturnW() (returnType string, returnStmt string) {
121121
returnType = "ImTextureID"
122122
returnStmt = "return ImTextureID(%s)"
123123
return

0 commit comments

Comments
 (0)