/
qt_js.go
27 lines (22 loc) · 670 Bytes
/
qt_js.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// +build js,!wasm
package qt
import "github.com/gopherjs/gopherjs/js"
var Global = js.Global
var Module = Global.Call("eval", "Module")
func MakeWrapper(i interface{}) *js.Object {
o := js.InternalObject(i)
methods := o.Get("constructor").Get("methods")
for i := 0; i < methods.Length(); i++ {
m := methods.Index(i)
if m.Get("pkg").String() != "" { // not exported
continue
}
if o.Get(m.Get("name").String()) == js.Undefined {
o.Set(m.Get("name").String(), func(args ...*js.Object) *js.Object {
return js.Global.Call("$externalizeFunction", o.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", o, args)
})
}
}
return o
}
//