# -*- coding: utf-8 -*- # <http://GitHub.com/phillip-nguyen/cocoa-python/blob/master/examples/list_ivars.py> # List the instance variables of an Objective-C class. from pycocoa import get_class, get_ivars, leaked2, sortuples __version__ = '18.11.02' if __name__ == '__main__': import sys if len(sys.argv) < 2: print('USAGE: python list_ivars.py <Obj-C Class> [prefix] ...') exit(1) clstr, prefs = sys.argv[1], sys.argv[2:] cls, n = get_class(clstr), 0 for name, encoding, ctype, _ in sortuples(get_ivars(cls, *prefs)): n += 1 t = getattr(ctype, '__name__', ctype) print('%s %s %s' % (name, encoding, t)) print('%s %s instance variables total %s' % (n, clstr, leaked2()))
from pycocoa import get_class, get_properties, get_protocol, leaked2, sortuples __version__ = '19.09.27' if __name__ == '__main__': import sys if len(sys.argv) < 2: print( 'USAGE: python list_properties.py <Obj-C Class> | <Obj-C Protocol> [prefix] ...' ) cls_protostr, prefs = sys.argv[1], sys.argv[2:] n, cls_proto = 0, get_class(cls_protostr) or get_protocol(cls_protostr) # avoid sorting the prop object in prop[3] for name, attrs, setter in sortuples( (prop[:3] for prop in get_properties(cls_proto, *prefs))): n += 1 print(' '.join((name, attrs, setter))) print('%s %s properties total %s' % (n, cls_protostr, leaked2())) # MIT License <https://OpenSource.org/licenses/MIT> # # Copyright (C) 2017-2021 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation
# List the protocols of an Objective-C class. from pycocoa import get_class, get_protocols, leaked2, sortuples __version__ = '19.09.272' if __name__ == '__main__': import sys if len(sys.argv) < 2: print('USAGE: python list_protocols.py <Obj-C Class> [prefix] ...') clstr, prefs = sys.argv[1], sys.argv[2:] n, cls = 0, get_class(clstr) for name, _ in sortuples(get_protocols(cls, *prefs)): n += 1 print(name) print('%s %s protocols total %s' % (n, clstr, leaked2())) # MIT License <https://OpenSource.org/licenses/MIT> # # Copyright (C) 2017-2021 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the
# Print the inheritance chain for a given class. from pycocoa import get_class, get_classname, get_inheritance __version__ = '19.09.27' if __name__ == '__main__': import sys if len(sys.argv) < 2: print('USAGE: python inheritance.py <Obj-C Class>') exit(1) cls = get_class(sys.argv[1]) for cls in get_inheritance(cls): print(get_classname(cls)) # MIT License <https://OpenSource.org/licenses/MIT> # # Copyright (C) 2017-2021 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included