-
Notifications
You must be signed in to change notification settings - Fork 26
Handle variadic functions and return values #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Handle variadic functions and return values #16
Conversation
| Tcl_SetResult(interp, result, free_string); | ||
| } | ||
|
|
||
| void _gotk_c_tcl_set_obj_result(Tcl_Interp *interp, Tcl_Obj *result) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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?
94daaf3 to
2e014f4
Compare
This PR implements variadic functions & return values.