@Documented @Retention(value=RUNTIME) @Target(value={METHOD,PARAMETER,ANNOTATION_TYPE}) public @interface Adapter
Generator
to bridge a few differences, for instance,
between std::string
and String
, between std::vector
, Java arrays of primitive
types, Buffer
, and Pointer
, or between xyz::shared_ptr
and Pointer
:
The helper annotations are shortcuts that infer the template type(s) of the adapter class from the Java class they annotate. When an argument of a method is annotated, an instance of the adapter class is created from the Java object passed as argument, and this instance is passed to the C++ function, thus triggering an implicit cast to the type expected by the function (usually a reference or pointer to the target type). If the argument is also annotated with
Adapter class Target type Adaptee types Helper annotation VectorAdapter<P,T,A>
std::vector<T,A>
P
StdVector
StringAdapter<T>
std::basic_string<T>
char
signed char
unsigned char
wchar_t
unsigned short
signed int
StdString
SharedPtrAdapter<T>
SHARED_PTR_NAMESPACE::shared_ptr<T>
T
SharedPtr
UniquePtrAdapter<T,D>
UNIQUE_PTR_NAMESPACE::unique_ptr<T,D>
T
UniquePtr
MoveAdapter<T,D>
T
T
StdMove
OptionalAdapter<T>
OPTIONAL_NAMESPACE::optional<T>
T
Optional
Cast
, the adapter instance is cast to the type(s) specified
by the Cast
annotation before being passed to the function.
When a method is annotated, an instance of the adapter is created from the value (usually a pointer or
reference to the target type) returned by the C++ function or by new
if the method is an allocator.
If the method is also annotated with Cast
, the value returned by the C++ function is
cast by value 3 of the Cast
annotation, if any, before instantiation of the adapter.
Then a Java object is created from the adapter to be returned by the method.
Adapter classes must at least define the following public members:
argc()
> 1): a pointer to a const value of the adaptee, a size, and the owner pointer
static void deallocate(owner)
function
void assign(pointer, size, owner)
functions with the same signature than the constructors accepting 3 arguments
size
member variable for arrays accessed via pointer
StdString
, StdVector
, and SharedPtr
.Generator
Copyright © 2024. All rights reserved.