Skip to content

Commit

Permalink
Actually run pre-commit hooks...
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldoussoren committed Apr 9, 2021
1 parent b8cc8f0 commit 43efdf6
Show file tree
Hide file tree
Showing 121 changed files with 29,427 additions and 5,946 deletions.
12 changes: 6 additions & 6 deletions pyobjc-core/Lib/PyObjCTools/TestSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def cast_int(value):
(where as: 1 << 31 == 2147483648)
"""
value = value & 0xffffffff
value = value & 0xFFFFFFFF
if value & 0x80000000:
value = ~value + 1 & 0xffffffff
value = ~value + 1 & 0xFFFFFFFF
return -value
else:
return value
Expand All @@ -136,9 +136,9 @@ def cast_longlong(value):
Usage:
cast_longlong(1 << 63) == -1
"""
value = value & 0xffffffffffffffff
value = value & 0xFFFFFFFFFFFFFFFF
if value & 0x8000000000000000:
value = ~value + 1 & 0xffffffffffffffff
value = ~value + 1 & 0xFFFFFFFFFFFFFFFF
return -value
else:
return value
Expand All @@ -152,15 +152,15 @@ def cast_uint(value):
cast_int(1 << 31) == 2147483648
"""
value = value & 0xffffffff
value = value & 0xFFFFFFFF
return value


def cast_ulonglong(value):
"""
Cast value to 64bit integer
"""
value = value & 0xffffffffffffffff
value = value & 0xFFFFFFFFFFFFFFFF
return value


Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/Lib/objc/_lazyimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def __get_constant(self, name):
elif alias == "objc.NULL":
result = objc.NULL
elif alias == "objc.UINT32_MAX":
result = 0xffffffff
result = 0xFFFFFFFF
else:
result = getattr(self, alias)

Expand Down
21 changes: 12 additions & 9 deletions pyobjc-core/PyObjCTest/test_archive_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,12 +1217,16 @@ def test_recursive_tuple_and_dict_key(self):
@expectedFailure
def test_recursive_tuple_and_dict_like_key(self):
# XXX: Needs further investigation...
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_dict_like_key(self)
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_dict_like_key(
self
)

@expectedFailure
def test_recursive_tuple_and_dict_subclass_key(self):
# XXX: Needs further investigation...
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_dict_subclass_key(self)
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_dict_subclass_key(
self
)

@expectedFailure
def test_recursive_tuple_and_inst_state(self):
Expand All @@ -1237,7 +1241,9 @@ def test_recursive_tuple_and_dict(self):
@expectedFailure
def test_recursive_tuple_and_dict_subclass(self):
# XXX: Needs further investigation...
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_dict_subclass(self)
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_dict_subclass(
self
)

@expectedFailure
def test_recursive_tuple_and_list_like(self):
Expand All @@ -1247,7 +1253,9 @@ def test_recursive_tuple_and_list_like(self):
@expectedFailure
def test_recursive_tuple_and_list_subclass(self):
# XXX: Needs further investigation...
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_list_subclass(self)
test.pickletester.AbstractPickleTests.test_recursive_tuple_and_list_subclass(
self
)

@expectedFailure
def test_recursive_set(self):
Expand All @@ -1269,11 +1277,6 @@ def test_recursive_dict_key(self):
# See 'TestArchiveNative'
test.pickletester.AbstractPickleTests.test_recursive_dict_key(self)

@expectedFailure
def test_recursive_set(self):
# See 'TestArchiveNative'
test.pickletester.AbstractPickleTests.test_recursive_set(self)

@expectedFailure
def test_recursive_frozenset(self):
# See 'TestArchiveNative'
Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/PyObjCTest/test_array_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class MutableArrayTest(list_tests.CommonTest):

@expectedFailure
def test_pop(self):
lists_tests.CommonTest.test_pop(self)
list_tests.CommonTest.test_pop(self)

@onlyIf(0, "test irrelevant for NSMutableArray")
def test_repr_deep(self):
Expand Down
8 changes: 4 additions & 4 deletions pyobjc-core/PyObjCTest/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,15 +1409,15 @@ def testResult(self):

data = v.as_buffer(4)
self.assertEqual(data[0], 0)
v[0] = 0x0f0f0f0f
self.assertEqual(data[0], 0x0f)
v[0] = 0x0F0F0F0F
self.assertEqual(data[0], 0x0F)
data[0] = 0

if sys.byteorder == "little":
self.assertEqual(v[0], 0x0f0f0f00)
self.assertEqual(v[0], 0x0F0F0F00)

else:
self.assertEqual(v[0], 0x000f0f0f)
self.assertEqual(v[0], 0x000F0F0F)

def testInput(self):
o = OC_MetaDataTest.alloc().init()
Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/PyObjCTest/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def testCharOut(self):
self.assertEqual(self.obj.passOutChar_(None), 127)

def testCharInOut(self):
self.assertEqual(self.obj.passInOutChar_(b"\x10"), 0x3a)
self.assertEqual(self.obj.passInOutChar_(b"\x10"), 0x3A)

def testUCharIn(self):
self.assertEqual(self.obj.passInUChar_(10), 19)
Expand Down
8 changes: 4 additions & 4 deletions pyobjc-core/PyObjCTest/test_pointer_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def test_opaque_capsule(self):

@onlyIf(ctypes is not None, "requires ctypes")
def test_opaque_ctypes(self):
ptr = ctypes.c_void_p(0xabcd)
ptr = ctypes.c_void_p(0xABCD)

value = OpaqueType(c_void_p=ptr)
self.assertIsInstance(value, OpaqueType)
self.assertEqual(value.__pointer__, 0xabcd)
self.assertEqual(value.__pointer__, 0xABCD)

value = OpaqueType(c_void_p=0xdefa)
value = OpaqueType(c_void_p=0xDEFA)
self.assertIsInstance(value, OpaqueType)
self.assertEqual(value.__pointer__, 0xdefa)
self.assertEqual(value.__pointer__, 0xDEFA)

def test_object_capsule(self):
NSObject = objc.lookUpClass("NSObject")
Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/PyObjCTest/test_specialtypecodes_charbyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def testReturnValueArray(self):
self.assertIsInstance(v, bytes)

self.assertEqual(v[0], 0x64)
self.assertEqual(v[1], 0xc8)
self.assertEqual(v[1], 0xC8)
self.assertEqual(v[2], 0x96)
self.assertEqual(v[3], 0x63)

Expand Down
5,889 changes: 4,958 additions & 931 deletions pyobjc-framework-AVFoundation/Lib/AVFoundation/_metadata.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyobjc-framework-AVFoundation/PyObjCTest/test_avasset.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def testConstants(self):
self.assertEqual(
AVFoundation.AVAssetReferenceRestrictionForbidLocalReferenceToLocal, 1 << 3
)
self.assertEqual(AVFoundation.AVAssetReferenceRestrictionForbidAll, 0xffff)
self.assertEqual(AVFoundation.AVAssetReferenceRestrictionForbidAll, 0xFFFF)
self.assertEqual(
AVFoundation.AVAssetReferenceRestrictionDefaultPolicy,
AVFoundation.AVAssetReferenceRestrictionForbidLocalReferenceToRemote,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def testConstants(self):
self.assertEqual(AVFoundation.AVAudioQualityLow, 0x20)
self.assertEqual(AVFoundation.AVAudioQualityMedium, 0x40)
self.assertEqual(AVFoundation.AVAudioQualityHigh, 0x60)
self.assertEqual(AVFoundation.AVAudioQualityMax, 0x7f)
self.assertEqual(AVFoundation.AVAudioQualityMax, 0x7F)

self.assertIsInstance(AVFoundation.AVSampleRateKey, str)
self.assertIsInstance(AVFoundation.AVNumberOfChannelsKey, str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def test_constants(self):
self.assertEqual(PrintCore.kPMQualityInkSaver, 0x0001)
self.assertEqual(PrintCore.kPMQualityDraft, 0x0004)
self.assertEqual(PrintCore.kPMQualityNormal, 0x0008)
self.assertEqual(PrintCore.kPMQualityPhoto, 0x000b)
self.assertEqual(PrintCore.kPMQualityBest, 0x000d)
self.assertEqual(PrintCore.kPMQualityHighest, 0x000f)
self.assertEqual(PrintCore.kPMQualityPhoto, 0x000B)
self.assertEqual(PrintCore.kPMQualityBest, 0x000D)
self.assertEqual(PrintCore.kPMQualityHighest, 0x000F)

self.assertEqual(PrintCore.kPMPaperTypeUnknown, 0x0000)
self.assertEqual(PrintCore.kPMPaperTypePlain, 0x0001)
Expand Down
4 changes: 2 additions & 2 deletions pyobjc-framework-CFNetwork/Lib/CFNetwork/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@


def CFSocketStreamSOCKSGetError(err):
return err.error & 0xffff
return err.error & 0xFFFF


def CFSocketStreamSOCKSGetErrorSubdomain(err):
return (err.error >> 16) & 0xffff
return (err.error >> 16) & 0xFFFF


frameworkPath = "/System/Library/Frameworks/CFNetwork.framework"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def testConstants(self):
self.assertEqual(CFNetwork.kCFStreamErrorSOCKS4RequestFailed, 91)
self.assertEqual(CFNetwork.kCFStreamErrorSOCKS4IdentdFailed, 92)
self.assertEqual(CFNetwork.kCFStreamErrorSOCKS4IdConflict, 93)
self.assertEqual(CFNetwork.kSOCKS5NoAcceptableMethod, 0xff)
self.assertEqual(CFNetwork.kSOCKS5NoAcceptableMethod, 0xFF)

# Moved to CoreFoundation in 10.14, still testing here for backward
# compat reasons.
Expand Down
152 changes: 132 additions & 20 deletions pyobjc-framework-ClassKit/Lib/ClassKit/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,144 @@
import objc, sys

if sys.maxsize > 2 ** 32:
def sel32or64(a, b): return b

def sel32or64(a, b):
return b


else:
def sel32or64(a, b): return a

misc = {
}
constants = '''$CLSContextTopicArtsAndMusic$CLSContextTopicComputerScienceAndEngineering$CLSContextTopicHealthAndFitness$CLSContextTopicLiteracyAndWriting$CLSContextTopicMath$CLSContextTopicScience$CLSContextTopicSocialScience$CLSContextTopicWorldLanguage$CLSErrorCodeDomain$CLSErrorObjectKey$CLSErrorUnderlyingErrorsKey$CLSPredicateKeyPathDateCreated$CLSPredicateKeyPathIdentifier$CLSPredicateKeyPathParent$CLSPredicateKeyPathTitle$CLSPredicateKeyPathTopic$CLSPredicateKeyPathUniversalLinkURL$'''
enums = '''$CLSBinaryValueTypeCorrectIncorrect@3$CLSBinaryValueTypePassFail@1$CLSBinaryValueTypeTrueFalse@0$CLSBinaryValueTypeYesNo@2$CLSContextTypeApp@1$CLSContextTypeAudio@14$CLSContextTypeBook@11$CLSContextTypeChallenge@7$CLSContextTypeChapter@2$CLSContextTypeCourse@16$CLSContextTypeCustom@17$CLSContextTypeDocument@13$CLSContextTypeExercise@9$CLSContextTypeGame@12$CLSContextTypeLesson@10$CLSContextTypeLevel@4$CLSContextTypeNone@0$CLSContextTypePage@5$CLSContextTypeQuiz@8$CLSContextTypeSection@3$CLSContextTypeTask@6$CLSContextTypeVideo@15$CLSErrorCodeAuthorizationDenied@4$CLSErrorCodeClassKitUnavailable@1$CLSErrorCodeDatabaseInaccessible@5$CLSErrorCodeInvalidArgument@2$CLSErrorCodeInvalidCreate@7$CLSErrorCodeInvalidModification@3$CLSErrorCodeInvalidUpdate@8$CLSErrorCodeLimits@6$CLSErrorCodeNone@0$CLSErrorCodePartialFailure@9$CLSProgressReportingCapabilityKindBinary@2$CLSProgressReportingCapabilityKindDuration@0$CLSProgressReportingCapabilityKindPercent@1$CLSProgressReportingCapabilityKindQuantity@3$CLSProgressReportingCapabilityKindScore@4$'''
def sel32or64(a, b):
return a


misc = {}
constants = """$CLSContextTopicArtsAndMusic$CLSContextTopicComputerScienceAndEngineering$CLSContextTopicHealthAndFitness$CLSContextTopicLiteracyAndWriting$CLSContextTopicMath$CLSContextTopicScience$CLSContextTopicSocialScience$CLSContextTopicWorldLanguage$CLSErrorCodeDomain$CLSErrorObjectKey$CLSErrorUnderlyingErrorsKey$CLSPredicateKeyPathDateCreated$CLSPredicateKeyPathIdentifier$CLSPredicateKeyPathParent$CLSPredicateKeyPathTitle$CLSPredicateKeyPathTopic$CLSPredicateKeyPathUniversalLinkURL$"""
enums = """$CLSBinaryValueTypeCorrectIncorrect@3$CLSBinaryValueTypePassFail@1$CLSBinaryValueTypeTrueFalse@0$CLSBinaryValueTypeYesNo@2$CLSContextTypeApp@1$CLSContextTypeAudio@14$CLSContextTypeBook@11$CLSContextTypeChallenge@7$CLSContextTypeChapter@2$CLSContextTypeCourse@16$CLSContextTypeCustom@17$CLSContextTypeDocument@13$CLSContextTypeExercise@9$CLSContextTypeGame@12$CLSContextTypeLesson@10$CLSContextTypeLevel@4$CLSContextTypeNone@0$CLSContextTypePage@5$CLSContextTypeQuiz@8$CLSContextTypeSection@3$CLSContextTypeTask@6$CLSContextTypeVideo@15$CLSErrorCodeAuthorizationDenied@4$CLSErrorCodeClassKitUnavailable@1$CLSErrorCodeDatabaseInaccessible@5$CLSErrorCodeInvalidArgument@2$CLSErrorCodeInvalidCreate@7$CLSErrorCodeInvalidModification@3$CLSErrorCodeInvalidUpdate@8$CLSErrorCodeLimits@6$CLSErrorCodeNone@0$CLSErrorCodePartialFailure@9$CLSProgressReportingCapabilityKindBinary@2$CLSProgressReportingCapabilityKindDuration@0$CLSProgressReportingCapabilityKindPercent@1$CLSProgressReportingCapabilityKindQuantity@3$CLSProgressReportingCapabilityKindScore@4$"""
misc.update({})
r = objc.registerMetaDataForSelector
objc._updatingMetadata(True)
try:
r(b'CLSActivity', b'contextsMatchingPredicate:completion:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
r(b'CLSActivity', b'isStarted', {'retval': {'type': b'Z'}})
r(b'CLSBinaryItem', b'setValue:', {'arguments': {2: {'type': b'Z'}}})
r(b'CLSBinaryItem', b'value', {'retval': {'type': b'Z'}})
r(b'CLSContext', b'descendantMatchingIdentifierPath:completion:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
r(b'CLSContext', b'isActive', {'retval': {'type': b'Z'}})
r(b'CLSContext', b'isAssignable', {'retval': {'type': b'Z'}})
r(b'CLSContext', b'setAssignable:', {'arguments': {2: {'type': b'Z'}}})
r(b'CLSDataStore', b'contextsMatchingIdentifierPath:completion:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
r(b'CLSDataStore', b'fetchActivityForURL:completion:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
r(b'CLSDataStore', b'saveWithCompletion:', {'arguments': {2: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}}}}}})
r(b'NSObject', b'createContextForIdentifier:parentContext:parentIdentifierPath:', {'required': True, 'retval': {'type': b'@'}, 'arguments': {2: {'type': b'@'}, 3: {'type': b'@'}, 4: {'type': b'@'}}})
r(b'NSObject', b'updateDescendantsOfContext:completion:', {'required': True, 'retval': {'type': b'v'}, 'arguments': {2: {'type': b'@'}, 3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}}}, 'type': b'@?'}}})
r(b'NSUserActivity', b'isClassKitDeepLink', {'retval': {'type': b'Z'}})
r(
b"CLSActivity",
b"contextsMatchingPredicate:completion:",
{
"arguments": {
3: {
"callable": {
"retval": {"type": b"v"},
"arguments": {
0: {"type": b"^v"},
1: {"type": b"@"},
2: {"type": b"@"},
},
}
}
}
},
)
r(b"CLSActivity", b"isStarted", {"retval": {"type": b"Z"}})
r(b"CLSBinaryItem", b"setValue:", {"arguments": {2: {"type": b"Z"}}})
r(b"CLSBinaryItem", b"value", {"retval": {"type": b"Z"}})
r(
b"CLSContext",
b"descendantMatchingIdentifierPath:completion:",
{
"arguments": {
3: {
"callable": {
"retval": {"type": b"v"},
"arguments": {
0: {"type": b"^v"},
1: {"type": b"@"},
2: {"type": b"@"},
},
}
}
}
},
)
r(b"CLSContext", b"isActive", {"retval": {"type": b"Z"}})
r(b"CLSContext", b"isAssignable", {"retval": {"type": b"Z"}})
r(b"CLSContext", b"setAssignable:", {"arguments": {2: {"type": b"Z"}}})
r(
b"CLSDataStore",
b"contextsMatchingIdentifierPath:completion:",
{
"arguments": {
3: {
"callable": {
"retval": {"type": b"v"},
"arguments": {
0: {"type": b"^v"},
1: {"type": b"@"},
2: {"type": b"@"},
},
}
}
}
},
)
r(
b"CLSDataStore",
b"fetchActivityForURL:completion:",
{
"arguments": {
3: {
"callable": {
"retval": {"type": b"v"},
"arguments": {
0: {"type": b"^v"},
1: {"type": b"@"},
2: {"type": b"@"},
},
}
}
}
},
)
r(
b"CLSDataStore",
b"saveWithCompletion:",
{
"arguments": {
2: {
"callable": {
"retval": {"type": b"v"},
"arguments": {0: {"type": b"^v"}, 1: {"type": b"@"}},
}
}
}
},
)
r(
b"NSObject",
b"createContextForIdentifier:parentContext:parentIdentifierPath:",
{
"required": True,
"retval": {"type": b"@"},
"arguments": {2: {"type": b"@"}, 3: {"type": b"@"}, 4: {"type": b"@"}},
},
)
r(
b"NSObject",
b"updateDescendantsOfContext:completion:",
{
"required": True,
"retval": {"type": b"v"},
"arguments": {
2: {"type": b"@"},
3: {
"callable": {
"retval": {"type": b"v"},
"arguments": {0: {"type": b"^v"}, 1: {"type": b"@"}},
},
"type": b"@?",
},
},
},
)
r(b"NSUserActivity", b"isClassKitDeepLink", {"retval": {"type": b"Z"}})
finally:
objc._updatingMetadata(False)
expressions = {}
Expand Down
Loading

0 comments on commit 43efdf6

Please sign in to comment.