Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
yofu committed Jan 7, 2016
1 parent e5dcad0 commit 2ff20f3
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func NewBlock(name, desc string) *Block {
return b
}


// Format writes data to formatter.
func (b *Block) Format(f *format.Formatter) {
f.WriteString(0, "BLOCK")
Expand Down Expand Up @@ -67,6 +66,7 @@ func (b *Block) FormatString(f *format.Formatter) string {
func (b *Block) Handle() int {
return b.handle
}

// SetHandle sets handles to BLOCK and ENDBLK.
func (b *Block) SetHandle(v *int) {
b.handle = *v
Expand Down
2 changes: 1 addition & 1 deletion drawing/drawing.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (d *Drawing) LineType(name string) (*table.LineType, error) {
}

// Entities returns slice of all entities contained in Drawing.
func (d *Drawing) Entities() (entity.Entities) {
func (d *Drawing) Entities() entity.Entities {
return d.Sections[ENTITIES].(entity.Entities)
}

Expand Down
4 changes: 2 additions & 2 deletions dxf.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Open(filename string) (*drawing.Drawing, error) {
scanner := bufio.NewScanner(f)
d := NewDrawing()
var code, value string
parsers := []func(*drawing.Drawing, int, [][2]string) (error) {
parsers := []func(*drawing.Drawing, int, [][2]string) error{
ParseHeader,
ParseClasses,
ParseTables,
Expand All @@ -44,7 +44,7 @@ func Open(filename string) (*drawing.Drawing, error) {
}
data := make([][2]string, 0)
setparser := false
var parser func(*drawing.Drawing, int, [][2]string) (error)
var parser func(*drawing.Drawing, int, [][2]string) error
line := 0
startline := 0
for scanner.Scan() {
Expand Down
3 changes: 3 additions & 0 deletions entity/circle.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ func (c *Circle) FormatString(f *format.Formatter) string {
func (c *Circle) CurrentDirection() []float64 {
return c.Direction
}

// SetDirection sets new extrusion direction.
func (c *Circle) SetDirection(d []float64) {
c.Direction = d
}

// CurrentCoord returns center point coord.
func (c *Circle) CurrentCoord() []float64 {
return c.Center
}

// SetCoord sets new center point coord.
func (c *Circle) SetCoord(co []float64) {
c.Center = co
Expand Down
1 change: 1 addition & 0 deletions entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (e *entity) FormatString(f *format.Formatter) string {
func (e *entity) Handle() int {
return e.handle
}

// SetHandle sets handles to TABLE itself and each SymbolTable.
func (e *entity) SetHandle(v *int) {
e.handle = *v
Expand Down
2 changes: 2 additions & 0 deletions entity/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ func (t *Text) togglegenflag(val int) {
t.genflag |= val
}
}

// FlipHorizontal flips Text horizontally.
func (t *Text) FlipHorizontal() {
t.togglegenflag(2)
}

// FlipHorizontal flips Text vertically.
func (t *Text) FlipVertical() {
t.togglegenflag(4)
Expand Down
1 change: 1 addition & 0 deletions object/acdbdictionarywdflt.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (d *AcDbDictionaryWDFLT) FormatString(f *format.Formatter) string {
func (d *AcDbDictionaryWDFLT) Handle() int {
return d.handle
}

// SetHandle sets a handle.
func (d *AcDbDictionaryWDFLT) SetHandle(v *int) {
d.handle = *v
Expand Down
1 change: 1 addition & 0 deletions object/acdbplaceholder.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (p *AcDbPlaceHolder) FormatString(f *format.Formatter) string {
func (p *AcDbPlaceHolder) Handle() int {
return p.handle
}

// SetHandle sets a handle.
func (p *AcDbPlaceHolder) SetHandle(v *int) {
p.handle = *v
Expand Down
1 change: 1 addition & 0 deletions object/dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (d *Dictionary) FormatString(f *format.Formatter) string {
func (d *Dictionary) Handle() int {
return d.handle
}

// SetHandle sets a handle.
func (d *Dictionary) SetHandle(v *int) {
d.handle = *v
Expand Down
1 change: 1 addition & 0 deletions object/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (g *Group) FormatString(f *format.Formatter) string {
func (g *Group) Handle() int {
return g.handle
}

// SetHandle sets a handle.
func (g *Group) SetHandle(v *int) {
g.handle = *v
Expand Down
20 changes: 10 additions & 10 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func ParseClasses(d *drawing.Drawing, line int, data [][2]string) error {

// ParseTables parses TABLES section.
func ParseTables(d *drawing.Drawing, line int, data [][2]string) error {
parsers := []func(*drawing.Drawing, [][2]string) (table.SymbolTable, error) {
parsers := []func(*drawing.Drawing, [][2]string) (table.SymbolTable, error){
ParseViewport,
ParseLtype,
ParseLayer,
Expand All @@ -103,11 +103,11 @@ func ParseTables(d *drawing.Drawing, line int, data [][2]string) error {
for i, dt := range data {
if setparser {
if dt[0] != "2" {
return fmt.Errorf("line %d: invalid group code: %s", line + 2*i, dt[0])
return fmt.Errorf("line %d: invalid group code: %s", line+2*i, dt[0])
}
ind = int(table.TableTypeValue(strings.ToUpper(dt[1])))
if ind < 0 {
return fmt.Errorf("line %d: unknown table type: %s", line + 2*i, dt[1])
return fmt.Errorf("line %d: unknown table type: %s", line+2*i, dt[1])
}
parser = parsers[ind]
setparser = false
Expand Down Expand Up @@ -135,15 +135,15 @@ func ParseTables(d *drawing.Drawing, line int, data [][2]string) error {
if len(tmpdata) > 0 {
err := ParseTable(d, tmpdata, ind, parser)
if err != nil {
return fmt.Errorf("line %d: %s", line + 2*len(data), err.Error())
return fmt.Errorf("line %d: %s", line+2*len(data), err.Error())
}
tmpdata = make([][2]string, 0)
}
return nil
}

// ParseTable parses each TABLE, which starts with "0\nTABLE\n" and ends with "0\nENDTAB\n".
func ParseTable(d *drawing.Drawing, data [][2]string, index int, parser func(*drawing.Drawing, [][2]string)(table.SymbolTable, error)) error {
func ParseTable(d *drawing.Drawing, data [][2]string, index int, parser func(*drawing.Drawing, [][2]string) (table.SymbolTable, error)) error {
t := d.Sections[drawing.TABLES].(table.Tables)[index]
t.Clear()
tmpdata := make([][2]string, 0)
Expand Down Expand Up @@ -426,7 +426,7 @@ func ParseBlocks(d *drawing.Drawing, line int, data [][2]string) error {
if len(tmpdata) > 0 {
err := ParseBlock(d, tmpdata)
if err != nil {
return fmt.Errorf("line %d: %s", line + 2*i, err.Error())
return fmt.Errorf("line %d: %s", line+2*i, err.Error())
}
tmpdata = make([][2]string, 0)
}
Expand All @@ -445,7 +445,7 @@ func ParseBlocks(d *drawing.Drawing, line int, data [][2]string) error {
if len(tmpdata) > 0 {
err := ParseBlock(d, tmpdata)
if err != nil {
return fmt.Errorf("line %d: %s", line + 2*len(data), err.Error())
return fmt.Errorf("line %d: %s", line+2*len(data), err.Error())
}
tmpdata = make([][2]string, 0)
}
Expand Down Expand Up @@ -497,7 +497,7 @@ func ParseEntities(d *drawing.Drawing, line int, data [][2]string) error {
if len(tmpdata) > 0 {
e, err := ParseEntity(d, tmpdata)
if err != nil {
return fmt.Errorf("line %d: %s", line + 2*i, err.Error())
return fmt.Errorf("line %d: %s", line+2*i, err.Error())
}
d.AddEntity(e)
tmpdata = make([][2]string, 0)
Expand All @@ -508,7 +508,7 @@ func ParseEntities(d *drawing.Drawing, line int, data [][2]string) error {
if len(tmpdata) > 0 {
e, err := ParseEntity(d, tmpdata)
if err != nil {
return fmt.Errorf("line %d: %s", line + 2*len(data), err.Error())
return fmt.Errorf("line %d: %s", line+2*len(data), err.Error())
}
d.AddEntity(e)
tmpdata = make([][2]string, 0)
Expand All @@ -532,7 +532,7 @@ func ParseEntity(d *drawing.Drawing, data [][2]string) (entity.Entity, error) {
}

// ParseEntityFunc returns a function for parsing acoording to entity type string.
func ParseEntityFunc(t string) (func(*drawing.Drawing, [][2]string)(entity.Entity, error), error) {
func ParseEntityFunc(t string) (func(*drawing.Drawing, [][2]string) (entity.Entity, error), error) {
switch t {
case "LINE":
return ParseLine, nil
Expand Down
7 changes: 4 additions & 3 deletions table/appid.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

// AppID represents APPID SymbolTable.
type AppID struct {
handle int
owner handle.Handler
name string
handle int
owner handle.Handler
name string
}

// NewAppID create a new AppID.
Expand Down Expand Up @@ -53,6 +53,7 @@ func (a *AppID) FormatString(f *format.Formatter) string {
func (a *AppID) Handle() int {
return a.handle
}

// SetHandle sets a handle.
func (a *AppID) SetHandle(v *int) {
a.handle = *v
Expand Down
7 changes: 4 additions & 3 deletions table/block_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

// BlockRecord represents BLOCK_RECORD SymbolTable.
type BlockRecord struct {
handle int
owner handle.Handler
name string
handle int
owner handle.Handler
name string
}

// NewBlockRecord creates a new BlockRecord.
Expand Down Expand Up @@ -55,6 +55,7 @@ func (b *BlockRecord) FormatString(f *format.Formatter) string {
func (b *BlockRecord) Handle() int {
return b.handle
}

// SetHandle sets a handle.
func (b *BlockRecord) SetHandle(v *int) {
b.handle = *v
Expand Down
7 changes: 4 additions & 3 deletions table/dimstyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

// DimStyle represents DIMSTYLE SymbolTable.
type DimStyle struct {
handle int
owner handle.Handler
name string
handle int
owner handle.Handler
name string
}

// NewDimStyle creates a new DimStyle.
Expand Down Expand Up @@ -53,6 +53,7 @@ func (d *DimStyle) FormatString(f *format.Formatter) string {
func (d *DimStyle) Handle() int {
return d.handle
}

// SetHandle sets a handle.
func (d *DimStyle) SetHandle(v *int) {
d.handle = *v
Expand Down
8 changes: 6 additions & 2 deletions table/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (l *Layer) FormatString(f *format.Formatter) string {
func (l *Layer) Handle() int {
return l.handle
}

// SetHandle sets a handle.
func (l *Layer) SetHandle(v *int) {
l.handle = *v
Expand Down Expand Up @@ -106,7 +107,7 @@ func (l *Layer) SetLineWidth(w int) int {
minkey := -3
minval := 211
for k, _ := range LineWidth {
tmp := k-w
tmp := k - w
if tmp > 0 && tmp < minval {
minkey = k
minval = tmp
Expand All @@ -122,7 +123,7 @@ func (l *Layer) SetPlotStyle(ps handle.Handler) {
}

// SetFlag sets standard flags.
// 1 = Layer is frozen; otherwise layer is thawed.
// 1 = Layer is frozen; otherwise layer is thawed.
// 2 = Layer is frozen by default in new viewports.
// 4 = Layer is locked.
// 16 = If set, table entry is externally dependent on an xref.
Expand All @@ -131,10 +132,12 @@ func (l *Layer) SetPlotStyle(ps handle.Handler) {
func (l *Layer) SetFlag(val int) {
l.flag = val
}

// Freeze freezes Layer.
func (l *Layer) Freeze() {
l.flag |= 1
}

// UnFreeze unfreezes Layer.
func (l *Layer) UnFreeze() {
l.flag &= ^1
Expand All @@ -144,6 +147,7 @@ func (l *Layer) UnFreeze() {
func (l *Layer) Lock() {
l.flag |= 4
}

// UnLock unlocks Layer.
func (l *Layer) UnLock() {
l.flag &= ^4
Expand Down
1 change: 1 addition & 0 deletions table/linetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (lt *LineType) FormatString(f *format.Formatter) string {
func (lt *LineType) Handle() int {
return lt.handle
}

// SetHandle sets a handle.
func (lt *LineType) SetHandle(v *int) {
lt.handle = *v
Expand Down
2 changes: 1 addition & 1 deletion table/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (st *Style) FormatString(f *format.Formatter) string {
func (st *Style) Handle() int {
return st.handle
}

// SetHandle sets a handle.
func (st *Style) SetHandle(v *int) {
st.handle = *v
Expand All @@ -83,4 +84,3 @@ func (st *Style) SetOwner(h handle.Handler) {
func (st *Style) Name() string {
return st.name
}

1 change: 1 addition & 0 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (t *Table) FormatString(f *format.Formatter) string {
func (t *Table) Handle() int {
return t.handle
}

// SetHandle sets handles to TABLE itself and each SymbolTable.
func (t *Table) SetHandle(v *int) {
t.handle = *v
Expand Down
1 change: 1 addition & 0 deletions table/ucs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (u *Ucs) FormatString(f *format.Formatter) string {
func (u *Ucs) Handle() int {
return u.handle
}

// SetHandle sets a handle.
func (u *Ucs) SetHandle(h *int) {
u.handle = *h
Expand Down
1 change: 1 addition & 0 deletions table/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (v *View) FormatString(f *format.Formatter) string {
func (v *View) Handle() int {
return v.handle
}

// SetHandle sets a handle.
func (v *View) SetHandle(h *int) {
v.handle = *h
Expand Down
1 change: 1 addition & 0 deletions table/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (v *Viewport) FormatString(f *format.Formatter) string {
func (v *Viewport) Handle() int {
return v.handle
}

// SetHandle sets a handle.
func (v *Viewport) SetHandle(h *int) {
v.handle = *h
Expand Down

0 comments on commit 2ff20f3

Please sign in to comment.