diff --git a/pkg/service/class.go b/pkg/service/class.go index 634370c..4211007 100644 --- a/pkg/service/class.go +++ b/pkg/service/class.go @@ -53,7 +53,11 @@ func (c *Class) methodDeclarationsToString() (code string) { } func (c *Class) methodDeclarationToString(m *ast.FuncDecl) (code string) { code += " " - code += "void " + m.Name.String() + "();" + code += handleFuncDeclType(m.Type) + code += " " + code += m.Name.String() + "(" + code += handleFuncDeclParams(m.Type) + code += ");" code += "\n" return } @@ -67,10 +71,11 @@ func (c *Class) methodImplementationsToString() (code string) { } func (c *Class) methodImplementationToString(m *ast.FuncDecl) (code string) { - code += "void " + code += handleFuncDeclType(m.Type) + code += " " code += c.Name + "::" code += m.Name.String() + "(" - + code += handleFuncDeclParams(m.Type) code += ") {" if len(m.Recv.List) > 0 { n := m.Recv.List[0].Names diff --git a/pkg/service/expr.go b/pkg/service/expr.go index dee0b64..a061aea 100644 --- a/pkg/service/expr.go +++ b/pkg/service/expr.go @@ -75,6 +75,8 @@ func handleIdentExpr(expr ast.Expr) string { code += "unsigned long" case "uint64": code += "unsigned long long" + case "float64": + code += "double" case "string": code += "std::string" default: diff --git a/pkg/service/features/app.feature b/pkg/service/features/app.feature index 02c61ce..58371bf 100644 --- a/pkg/service/features/app.feature +++ b/pkg/service/features/app.feature @@ -131,6 +131,47 @@ this->doSomethingElse(); } void device::doSomethingElse() { } +``` + + Сценарий: Структура с вызовом методов со входящими и выходящими параметрами + * Исходник: +``` +package test + +type device struct { + a int +} + +func (d *device) doSomething(i int, x string) { + d.doSomethingElse(1, 0.5) + d.doSomethingElse(i, 0.6) +} +func (d *device) doSomethingElse(i int, f float64) int { + return 1 +} +func (d *device) doSomethingBool(i int, f float64) bool { + return true +} +``` + * Результат: +``` +class device { +public: + int a; + void doSomething(int i,std::string x); + int doSomethingElse(int i,double f); + bool doSomethingBool(int i,double f); +}; +void device::doSomething(int i,std::string x) { +this->doSomethingElse(1,0.5); +this->doSomethingElse(i,0.6); +} +int device::doSomethingElse(int i,double f) { +return 1; +} +bool device::doSomethingBool(int i,double f) { +return true; +} ``` Сценарий: Структура с изменением свойства