When an interpreter type implementing an interface is used by the runtime, the runtime can extract its type and create new values using reflect, and call methods on it. The problem is that there will be no interpreted method counterpart in this case, which makes wrapper panic. Allow the String() method wrapper to always succeed and return an empty string if no interpreted method is present. This allows scripts to define custom flag.Value types on which the runtime internally instantiates values using reflect (see isZeroValue in Go src/flag/flag.go). This workaround could be generalized to all wrappers if necessary. At this moment, it is convenient to keep the default behavior of expecting instantiated interpreter methods, in order to catch interpreter bugs related to interfaces. Fixes #1276.
110 lines
3.2 KiB
Go
110 lines
3.2 KiB
Go
// Code generated by 'yaegi extract image/draw'. DO NOT EDIT.
|
|
|
|
//go:build go1.17
|
|
// +build go1.17
|
|
|
|
package stdlib
|
|
|
|
import (
|
|
"image"
|
|
"image/color"
|
|
"image/draw"
|
|
"reflect"
|
|
)
|
|
|
|
func init() {
|
|
Symbols["image/draw/draw"] = map[string]reflect.Value{
|
|
// function, constant and variable definitions
|
|
"Draw": reflect.ValueOf(draw.Draw),
|
|
"DrawMask": reflect.ValueOf(draw.DrawMask),
|
|
"FloydSteinberg": reflect.ValueOf(&draw.FloydSteinberg).Elem(),
|
|
"Over": reflect.ValueOf(draw.Over),
|
|
"Src": reflect.ValueOf(draw.Src),
|
|
|
|
// type definitions
|
|
"Drawer": reflect.ValueOf((*draw.Drawer)(nil)),
|
|
"Image": reflect.ValueOf((*draw.Image)(nil)),
|
|
"Op": reflect.ValueOf((*draw.Op)(nil)),
|
|
"Quantizer": reflect.ValueOf((*draw.Quantizer)(nil)),
|
|
"RGBA64Image": reflect.ValueOf((*draw.RGBA64Image)(nil)),
|
|
|
|
// interface wrapper definitions
|
|
"_Drawer": reflect.ValueOf((*_image_draw_Drawer)(nil)),
|
|
"_Image": reflect.ValueOf((*_image_draw_Image)(nil)),
|
|
"_Quantizer": reflect.ValueOf((*_image_draw_Quantizer)(nil)),
|
|
"_RGBA64Image": reflect.ValueOf((*_image_draw_RGBA64Image)(nil)),
|
|
}
|
|
}
|
|
|
|
// _image_draw_Drawer is an interface wrapper for Drawer type
|
|
type _image_draw_Drawer struct {
|
|
IValue interface{}
|
|
WDraw func(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point)
|
|
}
|
|
|
|
func (W _image_draw_Drawer) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point) {
|
|
W.WDraw(dst, r, src, sp)
|
|
}
|
|
|
|
// _image_draw_Image is an interface wrapper for Image type
|
|
type _image_draw_Image struct {
|
|
IValue interface{}
|
|
WAt func(x int, y int) color.Color
|
|
WBounds func() image.Rectangle
|
|
WColorModel func() color.Model
|
|
WSet func(x int, y int, c color.Color)
|
|
}
|
|
|
|
func (W _image_draw_Image) At(x int, y int) color.Color {
|
|
return W.WAt(x, y)
|
|
}
|
|
func (W _image_draw_Image) Bounds() image.Rectangle {
|
|
return W.WBounds()
|
|
}
|
|
func (W _image_draw_Image) ColorModel() color.Model {
|
|
return W.WColorModel()
|
|
}
|
|
func (W _image_draw_Image) Set(x int, y int, c color.Color) {
|
|
W.WSet(x, y, c)
|
|
}
|
|
|
|
// _image_draw_Quantizer is an interface wrapper for Quantizer type
|
|
type _image_draw_Quantizer struct {
|
|
IValue interface{}
|
|
WQuantize func(p color.Palette, m image.Image) color.Palette
|
|
}
|
|
|
|
func (W _image_draw_Quantizer) Quantize(p color.Palette, m image.Image) color.Palette {
|
|
return W.WQuantize(p, m)
|
|
}
|
|
|
|
// _image_draw_RGBA64Image is an interface wrapper for RGBA64Image type
|
|
type _image_draw_RGBA64Image struct {
|
|
IValue interface{}
|
|
WAt func(x int, y int) color.Color
|
|
WBounds func() image.Rectangle
|
|
WColorModel func() color.Model
|
|
WRGBA64At func(x int, y int) color.RGBA64
|
|
WSet func(x int, y int, c color.Color)
|
|
WSetRGBA64 func(x int, y int, c color.RGBA64)
|
|
}
|
|
|
|
func (W _image_draw_RGBA64Image) At(x int, y int) color.Color {
|
|
return W.WAt(x, y)
|
|
}
|
|
func (W _image_draw_RGBA64Image) Bounds() image.Rectangle {
|
|
return W.WBounds()
|
|
}
|
|
func (W _image_draw_RGBA64Image) ColorModel() color.Model {
|
|
return W.WColorModel()
|
|
}
|
|
func (W _image_draw_RGBA64Image) RGBA64At(x int, y int) color.RGBA64 {
|
|
return W.WRGBA64At(x, y)
|
|
}
|
|
func (W _image_draw_RGBA64Image) Set(x int, y int, c color.Color) {
|
|
W.WSet(x, y, c)
|
|
}
|
|
func (W _image_draw_RGBA64Image) SetRGBA64(x int, y int, c color.RGBA64) {
|
|
W.WSetRGBA64(x, y, c)
|
|
}
|