Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

corona10
Copy link
Collaborator

@corona10 corona10 commented Jun 30, 2017

  • Generate Struct types from a CFFI engine.
  • Passing a Struct type as an argument is supported.
  • Passing structs.go test.

Update: #102
Fix: #106

@corona10
Copy link
Collaborator Author

corona10 commented Jun 30, 2017

@sbinet
PTAL :)

@corona10 corona10 force-pushed the gsoc-usertype branch 2 times, most recently from 57540c2 to e8c86e2 Compare July 1, 2017 01:36
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'
Copy link
Collaborator Author

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'

Copy link
Member

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.

Copy link
Collaborator Author

@corona10 corona10 Jul 12, 2017

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?

Copy link
Member

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.

Copy link
Member

@sbinet sbinet Jul 14, 2017

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.

Copy link
Member

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")
Copy link
Member

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.

"strconv"
"strings"
)

func (g *cffiGen) genCdefStruct(s Struct) {
g.wrapper.Printf("typedef void* %s;\n", s.sym.cgoname)
Copy link
Member

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'
Copy link
Member

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.
@corona10
Copy link
Collaborator Author

@sbinet Sorry for a delay. Updated!

@sbinet
Copy link
Member

sbinet commented Jul 14, 2017

thanks!

@sbinet
Copy link
Member

sbinet commented Jul 14, 2017

closed via 4442f0a

@sbinet sbinet closed this Jul 14, 2017
@corona10 corona10 deleted the gsoc-usertype branch August 4, 2017 15:18
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.

2 participants