forked from gopherdata/gophernotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
x_package.go
196 lines (170 loc) · 5.82 KB
/
x_package.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
196
package main
import (
"image"
"image/color"
r "reflect"
"github.com/cosmos72/gomacro/imports"
)
// prepare imports.Package for interpreted code
var display = imports.Package{
Binds: map[string]r.Value{
"Any": r.ValueOf(Any),
"Auto": r.ValueOf(Auto),
"File": r.ValueOf(File),
"HTML": r.ValueOf(HTML),
"Image": r.ValueOf(Image),
"JPEG": r.ValueOf(JPEG),
"JSON": r.ValueOf(JSON),
"JavaScript": r.ValueOf(JavaScript),
"Latex": r.ValueOf(Latex),
"MakeData": r.ValueOf(MakeData),
"MakeData3": r.ValueOf(MakeData3),
"Markdown": r.ValueOf(Markdown),
"Math": r.ValueOf(Math),
"MIME": r.ValueOf(MIME),
"MIMETypeHTML": r.ValueOf(MIMETypeHTML),
"MIMETypeJavaScript": r.ValueOf(MIMETypeJavaScript),
"MIMETypeJPEG": r.ValueOf(MIMETypeJPEG),
"MIMETypeJSON": r.ValueOf(MIMETypeJSON),
"MIMETypeLatex": r.ValueOf(MIMETypeLatex),
"MIMETypeMarkdown": r.ValueOf(MIMETypeMarkdown),
"MIMETypePDF": r.ValueOf(MIMETypePDF),
"MIMETypePNG": r.ValueOf(MIMETypePNG),
"MIMETypeSVG": r.ValueOf(MIMETypeSVG),
"PDF": r.ValueOf(PDF),
"PNG": r.ValueOf(PNG),
"SVG": r.ValueOf(SVG),
},
Types: map[string]r.Type{
"Data": r.TypeOf((*Data)(nil)).Elem(),
"HTMLer": r.TypeOf((*HTMLer)(nil)).Elem(),
"JavaScripter": r.TypeOf((*JavaScripter)(nil)).Elem(),
"Image": r.TypeOf((*image.Image)(nil)).Elem(),
"JPEGer": r.TypeOf((*JPEGer)(nil)).Elem(),
"JSONer": r.TypeOf((*JSONer)(nil)).Elem(),
"Latexer": r.TypeOf((*Latexer)(nil)).Elem(),
"Markdowner": r.TypeOf((*Markdowner)(nil)).Elem(),
"MIMEMap": r.TypeOf((*MIMEMap)(nil)).Elem(),
"PNGer": r.TypeOf((*PNGer)(nil)).Elem(),
"PDFer": r.TypeOf((*PDFer)(nil)).Elem(),
"Renderer": r.TypeOf((*Renderer)(nil)).Elem(),
"SimpleRenderer": r.TypeOf((*SimpleRenderer)(nil)).Elem(),
"SVGer": r.TypeOf((*SVGer)(nil)).Elem(),
}, Proxies: map[string]r.Type{
// these are needed to allow interpreted types
// to implement the corresponding interfaces
"HTMLer": r.TypeOf((*proxy_HTMLer)(nil)).Elem(),
"Image": r.TypeOf((*proxy_image_Image)(nil)).Elem(),
"JPEGer": r.TypeOf((*proxy_JPEGer)(nil)).Elem(),
"JSONer": r.TypeOf((*proxy_JSONer)(nil)).Elem(),
"Latexer": r.TypeOf((*proxy_Latexer)(nil)).Elem(),
"Markdowner": r.TypeOf((*proxy_Markdowner)(nil)).Elem(),
"PNGer": r.TypeOf((*proxy_PNGer)(nil)).Elem(),
"PDFer": r.TypeOf((*proxy_PDFer)(nil)).Elem(),
"Renderer": r.TypeOf((*proxy_Renderer)(nil)).Elem(),
"SimpleRenderer": r.TypeOf((*proxy_SimpleRenderer)(nil)).Elem(),
"SVGer": r.TypeOf((*proxy_SVGer)(nil)).Elem(),
},
}
// --------------- proxy for display.HTMLer ---------------
type proxy_HTMLer struct {
Object interface{}
HTML_ func(interface{}) string
}
func (P *proxy_HTMLer) HTML() string {
return P.HTML_(P.Object)
}
// --------------- proxy for display.JPEGer ---------------
type proxy_JPEGer struct {
Object interface{}
JPEG_ func(interface{}) []byte
}
func (P *proxy_JPEGer) JPEG() []byte {
return P.JPEG_(P.Object)
}
// --------------- proxy for display.JSONer ---------------
type proxy_JSONer struct {
Object interface{}
JSON_ func(interface{}) string
}
func (P *proxy_JSONer) JSON() string {
return P.JSON_(P.Object)
}
// --------------- proxy for display.Latexer ---------------
type proxy_Latexer struct {
Object interface{}
Latex_ func(interface{}) string
}
func (P *proxy_Latexer) Latex() string {
return P.Latex_(P.Object)
}
// --------------- proxy for display.Markdowner ---------------
type proxy_Markdowner struct {
Object interface{}
Markdown_ func(interface{}) string
}
func (P *proxy_Markdowner) Markdown() string {
return P.Markdown_(P.Object)
}
// --------------- proxy for display.PNGer ---------------
type proxy_PNGer struct {
Object interface{}
PNG_ func(interface{}) []byte
}
func (P *proxy_PNGer) PNG() []byte {
return P.PNG_(P.Object)
}
// --------------- proxy for display.PDFer ---------------
type proxy_PDFer struct {
Object interface{}
PDF_ func(interface{}) []byte
}
func (P *proxy_PDFer) PDF() []byte {
return P.PDF_(P.Object)
}
// --------------- proxy for display.Renderer ---------------
type proxy_Renderer struct {
Object interface{}
Render_ func(interface{}) Data
}
func (P *proxy_Renderer) Render() Data {
return P.Render_(P.Object)
}
// --------------- proxy for display.SimpleRenderer ---------------
type proxy_SimpleRenderer struct {
Object interface{}
SimpleRender_ func(interface{}) MIMEMap
}
func (P *proxy_SimpleRenderer) SimpleRender() MIMEMap {
return P.SimpleRender_(P.Object)
}
// --------------- proxy for display.SVGer ---------------
type proxy_SVGer struct {
Object interface{}
SVG_ func(interface{}) string
}
func (P *proxy_SVGer) SVG() string {
return P.SVG_(P.Object)
}
// --------------- proxy for image.Image ---------------
type proxy_image_Image struct {
Object interface{}
At_ func(_proxy_obj_ interface{}, x int, y int) color.Color
Bounds_ func(interface{}) image.Rectangle
ColorModel_ func(interface{}) color.Model
}
func (P *proxy_image_Image) At(x int, y int) color.Color {
return P.At_(P.Object, x, y)
}
func (P *proxy_image_Image) Bounds() image.Rectangle {
return P.Bounds_(P.Object)
}
func (P *proxy_image_Image) ColorModel() color.Model {
return P.ColorModel_(P.Object)
}
// --------------------------------------------------------
// allow importing "display" and "github.com/gopherdata/gophernotes" packages
func init() {
imports.Packages["display"] = display
imports.Packages["github.com/gopherdata/gophernotes"] = display
}