@@ -16,7 +16,7 @@ type Function struct {
1616 Type * typing.FunctionType
1717 Name string // the first part of objc function name
1818 GoName string
19- Params []* Param
19+ Parameters []* Param
2020 ReturnType typing.Type
2121 Deprecated bool // if has been deprecated
2222 Suffix bool // GoName conflicts so add suffix to this function
@@ -28,28 +28,28 @@ type Function struct {
2828}
2929
3030// GoArgs return go function args
31- func (f * Function ) GoArgs () string {
31+ func (f * Function ) GoArgs (currentModule * modules. Module ) string {
3232 var args []string
33- for _ , p := range f .Params {
34- args = append (args , p . GoName ())
33+ for _ , p := range f .Parameters {
34+ args = append (args , fmt . Sprintf ( "%s %s" , p . Name , p . Type . GoName (currentModule , true ) ))
3535 }
3636 return strings .Join (args , ", " )
3737}
3838
3939// GoReturn return go function return
40- func (f * Function ) GoReturn () string {
40+ func (f * Function ) GoReturn (currentModule * modules. Module ) string {
4141 if f .ReturnType == nil {
4242 return ""
4343 }
44- return f .ReturnType .GoName (nil , true )
44+ return f .ReturnType .GoName (currentModule , true )
4545}
4646
4747// Selector return full Objc function name
4848func (f * Function ) Selector () string {
4949 if f .identifier == "" {
5050 var sb strings.Builder
5151 sb .WriteString (f .Name )
52- for idx , p := range f .Params {
52+ for idx , p := range f .Parameters {
5353 if idx > 0 {
5454 sb .WriteString (p .FieldName )
5555 }
@@ -69,7 +69,7 @@ func (f *Function) NormalizeInstanceTypeFunction(returnType *typing.ClassType) *
6969 nm := & Function {
7070 Name : f .Name ,
7171 GoName : f .GoName ,
72- Params : f . Params ,
72+ Parameters : f . Parameters ,
7373 ReturnType : returnType ,
7474 goFuncName : f .goFuncName ,
7575 Suffix : f .Suffix ,
@@ -107,7 +107,7 @@ func (f *Function) WriteGoCallCode(currentModule *modules.Module, typeName strin
107107 }
108108 callCode := fmt .Sprintf ("objc.Call[%s](%s, objc.Sel(\" %s\" )" , returnTypeStr , receiver , f .Selector ())
109109 var sb strings.Builder
110- for idx , p := range f .Params {
110+ for idx , p := range f .Parameters {
111111 sb .WriteString (", " )
112112 switch tt := p .Type .(type ) {
113113 case * typing.ClassType :
@@ -154,7 +154,7 @@ func (f *Function) WriteGoInterfaceCode(currentModule *modules.Module, classType
154154// GoFuncDeclare generate go function declaration
155155func (f * Function ) GoFuncDeclare (currentModule * modules.Module , goTypeName string ) string {
156156 var paramStrs []string
157- for _ , p := range f .Params {
157+ for _ , p := range f .Parameters {
158158 paramStrs = append (paramStrs , p .GoDeclare (currentModule , false ))
159159 }
160160
@@ -167,11 +167,11 @@ func (f *Function) GoFuncName() string {
167167 if f .goFuncName == "" {
168168 var sb strings.Builder
169169 name := f .GoName
170- if len (f .Params ) == 0 {
170+ if len (f .Parameters ) == 0 {
171171 sb .WriteString (stringx .Capitalize (name ))
172172 }
173173
174- for _ , p := range f .Params {
174+ for _ , p := range f .Parameters {
175175 sb .WriteString (stringx .Capitalize (p .FieldName ))
176176 if p .Object {
177177 sb .WriteString ("Object" )
@@ -189,7 +189,7 @@ func (f *Function) GoFuncName() string {
189189// ProtocolGoFuncFieldType generate go function declaration for protocol struct impl field
190190func (f * Function ) ProtocolGoFuncFieldType (currentModule * modules.Module ) string {
191191 var paramStrs []string
192- for _ , p := range f .Params {
192+ for _ , p := range f .Parameters {
193193 paramStrs = append (paramStrs , p .GoDeclare (currentModule , true ))
194194 }
195195
@@ -201,7 +201,7 @@ func (f *Function) ProtocolGoFuncName() string {
201201 if f .goFuncName == "" {
202202 var sb strings.Builder
203203 sb .WriteString (stringx .Capitalize (f .Name ))
204- for idx , p := range f .Params {
204+ for idx , p := range f .Parameters {
205205 if idx == 0 {
206206 continue
207207 }
@@ -222,7 +222,7 @@ func (f *Function) ProtocolGoFuncName() string {
222222// GoImports return all imports for go file
223223func (f * Function ) GoImports () set.Set [string ] {
224224 var imports = set .New ("github.com/progrium/macdriver/objc" )
225- for _ , param := range f .Params {
225+ for _ , param := range f .Parameters {
226226 imports .AddSet (param .Type .GoImports ())
227227 }
228228 if f .ReturnType != nil {
@@ -232,7 +232,7 @@ func (f *Function) GoImports() set.Set[string] {
232232}
233233
234234func (f * Function ) HasProtocolParam () bool {
235- for _ , p := range f .Params {
235+ for _ , p := range f .Parameters {
236236 switch p .Type .(type ) {
237237 case * typing.ProtocolType :
238238 return true
@@ -242,8 +242,8 @@ func (f *Function) HasProtocolParam() bool {
242242}
243243
244244func (f * Function ) ToProtocolParamAsObjectFunction () * Function {
245- var newParams = make ([]* Param , len (f .Params ))
246- for i , p := range f .Params {
245+ var newParams = make ([]* Param , len (f .Parameters ))
246+ for i , p := range f .Parameters {
247247 switch p .Type .(type ) {
248248 case * typing.ProtocolType :
249249 newParams [i ] = & Param {
@@ -259,7 +259,7 @@ func (f *Function) ToProtocolParamAsObjectFunction() *Function {
259259 return & Function {
260260 Name : f .Name ,
261261 GoName : f .GoName ,
262- Params : newParams ,
262+ Parameters : newParams ,
263263 Suffix : f .Suffix ,
264264 ReturnType : f .ReturnType ,
265265 Deprecated : f .Deprecated ,
0 commit comments