Guide가이드

Bind a prebuilt library빌드된 라이브러리 바인딩

The Gradle plugin walks jars you depend on and generates the same kind of table KSP generates for your sources.Gradle 플러그인이 의존하는 jar 를 훑어, KSP 가 내 소스에 대해 만드는 것과 같은 종류의 테이블을 생성한다.

01Apply the plugin플러그인 적용

plugins {
    id("io.github.thisisthepy.python.multiplatform.bindings") version "<version>"
}

The walker reads Kotlin metadata with ASM, generates Kotlin source for every reachable declaration, and lets kotlinc compile it. It never looks up JVM methods by name: value-class name mangling makes that impossible in principle.워커는 ASM 으로 Kotlin 메타데이터를 읽고, 닿을 수 있는 모든 선언에 대해 Kotlin 소스를 생성해 kotlinc 가 컴파일하게 한다. JVM 메서드를 이름으로 찾지 않는다. 값 클래스 이름 맹글링 때문에 그것은 원리적으로 불가능하다.

02What you get얻는 것

  • Default arguments can be omitted from Python.Python 에서 기본 인자를 생략할 수 있다.
  • Value classes round-trip; allow-listed ones such as Dp accept a raw number.값 클래스가 왕복한다. Dp 처럼 허용 목록에 있는 것은 숫자를 그대로 받는다.
  • Python callables can fill Kotlin function parameters (value-returning slots are not supported yet).Python 호출 가능 객체로 Kotlin 함수 파라미터를 채울 수 있다 (값을 돌려주는 슬롯은 아직 미지원).
  • @Composable functions can be called from Python inside a composition; clicks reach Kotlin callbacks and redraw.@Composable 함수를 컴포지션 안에서 Python 으로 부를 수 있다. 클릭이 Kotlin 콜백에 닿고 다시 그려진다.
  • .pyi stubs so an editor sees the surface (partial).에디터가 표면을 보도록 .pyi 스텁 생성 (부분).

Compose from Python is verified on desktop only. Kotlin/Native klibs are scanned but not bound yet.Python 에서의 Compose 는 데스크톱에서만 검증되었다. Kotlin/Native klib 은 스캔만 되고 아직 바인딩되지 않는다.

Specification: B-1 to B-7. Tests: ArtifactScannerTest, WalkedArtifactPythonImportTest, ComposableRenderTest.스펙: B-1 ~ B-7. 테스트: ArtifactScannerTest, WalkedArtifactPythonImportTest, ComposableRenderTest.