Skip to content

Commit 8c2a41c

Browse files
committed
Handle base class auto methods
1 parent d3a745a commit 8c2a41c

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Source/buildimplementationrust.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,19 @@ func writeRustTrait(component ComponentDefinition, class ComponentDefinitionClas
172172
}
173173
w.Writeln("trait %s %s {", class.ClassName, parentClassString)
174174
w.AddIndentationLevel(1)
175-
// TODO add the base class methods!
175+
methods := class.Methods
176+
if component.isBaseClass(class) {
177+
methods = append(
178+
methods,
179+
GetLastErrorMessageMethod(),
180+
ClearErrorMessageMethod(),
181+
RegisterErrorMessageMethod(),
182+
IncRefCountMethod(),
183+
DecRefCountMethod())
184+
}
176185

177-
for j := 0; j < len(class.Methods); j++ {
178-
method := class.Methods[j]
186+
for j := 0; j < len(methods); j++ {
187+
method := methods[j]
179188
w.Writeln("")
180189
err := writeRustTraitFn(method, w)
181190
if err != nil {

Source/languagerust.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,14 @@ func generateRustParameterType(param ComponentDefinitionParam, isPlain bool) (st
276276
if isPlain {
277277
RustParamTypeName = "*mut char"
278278
} else {
279-
// TODO
280-
return "", fmt.Errorf("%s Not yet handled", param.ParamType)
279+
switch param.ParamPass {
280+
case "out":
281+
RustParamTypeName = "&mut str"
282+
case "in":
283+
RustParamTypeName = "&str"
284+
case "return":
285+
RustParamTypeName = "String"
286+
}
281287
}
282288

283289
case "enum":
@@ -303,7 +309,7 @@ func generateRustParameterType(param ComponentDefinitionParam, isPlain bool) (st
303309
case "out":
304310
RustParamTypeName = fmt.Sprintf("&mut %s", ParamClass)
305311
case "in":
306-
RustParamTypeName = fmt.Sprintf("& %s", ParamClass)
312+
RustParamTypeName = fmt.Sprintf("&%s", ParamClass)
307313
case "return":
308314
RustParamTypeName = fmt.Sprintf("%s", ParamClass)
309315
}

0 commit comments

Comments
 (0)