Skip to content
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

auto: new package for automatically wrapping Go functionality #137

Open
2 of 3 tasks
DeedleFake opened this issue Oct 25, 2018 · 0 comments
Open
2 of 3 tasks

auto: new package for automatically wrapping Go functionality #137

DeedleFake opened this issue Oct 25, 2018 · 0 comments

Comments

@DeedleFake
Copy link
Owner

DeedleFake commented Oct 25, 2018

Currently, the primary way to access simple Go functions from WDTE is by providing a GoFunc to call. While this is nice as a low-level system, it would be quite useful to be able to just wrap existing Go functions without having to worry about perfectly matching the Func.Call() API. As such, a set of functions for automatically creating Funcs from existing Go structures would be quite useful.

As these are not technically required for the core functionality of WDTE, they should probably be in a separate package, such as wrap, fun, or simple. Maybe auto. Hmmm...

  • func Func(name string, f interface{}) wdte.Func. Takes a name so that the frame can be subbed properly and a function. It uses reflection to create a wrapper around f that properly converts arguments passed from WDTE to requested types, automatically handling built-in types separately, and then converts the return value back as well. Might also support multiple return values.
  • A variant of Func that lets the user specify how the arguments are handled, allowing for more complicated WDTE function signatures.
  • The opposite of Func. A function that converts a wdte.Func to a Go function. Probably should work similarly to reflect.MakeFunc.
@DeedleFake DeedleFake self-assigned this Oct 25, 2018
@DeedleFake DeedleFake added this to Todo in Initial Implementation via automation Oct 25, 2018
@DeedleFake DeedleFake mentioned this issue Oct 26, 2018
@DeedleFake DeedleFake moved this from Todo to Doing in Initial Implementation Oct 26, 2018
@DeedleFake DeedleFake changed the title Add Convience Functions for Wrapping Go Functionality auto: new package for automatically wrapping Go functionality Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant