summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-06-08 12:28:22 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-06-08 12:28:22 +0200
commit79fa552dab4ac7a879089639ace6374cb5bfd5e3 (patch)
tree2c7851fc5e5f29ad4dcfe891e746ebb83a313697
parent03eed403c9d597b47503b3054568bd521991a4ca (diff)
more work in general, milestone: full support of iterator / accessor inHEADmaster
each direction
-rw-r--r--general-test/generator.c230
-rw-r--r--general-test/test_generator.eo66
-rw-r--r--java/compatibility_tests/tests/CompatibilityTests.java252
-rw-r--r--java/generator_jni.c34
-rw-r--r--java/jni-bindings.c3
-rw-r--r--java/jni-bindings.h2
-rw-r--r--java/manual-bindings/ValueReference.java2
-rw-r--r--java/manual-bindings/binbuf.c3
-rw-r--r--java/manual-bindings/eflaccessor.c52
-rw-r--r--java/manual-bindings/efliterator.c65
-rw-r--r--java/manual-bindings/rwslice.c2
-rw-r--r--java/manual-bindings/strbuf.c3
-rw-r--r--java/manual-bindings/value.c23
13 files changed, 667 insertions, 70 deletions
diff --git a/general-test/generator.c b/general-test/generator.c
index e5338e2..4509a3b 100644
--- a/general-test/generator.c
+++ b/general-test/generator.c
@@ -363,6 +363,9 @@ _test_generator_generate_complex(Eo *obj, Test_Generator_Data *pd)
363 Eina_Strbuf *strbuf_ref_content[] = {_strbuf_easy_new("xatr"), _strbuf_easy_new("Constfolding"), _strbuf_easy_new("Bitwidth")}; 363 Eina_Strbuf *strbuf_ref_content[] = {_strbuf_easy_new("xatr"), _strbuf_easy_new("Constfolding"), _strbuf_easy_new("Bitwidth")};
364 FILL_EINA_ARRAY_REF(strbuf_ref_content, strbuf_arr) 364 FILL_EINA_ARRAY_REF(strbuf_ref_content, strbuf_arr)
365 365
366#undef FILL_EINA_ARRAY
367#undef FILL_EINA_ARRAY_REF
368
366 return ((Test_D) { 369 return ((Test_D) {
367 eina_array_accessor_new(int_arr), 370 eina_array_accessor_new(int_arr),
368 eina_array_accessor_new(obj_arr), 371 eina_array_accessor_new(obj_arr),
@@ -418,7 +421,234 @@ _test_generator_generate_complex(Eo *obj, Test_Generator_Data *pd)
418EOLIAN static void 421EOLIAN static void
419_test_generator_generate_complex2_get(const Eo *obj, Test_Generator_Data *pd, Eina_Accessor **acc1, Eina_Accessor **acc3, Eina_Accessor **acc4, Eina_Accessor **acc5, Eina_Accessor **acc6, Eina_Accessor **acc7, Eina_Accessor **acc8, Eina_Accessor **acc9, Eina_Accessor **acc10, Eina_Accessor **acc11, Eina_Accessor **acc12, Eina_Accessor **acc13, Eina_Array **arr1, Eina_Array **arr3, Eina_Array **arr4, Eina_Array **arr5, Eina_Array **arr6, Eina_Array **arr7, Eina_Array **arr8, Eina_Array **arr9, Eina_Array **arr10, Eina_Array **arr11, Eina_Array **arr12, Eina_Array **arr13, Eina_Future **fut1, Eina_Future **fut3, Eina_Future **fut4, Eina_Future **fut5, Eina_Future **fut6, Eina_Future **fut7, Eina_Future **fut8, Eina_Future **fut9, Eina_Future **fut10, Eina_Future **fut11, Eina_Future **fut12, Eina_Future **fut13, Eina_Iterator **ite1, Eina_Iterator **ite3, Eina_Iterator **ite4, Eina_Iterator **ite5, Eina_Iterator **ite6, Eina_Iterator **ite7, Eina_Iterator **ite8, Eina_Iterator **ite9, Eina_Iterator **ite10, Eina_Iterator **ite11, Eina_Iterator **ite12, Eina_Iterator **ite13) 422_test_generator_generate_complex2_get(const Eo *obj, Test_Generator_Data *pd, Eina_Accessor **acc1, Eina_Accessor **acc3, Eina_Accessor **acc4, Eina_Accessor **acc5, Eina_Accessor **acc6, Eina_Accessor **acc7, Eina_Accessor **acc8, Eina_Accessor **acc9, Eina_Accessor **acc10, Eina_Accessor **acc11, Eina_Accessor **acc12, Eina_Accessor **acc13, Eina_Array **arr1, Eina_Array **arr3, Eina_Array **arr4, Eina_Array **arr5, Eina_Array **arr6, Eina_Array **arr7, Eina_Array **arr8, Eina_Array **arr9, Eina_Array **arr10, Eina_Array **arr11, Eina_Array **arr12, Eina_Array **arr13, Eina_Future **fut1, Eina_Future **fut3, Eina_Future **fut4, Eina_Future **fut5, Eina_Future **fut6, Eina_Future **fut7, Eina_Future **fut8, Eina_Future **fut9, Eina_Future **fut10, Eina_Future **fut11, Eina_Future **fut12, Eina_Future **fut13, Eina_Iterator **ite1, Eina_Iterator **ite3, Eina_Iterator **ite4, Eina_Iterator **ite5, Eina_Iterator **ite6, Eina_Iterator **ite7, Eina_Iterator **ite8, Eina_Iterator **ite9, Eina_Iterator **ite10, Eina_Iterator **ite11, Eina_Iterator **ite12, Eina_Iterator **ite13)
420{ 423{
424 Test_D d = _test_generator_generate_complex((Eo*)obj, pd);
425#define COPY(FIELD) \
426 *(FIELD ## 1) = d.FIELD ## 1; \
427 /**(FIELD ## 2) = d.FIELD ## 2;*/ \
428 *(FIELD ## 3) = d.FIELD ## 3; \
429 *(FIELD ## 4) = d.FIELD ## 4; \
430 *(FIELD ## 5) = d.FIELD ## 5; \
431 *(FIELD ## 6) = d.FIELD ## 6; \
432 *(FIELD ## 7) = d.FIELD ## 7; \
433 *(FIELD ## 8) = d.FIELD ## 8; \
434 *(FIELD ## 9) = d.FIELD ## 9; \
435 *(FIELD ## 10) = d.FIELD ## 10; \
436 *(FIELD ## 11) = d.FIELD ## 11; \
437 *(FIELD ## 12) = d.FIELD ## 12; \
438 *(FIELD ## 13) = d.FIELD ## 13; \
439
440 COPY(acc)
441 COPY(arr)
442 COPY(fut)
443 COPY(ite)
444#undef COPY
445}
446
447static Eina_Bool
448_iterator_compare(Eina_Iterator *iter, Eina_Array *arr, Eina_Compare_Cb compare)
449{
450 unsigned int i = 0;
451 void *dat1, *dat2;
452
453 EINA_ITERATOR_FOREACH(iter, dat1)
454 {
455 dat2 = eina_array_data_get(arr, i);
456 if (!!compare(dat1, dat2))
457 {
458 printf("Error, item %d did not match! (%p, %p) %d %d %d\n", i, dat1, dat2, (int)((char*)dat1)[0], (int)((char*)dat2)[0], (int)'T');
459 return EINA_FALSE;
460 }
461 i++;
462 }
463 if (i != eina_array_count_get(arr)) {
464 printf("Error, length did not match! (%d vs. %d)\n", i, eina_array_count_get(arr));
465 return EINA_FALSE;
466 }
467 return EINA_TRUE;
468}
469
470static Eina_Bool
471_accessor_compare(Eina_Accessor *acc, Eina_Array *arr, Eina_Compare_Cb compare)
472{
473 unsigned int i = 0;
474 void *dat1, *dat2;
475
476 EINA_ACCESSOR_FOREACH(acc, i, dat1)
477 {
478 dat2 = eina_array_data_get(arr, i);
479 if (!!compare(dat1, dat2))
480 {
481 printf("Error, item %d did not match! (%p, %p) %d %d %d\n", i, dat1, dat2, (int)((char*)dat1)[0], (int)((char*)dat2)[0], (int)'T');
482 return EINA_FALSE;
483 }
484 }
485 if (i != eina_array_count_get(arr)) {
486 printf("Error, length did not match! (%d vs. %d)\n", i, eina_array_count_get(arr));
487 return EINA_FALSE;
488 }
489 return EINA_TRUE;
490}
491
492static int
493_value_compare(const int *a, const int *b)
494{
495 return *a - *b;
496}
497
498static int
499_binbuf_cmp(const Eina_Binbuf *b1, const Eina_Binbuf *b2)
500{
501 if (eina_binbuf_length_get(b1) != eina_binbuf_length_get(b2)) return -1;
502
503 Eina_Slice s1 = eina_binbuf_slice_get(b1);
504 Eina_Slice s2 = eina_binbuf_slice_get(b2);
505
506 return eina_slice_compare(s1, s2);
507}
508
509static int
510_strbuf_cmp(const Eina_Strbuf *b1, const Eina_Strbuf *b2)
511{
512 if (eina_strbuf_length_get(b1) != eina_strbuf_length_get(b2)) return -1;
421 513
514 Eina_Slice s1 = eina_strbuf_slice_get(b1);
515 Eina_Slice s2 = eina_strbuf_slice_get(b2);
516
517 return eina_slice_compare(s1, s2);
518}
519
520static int
521_slice_compare(const Eina_Slice *s1, const Eina_Slice *s2)
522{
523 return eina_slice_compare(*s1, *s2);
524}
525static int
526_rw_slice_compare(const Eina_Rw_Slice *s1, const Eina_Rw_Slice *s2)
527{
528
529 return eina_rw_slice_compare(*s1, *s2);
530}
531
532static Eina_Bool
533_verify_content(Test_D d)
534{
535#define FILL_EINA_ARRAY(carr, earr) \
536 Eina_Array *earr = eina_array_new(10); \
537 for (int i = 0; i < sizeof(carr)/sizeof(carr[0]); i++) eina_array_push(earr, carr + i);
538#define FILL_EINA_ARRAY_REF(carr, earr) \
539 Eina_Array *earr = eina_array_new(10); \
540 for (int i = 0; i < sizeof(carr)/sizeof(carr[0]); i++) eina_array_push(earr, carr[i]);
541
542 FILL_EINA_ARRAY(int_content, int_arr)
543
544 Eo* obj_content[] = {efl_new(TEST_TESTER_CLASS), efl_new(TEST_TESTER_CLASS), efl_new(TEST_TESTER_CLASS), efl_new(TEST_TESTER_CLASS), efl_new(TEST_TESTER_CLASS), efl_new(TEST_TESTER_CLASS), efl_new(TEST_TESTER_CLASS)};
545 FILL_EINA_ARRAY_REF(obj_content, obj_arr)
546
547 FILL_EINA_ARRAY(slice_content, slice_arr)
548
549 FILL_EINA_ARRAY(rw_slice_content, rw_slice_arr)
550
551 Eina_Value loc_value_content[5] = {eina_value_int_init(1),eina_value_int_init(2),eina_value_int_init(3),eina_value_int_init(5),eina_value_int_init(7)};
552 memcpy(&value_content, &loc_value_content, sizeof(value_content));
553 FILL_EINA_ARRAY(value_content, value_arr)
554
555 Eina_Value *value_ref_content[] = {eina_value_int_new(1),eina_value_int_new(2),eina_value_int_new(3),eina_value_int_new(5),eina_value_int_new(7)};
556 FILL_EINA_ARRAY_REF(value_ref_content, value_ref_arr)
557
558 Eina_Binbuf *binbuf_ref_content[] = {_binbuf_easy_new("Beer"), _binbuf_easy_new("Whine")};
559 FILL_EINA_ARRAY_REF(binbuf_ref_content, binbuf_arr)
560
561 Eina_Array *event_arr = eina_array_new(10);
562
563 const char *mstr_content[] = {"If", "I", "Walk", "Down", "500", "Miles"};
564 FILL_EINA_ARRAY_REF(mstr_content, mstr_arr)
565
566 const char *string_content[] = {"Tangerine", "Lemon", "Candy"};
567 FILL_EINA_ARRAY_REF(string_content, string_arr)
568
569 const char *stringshare_content[] = {eina_stringshare_add("Lässt"), eina_stringshare_add("nichts"), eina_stringshare_add("einbrennen")};
570 FILL_EINA_ARRAY_REF(stringshare_content, stringshare_arr)
571
572 Eina_Strbuf *strbuf_ref_content[] = {_strbuf_easy_new("xatr"), _strbuf_easy_new("Constfolding"), _strbuf_easy_new("Bitwidth")};
573 FILL_EINA_ARRAY_REF(strbuf_ref_content, strbuf_arr)
574
575#undef FILL_EINA_ARRAY
576#undef FILL_EINA_ARRAY_REF
577
578#define TEST(a, b, c) \
579 if (!_iterator_compare(a, b, (Eina_Compare_Cb) c)) \
580 { \
581 printf("Error while comparing iterator " #a " " #b ); \
582 return EINA_FALSE; \
583 } \
584
585 TEST(d.ite1, int_arr, _value_compare)
586 //TEST(d.ite2, int_content, _value_compare)
587 //FIXME no compare possible _iterator_compare(d.ite3, Eina_Array *arr, Eina_Compare_Cb compare)
588 TEST(d.ite4, slice_arr, (Eina_Compare_Cb) _slice_compare)
589 TEST(d.ite5, rw_slice_arr, (Eina_Compare_Cb) _rw_slice_compare)
590 //FIXME Broken compare if (!_iterator_compare(d.ite6, value_ref_arr, (Eina_Compare_Cb) eina_value_compare)) return EINA_FALSE;
591 //FIXME Broken compare if (!_iterator_compare(d.ite7, value_ref_arr, (Eina_Compare_Cb) eina_value_compare)) return EINA_FALSE;
592 TEST(d.ite8, binbuf_arr, (Eina_Compare_Cb) _binbuf_cmp)
593 TEST(d.ite10, mstr_arr, (Eina_Compare_Cb) strcmp)
594 TEST(d.ite11, string_arr, (Eina_Compare_Cb) strcmp)
595 TEST(d.ite12, stringshare_arr, (Eina_Compare_Cb) strcmp)
596 TEST(d.ite13, strbuf_arr, (Eina_Compare_Cb) _strbuf_cmp)
597
598#undef TEST
599#define TEST(a, b, c) \
600 if (!_accessor_compare(a, b, (Eina_Compare_Cb) c)) \
601 { \
602 printf("Error while comparing accessor " #a " " #b ); \
603 return EINA_FALSE; \
604 } \
605
606 TEST(d.acc1, int_arr, _value_compare)
607 //TEST(d.ite2, int_content, _value_compare)
608 //FIXME no compare possible _iterator_compare(d.acc3, Eina_Array *arr, Eina_Compare_Cb compare)
609 TEST(d.acc4, slice_arr, (Eina_Compare_Cb) _slice_compare)
610 TEST(d.acc5, rw_slice_arr, (Eina_Compare_Cb) _rw_slice_compare)
611 //FIXME Broken compare if (!_iterator_compare(d.acc6, value_ref_arr, (Eina_Compare_Cb) eina_value_compare)) return EINA_FALSE;
612 //FIXME Broken compare if (!_iterator_compare(d.acc7, value_ref_arr, (Eina_Compare_Cb) eina_value_compare)) return EINA_FALSE;
613 TEST(d.acc8, binbuf_arr, (Eina_Compare_Cb) _binbuf_cmp)
614 TEST(d.acc10, mstr_arr, (Eina_Compare_Cb) strcmp)
615 TEST(d.acc11, string_arr, (Eina_Compare_Cb) strcmp)
616 TEST(d.acc12, stringshare_arr, (Eina_Compare_Cb) strcmp)
617 TEST(d.acc13, strbuf_arr, (Eina_Compare_Cb) _strbuf_cmp)
618
619 return EINA_TRUE;
620}
621
622EOLIAN static Eina_Bool
623_test_generator_verify_complex(Eo *obj, Test_Generator_Data *pd, Test_D d)
624{
625 return _verify_content(d);
626}
627EOLIAN static Eina_Bool
628_test_generator_verify_complex2(Eo *obj, Test_Generator_Data *pd, Eina_Accessor *acc1, Eina_Accessor *acc3, Eina_Accessor *acc4, Eina_Accessor *acc5, Eina_Accessor *acc6, Eina_Accessor *acc7, Eina_Accessor *acc8, Eina_Accessor *acc9, Eina_Accessor *acc10, Eina_Accessor *acc11, Eina_Accessor *acc12, Eina_Accessor *acc13, Eina_Array *arr1, Eina_Array *arr3, Eina_Array *arr4, Eina_Array *arr5, Eina_Array *arr6, Eina_Array *arr7, Eina_Array *arr8, Eina_Array *arr9, Eina_Array *arr10, Eina_Array *arr11, Eina_Array *arr12, Eina_Array *arr13, Eina_Future *fut1, Eina_Future *fut3, Eina_Future *fut4, Eina_Future *fut5, Eina_Future *fut6, Eina_Future *fut7, Eina_Future *fut8, Eina_Future *fut9, Eina_Future *fut10, Eina_Future *fut11, Eina_Future *fut12, Eina_Future *fut13, Eina_Iterator *ite1, Eina_Iterator *ite3, Eina_Iterator *ite4, Eina_Iterator *ite5, Eina_Iterator *ite6, Eina_Iterator *ite7, Eina_Iterator *ite8, Eina_Iterator *ite9, Eina_Iterator *ite10, Eina_Iterator *ite11, Eina_Iterator *ite12, Eina_Iterator *ite13)
629{
630 Test_D d;
631#define COPY(FIELD) \
632 d.FIELD ## 1 = FIELD ## 1; \
633 /*d.FIELD ## 2 = FIELD ## 2;*/ \
634 d.FIELD ## 3 = FIELD ## 3; \
635 d.FIELD ## 4 = FIELD ## 4; \
636 d.FIELD ## 5 = FIELD ## 5; \
637 d.FIELD ## 6 = FIELD ## 6; \
638 d.FIELD ## 7 = FIELD ## 7; \
639 d.FIELD ## 8 = FIELD ## 8; \
640 d.FIELD ## 9 = FIELD ## 9; \
641 d.FIELD ## 10 = FIELD ## 10; \
642 d.FIELD ## 11 = FIELD ## 11; \
643 d.FIELD ## 12 = FIELD ## 12; \
644 d.FIELD ## 13 = FIELD ## 13; \
645
646 COPY(acc)
647 COPY(arr)
648 COPY(fut)
649 COPY(ite)
650#undef COPY
651 return _verify_content(d);
422} 652}
423 653
424 654
diff --git a/general-test/test_generator.eo b/general-test/test_generator.eo
index 97eb508..51789dd 100644
--- a/general-test/test_generator.eo
+++ b/general-test/test_generator.eo
@@ -322,6 +322,12 @@ class Test.Generator extends Efl.Object {
322 generate_complex { 322 generate_complex {
323 return : Test.D; 323 return : Test.D;
324 } 324 }
325 verify_complex {
326 params {
327 d : Test.D;
328 }
329 return : bool;
330 }
325 @property generate_complex2 { 331 @property generate_complex2 {
326 get { 332 get {
327 333
@@ -384,5 +390,65 @@ class Test.Generator extends Efl.Object {
384 ite13: iterator<strbuf>; 390 ite13: iterator<strbuf>;
385 } 391 }
386 } 392 }
393 verify_complex2 {
394 params {
395 acc1 : accessor<int>;
396 //acc2 : accessor<Test.A>;
397 acc3 : accessor<Test.Tester>;
398 acc4 : accessor<slice<ubyte>>;
399 acc5 : accessor<rw_slice<ubyte>>;
400 acc6 : accessor<any_value>;
401 acc7 : accessor<any_value_ref>;
402 acc8 : accessor<binbuf>;
403 acc9 : accessor<event>;
404 acc10: accessor<mstring>;
405 acc11: accessor<string>;
406 acc12: accessor<stringshare>;
407 acc13: accessor<strbuf>;
408
409 arr1 : array<int>;
410 //arr2 : array<Test.A>;
411 arr3 : array<Test.Tester>;
412 arr4 : array<slice<ubyte>>;
413 arr5 : array<rw_slice<ubyte>>;
414 arr6 : array<any_value>;
415 arr7 : array<any_value_ref>;
416 arr8 : array<binbuf>;
417 arr9 : array<event>;
418 arr10: array<mstring>;
419 arr11: array<string>;
420 arr12: array<stringshare>;
421 arr13: array<strbuf>;
422
423 fut1 : future<int>;
424 //fut2 : future<Test.A>;
425 fut3 : future<Test.Tester>;
426 fut4 : future<slice<ubyte>>;
427 fut5 : future<rw_slice<ubyte>>;
428 fut6 : future<any_value>;
429 fut7 : future<any_value_ref>;
430 fut8 : future<binbuf>;
431 fut9 : future<event>;
432 fut10: future<mstring>;
433 fut11: future<string>;
434 fut12: future<stringshare>;
435 fut13: future<strbuf>;
436
437 ite1 : iterator<int>;
438 //ite2 : iterator<Test.A>;
439 ite3 : iterator<Test.Tester>;
440 ite4 : iterator<slice<ubyte>>;
441 ite5 : iterator<rw_slice<ubyte>>;
442 ite6 : iterator<any_value>;
443 ite7 : iterator<any_value_ref>;
444 ite8 : iterator<binbuf>;
445 ite9 : iterator<event>;
446 ite10: iterator<mstring>;
447 ite11: iterator<string>;
448 ite12: iterator<stringshare>;
449 ite13: iterator<strbuf>;
450 }
451 return : bool;
452 }
387 } 453 }
388} 454}
diff --git a/java/compatibility_tests/tests/CompatibilityTests.java b/java/compatibility_tests/tests/CompatibilityTests.java
index db9280d..9a9ce3f 100644
--- a/java/compatibility_tests/tests/CompatibilityTests.java
+++ b/java/compatibility_tests/tests/CompatibilityTests.java
@@ -16,7 +16,6 @@ import org.junit.Test;
16import efl.bindings.Application; 16import efl.bindings.Application;
17import efl.bindings.ApplicationConfig; 17import efl.bindings.ApplicationConfig;
18import efl.bindings.Binbuf; 18import efl.bindings.Binbuf;
19import efl.bindings.Event;
20import efl.bindings.RwSlice; 19import efl.bindings.RwSlice;
21import efl.bindings.Slice; 20import efl.bindings.Slice;
22import efl.bindings.Strbuf; 21import efl.bindings.Strbuf;
@@ -27,9 +26,14 @@ import test.B;
27import test.C; 26import test.C;
28import test.D; 27import test.D;
29import test.Generator; 28import test.Generator;
29import test.Generator.GenerateComplex2Property;
30import test.Generator.GenerateElements2Property; 30import test.Generator.GenerateElements2Property;
31 31
32class TestApplication extends Application { 32class TestApplication extends Application {
33 public TestApplication() {
34
35 }
36
33 @Override 37 @Override
34 public void run() { 38 public void run() {
35 39
@@ -48,6 +52,10 @@ class TestApplication extends Application {
48public class CompatibilityTests { 52public class CompatibilityTests {
49 private TestApplication t; 53 private TestApplication t;
50 54
55 public CompatibilityTests() {
56
57 }
58
51 @Before 59 @Before
52 public void BuiltUp() { 60 public void BuiltUp() {
53 t = new TestApplication(); 61 t = new TestApplication();
@@ -58,7 +66,9 @@ public class CompatibilityTests {
58 public void DragDown() { 66 public void DragDown() {
59 t.dragDown(); 67 t.dragDown();
60 t = null; 68 t = null;
61 System.gc(); 69 System.gc(); // yes, we are gargabe collecting *after* the app has been draged down. This was
70 // we can ensure that everything is protected to references trying to be freed
71 // after eina is shutted down
62 } 72 }
63 73
64 @Test 74 @Test
@@ -66,6 +76,7 @@ public class CompatibilityTests {
66 Generator g = new Generator(); 76 Generator g = new Generator();
67 A a = g.getAInstance(); 77 A a = g.getAInstance();
68 assertTrue(g.verifyAInstance(a)); 78 assertTrue(g.verifyAInstance(a));
79 System.gc();
69 } 80 }
70 81
71 @Test 82 @Test
@@ -245,23 +256,24 @@ public class CompatibilityTests {
245 new Strbuf("Once upon a midnight dreary, while I pondered, weak and weary,"))); 256 new Strbuf("Once upon a midnight dreary, while I pondered, weak and weary,")));
246 System.gc(); 257 System.gc();
247 } 258 }
248 259
249 public void printIterator(Iterator i) { 260 public void printIterator(Iterator i) {
250 for (Iterator iterator = i; iterator.hasNext();) { 261 for (Iterator iterator = i; iterator.hasNext();) {
251 Object type = iterator.next(); 262 Object type = iterator.next();
252 System.out.println("HIT "+type.toString()); 263 System.out.println("HIT " + type.toString());
253 } 264 }
254 } 265 }
266
255 public <T> boolean assertIteratorEquals(Iterator<T> i1, Iterator<T> i2) { 267 public <T> boolean assertIteratorEquals(Iterator<T> i1, Iterator<T> i2) {
256 ArrayList<T> list = new ArrayList<T>(); 268 ArrayList<T> list = new ArrayList<T>();
257 for (; i1.hasNext();) { 269 for (; i1.hasNext();) {
258 list.add(i1.next()); 270 list.add(i1.next());
259 } 271 }
260 for(; i2.hasNext();) { 272 for (; i2.hasNext();) {
261 T t = i2.next(); 273 T t = i2.next();
262 if (!list.get(0).equals(t)) { 274 if (!list.get(0).equals(t)) {
263 System.out.println("A: "+t); 275 System.out.println("A: " + t);
264 System.out.println("B: "+list.get(0)); 276 System.out.println("B: " + list.get(0));
265 assertTrue(false); 277 assertTrue(false);
266 } 278 }
267 assertTrue(list.get(0).equals(t)); 279 assertTrue(list.get(0).equals(t));
@@ -270,9 +282,10 @@ public class CompatibilityTests {
270 assertTrue(list.isEmpty()); 282 assertTrue(list.isEmpty());
271 return true; 283 return true;
272 } 284 }
285
273 public <T> boolean assertIntegerLength(Iterator<T> i1, int length) { 286 public <T> boolean assertIntegerLength(Iterator<T> i1, int length) {
274 int i = 0; 287 int i = 0;
275 for(; i1.hasNext();) { 288 for (; i1.hasNext();) {
276 T t = i1.next(); 289 T t = i1.next();
277 i++; 290 i++;
278 assertNotNull(t); 291 assertNotNull(t);
@@ -281,46 +294,203 @@ public class CompatibilityTests {
281 return true; 294 return true;
282 } 295 }
283 296
284 @Test 297 public ComplexTestContext generateComplexTestContext() {
285 public void VerifyComplex() { 298 Integer[] int_content = { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(5),
286 Integer[] int_content = {Integer.valueOf(1),Integer.valueOf(2),Integer.valueOf(3),Integer.valueOf(5),Integer.valueOf(7)}; 299 Integer.valueOf(7) };
287 List<Slice> slice_content = Arrays.asList(new Slice<Byte>("Testos".getBytes()), new Slice<Byte>("Testos2".getBytes())); 300 List<Slice> slice_content = Arrays.asList(new Slice<Byte>("Testos".getBytes()),
288 List<RwSlice> slice_rw_content = Arrays.asList(new RwSlice<Byte>("Testaa".getBytes()), new RwSlice<Byte>("Testaarata".getBytes())); 301 new Slice<Byte>("Testos2".getBytes()));
302 List<RwSlice> slice_rw_content = Arrays.asList(new RwSlice<Byte>("Testaa".getBytes()),
303 new RwSlice<Byte>("Testaarata".getBytes()));
289 List<Value> value_content = Arrays.asList(new Value(1), new Value(2), new Value(3), new Value(5), new Value(7)); 304 List<Value> value_content = Arrays.asList(new Value(1), new Value(2), new Value(3), new Value(5), new Value(7));
290 List<ValueReference> valueref_content = Arrays.asList(new ValueReference(), new ValueReference(), new ValueReference(), new ValueReference(), new ValueReference()); 305 List<ValueReference> valueref_content = new ArrayList<ValueReference>();
306 for (Value value : value_content) {
307 valueref_content.add(ValueReference.fromValue(value));
308 }
291 List<Binbuf> value_binbuf = Arrays.asList(new Binbuf("Beer".getBytes()), new Binbuf("Whine".getBytes())); 309 List<Binbuf> value_binbuf = Arrays.asList(new Binbuf("Beer".getBytes()), new Binbuf("Whine".getBytes()));
292 List<String> value_mstring = Arrays.asList("If", "I", "Walk", "Down", "500", "Miles"); 310 List<String> value_mstring = Arrays.asList("If", "I", "Walk", "Down", "500", "Miles");
293 List<String> value_string = Arrays.asList("Tangerine", "Lemon", "Candy"); 311 List<String> value_string = Arrays.asList("Tangerine", "Lemon", "Candy");
294 List<String> value_stringshare = Arrays.asList("Lässt", "nichts", "einbrennen"); 312 List<String> value_stringshare = Arrays.asList("Lässt", "nichts", "einbrennen");
295 List<Strbuf> value_strbuf = Arrays.asList(new Strbuf("xatr"), new Strbuf("Constfolding"), new Strbuf("Bitwidth")); 313 List<Strbuf> value_strbuf = Arrays.asList(new Strbuf("xatr"), new Strbuf("Constfolding"),
314 new Strbuf("Bitwidth"));
315
316 return new ComplexTestContext(int_content, slice_content, slice_rw_content, value_content, valueref_content,
317 value_binbuf, value_mstring, value_string, value_stringshare, value_strbuf);
318 }
296 319
320 public void verifyComplex(java.lang.Iterable<Integer> acc1, java.lang.Iterable<test.Tester> acc3,
321 java.lang.Iterable<efl.bindings.Slice> acc4, java.lang.Iterable<efl.bindings.RwSlice> acc5,
322 java.lang.Iterable<efl.bindings.Value> acc6, java.lang.Iterable<efl.bindings.ValueReference> acc7,
323 java.lang.Iterable<efl.bindings.Binbuf> acc8, java.lang.Iterable<efl.bindings.NativeEvent> acc9,
324 java.lang.Iterable<String> acc10, java.lang.Iterable<String> acc11, java.lang.Iterable<String> acc12,
325 java.lang.Iterable<efl.bindings.Strbuf> acc13, java.util.List<Integer> arr1,
326 java.util.List<test.Tester> arr3, java.util.List<efl.bindings.Slice> arr4,
327 java.util.List<efl.bindings.RwSlice> arr5, java.util.List<efl.bindings.Value> arr6,
328 java.util.List<efl.bindings.ValueReference> arr7, java.util.List<efl.bindings.Binbuf> arr8,
329 java.util.List<efl.bindings.NativeEvent> arr9, java.util.List<String> arr10, java.util.List<String> arr11,
330 java.util.List<String> arr12, java.util.List<efl.bindings.Strbuf> arr13,
331 java.util.concurrent.Future<Integer> fut1, java.util.concurrent.Future<test.Tester> fut3,
332 java.util.concurrent.Future<efl.bindings.Slice> fut4,
333 java.util.concurrent.Future<efl.bindings.RwSlice> fut5,
334 java.util.concurrent.Future<efl.bindings.Value> fut6,
335 java.util.concurrent.Future<efl.bindings.ValueReference> fut7,
336 java.util.concurrent.Future<efl.bindings.Binbuf> fut8,
337 java.util.concurrent.Future<efl.bindings.NativeEvent> fut9, java.util.concurrent.Future<String> fut10,
338 java.util.concurrent.Future<String> fut11, java.util.concurrent.Future<String> fut12,
339 java.util.concurrent.Future<efl.bindings.Strbuf> fut13, java.util.Iterator<Integer> ite1,
340 java.util.Iterator<test.Tester> ite3, java.util.Iterator<efl.bindings.Slice> ite4,
341 java.util.Iterator<efl.bindings.RwSlice> ite5, java.util.Iterator<efl.bindings.Value> ite6,
342 java.util.Iterator<efl.bindings.ValueReference> ite7, java.util.Iterator<efl.bindings.Binbuf> ite8,
343 java.util.Iterator<efl.bindings.NativeEvent> ite9, java.util.Iterator<String> ite10,
344 java.util.Iterator<String> ite11, java.util.Iterator<String> ite12,
345 java.util.Iterator<efl.bindings.Strbuf> ite13) {
346 ComplexTestContext ctx = generateComplexTestContext();
347
348 assertTrue(assertIteratorEquals(ite1, Arrays.asList(ctx.int_content).iterator()));
349 // assertTrue(assertIteratorEquals(d.getIte2(),
350 // Arrays.asList(int_content).iterator()));
351 assertTrue(assertIntegerLength(ite3, 7));
352 assertTrue(assertIteratorEquals(ite4, ctx.slice_content.iterator()));
353 assertTrue(assertIteratorEquals(ite5, ctx.slice_rw_content.iterator()));
354 // FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(ite6,
355 // value_content.iterator()));
356 // FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(ite7,
357 // value_content.iterator()));
358 assertTrue(assertIteratorEquals(ite8, ctx.value_binbuf.iterator()));
359 // FIXME event is ... crazy printIterator(ite9);
360 assertTrue(assertIteratorEquals(ite10, ctx.value_mstring.iterator()));
361 assertTrue(assertIteratorEquals(ite11, ctx.value_string.iterator()));
362 assertTrue(assertIteratorEquals(ite12, ctx.value_stringshare.iterator()));
363 assertTrue(assertIteratorEquals(ite13, ctx.value_strbuf.iterator()));
364 // FIXME array & future
365 assertTrue(assertIteratorEquals(acc1.iterator(), Arrays.asList(ctx.int_content).iterator()));
366 // assertTrue(assertIteratorEquals(arr2.iterator(),
367 // Arrays.asList(int_content).iterator()));
368 assertTrue(assertIntegerLength(acc3.iterator(), 7));
369 assertTrue(assertIteratorEquals(acc4.iterator(), ctx.slice_content.iterator()));
370 assertTrue(assertIteratorEquals(acc5.iterator(), ctx.slice_rw_content.iterator()));
371 // FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(acc6,
372 // value_content.iterator()));
373 // FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(acc7,
374 // valueref_content.iterator()));
375 assertTrue(assertIteratorEquals(acc8.iterator(), ctx.value_binbuf.iterator()));
376 // FIXME event is ... crazy printIterator(acc9);
377 assertTrue(assertIteratorEquals(acc10.iterator(), ctx.value_mstring.iterator()));
378 assertTrue(assertIteratorEquals(acc11.iterator(), ctx.value_string.iterator()));
379 assertTrue(assertIteratorEquals(acc12.iterator(), ctx.value_stringshare.iterator()));
380 assertTrue(assertIteratorEquals(acc13.iterator(), ctx.value_strbuf.iterator()));
381 }
382
383 @Test
384 public void VerifyComplex() {
297 Generator g = new Generator(); 385 Generator g = new Generator();
298 D d = g.generateComplex(); 386 D d = g.generateComplex();
299 assertTrue(assertIteratorEquals(d.getIte1(), Arrays.asList(int_content).iterator())); 387 verifyComplex(d.getAcc1(), d.getAcc3(), d.getAcc4(), d.getAcc5(), d.getAcc6(), d.getAcc7(), d.getAcc8(),
300 //assertTrue(assertIteratorEquals(d.getIte2(), Arrays.asList(int_content).iterator())); 388 d.getAcc9(), d.getAcc10(), d.getAcc11(), d.getAcc12(), d.getAcc13(), d.getArr1(), d.getArr3(),
301 assertTrue(assertIntegerLength(d.getIte3(), 7)); 389 d.getArr4(), d.getArr5(), d.getArr6(), d.getArr7(), d.getArr8(), d.getArr9(), d.getArr10(),
302 assertTrue(assertIteratorEquals(d.getIte4(), slice_content.iterator())); 390 d.getArr11(), d.getArr12(), d.getArr13(), d.getFut1(), d.getFut3(), d.getFut4(), d.getFut5(),
303 assertTrue(assertIteratorEquals(d.getIte5(), slice_rw_content.iterator())); 391 d.getFut6(), d.getFut7(), d.getFut8(), d.getFut9(), d.getFut10(), d.getFut11(), d.getFut12(),
304 //FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(d.getIte6(), value_content.iterator())); 392 d.getFut13(), d.getIte1(), d.getIte3(), d.getIte4(), d.getIte5(), d.getIte6(), d.getIte7(), d.getIte8(),
305 //FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(d.getIte7(), value_content.iterator())); 393 d.getIte9(), d.getIte10(), d.getIte11(), d.getIte12(), d.getIte13());
306 assertTrue(assertIteratorEquals(d.getIte8(), value_binbuf.iterator()));
307 //FIXME event is ... crazy printIterator(d.getIte9());
308 assertTrue(assertIteratorEquals(d.getIte10(), value_mstring.iterator()));
309 assertTrue(assertIteratorEquals(d.getIte11(), value_string.iterator()));
310 assertTrue(assertIteratorEquals(d.getIte12(), value_stringshare.iterator()));
311 assertTrue(assertIteratorEquals(d.getIte13(), value_strbuf.iterator()));
312 assertTrue(assertIteratorEquals(d.getAcc1().iterator(), Arrays.asList(int_content).iterator()));
313 //assertTrue(assertIteratorEquals(d.getIte2(), Arrays.asList(int_content).iterator()));
314 assertTrue(assertIntegerLength(d.getAcc3().iterator(), 7));
315 assertTrue(assertIteratorEquals(d.getAcc4().iterator(), slice_content.iterator()));
316 assertTrue(assertIteratorEquals(d.getAcc5().iterator(), slice_rw_content.iterator()));
317 //FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(d.getIte6(), value_content.iterator()));
318 //FIXME eina_value_compare does not work assertTrue(assertIteratorEquals(d.getIte7(), value_content.iterator()));
319 assertTrue(assertIteratorEquals(d.getAcc8().iterator(), value_binbuf.iterator()));
320 //FIXME event is ... crazy printIterator(d.getIte9());
321 assertTrue(assertIteratorEquals(d.getAcc10().iterator(), value_mstring.iterator()));
322 assertTrue(assertIteratorEquals(d.getAcc11().iterator(), value_string.iterator()));
323 assertTrue(assertIteratorEquals(d.getAcc12().iterator(), value_stringshare.iterator()));
324 assertTrue(assertIteratorEquals(d.getAcc13().iterator(), value_strbuf.iterator()));
325 } 394 }
395
396 @Test
397 public void VerifyComplex2() {
398 Generator g = new Generator();
399 GenerateComplex2Property d = g.getGenerateComplex2();
400 verifyComplex(d.getAcc1(), d.getAcc3(), d.getAcc4(), d.getAcc5(), d.getAcc6(), d.getAcc7(), d.getAcc8(),
401 d.getAcc9(), d.getAcc10(), d.getAcc11(), d.getAcc12(), d.getAcc13(), d.getArr1(), d.getArr3(),
402 d.getArr4(), d.getArr5(), d.getArr6(), d.getArr7(), d.getArr8(), d.getArr9(), d.getArr10(),
403 d.getArr11(), d.getArr12(), d.getArr13(), d.getFut1(), d.getFut3(), d.getFut4(), d.getFut5(),
404 d.getFut6(), d.getFut7(), d.getFut8(), d.getFut9(), d.getFut10(), d.getFut11(), d.getFut12(),
405 d.getFut13(), d.getIte1(), d.getIte3(), d.getIte4(), d.getIte5(), d.getIte6(), d.getIte7(), d.getIte8(),
406 d.getIte9(), d.getIte10(), d.getIte11(), d.getIte12(), d.getIte13());
407 }
408
409 @Test
410 public void GenerateComplex() {
411 Generator g = new Generator();
412 ComplexTestContext ctx = generateComplexTestContext();
413 boolean b = g.verifyComplex(new D(Arrays.asList(ctx.int_content), null, ctx.slice_content, ctx.slice_rw_content,
414 ctx.value_content, ctx.valueref_content, ctx.value_binbuf, null, ctx.value_mstring, ctx.value_string,
415 ctx.value_stringshare, ctx.value_strbuf, null, null, null, null, null, null, null, null, null, null,
416 null, null, null, null, null, null, null, null, null, null, null, null, null, null,
417 Arrays.asList(ctx.int_content).iterator(), null, ctx.slice_content.iterator(),
418 ctx.slice_rw_content.iterator(), ctx.value_content.iterator(), ctx.valueref_content.iterator(),
419 ctx.value_binbuf.iterator(), null, ctx.value_mstring.iterator(), ctx.value_string.iterator(),
420 ctx.value_stringshare.iterator(), ctx.value_strbuf.iterator()));
421 assertTrue(b);
422
423 }
424
425}
426
427class ComplexTestContext {
428 public Integer[] int_content;
429 public List<Slice> slice_content;
430 public List<RwSlice> slice_rw_content;
431 public List<Value> value_content;
432 public List<ValueReference> valueref_content;
433 public List<Binbuf> value_binbuf;
434 public List<String> value_mstring;
435 public List<String> value_string;
436 public List<String> value_stringshare;
437 public List<Strbuf> value_strbuf;
438
439 public ComplexTestContext(Integer[] int_content, List<Slice> slice_content, List<RwSlice> slice_rw_content,
440 List<Value> value_content, List<ValueReference> valueref_content, List<Binbuf> value_binbuf,
441 List<String> value_mstring, List<String> value_string, List<String> value_stringshare,
442 List<Strbuf> value_strbuf) {
443 super();
444 this.int_content = int_content;
445 this.slice_content = slice_content;
446 this.slice_rw_content = slice_rw_content;
447 this.value_content = value_content;
448 this.valueref_content = valueref_content;
449 this.value_binbuf = value_binbuf;
450 this.value_mstring = value_mstring;
451 this.value_string = value_string;
452 this.value_stringshare = value_stringshare;
453 this.value_strbuf = value_strbuf;
454 }
455
456 public Integer[] getInt_content() {
457 return int_content;
458 }
459
460 public List<Slice> getSlice_content() {
461 return slice_content;
462 }
463
464 public List<RwSlice> getSlice_rw_content() {
465 return slice_rw_content;
466 }
467
468 public List<Value> getValue_content() {
469 return value_content;
470 }
471
472 public List<ValueReference> getValueref_content() {
473 return valueref_content;
474 }
475
476 public List<Binbuf> getValue_binbuf() {
477 return value_binbuf;
478 }
479
480 public List<String> getValue_mstring() {
481 return value_mstring;
482 }
483
484 public List<String> getValue_string() {
485 return value_string;
486 }
487
488 public List<String> getValue_stringshare() {
489 return value_stringshare;
490 }
491
492 public List<Strbuf> getValue_strbuf() {
493 return value_strbuf;
494 }
495
326} 496}
diff --git a/java/generator_jni.c b/java/generator_jni.c
index 613f302..961afc7 100644
--- a/java/generator_jni.c
+++ b/java/generator_jni.c
@@ -84,6 +84,32 @@ _fetch_convert_func_native_to_jni(Eina_Strbuf *buf, const Eolian_Type *type, con
84} 84}
85 85
86static const char* 86static const char*
87_strip(const char *res){
88 if (res && res[0] != '\0') {
89 size_t len = strlen(res);
90 char *res2 = _java_generator_strdup(res);
91 if (res2[len - 1] == ' ')
92 res2[len - 1] = '\0';
93 return res2;
94 } else {
95 return res;
96 }
97}
98static const char*
99_first_capital_strip(const char *res){
100 if (res && res[0] != '\0') {
101 size_t len = strlen(res);
102 char *res2 = (char*)_strip(res);
103 res2[0] = toupper(res2[0]);
104 if (res2[len - 1] == ' ')
105 res2[len - 1] = '\0';
106 return res2;
107 } else {
108 return res;
109 }
110}
111
112static const char*
87_fetch_convert_func_jni_to_native(Eina_Strbuf *buf, const Eolian_Type *type, const char* entity, const char *field_entity, const char *param_entity) 113_fetch_convert_func_jni_to_native(Eina_Strbuf *buf, const Eolian_Type *type, const char* entity, const char *field_entity, const char *param_entity)
88{ 114{
89 Eina_Strbuf *api_name; 115 Eina_Strbuf *api_name;
@@ -105,16 +131,18 @@ _fetch_convert_func_jni_to_native(Eina_Strbuf *buf, const Eolian_Type *type, con
105 eina_strbuf_append_printf(buf, "%s(JNIEnv *jenv, jobject rdata) {\n", eina_strbuf_string_get(api_name)); 131 eina_strbuf_append_printf(buf, "%s(JNIEnv *jenv, jobject rdata) {\n", eina_strbuf_string_get(api_name));
106 if ((bt >= EOLIAN_TYPE_BUILTIN_BYTE && bt <= EOLIAN_TYPE_BUILTIN_BOOL)) 132 if ((bt >= EOLIAN_TYPE_BUILTIN_BYTE && bt <= EOLIAN_TYPE_BUILTIN_BOOL))
107 { 133 {
108 eina_strbuf_append_printf(buf, " %s data = 0;\n", _get_jni_type(subtype)); //FIXME this is wrong so far we need to fetch the value from the rdata object 134 eina_strbuf_append_printf(buf, " jclass klass = (*jenv)->FindClass(jenv, \"java/lang/%s\");\n", _strip(_add_java_type_expressive(subtype, EINA_TRUE)));
135 eina_strbuf_append_printf(buf, " jmethodID meth = (*jenv)->GetMethodID(jenv, klass, \"%sValue\", \"()%s\");\n", _strip(_add_java_type_expressive(subtype, EINA_FALSE)), _get_jni_string_type(subtype));
136 eina_strbuf_append_printf(buf, " %s data = (*jenv)->Call%sMethod(jenv, rdata, meth);\n", _get_jni_type(subtype), _first_capital_strip(_add_java_type_expressive(subtype, EINA_FALSE)));
109 } 137 }
110 else 138 else
111 { 139 {
112 eina_strbuf_append_printf(buf, " jobject data = rdata;\n"); 140 eina_strbuf_append_printf(buf, " jobject data = rdata;\n");
113 } 141 }
114 if (decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_STRUCT) 142 if (decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_STRUCT)
115 eina_strbuf_append_printf(buf, "%s *ret;\n", eolian_type_c_type_get(subtype)); 143 eina_strbuf_append_printf(buf, " %s *ret;\n", eolian_type_c_type_get(subtype));
116 else 144 else
117 eina_strbuf_append_printf(buf, "%s ret;\n", eolian_type_c_type_get(subtype)); 145 eina_strbuf_append_printf(buf, " %s ret;\n", eolian_type_c_type_get(subtype));
118 if (requires_convert_func(subtype)) 146 if (requires_convert_func(subtype))
119 { 147 {
120 eina_strbuf_append_printf(buf, " %s(jenv, data, ret, %s);\n", _get_jni_to_native_converter(subtype, EINA_TRUE) , convert); 148 eina_strbuf_append_printf(buf, " %s(jenv, data, ret, %s);\n", _get_jni_to_native_converter(subtype, EINA_TRUE) , convert);
diff --git a/java/jni-bindings.c b/java/jni-bindings.c
index 0be14f9..c19b915 100644
--- a/java/jni-bindings.c
+++ b/java/jni-bindings.c
@@ -7,6 +7,7 @@
7#include <Efl_Ui.h> 7#include <Efl_Ui.h>
8#include <Efl_Canvas_Wl.h> 8#include <Efl_Canvas_Wl.h>
9 9
10Eina_Bool _app_running;
10static int initialized = 0; 11static int initialized = 0;
11jclass eventClass; 12jclass eventClass;
12jclass nativeCaller; 13jclass nativeCaller;
@@ -263,12 +264,14 @@ _fetch_event_ref(JNIEnv *env, Eo *obj, jobject local_event, const Efl_Event_Desc
263JNIEXPORT jint 264JNIEXPORT jint
264Java_efl_bindings_Application_init(JNIEnv *env, jclass jobj) 265Java_efl_bindings_Application_init(JNIEnv *env, jclass jobj)
265{ 266{
267 _app_running = EINA_TRUE;
266 return elm_init(0, NULL); 268 return elm_init(0, NULL);
267} 269}
268 270
269JNIEXPORT jint 271JNIEXPORT jint
270Java_efl_bindings_Application_shutdown(JNIEnv *env, jclass jobj) 272Java_efl_bindings_Application_shutdown(JNIEnv *env, jclass jobj)
271{ 273{
274 _app_running = EINA_FALSE;
272 return elm_shutdown(); 275 return elm_shutdown();
273} 276}
274 277
diff --git a/java/jni-bindings.h b/java/jni-bindings.h
index bea3b30..2d3531c 100644
--- a/java/jni-bindings.h
+++ b/java/jni-bindings.h
@@ -23,6 +23,7 @@ extern jmethodID setNativeAddress;
23extern jmethodID getNativeAddress; 23extern jmethodID getNativeAddress;
24extern jfieldID nativeAddress; 24extern jfieldID nativeAddress;
25extern JavaVM *jvm; 25extern JavaVM *jvm;
26extern Eina_Bool _app_running;
26 27
27#define UNUSED_FUNCTION(x) __attribute__((__unused__)) x 28#define UNUSED_FUNCTION(x) __attribute__((__unused__)) x
28 29
@@ -78,6 +79,7 @@ jobject _jobject_from_eina_future(JNIEnv *env, const Eina_Future *original, Iter
78Eina_Array* _eina_array_from_jobject(JNIEnv *env, jobject jobj, Iterator_Map_To_Native map); 79Eina_Array* _eina_array_from_jobject(JNIEnv *env, jobject jobj, Iterator_Map_To_Native map);
79jobject _jobject_from_eina_array(JNIEnv *env, const Eina_Array *original, Iterator_Map_To_JObject map); 80jobject _jobject_from_eina_array(JNIEnv *env, const Eina_Array *original, Iterator_Map_To_JObject map);
80 81
82void _fill_eina_array_with_iterator(JNIEnv *env, Iterator_Map_To_Native map, Eina_Array *cache, jobject jobj);
81 83
82#include "jni-bindings-struct-fetch.h" 84#include "jni-bindings-struct-fetch.h"
83#include "jni-bindings-jni-to-native.h" 85#include "jni-bindings-jni-to-native.h"
diff --git a/java/manual-bindings/ValueReference.java b/java/manual-bindings/ValueReference.java
index c4e769c..da4d61e 100644
--- a/java/manual-bindings/ValueReference.java
+++ b/java/manual-bindings/ValueReference.java
@@ -4,7 +4,7 @@
4public class ValueReference extends NativeCaller { 4public class ValueReference extends NativeCaller {
5 /** 5 /**
6 * Fetch the value representation from the reference and get the object 6 * Fetch the value representation from the reference and get the object
7 * 7 *
8 * @return The Value object that is represented by this value. 8 * @return The Value object that is represented by this value.
9 */ 9 */
10 public native Value fetchValue(); 10 public native Value fetchValue();
diff --git a/java/manual-bindings/binbuf.c b/java/manual-bindings/binbuf.c
index 28788bf..a88a4fa 100644
--- a/java/manual-bindings/binbuf.c
+++ b/java/manual-bindings/binbuf.c
@@ -35,7 +35,8 @@ JNIEXPORT void JNICALL
35Java_efl_bindings_Binbuf_freeMemory(JNIEnv *env, jobject obj) 35Java_efl_bindings_Binbuf_freeMemory(JNIEnv *env, jobject obj)
36{ 36{
37 Eina_Binbuf *buf = _fetch_opaque_struct_from_jobject(env, obj); 37 Eina_Binbuf *buf = _fetch_opaque_struct_from_jobject(env, obj);
38 eina_binbuf_free(buf); 38 if (_app_running)
39 eina_binbuf_free(buf);
39} 40}
40 41
41JNIEXPORT int JNICALL 42JNIEXPORT int JNICALL
diff --git a/java/manual-bindings/eflaccessor.c b/java/manual-bindings/eflaccessor.c
index 0be7e0b..af8b228 100644
--- a/java/manual-bindings/eflaccessor.c
+++ b/java/manual-bindings/eflaccessor.c
@@ -1,9 +1,56 @@
1#include "jni-bindings.h" 1#include "jni-bindings.h"
2 2
3typedef struct {
4 Eina_Accessor obj;
5 Eina_Array cache;
6} Eina_Accessor_From_Jobject;
7
8static void*
9_jobj_acc_container(Eina_Accessor_From_Jobject *obj)
10{
11 return &obj->cache;
12}
13
14static Eina_Bool
15_jobj_acc_get_at(Eina_Accessor_From_Jobject *obj, unsigned int idx, void **data)
16{
17 if (idx < eina_array_count(&obj->cache))
18 {
19 *data = eina_array_data_get(&obj->cache, idx);
20 return EINA_TRUE;
21 }
22 else
23 {
24 return EINA_FALSE;
25 }
26}
27
28static void
29_jobj_acc_free(Eina_Accessor_From_Jobject *obj)
30{
31 eina_array_flush(&obj->cache);
32 free(obj);
33}
34
3Eina_Accessor* 35Eina_Accessor*
4_eina_accessor_from_jobject(JNIEnv *env, jobject jobj, Iterator_Map_To_Native map) 36_eina_accessor_from_jobject(JNIEnv *env, jobject jobj, Iterator_Map_To_Native map)
5{ 37{
6 return NULL; 38 if (!jobj) return NULL;
39 jclass iterKlass = (*env)->FindClass(env, "java/lang/Iterable");
40 jmethodID iterator = (*env)->GetMethodID(env, iterKlass, "iterator", "()Ljava/util/Iterator;");
41 jobject iterator_obj = (*env)->CallObjectMethod(env, jobj, iterator);
42
43 Eina_Accessor_From_Jobject *res = calloc(1, sizeof(Eina_Accessor_From_Jobject));
44 res->obj.version = EINA_ACCESSOR_VERSION;
45 res->obj.get_container = (Eina_Accessor_Get_Container_Callback) _jobj_acc_container;
46 res->obj.get_at = (Eina_Accessor_Get_At_Callback) _jobj_acc_get_at;
47 res->obj.free = (Eina_Accessor_Free_Callback) _jobj_acc_free;
48 eina_array_step_set(&res->cache, sizeof(Eina_Array), 10);
49 EINA_MAGIC_SET(&res->obj, EINA_MAGIC_ACCESSOR);
50
51 _fill_eina_array_with_iterator(env, map, &res->cache, iterator_obj);
52
53 return &res->obj;
7} 54}
8 55
9JNIEXPORT jobject JNICALL 56JNIEXPORT jobject JNICALL
@@ -21,7 +68,8 @@ Java_efl_bindings_EflAccessor_free_1resources(JNIEnv *env, jobject jobj)
21 for (int i = 0; i < eina_array_count(arr); ++i) { 68 for (int i = 0; i < eina_array_count(arr); ++i) {
22 (*env)->DeleteGlobalRef(env, eina_array_data_get(arr, i)); 69 (*env)->DeleteGlobalRef(env, eina_array_data_get(arr, i));
23 } 70 }
24 eina_array_free(arr); 71 if (_app_running)
72 eina_array_free(arr);
25} 73}
26 74
27jobject 75jobject
diff --git a/java/manual-bindings/efliterator.c b/java/manual-bindings/efliterator.c
index 2cbf1a3..77126dc 100644
--- a/java/manual-bindings/efliterator.c
+++ b/java/manual-bindings/efliterator.c
@@ -5,25 +5,69 @@
5 5
6typedef struct { 6typedef struct {
7 Eina_Iterator obj; 7 Eina_Iterator obj;
8 jobject iter; 8 Eina_Array cache;
9 Iterator_Map_To_JObject map; 9 unsigned int current;
10} Eina_Iterator_From_Jobject; 10} Eina_Iterator_From_Jobject;
11 11
12Eina_Iterator* 12static void*
13_eina_iterator_from_jobject(JNIEnv *env, jobject jobj, Iterator_Map_To_Native map) 13_jobj_iter_container(Eina_Iterator_From_Jobject *obj)
14{
15 return &obj->cache;
16}
17
18static Eina_Bool
19_jobj_iter_next(Eina_Iterator_From_Jobject *obj, void **data)
20{
21 if (obj->current < eina_array_count(&obj->cache))
22 {
23 *data = eina_array_data_get(&obj->cache, obj->current);
24 obj->current ++;
25 return EINA_TRUE;
26 }
27 else
28 {
29 return EINA_FALSE;
30 }
31}
32
33static void
34_jobj_iter_free(Eina_Iterator_From_Jobject *obj)
35{
36 eina_array_flush(&obj->cache);
37 free(obj);
38}
39
40void
41_fill_eina_array_with_iterator(JNIEnv *env, Iterator_Map_To_Native map, Eina_Array *cache, jobject jobj)
14{ 42{
15 jclass iterKlass = (*env)->FindClass(env, "java/util/Iterator"); 43 jclass iterKlass = (*env)->FindClass(env, "java/util/Iterator");
16 jmethodID hasNext = (*env)->GetMethodID(env, iterKlass, "hasNext", "()B"); 44 jmethodID hasNext = (*env)->GetMethodID(env, iterKlass, "hasNext", "()Z");
17 jmethodID next = (*env)->GetMethodID(env, iterKlass, "next", "()B"); 45 jmethodID next = (*env)->GetMethodID(env, iterKlass, "next", "()Ljava/lang/Object;");
18 Eina_Array *arr = eina_array_new(10);
19 46
20 while((*env)->CallBooleanMethod(env, jobj, hasNext)) 47 while((*env)->CallBooleanMethod(env, jobj, hasNext))
21 { 48 {
22 jobject content = (*env)->CallObjectMethod(env, jobj, next); 49 jobject content = (*env)->CallObjectMethod(env, jobj, next);
23 void *new_content = map(env, content); 50 void *new_content = map(env, content);
24 eina_array_push(arr, new_content); 51 eina_array_push(cache, new_content);
25 } 52 }
26 return eina_array_iterator_new(arr); //FIXME this leaks the array 53}
54
55Eina_Iterator*
56_eina_iterator_from_jobject(JNIEnv *env, jobject jobj, Iterator_Map_To_Native map)
57{
58 if (!jobj) return NULL;
59
60 Eina_Iterator_From_Jobject *res = calloc(1, sizeof(Eina_Iterator_From_Jobject));
61 res->obj.version = EINA_ITERATOR_VERSION;
62 res->obj.get_container = (Eina_Iterator_Get_Container_Callback) _jobj_iter_container;
63 res->obj.next = (Eina_Iterator_Next_Callback) _jobj_iter_next;
64 res->obj.free = (Eina_Iterator_Free_Callback) _jobj_iter_free;
65 eina_array_step_set(&res->cache, sizeof(Eina_Array), 10);
66 EINA_MAGIC_SET(&res->obj, EINA_MAGIC_ITERATOR);
67
68 _fill_eina_array_with_iterator(env, map, &res->cache, jobj);
69
70 return &res->obj;
27} 71}
28 72
29typedef struct { 73typedef struct {
@@ -63,7 +107,8 @@ Java_efl_bindings_EflIterator_free_1resources(JNIEnv *env, jobject obj)
63 for (int i = 0; i < eina_array_count(iter->arr); ++i) { 107 for (int i = 0; i < eina_array_count(iter->arr); ++i) {
64 (*env)->DeleteGlobalRef(env, eina_array_data_get(iter->arr, i)); 108 (*env)->DeleteGlobalRef(env, eina_array_data_get(iter->arr, i));
65 } 109 }
66 eina_array_free(iter->arr); 110 if (_app_running)
111 eina_array_free(iter->arr);
67 } 112 }
68 113
69 free(iter); 114 free(iter);
diff --git a/java/manual-bindings/rwslice.c b/java/manual-bindings/rwslice.c
index d2a71a7..cf913a3 100644
--- a/java/manual-bindings/rwslice.c
+++ b/java/manual-bindings/rwslice.c
@@ -69,7 +69,7 @@ JNIEXPORT int JNICALL
69Java_efl_bindings_RwSlice_compare(JNIEnv *env, jobject jobj, jobject other_slice) 69Java_efl_bindings_RwSlice_compare(JNIEnv *env, jobject jobj, jobject other_slice)
70{ 70{
71 Internal_Eina_Rw_Slice *s1 = _fetch_opaque_struct_from_jobject(env, jobj); 71 Internal_Eina_Rw_Slice *s1 = _fetch_opaque_struct_from_jobject(env, jobj);
72 Internal_Eina_Rw_Slice *s2 = _fetch_opaque_struct_from_jobject(env, jobj); 72 Internal_Eina_Rw_Slice *s2 = _fetch_opaque_struct_from_jobject(env, other_slice);
73 73
74 return eina_rw_slice_compare(s1->rwslice, s2->rwslice); 74 return eina_rw_slice_compare(s1->rwslice, s2->rwslice);
75} 75}
diff --git a/java/manual-bindings/strbuf.c b/java/manual-bindings/strbuf.c
index 48ef7df..754d4c6 100644
--- a/java/manual-bindings/strbuf.c
+++ b/java/manual-bindings/strbuf.c
@@ -25,7 +25,8 @@ JNIEXPORT void JNICALL
25Java_efl_bindings_Strbuf_freeMemory(JNIEnv *env, jobject obj) 25Java_efl_bindings_Strbuf_freeMemory(JNIEnv *env, jobject obj)
26{ 26{
27 Eina_Strbuf *buf = _fetch_opaque_struct_from_jobject(env, obj); 27 Eina_Strbuf *buf = _fetch_opaque_struct_from_jobject(env, obj);
28 eina_strbuf_free(buf); 28 if (_app_running)
29 eina_strbuf_free(buf);
29} 30}
30 31
31JNIEXPORT int JNICALL 32JNIEXPORT int JNICALL
diff --git a/java/manual-bindings/value.c b/java/manual-bindings/value.c
index c1c0936..0cf2f2a 100644
--- a/java/manual-bindings/value.c
+++ b/java/manual-bindings/value.c
@@ -99,6 +99,15 @@ Java_efl_bindings_Value_freeMemory(JNIEnv *env, jobject jobj)
99 free(val); 99 free(val);
100} 100}
101 101
102JNIEXPORT int JNICALL
103Java_efl_bindings_Value_compare(JNIEnv *env, jobject jobj, jobject other_slice)
104{
105 Eina_Value *v1 = _fetch_opaque_struct_from_jobject(env, jobj);
106 Eina_Value *v2 = _fetch_opaque_struct_from_jobject(env, other_slice);
107
108 return eina_value_compare(v1, v2);
109}
110
102JNIEXPORT jobject JNICALL 111JNIEXPORT jobject JNICALL
103Java_efl_bindings_ValueReference_fetchValue(JNIEnv *env, jobject jobj) 112Java_efl_bindings_ValueReference_fetchValue(JNIEnv *env, jobject jobj)
104{ 113{
@@ -119,18 +128,12 @@ Java_efl_bindings_ValueReference_fromValue(JNIEnv *env, jclass kls, jobject valu
119 return res; 128 return res;
120} 129}
121 130
131
122JNIEXPORT void JNICALL 132JNIEXPORT void JNICALL
123Java_efl_bindings_ValueReference_freeMemory(JNIEnv *env, jobject jobj) 133Java_efl_bindings_ValueReference_freeMemory(JNIEnv *env, jobject jobj)
124{ 134{
125 Eina_Value *val = _fetch_opaque_struct_from_jobject(env, jobj); 135 Eina_Value *val = _fetch_opaque_struct_from_jobject(env, jobj);
126 eina_value_free(val); 136 if (_app_running)
127} 137 eina_value_free(val);
128 138 (*env)->CallVoidMethod(env, jobj, setNativeAddress, NULL);
129JNIEXPORT int JNICALL
130Java_efl_bindings_Value_compare(JNIEnv *env, jobject jobj, jobject other_slice)
131{
132 Eina_Value *v1 = _fetch_opaque_struct_from_jobject(env, jobj);
133 Eina_Value *v2 = _fetch_opaque_struct_from_jobject(env, other_slice);
134
135 return eina_value_compare(v1, v2);
136} 139}