-
Notifications
You must be signed in to change notification settings - Fork 84
Give up supporting Go 1.16 and Go 1.17 #54
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
Comments
There isn't anything that needs to be done since purego already works for 1.18. Updating to 1.18 would allow us to remove the stack and register hack files though. This is because on Darwin amd64 and arm64 would use register based calling convention by 1.18 |
Another reason is that semi-standard libraries like
Sure! As there seems no issue, I'll drop Go 1.16 and 1.17 supports from Ebitengine and Oto first. After that, we can remove the hacks for old Go. It's not hurry anyway. |
Oh yeah! |
Ebitengine: hajimehoshi/ebiten@606ff77 OK, it's ready! As I said, it's not hurry. |
By the way, do you think it is possible to remove go-vet warnings?
I feel like these are false positives. See also golang/go#56487 |
Yeah these are false positives. My first inclination is to use the address hack. Like here. But I'll see if there is just a better way to write it that avoids the message |
golang/go#56487 (comment) This might be fixed at Go 1.20! |
That would be awesome! I do want to point out that the two test messages are actually examples that should be replaced with |
So I came up with a clever solution. Since Objective-C objects are just pointers to C structs with the first field being type So the type barT struct {
isa objc.Class
bar int
}
var class = objc.AllocateClassPair(objc.GetClass("NSObject"), "BarObject", 0)
class.AddIvar("bar", int(0), "q")
class.AddMethod(objc.RegisterName("bar"), objc.NewIMP(func(self *barT, _cmd objc.SEL) int {
return self.bar
}), "q@:")
class.AddMethod(objc.RegisterName("setBar:"), objc.NewIMP(func(self *barT, _cmd objc.SEL, bar int) {
self.bar = bar
}), "v@:q")
class.Register() And we can verify that the field has the right offset by testing like: var barOffset = class.InstanceVariable("bar").Offset()
if barOffset != unsafe.Offsetof(barT{}.bar) {
panic("offsets are different")
} This requires a small change to support IMPs that take a pointer struct whose structure matches
Doing so makes the tests completely type safe. Also, It might be nice to have an API that creates the objc.Class from the fields and methods of a Go struct. It would also check that each of the methods like var class_BarObject objc.Class
type _BarObject struct {
isa objc.Class
bar int
}
func (b * _BarObject) getBar(_cmd objc.SEL) int {
return b.bar
}
func (b * _BarObject) setBar(_cmd objc.SEL, bar int) {
b.bar = bar
}
func init() {
// RegisterClass takes a pointer to a struct whose fields matches that of an objective-c object
// and the name of the superclass. It returns the created class or an error message if it failed to.
// The created objc.Class will have Ivars created for each field in the struct and methods added
// for each method that takes a pointer receiver.
var err error
class_BarObject, err = objc.RegisterClass(& _BarObject, "NSObject")
// ... check error here
} Thoughts? I think we should create a new issue to track a solution to the |
Nice idea!
Well, I think tracking this by this issue #54 is fine, but it's also fine to have another issue. |
So we can now replace |
Yep! :D |
DebianUbuntu stable already supports Go 1.18 (note thatUbuntuDebian stable supports Go 1.15 by default...)@TotallyGamerJet what do you think? Are there extra tasks for this?
The text was updated successfully, but these errors were encountered: