crossrealm.gno

0.82 Kb ยท 45 lines
 1package crossrealm_b
 2
 3import (
 4	"std"
 5
 6	"gno.land/r/demo/tests/crossrealm"
 7)
 8
 9type fooer struct {
10	s string
11}
12
13func (f *fooer) SetS(newVal string) {
14	f.s = newVal
15}
16
17func (f *fooer) Foo(cur realm) {
18	println("hello " + f.s + " cur=" + std.CurrentRealm().PkgPath() + " prev=" + std.PreviousRealm().PkgPath())
19}
20
21func (f *fooer) Bar() {
22	println("hello " + f.s + " cur=" + std.CurrentRealm().PkgPath() + " prev=" + std.PreviousRealm().PkgPath())
23}
24
25var (
26	Fooer              = &fooer{s: "A"}
27	FooerGetter        = func() crossrealm.Fooer { return Fooer }
28	FooerGetterBuilder = func() crossrealm.FooerGetter { return func() crossrealm.Fooer { return Fooer } }
29)
30
31var Closure func()
32
33func SetClosure(cur realm, f func()) {
34	Closure = f
35}
36
37var Object any
38
39func SetObject(cur realm, x any) {
40	Object = x
41}
42
43func GetObject() any {
44	return Object
45}