Clean up for go1

This commit is contained in:
Laurent Le Goff 2012-03-29 16:52:12 +02:00
parent c595982fba
commit 7f2c247e7a
38 changed files with 65 additions and 63 deletions

View file

@ -4,23 +4,23 @@
all: install all: install
install: install:
cd draw2d && make install cd draw2d && go install
# cd draw2dgl && make install # cd draw2dgl && make install
cd postscript && make install cd postscript && go install
# cd wingui && make install # cd wingui && make install
clean: build:
cd draw2d && make clean cd draw2d && go build
# cd draw2dgl && make clean # cd draw2dgl && make build
cd postscript && make clean cd postscript && go build
cd cmd && make clean # cd wingui && make build
# cd wingui && make clean
nuke: clean:
cd draw2d && make nuke cd draw2d && go clean
# cd draw2dgl && make nuke # cd draw2dgl && make clean
cd postscript && make nuke cd postscript && go clean
# cd wingui && make nuke cd cmd && go clean
# cd wingui && make clean
command: command:
cd cmd && make cd cmd && make

View file

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"time"
"code.google.com/p/draw2d/draw2d" "code.google.com/p/draw2d/draw2d"
"image" "image"
@ -26,7 +25,6 @@ var (
func initGc(w, h int) (image.Image, draw2d.GraphicContext) { func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
i := image.NewRGBA(image.Rect(0, 0, w, h)) i := image.NewRGBA(image.Rect(0, 0, w, h))
gc := draw2d.NewGraphicContext(i) gc := draw2d.NewGraphicContext(i)
lastTime = time.Now()
gc.SetStrokeColor(image.Black) gc.SetStrokeColor(image.Black)
gc.SetFillColor(image.White) gc.SetFillColor(image.White)
@ -37,8 +35,6 @@ func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
} }
func saveToPngFile(TestName string, m image.Image) { func saveToPngFile(TestName string, m image.Image) {
dt := time.Now().Sub(lastTime)
fmt.Printf("%s during: %f ms\n", TestName, float64(dt)*1e-6)
filePath := folder + TestName + ".png" filePath := folder + TestName + ".png"
f, err := os.Create(filePath) f, err := os.Create(filePath)
if err != nil { if err != nil {

View file

@ -8,7 +8,6 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"time"
"code.google.com/p/draw2d/draw2d" "code.google.com/p/draw2d/draw2d"
"image" "image"
@ -29,7 +28,6 @@ var (
func initGc(w, h int) (image.Image, draw2d.GraphicContext) { func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
i := image.NewRGBA(image.Rect(0, 0, w, h)) i := image.NewRGBA(image.Rect(0, 0, w, h))
gc := draw2d.NewGraphicContext(i) gc := draw2d.NewGraphicContext(i)
lastTime = time.Now()
gc.SetStrokeColor(image.Black) gc.SetStrokeColor(image.Black)
gc.SetFillColor(image.White) gc.SetFillColor(image.White)
@ -40,9 +38,6 @@ func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
} }
func saveToPngFile(TestName string, m image.Image) { func saveToPngFile(TestName string, m image.Image) {
t := time.Now()
dt := t.Sub(lastTime)
fmt.Printf("%s during: %f ms\n", TestName, float64(dt)*1e-6)
filePath := folder + TestName + ".png" filePath := folder + TestName + ".png"
f, err := os.Create(filePath) f, err := os.Create(filePath)
if err != nil { if err != nil {
@ -61,8 +56,7 @@ func saveToPngFile(TestName string, m image.Image) {
log.Println(err) log.Println(err)
os.Exit(1) os.Exit(1)
} }
dt = time.Now().Sub(t) fmt.Printf("Wrote %s OK.\n", filePath)
fmt.Printf("Wrote %s OK in %f ms.\n", filePath, float64(dt)*1e-6)
} }
/* /*
@ -513,7 +507,6 @@ func TestBigPicture() {
} }
func main() { func main() {
t := time.Now()
TestPath() TestPath()
TestDrawArc() TestDrawArc()
TestDrawArcNegative() TestDrawArcNegative()
@ -532,6 +525,4 @@ func main() {
TestPathTransform() TestPathTransform()
TestFillString() TestFillString()
TestBigPicture() TestBigPicture()
dt := time.Now().Sub(t)
fmt.Printf("All tests during: %f ms\n", float64(dt)*1e-6)
} }

View file

@ -6,7 +6,6 @@ import (
"log" "log"
"math" "math"
"os" "os"
"time"
"code.google.com/p/draw2d/draw2d" "code.google.com/p/draw2d/draw2d"
"image" "image"
@ -26,7 +25,6 @@ var (
func initGc(w, h int) (image.Image, draw2d.GraphicContext) { func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
i := image.NewRGBA(image.Rect(0, 0, w, h)) i := image.NewRGBA(image.Rect(0, 0, w, h))
gc := draw2d.NewGraphicContext(i) gc := draw2d.NewGraphicContext(i)
lastTime = time.Now()
gc.SetStrokeColor(image.Black) gc.SetStrokeColor(image.Black)
gc.SetFillColor(image.White) gc.SetFillColor(image.White)
@ -37,8 +35,6 @@ func initGc(w, h int) (image.Image, draw2d.GraphicContext) {
} }
func saveToPngFile(TestName string, m image.Image) { func saveToPngFile(TestName string, m image.Image) {
dt := time.Now().Sub(lastTime)
fmt.Printf("%s during: %f ms\n", TestName, float64(dt)*1e-6)
filePath := folder + TestName + ".png" filePath := folder + TestName + ".png"
f, err := os.Create(filePath) f, err := os.Create(filePath)
if err != nil { if err != nil {

View file

@ -10,7 +10,6 @@ import (
"log" "log"
"math" "math"
"os" "os"
"time"
) )
func saveToPngFile(filePath string, m image.Image) { func saveToPngFile(filePath string, m image.Image) {
@ -37,7 +36,7 @@ func saveToPngFile(filePath string, m image.Image) {
func loadFromPngFile(filePath string) image.Image { func loadFromPngFile(filePath string) image.Image {
f, err := os.OpenFile(filePath, 0, 0) f, err := os.OpenFile(filePath, 0, 0)
if f == nil { if f == nil {
log.Printf("can't open file; err=%s\n", err.String()) log.Printf("can't open file; err=%s\n", err)
return nil return nil
} }
defer f.Close() defer f.Close()
@ -61,9 +60,6 @@ func main() {
//tr.Scale(3, 3) //tr.Scale(3, 3)
tr.Translate(-width/2, -height/2) tr.Translate(-width/2, -height/2)
tr.Translate(200, 5) tr.Translate(200, 5)
lastTime := time.Now()
draw2d.DrawImage(source, dest, tr, draw.Over, draw2d.BilinearFilter) draw2d.DrawImage(source, dest, tr, draw.Over, draw2d.BilinearFilter)
dt := time.Now().Sub(lastTime)
fmt.Printf("Draw image: %f ms\n", float64(dt)*1e-6)
saveToPngFile("../resource/result/TestDrawImage.png", dest) saveToPngFile("../resource/result/TestDrawImage.png", dest)
} }

View file

@ -11,7 +11,6 @@ import (
"log" "log"
"os" "os"
"strings" "strings"
"time"
) )
func saveToPngFile(filePath string, m image.Image) { func saveToPngFile(filePath string, m image.Image) {
@ -49,9 +48,6 @@ func main() {
bytes, err := ioutil.ReadAll(src) bytes, err := ioutil.ReadAll(src)
reader := strings.NewReader(string(bytes)) reader := strings.NewReader(string(bytes))
interpreter := postscript.NewInterpreter(gc) interpreter := postscript.NewInterpreter(gc)
lastTime := time.Now()
interpreter.Execute(reader) interpreter.Execute(reader)
dt := time.Now().Sub(lastTime)
fmt.Printf("Draw image: %f ms\n", float64(dt)*1e-6)
saveToPngFile("../resource/result/TestPostscript.png", i) saveToPngFile("../resource/result/TestPostscript.png", i)
} }

View file

@ -6,10 +6,8 @@ import (
"math" "math"
) )
//high level path creation //high level path creation
func Rect(path Path, x1, y1, x2, y2 float64) { func Rect(path Path, x1, y1, x2, y2 float64) {
path.MoveTo(x1, y1) path.MoveTo(x1, y1)
path.LineTo(x2, y1) path.LineTo(x2, y1)

View file

@ -1,3 +1,2 @@
// The package draw2d provide a Graphic Context that can draw vectorial figure on surface. // The package draw2d provide a Graphic Context that can draw vectorial figure on surface.
package draw2d package draw2d

View file

@ -1,6 +1,7 @@
// Copyright 2010 The draw2d Authors. All rights reserved. // Copyright 2010 The draw2d Authors. All rights reserved.
// created: 21/11/2010 by Laurent Le Goff // created: 21/11/2010 by Laurent Le Goff
package draw2d package draw2d
/* /*
import ( import (
"image/draw" "image/draw"
@ -9,6 +10,7 @@ import (
)*/ )*/
const M = 1<<16 - 1 const M = 1<<16 - 1
/* /*
type NRGBAPainter struct { type NRGBAPainter struct {
// The image to compose onto. // The image to compose onto.
@ -74,7 +76,7 @@ func (r *NRGBAPainter) Paint(ss []raster.Span, done bool) {
} }
} }
} }
} }
// SetColor sets the color to paint the spans. // SetColor sets the color to paint the spans.
@ -86,4 +88,4 @@ func (r *NRGBAPainter) SetColor(c image.Color) {
func NewNRGBAPainter(m *image.NRGBA) *NRGBAPainter { func NewNRGBAPainter(m *image.NRGBA) *NRGBAPainter {
return &NRGBAPainter{Image: m} return &NRGBAPainter{Image: m}
} }
*/ */

View file

@ -26,7 +26,6 @@ func (c *PathConverter) Convert(paths ...*PathStorage) {
} }
} }
func (c *PathConverter) ConvertCommand(cmd PathCmd, vertices ...float64) int { func (c *PathConverter) ConvertCommand(cmd PathCmd, vertices ...float64) int {
switch cmd { switch cmd {
case MoveTo: case MoveTo:

View file

@ -12,7 +12,6 @@ const (
type Polygon []float64 type Polygon []float64
type PolygonEdge struct { type PolygonEdge struct {
X, Slope float64 X, Slope float64
FirstLine, LastLine int FirstLine, LastLine int
@ -166,7 +165,6 @@ func (p Polygon) getEdges(startIndex, vertexCount int, edges []PolygonEdge, tr [
return edgeCount return edgeCount
} }
//! Creates a polygon edge between two vectors. //! Creates a polygon edge between two vectors.
/*! Clips the edge vertically to the clip rectangle. Returns true for edges that /*! Clips the edge vertically to the clip rectangle. Returns true for edges that
* should be rendered, false for others. * should be rendered, false for others.
@ -228,7 +226,6 @@ func getEdge(x0, y0, x1, y1 float64, edge *PolygonEdge, clipBound [4]float64) bo
return true return true
} }
//! Creates a vertical polygon edge between two y values. //! Creates a vertical polygon edge between two y values.
/*! Clips the edge vertically to the clip rectangle. Returns true for edges that /*! Clips the edge vertically to the clip rectangle. Returns true for edges that
* should be rendered, false for others. * should be rendered, false for others.
@ -277,12 +274,12 @@ func getVerticalEdge(startY, endY, x float64, edge *PolygonEdge, clipBound [4]fl
return true return true
} }
type VertexData struct { type VertexData struct {
X, Y float64 X, Y float64
ClipFlags int ClipFlags int
Line int Line int
} }
//! Calculates the edges of the polygon with transformation and clipping to edges array. //! Calculates the edges of the polygon with transformation and clipping to edges array.
/*! Note that this may return upto three times the amount of edges that the polygon has vertices, /*! Note that this may return upto three times the amount of edges that the polygon has vertices,
* in the unlucky case where both left and right side get clipped for all edges. * in the unlucky case where both left and right side get clipped for all edges.

View file

@ -18,7 +18,6 @@ const (
MiterJoin MiterJoin
) )
type LineStroker struct { type LineStroker struct {
Next VertexConverter Next VertexConverter
HalfLineWidth float64 HalfLineWidth float64
@ -42,7 +41,6 @@ func NewLineStroker(c Cap, j Join, converter VertexConverter) *LineStroker {
return l return l
} }
func (l *LineStroker) NextCommand(command VertexCommand) { func (l *LineStroker) NextCommand(command VertexCommand) {
l.command = command l.command = command
if command == VertexStopCommand { if command == VertexStopCommand {
@ -107,7 +105,6 @@ func (l *LineStroker) closePolygon() {
} }
} }
func (l *LineStroker) line(x1, y1, x2, y2 float64) { func (l *LineStroker) line(x1, y1, x2, y2 float64) {
dx := (x2 - x1) dx := (x2 - x1)
dy := (y2 - y1) dy := (y2 - y1)

View file

@ -17,7 +17,6 @@ func (o *PrimitiveOperator) Execute(interpreter *Interpreter) {
o.f(interpreter) o.f(interpreter)
} }
func save(interpreter *Interpreter) { func save(interpreter *Interpreter) {
interpreter.Push("VM Snapshot") interpreter.Push("VM Snapshot")
} }
@ -26,7 +25,6 @@ func restore(interpreter *Interpreter) {
interpreter.Pop() interpreter.Pop()
} }
func initSystemOperators(interpreter *Interpreter) { func initSystemOperators(interpreter *Interpreter) {
interpreter.SystemDefine("save", NewOperator(save)) interpreter.SystemDefine("save", NewOperator(save))
interpreter.SystemDefine("restore", NewOperator(restore)) interpreter.SystemDefine("restore", NewOperator(restore))

View file

@ -3,22 +3,25 @@
package postscript package postscript
import () import ()
//int array array -> Create array of length int //int array array -> Create array of length int
func array(interpreter *Interpreter) { func array(interpreter *Interpreter) {
interpreter.Push(make([]Value, interpreter.PopInt())) interpreter.Push(make([]Value, interpreter.PopInt()))
} }
//array length int -> Return number of elements in array //array length int -> Return number of elements in array
func lengtharray(interpreter *Interpreter) { func lengtharray(interpreter *Interpreter) {
interpreter.Push(float64(len(interpreter.Pop().([]Value)))) interpreter.Push(float64(len(interpreter.Pop().([]Value))))
} }
//array index get any -> Return array element indexed by index //array index get any -> Return array element indexed by index
func getarray(interpreter *Interpreter) { func getarray(interpreter *Interpreter) {
index := interpreter.PopInt() index := interpreter.PopInt()
array := interpreter.Pop().([]Value) array := interpreter.Pop().([]Value)
interpreter.Push(array[index]) interpreter.Push(array[index])
} }
//array index any put -> Put any into array at index //array index any put -> Put any into array at index
func putarray(interpreter *Interpreter) { func putarray(interpreter *Interpreter) {
value := interpreter.Pop() value := interpreter.Pop()
@ -26,6 +29,7 @@ func putarray(interpreter *Interpreter) {
array := interpreter.Pop().([]Value) array := interpreter.Pop().([]Value)
array[index] = value array[index] = value
} }
//array index count getinterval subarray -> Return subarray of array starting at index for count elements //array index count getinterval subarray -> Return subarray of array starting at index for count elements
func getinterval(interpreter *Interpreter) { func getinterval(interpreter *Interpreter) {
count := interpreter.PopInt() count := interpreter.PopInt()
@ -35,6 +39,7 @@ func getinterval(interpreter *Interpreter) {
copy(subarray, array[index:index+count]) copy(subarray, array[index:index+count])
interpreter.Push(subarray) interpreter.Push(subarray)
} }
//array1 index array2 putinterval Replace subarray of array1 starting at index by array2|packedarray2 //array1 index array2 putinterval Replace subarray of array1 starting at index by array2|packedarray2
func putinterval(interpreter *Interpreter) { func putinterval(interpreter *Interpreter) {
array2 := interpreter.Pop().([]Value) array2 := interpreter.Pop().([]Value)
@ -44,6 +49,7 @@ func putinterval(interpreter *Interpreter) {
array1[i+index] = v array1[i+index] = v
} }
} }
// any0 … anyn1 array astore array // any0 … anyn1 array astore array
// stores the objects any0 to anyn1 from the operand stack into array, where n is the length of array // stores the objects any0 to anyn1 from the operand stack into array, where n is the length of array
func astore(interpreter *Interpreter) { func astore(interpreter *Interpreter) {
@ -53,6 +59,7 @@ func astore(interpreter *Interpreter) {
array[i] = interpreter.Pop() array[i] = interpreter.Pop()
} }
} }
//array aload any0 … any-1 array //array aload any0 … any-1 array
//Push all elements of array on stack //Push all elements of array on stack
func aload(interpreter *Interpreter) { func aload(interpreter *Interpreter) {
@ -62,6 +69,7 @@ func aload(interpreter *Interpreter) {
} }
interpreter.Push(array) interpreter.Push(array)
} }
//array proc forall Execute proc for each element of array //array proc forall Execute proc for each element of array
func forallarray(interpreter *Interpreter) { func forallarray(interpreter *Interpreter) {
proc := NewProcedure(interpreter.PopProcedureDefinition()) proc := NewProcedure(interpreter.PopProcedureDefinition())

View file

@ -6,6 +6,7 @@ package postscript
import ( import (
"log" "log"
) )
// any exec Execute arbitrary object // any exec Execute arbitrary object
func exec(interpreter *Interpreter) { func exec(interpreter *Interpreter) {
value := interpreter.Pop() value := interpreter.Pop()
@ -69,7 +70,6 @@ func stopped(interpreter *Interpreter) {
interpreter.Push(false) interpreter.Push(false)
} }
func initControlOperators(interpreter *Interpreter) { func initControlOperators(interpreter *Interpreter) {
interpreter.SystemDefine("exec", NewOperator(exec)) interpreter.SystemDefine("exec", NewOperator(exec))
interpreter.SystemDefine("if", NewOperator(ifoperator)) interpreter.SystemDefine("if", NewOperator(ifoperator))

View file

@ -3,32 +3,37 @@
package postscript package postscript
import ( import (
"log" "log"
) )
//int dict dict -> Create dictionary with capacity for int elements //int dict dict -> Create dictionary with capacity for int elements
func dict(interpreter *Interpreter) { func dict(interpreter *Interpreter) {
interpreter.Push(NewDictionary(interpreter.PopInt())) interpreter.Push(NewDictionary(interpreter.PopInt()))
} }
//dict length int -> Return number of entries in dict //dict length int -> Return number of entries in dict
func lengthdict(interpreter *Interpreter) { func lengthdict(interpreter *Interpreter) {
dictionary := interpreter.Pop().(Dictionary) dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(float64(len(dictionary))) interpreter.Push(float64(len(dictionary)))
} }
//dict maxlength int -> Return current capacity of dict //dict maxlength int -> Return current capacity of dict
func maxlength(interpreter *Interpreter) { func maxlength(interpreter *Interpreter) {
interpreter.Pop() interpreter.Pop()
interpreter.Push(float64(999999999)) // push arbitrary value interpreter.Push(float64(999999999)) // push arbitrary value
} }
//dict begin -> Push dict on dictionary stack //dict begin -> Push dict on dictionary stack
func begin(interpreter *Interpreter) { func begin(interpreter *Interpreter) {
interpreter.PushDictionary(interpreter.Pop().(Dictionary)) interpreter.PushDictionary(interpreter.Pop().(Dictionary))
} }
// end -> Pop current dictionary off dictionary stack // end -> Pop current dictionary off dictionary stack
func end(interpreter *Interpreter) { func end(interpreter *Interpreter) {
interpreter.PopDictionary() interpreter.PopDictionary()
} }
//key value def -> Associate key and value in current dictionary //key value def -> Associate key and value in current dictionary
func def(interpreter *Interpreter) { func def(interpreter *Interpreter) {
value := interpreter.Pop() value := interpreter.Pop()
@ -38,6 +43,7 @@ func def(interpreter *Interpreter) {
} }
interpreter.Define(name, value) interpreter.Define(name, value)
} }
//key load value -> Search dictionary stack for key and return associated value //key load value -> Search dictionary stack for key and return associated value
func load(interpreter *Interpreter) { func load(interpreter *Interpreter) {
name := interpreter.PopName() name := interpreter.PopName()
@ -47,6 +53,7 @@ func load(interpreter *Interpreter) {
} }
interpreter.Push(value) interpreter.Push(value)
} }
//key value store -> Replace topmost definition of key //key value store -> Replace topmost definition of key
func store(interpreter *Interpreter) { func store(interpreter *Interpreter) {
value := interpreter.Pop() value := interpreter.Pop()
@ -56,12 +63,14 @@ func store(interpreter *Interpreter) {
dictionary[key] = value dictionary[key] = value
} }
} }
//dict key get any -> Return value associated with key in dict //dict key get any -> Return value associated with key in dict
func getdict(interpreter *Interpreter) { func getdict(interpreter *Interpreter) {
key := interpreter.PopName() key := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary) dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(dictionary[key]) interpreter.Push(dictionary[key])
} }
//dict key value put -> Associate key with value in dict //dict key value put -> Associate key with value in dict
func putdict(interpreter *Interpreter) { func putdict(interpreter *Interpreter) {
value := interpreter.Pop() value := interpreter.Pop()
@ -69,18 +78,21 @@ func putdict(interpreter *Interpreter) {
dictionary := interpreter.Pop().(Dictionary) dictionary := interpreter.Pop().(Dictionary)
dictionary[key] = value dictionary[key] = value
} }
//dict key undef Remove key and its value from dict //dict key undef Remove key and its value from dict
func undef(interpreter *Interpreter) { func undef(interpreter *Interpreter) {
key := interpreter.PopName() key := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary) dictionary := interpreter.Pop().(Dictionary)
dictionary[key] = nil dictionary[key] = nil
} }
//dict key known bool -> Test whether key is in dict //dict key known bool -> Test whether key is in dict
func known(interpreter *Interpreter) { func known(interpreter *Interpreter) {
key := interpreter.PopName() key := interpreter.PopName()
dictionary := interpreter.Pop().(Dictionary) dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(dictionary[key] != nil) interpreter.Push(dictionary[key] != nil)
} }
//key where (dict true) or false -> Find dictionary in which key is defined //key where (dict true) or false -> Find dictionary in which key is defined
func where(interpreter *Interpreter) { func where(interpreter *Interpreter) {
key := interpreter.PopName() key := interpreter.PopName()
@ -92,6 +104,7 @@ func where(interpreter *Interpreter) {
interpreter.Push(true) interpreter.Push(true)
} }
} }
// dict1 dict2 copy dict2 -> Copy contents of dict1 to dict2 // dict1 dict2 copy dict2 -> Copy contents of dict1 to dict2
func copydict(interpreter *Interpreter) { func copydict(interpreter *Interpreter) {
dict2 := interpreter.Pop().(Dictionary) dict2 := interpreter.Pop().(Dictionary)
@ -101,6 +114,7 @@ func copydict(interpreter *Interpreter) {
} }
interpreter.Push(dict2) interpreter.Push(dict2)
} }
//dict proc forall -> Execute proc for each entry in dict //dict proc forall -> Execute proc for each entry in dict
func foralldict(interpreter *Interpreter) { func foralldict(interpreter *Interpreter) {
proc := NewProcedure(interpreter.PopProcedureDefinition()) proc := NewProcedure(interpreter.PopProcedureDefinition())
@ -111,34 +125,42 @@ func foralldict(interpreter *Interpreter) {
proc.Execute(interpreter) proc.Execute(interpreter)
} }
} }
// currentdict dict -> Return current dictionary // currentdict dict -> Return current dictionary
func currentdict(interpreter *Interpreter) { func currentdict(interpreter *Interpreter) {
interpreter.Push(interpreter.PeekDictionary()) interpreter.Push(interpreter.PeekDictionary())
} }
// systemdict dict -> Return system dictionary // systemdict dict -> Return system dictionary
func systemdict(interpreter *Interpreter) { func systemdict(interpreter *Interpreter) {
interpreter.Push(interpreter.SystemDictionary()) interpreter.Push(interpreter.SystemDictionary())
} }
// userdict dict -> Return writeable dictionary in local VM // userdict dict -> Return writeable dictionary in local VM
func userdict(interpreter *Interpreter) { func userdict(interpreter *Interpreter) {
interpreter.Push(interpreter.UserDictionary()) interpreter.Push(interpreter.UserDictionary())
} }
// globaldict dict -> Return writeable dictionary in global VM // globaldict dict -> Return writeable dictionary in global VM
func globaldict(interpreter *Interpreter) { func globaldict(interpreter *Interpreter) {
interpreter.Push(interpreter.UserDictionary()) interpreter.Push(interpreter.UserDictionary())
} }
// statusdict dict -> Return product-dependent dictionary // statusdict dict -> Return product-dependent dictionary
func statusdict(interpreter *Interpreter) { func statusdict(interpreter *Interpreter) {
interpreter.Push(interpreter.UserDictionary()) interpreter.Push(interpreter.UserDictionary())
} }
// countdictstack int -> Count elements on dictionary stack // countdictstack int -> Count elements on dictionary stack
func countdictstack(interpreter *Interpreter) { func countdictstack(interpreter *Interpreter) {
interpreter.Push(float64(interpreter.DictionaryStackSize())) interpreter.Push(float64(interpreter.DictionaryStackSize()))
} }
//array dictstack subarray -> Copy dictionary stack into array //array dictstack subarray -> Copy dictionary stack into array
func dictstack(interpreter *Interpreter) { func dictstack(interpreter *Interpreter) {
panic("No yet implemenented") panic("No yet implemenented")
} }
// cleardictstack -> Pop all nonpermanent dictionaries off dictionary stack // cleardictstack -> Pop all nonpermanent dictionaries off dictionary stack
func cleardictstack(interpreter *Interpreter) { func cleardictstack(interpreter *Interpreter) {
interpreter.ClearDictionaries() interpreter.ClearDictionaries()

View file

@ -3,7 +3,6 @@
package postscript package postscript
func eq(interpreter *Interpreter) { func eq(interpreter *Interpreter) {
value1 := interpreter.Pop() value1 := interpreter.Pop()
value2 := interpreter.Pop() value2 := interpreter.Pop()

View file

@ -8,6 +8,7 @@ package postscript
func pop(interpreter *Interpreter) { func pop(interpreter *Interpreter) {
interpreter.Pop() interpreter.Pop()
} }
//any1 any2 exch any2 any1 -> Exchange top two elements //any1 any2 exch any2 any1 -> Exchange top two elements
func exch(interpreter *Interpreter) { func exch(interpreter *Interpreter) {
value1 := interpreter.Pop() value1 := interpreter.Pop()
@ -15,6 +16,7 @@ func exch(interpreter *Interpreter) {
interpreter.Push(value1) interpreter.Push(value1)
interpreter.Push(value2) interpreter.Push(value2)
} }
//any dup any any -> Duplicate top element //any dup any any -> Duplicate top element
func dup(interpreter *Interpreter) { func dup(interpreter *Interpreter) {
interpreter.Push(interpreter.Peek()) interpreter.Push(interpreter.Peek())
@ -28,11 +30,13 @@ func copystack(interpreter *Interpreter) {
interpreter.Push(value) interpreter.Push(value)
} }
} }
//anyn … any0 n index anyn … any0 anyn -> Duplicate arbitrary element //anyn … any0 n index anyn … any0 anyn -> Duplicate arbitrary element
func index(interpreter *Interpreter) { func index(interpreter *Interpreter) {
f := interpreter.PopInt() f := interpreter.PopInt()
interpreter.Push(interpreter.Get(int(f))) interpreter.Push(interpreter.Get(int(f)))
} }
//anyn1 … any0 n j roll any(j1) mod n … any0 anyn1 … anyj mod n -> Roll n elements up j times //anyn1 … any0 n j roll any(j1) mod n … any0 anyn1 … anyj mod n -> Roll n elements up j times
func roll(interpreter *Interpreter) { func roll(interpreter *Interpreter) {
j := interpreter.PopInt() j := interpreter.PopInt()
@ -43,20 +47,25 @@ func roll(interpreter *Interpreter) {
interpreter.Push(values[(n+i-j)%n]) interpreter.Push(values[(n+i-j)%n])
} }
} }
//any1 … anyn clear -> Discard all elements //any1 … anyn clear -> Discard all elements
func clear(interpreter *Interpreter) { func clear(interpreter *Interpreter) {
interpreter.ClearOperands() interpreter.ClearOperands()
} }
//any1 … anyn count any1 … anyn n -> Count elements on stack //any1 … anyn count any1 … anyn n -> Count elements on stack
func count(interpreter *Interpreter) { func count(interpreter *Interpreter) {
interpreter.Push(interpreter.OperandSize()) interpreter.Push(interpreter.OperandSize())
} }
//Mark //Mark
type Mark struct{} type Mark struct{}
// mark mark -> Push mark on stack // mark mark -> Push mark on stack
func mark(interpreter *Interpreter) { func mark(interpreter *Interpreter) {
interpreter.Push(Mark{}) interpreter.Push(Mark{})
} }
//mark obj 1 … obj n cleartomark -> Discard elements down through mark //mark obj 1 … obj n cleartomark -> Discard elements down through mark
func cleartomark(interpreter *Interpreter) { func cleartomark(interpreter *Interpreter) {
value := interpreter.Pop() value := interpreter.Pop()
@ -64,6 +73,7 @@ func cleartomark(interpreter *Interpreter) {
value = interpreter.Pop() value = interpreter.Pop()
} }
} }
//mark obj 1 … obj n counttomark mark obj 1 … obj n n -> Count elements down to mark //mark obj 1 … obj n counttomark mark obj 1 … obj n n -> Count elements down to mark
func counttomark(interpreter *Interpreter) { func counttomark(interpreter *Interpreter) {
i := 0 i := 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -4,13 +4,12 @@
package wingui package wingui
import ( import (
"syscall"
"unsafe"
"fmt" "fmt"
"os" "os"
"syscall"
"unsafe"
) )
func abortf(format string, a ...interface{}) { func abortf(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, format, a...) fmt.Fprintf(os.Stdout, format, a...)
os.Exit(1) os.Exit(1)

View file

@ -1,6 +1,5 @@
package wingui package wingui
import "unsafe" import "unsafe"
import "syscall" import "syscall"