/
impl-nonjs.go
195 lines (153 loc) · 3.17 KB
/
impl-nonjs.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// +build !js
package js
import "errors"
var errNotImpl = errors.New("js not implemented")
// Error placeholder for syscall/js
type Error struct {
Value
}
// Error placeholder for syscall/js
func (e Error) Error() string {
return errNotImpl.Error()
}
// Func placeholder for syscall/js
type Func struct {
Value
}
// FuncOf placeholder for syscall/js
func FuncOf(fn func(Value, []Value) interface{}) Func {
// making this panic for now, although I can see some utility in allowing this
// and then they just never get called, will see...
panic(errNotImpl)
// return Func{}
}
// Release placeholder for syscall/js
func (c Func) Release() {
// nop
}
// Type placeholder for syscall/js
type Type int
// Placeholder for syscall/js
const (
TypeUndefined Type = iota
TypeNull
TypeBoolean
TypeNumber
TypeString
TypeSymbol
TypeObject
TypeFunction
)
// String placeholder for syscall/js
func (t Type) String() string {
return "undefined"
}
// Undefined placeholder for syscall/js
func Undefined() Value {
return Value{}
}
// Null placeholder for syscall/js
func Null() Value {
return Value{}
}
// Global placeholder for syscall/js
func Global() Value {
return Value{}
}
// ValueOf placeholder for syscall/js
func ValueOf(x interface{}) Value {
return Value{}
}
// CopyBytesToGo placeholder for syscall/js
func CopyBytesToGo(dst []byte, src Value) int {
return 0
}
// CopyBytesToJS placeholder for syscall/js
func CopyBytesToJS(dst Value, src []byte) int {
return 0
}
// // TypedArray placeholder for syscall/js
// type TypedArray struct {
// Value
// }
// // TypedArrayOf placeholder for syscall/js
// func TypedArrayOf(slice interface{}) TypedArray {
// return TypedArray{}
// }
// // Release placeholder for syscall/js
// func (a TypedArray) Release() {
// // nop
// }
// ValueError placeholder for syscall/js
type ValueError struct {
Method string
Type Type
}
// Error placeholder for syscall/js
func (e *ValueError) Error() string {
return errNotImpl.Error()
}
// Wrapper placeholder for syscall/js
type Wrapper interface {
JSValue() Value
}
// Value placeholder for syscall/js
type Value struct {
stub uint64
}
// JSValue placeholder for syscall/js
func (v Value) JSValue() Value {
return v
}
// Type placeholder for syscall/js
func (v Value) Type() Type {
return TypeUndefined
}
func (v Value) Get(p string) Value {
return Undefined()
}
func (v Value) Set(p string, x interface{}) {
panic(errNotImpl)
}
func (v Value) Index(i int) Value {
return Undefined()
}
func (v Value) SetIndex(i int, x interface{}) {
panic(errNotImpl)
}
func (v Value) Length() int {
return 0
}
func (v Value) Call(m string, args ...interface{}) Value {
panic(errNotImpl)
}
func (v Value) Invoke(args ...interface{}) Value {
panic(errNotImpl)
}
func (v Value) New(args ...interface{}) Value {
return Undefined()
}
func (v Value) Float() float64 {
return 0
}
func (v Value) Int() int {
return 0
}
func (v Value) Bool() bool {
return false
}
func (v Value) Truthy() bool {
return false
}
func (v Value) String() string {
return ""
}
func (v Value) InstanceOf(t Value) bool {
return false
}
func (v Value) IsUndefined() bool {
return true
}
func (v Value) IsNull() bool {
return false
}