본문 바로가기
Kotlin/Release Notes

[Kotlin Release Notes] Kotlin/Native v0.3 is out

by 노력남자 2023. 9. 4.
반응형

2017년 6월 22일

 

Kotlin/Native v0.3의 릴리스를 기쁘게 발표합니다. 새로운 영역으로 나아가고 있습니다! v0.3 버전의 릴리스로 Windows가 컴파일 호스트 및 실행 대상으로 지원되며, Google Android 기기가 네이티브 액티비티의 실행 대상으로 지원됩니다. 따라서 Windows API 'Hello World'는 다음과 같이 간단할 수 있습니다:

 

import win32.*
fun main(args: Array<String>) {
  MessageBoxW(null, "Привет!","标题", MB_YESNOCANCEL or MB_ICONQUESTION)
}

 

Android 네이티브 액티비티의 이벤트 처리:

 

if (AInputQueue_getEvent(queue, event.ptr) < 0) {
  logError("Failure reading input event")
  return
}
if (AInputEvent_getType(event.value) == AINPUT_EVENT_TYPE_MOTION) {
  when (AKeyEvent_getAction(event.value) and AMOTION_EVENT_ACTION_MASK) {
    AMOTION_EVENT_ACTION_DOWN -> {
      animating = false
      currentPoint = getEventPoint(event.value, 0)
      startTime = getEventTime(event.value)
      startPoint = currentPoint
    }
    AMOTION_EVENT_ACTION_UP -> {
      val endPoint = getEventPoint(event.value, 0)
      val endTime = getEventTime(event.value)
      ....
   }
   AMOTION_EVENT_ACTION_MOVE -> {
      val numberOfPointers = AMotionEvent_getPointerCount(event.value).toInt()
      for (i in 0 until numberOfPointers)
         move(getEventPoint(event.value, i))
   }
}
AInputQueue_finishEvent(queue, event.value, 1)

 

디버깅


이번 릴리스에서는 소스 레벨 디버깅 (단계별 실행만 가능)을 지원합니다. 예를 들어 다음을 시도해보세요.

 

$ bin/konanc string0.kt  -g -o string0
$ lldb ./string0.kexe
(lldb) target create "string0.kexe"
Current executable set to 'string0.kexe' (x86_64).
(lldb) b string0.kt:1
Breakpoint 1: where = string0.kexe`kfun:main(kotlin.Array<kotlin.String>) + 4 at string0.kt:1, address = 0x0000000100001344
(lldb) r
Process 12288 launched: '/Users/jetbrains/kotlin/kotlin-native-release/kotlin-native/string0.kexe' (x86_64)
Process 12288 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100001344 string0.kexe`kfun:main(kotlin.Array<kotlin.String>) at string0.kt:1
-> 1       fun main(args: Array<String>) {
   2           val str = "hello"
   3           println(str.equals("HElLo", true))
   4           val strI18n = "Привет"
   5           println(strI18n.equals("прИВет", true))
   6           println(strI18n.toUpperCase())
   7           println(strI18n.toLowerCase())
(lldb) s
Process 12288 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x0000000100001354 string0.kexe`kfun:main(kotlin.Array<kotlin.String>) at string0.kt:3
   1       fun main(args: Array<String>) {
   2           val str = "hello"
-> 3           println(str.equals("HElLo", true))
   4           val strI18n = "Привет"
   5           println(strI18n.equals("прИВет", true))
   6           println(strI18n.toUpperCase())
   7           println(strI18n.toLowerCase())

 

라이브러리


마지막이지만 확실히 아닌 것은 새로운 라이브러리 포맷인 .klib를 소개한 것입니다. 이것은 Kotlin/Native 라이브러리의 기본 배포 형식으로 사용될 것입니다. 네이티브 라이브러리 및 프레임워크는 .klib를 사용하여 쉽게 상호 운용하고, -library library 커맨드 라인 플래그 또는 library Gradle 플러그인 옵션을 사용하여 Kotlin/Native 컴파일러와 함께 사용할 수 있습니다. 상호 운용 도구는 이미 기본적으로 .klib 형식 파일을 생성합니다. 라이브러리 형식에 대한 자세한 내용은 여기를 참조하세요.


비트 가져오기


아래에서 바이너리를 다운로드할 수 있습니다:

 

  • x86-64 Linux
  • x86-64 MacOS
  • x86-64 Windows


버그 및 문제는 Kotlin 버그 추적기를 사용하여 보고할 수 있습니다.

 

원문

 

https://blog.jetbrains.com/kotlin/2017/05/kotlinnative-v0-2-is-out/

반응형

댓글