Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ out, err := troop.Call("fmt.Fprintf", os.Stdout, "hello %s", []interface{}{"worl
if err != nil { // some error calling the function
return err
}
n, err := out[0].(int), out[1].(error)
n, err := out[0].Int(), out[1].Interface().(error)
if err != nil {
return err
}
Expand Down
8 changes: 0 additions & 8 deletions reflect_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import (
"unsafe"
)

func ifaces(values []reflect.Value) []interface{} {
out := make([]interface{}, 0, len(values))
for _, value := range values {
out = append(out, value.Interface())
}
return out
}

func reflectCanBeNil(rtyp reflect.Type) bool {
switch rtyp.Kind() {
case reflect.Interface,
Expand Down
4 changes: 2 additions & 2 deletions troop_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (t *Troop) Functions() ([]string, error) {
return out, nil
}

func (t *Troop) Call(name string, args ...interface{}) ([]interface{}, error) {
func (t *Troop) Call(name string, args ...interface{}) ([]reflect.Value, error) {
if err := t.check(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -103,7 +103,7 @@ func (t *Troop) Call(name string, args ...interface{}) ([]interface{}, error) {
// make it happen
fn_typ := reflect.FuncOf(in_types, out_types, false)
fn := reflect.ValueOf(makeInterface(dataPtr(fn_typ), unsafe.Pointer(&pc)))
return ifaces(fn.Call(in)), nil
return fn.Call(in), nil
}

func (t *Troop) buildArguments(args []interface{}, dtypes []dwarf.Type) (
Expand Down