fix bugprone-multi-level-implicit-pointer-conversio
[liba.git] / java / src / trajpoly3.c
blob57f2a6a3de78860390d0f79d0959511f3cbcc4f6
1 #include "a.h"
2 #include "a/trajpoly3.h"
3 #include "liba_trajpoly3.h"
5 #undef L
6 #define L Java_liba_trajpoly3
7 static struct
9 jmethodID _new;
10 jfieldID ctx;
11 } L = {NULL, NULL};
13 JNIEXPORT void JNICALL Java_liba_trajpoly3_clinit(JNIEnv *_env, jclass _cls)
15 jclass _nbb = (*_env)->FindClass(_env, "Ljava/nio/ByteBuffer;");
16 L._new = (*_env)->GetStaticMethodID(_env, _nbb, "allocateDirect", "(I)Ljava/nio/ByteBuffer;");
17 L.ctx = (*_env)->GetFieldID(_env, _cls, "ctx", "Ljava/nio/ByteBuffer;");
20 JNIEXPORT jobject JNICALL Java_liba_trajpoly3_gen(JNIEnv *_env, jobject _obj, jdouble ts, jdouble p0, jdouble p1, jdouble v0, jdouble v1)
22 jobject _ctx = (*_env)->CallObjectMethod(_env, _obj, L._new, (jint)sizeof(a_trajpoly3));
23 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
24 (*_env)->SetObjectField(_env, _obj, L.ctx, _ctx);
25 a_trajpoly3_gen(ctx, ts, p0, p1, v0, v1);
26 return _obj;
29 JNIEXPORT jobject JNICALL Java_liba_trajpoly3_p(JNIEnv *_env, jobject _obj)
31 jobject _ctx = (*_env)->GetObjectField(_env, _obj, L.ctx);
32 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
33 jobject p = (*_env)->NewDoubleArray(_env, A_LEN(ctx->p));
34 (*_env)->SetDoubleArrayRegion(_env, p, 0, A_LEN(ctx->p), ctx->p);
35 return p;
38 JNIEXPORT jobject JNICALL Java_liba_trajpoly3_v(JNIEnv *_env, jobject _obj)
40 jobject _ctx = (*_env)->GetObjectField(_env, _obj, L.ctx);
41 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
42 jobject v = (*_env)->NewDoubleArray(_env, A_LEN(ctx->v));
43 (*_env)->SetDoubleArrayRegion(_env, v, 0, A_LEN(ctx->v), ctx->v);
44 return v;
47 JNIEXPORT jobject JNICALL Java_liba_trajpoly3_a(JNIEnv *_env, jobject _obj)
49 jobject _ctx = (*_env)->GetObjectField(_env, _obj, L.ctx);
50 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
51 jobject a = (*_env)->NewDoubleArray(_env, A_LEN(ctx->a));
52 (*_env)->SetDoubleArrayRegion(_env, a, 0, A_LEN(ctx->a), ctx->a);
53 return a;
56 JNIEXPORT jdouble JNICALL Java_liba_trajpoly3_pos(JNIEnv *_env, jobject _obj, jdouble dt)
58 jobject _ctx = (*_env)->GetObjectField(_env, _obj, L.ctx);
59 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
60 return a_trajpoly3_pos(ctx, dt);
63 JNIEXPORT jdouble JNICALL Java_liba_trajpoly3_vel(JNIEnv *_env, jobject _obj, jdouble dt)
65 jobject _ctx = (*_env)->GetObjectField(_env, _obj, L.ctx);
66 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
67 return a_trajpoly3_vel(ctx, dt);
70 JNIEXPORT jdouble JNICALL Java_liba_trajpoly3_acc(JNIEnv *_env, jobject _obj, jdouble dt)
72 jobject _ctx = (*_env)->GetObjectField(_env, _obj, L.ctx);
73 a_trajpoly3 *ctx = (a_trajpoly3 *)(*_env)->GetDirectBufferAddress(_env, _ctx);
74 return a_trajpoly3_acc(ctx, dt);