Skip to content

Commit

Permalink
MacOs 14 Sonoma dlopen cache fix
Browse files Browse the repository at this point in the history
Updated the find_library patch for backward compatibility
Closes #2547
  • Loading branch information
takacsmark committed Nov 15, 2023
1 parent 5b4731c commit d480c9e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions vispy/ext/cocoapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def new_util_find_library(name):
return res
lut = {
'objc': 'libobjc.dylib',
'quartz': 'Quartz.framework/Quartz'
'quartz': '/System/Library/Frameworks/Quartz.framework/Quartz'
}
return lut.get(name, name+'.framework/'+name)
return lut.get(name, f'/System/Library/Frameworks/${name}.framework/${name}')
util.find_library = new_util_find_library


Expand All @@ -57,6 +57,7 @@ def encoding_for_ctype(vartype):
py_object: PyObjectEncoding}
return typecodes.get(vartype, b'?')


if __LP64__:
NSInteger = c_long
NSUInteger = c_ulong
Expand Down Expand Up @@ -84,16 +85,22 @@ def encoding_for_ctype(vartype):

class NSPoint(Structure):
_fields_ = [("x", CGFloat), ("y", CGFloat)]


CGPoint = NSPoint


class NSSize(Structure):
_fields_ = [("width", CGFloat), ("height", CGFloat)]


CGSize = NSSize


class NSRect(Structure):
_fields_ = [("origin", NSPoint), ("size", NSSize)]


CGRect = NSRect


Expand Down Expand Up @@ -431,6 +438,7 @@ def send_message(receiver, selName, *args, **kwargs):
class OBJC_SUPER(Structure):
_fields_ = [('receiver', c_void_p), ('class', c_void_p)]


OBJC_SUPER_PTR = POINTER(OBJC_SUPER)


Expand Down Expand Up @@ -475,7 +483,7 @@ def parse_type_encoding(encoding):
elif c == b'}':
typecode += c
brace_count -= 1
assert(brace_count >= 0)
assert (brace_count >= 0)
elif c == b'[':
if typecode and typecode[-1:] != b'^' and brace_count == 0 and \
bracket_count == 0:
Expand All @@ -486,7 +494,7 @@ def parse_type_encoding(encoding):
elif c == b']':
typecode += c
bracket_count -= 1
assert(bracket_count >= 0)
assert (bracket_count >= 0)
elif brace_count or bracket_count:
typecode += c
elif c in b'0123456789':
Expand Down Expand Up @@ -545,8 +553,8 @@ def register_subclass(subclass):

def add_method(cls, selName, method, types):
type_encodings = parse_type_encoding(types)
assert(type_encodings[1] == b'@') # ensure id self typecode
assert(type_encodings[2] == b':') # ensure SEL cmd typecode
assert (type_encodings[1] == b'@') # ensure id self typecode
assert (type_encodings[2] == b':') # ensure SEL cmd typecode
selector = get_selector(selName)
cfunctype = cfunctype_for_encoding(types)
imp = cfunctype(method)
Expand Down Expand Up @@ -1077,6 +1085,7 @@ def cfnumber_to_number(cfnumber):
raise Exception(
'cfnumber_to_number: unhandled CFNumber type %d' % numeric_type)


# Dictionary of cftypes matched to the method converting them to python values.
known_cftypes = {cf.CFStringGetTypeID(): cfstring_to_string,
cf.CFNumberGetTypeID(): cfnumber_to_number}
Expand All @@ -1097,6 +1106,7 @@ def cftype_to_value(cftype):
else:
return cftype


cf.CFSetGetCount.restype = CFIndex
cf.CFSetGetCount.argtypes = [c_void_p]

Expand All @@ -1113,6 +1123,7 @@ def cfset_to_set(cfset):
cf.CFSetGetValues(cfset, byref(buffer))
return set([cftype_to_value(c_void_p(buffer[i])) for i in range(count)])


cf.CFArrayGetCount.restype = CFIndex
cf.CFArrayGetCount.argtypes = [c_void_p]

Expand Down

0 comments on commit d480c9e

Please sign in to comment.