@@ -456,173 +456,6 @@ Java_com_osfans_trime_core_Rime_selectRimeSchema(JNIEnv *env, jclass /* thiz */,
456
456
return Rime::Instance ().selectSchema (schema);
457
457
}
458
458
459
- // configuration
460
- extern " C"
461
- JNIEXPORT jobject JNICALL
462
- Java_com_osfans_trime_core_Rime_config_1get_1bool (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key) {
463
- const char * s = env->GetStringUTFChars (name, nullptr );
464
- RimeConfig config = {0 };
465
- Bool b = RimeConfigOpen (s, &config);
466
- env->ReleaseStringUTFChars (name, s);
467
- Bool value;
468
- if (b) {
469
- s = env->GetStringUTFChars (key, nullptr );
470
- b = RimeConfigGetBool (&config, s, &value);
471
- env->ReleaseStringUTFChars (key, s);
472
- }
473
- RimeConfigClose (&config);
474
- if (!b) return nullptr ;
475
- jclass jc = env->FindClass (" java/lang/Boolean" );
476
- jmethodID ctorID = env->GetMethodID (jc, " <init>" , " (Z)V" );
477
- auto ret = env->NewObject (jc, ctorID, value);
478
- env->DeleteLocalRef (jc);
479
- return ret;
480
- }
481
-
482
- extern " C"
483
- JNIEXPORT jboolean JNICALL
484
- Java_com_osfans_trime_core_Rime_config_1set_1bool (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key, jboolean value) {
485
- const char * s = env->GetStringUTFChars (name, nullptr );
486
- RimeConfig config = {nullptr };
487
- Bool b = RimeConfigOpen (s, &config);
488
- env->ReleaseStringUTFChars (name, s);
489
- if (b) {
490
- s = env->GetStringUTFChars (key, nullptr );
491
- b = RimeConfigSetBool (&config, s, value);
492
- env->ReleaseStringUTFChars (key, s);
493
- }
494
- RimeConfigClose (&config);
495
- return b;
496
- }
497
-
498
- extern " C"
499
- JNIEXPORT jobject JNICALL
500
- Java_com_osfans_trime_core_Rime_config_1get_1int (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key) {
501
- const char * s = env->GetStringUTFChars (name, nullptr );
502
- RimeConfig config = {nullptr };
503
- Bool b = RimeConfigOpen (s, &config);
504
- env->ReleaseStringUTFChars (name, s);
505
- int value;
506
- if (b) {
507
- s = env->GetStringUTFChars (key, nullptr );
508
- b = RimeConfigGetInt (&config, s, &value);
509
- env->ReleaseStringUTFChars (key, s);
510
- }
511
- RimeConfigClose (&config);
512
- if (!b) return nullptr ;
513
- jclass jc = env->FindClass (" java/lang/Integer" );
514
- jmethodID ctorID = env->GetMethodID (jc, " <init>" , " (I)V" );
515
- auto ret = env->NewObject (jc, ctorID, value);
516
- env->DeleteLocalRef (jc);
517
- return ret;
518
- }
519
-
520
- extern " C"
521
- JNIEXPORT jboolean JNICALL
522
- Java_com_osfans_trime_core_Rime_config_1set_1int (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key, jint value) {
523
- const char * s = env->GetStringUTFChars (name, nullptr );
524
- RimeConfig config = {nullptr };
525
- Bool b = RimeConfigOpen (s, &config);
526
- env->ReleaseStringUTFChars (name, s);
527
- if (b) {
528
- s = env->GetStringUTFChars (key, nullptr );
529
- b = RimeConfigSetInt (&config, s, value);
530
- env->ReleaseStringUTFChars (key, s);
531
- }
532
- RimeConfigClose (&config);
533
- return b;
534
- }
535
-
536
- extern " C"
537
- JNIEXPORT jobject JNICALL
538
- Java_com_osfans_trime_core_Rime_config_1get_1double (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key) {
539
- const char * s = env->GetStringUTFChars (name, nullptr );
540
- RimeConfig config = {nullptr };
541
- Bool b = RimeConfigOpen (s, &config);
542
- env->ReleaseStringUTFChars (name, s);
543
- double value;
544
- if (b) {
545
- s = env->GetStringUTFChars (key, nullptr );
546
- b = RimeConfigGetDouble (&config, s, &value);
547
- env->ReleaseStringUTFChars (key, s);
548
- }
549
- RimeConfigClose (&config);
550
- if (!b) return nullptr ;
551
- jclass jc = env->FindClass (" java/lang/Double" );
552
- jmethodID ctorID = env->GetMethodID (jc, " <init>" , " (D)V" );
553
- auto ret = env->NewObject (jc, ctorID, value);
554
- env->DeleteLocalRef (jc);
555
- return ret;
556
- }
557
-
558
- extern " C"
559
- JNIEXPORT jboolean JNICALL
560
- Java_com_osfans_trime_core_Rime_config_1set_1double (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key, jdouble value) {
561
- const char * s = env->GetStringUTFChars (name, nullptr );
562
- RimeConfig config = {0 };
563
- Bool b = RimeConfigOpen (s, &config);
564
- env->ReleaseStringUTFChars (name, s);
565
- if (b) {
566
- s = env->GetStringUTFChars (key, nullptr );
567
- b = RimeConfigSetDouble (&config, s, value);
568
- env->ReleaseStringUTFChars (key, s);
569
- }
570
- RimeConfigClose (&config);
571
- return b;
572
- }
573
-
574
- extern " C"
575
- JNIEXPORT jstring JNICALL
576
- Java_com_osfans_trime_core_Rime_config_1get_1string (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key) {
577
- const char * s = env->GetStringUTFChars (name, nullptr );
578
- RimeConfig config = {nullptr };
579
- Bool b = RimeConfigOpen (s, &config);
580
- env->ReleaseStringUTFChars (name, s);
581
- char value[MAX_BUFFER_LENGTH] = {0 };
582
- if (b) {
583
- s = env->GetStringUTFChars (key, nullptr );
584
- b = RimeConfigGetString (&config, s, value, MAX_BUFFER_LENGTH);
585
- env->ReleaseStringUTFChars (key, s);
586
- }
587
- RimeConfigClose (&config);
588
- return b ? env->NewStringUTF (value) : nullptr ;
589
- }
590
-
591
- extern " C"
592
- JNIEXPORT jboolean JNICALL
593
- Java_com_osfans_trime_core_Rime_config_1set_1string (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key, jstring value) {
594
- const char * s = env->GetStringUTFChars (name, nullptr );
595
- RimeConfig config = {nullptr };
596
- Bool b = RimeConfigOpen (s, &config);
597
- env->ReleaseStringUTFChars (name, s);
598
- if (b) {
599
- s = env->GetStringUTFChars (key, nullptr );
600
- const char * v = env->GetStringUTFChars (value, nullptr );
601
- b = RimeConfigSetString (&config, s, v);
602
- env->ReleaseStringUTFChars (key, s);
603
- env->ReleaseStringUTFChars (key, v);
604
- }
605
- RimeConfigClose (&config);
606
- return b;
607
- }
608
-
609
- extern " C"
610
- JNIEXPORT jint JNICALL
611
- Java_com_osfans_trime_core_Rime_config_1list_1size (JNIEnv *env, jclass /* thiz */ , jstring name, jstring key) {
612
- const char * s = env->GetStringUTFChars (name, nullptr );
613
- RimeConfig config = {nullptr };
614
- Bool b = RimeConfigOpen (s, &config);
615
- env->ReleaseStringUTFChars (name, s);
616
- int value = 0 ;
617
- if (b) {
618
- s = env->GetStringUTFChars (key, nullptr );
619
- value = RimeConfigListSize (&config, s);
620
- env->ReleaseStringUTFChars (key, s);
621
- }
622
- RimeConfigClose (&config);
623
- return value;
624
- }
625
-
626
459
// testing
627
460
extern " C"
628
461
JNIEXPORT jboolean JNICALL
0 commit comments