-
Notifications
You must be signed in to change notification settings - Fork 510
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
[CoreFoundation] Fetch a few static values lazily. #4924
Conversation
This avoids using static constructors, and also avoids fetching the values unless they're needed.
get { | ||
if (kCFTypeArrayCallbacks_ptr_value == IntPtr.Zero) | ||
kCFTypeArrayCallbacks_ptr_value = Dlfcn.GetIndirect (Libraries.CoreFoundation.Handle, "kCFTypeArrayCallBacks"); | ||
return kCFTypeArrayCallbacks_ptr_value; |
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.
Why not move this into corefoundation.cs
as [Field]
?
That will give us some free* introspection and xtro tests and less manual code to maintain.
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.
That will call Dlfcn.GetIntPtr
, which is incorrect for this (it needs to do Dlfcn.GetIndirect
).
return; | ||
try { | ||
True = new CFBoolean (Dlfcn.GetIntPtr (handle, "kCFBooleanTrue"), false); | ||
False = new CFBoolean (Dlfcn.GetIntPtr (handle, "kCFBooleanFalse"), false); |
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, if we touch that code then I'd rather use the bindings file
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.
fixed
src/CoreFoundation/DispatchData.cs
Outdated
get { | ||
if (free_ptr == IntPtr.Zero) | ||
free_ptr = Marshal.ReadIntPtr (Dlfcn.dlsym (Libraries.LibC.Handle, "_dispatch_data_destructor_free")); | ||
return free_ptr; |
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
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.
Fixed.
Build success |
… a manual binding.
…tor. Since the generator doesn't know about CFBoolean, bind as IntPtr instead, and fix most callers to use the handle directly, instead of getting a CFBoolean object and then immediately getting the handle.
Build failure Test results7 tests failed, 0 tests skipped, 73 tests passed.Failed tests
|
Build failure Test results1 tests failed, 0 tests skipped, 80 tests passed.Failed tests
|
Build success |
This avoids using static constructors, and also avoids fetching the values
unless they're needed.