Fix names, samples (#426)
This commit is contained in:
+10
-13
@@ -1,17 +1,17 @@
|
||||
# Kotlin N interoperability #
|
||||
# _Kotlin/Native_ interoperability #
|
||||
|
||||
## Introduction ##
|
||||
|
||||
_Kotlin N_ follows general tradition of Kotlin to provide excellent
|
||||
_Kotlin/Native_ follows general tradition of Kotlin to provide excellent
|
||||
existing platform software interoperability. In case of native platform
|
||||
most important interoperability target is a C library. Thus _Kotlin N_
|
||||
comes with an `interop` tool, which could be used to quickly generate
|
||||
most important interoperability target is a C library. Thus _Kotlin/Native_
|
||||
comes with an `cinterop` tool, which could be used to quickly generate
|
||||
everything needed to interact with an external library.
|
||||
|
||||
Following workflow is expected when interacting with the native library.
|
||||
* create `.def` file describing what to include into bindings
|
||||
* use `interop` tool to produce Kotlin bindings
|
||||
* run _Kotlin N_ compiler on an application to produce the final executable
|
||||
* use `cinterop` tool to produce Kotlin bindings
|
||||
* run _Kotlin/Native_ compiler on an application to produce the final executable
|
||||
|
||||
Interoperability tool analyses C headers and produces "natural" mapping of
|
||||
types, function and constants into the Kotlin world. Generated stubs can be
|
||||
@@ -24,7 +24,7 @@ Build the dependencies and the compiler (see `README.md`).
|
||||
Prepare stubs for the system sockets library:
|
||||
|
||||
cd samples/socket
|
||||
../../dist/bin/interop -def:sockets.def -o:sockets.kt.bc
|
||||
../../dist/bin/cinterop -def:sockets.def -o:sockets.kt.bc
|
||||
|
||||
Compile the echo server:
|
||||
|
||||
@@ -45,9 +45,6 @@ Test the server by conecting to it, for example with telnet:
|
||||
|
||||
Write something to console and watch server echoing it back.
|
||||
|
||||
~~Quit telnet by pressing ctrl+] ctrl+D~~
|
||||
|
||||
|
||||
## Creating bindings for a new library ##
|
||||
|
||||
To create bindings for a new library, start by creating `.def` file.
|
||||
@@ -57,14 +54,14 @@ Structurally it's a simple property file, looking like this:
|
||||
header = zlib.h
|
||||
compilerOpts = -std=c99
|
||||
|
||||
Then run interop tool with something like (note that for host libraries not included
|
||||
Then run `cinterop` tool with something like (note that for host libraries not included
|
||||
in sysroot search paths for headers may be needed):
|
||||
|
||||
interop -def:zlib.def -copt:-I/opt/local/include -o:zlib.kt.bc
|
||||
cinterop -def:zlib.def -copt:-I/opt/local/include -o:zlib.kt.bc
|
||||
|
||||
This command will produce `zlib.kt.bc` compiled library and
|
||||
`zlib.kt.bc-build/kotlin` directory containing Kotlin source code for the library.
|
||||
|
||||
``
|
||||
If behavior for certain platform shall be modified, one may use format like
|
||||
`compilerOpts.osx` or `compilerOpts.linux` to provide platform-specific values
|
||||
to options.
|
||||
|
||||
Reference in New Issue
Block a user