forked from ReVanced/revanced-patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remaining mutable
EncodedValue
classes
- Loading branch information
Showing
24 changed files
with
469 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableAnnotationElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/MutableEncodedValue.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...lin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableAnnotationEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import app.revanced.patcher.proxy.mutableTypes.MutableAnnotationElement.Companion.toMutable | ||
import org.jf.dexlib2.base.value.BaseAnnotationEncodedValue | ||
import org.jf.dexlib2.iface.AnnotationElement | ||
import org.jf.dexlib2.iface.value.AnnotationEncodedValue | ||
|
||
class MutableAnnotationEncodedValue(annotationEncodedValue: AnnotationEncodedValue) : BaseAnnotationEncodedValue(), | ||
MutableEncodedValue { | ||
private var type = annotationEncodedValue.type | ||
|
||
private val _elements by lazy { | ||
annotationEncodedValue.elements.map { annotationElement -> annotationElement.toMutable() }.toMutableSet() | ||
} | ||
|
||
override fun getType(): String { | ||
return this.type | ||
} | ||
|
||
fun setType(type: String) { | ||
this.type = type | ||
} | ||
|
||
override fun getElements(): MutableSet<out AnnotationElement> { | ||
return _elements | ||
} | ||
|
||
companion object { | ||
fun AnnotationEncodedValue.toMutable(): MutableAnnotationEncodedValue { | ||
return MutableAnnotationEncodedValue(this) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableArrayEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import app.revanced.patcher.proxy.mutableTypes.encodedValue.MutableEncodedValue.Companion.toMutable | ||
import org.jf.dexlib2.base.value.BaseArrayEncodedValue | ||
import org.jf.dexlib2.iface.value.ArrayEncodedValue | ||
import org.jf.dexlib2.iface.value.EncodedValue | ||
|
||
class MutableArrayEncodedValue(arrayEncodedValue: ArrayEncodedValue) : BaseArrayEncodedValue(), MutableEncodedValue { | ||
private val _value by lazy { | ||
arrayEncodedValue.value.map { encodedValue -> encodedValue.toMutable() }.toMutableList() | ||
} | ||
|
||
override fun getValue(): MutableList<out EncodedValue> { | ||
return _value | ||
} | ||
|
||
companion object { | ||
fun ArrayEncodedValue.toMutable(): MutableArrayEncodedValue { | ||
return MutableArrayEncodedValue(this) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableBooleanEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseBooleanEncodedValue | ||
import org.jf.dexlib2.iface.value.BooleanEncodedValue | ||
|
||
class MutableBooleanEncodedValue(booleanEncodedValue: BooleanEncodedValue) : BaseBooleanEncodedValue(), | ||
MutableEncodedValue { | ||
private var value = booleanEncodedValue.value | ||
|
||
override fun getValue(): Boolean { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: Boolean) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun BooleanEncodedValue.toMutable(): MutableBooleanEncodedValue { | ||
return MutableBooleanEncodedValue(this) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...in/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableByteEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseByteEncodedValue | ||
import org.jf.dexlib2.iface.value.ByteEncodedValue | ||
|
||
class MutableByteEncodedValue(byteEncodedValue: ByteEncodedValue) : BaseByteEncodedValue(), MutableEncodedValue { | ||
private var value = byteEncodedValue.value | ||
|
||
override fun getValue(): Byte { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: Byte) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun ByteEncodedValue.toMutable(): MutableByteEncodedValue { | ||
return MutableByteEncodedValue(this) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...in/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableCharEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseCharEncodedValue | ||
import org.jf.dexlib2.iface.value.CharEncodedValue | ||
|
||
class MutableCharEncodedValue(charEncodedValue: CharEncodedValue) : BaseCharEncodedValue(), MutableEncodedValue { | ||
private var value = charEncodedValue.value | ||
|
||
override fun getValue(): Char { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: Char) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun CharEncodedValue.toMutable(): MutableCharEncodedValue { | ||
return MutableCharEncodedValue(this) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableDoubleEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseDoubleEncodedValue | ||
import org.jf.dexlib2.iface.value.DoubleEncodedValue | ||
|
||
class MutableDoubleEncodedValue(doubleEncodedValue: DoubleEncodedValue) : BaseDoubleEncodedValue(), | ||
MutableEncodedValue { | ||
private var value = doubleEncodedValue.value | ||
|
||
override fun getValue(): Double { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: Double) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun DoubleEncodedValue.toMutable(): MutableDoubleEncodedValue { | ||
return MutableDoubleEncodedValue(this) | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.ValueType | ||
import org.jf.dexlib2.iface.value.* | ||
|
||
interface MutableEncodedValue : EncodedValue { | ||
companion object { | ||
fun EncodedValue.toMutable(): MutableEncodedValue { | ||
return when (this.valueType) { | ||
ValueType.TYPE -> MutableTypeEncodedValue(this as TypeEncodedValue) | ||
ValueType.FIELD -> MutableFieldEncodedValue(this as FieldEncodedValue) | ||
ValueType.METHOD -> MutableMethodEncodedValue(this as MethodEncodedValue) | ||
ValueType.ENUM -> MutableEnumEncodedValue(this as EnumEncodedValue) | ||
ValueType.ARRAY -> MutableArrayEncodedValue(this as ArrayEncodedValue) | ||
ValueType.ANNOTATION -> MutableAnnotationEncodedValue(this as AnnotationEncodedValue) | ||
ValueType.BYTE -> MutableByteEncodedValue(this as ByteEncodedValue) | ||
ValueType.SHORT -> MutableShortEncodedValue(this as ShortEncodedValue) | ||
ValueType.CHAR -> MutableCharEncodedValue(this as CharEncodedValue) | ||
ValueType.INT -> MutableIntEncodedValue(this as IntEncodedValue) | ||
ValueType.LONG -> MutableLongEncodedValue(this as LongEncodedValue) | ||
ValueType.FLOAT -> MutableFloatEncodedValue(this as FloatEncodedValue) | ||
ValueType.DOUBLE -> MutableDoubleEncodedValue(this as DoubleEncodedValue) | ||
ValueType.METHOD_TYPE -> MutableMethodTypeEncodedValue(this as MethodTypeEncodedValue) | ||
ValueType.METHOD_HANDLE -> MutableMethodHandleEncodedValue(this as MethodHandleEncodedValue) | ||
ValueType.STRING -> MutableStringEncodedValue(this as StringEncodedValue) | ||
ValueType.BOOLEAN -> MutableBooleanEncodedValue(this as BooleanEncodedValue) | ||
ValueType.NULL -> MutableNullEncodedValue() | ||
else -> this as MutableEncodedValue | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableEnumEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseEnumEncodedValue | ||
import org.jf.dexlib2.iface.reference.FieldReference | ||
import org.jf.dexlib2.iface.value.EnumEncodedValue | ||
|
||
class MutableEnumEncodedValue(enumEncodedValue: EnumEncodedValue) : BaseEnumEncodedValue(), MutableEncodedValue { | ||
private var value = enumEncodedValue.value | ||
|
||
override fun getValue(): FieldReference { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: FieldReference) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun EnumEncodedValue.toMutable(): MutableEnumEncodedValue { | ||
return MutableEnumEncodedValue(this) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...n/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFieldEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.ValueType | ||
import org.jf.dexlib2.base.value.BaseFieldEncodedValue | ||
import org.jf.dexlib2.iface.reference.FieldReference | ||
import org.jf.dexlib2.iface.value.FieldEncodedValue | ||
|
||
class MutableFieldEncodedValue(fieldEncodedValue: FieldEncodedValue) : BaseFieldEncodedValue(), MutableEncodedValue { | ||
private var value = fieldEncodedValue.value | ||
|
||
override fun getValueType(): Int { | ||
return ValueType.FIELD | ||
} | ||
|
||
override fun getValue(): FieldReference { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: FieldReference) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun FieldEncodedValue.toMutable(): MutableFieldEncodedValue { | ||
return MutableFieldEncodedValue(this) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableFloatEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseFloatEncodedValue | ||
import org.jf.dexlib2.iface.value.FloatEncodedValue | ||
|
||
class MutableFloatEncodedValue(floatEncodedValue: FloatEncodedValue) : BaseFloatEncodedValue(), MutableEncodedValue { | ||
private var value = floatEncodedValue.value | ||
|
||
override fun getValue(): Float { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: Float) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun FloatEncodedValue.toMutable(): MutableFloatEncodedValue { | ||
return MutableFloatEncodedValue(this) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ain/kotlin/app/revanced/patcher/proxy/mutableTypes/encodedValue/MutableIntEncodedValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patcher.proxy.mutableTypes.encodedValue | ||
|
||
import org.jf.dexlib2.base.value.BaseIntEncodedValue | ||
import org.jf.dexlib2.iface.value.IntEncodedValue | ||
|
||
class MutableIntEncodedValue(intEncodedValue: IntEncodedValue) : BaseIntEncodedValue(), MutableEncodedValue { | ||
private var value = intEncodedValue.value | ||
|
||
override fun getValue(): Int { | ||
return this.value | ||
} | ||
|
||
fun setValue(value: Int) { | ||
this.value = value | ||
} | ||
|
||
companion object { | ||
fun IntEncodedValue.toMutable(): MutableIntEncodedValue { | ||
return MutableIntEncodedValue(this) | ||
} | ||
} | ||
} |
Oops, something went wrong.