From d340d11c77c55e4e04ef631e23e9960572f0b2bc Mon Sep 17 00:00:00 2001 From: Softonik Date: Mon, 12 Feb 2024 07:07:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BA=D0=B0=D0=B7=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=B2=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D1=85=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84?= =?UTF-8?q?=D0=B5=D0=B9=D1=81=D0=BE=D0=B2=20=D0=B8=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/class_abstract.go | 8 ++++++-- pkg/service/features/app.feature | 8 +++++--- pkg/service/func.go | 12 +++++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pkg/service/class_abstract.go b/pkg/service/class_abstract.go index b8c0971..7432ac9 100644 --- a/pkg/service/class_abstract.go +++ b/pkg/service/class_abstract.go @@ -63,11 +63,15 @@ func handleAbstractFuncDeclParams(t *ast.FuncType) (code string) { } values := make([]string, 0) for _, field := range t.Params.List { + t := "" switch ft := field.Type.(type) { case *ast.Ident: - t := handleIdentExpr(ft) - values = append(values, t) + t = handleIdentExpr(ft) + case *ast.StarExpr: + t = handleStarExpr(ft) + t += "*" } + values = append(values, t) } code += strings.Join(values, ",") return diff --git a/pkg/service/features/app.feature b/pkg/service/features/app.feature index 301b7d0..6d997f5 100644 --- a/pkg/service/features/app.feature +++ b/pkg/service/features/app.feature @@ -35,6 +35,7 @@ package test type Device interface { Name() string String() string + Some(*Thing) string Add(int) Add2(int,float64) } @@ -45,6 +46,7 @@ class Device { public: virtual std::string Name() = 0; virtual std::string String() = 0; + virtual std::string Some(Thing*) = 0; virtual void Add(int) = 0; virtual void Add2(int,double) = 0; }; @@ -145,7 +147,7 @@ type device struct { a int } -func (d *device) doSomething() { +func (d *device) doSomething(a *int) { } ``` * Результат: @@ -153,9 +155,9 @@ func (d *device) doSomething() { class device { public: int a; - void doSomething(); + void doSomething(int* a); }; -void device::doSomething() { +void device::doSomething(int* a) { } ``` diff --git a/pkg/service/func.go b/pkg/service/func.go index 5884a07..8a14c5e 100644 --- a/pkg/service/func.go +++ b/pkg/service/func.go @@ -132,12 +132,22 @@ func handleFuncDeclParams(t *ast.FuncType) string { values := make([]string, 0) for _, field := range t.Params.List { ftype := "" + star := false switch ft := field.Type.(type) { case *ast.Ident: ftype = handleIdentExpr(ft) + case *ast.StarExpr: + ftype = handleStarExpr(ft) + star = true } for _, names := range field.Names { - values = append(values, ftype+" "+names.Name) + n := ftype + if star { + n += "*" + } + n += " " + n += names.Name + values = append(values, n) } } code += strings.Join(values, ",")