Skip to content

Conversation

@robert-uhl
Copy link

This PR implements variadic functions & return values.

Tcl_SetResult(interp, result, free_string);
}

void _gotk_c_tcl_set_obj_result(Tcl_Interp *interp, Tcl_Obj *result) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to return a TCL object.


func go_value_to_tcl_obj(value interface{}) *C.Tcl_Obj {
v := reflect.ValueOf(value)
func go_value_to_tcl_obj(v reflect.Value) *C.Tcl_Obj {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to using a reflect.Value because it better reflects usage at the existing call site and the new one.

s := v.String()
sh := *(*reflect.StringHeader)(unsafe.Pointer(&s))
return C.Tcl_NewStringObj((*C.char)(unsafe.Pointer(sh.Data)), C.int(len(s)))
b := C.CBytes([]byte(s))
Copy link
Author

@robert-uhl robert-uhl Jul 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to this style in order to muffle linter. It does allocate more, though. Maybe it's not worth it?

@robert-uhl robert-uhl force-pushed the handle-variadic-functions-and-return-values branch from 94daaf3 to 2e014f4 Compare July 27, 2017 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant