| 336 | } |
| 337 | |
| 338 | JNIEXPORT jintArray JNICALL |
| 339 | Java_com_cactus_CactusJNI_nativeTokenize(JNIEnv* env, jobject, jlong handle, jstring text) { |
| 340 | if (handle == 0) { throwCactusException(env, "Model not initialized"); return nullptr; } |
| 341 | |
| 342 | const char* textStr = jstring_to_cstr(env, text); |
| 343 | std::vector<uint32_t> buffer(8192); |
| 344 | size_t tokenLen = 0; |
| 345 | |
| 346 | int result = cactus_tokenize( |
| 347 | reinterpret_cast<cactus_model_t>(handle), |
| 348 | textStr, |
| 349 | buffer.data(), |
| 350 | buffer.size(), |
| 351 | &tokenLen |
| 352 | ); |
| 353 | |
| 354 | release_jstring(env, text, textStr); |
| 355 | |
| 356 | if (result < 0) { throwOnError(env); return nullptr; } |
| 357 | |
| 358 | jintArray jarray = env->NewIntArray(static_cast<jsize>(tokenLen)); |
| 359 | if (tokenLen > 0) { |
| 360 | env->SetIntArrayRegion(jarray, 0, static_cast<jsize>(tokenLen), reinterpret_cast<jint*>(buffer.data())); |
| 361 | } |
| 362 | return jarray; |
| 363 | } |
| 364 | |
| 365 | JNIEXPORT jstring JNICALL |
| 366 | Java_com_cactus_CactusJNI_nativeScoreWindow(JNIEnv* env, jobject, jlong handle, |
nothing calls this directly
no test coverage detected