Пример #1
0
    def test_byref_out(self):
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)

        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")

        objc._updatingMetadata(True)
        objc.registerMetaDataForSelector(b"OC_TestDecimal", b"getDecimal:",
            dict(
                arguments={
                    2+0:  dict(type_modifier=objc._C_OUT, type=b'^{_NSDecimal=b8b4b1b1b18[8S]}', null_accepted=False),
                    #2+0:  dict(type=b'o^{_NSDecimal=b8b4b1b1b18[8S]}', null_accepted=False),
                }
            )
        )
        objc._updatingMetadata(False)
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)
        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")
def parseBridgeSupport(xmldata, globals, frameworkName, dylib_path=None, inlineTab=None):

    if dylib_path:
        lib = ctypes.cdll.LoadLibrary(dylib_path)
        _libraries.append(lib)

    objc._updatingMetadata(True)
    try:
        prs = _BridgeSupportParser(xmldata, frameworkName)

        globals.update(prs.values)
        for entry in prs.cftypes:
            tp = objc.registerCFSignature(*entry)

            globals[entry[0]] = tp

        for name, typestr in prs.opaque:
            globals[name] = objc.createOpaquePointerType(name, typestr)

        for name, typestr, alias in prs.structs:
            if alias is not None:
                globals[name] = alias
                objc.createStructAlias(name, typestr, alias)
            else:
                globals[name] = value = objc.createStructType(name, typestr, None)


        for name, typestr, magic in prs.constants:
            try:
                value = objc._loadConstant(name, _as_string(typestr), magic)
            except AttributeError:
                continue

            globals[name] = value

        for class_name, sel_name, is_class in prs.meta:
            objc.registerMetaDataForSelector(class_name, sel_name, prs.meta[(class_name, sel_name, is_class)])

        if prs.functions:
            objc.loadBundleFunctions(None, globals, prs.functions)

            if inlineTab is not None:
                objc.loadFunctionList(inlineTab, globals, prs.functions)

        for name, orig in prs.func_aliases:
            try:
                globals[name] = globals[orig]
            except KeyError:
                pass

    finally:
        objc._updatingMetadata(False)
Пример #3
0
    def sel32or64(a, b): return b
else:
    def sel32or64(a, b): return a
if sys.byteorder == 'little':
    def littleOrBig(a, b): return a
else:
    def littleOrBig(a, b): return b

misc = {
}
constants = '''$CKAccountChangedNotification$CKErrorDomain$CKErrorRetryAfterKey$CKOwnerDefaultName$CKPartialErrorsByItemIDKey$CKQueryOperationMaximumResults@Q$CKRecordChangedErrorAncestorRecordKey$CKRecordChangedErrorClientRecordKey$CKRecordChangedErrorServerRecordKey$CKRecordTypeUserRecord$CKRecordZoneDefaultName$'''
enums = '''$CKAccountStatusAvailable@1$CKAccountStatusCouldNotDetermine@0$CKAccountStatusNoAccount@3$CKAccountStatusRestricted@2$CKApplicationPermissionStatusCouldNotComplete@1$CKApplicationPermissionStatusDenied@2$CKApplicationPermissionStatusGranted@3$CKApplicationPermissionStatusInitialState@0$CKApplicationPermissionUserDiscoverability@1$CKErrorAssetFileModified@17$CKErrorAssetFileNotFound@16$CKErrorBadContainer@5$CKErrorBadDatabase@24$CKErrorBatchRequestFailed@22$CKErrorChangeTokenExpired@21$CKErrorConstraintViolation@19$CKErrorIncompatibleVersion@18$CKErrorInternalError@1$CKErrorInvalidArguments@12$CKErrorLimitExceeded@27$CKErrorMissingEntitlement@8$CKErrorNetworkFailure@4$CKErrorNetworkUnavailable@3$CKErrorNotAuthenticated@9$CKErrorOperationCancelled@20$CKErrorPartialFailure@2$CKErrorPermissionFailure@10$CKErrorQuotaExceeded@25$CKErrorRequestRateLimited@7$CKErrorResultsTruncated@13$CKErrorServerRecordChanged@14$CKErrorServerRejectedRequest@15$CKErrorServiceUnavailable@6$CKErrorUnknownItem@11$CKErrorUserDeletedZone@28$CKErrorZoneBusy@23$CKErrorZoneNotFound@26$CKNotificationTypeQuery@1$CKNotificationTypeReadNotification@3$CKNotificationTypeRecordZone@2$CKQueryNotificationReasonRecordCreated@1$CKQueryNotificationReasonRecordDeleted@3$CKQueryNotificationReasonRecordUpdated@2$CKRecordSaveAllKeys@2$CKRecordSaveChangedKeys@1$CKRecordSaveIfServerRecordUnchanged@0$CKRecordZoneCapabilityAtomic@2$CKRecordZoneCapabilityFetchChanges@1$CKReferenceActionDeleteSelf@1$CKReferenceActionNone@0$CKSubscriptionOptionsFiresOnRecordCreation@1$CKSubscriptionOptionsFiresOnRecordDeletion@4$CKSubscriptionOptionsFiresOnRecordUpdate@2$CKSubscriptionOptionsFiresOnce@8$CKSubscriptionTypeQuery@1$CKSubscriptionTypeRecordZone@2$'''
misc.update({})
aliases = {'CK_UNIT_TESTS_EXTERN': 'CK_EXTERN'}
r = objc.registerMetaDataForSelector
objc._updatingMetadata(True)
try:
    r(b'CKContainer', b'accountStatusWithCompletionHandler:', {'arguments': {2: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'q'}, 2: {'type': b'@'}}}}}})
    r(b'CKContainer', b'discoverAllContactUserInfosWithCompletionHandler:', {'arguments': {2: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKContainer', b'discoverUserInfoWithEmailAddress:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKContainer', b'discoverUserInfoWithUserRecordID:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKContainer', b'fetchUserRecordIDWithCompletionHandler:', {'arguments': {2: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKContainer', b'requestApplicationPermission:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'q'}, 2: {'type': b'@'}}}}}})
    r(b'CKContainer', b'statusForApplicationPermission:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'q'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'deleteRecordWithID:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'deleteRecordZoneWithID:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'deleteSubscriptionWithID:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'fetchAllRecordZonesWithCompletionHandler:', {'arguments': {2: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'fetchAllSubscriptionsWithCompletionHandler:', {'arguments': {2: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'fetchRecordWithID:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
    r(b'CKDatabase', b'fetchRecordZoneWithID:completionHandler:', {'arguments': {3: {'callable': {'retval': {'type': b'v'}, 'arguments': {0: {'type': b'^v'}, 1: {'type': b'@'}, 2: {'type': b'@'}}}}}})
Пример #4
0
def parseBridgeSupport(xmldata, globals, frameworkName, dylib_path=None, inlineTab=None):

    if dylib_path:
        lib = ctypes.cdll.LoadLibrary(dylib_path)
        _libraries.append(lib)

    objc._updatingMetadata(True)
    try:
        prs = _BridgeSupportParser(xmldata, frameworkName)

        globals.update(prs.values)
        for entry in prs.cftypes:
            tp = objc.registerCFSignature(*entry)

            globals[entry[0]] = tp

        for name, typestr in prs.opaque:
            globals[name] = objc.createOpaquePointerType(name, typestr)

        for name, typestr, alias in prs.structs:
            if alias is not None:
                globals[name] = alias
                objc.createStructAlias(name, typestr, alias)
            else:
                globals[name] = value = objc.createStructType(name, typestr, None)


        for name, typestr, magic in prs.constants:
            try:
                value = objc._loadConstant(name, typestr, magic)
            except AttributeError:
                continue

            globals[name] = value

        for class_name, sel_name, is_class in prs.meta:
            objc.registerMetaDataForSelector(class_name, sel_name, prs.meta[(class_name, sel_name, is_class)])

        for name, method_list in prs.informal_protocols:
            proto = objc.informal_protocol(name, method_list)

            # XXX: protocols submodule should be deprecated
            if "protocols" not in globals:
                mod_name = "%s.protocols"%(frameworkName,)
                m = globals["protocols"] = type(objc)(mod_name)
                sys.modules[mod_name] = m

            else:
                m = globals["protocols"]

            setattr(m, name, proto)

        if prs.functions:
            objc.loadBundleFunctions(None, globals, prs.functions)

            if inlineTab is not None:
                objc.loadFunctionList(inlineTab, globals, prs.functions)

        for name, orig in prs.func_aliases:
            try:
                globals[name] = globals[orig]
            except KeyError:
                pass

    finally:
        objc._updatingMetadata(False)
Пример #5
0
else:

    def littleOrBig(a, b):
        return b


misc = {}
constants = '''$PSEnclosureDownloadStateDidChangeNotification$PSErrorDomain$PSFeedAddedEntriesKey$PSFeedDidChangeEntryFlagsKey$PSFeedEntriesChangedNotification$PSFeedRefreshingNotification$PSFeedRemovedEntriesKey$PSFeedUpdatedEntriesKey$'''
enums = '''$PSAtomFormat@2$PSEnclosureDownloadDidFail@4$PSEnclosureDownloadDidFinish@3$PSEnclosureDownloadIsActive@2$PSEnclosureDownloadIsIdle@0$PSEnclosureDownloadIsQueued@1$PSEnclosureDownloadWasDeleted@5$PSFeedSettingsUnlimitedSize@0$PSInternalError@1$PSLinkToAlternate@7$PSLinkToAtom@2$PSLinkToAtomService@3$PSLinkToFOAF@4$PSLinkToOther@0$PSLinkToRSD@5$PSLinkToRSS@1$PSLinkToSelf@6$PSNotAFeedError@2$PSRSSFormat@1$PSUnknownFormat@0$'''
misc.update({
    'PSFeedSettingsIntervalNever': -1.0,
    'PSFeedSettingsAllTypes': None,
    'PSFeedSettingsIntervalDefault': 0.0
})
r = objc.registerMetaDataForSelector
objc._updatingMetadata(True)
try:
    r(b'PSClient', b'addFeed:', {'retval': {'type': 'Z'}})
    r(b'PSClient', b'isPrivate', {'retval': {'type': 'Z'}})
    r(b'PSClient', b'removeFeed:', {'retval': {'type': 'Z'}})
    r(b'PSClient', b'setPrivate:', {'arguments': {2: {'type': 'Z'}}})
    r(b'PSEnclosure', b'download:', {
        'retval': {
            'type': 'Z'
        },
        'arguments': {
            2: {
                'type_modifier': b'o'
            }
        }
    })