mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-24 19:51:03 +00:00
refactor: migrate signature schema changes to Patcher
also updated Extensions, for good measure.
This commit is contained in:
@@ -4,7 +4,12 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.builder.BuilderInstruction
|
||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||
|
||||
infix fun AccessFlags.or(other: AccessFlags) = this.value or other.value
|
||||
class AccessFlagExtensions {
|
||||
companion object {
|
||||
infix fun AccessFlags.or(other: AccessFlags) = this.value or other.value
|
||||
infix fun Int.or(other: AccessFlags) = this or other.value
|
||||
}
|
||||
}
|
||||
|
||||
fun MutableMethodImplementation.addInstructions(index: Int, instructions: List<BuilderInstruction>) {
|
||||
for (i in instructions.lastIndex downTo 0) {
|
||||
|
||||
@@ -5,16 +5,61 @@ import org.jf.dexlib2.Opcode
|
||||
/**
|
||||
* Represents a method signature.
|
||||
* @param name A suggestive name for the method which the signature was created for.
|
||||
* @param metadata Metadata about this signature.
|
||||
* @param returnType The return type of the method.
|
||||
* @param accessFlags The access flags of the method.
|
||||
* @param methodParameters The parameters of the method.
|
||||
* @param opcodes A list of opcodes of the method.
|
||||
* @param accessFlags The access flags of the method.
|
||||
*/
|
||||
@Suppress("ArrayInDataClass")
|
||||
data class MethodSignature(
|
||||
val name: String,
|
||||
val metadata: SignatureMetadata,
|
||||
val returnType: String?,
|
||||
val accessFlags: Int?,
|
||||
val methodParameters: Iterable<String>?,
|
||||
val opcodes: Iterable<Opcode>?
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Metadata about the signature.
|
||||
* @param method Metadata about the method for this signature.
|
||||
* @param patcher Metadata for the Patcher, this contains things like how the Patcher should interpret this signature.
|
||||
*/
|
||||
data class SignatureMetadata(
|
||||
val method: MethodMetadata,
|
||||
val patcher: PatcherMetadata
|
||||
)
|
||||
|
||||
/**
|
||||
* Metadata about the method for this signature.
|
||||
* @param definingClass The defining class name of the original method.
|
||||
* @param methodName The name of the original method.
|
||||
* @param comment A comment about this method and the data above.
|
||||
* For example, the version this signature was originally made for.
|
||||
*/
|
||||
data class MethodMetadata(
|
||||
val definingClass: String?,
|
||||
val methodName: String?,
|
||||
val comment: String
|
||||
)
|
||||
|
||||
/**
|
||||
* Metadata for the Patcher, this contains things like how the Patcher should interpret this signature.
|
||||
* @param method The method the Patcher should use to resolve the signature.
|
||||
*/
|
||||
data class PatcherMetadata(
|
||||
val method: PatcherMethod
|
||||
)
|
||||
|
||||
interface PatcherMethod {
|
||||
/**
|
||||
* When comparing the signature, if one or more of the opcodes do not match, skip.
|
||||
*/
|
||||
class Direct : PatcherMethod
|
||||
|
||||
/**
|
||||
* When comparing the signature, if [threshold] or more of the opcodes do not match, skip.
|
||||
*/
|
||||
class Fuzzy(val threshold: Int) : PatcherMethod
|
||||
}
|
||||
Reference in New Issue
Block a user