# -*- 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()))
# -*- coding: utf-8 -*- # Originally <http://GitHub.com/phillip-nguyen/cocoa-python/blob/master/examples/list_classes.py> # List all loaded Objective-C classes. from pycocoa import get_classes, leaked2, sortuples __version__ = '18.11.02' if __name__ == '__main__': import sys if len(sys.argv) < 2: print('USAGE: python list_classes.py [prefix] ...') n, prefs = 0, sys.argv[1:] for name, _ in sortuples(get_classes(*prefs)): n += 1 print(name) print('%s %s classes total %s' % (n, ', '.join(prefs), leaked2()))
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 # Software is furnished to do so, subject to the following conditions:
# Originally <http://GitHub.com/phillip-nguyen/cocoa-python/blob/master/examples/list_methods.py> # List all methods of an Objective-C class. from pycocoa import get_class, get_methods, leaked2, sortuples __version__ = '18.11.06' if __name__ == '__main__': import sys if len(sys.argv) < 2: print('USAGE: python list_methods.py <Obj-C Class> [prefix] ...') exit(1) clstr, prefs = sys.argv[1], sys.argv[2:] cls, n = get_class(clstr), 0 if cls is None: # and clstr.endswith('Delegate') import pycocoa # PYCHOK expected cls = pycocoa.__dict__.get(clstr, cls) # inlieu of __import__ ... for name, encoding, rargtypes, _ in sortuples(get_methods(cls, *prefs)): n += 1 rargtypes = [getattr(rarg, '__name__', rarg) for rarg in rargtypes] print('%s %s (%s)' % (name, encoding, ', '.join(map(str, rargtypes)))) print('%s %s methods total %s' % (n, clstr, leaked2()))
__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 # 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: