Skip to content

NDL file

NDL - is a custom interface definition language, that based on WebIDL format.

Kotlin and C code generates based on this file when Gradle is synchronized in IDEA.

Example of all possible records
namespace global {
    void simpleFunc();
    boolean myFunc(MyDictionary params, Array<int> flags, MyCallback response);
    [Dealloc] string returnString();
    [Critical] void fastFunc();
}

enum MyEnum {
    "CASE1",
    "CASE2"
};

callback MyCallback = boolean (int arg);

dictionary ParentDictionary {
    MyEnum a;
    int b;
};

dictionary MyDictionary: ParentDictionary {
    int c;
    int d;
};

Types mapping

Many types are currently supported, but there are still limitations.

NDL Kotlin C Kotlin Array C Array
int Int KInt IntArray KIntArray
long Long KLong LongArray KLongArray
float Float KFloat FloatArray KFloatArray
double Double KDouble DoubleArray KDoubleArray
char Char KChar CharArray KCharArray
boolean Boolean KBoolean BooleanArray KBooleanArray
byte Byte KByte ByteArray KByteArray
short Short KShort ShortArray KShortArray
string String KString ❌
void Unit void ❌
Callback Callback Callback Array<Callback> Array<Callback>
Struct Struct Struct Array<Struct> Array<Struct>

Warning

String type can not be used as an array type

Functions

Functions are used to call code. They have the following format:

type name(argType arg, ...);

To declare a callable function, place it inside namespace global block.

Example:

namespace global {
    int pow2(int num);
}

Dictionary

A Dictionary is a data container.

All its fields are copied when passed between Native and Kotlin.

Example:

dictionary UserInfo {
    string name;
    string lastName;
    int age;
}

namespace global {
    void sendUserInfo(UserInfo info);
}

Callback

Callback is used to call Kotlin from Native.

Example:

callback OnResponse = void (int response);

namespace global {
    void request(OnResponse result);
}

Enums

Enums are some typed constants.

Example:

enum MyEnum {
    "CASE1",
    "CASE2"
};

Annotations

There are several annotations that affect the generated code.

Annotations can be placed before functions or their arguments.

Example:

namespace global {
    [Dealloc] Array<int> returnInts();
    [Critical] void sendFast();
}