Files
openchamber-android-native/third_party/mygo/native/internal/roundtrip/roundtrip_native.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
2026-11-18 13:22:59 +08:00

725 lines
15 KiB
Go

// Code generated by mygo generate from the interfaces of the native module. DO NOT EDIT.
// mygo:native 3 aebdfd9f7bfb2215
package roundtrip
import (
"context"
_context "context"
_fmt "fmt"
"io"
"iter"
_filepath "path/filepath"
_runtime "runtime"
"time"
"github.com/egoist/mygo/native"
_native "github.com/egoist/mygo/native"
"github.com/egoist/mygo/ui"
)
// _module describes the module to the runtime.
var _module = &_native.Module{Name: "Roundtrip", Symbol: "roundtrip", Langs: []string{"swift", "kotlin", "rust", "zig"}, SwiftOS: []string{"macos", "ios"}, MinMacOS: "13", MinIOS: "16", Kotlin: "com.github.egoist.mygo.native_.internal.roundtrip.MygoModule", Dir: _dir(), Errors: []*_native.Error{ErrNamed}, Deps: []string{}}
// _dir returns the package's directory when the binary knows it, where
// mygo dev builds the implementation for go test and go run.
func _dir() string {
_, file, _, ok := _runtime.Caller(0)
if !ok || !_filepath.IsAbs(file) {
return ""
}
return _filepath.Dir(file)
}
func init() {
_native.Register(_module, map[string]_native.Wrapper{
"Echo": {Flags: 0, Wrap: func(o *_native.Object) any { return &_Echo{o} }},
"Counter": {Flags: 0, Wrap: func(o *_native.Object) any { return &_Counter{o} }},
})
}
// NewEcho makes the implementation of Echo on this platform. It returns
// errors.ErrUnsupported where the module has none, or the system lacks
// what it needs.
func NewEcho() (Echo, error) {
o, err := _module.New("Echo", 0)
if err != nil {
return nil, err
}
return &_Echo{o}, nil
}
// _Echo calls the platform's implementation of Echo.
type _Echo struct{ o *_native.Object }
// NativeObject returns the platform's object.
func (x *_Echo) NativeObject() *_native.Object { return x.o }
// _wrapEcho wraps a handle of the platform's, or returns nil.
func _wrapEcho(h uint64) Echo {
if h == 0 {
return nil
}
return &_Echo{_module.Object(h, 0)}
}
func (_x *_Echo) Scalars(i int, i8 int8, u16 uint16, i32 int32, u64 uint64, f32 float32, f float64, b bool) Scalars {
_e := _native.NewEncoder()
_e.Int(int64(i))
_e.Int(int64(i8))
_e.Int(int64(u16))
_e.Int(int64(i32))
_e.Int(int64(u64))
_e.Float(float64(f32))
_e.Float(float64(f))
_e.Bool(b)
var _r Scalars
_d, _err := _x.NativeObject().Call("Echo_Scalars", 0, _e)
if _err == nil {
_r = _dec_Scalars(_d)
_err = _d.Close()
}
_ = _err
return _r
}
func (_x *_Echo) Add(a int, b int) int {
return int(_x.NativeObject().Direct("Echo_Add_direct", uintptr(a), uintptr(b)))
}
func (_x *_Echo) Text(s string, b []byte) Texts {
_e := _native.NewEncoder()
_e.String(s)
_e.Bytes(b)
var _r Texts
_d, _err := _x.NativeObject().Call("Echo_Text", 0, _e)
if _err == nil {
_r = _dec_Texts(_d)
_err = _d.Close()
}
_ = _err
return _r
}
func (_x *_Echo) Record(r Record) (Record, error) {
_e := _native.NewEncoder()
_enc_Record(_e, r)
var _r Record
_d, _err := _x.NativeObject().Call("Echo_Record", 0, _e)
if _err == nil {
_r = _dec_Record(_d)
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Lists(words []string, nested [][]int) (map[string]int, error) {
_e := _native.NewEncoder()
_enc_slice_string(_e, words)
_enc_slice_slice_int(_e, nested)
var _r map[string]int
_d, _err := _x.NativeObject().Call("Echo_Lists", 0, _e)
if _err == nil {
_r = _dec_map_int(_d)
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Maybe(p *int) *int {
_e := _native.NewEncoder()
_enc_ptr_int(_e, p)
var _r *int
_d, _err := _x.NativeObject().Call("Echo_Maybe", 0, _e)
if _err == nil {
_r = _dec_ptr_int(_d)
_err = _d.Close()
}
_ = _err
return _r
}
func (_x *_Echo) Times(t time.Time, d time.Duration) (Moment, error) {
_e := _native.NewEncoder()
_e.Time(t)
_e.Duration(d)
var _r Moment
_d, _err := _x.NativeObject().Call("Echo_Times", 0, _e)
if _err == nil {
_r = _dec_Moment(_d)
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Kind(k Kind, l Level) (Kinds, error) {
_e := _native.NewEncoder()
_enc_Kind(_e, k)
_enc_Level(_e, l)
var _r Kinds
_d, _err := _x.NativeObject().Call("Echo_Kind", 0, _e)
if _err == nil {
_r = _dec_Kinds(_d)
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Fail(name string) error {
_e := _native.NewEncoder()
_e.String(name)
_d, _err := _x.NativeObject().Call("Echo_Fail", 0, _e)
if _err == nil {
_err = _d.Close()
}
return _err
}
func (_x *_Echo) Wait(_ctx context.Context, d time.Duration, s string) (string, error) {
_e := _native.NewEncoder()
_e.Duration(d)
_e.String(s)
var _r string
_d, _err := _x.NativeObject().CallContext(_ctx, "Echo_Wait", 0, _e)
if _err == nil {
_r = _d.String()
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Count(_ctx context.Context, n int, fail int) iter.Seq2[int, error] {
return _native.Stream(_ctx, _x.NativeObject(), "Echo_Count", 0, func() (*_native.Encoder, []uint64) {
_e := _native.NewEncoder()
_e.Int(int64(n))
_e.Int(int64(fail))
return _e, nil
}, func(_d *_native.Decoder) int { return int(_d.Int()) })
}
func (_x *_Echo) Records(_ctx context.Context, n int) iter.Seq2[Record, error] {
return _native.Stream(_ctx, _x.NativeObject(), "Echo_Records", 0, func() (*_native.Encoder, []uint64) {
_e := _native.NewEncoder()
_e.Int(int64(n))
return _e, nil
}, func(_d *_native.Decoder) Record { return _dec_Record(_d) })
}
func (_x *_Echo) Counter(n int) (Counter, error) {
_e := _native.NewEncoder()
_e.Int(int64(n))
var _h uint64
_d, _err := _x.NativeObject().Call("Echo_Counter", 0, _e)
if _err == nil {
_h = _d.Uint()
_err = _d.Close()
}
if _err != nil {
return nil, _err
}
return _wrapCounter(_h), nil
}
func (_x *_Echo) Each(words []string, f func(word string, i int)) int {
var _f1 uint64
if f != nil {
_f1 = _native.Func(func(_d *_native.Decoder, _e *_native.Encoder) error {
_p0 := _d.String()
_p1 := int(_d.Int())
if _err := _d.Err(); _err != nil {
return _err
}
f(_p0, _p1)
return nil
}, true)
}
_e := _native.NewEncoder()
_enc_slice_string(_e, words)
_e.Uint(_f1)
var _r int
_d, _err := _x.NativeObject().Call("Echo_Each", 0, _e)
if _err == nil {
_r = int(_d.Int())
_err = _d.Close()
}
if _err != nil {
_native.Forget(_f1)
}
_ = _err
return _r
}
func (_x *_Echo) Ask(ns []int, f func(n int) (int, error)) (int, error) {
var _f1 uint64
if f != nil {
_f1 = _native.Func(func(_d *_native.Decoder, _e *_native.Encoder) error {
_p0 := int(_d.Int())
if _err := _d.Err(); _err != nil {
return _err
}
_r, _err := f(_p0)
if _err != nil {
return _err
}
_e.Int(int64(_r))
return nil
}, false)
}
_e := _native.NewEncoder()
_enc_slice_int(_e, ns)
_e.Uint(_f1)
var _r int
_d, _err := _x.NativeObject().Call("Echo_Ask", 0, _e)
if _err == nil {
_r = int(_d.Int())
_err = _d.Close()
}
if _err != nil {
_native.Forget(_f1)
}
return _r, _err
}
func (_x *_Echo) Ticks(interval time.Duration, f func(n int)) io.Closer {
var _f1 uint64
if f != nil {
_f1 = _native.Func(func(_d *_native.Decoder, _e *_native.Encoder) error {
_p0 := int(_d.Int())
if _err := _d.Err(); _err != nil {
return _err
}
f(_p0)
return nil
}, true)
}
_e := _native.NewEncoder()
_e.Duration(interval)
_e.Uint(_f1)
return _x.NativeObject().Subscribe("Echo_Ticks", 0, _e, _f1)
}
func (_x *_Echo) Use(_ctx context.Context, s Scorer, words []string) (float64, error) {
var _g0 uint64
if s != nil {
_g0 = _native.Export(_module, s, func(_c _context.Context, _m int, _d *_native.Decoder, _e *_native.Encoder) error {
return _dispatchScorer(s, _c, _m, _d, _e)
})
}
_e := _native.NewEncoder()
_e.Uint(_g0)
_enc_slice_string(_e, words)
var _r float64
_d, _err := _x.NativeObject().CallContext(_ctx, "Echo_Use", 0, _e)
if _err == nil {
_r = float64(_d.Float())
_err = _d.Close()
}
if _err != nil {
_native.Forget(_g0)
}
return _r, _err
}
func (_x *_Echo) Fill(buf *native.Buffer, x int) (int, error) {
defer _runtime.KeepAlive(buf)
_e := _native.NewEncoder()
_e.Buffer(buf)
_e.Int(int64(x))
var _r int
_d, _err := _x.NativeObject().Call("Echo_Fill", 0, _e)
if _err == nil {
_r = int(_d.Int())
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Mix(f float32, d float64, b bool, i int8) float64 {
return float64(_native.FloatResult(_x.NativeObject().Direct("Echo_Mix_direct", _native.FloatArg(float64(f)), _native.FloatArg(float64(d)), _native.BoolArg(b), uintptr(i))))
}
func (_x *_Echo) Box(r ui.Rect) (ui.Rect, error) {
_e := _native.NewEncoder()
_e.Rect(r.X, r.Y, r.W, r.H)
var _r ui.Rect
_d, _err := _x.NativeObject().Call("Echo_Box", 0, _e)
if _err == nil {
_r = ui.Rect{X: float32(_d.Float()), Y: float32(_d.Float()), W: float32(_d.Float()), H: float32(_d.Float())}
_err = _d.Close()
}
return _r, _err
}
func (_x *_Echo) Nothing(e []Empty) int {
_e := _native.NewEncoder()
_enc_slice_Empty(_e, e)
var _r int
_d, _err := _x.NativeObject().Call("Echo_Nothing", 0, _e)
if _err == nil {
_r = int(_d.Int())
_err = _d.Close()
}
_ = _err
return _r
}
func (_x *_Echo) OnMain(r Record, f func(in Inner)) (Texts, error) {
var _f1 uint64
if f != nil {
_f1 = _native.Func(func(_d *_native.Decoder, _e *_native.Encoder) error {
_p0 := _dec_Inner(_d)
if _err := _d.Err(); _err != nil {
return _err
}
f(_p0)
return nil
}, true)
}
_e := _native.NewEncoder()
_enc_Record(_e, r)
_e.Uint(_f1)
var _r Texts
_d, _err := _x.NativeObject().Call("Echo_OnMain", _native.MainThread, _e)
if _err == nil {
_r = _dec_Texts(_d)
_err = _d.Close()
}
if _err != nil {
_native.Forget(_f1)
}
return _r, _err
}
// _Counter calls the platform's implementation of Counter.
type _Counter struct{ o *_native.Object }
// NativeObject returns the platform's object.
func (x *_Counter) NativeObject() *_native.Object { return x.o }
// _wrapCounter wraps a handle of the platform's, or returns nil.
func _wrapCounter(h uint64) Counter {
if h == 0 {
return nil
}
return &_Counter{_module.Object(h, 0)}
}
func (_x *_Counter) Close() error {
return _x.NativeObject().Close()
}
func (_x *_Counter) Next() int {
return int(_x.NativeObject().Direct("Counter_Next_direct"))
}
func (_x *_Counter) Same() Counter {
var _h uint64
_d, _err := _x.NativeObject().Call("Counter_Same", 0, nil)
if _err == nil {
_h = _d.Uint()
_err = _d.Close()
}
if _err != nil {
return nil
}
return _wrapCounter(_h)
}
// _dispatchScorer calls the method number _m of _v for the platform, with
// the arguments in _d, and writes its result to _e.
func _dispatchScorer(_v Scorer, _ctx _context.Context, _m int, _d *_native.Decoder, _e *_native.Encoder) error {
switch _m {
case 0:
_p0 := _d.String()
if _err := _d.Err(); _err != nil {
return _err
}
_r := _v.Score(_p0)
_e.Float(float64(_r))
return nil
case 1:
_p0 := _d.String()
if _err := _d.Err(); _err != nil {
return _err
}
_r, _err := _v.Explain(_ctx, _p0)
if _err != nil {
return _err
}
_e.String(_r)
return nil
}
return _fmt.Errorf("native: Scorer has no method %d", _m)
}
func _enc_Empty(_e *_native.Encoder, _v Empty) {
_e.Bool(false)
}
func _dec_Empty(_d *_native.Decoder) Empty {
_d.Bool()
return Empty{}
}
func _enc_Inner(_e *_native.Encoder, _v Inner) {
_e.Float(float64(_v.X))
_e.Float(float64(_v.Y))
}
func _dec_Inner(_d *_native.Decoder) Inner {
return Inner{
X: float64(_d.Float()),
Y: float64(_d.Float()),
}
}
func _enc_Kind(_e *_native.Encoder, _v Kind) {
_e.String(string(_v))
}
func _dec_Kind(_d *_native.Decoder) Kind {
return Kind(_d.String())
}
func _enc_Kinds(_e *_native.Encoder, _v Kinds) {
_enc_Kind(_e, _v.Kind)
_enc_Level(_e, _v.Level)
}
func _dec_Kinds(_d *_native.Decoder) Kinds {
return Kinds{
Kind: _dec_Kind(_d),
Level: _dec_Level(_d),
}
}
func _enc_Level(_e *_native.Encoder, _v Level) {
_e.Int(int64(_v))
}
func _dec_Level(_d *_native.Decoder) Level {
return Level(_d.Int())
}
func _enc_Moment(_e *_native.Encoder, _v Moment) {
_e.Time(_v.At)
_e.Duration(_v.Twice)
}
func _dec_Moment(_d *_native.Decoder) Moment {
return Moment{
At: _d.Time(),
Twice: _d.Duration(),
}
}
func _enc_Record(_e *_native.Encoder, _v Record) {
_e.String(_v.Name)
_enc_slice_int(_e, _v.Counts)
_enc_map_string(_e, _v.Tags)
_enc_Inner(_e, _v.Inner)
_enc_ptr_Inner(_e, _v.Next)
_enc_Kind(_e, _v.Kind)
_e.Bytes(_v.Data)
}
func _dec_Record(_d *_native.Decoder) Record {
return Record{
Name: _d.String(),
Counts: _dec_slice_int(_d),
Tags: _dec_map_string(_d),
Inner: _dec_Inner(_d),
Next: _dec_ptr_Inner(_d),
Kind: _dec_Kind(_d),
Data: _d.Bytes(),
}
}
func _enc_Scalars(_e *_native.Encoder, _v Scalars) {
_e.Int(int64(_v.I))
_e.Int(int64(_v.I8))
_e.Int(int64(_v.U16))
_e.Int(int64(_v.I32))
_e.Int(int64(_v.U64))
_e.Float(float64(_v.F32))
_e.Float(float64(_v.F))
_e.Bool(_v.B)
}
func _dec_Scalars(_d *_native.Decoder) Scalars {
return Scalars{
I: int(_d.Int()),
I8: int8(_d.Int()),
U16: uint16(_d.Int()),
I32: int32(_d.Int()),
U64: uint64(_d.Int()),
F32: float32(_d.Float()),
F: float64(_d.Float()),
B: _d.Bool(),
}
}
func _enc_Texts(_e *_native.Encoder, _v Texts) {
_e.String(_v.S)
_e.Bytes(_v.B)
}
func _dec_Texts(_d *_native.Decoder) Texts {
return Texts{
S: _d.String(),
B: _d.Bytes(),
}
}
func _enc_map_int(_e *_native.Encoder, _v map[string]int) {
_e.Len(len(_v))
for _k, _x := range _v {
_e.String(_k)
_e.Int(int64(_x))
}
}
func _dec_map_int(_d *_native.Decoder) map[string]int {
_n := _d.Len()
if _n == 0 {
return nil
}
_v := make(map[string]int, _n)
for range _n {
_k := _d.String()
_v[_k] = int(_d.Int())
}
return _v
}
func _enc_map_string(_e *_native.Encoder, _v map[string]string) {
_e.Len(len(_v))
for _k, _x := range _v {
_e.String(_k)
_e.String(_x)
}
}
func _dec_map_string(_d *_native.Decoder) map[string]string {
_n := _d.Len()
if _n == 0 {
return nil
}
_v := make(map[string]string, _n)
for range _n {
_k := _d.String()
_v[_k] = _d.String()
}
return _v
}
func _enc_ptr_Inner(_e *_native.Encoder, _v *Inner) {
if _v == nil {
_e.Bool(false)
return
}
_e.Bool(true)
_enc_Inner(_e, *_v)
}
func _dec_ptr_Inner(_d *_native.Decoder) *Inner {
if !_d.Bool() {
return nil
}
_x := _dec_Inner(_d)
return &_x
}
func _enc_ptr_int(_e *_native.Encoder, _v *int) {
if _v == nil {
_e.Bool(false)
return
}
_e.Bool(true)
_e.Int(int64(*_v))
}
func _dec_ptr_int(_d *_native.Decoder) *int {
if !_d.Bool() {
return nil
}
_x := int(_d.Int())
return &_x
}
func _enc_slice_Empty(_e *_native.Encoder, _v []Empty) {
_e.Len(len(_v))
for _, _x := range _v {
_enc_Empty(_e, _x)
}
}
func _dec_slice_Empty(_d *_native.Decoder) []Empty {
_n := _d.Len()
if _n == 0 {
return nil
}
_v := make([]Empty, _n)
for _i := range _v {
_v[_i] = _dec_Empty(_d)
}
return _v
}
func _enc_slice_int(_e *_native.Encoder, _v []int) {
_e.Len(len(_v))
for _, _x := range _v {
_e.Int(int64(_x))
}
}
func _dec_slice_int(_d *_native.Decoder) []int {
_n := _d.Len()
if _n == 0 {
return nil
}
_v := make([]int, _n)
for _i := range _v {
_v[_i] = int(_d.Int())
}
return _v
}
func _enc_slice_slice_int(_e *_native.Encoder, _v [][]int) {
_e.Len(len(_v))
for _, _x := range _v {
_enc_slice_int(_e, _x)
}
}
func _dec_slice_slice_int(_d *_native.Decoder) [][]int {
_n := _d.Len()
if _n == 0 {
return nil
}
_v := make([][]int, _n)
for _i := range _v {
_v[_i] = _dec_slice_int(_d)
}
return _v
}
func _enc_slice_string(_e *_native.Encoder, _v []string) {
_e.Len(len(_v))
for _, _x := range _v {
_e.String(_x)
}
}
func _dec_slice_string(_d *_native.Decoder) []string {
_n := _d.Len()
if _n == 0 {
return nil
}
_v := make([]string, _n)
for _i := range _v {
_v[_i] = _d.String()
}
return _v
}