def generate_class(self, clazz): """ return wether or not to generate implementation class clazz. Now true for everything except OFTableModVer10. @param clazz JavaOFClass instance """ if clazz.interface.name.startswith("OFMatchV"): return True if clazz.interface.name.startswith("OFStatV"): return True elif clazz.name == "OFTableModVer10": # tablemod ver 10 is a hack and has no oftype defined return False if loxi_utils.class_is_message(clazz.interface.c_name): return True if loxi_utils.class_is_oxm(clazz.interface.c_name): return True if loxi_utils.class_is_action(clazz.interface.c_name): return True if loxi_utils.class_is_instruction(clazz.interface.c_name): return True if loxi_utils.class_is_oxs(clazz.interface.c_name): return True else: return True
def class_info(self): """ return tuple of (package_prefix, parent_class) for the current JavaOFInterface""" # FIXME: This code could be cleaned up further. Maybe some of the exceptions # here could be folded into ir, or the type arithmetic specified in a more general # fashion def calc_package(i): if i.is_subclassof("of_error_msg"): return "errormsg" elif i.is_instanceof("of_action"): return "action" elif i.is_instanceof("of_action_id"): return "actionid" elif i.is_instanceof("of_instruction"): return "instruction" elif i.is_instanceof("of_instruction_id"): return "instructionid" elif i.is_instanceof("of_oxm"): return "oxm" elif i.is_instanceof("of_oxs"): return "oxs" elif i.is_instanceof("of_meter_band"): return "meterband" elif i.is_instanceof("of_queue_prop"): return "queueprop" elif i.is_instanceof("of_bsn_tlv"): return "bsntlv" else: return "" def calc_super_name(i): if re.match('of_match_.*', i.name): return "Match" elif re.match('of_stat_.*', i.name): return "Stat" else: ir_super_class = self.ir_class.superclass return java_class_name(ir_super_class.name) if ir_super_class else "" package = calc_package(self.ir_class) super_name = calc_super_name(self.ir_class) if self.name == "OFStatsRequest": # stats_requests are special because of their type annotation return (package, "OFMessage", "T extends OFStatsReply") elif self.ir_class.is_subclassof('of_stats_request'): # stats_request subclasses are special because of their type annotation reply_name = re.sub(r'Request$', 'Reply', self.name) super_type_annotation = "T" if self.ir_class.virtual else reply_name type_annotation = "T extends {}".format(reply_name) if self.ir_class.virtual \ else "" return (package, "{}<{}>".format(super_name, super_type_annotation), type_annotation) elif self.name == "OFOxm": return (package, None, "T extends OFValueType<T>") elif self.name == "OFOxs": return (package, None, "T extends OFValueType<T>") elif loxi_utils.class_is_oxm(self.c_name): # look up type from member value for OFValueType type annotation if self.member_by_name("value") is not None: return (package, "OFOxm<%s>" % self.member_by_name("value").java_type.public_type, None) else: return (package, "OFOxm", None) elif loxi_utils.class_is_oxs(self.c_name): # look up type from member value for OFValueType type annotation if self.member_by_name("value") is not None: return (package, "OFOxs<%s>" % self.member_by_name("value").java_type.public_type, None) else: return (package, "OFOxs", None) else: return (package, super_name, None)