-
Notifications
You must be signed in to change notification settings - Fork 122
cffi: Support struct types. #113
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
@sbinet |
57540c2
to
e8c86e2
Compare
caught error: S2.__init__ takes at most 1 argument(s) | ||
s2 = structs.S2{Public:42, private:0} | ||
s2.Public = 42 | ||
caught error: 'S2' object has no attribute 'private' |
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
Note that error msg is changed
CPy2 version
caught error: 'structs.S2' object has no attribute 'private'
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.
it would be better to keep the module/package name there as well.
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
To solve this issue, I need to change tp_name
. Is there any way to change tp_name
on Python code level?
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.
no, I don't think there is.
but it's actually probably a mistake from my end to try to sneak the package name in there.
regular python classes don't show this.
gopy
shouldn't either.
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.
I'll file an issue for this.
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.
done: #119
bind/gencffi.go
Outdated
} | ||
g.wrapper.Outdent() | ||
|
||
g.wrapper.Printf("# make sure Cgo is loaded and initialized\n") |
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.
you may want to comment here why we have to put the loading of cgo here and not in the preamble.
bind/gencffi_cdef.go
Outdated
"strconv" | ||
"strings" | ||
) | ||
|
||
func (g *cffiGen) genCdefStruct(s Struct) { | ||
g.wrapper.Printf("typedef void* %s;\n", s.sym.cgoname) |
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 generate some comment that says what this void*
is? (ie with the Go name of the symbol being wrapped)
caught error: S2.__init__ takes at most 1 argument(s) | ||
s2 = structs.S2{Public:42, private:0} | ||
s2.Public = 42 | ||
caught error: 'S2' object has no attribute 'private' |
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.
it would be better to keep the module/package name there as well.
* Generate Struct types from a CFFI engine. * Passing a Struct type as an argument is supported. * Passing 'structs.go' test.
@sbinet Sorry for a delay. Updated! |
thanks! |
closed via 4442f0a |
structs.go
test.Update: #102
Fix: #106