Loading tools/codegen/src/com/android/codegen/Generators.kt +8 −6 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ private fun ClassPrinter.generateBuilderBuild() { fun ClassPrinter.generateParcelable() { val booleanFields = fields.filter { it.Type == "boolean" } val objectFields = fields.filter { it.Type !in PRIMITIVE_TYPES } val nullableFields = objectFields.filter { it.mayBeNull } val nullableFields = objectFields.filter { it.mayBeNull && it.Type !in PRIMITIVE_ARRAY_TYPES } val nonBooleanFields = fields - booleanFields Loading Loading @@ -457,7 +457,7 @@ fun ClassPrinter.generateParcelable() { hasAnnotation("@$DataClassEnum") -> +"dest.writeInt($internalGetter == null ? -1 : $internalGetter.ordinal());" else -> { if (mayBeNull) !"if ($internalGetter != null) " if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) !"if ($internalGetter != null) " var args = internalGetter if (ParcelMethodsSuffix.startsWith("Parcelable") || ParcelMethodsSuffix.startsWith("TypedObject") Loading Loading @@ -529,7 +529,7 @@ fun ClassPrinter.generateParcelable() { if (passContainer) { methodArgs.add(_name) !"$Type $_name = " if (mayBeNull) { if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) { +"null;" !"if ((flg & $fieldBit) != 0) {" pushIndent() Loading @@ -539,7 +539,9 @@ fun ClassPrinter.generateParcelable() { +"$containerInitExpr;" } else { !"$Type $_name = " if (mayBeNull) !"(flg & $fieldBit) == 0 ? null : " if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) { !"(flg & $fieldBit) == 0 ? null : " } if (ParcelMethodsSuffix == "StrongInterface") { !"$FieldClass.Stub.asInterface(" } else if (Type !in PRIMITIVE_TYPES + "String" + "Bundle" && Loading Loading @@ -578,7 +580,7 @@ fun ClassPrinter.generateParcelable() { +";" // Cleanup if passContainer if (passContainer && mayBeNull) { if (passContainer && mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) { popIndent() rmEmptyLine() +"\n}" Loading tools/codegen/src/com/android/codegen/Main.kt +2 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ const val GENERATED_END = "// End of generated code" const val INDENT_SINGLE = " " val PRIMITIVE_TYPES = listOf("byte", "short", "int", "long", "char", "float", "double", "boolean") val PRIMITIVE_ARRAY_TYPES = listOf("byte[]", "short[]", "int[]", "long[]", "char[]", "float[]", "double[]", "boolean[]") val BOXED_PRIMITIVE_TYPES = PRIMITIVE_TYPES.map { it.capitalize() } - "Int" + "Integer" - "Char" + "Character" val BUILTIN_SPECIAL_PARCELLINGS = listOf("Pattern") Loading Loading
tools/codegen/src/com/android/codegen/Generators.kt +8 −6 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ private fun ClassPrinter.generateBuilderBuild() { fun ClassPrinter.generateParcelable() { val booleanFields = fields.filter { it.Type == "boolean" } val objectFields = fields.filter { it.Type !in PRIMITIVE_TYPES } val nullableFields = objectFields.filter { it.mayBeNull } val nullableFields = objectFields.filter { it.mayBeNull && it.Type !in PRIMITIVE_ARRAY_TYPES } val nonBooleanFields = fields - booleanFields Loading Loading @@ -457,7 +457,7 @@ fun ClassPrinter.generateParcelable() { hasAnnotation("@$DataClassEnum") -> +"dest.writeInt($internalGetter == null ? -1 : $internalGetter.ordinal());" else -> { if (mayBeNull) !"if ($internalGetter != null) " if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) !"if ($internalGetter != null) " var args = internalGetter if (ParcelMethodsSuffix.startsWith("Parcelable") || ParcelMethodsSuffix.startsWith("TypedObject") Loading Loading @@ -529,7 +529,7 @@ fun ClassPrinter.generateParcelable() { if (passContainer) { methodArgs.add(_name) !"$Type $_name = " if (mayBeNull) { if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) { +"null;" !"if ((flg & $fieldBit) != 0) {" pushIndent() Loading @@ -539,7 +539,9 @@ fun ClassPrinter.generateParcelable() { +"$containerInitExpr;" } else { !"$Type $_name = " if (mayBeNull) !"(flg & $fieldBit) == 0 ? null : " if (mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) { !"(flg & $fieldBit) == 0 ? null : " } if (ParcelMethodsSuffix == "StrongInterface") { !"$FieldClass.Stub.asInterface(" } else if (Type !in PRIMITIVE_TYPES + "String" + "Bundle" && Loading Loading @@ -578,7 +580,7 @@ fun ClassPrinter.generateParcelable() { +";" // Cleanup if passContainer if (passContainer && mayBeNull) { if (passContainer && mayBeNull && Type !in PRIMITIVE_ARRAY_TYPES) { popIndent() rmEmptyLine() +"\n}" Loading
tools/codegen/src/com/android/codegen/Main.kt +2 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ const val GENERATED_END = "// End of generated code" const val INDENT_SINGLE = " " val PRIMITIVE_TYPES = listOf("byte", "short", "int", "long", "char", "float", "double", "boolean") val PRIMITIVE_ARRAY_TYPES = listOf("byte[]", "short[]", "int[]", "long[]", "char[]", "float[]", "double[]", "boolean[]") val BOXED_PRIMITIVE_TYPES = PRIMITIVE_TYPES.map { it.capitalize() } - "Int" + "Integer" - "Char" + "Character" val BUILTIN_SPECIAL_PARCELLINGS = listOf("Pattern") Loading