Skip to content

Commit eb498f7

Browse files
authored
feat: second mapping tutorial (#4720)
1 parent f7e82c7 commit eb498f7

File tree

2 files changed

+231
-291
lines changed

2 files changed

+231
-291
lines changed

docs/topics/native/mapping-primitive-data-types-from-c.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<p>This is the first part of the <strong>Mapping Kotlin and C</strong> tutorial series.</p>
55
<p><img src="icon-1.svg" width="20" alt="First step"/> <strong>Mapping primitive data types from C</strong><br/>
66
<img src="icon-2-todo.svg" width="20" alt="Second step"/> <a href="mapping-struct-union-types-from-c.md">Mapping struct and union types from C</a><br/>
7-
<img src="icon-3-todo.svg" width="20" alt="Third step"/> <a href="mapping-function-pointers-from-c.md">Mapping function pointers</a><br/>
7+
<img src="icon-3-todo.svg" width="20" alt="Third step"/> <a href="mapping-function-pointers-from-c.md">Mapping function pointers</a><br/>
88
<img src="icon-4-todo.svg" width="20" alt="Fourth step"/> <a href="mapping-strings-from-c.md">Mapping strings from C</a><br/>
99
</p>
1010
</tldr>
@@ -18,8 +18,8 @@
1818
>
1919
{style="warning"}
2020

21-
In this tutorial, you'll learn which C data types are visible in Kotlin/Native and vice versa and explore the advanced
22-
C interop-related usages of Kotlin/Native and [multiplatform](gradle-configure-project.md#targeting-multiple-platforms)
21+
Let's explore which C data types are visible in Kotlin/Native and vice versa and examine advanced
22+
C interop-related use cases of Kotlin/Native and [multiplatform](gradle-configure-project.md#targeting-multiple-platforms)
2323
Gradle builds.
2424

2525
In this tutorial, you'll:
@@ -120,7 +120,7 @@ To create project files:
120120
121121
<tabs group="build-script">
122122
<tab title="Kotlin" group-key="kotlin">
123-
123+
124124
```kotlin
125125
plugins {
126126
kotlin("multiplatform") version "%kotlinVersion%"
@@ -150,10 +150,10 @@ To create project files:
150150
distributionType = Wrapper.DistributionType.BIN
151151
}
152152
```
153-
153+
154154
</tab>
155155
<tab title="Groovy" group-key="groovy">
156-
156+
157157
```groovy
158158
plugins {
159159
id 'org.jetbrains.kotlin.multiplatform' version '%kotlinVersion%'
@@ -184,13 +184,13 @@ To create project files:
184184
distributionType = 'BIN'
185185
}
186186
```
187-
187+
188188
</tab>
189189
</tabs>
190190
191-
The project file configures the C interop as an additional build step.
192-
Check out the [Multiplatform Gradle DSL reference](multiplatform-dsl-reference.md) to learn about different
193-
ways you can configure it.
191+
The project file configures the C interop as an additional build step.
192+
Check out the [Multiplatform Gradle DSL reference](multiplatform-dsl-reference.md) to learn about different
193+
ways you can configure it.
194194
195195
2. Move your `interop.def`, `lib.h`, and `lib.def` files to the `src/nativeInterop/cinterop` directory.
196196
3. Create a `src/nativeMain/kotlin` directory. This is where you should place all the source files, following Gradle's
@@ -218,10 +218,10 @@ You'll complete the code later as you learn how C primitive type declarations lo
218218
219219
## Inspect generated Kotlin APIs for a C library
220220
221-
Let's see how C primitive types are mapped into Kotlin/Native and update the example project accordingly.
221+
Let's see how C primitive types are mapped into Kotlin/Native and update the example project accordingly.
222222
223-
With the help of IntelliJ IDEA's [Go to declaration](https://www.jetbrains.com/help/rider/Navigation_and_Search__Go_to_Declaration.html)
224-
command (<shortcut>Cmd + B</shortcut>/<shortcut>Ctrl + B</shortcut>), you can navigate to the following generated API
223+
Use the IntelliJ IDEA's [Go to declaration](https://www.jetbrains.com/help/rider/Navigation_and_Search__Go_to_Declaration.html)
224+
command (<shortcut>Cmd + B</shortcut>/<shortcut>Ctrl + B</shortcut>) to navigate to the following generated API
225225
for C functions:
226226
227227
```kotlin
@@ -250,7 +250,7 @@ signed value:
250250

251251
Now that you've seen the C definitions, you can update your Kotlin code. The final code in the `hello.kt` file may look
252252
like this:
253-
253+
254254
```kotlin
255255
import interop.*
256256
import kotlinx.cinterop.ExperimentalForeignApi
@@ -265,7 +265,7 @@ fun main() {
265265
}
266266
```
267267

268-
To verify that everything works as expected, run the `linkDebugSharedNative` Gradle task [in your IDE](native-get-started.md#build-and-run-the-application)
268+
To verify that everything works as expected, run the `runDebugExecutableNative` Gradle task [in your IDE](native-get-started.md#build-and-run-the-application)
269269
or use the following command to run the code:
270270

271271
```bash

0 commit comments

Comments
 (0)