1from objc._objc import *
2from objc import _objc
3import struct
4
5__all__ = [ 'registerListType', 'registerMappingType' ]
6
7BRIDGED_STRUCTURES = {}
8BRIDGED_STRUCTURES2 = {}
9BRIDGED_TYPES = []
10
11def registerListType(type):
12    """
13    Register 'type' as a list-like type that will be proxied
14    as an NSMutableArray subclass.
15    """
16    OC_PythonArray = lookUpClass('OC_PythonArray')
17    OC_PythonArray.depythonifyTable().append(type)
18
19def registerMappingType(type):
20    """
21    Register 'type' as a list-like type that will be proxied
22    as an NSMutableArray subclass.
23    """
24    OC_PythonDictionary = lookUpClass('OC_PythonDictionary')
25    OC_PythonDictionary.depythonifyTable().append(type)
26
27
28def _bridgePythonTypes():
29    # Python to Obj-C
30    OC_PythonObject = lookUpClass('OC_PythonObject')
31    try:
32        if BRIDGED_TYPES:
33            OC_PythonObject.depythonifyTable().extend(BRIDGED_TYPES)
34        if BRIDGED_STRUCTURES:
35            OC_PythonObject.pythonifyStructTable().update(BRIDGED_STRUCTURES)
36    except AttributeError:
37        pass
38
39_bridgePythonTypes()
40