-
Notifications
You must be signed in to change notification settings - Fork 124
bind, gencffi: Remove generating builders and support Vars and Consts. #98
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
Conversation
Ready for review. |
please rebase on top of the new |
Yeah done! |
3e3b555
to
b75dbe6
Compare
b75dbe6
to
471fc48
Compare
471fc48
to
9bbfbb0
Compare
@sbinet Ready to review :) PTAL |
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.
LGTM, with minor edits.
_examples/vars/test.py
Outdated
@@ -7,6 +7,7 @@ | |||
|
|||
import vars | |||
|
|||
print("Before set values") |
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.
s/Before set values/Initial values/
_examples/vars/test.py
Outdated
|
||
vars.SetKind1(123) | ||
vars.SetKind2(456) | ||
print("After set values") |
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.
s/After set values/New values/
bind/bind.go
Outdated
// Second, Then GenCFFI writes a CFFI builder package with writing exposed interfaces | ||
// Third, The GenCFFI writes a wrapper python script. | ||
func GenCFFI(b io.Writer, w io.Writer, fset *token.FileSet, pkg *Package, lang int) error { | ||
// Second, The GenCFFI writes a wrapper python script. |
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.
s/Second, The GenCFFI/Then, GenCFFI/
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.
also:
s/First, GenCFFI analyze/First, GenCFFI analyzes/
bind/gencffi_func.go
Outdated
g.wrapper.Printf(` | ||
# pythonization of: %[1]s.%[2]s | ||
def Get%[2]s(%[3]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.
perhaps inject the documentation (if any) for the variable we get here?
so when we do help(mymodule.GetFoo)
we get the documentation that was attached to the Foo
variable on the Go side.
that would look like:
g.wrapper.Printf(`
# pythonization of: %[1]s.%[2]s
def Get%[2]s(%[3]s):
"""%[4]s""""
`,
g.pkg.pkg.Name(),
o.GoName(),
strings.Join(funcArgs, ", "),
o.Doc(),
)
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.
@sbinet That's cool. I will do that :)
bind/gencffi_func.go
Outdated
g.wrapper.Printf(` | ||
# pythonization of: %[1]s.%[2]s | ||
def Set%[2]s(%[3]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.
same here.
4cf7355
to
189b108
Compare
@sbinet Done! |
main_test.go
Outdated
testPkgWithCFFI(t, pkg{ | ||
path: "_examples/vars", | ||
want: []byte(`Initial values | ||
v1 = v1 |
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.
perhaps also add here a test of the docstring?
see:
https://github.com/go-python/gopy/blob/master/_examples/empty/test.py#L10
https://github.com/go-python/gopy/blob/master/main_test.go#L399
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.
(just for one of the vars, no need to do that for all of them. the mechanism is the same)
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.
@sbinet Just for the vars.__doc__
? or for all the Get/Set functions?
Only vars__doc__ is okay but for each of Get/Set functions might be a problem.
The problem of Get/Set functions docstring is that output is different between Cpy2 and CFFI.
# CFFI output
doc(vars.GetV1()):
'returns vars.V1'
# CPy2 output
doc(vars.GetV1()):
''
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.
and for one Get/Set
pair.
it's OK to have a different reference for CFFI and for CPython-2.
(if there is no issue number for the CPython-2 backend to generate docstrings for Get/Set
s of vars, I'll add one.)
189b108
to
b275de1
Compare
Updated! |
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.
LGTM
one last thing: please squash the 2 commits together (keeping the commit message of the first commit), and I'll merge that PR.
thanks!
- Remove the generating builder python script. - Now, genCFFI interface is same as the genCpy. - Support builtin-types Vars and Consts. - Pass empty.go - Pass cgo.go - Pass vars.go - Pass consts.go Updates: go-python#102
b275de1
to
2bad8a4
Compare
@sbinet Thank you for reviewing this. :) PTAL |
thanks |
empty.go
cgo.go
vars.go
+ Add set vars test.consts.go
Updates: #102