# AKI **Repository Path**: chuang-xia/aki ## Basic Information - **Project Name**: AKI - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-15 - **Last Updated**: 2025-12-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README - [Introduction to AKI](#introduction-to-aki) - [Quick Start](doc/quick-start.md) - [User Guide](#user-guide) - [Example Demos](example/ohos/README.md) - [Benchmark](#benchmark) # Introduction to AKI Alpha Kernel Interacting (AKI) is a user-friendly development framework that allows interactions between JavaScript (JS) and C/C++ in OpenHarmony native development. It provides seamless calls between C/C++ and JS, using simplified syntactic sugar. ## Advantages 1. Provides user-friendly APIs by decoupling foreign function interfaces (FFI) code and service code. 2. Provides features such as data type conversion, easy binding of functions and objects across languages, and thread safety. 3. Supports interactions between JS and C/C++. 4. Supports nesting with Node-API. 
| Native C/C++ Service Code | ArkTS Code |
|---|---|
#include <string>
#include <aki/jsbind.h>
// Class/struct.
struct Person {
std::string SayHello();
int age;
std::string name;
double weight;
};
// Global function.
Person MakePerson() {
Person person = {99, "aki", 128.8};
return person;
}
// AKI JSBind syntactic sugar.
JSBIND_GLOBAL() {
JSBIND_FUNCTION(MakePerson);
}
JSBIND_CLASS(Person) {
JSBIND_CONSTRUCTOR<int>();
JSBIND_METHOD(SayHello);
JSBIND_PROPERTY(age);
JSBIND_PROPERTY(name);
JSBIND_PROPERTY(weight);
}
JSBIND_ADDON(<Name>)
|
import libaki from "lib<Name>.so" // Call the C/C++ constructor Person(). let man = new libaki.Person(10); // Access the class/struct member properties. console.log(man.age); // Class/struct member function. man.SayHello(); // Call the C/C++ global function. let woman = libaki.MakePerson(); // Simplified conversion of all types. console.log(woman.name); |
| Syntactic Sugar | AKI | Description | |
|---|---|---|---|
| Addon registration | From JS to C++ | JSBIND_ADDON | Registers an OpenHarmony native addon. User Guide |
| From C++ to JS | aki::Value::FromGlobal | Obtains the properties of **globalThis** in JS code. User Guide |
|
| Global function | From JS to C++ | JSBIND_FUNCTION JSBIND_PFUNCTION |
Binds a C++ global function to make it can be called from a JS addon. User Guide |
| From C++ to JS | aki::Value::operator() | Calls a JS global function from a C/C++ addon. User Guide |
|
| Class constructor | From JS to C++ | JSBIND_CONSTRUCTOR<> | Binds a C++ class constructor to make it can be called from a JS addon. The constructor can be overloaded. You need to specify the parameter type of the constructor. User Guide |
| From C++ to JS | - | Not supported. | |
| Class member function | From JS to C++ | JSBIND_METHOD JSBIND_PMETHOD |
Binds a C++ class member function to make it can be called from a JS addon. Available member functions: class static function, class member function, and const class member function. User Guide |
| From C++ to JS | aki::Value::CallMethod | Calls a member function of a JS object. User Guide |
|
| Class member property | From JS to C++ | JSBIND_PROPERTY JSBIND_FIELD |
Binds a C++ class member property using JSBIND_PROPERTY. Binds a C++ class member property accessor (Get/Set) using JSBIND_FIELD. User Guide |
| From C++ to JS | aki::Value::operator[] | Accesses the properties of a JS object. User Guide |
|
| Enum | From JS to C++ | JSBIND_ENUM JSBIND_ENUM_VALUE |
Binds an enum. The default enum in C/C++ is int32_t in the POD, and the property of the enum in JS is readonly. User Guide |
| From C++ to JS | - | - | |
| API | Calls | AKI (ms) | Node-API (ms) |
| bool (*)() | 10000 | 0.0032 | 0.0031 |
| string (*)(string) | 10000 | 0.0058 | 0.0057 |
| void (*)( std::function ) | 10000 | 0.0667 | 0.0176 |
| void (*)( aki::Callback ) | 10000 | 0.0178 | |
| void (*)( aki::SafetyCallback ) | 10000 | 0.0664 |