1
mirror of https://github.com/revanced/revanced-patcher synced 2025-09-13 18:30:49 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot
70ca184cf9 chore(release): 1.0.0-dev.15 [skip ci]
# [1.0.0-dev.15](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.14...v1.0.0-dev.15) (2022-05-25)

### Features

* utility functions to get metadata of patch & sigs ([72f16b7](72f16b7785))
2022-05-25 20:55:57 +00:00
Lucaskyy
72f16b7785 feat: utility functions to get metadata of patch & sigs 2022-05-25 22:54:20 +02:00
Lucaskyy
fc03639b26 chore: fix typo 2022-05-25 22:52:57 +02:00
4 changed files with 41 additions and 2 deletions

View File

@@ -1,3 +1,10 @@
# [1.0.0-dev.15](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.14...v1.0.0-dev.15) (2022-05-25)
### Features
* utility functions to get metadata of patch & sigs ([72f16b7](https://github.com/revanced/revanced-patcher/commit/72f16b778587c28d8f8e91da502f197e7dc35d6d))
# [1.0.0-dev.14](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.13...v1.0.0-dev.14) (2022-05-24)

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 1.0.0-dev.14
version = 1.0.0-dev.15

View File

@@ -0,0 +1,32 @@
package app.revanced.patcher.extensions
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.patch.base.Patch
import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
private inline fun <reified T : Annotation> Any.firstAnnotation() =
this::class.annotations.first { it is T } as T
private inline fun <reified T : Annotation> Any.recursiveAnnotation() =
this::class.java.findAnnotationRecursively(T::class.java)!!
object PatchExtensions {
val Patch<*>.name get() = firstAnnotation<Name>().name
val Patch<*>.version get() = firstAnnotation<Version>().version
val Patch<*>.description get() = firstAnnotation<Description>().description
val Patch<*>.compatiblePackages get() = recursiveAnnotation<Compatibility>().compatiblePackages
}
object MethodSignatureExtensions {
val MethodSignature.name get() = firstAnnotation<Name>().name
val MethodSignature.version get() = firstAnnotation<Version>().version
val MethodSignature.description get() = firstAnnotation<Description>().description
val MethodSignature.compatiblePackages get() = recursiveAnnotation<Compatibility>().compatiblePackages
val MethodSignature.matchingMethod get() = firstAnnotation<MatchingMethod>()
val MethodSignature.fuzzyThreshold get() = firstAnnotation<FuzzyPatternScanMethod>().threshold
}

View File

@@ -10,7 +10,7 @@ import app.revanced.patcher.signature.implementation.method.MethodSignature
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class MatchingMethod(
val definingClass: String = "L<unspecified-class>",
val definingClass: String = "L<unspecified-class>;",
val name: String = "<unspecified-method>"
)