diff options
Diffstat (limited to 'libvehiclenetwork/tool/vehiclehal_code_gen.py')
-rwxr-xr-x | libvehiclenetwork/tool/vehiclehal_code_gen.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libvehiclenetwork/tool/vehiclehal_code_gen.py b/libvehiclenetwork/tool/vehiclehal_code_gen.py index dfabd7dccd..e208e8c69b 100755 --- a/libvehiclenetwork/tool/vehiclehal_code_gen.py +++ b/libvehiclenetwork/tool/vehiclehal_code_gen.py @@ -37,8 +37,9 @@ JAVA_HEADER = \ * limitations under the License. */ -//Autogenerated from vehicle.h using libvehiclenetwork/tool/vehicle_code_gen.py. -//Do not modify manually. +// Autogenerated from vehicle.h using +// libvehiclenetwork/tool/vehiclehal_code_gen.py. +// Do not modify manually. package com.android.car.vehiclenetwork; @@ -50,7 +51,7 @@ JAVA_TRAIL = \ } """ -RE_PROPERTY_PATTERN = r'/\*\*(.*?)\*/\n\#define\s+VEHICLE_PROPERTY_(\S+)\s+(\(0x\S+\))' +RE_PROPERTY_PATTERN = r'/\*\*((.(?!\/\/===))*?)\*/\n\#define\s+VEHICLE_PROPERTY_(\S+)\s+(\(0x\S+\))' RE_ENUM_PATTERN = r'enum\s+(\S+)\s+\{\S*(.*?)\}' RE_ENUM_ENTRY_PATTERN = r'(\S+)\s*=\s*(.*?)[,\n]' RE_AUDIO_EXT_ROUTING_PATTERN = r'\n\#define\s+VEHICLE_PROPERTY_AUDIO_EXT_ROUTING_SOURCE_(\S+)\s+\"(\S+)\"' @@ -64,6 +65,7 @@ class PropertyInfo(object): self.access = "" self.unit = "" self.startEnd = 0 # _START/END property + self.zoneType = "" def __str__(self): r = ["value:" + self.value] @@ -163,6 +165,18 @@ switch (property) {""" } } """ + #now implement getVehicleZoneType + print \ +"""public static int getVehicleZoneType(int property) { +switch (property) {""" + for p in props: + if p.zoneType != "": + print "case " + p.name + ": return VehicleZoneType." + p.zoneType + " ;" + print \ +"""default: return VehicleZoneType.VEHICLE_ZONE_TYPE_NONE; +} +} +""" def printEnum(e): print "public static class " + toJavaStyleName(e.name) + " {" @@ -208,8 +222,8 @@ def main(argv): property_re = re.compile(RE_PROPERTY_PATTERN, re.MULTILINE | re.DOTALL) for match in property_re.finditer(text): words = match.group(1).split() - name = "VEHICLE_PROPERTY_" + match.group(2) - value = match.group(3) + name = "VEHICLE_PROPERTY_" + match.group(3) + value = match.group(4) if (value[0] == "(" and value[-1] == ")"): value = value[1:-1] prop = PropertyInfo(value, name) @@ -227,6 +241,9 @@ def main(argv): elif words[i] == "@unit": i += 1 prop.unit = words[i] + elif words[i] == "@zone_type": + i += 1 + prop.zoneType = words[i] elif words[i] == "@range_start" or words[i] == "@range_end": prop.startEnd = 1 i += 1 @@ -272,4 +289,3 @@ def main(argv): if __name__ == '__main__': main(sys.argv) - |