Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #48 from adamreese/chore/fmt
Browse files Browse the repository at this point in the history
chore(*): run gofmt
  • Loading branch information
adamreese authored Dec 11, 2018
2 parents 47a8828 + bc2939b commit b662eb2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lua/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (x *table) String() string { return fmt.Sprintf("table: %p", x) }
func (x *table) Length() int { return len(x.list) }
func (x *table) Type() Type { return TableType }

func (x *table) ForEach(fn func(Value,Value)) {
func (x *table) ForEach(fn func(Value, Value)) {
if x.list != nil {
for i, v := range x.list {
fn(Int(i), v)
Expand Down
4 changes: 2 additions & 2 deletions lua/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func UserData(data interface{}) *Object {
}

func (x *Object) Value() interface{} { return x.data }
func (x *Object) String() string { return fmt.Sprintf("userdata: %p", x) }
func (x *Object) Type() Type { return UserDataType }
func (x *Object) String() string { return fmt.Sprintf("userdata: %p", x) }
func (x *Object) Type() Type { return UserDataType }

type Table interface {
Value
Expand Down
6 changes: 3 additions & 3 deletions pkg/luautil/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func mapLength(state *lua.State) int {

func valueFromMap(state *lua.State, rv reflect.Value) *lua.Object {
var mapMetaFuncs = map[string]lua.Func{
"__newindex": lua.Func(mapNewIndex),
"__newindex": lua.Func(mapNewIndex),
"__index": lua.Func(mapIndex),
"__len": lua.Func(mapLength),
"__len": lua.Func(mapLength),
}
state.Push(rv.Interface())
state.NewTableSize(0, len(mapMetaFuncs))
state.SetFuncs(mapMetaFuncs, 0)
state.SetMetaTableAt(-2)
return state.ToUserData(-1)
}
}
3 changes: 1 addition & 2 deletions pkg/luautil/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/Azure/golua/lua"
)


func ValueOf(state *lua.State, any interface{}) lua.Value {
if any == nil {
return nil
Expand Down Expand Up @@ -77,4 +76,4 @@ func tableToGo(table lua.Table) reflect.Value {
}
return reflect.ValueOf(slice)
}
}
}
10 changes: 5 additions & 5 deletions pkg/luautil/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func sliceNewIndex(state *lua.State) int {
if index < 1 || index > slice.Len() {
state.ArgError(2, "index out of range")
}
slice.Index(index-1).Set(value)
slice.Index(index - 1).Set(value)
return 0
}

Expand All @@ -27,7 +27,7 @@ func sliceIndex(state *lua.State) int {
if index < 1 || index > slice.Len() {
state.ArgError(2, "index out of range")
}
state.Push(valueOf(state, slice.Index(index-1).Interface()))
state.Push(valueOf(state, slice.Index(index-1).Interface()))
return 1
}

Expand All @@ -38,13 +38,13 @@ func sliceLength(state *lua.State) int {

func valueFromSlice(state *lua.State, rv reflect.Value) *lua.Object {
var sliceMetaFuncs = map[string]lua.Func{
"__newindex": lua.Func(sliceNewIndex),
"__newindex": lua.Func(sliceNewIndex),
"__index": lua.Func(sliceIndex),
"__len": lua.Func(sliceLength),
"__len": lua.Func(sliceLength),
}
state.Push(rv.Interface())
state.NewTableSize(0, len(sliceMetaFuncs))
state.SetFuncs(sliceMetaFuncs, 0)
state.SetMetaTableAt(-2)
return state.ToUserData(-1)
}
}

0 comments on commit b662eb2

Please sign in to comment.