Skip to content

Type Mapping between C and Java types

Tianxiao Gu edited this page Jan 25, 2022 · 1 revision

The binding generator needs to process each C++ type and its definition to a corresponding Java type. We use Clang to model C++ types and JavaPoet to model Java types. Here we actually document how convert a given Clang Type to JavaPoet TypeName and how to build a Java class via JavaPoet's ClassBuilder for a Clang Decl.

The first thing we need to discuss is about the primitive types. Indeed if a C++ type (e.g., struct or int) can be allocated in heap, we must create a Java binding for it because we may use its pointers between Java and C++. However, boxed primitives in Java may easily lead to performance issues.

Clone this wiki locally