-
Notifications
You must be signed in to change notification settings - Fork 94
-
Notifications
You must be signed in to change notification settings - Fork 94
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
On macOS testClass
crashes in dealloc
#5
Comments
May have to remove this feature or make it an iOS only thing. Was able to build classes without the objc runtime but not without memory leaks. ARC ignore the objects even when the retain counts are set. |
Maybe the layout on x86 is just different to the layout on ARM. And I think it would be OK to just throw the You could also create an issue for this, maybe some other contributor steps in and does the macOS/Linux parts. |
I commented out the functionality in PR #6. If that is integrated, we could close this particular issue. (and maybe we would want to create new ones for macOS/Linux/x86 support). |
Merged your PR. Would like to get this functionality in sometime. From the looks of it I don't know how possible it is though. Going to close this for now. |
Can we re-open this? The crash is still there, but we're just sort of ignoring it by not supporting macOS... Per Joe's advice, we should be using |
Reopened. If youre able to get it feel free to PR it! Id love to have this. Ill try to look into it as well |
@NSExceptional Got it quick version of it working using In func buildClass(type: Any.Type) throws -> Any {
var md = ClassMetadata(type: type)
let info = md.toTypeInfo()
guard var value = _allocObject(
type: type,
requiredSize: md.pointer.pointee.classSize,
requiredAlignmentMask: UInt32(md.alignment)) else {
throw RuntimeError.unableToBuildType(type: type)
}
try withClassValuePointer(of: &value) { pointer in
try setProperties(typeInfo: info, pointer: pointer)
}
return value
} |
Neat! Can you share your definition for Edit: I'm actually getting an error thrown, it's not able to cast the resulting value to @_silgen_name("swift_allocObject")
func _allocObject(
type: Any.Type,
requiredSize: UInt32,
requiredAlignmentMask: UInt32
) -> UnsafeRawPointer? |
Here you go:
|
I’ll be out for a few hours so if you have it working feel free to push a PR as well! If not I’ll do it later. |
Done and done: |
Use swift_allocObject instead of Objc runtime, fix #5
Merged! Thanks for adding that. |
Looks like something is wrong/different w/ the RC here.
The text was updated successfully, but these errors were encountered: