mirror of
https://github.com/araxiaonline/araxiapatch.git
synced 2026-06-13 03:12:23 -04:00
full code
This commit is contained in:
7
go.mod
Normal file
7
go.mod
Normal file
@@ -0,0 +1,7 @@
|
||||
module github.com/turleynerd/araxiapatch
|
||||
|
||||
go 1.20
|
||||
|
||||
require github.com/therecipe/qt v0.0.0-20200904063919-c0c124a5770d
|
||||
|
||||
require github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e // indirect
|
||||
25
go.sum
Normal file
25
go.sum
Normal file
@@ -0,0 +1,25 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e h1:XWcjeEtTFTOVA9Fs1w7n2XBftk5ib4oZrhzWk0B+3eA=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/therecipe/qt v0.0.0-20200904063919-c0c124a5770d h1:T+d8FnaLSvM/1BdlDXhW4d5dr2F07bAbB+LpgzMxx+o=
|
||||
github.com/therecipe/qt v0.0.0-20200904063919-c0c124a5770d/go.mod h1:SUUR2j3aE1z6/g76SdD6NwACEpvCxb3fvG82eKbD6us=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
BIN
img/ui.PNG
Normal file
BIN
img/ui.PNG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
241
main.go
Normal file
241
main.go
Normal file
@@ -0,0 +1,241 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/therecipe/qt/core"
|
||||
"github.com/therecipe/qt/widgets"
|
||||
)
|
||||
|
||||
type ProgressBarWindow struct {
|
||||
app *widgets.QApplication
|
||||
window *widgets.QWidget
|
||||
layout *widgets.QVBoxLayout
|
||||
bars []*ProgressBar
|
||||
maxNameWidth int // Maximum width for file names
|
||||
done chan bool
|
||||
}
|
||||
|
||||
type ProgressBar struct {
|
||||
order int
|
||||
total int64
|
||||
current int64
|
||||
file string
|
||||
progressBar *widgets.QProgressBar
|
||||
label *widgets.QLabel
|
||||
}
|
||||
|
||||
// Files to download
|
||||
var files = []string{
|
||||
"info.txt",
|
||||
"patch-4.mpq",
|
||||
"patch-5.mpq",
|
||||
"patch-7.mpq",
|
||||
"patch-9.mpq",
|
||||
"patch-B.mpq",
|
||||
"patch-C.mpq",
|
||||
"patch-D.mpq",
|
||||
"patch-F.mpq",
|
||||
"patch-G.mpq",
|
||||
"patch-J.mpq",
|
||||
"patch-L.mpq",
|
||||
"patch-S.mpq",
|
||||
"patch-T.mpq",
|
||||
"patch-U.mpq",
|
||||
}
|
||||
|
||||
var patchSource = "https://storage.googleapis.com/araxia-client-patches/"
|
||||
|
||||
func main() {
|
||||
catchInterrupt()
|
||||
|
||||
app := widgets.NewQApplication(len(os.Args), os.Args)
|
||||
window := widgets.NewQWidget(nil, 0)
|
||||
window.SetWindowTitle("Araxia Client Patch Downloader")
|
||||
// Add header Title
|
||||
title := widgets.NewQLabel2("Araxia Client Patch Downloader", nil, 0)
|
||||
title.Font().SetPointSize(20)
|
||||
title.Font().SetFamily("Arial")
|
||||
title.SetAlignment(core.Qt__AlignCenter)
|
||||
|
||||
window.SetMinimumSize2(800, 600)
|
||||
|
||||
layout := widgets.NewQVBoxLayout()
|
||||
window.SetLayout(layout)
|
||||
layout.AddWidget(title, 0, core.Qt__AlignCenter)
|
||||
|
||||
progressBarWindow := ProgressBarWindow{
|
||||
app: app,
|
||||
window: window,
|
||||
layout: layout,
|
||||
done: make(chan bool),
|
||||
}
|
||||
|
||||
progressBarWindow.calculateMaxNameWidth()
|
||||
progressBarWindow.initProgressBars()
|
||||
|
||||
go progressBarWindow.run()
|
||||
|
||||
closeButton := widgets.NewQPushButton2("Close", nil)
|
||||
closeButton.ConnectClicked(func(bool) {
|
||||
app.Quit()
|
||||
})
|
||||
layout.AddWidget(closeButton, 0, core.Qt__AlignRight)
|
||||
|
||||
window.Show()
|
||||
|
||||
app.Exec()
|
||||
}
|
||||
|
||||
func (p *ProgressBarWindow) calculateMaxNameWidth() {
|
||||
for _, file := range files {
|
||||
if len(file) > p.maxNameWidth {
|
||||
p.maxNameWidth = len(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ProgressBarWindow) initProgressBars() {
|
||||
for i, file := range files {
|
||||
progressBar := NewProgressBar(i+1, file, p.maxNameWidth)
|
||||
p.bars = append(p.bars, progressBar)
|
||||
|
||||
// Create labels for filename and download speed
|
||||
filenameLabel := widgets.NewQLabel2(file, nil, 0)
|
||||
filenameLabel.SetFixedWidth(p.maxNameWidth * 8)
|
||||
|
||||
// Create a horizontal layout for the labels and progress bar
|
||||
labelLayout := widgets.NewQHBoxLayout2(nil)
|
||||
labelLayout.AddWidget(filenameLabel, 0, core.Qt__AlignTop)
|
||||
labelLayout.AddWidget(progressBar.label, 0, core.Qt__AlignTop)
|
||||
|
||||
// Create a vertical layout to hold the labels and progress bar
|
||||
progressLayout := widgets.NewQVBoxLayout()
|
||||
progressLayout.AddLayout(labelLayout, 0)
|
||||
progressLayout.AddWidget(progressBar.progressBar, 0, core.Qt__AlignTop)
|
||||
|
||||
p.layout.AddLayout(progressLayout, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ProgressBarWindow) run() {
|
||||
directory := "."
|
||||
if len(os.Args) > 1 {
|
||||
directory = os.Args[1]
|
||||
}
|
||||
|
||||
// create channel to wait for all downloads to finish
|
||||
done := make(chan bool)
|
||||
|
||||
// Download each file in parallel
|
||||
for i, file := range files {
|
||||
go p.downloadFile(directory, file, i+1, done)
|
||||
}
|
||||
|
||||
// Wait for all downloads to finish
|
||||
for i := 0; i < len(files); i++ {
|
||||
<-done
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (p *ProgressBarWindow) downloadFile(directory string, file string, order int, done chan bool) {
|
||||
out, err := os.Create(directory + "/" + file)
|
||||
if err != nil {
|
||||
fmt.Println("Error creating file:", file)
|
||||
return
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
resp, err := http.Get(patchSource + file)
|
||||
if err != nil {
|
||||
fmt.Println("Error downloading file:", file)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
progressBar := p.bars[order-1]
|
||||
progressBar.total = resp.ContentLength
|
||||
|
||||
start := time.Now()
|
||||
lastTime := start
|
||||
lastBytes := int64(0)
|
||||
|
||||
buf := make([]byte, 1024) // Buffer for calculating download speed
|
||||
for {
|
||||
n, err := resp.Body.Read(buf)
|
||||
if n > 0 {
|
||||
out.Write(buf[:n])
|
||||
progressBar.current += int64(n)
|
||||
now := time.Now()
|
||||
elapsed := now.Sub(lastTime).Seconds()
|
||||
if elapsed >= 1 { // Update speed label every second
|
||||
speed := float64(progressBar.current-lastBytes) / elapsed
|
||||
updateSpeedLabel(progressBar.label, speed)
|
||||
lastBytes = progressBar.current
|
||||
lastTime = now
|
||||
}
|
||||
updateProgressBar(progressBar.progressBar, progressBar.current, progressBar.total)
|
||||
}
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Error writing file:", file, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
done <- true
|
||||
}
|
||||
|
||||
func NewProgressBar(order int, file string, maxNameWidth int) *ProgressBar {
|
||||
progressBar := widgets.NewQProgressBar(nil)
|
||||
progressBar.SetMinimum(0)
|
||||
progressBar.SetMaximum(100)
|
||||
progressBar.SetValue(0)
|
||||
|
||||
label := widgets.NewQLabel2("", nil, 0)
|
||||
label.SetFixedWidth(maxNameWidth * 8)
|
||||
|
||||
return &ProgressBar{
|
||||
order: order,
|
||||
file: file,
|
||||
progressBar: progressBar,
|
||||
label: label,
|
||||
}
|
||||
}
|
||||
|
||||
func updateProgressBar(progressBar *widgets.QProgressBar, current int64, total int64) {
|
||||
percent := float32(current) / float32(total) * 100
|
||||
progressBar.SetValue(int(percent))
|
||||
}
|
||||
|
||||
func updateSpeedLabel(label *widgets.QLabel, speed float64) {
|
||||
var speedLabel string
|
||||
if speed < 1024 {
|
||||
speedLabel = fmt.Sprintf("%.2f B/s", speed)
|
||||
} else if speed < 1024*1024 {
|
||||
speedLabel = fmt.Sprintf("%.2f KB/s", speed/1024)
|
||||
} else {
|
||||
speedLabel = fmt.Sprintf("%.2f MB/s", speed/1024/1024)
|
||||
}
|
||||
label.SetText(speedLabel)
|
||||
}
|
||||
|
||||
// catch interrupt signal and exit
|
||||
func catchInterrupt() {
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
for sig := range c {
|
||||
fmt.Printf("Received %v, exiting.\n", sig)
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
}
|
||||
24
vendor/github.com/gopherjs/gopherjs/LICENSE
generated
vendored
Normal file
24
vendor/github.com/gopherjs/gopherjs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2013 Richard Musiol. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
168
vendor/github.com/gopherjs/gopherjs/js/js.go
generated
vendored
Normal file
168
vendor/github.com/gopherjs/gopherjs/js/js.go
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax.
|
||||
//
|
||||
// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed:
|
||||
//
|
||||
// | Go type | JavaScript type | Conversions back to interface{} |
|
||||
// | --------------------- | --------------------- | ------------------------------- |
|
||||
// | bool | Boolean | bool |
|
||||
// | integers and floats | Number | float64 |
|
||||
// | string | String | string |
|
||||
// | []int8 | Int8Array | []int8 |
|
||||
// | []int16 | Int16Array | []int16 |
|
||||
// | []int32, []int | Int32Array | []int |
|
||||
// | []uint8 | Uint8Array | []uint8 |
|
||||
// | []uint16 | Uint16Array | []uint16 |
|
||||
// | []uint32, []uint | Uint32Array | []uint |
|
||||
// | []float32 | Float32Array | []float32 |
|
||||
// | []float64 | Float64Array | []float64 |
|
||||
// | all other slices | Array | []interface{} |
|
||||
// | arrays | see slice type | see slice type |
|
||||
// | functions | Function | func(...interface{}) *js.Object |
|
||||
// | time.Time | Date | time.Time |
|
||||
// | - | instanceof Node | *js.Object |
|
||||
// | maps, structs | instanceof Object | map[string]interface{} |
|
||||
//
|
||||
// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa.
|
||||
package js
|
||||
|
||||
// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key.
|
||||
type Object struct{ object *Object }
|
||||
|
||||
// Get returns the object's property with the given key.
|
||||
func (o *Object) Get(key string) *Object { return o.object.Get(key) }
|
||||
|
||||
// Set assigns the value to the object's property with the given key.
|
||||
func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) }
|
||||
|
||||
// Delete removes the object's property with the given key.
|
||||
func (o *Object) Delete(key string) { o.object.Delete(key) }
|
||||
|
||||
// Length returns the object's "length" property, converted to int.
|
||||
func (o *Object) Length() int { return o.object.Length() }
|
||||
|
||||
// Index returns the i'th element of an array.
|
||||
func (o *Object) Index(i int) *Object { return o.object.Index(i) }
|
||||
|
||||
// SetIndex sets the i'th element of an array.
|
||||
func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) }
|
||||
|
||||
// Call calls the object's method with the given name.
|
||||
func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) }
|
||||
|
||||
// Invoke calls the object itself. This will fail if it is not a function.
|
||||
func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) }
|
||||
|
||||
// New creates a new instance of this type object. This will fail if it not a function (constructor).
|
||||
func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) }
|
||||
|
||||
// Bool returns the object converted to bool according to JavaScript type conversions.
|
||||
func (o *Object) Bool() bool { return o.object.Bool() }
|
||||
|
||||
// String returns the object converted to string according to JavaScript type conversions.
|
||||
func (o *Object) String() string { return o.object.String() }
|
||||
|
||||
// Int returns the object converted to int according to JavaScript type conversions (parseInt).
|
||||
func (o *Object) Int() int { return o.object.Int() }
|
||||
|
||||
// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt).
|
||||
func (o *Object) Int64() int64 { return o.object.Int64() }
|
||||
|
||||
// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt).
|
||||
func (o *Object) Uint64() uint64 { return o.object.Uint64() }
|
||||
|
||||
// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat).
|
||||
func (o *Object) Float() float64 { return o.object.Float() }
|
||||
|
||||
// Interface returns the object converted to interface{}. See table in package comment for details.
|
||||
func (o *Object) Interface() interface{} { return o.object.Interface() }
|
||||
|
||||
// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use.
|
||||
func (o *Object) Unsafe() uintptr { return o.object.Unsafe() }
|
||||
|
||||
// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object.
|
||||
type Error struct {
|
||||
*Object
|
||||
}
|
||||
|
||||
// Error returns the message of the encapsulated JavaScript error object.
|
||||
func (err *Error) Error() string {
|
||||
return "JavaScript error: " + err.Get("message").String()
|
||||
}
|
||||
|
||||
// Stack returns the stack property of the encapsulated JavaScript error object.
|
||||
func (err *Error) Stack() string {
|
||||
return err.Get("stack").String()
|
||||
}
|
||||
|
||||
// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js).
|
||||
var Global *Object
|
||||
|
||||
// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'.
|
||||
var Module *Object
|
||||
|
||||
// Undefined gives the JavaScript value "undefined".
|
||||
var Undefined *Object
|
||||
|
||||
// Debugger gets compiled to JavaScript's "debugger;" statement.
|
||||
func Debugger() {}
|
||||
|
||||
// InternalObject returns the internal JavaScript object that represents i. Not intended for public use.
|
||||
func InternalObject(i interface{}) *Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords.
|
||||
func MakeFunc(fn func(this *Object, arguments []*Object) interface{}) *Object {
|
||||
return Global.Call("$makeFunc", InternalObject(fn))
|
||||
}
|
||||
|
||||
// Keys returns the keys of the given JavaScript object.
|
||||
func Keys(o *Object) []string {
|
||||
if o == nil || o == Undefined {
|
||||
return nil
|
||||
}
|
||||
a := Global.Get("Object").Call("keys", o)
|
||||
s := make([]string, a.Length())
|
||||
for i := 0; i < a.Length(); i++ {
|
||||
s[i] = a.Index(i).String()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript.
|
||||
func MakeWrapper(i interface{}) *Object {
|
||||
v := InternalObject(i)
|
||||
o := Global.Get("Object").New()
|
||||
o.Set("__internal_object__", v)
|
||||
methods := v.Get("constructor").Get("methods")
|
||||
for i := 0; i < methods.Length(); i++ {
|
||||
m := methods.Index(i)
|
||||
if m.Get("pkg").String() != "" { // not exported
|
||||
continue
|
||||
}
|
||||
o.Set(m.Get("name").String(), func(args ...*Object) *Object {
|
||||
return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args)
|
||||
})
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice.
|
||||
func NewArrayBuffer(b []byte) *Object {
|
||||
slice := InternalObject(b)
|
||||
offset := slice.Get("$offset").Int()
|
||||
length := slice.Get("$length").Int()
|
||||
return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length)
|
||||
}
|
||||
|
||||
// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion).
|
||||
type M map[string]interface{}
|
||||
|
||||
// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion).
|
||||
type S []interface{}
|
||||
|
||||
func init() {
|
||||
// avoid dead code elimination
|
||||
e := Error{}
|
||||
_ = e
|
||||
}
|
||||
34
vendor/github.com/therecipe/qt/.gitignore
generated
vendored
Normal file
34
vendor/github.com/therecipe/qt/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
*.jsc
|
||||
*.log
|
||||
*.pro
|
||||
*.pro.user
|
||||
*.qmake.stash
|
||||
*.qmlc
|
||||
*.so
|
||||
*.trace
|
||||
*.vagrant
|
||||
.DS_Store
|
||||
Mfile*
|
||||
qtbox
|
||||
|
||||
*/*-minimal.*
|
||||
*/*.o
|
||||
*/*_string.go
|
||||
*/cgo_*
|
||||
*/minimal_*
|
||||
*/*.d.ts
|
||||
*/*.dart
|
||||
*/*.hx
|
||||
*/*.swift
|
||||
|
||||
interop/moc*
|
||||
|
||||
/internal/binding/dump/*
|
||||
/internal/binding/runtime/moc*
|
||||
/internal/cmd/moc/test/**/moc*
|
||||
/internal/examples/**/deploy
|
||||
/internal/examples/**/moc*
|
||||
/internal/examples/**/rcc*
|
||||
/internal/examples/**/uic*
|
||||
|
||||
flutter/*lutter*
|
||||
165
vendor/github.com/therecipe/qt/LICENSE
generated
vendored
Normal file
165
vendor/github.com/therecipe/qt/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
97
vendor/github.com/therecipe/qt/README.md
generated
vendored
Normal file
97
vendor/github.com/therecipe/qt/README.md
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
Introduction
|
||||
------------
|
||||
|
||||
[Qt](https://en.wikipedia.org/wiki/Qt_(software)) is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms with little or no change in the underlying codebase.
|
||||
|
||||
[Go](https://en.wikipedia.org/wiki/Go_(programming_language)), also known as Golang, is a programming language designed at Google.
|
||||
|
||||
[therecipe/qt](https://github.com/therecipe/qt) allows you to write Qt applications entirely in Go, [JavaScript/TypeScript](https://github.com/therecipe/entry), [Dart/Flutter](https://github.com/therecipe/flutter), [Haxe](https://github.com/therecipe/haxe) and [Swift](https://github.com/therecipe/swift)
|
||||
|
||||
Beside the language bindings provided, `therecipe/qt` also greatly simplifies the deployment of Qt applications to various software and hardware platforms.
|
||||
|
||||
At the time of writing, almost all Qt functions and classes are accessible, and you should be able to find everything you need to build fully featured Qt applications.
|
||||
|
||||
Impressions
|
||||
-----------
|
||||
|
||||
[Gallery](https://github.com/therecipe/qt/wiki/Gallery) of example applications.
|
||||
|
||||
[JavaScript Demo](https://therecipe.github.io/entry) | *[source](https://github.com/therecipe/entry)*
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
The following instructions assume that you already installed [Go](https://golang.org/dl/) and [Git](https://git-scm.com/downloads)
|
||||
|
||||
#### (Experimental) cgo-less version (try this first, if you are new and want to test the binding)
|
||||
|
||||
##### Windows
|
||||
|
||||
```powershell
|
||||
go get -ldflags="-w" github.com/therecipe/examples/basic/widgets && for /f %v in ('go env GOPATH') do %v\bin\widgets.exe
|
||||
```
|
||||
|
||||
##### macOS/Linux
|
||||
|
||||
```bash
|
||||
go get -ldflags="-w" github.com/therecipe/examples/basic/widgets && $(go env GOPATH)/bin/widgets
|
||||
```
|
||||
|
||||
#### Default version
|
||||
|
||||
##### Windows [(more info)](https://github.com/therecipe/qt/wiki/Installation-on-Windows)
|
||||
|
||||
```powershell
|
||||
set GO111MODULE=off
|
||||
go get -v github.com/therecipe/qt/cmd/... && for /f %v in ('go env GOPATH') do %v\bin\qtsetup test && %v\bin\qtsetup -test=false
|
||||
```
|
||||
|
||||
##### macOS [(more info)](https://github.com/therecipe/qt/wiki/Installation-on-macOS)
|
||||
|
||||
```bash
|
||||
export GO111MODULE=off; xcode-select --install; go get -v github.com/therecipe/qt/cmd/... && $(go env GOPATH)/bin/qtsetup test && $(go env GOPATH)/bin/qtsetup -test=false
|
||||
```
|
||||
|
||||
##### Linux [(more info)](https://github.com/therecipe/qt/wiki/Installation-on-Linux)
|
||||
|
||||
```bash
|
||||
export GO111MODULE=off; go get -v github.com/therecipe/qt/cmd/... && $(go env GOPATH)/bin/qtsetup test && $(go env GOPATH)/bin/qtsetup -test=false
|
||||
```
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
- [Installation](https://github.com/therecipe/qt/wiki/Installation)
|
||||
- [Getting Started](https://github.com/therecipe/qt/wiki/Getting-Started)
|
||||
- [Wiki](https://github.com/therecipe/qt/wiki)
|
||||
- [Qt Documentation](https://doc.qt.io/qt-5/classes.html)
|
||||
- [FAQ](https://github.com/therecipe/qt/wiki/FAQ)
|
||||
- [#qt-binding](https://gophers.slack.com/messages/qt-binding/details) Slack channel ([invite](https://invite.slack.golangbridge.org)\)
|
||||
|
||||
Deployment Targets
|
||||
------------------
|
||||
|
||||
| Target | Arch | Linkage | Docker Deployment | Host OS |
|
||||
|:------------------------:|:----------------:|:-------------------------:|:-----------------:|:-------:|
|
||||
| Windows | 32 / 64 | dynamic / static | Yes | Any |
|
||||
| macOS | 64 | dynamic | Yes | Any |
|
||||
| Linux | arm / arm64 / 64 | dynamic / static / system | Yes | Any |
|
||||
| Android (+Wear) | arm / arm64 | dynamic | Yes | Any |
|
||||
| Android-Emulator (+Wear) | 32 | dynamic | Yes | Any |
|
||||
| SailfishOS | arm | system | Yes | Any |
|
||||
| SailfishOS-Emulator | 32 | system | Yes | Any |
|
||||
| Raspberry Pi (1/2/3) | arm | dynamic / system | Yes | Any |
|
||||
| Ubuntu Touch | arm / 64 | system | Yes | Any |
|
||||
| JavaScript | 32 | static | Yes | Any |
|
||||
| WebAssembly | 32 | static | Yes | Any |
|
||||
| iOS | arm64 | static | No | macOS |
|
||||
| iOS-Simulator | 64 | static | No | macOS |
|
||||
| AsteroidOS | arm | system | No | Linux |
|
||||
| FreeBSD | 32 / 64 | system | No | FreeBSD |
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
This package is released under [LGPLv3](https://opensource.org/licenses/LGPL-3.0)
|
||||
|
||||
Qt itself is licensed and available under multiple [licenses](https://www.qt.io/licensing).
|
||||
1
vendor/github.com/therecipe/qt/_config.yml
generated
vendored
Normal file
1
vendor/github.com/therecipe/qt/_config.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-cayman
|
||||
3
vendor/github.com/therecipe/qt/azure-pipelines.yml
generated
vendored
Normal file
3
vendor/github.com/therecipe/qt/azure-pipelines.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
jobs:
|
||||
-
|
||||
template: internal/docker/docker_pipelines_template.yml
|
||||
42777
vendor/github.com/therecipe/qt/core/core.go
generated
vendored
Normal file
42777
vendor/github.com/therecipe/qt/core/core.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
48992
vendor/github.com/therecipe/qt/gui/gui.go
generated
vendored
Normal file
48992
vendor/github.com/therecipe/qt/gui/gui.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
424
vendor/github.com/therecipe/qt/internal/internal.go
generated
vendored
Normal file
424
vendor/github.com/therecipe/qt/internal/internal.go
generated
vendored
Normal file
@@ -0,0 +1,424 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type Internal struct {
|
||||
PtrI uintptr `json:"___pointer"`
|
||||
ClassNameI string `json:"___className"`
|
||||
}
|
||||
|
||||
func (i *Internal) Pointer() uintptr {
|
||||
return i.PtrI
|
||||
}
|
||||
|
||||
func (i *Internal) SetPointer(p uintptr) {
|
||||
i.PtrI = p
|
||||
}
|
||||
|
||||
func (i *Internal) InitFromInternal(p uintptr, n string) {
|
||||
i.PtrI = p
|
||||
i.ClassNameI = n
|
||||
}
|
||||
|
||||
func (i *Internal) ClassNameInternalF() string {
|
||||
return i.ClassNameI
|
||||
}
|
||||
|
||||
var (
|
||||
callbackTable = make(map[uintptr]map[string]interface{})
|
||||
ConstructorTable = make(map[string]interface{})
|
||||
)
|
||||
|
||||
func registerFunctionInCallbackTable(ptr uintptr, fn string, f interface{}) {
|
||||
if _, ok := callbackTable[ptr]; !ok {
|
||||
callbackTable[ptr] = map[string]interface{}{fn: f}
|
||||
} else {
|
||||
callbackTable[ptr][fn] = f
|
||||
}
|
||||
}
|
||||
|
||||
func deregisterFunctionInCallbackTable(ptr uintptr, fn string) {
|
||||
delete(callbackTable[ptr], fn)
|
||||
}
|
||||
|
||||
func handleCallback(message string) string {
|
||||
//println("input:", message)
|
||||
var msg []interface{}
|
||||
json.Unmarshal([]byte(message), &msg)
|
||||
|
||||
meth := reflect.ValueOf(callbackTable[uintptr(msg[0].(float64))][msg[1].(string)])
|
||||
|
||||
rv := make([]reflect.Value, len(msg)-2)
|
||||
for i, v := range convertList(msg[2:]) {
|
||||
rv[i] = reflect.ValueOf(v).Convert(meth.Type().In(i))
|
||||
}
|
||||
|
||||
var output []byte
|
||||
if ret := meth.Call(rv); len(ret) > 0 {
|
||||
output, _ = json.Marshal(convertToJson(ret[0].Interface()))
|
||||
}
|
||||
|
||||
//println("output:", string(output))
|
||||
return string(output)
|
||||
}
|
||||
|
||||
func httpRequest(url string, msg string) string {
|
||||
|
||||
resp, err := http.Post("http://127.0.0.1:8000/"+url, "text", strings.NewReader(msg))
|
||||
if err != nil {
|
||||
fmt.Printf("httpRequest error: %v -> %v\n", msg, err.Error())
|
||||
return ""
|
||||
}
|
||||
|
||||
bb := new(bytes.Buffer)
|
||||
io.Copy(bb, resp.Body)
|
||||
resp.Body.Close()
|
||||
|
||||
return bb.String()
|
||||
}
|
||||
|
||||
func syncCallIntoLocal(msg string) string {
|
||||
return httpRequest("syncCallIntoLocal", msg)
|
||||
}
|
||||
|
||||
func asyncCallIntoRemoteResponse(msg string) {
|
||||
httpRequest("asyncCallIntoRemoteResponse", msg)
|
||||
}
|
||||
|
||||
func syncCallIntoRemoteResponse(msg string) {
|
||||
httpRequest("syncCallIntoRemoteResponse", msg)
|
||||
}
|
||||
|
||||
func asyncCallbackHandler(message string) {
|
||||
asyncCallIntoRemoteResponse(handleCallback(message))
|
||||
}
|
||||
|
||||
func syncCallbackHandler(message string) {
|
||||
syncCallIntoRemoteResponse(handleCallback(message))
|
||||
}
|
||||
|
||||
func convertList(l []interface{}) []interface{} {
|
||||
for i := range l {
|
||||
l[i] = convert(l[i])
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func convertMap(m map[string]interface{}) map[string]interface{} {
|
||||
for i := range m {
|
||||
m[i] = convert(m[i])
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func convert(l interface{}) interface{} {
|
||||
|
||||
switch d := l.(type) {
|
||||
case map[string]interface{}:
|
||||
___className, okC := d["___className"]
|
||||
___pointer, okN := d["___pointer"]
|
||||
if okC && okN {
|
||||
return reflect.ValueOf(ConstructorTable[___className.(string)]).Call([]reflect.Value{reflect.ValueOf(unsafe.Pointer(uintptr(___pointer.(float64))))})[0].Interface()
|
||||
}
|
||||
return convertMap(d)
|
||||
case []interface{}:
|
||||
return convertList(d)
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
func convertListToJson(l []interface{}) []interface{} {
|
||||
for i := range l {
|
||||
l[i] = convertToJson(l[i])
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func convertMapToJson(l map[string]interface{}) map[string]interface{} {
|
||||
for k, v := range l {
|
||||
l[k] = convertToJson(v)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func convertToJson(i interface{}) interface{} {
|
||||
switch reflect.ValueOf(i).Kind() {
|
||||
case reflect.Map:
|
||||
return convertMapToJson(i.(map[string]interface{}))
|
||||
|
||||
case reflect.Slice:
|
||||
switch i.(type) {
|
||||
//TODO:
|
||||
case []string:
|
||||
case []uint, []uint8, []uint16, []uint32, []uint64:
|
||||
case []int, []int8, []int16, []int32, []int64:
|
||||
//
|
||||
//case []*qml.QQmlError:
|
||||
|
||||
default:
|
||||
return convertListToJson(i.([]interface{}))
|
||||
}
|
||||
|
||||
case reflect.Ptr:
|
||||
if !reflect.ValueOf(i).IsNil() {
|
||||
return map[string]interface{}{
|
||||
"___pointer": uintptr(reflect.ValueOf(i).MethodByName("Pointer").Call(nil)[0].Interface().(unsafe.Pointer)),
|
||||
"___className": reflect.ValueOf(i).MethodByName("ClassNameInternalF").Call(nil)[0].Interface(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
var inited = false
|
||||
|
||||
func init() {
|
||||
if inited {
|
||||
return
|
||||
}
|
||||
inited = true
|
||||
}
|
||||
|
||||
func functionName(fnDef string, fnOpt string) string {
|
||||
if strings.Contains(fnOpt, ":") {
|
||||
return strings.Split(fnOpt, ":")[1]
|
||||
}
|
||||
return fnDef
|
||||
}
|
||||
|
||||
func CallLocalAndRegisterRemoteFunction(l []interface{}, f interface{}) interface{} {
|
||||
registerFunctionInCallbackTable(uintptr(l[1].(uintptr)), functionName(l[3].(string), l[4].(string)), f)
|
||||
return CallLocalFunction(l)
|
||||
}
|
||||
|
||||
func CallLocalAndDeregisterRemoteFunction(l []interface{}) {
|
||||
CallLocalFunction(l)
|
||||
deregisterFunctionInCallbackTable(l[1].(uintptr), l[3].(string))
|
||||
}
|
||||
|
||||
func CallLocalFunction(l []interface{}) interface{} {
|
||||
msg, _ := json.Marshal(convertToJson(l))
|
||||
var output interface{}
|
||||
json.Unmarshal([]byte(syncCallIntoLocal(string(msg))), &output)
|
||||
|
||||
switch d := output.(type) {
|
||||
case []string: //TODO: dead code?
|
||||
if len(d) == 2 && d[0] == "___block" {
|
||||
return CallLocalFunction([]interface{}{"___return", handleCallback(d[1])})
|
||||
}
|
||||
|
||||
case []interface{}:
|
||||
if s, ok := d[0].(string); ok && len(d) == 2 && s == "___block" {
|
||||
return CallLocalFunction([]interface{}{"___return", handleCallback(d[1].(string))})
|
||||
}
|
||||
}
|
||||
|
||||
return convert(output)
|
||||
}
|
||||
|
||||
type InteropServerConfig struct {
|
||||
Download bool
|
||||
Override bool
|
||||
Path string
|
||||
DownloadUrl string
|
||||
}
|
||||
|
||||
var Config = &InteropServerConfig{
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
}
|
||||
|
||||
var proc *exec.Cmd
|
||||
|
||||
func InitProcess() {
|
||||
|
||||
var runPath string
|
||||
|
||||
if Config.Download && Config.Path == "" {
|
||||
|
||||
var ending string
|
||||
if runtime.GOOS == "windows" {
|
||||
ending = ".exe"
|
||||
}
|
||||
|
||||
pwd, _ := os.Getwd()
|
||||
arg, _ := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
|
||||
for i, path := range []string{pwd, arg} {
|
||||
if i == 1 && pwd == arg {
|
||||
continue
|
||||
}
|
||||
|
||||
runPath = filepath.Join(path, fmt.Sprintf("qtbox%v", ending))
|
||||
println("looking for qtbox in:", runPath)
|
||||
|
||||
if strings.HasPrefix(runPath, "/private/var/folders/") { //app is quarantined on macOS
|
||||
runPath = filepath.Join(os.TempDir(), "qtbox")
|
||||
break
|
||||
}
|
||||
|
||||
if strings.HasPrefix(runPath, "/var/folders/") ||
|
||||
strings.HasPrefix(runPath, "/tmp/go-build") {
|
||||
runPath = filepath.Join(pwd, "qtbox")
|
||||
break
|
||||
}
|
||||
|
||||
if _, err := os.Stat(runPath); err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
dst := filepath.Dir(runPath)
|
||||
_, err := os.Stat(runPath)
|
||||
f, errF := os.Stat(filepath.Join(dst, "qtbox"))
|
||||
if errF == nil && f.IsDir() {
|
||||
runPath = filepath.Join(dst, "qtbox", "qtbox"+ending)
|
||||
}
|
||||
|
||||
println("final qtbox location:", runPath)
|
||||
|
||||
if Config.Override || (err != nil && errF != nil) {
|
||||
|
||||
var copyWithProgress = func(w io.Writer, r io.Reader, callback func(off int64)) error {
|
||||
tee := io.TeeReader(r, w)
|
||||
buf := make([]byte, bytes.MinRead*10)
|
||||
off := int64(0)
|
||||
for count := 0; ; count++ {
|
||||
n, err := tee.Read(buf)
|
||||
off += int64(n)
|
||||
if count%100 == 0 {
|
||||
callback(off)
|
||||
}
|
||||
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
callback(off)
|
||||
return nil
|
||||
}
|
||||
|
||||
dlpath := fmt.Sprintf("https://github.com/therecipe/box/releases/download/v0.0.0/%v_%v_%v_%v_%v.zip", runtime.GOOS, runtime.GOARCH, "513", "full", "http")
|
||||
if Config.DownloadUrl != "" {
|
||||
dlpath = Config.DownloadUrl
|
||||
}
|
||||
resp, err := http.Get(dlpath)
|
||||
if err != nil {
|
||||
println("failed to download qtbox:", err.Error())
|
||||
} else {
|
||||
|
||||
bb := new(bytes.Buffer)
|
||||
copyWithProgress(bb, resp.Body, func(off int64) {
|
||||
fmt.Printf("downloading qtbox => %v%%\n", off/(resp.ContentLength/100))
|
||||
})
|
||||
resp.Body.Close()
|
||||
|
||||
r, _ := zip.NewReader(bytes.NewReader(bb.Bytes()), int64(bb.Len()))
|
||||
if len(r.File) == 1 {
|
||||
fr, _ := r.File[0].Open()
|
||||
fw, _ := os.OpenFile(runPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, r.File[0].Mode())
|
||||
io.Copy(fw, fr)
|
||||
fr.Close()
|
||||
fw.Close()
|
||||
} else {
|
||||
|
||||
for _, f := range r.File {
|
||||
|
||||
//TODO: pack runtimes with correct name
|
||||
fns := strings.Split(f.Name, "/")
|
||||
fns[0] = "qtbox"
|
||||
f.Name = strings.Join(fns, "/")
|
||||
//
|
||||
|
||||
if f.FileInfo().IsDir() {
|
||||
os.MkdirAll(filepath.Join(dst, f.Name), f.Mode())
|
||||
continue
|
||||
}
|
||||
|
||||
dn, fn := filepath.Split(f.Name)
|
||||
if strings.HasPrefix(fn, "full") { //TODO: pack runtimes with correct name
|
||||
fn = filepath.Join(dn, "qtbox"+ending)
|
||||
} else {
|
||||
fn = f.Name
|
||||
}
|
||||
|
||||
fw, errC := os.OpenFile(filepath.Join(dst, fn), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
|
||||
if errC != nil {
|
||||
println("failed to create file", errC.Error())
|
||||
}
|
||||
|
||||
fr, errR := f.Open()
|
||||
if errR != nil {
|
||||
println("failed to read file", errR.Error())
|
||||
}
|
||||
|
||||
io.Copy(fw, fr)
|
||||
|
||||
fw.Close()
|
||||
fr.Close()
|
||||
}
|
||||
|
||||
runPath = filepath.Join(dst, "qtbox", "qtbox"+ending)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if Config.Path != "" {
|
||||
runPath = Config.Path
|
||||
}
|
||||
|
||||
process := exec.Command(runPath)
|
||||
rc, err := process.StderrPipe()
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
}
|
||||
process.Start()
|
||||
|
||||
time.Sleep(3 * time.Second) //TODO:
|
||||
|
||||
scanner := bufio.NewScanner(rc)
|
||||
|
||||
go func() {
|
||||
for scanner.Scan() {
|
||||
if l := scanner.Text(); strings.Contains(l, "async:") {
|
||||
go asyncCallbackHandler(strings.Split(l, "async:")[1])
|
||||
} else if strings.Contains(l, "sync:") {
|
||||
go syncCallbackHandler(strings.Split(l, "sync:")[1])
|
||||
} else {
|
||||
println(l)
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
println("reading stderr:", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
proc = process
|
||||
}
|
||||
|
||||
func Exec() {
|
||||
proc.Wait()
|
||||
}
|
||||
8
vendor/github.com/therecipe/qt/interop/gow/gow.go
generated
vendored
Normal file
8
vendor/github.com/therecipe/qt/interop/gow/gow.go
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
package gow
|
||||
|
||||
import "github.com/therecipe/qt/internal"
|
||||
|
||||
var (
|
||||
InitProcess = internal.InitProcess
|
||||
Exec = internal.Exec
|
||||
)
|
||||
332
vendor/github.com/therecipe/qt/qt.go
generated
vendored
Normal file
332
vendor/github.com/therecipe/qt/qt.go
generated
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
package qt
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
Logger = log.New(os.Stderr, "", log.Ltime)
|
||||
|
||||
signals = make(map[unsafe.Pointer]map[string]unsafe.Pointer)
|
||||
signalsJNI = make(map[string]map[string]unsafe.Pointer)
|
||||
signalsMutex sync.Mutex
|
||||
|
||||
objects = make(map[unsafe.Pointer]interface{})
|
||||
objectsMutex sync.Mutex
|
||||
|
||||
objectsTemp = make(map[unsafe.Pointer]unsafe.Pointer)
|
||||
objectsTempMutex sync.Mutex
|
||||
|
||||
connectionTypes = make(map[unsafe.Pointer]map[string]int64)
|
||||
connectionTypesMutex sync.Mutex
|
||||
|
||||
finalizerMap = make(map[unsafe.Pointer]struct{})
|
||||
finalizerMapMutex sync.Mutex
|
||||
|
||||
//
|
||||
|
||||
FuncMap = make(map[string]interface{})
|
||||
FuncMapMutex sync.Mutex
|
||||
ItfMap = make(map[string]interface{})
|
||||
itfMapMutex sync.Mutex
|
||||
EnumMap = make(map[string]int64)
|
||||
EnumMapMutex sync.Mutex
|
||||
)
|
||||
|
||||
func init() { runtime.LockOSThread() }
|
||||
|
||||
func ExistsSignal(cPtr unsafe.Pointer, signal string) (exists bool) {
|
||||
signalsMutex.Lock()
|
||||
_, exists = signals[cPtr][signal]
|
||||
signalsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func LendSignal(cPtr unsafe.Pointer, signal string) (s unsafe.Pointer) {
|
||||
signalsMutex.Lock()
|
||||
s = signals[cPtr][signal]
|
||||
signalsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func lendSignalJNI(cPtr, signal string) (s unsafe.Pointer) {
|
||||
signalsMutex.Lock()
|
||||
s = signalsJNI[cPtr][signal]
|
||||
signalsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func GetSignal(cPtr interface{}, signal string) unsafe.Pointer {
|
||||
if dcPtr, ok := cPtr.(unsafe.Pointer); ok {
|
||||
if signal == "destroyed" || strings.HasPrefix(signal, "~") {
|
||||
defer DisconnectAllSignals(dcPtr, signal)
|
||||
}
|
||||
return LendSignal(dcPtr, signal)
|
||||
}
|
||||
return lendSignalJNI(cPtr.(string), signal)
|
||||
}
|
||||
|
||||
func ConnectSignal(cPtr interface{}, signal string, function unsafe.Pointer) {
|
||||
if dcPtr, ok := cPtr.(unsafe.Pointer); ok {
|
||||
signalsMutex.Lock()
|
||||
if s, exists := signals[dcPtr]; !exists {
|
||||
signals[dcPtr] = map[string]unsafe.Pointer{signal: function}
|
||||
} else {
|
||||
s[signal] = function
|
||||
}
|
||||
signalsMutex.Unlock()
|
||||
} else {
|
||||
connectSignalJNI(cPtr.(string), signal, function)
|
||||
}
|
||||
}
|
||||
|
||||
func connectSignalJNI(cPtr, signal string, function unsafe.Pointer) {
|
||||
signalsMutex.Lock()
|
||||
if s, exists := signalsJNI[cPtr]; !exists {
|
||||
signalsJNI[cPtr] = map[string]unsafe.Pointer{signal: function}
|
||||
} else {
|
||||
s[signal] = function
|
||||
}
|
||||
signalsMutex.Unlock()
|
||||
}
|
||||
|
||||
func DisconnectSignal(cPtr interface{}, signal string) {
|
||||
if dcPtr, ok := cPtr.(unsafe.Pointer); ok {
|
||||
signalsMutex.Lock()
|
||||
delete(signals[dcPtr], signal)
|
||||
if len(signals[dcPtr]) == 0 {
|
||||
delete(signals, dcPtr)
|
||||
}
|
||||
signalsMutex.Unlock()
|
||||
} else {
|
||||
disconnectSignalJNI(cPtr.(string), signal)
|
||||
}
|
||||
}
|
||||
|
||||
func disconnectSignalJNI(cPtr, signal string) {
|
||||
signalsMutex.Lock()
|
||||
delete(signalsJNI[cPtr], signal)
|
||||
if len(signalsJNI[cPtr]) == 0 {
|
||||
delete(signalsJNI, cPtr)
|
||||
}
|
||||
signalsMutex.Unlock()
|
||||
}
|
||||
|
||||
func DisconnectAllSignals(cPtr unsafe.Pointer, signal string) {
|
||||
signalsMutex.Lock()
|
||||
if s, exists := signals[cPtr]["destroyed"]; signal != "destroyed" && exists {
|
||||
signals[cPtr] = map[string]unsafe.Pointer{"destroyed": s}
|
||||
} else {
|
||||
delete(signals, cPtr)
|
||||
}
|
||||
signalsMutex.Unlock()
|
||||
}
|
||||
|
||||
func DumpSignals() {
|
||||
Debug("##############################\tSIGNALS_TABLE_START\t##############################")
|
||||
signalsMutex.Lock()
|
||||
for cPtr, entry := range signals {
|
||||
Debug(cPtr, entry)
|
||||
}
|
||||
signalsMutex.Unlock()
|
||||
Debug("##############################\tSIGNALS_TABLE_END\t##############################")
|
||||
}
|
||||
|
||||
func DumpObjects() {
|
||||
Debug("##############################\tOBJECTS_TABLE_START\t##############################")
|
||||
objectsMutex.Lock()
|
||||
for cPtr, entry := range objects {
|
||||
Debug(cPtr, entry)
|
||||
}
|
||||
objectsMutex.Unlock()
|
||||
Debug("##############################\tOBJECTS_TABLE_END\t##############################")
|
||||
}
|
||||
|
||||
func DumpTempObjects() {
|
||||
Debug("##############################\tTMP_OBJECTS_TABLE_START\t##############################")
|
||||
objectsTempMutex.Lock()
|
||||
for cPtr, entry := range objectsTemp {
|
||||
Debug(cPtr, entry)
|
||||
}
|
||||
objectsTempMutex.Unlock()
|
||||
Debug("##############################\tTMP_OBJECTS_TABLE_END\t##############################")
|
||||
}
|
||||
|
||||
func DumpConnectionTypes() {
|
||||
Debug("##############################\tCON_MODES_TABLE_START\t##############################")
|
||||
connectionTypesMutex.Lock()
|
||||
for cPtr, entry := range connectionTypes {
|
||||
Debug(cPtr, entry)
|
||||
}
|
||||
connectionTypesMutex.Unlock()
|
||||
Debug("##############################\tCON_MODES_TABLE_END\t##############################")
|
||||
}
|
||||
|
||||
func CountSignals() (c int) {
|
||||
signalsMutex.Lock()
|
||||
c = len(signals)
|
||||
signalsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func GoBoolToInt(b bool) int8 {
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func Recover(fn string) {
|
||||
if recover() != nil {
|
||||
Debug("RECOVERED:", fn)
|
||||
}
|
||||
}
|
||||
|
||||
func Debug(fn ...interface{}) {
|
||||
if strings.ToLower(os.Getenv("QT_DEBUG")) == "true" || runtime.GOARCH == "js" || runtime.GOARCH == "wasm" {
|
||||
Logger.Println(fn...)
|
||||
}
|
||||
}
|
||||
|
||||
func ClearSignals() {
|
||||
signalsMutex.Lock()
|
||||
signals = make(map[unsafe.Pointer]map[string]unsafe.Pointer)
|
||||
signalsMutex.Unlock()
|
||||
}
|
||||
|
||||
func Register(cPtr unsafe.Pointer, gPtr interface{}) {
|
||||
objectsMutex.Lock()
|
||||
objects[cPtr] = gPtr
|
||||
objectsMutex.Unlock()
|
||||
}
|
||||
|
||||
func Receive(cPtr unsafe.Pointer) (o interface{}, ok bool) {
|
||||
objectsMutex.Lock()
|
||||
o, ok = objects[cPtr]
|
||||
objectsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func Unregister(cPtr unsafe.Pointer) {
|
||||
objectsMutex.Lock()
|
||||
delete(objects, cPtr)
|
||||
objectsMutex.Unlock()
|
||||
}
|
||||
|
||||
func RegisterTemp(cPtr unsafe.Pointer, gPtr unsafe.Pointer) {
|
||||
objectsTempMutex.Lock()
|
||||
objectsTemp[cPtr] = gPtr
|
||||
objectsTempMutex.Unlock()
|
||||
}
|
||||
|
||||
func ReceiveTemp(cPtr unsafe.Pointer) (o unsafe.Pointer, ok bool) {
|
||||
objectsTempMutex.Lock()
|
||||
o, ok = objectsTemp[cPtr]
|
||||
objectsTempMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func UnregisterTemp(cPtr unsafe.Pointer) {
|
||||
objectsTempMutex.Lock()
|
||||
delete(objectsTemp, cPtr)
|
||||
objectsTempMutex.Unlock()
|
||||
}
|
||||
|
||||
func RegisterConnectionType(cPtr unsafe.Pointer, signal string, mode int64) {
|
||||
connectionTypesMutex.Lock()
|
||||
if s, exists := connectionTypes[cPtr]; !exists {
|
||||
connectionTypes[cPtr] = map[string]int64{signal: mode}
|
||||
} else {
|
||||
s[signal] = mode
|
||||
}
|
||||
connectionTypesMutex.Unlock()
|
||||
}
|
||||
|
||||
func ConnectionType(cPtr unsafe.Pointer, signal string) (m int64) {
|
||||
connectionTypesMutex.Lock()
|
||||
if s, exists := connectionTypes[cPtr]; exists {
|
||||
if lm, ok := s[signal]; ok {
|
||||
delete(s, signal)
|
||||
if len(s) == 0 {
|
||||
delete(connectionTypes, cPtr)
|
||||
}
|
||||
m = lm
|
||||
}
|
||||
}
|
||||
connectionTypesMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func GetFuncMap(n string) (o interface{}, ok bool) {
|
||||
FuncMapMutex.Lock()
|
||||
o, ok = FuncMap[n]
|
||||
FuncMapMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func SetFuncMap(n string, v interface{}) {
|
||||
FuncMapMutex.Lock()
|
||||
FuncMap[n] = v
|
||||
FuncMapMutex.Unlock()
|
||||
}
|
||||
|
||||
func GetItfMap(n string) (o interface{}, ok bool) {
|
||||
itfMapMutex.Lock()
|
||||
o, ok = ItfMap[n]
|
||||
itfMapMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func SetItfMap(n string, v interface{}) {
|
||||
itfMapMutex.Lock()
|
||||
ItfMap[n] = v
|
||||
itfMapMutex.Unlock()
|
||||
}
|
||||
|
||||
func GetEnumMap(n string) (o int64, ok bool) {
|
||||
EnumMapMutex.Lock()
|
||||
o, ok = EnumMap[n]
|
||||
EnumMapMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func SetEnumMap(n string, v int64) {
|
||||
EnumMapMutex.Lock()
|
||||
EnumMap[n] = v
|
||||
EnumMapMutex.Unlock()
|
||||
}
|
||||
|
||||
type ptr_itf interface {
|
||||
Pointer() unsafe.Pointer
|
||||
SetPointer(p unsafe.Pointer)
|
||||
}
|
||||
|
||||
func SetFinalizer(ptr interface{}, f interface{}) {
|
||||
finalizerMapMutex.Lock()
|
||||
cPtr := ptr.(ptr_itf).Pointer()
|
||||
if _, ok := finalizerMap[cPtr]; !ok || f == nil || cPtr == nil {
|
||||
if cPtr != nil || (cPtr == nil && f == nil) {
|
||||
runtime.SetFinalizer(ptr, f)
|
||||
}
|
||||
if f == nil {
|
||||
delete(finalizerMap, cPtr)
|
||||
} else if cPtr != nil {
|
||||
finalizerMap[cPtr] = struct{}{}
|
||||
}
|
||||
} else {
|
||||
runtime.SetFinalizer(ptr, func(p ptr_itf) { p.SetPointer(nil) })
|
||||
}
|
||||
finalizerMapMutex.Unlock()
|
||||
}
|
||||
|
||||
func HasFinalizer(ptr interface{}) (ok bool) {
|
||||
finalizerMapMutex.Lock()
|
||||
_, ok = finalizerMap[ptr.(ptr_itf).Pointer()]
|
||||
finalizerMapMutex.Unlock()
|
||||
return
|
||||
}
|
||||
92
vendor/github.com/therecipe/qt/qt_android.go
generated
vendored
Normal file
92
vendor/github.com/therecipe/qt/qt_android.go
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package qt
|
||||
|
||||
/*
|
||||
To view the log output run:
|
||||
adb logcat GoLog:I *:S
|
||||
*/
|
||||
|
||||
// Android redirects stdout and stderr to /dev/null.
|
||||
// As these are common debugging utilities in Go,
|
||||
// we redirect them to logcat.
|
||||
//
|
||||
// Unfortunately, logcat is line oriented, so we must buffer.
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -landroid -llog
|
||||
#include <android/log.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"log"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
ctag = C.CString("GoLog")
|
||||
// Store the writer end of the redirected stderr and stdout
|
||||
// so that they are not garbage collected and closed.
|
||||
stderr, stdout *os.File
|
||||
)
|
||||
|
||||
type infoWriter struct{}
|
||||
|
||||
func (infoWriter) Write(p []byte) (n int, err error) {
|
||||
cstr := C.CString(string(p))
|
||||
C.__android_log_write(C.ANDROID_LOG_INFO, ctag, cstr)
|
||||
C.free(unsafe.Pointer(cstr))
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func lineLog(f *os.File, priority C.int) {
|
||||
const logSize = 1024 // matches android/log.h.
|
||||
r := bufio.NewReaderSize(f, logSize)
|
||||
for {
|
||||
line, _, err := r.ReadLine()
|
||||
str := string(line)
|
||||
if err != nil {
|
||||
str += " " + err.Error()
|
||||
}
|
||||
cstr := C.CString(str)
|
||||
C.__android_log_write(priority, ctag, cstr)
|
||||
C.free(unsafe.Pointer(cstr))
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetOutput(infoWriter{})
|
||||
// android logcat includes all of log.LstdFlags
|
||||
log.SetFlags(log.Flags() &^ log.LstdFlags)
|
||||
|
||||
r, w, err := os.Pipe()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
stderr = w
|
||||
if err := syscall.Dup3(int(w.Fd()), int(os.Stderr.Fd()), 0); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go lineLog(r, C.ANDROID_LOG_ERROR)
|
||||
|
||||
r, w, err = os.Pipe()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
stdout = w
|
||||
if err := syscall.Dup3(int(w.Fd()), int(os.Stdout.Fd()), 0); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go lineLog(r, C.ANDROID_LOG_INFO)
|
||||
}
|
||||
27
vendor/github.com/therecipe/qt/qt_js.go
generated
vendored
Normal file
27
vendor/github.com/therecipe/qt/qt_js.go
generated
vendored
Normal file
@@ -0,0 +1,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
|
||||
}
|
||||
|
||||
//
|
||||
11
vendor/github.com/therecipe/qt/qt_notjs.go
generated
vendored
Normal file
11
vendor/github.com/therecipe/qt/qt_notjs.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// +build !js
|
||||
|
||||
package qt
|
||||
|
||||
type jsValue interface {
|
||||
Call(...string) jsValue
|
||||
Int() int
|
||||
}
|
||||
|
||||
var Global jsValue
|
||||
var Module jsValue
|
||||
20
vendor/github.com/therecipe/qt/qt_wasm.go
generated
vendored
Normal file
20
vendor/github.com/therecipe/qt/qt_wasm.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// +build js,wasm
|
||||
|
||||
package qt
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Module.Set("_callbackReleaseTypedArray", js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
ReleaseTypedArray(unsafe.Pointer(uintptr(args[0].Int())))
|
||||
return nil
|
||||
}))
|
||||
}
|
||||
|
||||
var Global = js.Global()
|
||||
var Module = Global.Call("eval", "Module")
|
||||
|
||||
//TODO: func MakeWrapper(i interface{}) *js.Value
|
||||
13
vendor/github.com/therecipe/qt/qt_wasm_112.go
generated
vendored
Normal file
13
vendor/github.com/therecipe/qt/qt_wasm_112.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// +build js,wasm
|
||||
// +build go1.12,!go1.13,!go1.14,!go1.15,!go1.16,!go1.17
|
||||
|
||||
package qt
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func TypedArrayOf(src []byte) js.TypedArray { return js.TypedArrayOf(src) }
|
||||
|
||||
func ReleaseTypedArray(p unsafe.Pointer) { (*js.TypedArray)(p).Release() }
|
||||
17
vendor/github.com/therecipe/qt/qt_wasm_113.go
generated
vendored
Normal file
17
vendor/github.com/therecipe/qt/qt_wasm_113.go
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// +build js,wasm
|
||||
// +build go1.13
|
||||
|
||||
package qt
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func TypedArrayOf(src []byte) js.Value {
|
||||
dst := Global.Get("Uint8Array").New(len(src))
|
||||
js.CopyBytesToJS(dst, src)
|
||||
return dst
|
||||
}
|
||||
|
||||
func ReleaseTypedArray(unsafe.Pointer) {}
|
||||
62288
vendor/github.com/therecipe/qt/widgets/widgets.go
generated
vendored
Normal file
62288
vendor/github.com/therecipe/qt/widgets/widgets.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11
vendor/modules.txt
vendored
Normal file
11
vendor/modules.txt
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e
|
||||
## explicit
|
||||
github.com/gopherjs/gopherjs/js
|
||||
# github.com/therecipe/qt v0.0.0-20200904063919-c0c124a5770d
|
||||
## explicit
|
||||
github.com/therecipe/qt
|
||||
github.com/therecipe/qt/core
|
||||
github.com/therecipe/qt/gui
|
||||
github.com/therecipe/qt/internal
|
||||
github.com/therecipe/qt/interop/gow
|
||||
github.com/therecipe/qt/widgets
|
||||
Reference in New Issue
Block a user