cppintf: with param
This commit is contained in:
@@ -3,23 +3,23 @@ package main
|
||||
import (
|
||||
"github.com/goplus/llgo/_demo/cppintf/foo"
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/math"
|
||||
)
|
||||
|
||||
type Bar struct {
|
||||
foo.Callback
|
||||
a int
|
||||
b float64
|
||||
}
|
||||
|
||||
func NewBar(a int, b float64) *Bar {
|
||||
func NewBar(a int) *Bar {
|
||||
return &Bar{
|
||||
Callback: foo.Callback{
|
||||
Vptr: &foo.CallbackVtbl{
|
||||
ValA: c.Func((*Bar).getA),
|
||||
ValB: c.Func((*Bar).getB),
|
||||
Val: c.Func((*Bar).getA),
|
||||
Calc: c.Func((*Bar).sqrt),
|
||||
},
|
||||
},
|
||||
a: a, b: b,
|
||||
a: a,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ func (p *Bar) getA() int {
|
||||
return p.a
|
||||
}
|
||||
|
||||
func (p *Bar) getB() float64 {
|
||||
return p.b
|
||||
func (p *Bar) sqrt(v float64) float64 {
|
||||
return math.Sqrt(v)
|
||||
}
|
||||
|
||||
func main() {
|
||||
bar := NewBar(1, 2.0)
|
||||
bar := NewBar(1)
|
||||
foo.F(&bar.Callback)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user