mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
refactor!: use proper extension function names
BREAKING CHANGE: This changes the names of extension functions
This commit is contained in:
parent
eafe1c631f
commit
efdd01a988
3 changed files with 14 additions and 15 deletions
|
@ -5,10 +5,11 @@ import org.jf.dexlib2.AccessFlags
|
|||
|
||||
/**
|
||||
* Create a label for the instruction at given index.
|
||||
*
|
||||
* @param index The index to create the label for the instruction at.
|
||||
* @return The label.
|
||||
*/
|
||||
fun MutableMethod.label(index: Int) = implementation!!.newLabelForIndex(index)
|
||||
fun MutableMethod.newLabel(index: Int) = implementation!!.newLabelForIndex(index)
|
||||
|
||||
/**
|
||||
* Perform a bitwise OR operation between two [AccessFlags].
|
||||
|
|
|
@ -290,15 +290,13 @@ object InstructionExtensions {
|
|||
fun MutableMethod.replaceInstructions(index: Int, smaliInstructions: String) =
|
||||
implementation!!.replaceInstructions(index, smaliInstructions.toInstructions(this))
|
||||
|
||||
// TODO: Use proper names for functions below.
|
||||
|
||||
/**
|
||||
* Get an instruction at the given index.
|
||||
*
|
||||
* @param index The index to get the instruction at.
|
||||
* @return The instruction.
|
||||
*/
|
||||
fun MutableMethodImplementation.instruction(index: Int): BuilderInstruction = instructions[index]
|
||||
fun MutableMethodImplementation.getInstruction(index: Int): BuilderInstruction = instructions[index]
|
||||
|
||||
/**
|
||||
* Get an instruction at the given index.
|
||||
|
@ -308,14 +306,14 @@ object InstructionExtensions {
|
|||
* @return The instruction.
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> MutableMethodImplementation.instruction(index: Int): T = instruction(index) as T
|
||||
fun <T> MutableMethodImplementation.getInstruction(index: Int): T = getInstruction(index) as T
|
||||
|
||||
/**
|
||||
* Get an instruction at the given index.
|
||||
* @param index The index to get the instruction at.
|
||||
* @return The instruction.
|
||||
*/
|
||||
fun MutableMethod.instruction(index: Int): BuilderInstruction = implementation!!.instruction(index)
|
||||
fun MutableMethod.getInstruction(index: Int): BuilderInstruction = implementation!!.getInstruction(index)
|
||||
|
||||
/**
|
||||
* Get an instruction at the given index.
|
||||
|
@ -324,5 +322,5 @@ object InstructionExtensions {
|
|||
* @return The instruction.
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> MutableMethod.instruction(index: Int): T = implementation!!.instruction<T>(index)
|
||||
fun <T> MutableMethod.getInstruction(index: Int): T = implementation!!.getInstruction<T>(index)
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package app.revanced.patcher.util.smali
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.InstructionExtensions.instruction
|
||||
import app.revanced.patcher.extensions.label
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.newLabel
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
@ -45,7 +45,7 @@ internal class InlineSmaliCompilerTest {
|
|||
"""
|
||||
)
|
||||
|
||||
val insn = method.instruction<BuilderInstruction21t>(insnIndex)
|
||||
val insn = method.getInstruction<BuilderInstruction21t>(insnIndex)
|
||||
assertEquals(targetIndex, insn.target.location.index)
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ internal class InlineSmaliCompilerTest {
|
|||
"""
|
||||
)
|
||||
|
||||
assertEquals(labelIndex, method.label(labelIndex).location.index)
|
||||
assertEquals(labelIndex, method.newLabel(labelIndex).location.index)
|
||||
|
||||
method.addInstructionsWithLabels(
|
||||
method.implementation!!.instructions.size,
|
||||
|
@ -71,10 +71,10 @@ internal class InlineSmaliCompilerTest {
|
|||
if-eqz v0, :test
|
||||
return-void
|
||||
""",
|
||||
ExternalLabel("test", method.instruction(1))
|
||||
ExternalLabel("test", method.getInstruction(1))
|
||||
)
|
||||
|
||||
val insn = method.instruction<BuilderInstruction21t>(insnIndex)
|
||||
val insn = method.getInstruction<BuilderInstruction21t>(insnIndex)
|
||||
assertTrue(insn.target.isPlaced, "Label was not placed")
|
||||
assertEquals(labelIndex, insn.target.location.index)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue