1from objc._objc import _setClassSetUpHook, selector, ivar 2 3__all__ = () 4 5FunctionType = type(lambda:1) 6 7def class_setup_hook(name, 8 super_class, class_dict, instance_vars, instance_methods, 9 class_methods): 10 """ 11 This function is called during the construction of a Python subclass 12 of an Objective-C class. 13 """ 14 class_keys = class_dict.keys() 15 16 for k in class_keys: 17 v = class_dict[k] 18 19 if isinstance(v, ivar): 20 instance_vars.append(v) 21 22 elif isinstance(v, selector): 23 if v.isClassMethod: 24 if v not in class_methods: 25 class_methods.append(v) 26 else: 27 if v not in instance_methods: 28 instance_methods.append(v) 29 30 elif isinstance(v, FunctionType): 31 if k.startswith('__') and k.endswith('__'): 32 # Skip special methods 33 continue 34 35 36 37 38 39 40 41 42 43 44#_setClassSetUpHook(class_setup_hook) 45