summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-14 23:57:31 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-23 14:13:31 +0100
commit286ad910754c659f677caae2b0c566d4cc99f859 (patch)
treed7572760357b4e212c21956a15bb54fa0637f4ba
parentefaa4bc7f9c44a64de1af155fde18e56fab969cb (diff)
efl_mono: add a free function to every owned type
this is another step towards enforcing free functions on every owned type. To equip every owned type with a free function the following is applied. Every owned ptr is assumed to be a heap pointer, with the free function "free". Every string that is owed is converted to a mstring. a pointer to a eo object is also assumed to be a heap pointer, and equiped with the free function "free". Differential Revision: https://phab.enlightenment.org/D7710
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo86
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c12
2 files changed, 49 insertions, 49 deletions
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index e6c42f64c8..2081f3f4e0 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -10,7 +10,7 @@ enum Dummy.SampleEnum {
10 v4, 10 v4,
11} 11}
12 12
13struct Dummy.StructSimple 13struct @free(free) Dummy.StructSimple
14{ 14{
15 fbyte: byte; 15 fbyte: byte;
16 fubyte: ubyte; 16 fubyte: ubyte;
@@ -62,7 +62,7 @@ struct Dummy.StructSimple
62 fmyint: Dummy.MyInt; 62 fmyint: Dummy.MyInt;
63} 63}
64 64
65struct Dummy.StructComplex { 65struct @free(free) Dummy.StructComplex {
66 farray: array<ptr(int)>; 66 farray: array<ptr(int)>;
67 finarray: inarray<int>; 67 finarray: inarray<int>;
68 flist: list<string>; 68 flist: list<string>;
@@ -151,7 +151,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
151 params { 151 params {
152 @in str: string; 152 @in str: string;
153 } 153 }
154 return: string @owned; 154 return: mstring @owned;
155 } 155 }
156 156
157 in_own_string { 157 in_own_string {
@@ -166,7 +166,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
166 } 166 }
167 167
168 return_own_string { 168 return_own_string {
169 return: string @owned; 169 return: mstring @owned;
170 } 170 }
171 171
172 out_string { 172 out_string {
@@ -177,7 +177,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
177 177
178 out_own_string { 178 out_own_string {
179 params { 179 params {
180 @out str: string @owned; 180 @out str: mstring @owned;
181 } 181 }
182 } 182 }
183 183
@@ -198,7 +198,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
198 } 198 }
199 199
200 call_return_own_string { 200 call_return_own_string {
201 return: string @owned; 201 return: mstring @owned;
202 } 202 }
203 203
204 call_out_string { 204 call_out_string {
@@ -206,7 +206,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
206 } 206 }
207 207
208 call_out_own_string { 208 call_out_own_string {
209 return: string @owned; 209 return: mstring @owned;
210 } 210 }
211 211
212 // Stringshare virtual helpers 212 // Stringshare virtual helpers
@@ -373,7 +373,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
373 373
374 eina_array_int_in_own { 374 eina_array_int_in_own {
375 params { 375 params {
376 @in arr: array<ptr(int) @owned> @owned; 376 @in arr: array<free(ptr(int),free) @owned> @owned;
377 } 377 }
378 return: bool; 378 return: bool;
379 } 379 }
@@ -393,7 +393,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
393 393
394 eina_array_int_out_own { 394 eina_array_int_out_own {
395 params { 395 params {
396 @out arr: array<ptr(int) @owned> @owned; 396 @out arr: array<free(ptr(int),free) @owned> @owned;
397 } 397 }
398 return: bool; 398 return: bool;
399 } 399 }
@@ -406,7 +406,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
406 } 406 }
407 407
408 eina_array_int_return_own { 408 eina_array_int_return_own {
409 return: array<ptr(int) @owned> @owned; 409 return: array<free(ptr(int),free) @owned> @owned;
410 } 410 }
411 411
412 /* String */ 412 /* String */
@@ -419,7 +419,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
419 419
420 eina_array_str_in_own { 420 eina_array_str_in_own {
421 params { 421 params {
422 @in arr: array<string @owned> @owned; 422 @in arr: array<mstring @owned> @owned;
423 } 423 }
424 return: bool; 424 return: bool;
425 } 425 }
@@ -439,7 +439,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
439 439
440 eina_array_str_out_own { 440 eina_array_str_out_own {
441 params { 441 params {
442 @out arr: array<string @owned> @owned; 442 @out arr: array<mstring @owned> @owned;
443 } 443 }
444 return: bool; 444 return: bool;
445 } 445 }
@@ -452,7 +452,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
452 } 452 }
453 453
454 eina_array_str_return_own { 454 eina_array_str_return_own {
455 return: array<string @owned> @owned; 455 return: array<mstring @owned> @owned;
456 } 456 }
457 457
458 /* Object */ 458 /* Object */
@@ -520,7 +520,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
520 520
521 eina_inarray_int_in_own { 521 eina_inarray_int_in_own {
522 params { 522 params {
523 @in arr: inarray<ptr(int) @owned> @owned; 523 @in arr: inarray<free(ptr(int),free) @owned> @owned;
524 } 524 }
525 return: bool; 525 return: bool;
526 } 526 }
@@ -540,7 +540,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
540 540
541 eina_inarray_int_out_own { 541 eina_inarray_int_out_own {
542 params { 542 params {
543 @out arr: inarray<ptr(int) @owned> @owned; 543 @out arr: inarray<free(ptr(int),free) @owned> @owned;
544 } 544 }
545 return: bool; 545 return: bool;
546 } 546 }
@@ -553,7 +553,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
553 } 553 }
554 554
555 eina_inarray_int_return_own { 555 eina_inarray_int_return_own {
556 return: inarray<ptr(int) @owned> @owned; 556 return: inarray<free(ptr(int),free) @owned> @owned;
557 } 557 }
558 558
559 /* String */ 559 /* String */
@@ -566,7 +566,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
566 566
567 eina_inarray_str_in_own { 567 eina_inarray_str_in_own {
568 params { 568 params {
569 @in arr: inarray<string @owned> @owned; 569 @in arr: inarray<mstring @owned> @owned;
570 } 570 }
571 return: bool; 571 return: bool;
572 } 572 }
@@ -586,7 +586,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
586 586
587 eina_inarray_str_out_own { 587 eina_inarray_str_out_own {
588 params { 588 params {
589 @out arr: inarray<string @owned> @owned; 589 @out arr: inarray<mstring @owned> @owned;
590 } 590 }
591 return: bool; 591 return: bool;
592 } 592 }
@@ -599,7 +599,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
599 } 599 }
600 600
601 eina_inarray_str_return_own { 601 eina_inarray_str_return_own {
602 return: inarray<string @owned> @owned; 602 return: inarray<mstring @owned> @owned;
603 } 603 }
604 604
605 /* Object */ 605 /* Object */
@@ -667,7 +667,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
667 667
668 eina_list_int_in_own { 668 eina_list_int_in_own {
669 params { 669 params {
670 @in lst: list<ptr(int) @owned> @owned; 670 @in lst: list<free(ptr(int),free) @owned> @owned;
671 } 671 }
672 return: bool; 672 return: bool;
673 } 673 }
@@ -687,7 +687,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
687 687
688 eina_list_int_out_own { 688 eina_list_int_out_own {
689 params { 689 params {
690 @out lst: list<ptr(int) @owned> @owned; 690 @out lst: list<free(ptr(int),free) @owned> @owned;
691 } 691 }
692 return: bool; 692 return: bool;
693 } 693 }
@@ -700,7 +700,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
700 } 700 }
701 701
702 eina_list_int_return_own { 702 eina_list_int_return_own {
703 return: list<ptr(int) @owned> @owned; 703 return: list<free(ptr(int),free) @owned> @owned;
704 } 704 }
705 705
706 /* String */ 706 /* String */
@@ -713,7 +713,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
713 713
714 eina_list_str_in_own { 714 eina_list_str_in_own {
715 params { 715 params {
716 @in lst: list<string @owned> @owned; 716 @in lst: list<mstring @owned> @owned;
717 } 717 }
718 return: bool; 718 return: bool;
719 } 719 }
@@ -733,7 +733,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
733 733
734 eina_list_str_out_own { 734 eina_list_str_out_own {
735 params { 735 params {
736 @out lst: list<string @owned> @owned; 736 @out lst: list<mstring @owned> @owned;
737 } 737 }
738 return: bool; 738 return: bool;
739 } 739 }
@@ -746,7 +746,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
746 } 746 }
747 747
748 eina_list_str_return_own { 748 eina_list_str_return_own {
749 return: list<string @owned> @owned; 749 return: list<mstring @owned> @owned;
750 } 750 }
751 751
752 /* Object */ 752 /* Object */
@@ -814,7 +814,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
814 814
815 eina_inlist_int_in_own { 815 eina_inlist_int_in_own {
816 params { 816 params {
817 @in lst: inlist<ptr(int) @owned> @owned; 817 @in lst: inlist<free(ptr(int),free) @owned> @owned;
818 } 818 }
819 return: bool; 819 return: bool;
820 } 820 }
@@ -834,7 +834,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
834 834
835 eina_inlist_int_out_own { 835 eina_inlist_int_out_own {
836 params { 836 params {
837 @out lst: inlist<ptr(int) @owned> @owned; 837 @out lst: inlist<free(ptr(int),free) @owned> @owned;
838 } 838 }
839 return: bool; 839 return: bool;
840 } 840 }
@@ -847,7 +847,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
847 } 847 }
848 848
849 eina_inlist_int_return_own { 849 eina_inlist_int_return_own {
850 return: inlist<ptr(int) @owned> @owned; 850 return: inlist<free(ptr(int),free) @owned> @owned;
851 } 851 }
852 852
853 /* String */ 853 /* String */
@@ -860,7 +860,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
860 860
861 eina_inlist_str_in_own { 861 eina_inlist_str_in_own {
862 params { 862 params {
863 @in lst: inlist<string @owned> @owned; 863 @in lst: inlist<mstring @owned> @owned;
864 } 864 }
865 return: bool; 865 return: bool;
866 } 866 }
@@ -880,7 +880,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
880 880
881 eina_inlist_str_out_own { 881 eina_inlist_str_out_own {
882 params { 882 params {
883 @out lst: inlist<string @owned> @owned; 883 @out lst: inlist<mstring @owned> @owned;
884 } 884 }
885 return: bool; 885 return: bool;
886 } 886 }
@@ -893,7 +893,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
893 } 893 }
894 894
895 eina_inlist_str_return_own { 895 eina_inlist_str_return_own {
896 return: inlist<string @owned> @owned; 896 return: inlist<mstring @owned> @owned;
897 } 897 }
898 898
899 /* Object */ 899 /* Object */
@@ -962,7 +962,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
962 962
963 eina_hash_int_in_own { 963 eina_hash_int_in_own {
964 params { 964 params {
965 @in hsh: hash<ptr(int), ptr(int) @owned> @owned; 965 @in hsh: hash<ptr(int), free(ptr(int),free) @owned> @owned;
966 } 966 }
967 return: bool; 967 return: bool;
968 } 968 }
@@ -982,7 +982,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
982 982
983 eina_hash_int_out_own { 983 eina_hash_int_out_own {
984 params { 984 params {
985 @out hsh: hash<ptr(int), ptr(int) @owned> @owned; 985 @out hsh: hash<ptr(int), free(ptr(int),free) @owned> @owned;
986 } 986 }
987 return: bool; 987 return: bool;
988 } 988 }
@@ -998,7 +998,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
998 } 998 }
999 999
1000 eina_hash_int_return_own { 1000 eina_hash_int_return_own {
1001 return: hash<ptr(int), ptr(int) @owned> @owned; 1001 return: hash<ptr(int), free(ptr(int),free) @owned> @owned;
1002 } 1002 }
1003 check_eina_hash_int_return_own { 1003 check_eina_hash_int_return_own {
1004 return: bool; 1004 return: bool;
@@ -1014,7 +1014,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1014 1014
1015 eina_hash_str_in_own { 1015 eina_hash_str_in_own {
1016 params { 1016 params {
1017 @in hsh: hash<string, string @owned> @owned; 1017 @in hsh: hash<string, mstring @owned> @owned;
1018 } 1018 }
1019 return: bool; 1019 return: bool;
1020 } 1020 }
@@ -1034,7 +1034,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1034 1034
1035 eina_hash_str_out_own { 1035 eina_hash_str_out_own {
1036 params { 1036 params {
1037 @out hsh: hash<string, string @owned> @owned; 1037 @out hsh: hash<string, mstring @owned> @owned;
1038 } 1038 }
1039 return: bool; 1039 return: bool;
1040 } 1040 }
@@ -1050,7 +1050,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1050 } 1050 }
1051 1051
1052 eina_hash_str_return_own { 1052 eina_hash_str_return_own {
1053 return: hash<string, string @owned> @owned; 1053 return: hash<string, mstring @owned> @owned;
1054 } 1054 }
1055 check_eina_hash_str_return_own { 1055 check_eina_hash_str_return_own {
1056 return: bool; 1056 return: bool;
@@ -1158,7 +1158,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1158 1158
1159 eina_iterator_int_in_own { 1159 eina_iterator_int_in_own {
1160 params { 1160 params {
1161 @in itr: iterator<ptr(int) @owned> @owned; 1161 @in itr: iterator<free(ptr(int),free) @owned> @owned;
1162 } 1162 }
1163 return: bool; 1163 return: bool;
1164 } 1164 }
@@ -1178,7 +1178,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1178 1178
1179 eina_iterator_int_out_own { 1179 eina_iterator_int_out_own {
1180 params { 1180 params {
1181 @out itr: iterator<ptr(int) @owned> @owned; 1181 @out itr: iterator<free(ptr(int),free) @owned> @owned;
1182 } 1182 }
1183 return: bool; 1183 return: bool;
1184 } 1184 }
@@ -1191,7 +1191,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1191 } 1191 }
1192 1192
1193 eina_iterator_int_return_own { 1193 eina_iterator_int_return_own {
1194 return: iterator<ptr(int) @owned> @owned; 1194 return: iterator<free(ptr(int),free) @owned> @owned;
1195 } 1195 }
1196 1196
1197 /* String */ 1197 /* String */
@@ -1204,7 +1204,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1204 1204
1205 eina_iterator_str_in_own { 1205 eina_iterator_str_in_own {
1206 params { 1206 params {
1207 @in itr: iterator<string @owned> @owned; 1207 @in itr: iterator<mstring @owned> @owned;
1208 } 1208 }
1209 return: bool; 1209 return: bool;
1210 } 1210 }
@@ -1224,7 +1224,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1224 1224
1225 eina_iterator_str_out_own { 1225 eina_iterator_str_out_own {
1226 params { 1226 params {
1227 @out itr: iterator<string @owned> @owned; 1227 @out itr: iterator<mstring @owned> @owned;
1228 } 1228 }
1229 return: bool; 1229 return: bool;
1230 } 1230 }
@@ -1237,7 +1237,7 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
1237 } 1237 }
1238 1238
1239 eina_iterator_str_return_own { 1239 eina_iterator_str_return_own {
1240 return: iterator<string @owned> @owned; 1240 return: iterator<mstring @owned> @owned;
1241 } 1241 }
1242 1242
1243 /* Object */ 1243 /* Object */
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 4c46e1e8dc..986cd1fa53 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -165,7 +165,7 @@ void _dummy_test_object_int_ptr_out(EINA_UNUSED Eo *obj, Dummy_Test_Object_Data
165 *y = &pd->stored_int; 165 *y = &pd->stored_int;
166} 166}
167 167
168const char *_dummy_test_object_in_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, const char *str) 168char *_dummy_test_object_in_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, const char *str)
169{ 169{
170 const char *ret = malloc(sizeof(char)*(strlen(str) + 1)); 170 const char *ret = malloc(sizeof(char)*(strlen(str) + 1));
171 return strcpy((char*)ret, str); 171 return strcpy((char*)ret, str);
@@ -196,7 +196,7 @@ const char *_dummy_test_object_return_string(EINA_UNUSED Eo *obj, EINA_UNUSED Du
196 return "string"; 196 return "string";
197} 197}
198 198
199const char *_dummy_test_object_return_own_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) 199char *_dummy_test_object_return_own_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
200{ 200{
201 static const char* reference = "own_string"; 201 static const char* reference = "own_string";
202 const char *ret = malloc(sizeof(char)*(strlen(reference) + 1)); 202 const char *ret = malloc(sizeof(char)*(strlen(reference) + 1));
@@ -208,7 +208,7 @@ void _dummy_test_object_out_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_O
208 *str = "out_string"; 208 *str = "out_string";
209} 209}
210 210
211void _dummy_test_object_out_own_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, const char**str) 211void _dummy_test_object_out_own_string(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, char**str)
212{ 212{
213 static const char* reference = "out_own_string"; 213 static const char* reference = "out_own_string";
214 *str = malloc(sizeof(char)*(strlen(reference) + 1)); 214 *str = malloc(sizeof(char)*(strlen(reference) + 1));
@@ -230,7 +230,7 @@ const char *_dummy_test_object_call_return_string(Eo *obj, EINA_UNUSED Dummy_Tes
230 return dummy_test_object_return_string(obj); 230 return dummy_test_object_return_string(obj);
231} 231}
232 232
233const char *_dummy_test_object_call_return_own_string(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) 233char *_dummy_test_object_call_return_own_string(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
234{ 234{
235 return dummy_test_object_return_own_string(obj); 235 return dummy_test_object_return_own_string(obj);
236} 236}
@@ -242,9 +242,9 @@ const char *_dummy_test_object_call_out_string(Eo *obj, EINA_UNUSED Dummy_Test_O
242 return ret; 242 return ret;
243} 243}
244 244
245const char *_dummy_test_object_call_out_own_string(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) 245char *_dummy_test_object_call_out_own_string(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
246{ 246{
247 const char *ret = NULL; 247 char *ret = NULL;
248 dummy_test_object_out_own_string(obj, &ret); 248 dummy_test_object_out_own_string(obj, &ret);
249 return ret; 249 return ret;
250} 250}