def order_and_assign_object_ids(): """ Order all classes and assign object ids to all classes. This is done to promote a reasonable order of the objects, putting messages first followed by non-messages. No assumptions should be made about the order, nor about contiguous numbering. However, the numbers should all be reasonably small allowing arrays indexed by these enum values to be defined. """ # Generate separate message and non-message ordered lists for cls in of_g.unified: if loxi_utils.class_is_message(cls): of_g.ordered_messages.append(cls) elif loxi_utils.class_is_list(cls): of_g.ordered_list_objects.append(cls) else: of_g.ordered_non_messages.append(cls) of_g.ordered_messages.sort() of_g.ordered_pseudo_objects.sort() of_g.ordered_non_messages.sort() of_g.ordered_list_objects.sort() of_g.standard_class_order.extend(of_g.ordered_messages) of_g.standard_class_order.extend(of_g.ordered_non_messages) of_g.standard_class_order.extend(of_g.ordered_list_objects) # This includes pseudo classes for which most code is not generated of_g.all_class_order.extend(of_g.ordered_messages) of_g.all_class_order.extend(of_g.ordered_non_messages) of_g.all_class_order.extend(of_g.ordered_list_objects) of_g.all_class_order.extend(of_g.ordered_pseudo_objects) # Assign object IDs for cls in of_g.ordered_messages: of_g.unified[cls]["object_id"] = of_g.object_id of_g.object_id += 1 for cls in of_g.ordered_non_messages: of_g.unified[cls]["object_id"] = of_g.object_id of_g.object_id += 1 for cls in of_g.ordered_list_objects: of_g.unified[cls]["object_id"] = of_g.object_id of_g.object_id += 1 for cls in of_g.ordered_pseudo_objects: of_g.unified[cls] = {} of_g.unified[cls]["object_id"] = of_g.object_id of_g.object_id += 1