summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-11-03 15:30:10 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-11-03 15:30:10 +0100
commit0dbbb18171d58482553d1c76e13ff50e56776ac0 (patch)
tree0290d657713a373e1c047e99328868fd19e8e062
parente5d1cc731a6ea6d8336b6b887352f7a4e02537ae (diff)
eolian: disallow ptr() on things that are already pointer-like
This disallows deeply nested pointers, you can only explicitly ptr() on types that are strictly value types. For a few cases where it was necessary to override this behavior, you can use legacy(ptr(x)) as a temporary measure.
Diffstat (limited to '')
-rw-r--r--src/lib/ector/cairo/ector_cairo_surface.eo2
-rw-r--r--src/lib/elementary/elm_calendar.eo2
-rw-r--r--src/lib/elementary/elm_dayselector.eo2
-rw-r--r--src/lib/elementary/elm_map.eo2
-rw-r--r--src/lib/eolian/database_type.c14
-rw-r--r--src/lib/eolian/database_validate.c11
-rw-r--r--src/lib/eolian/eo_parser.c51
-rw-r--r--src/lib/eolian/eolian_database.h1
8 files changed, 49 insertions, 36 deletions
diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo
index 31f68e400c..7967c4d348 100644
--- a/src/lib/ector/cairo/ector_cairo_surface.eo
+++ b/src/lib/ector/cairo/ector_cairo_surface.eo
@@ -1,4 +1,4 @@
1type @extern cairo_t: void_ptr; [[cairo_t type]] 1struct @extern cairo_t; [[cairo_t type]]
2 2
3class Ector.Cairo.Surface (Efl.Object, Ector.Surface) 3class Ector.Cairo.Surface (Efl.Object, Ector.Surface)
4{ 4{
diff --git a/src/lib/elementary/elm_calendar.eo b/src/lib/elementary/elm_calendar.eo
index d08765d312..2b734b30fe 100644
--- a/src/lib/elementary/elm_calendar.eo
+++ b/src/lib/elementary/elm_calendar.eo
@@ -169,7 +169,7 @@ class Elm.Calendar (Efl.Ui.Layout, Efl.Ui.Focus.Composition, Elm.Interface.Atspi
169 get { 169 get {
170 } 170 }
171 values { 171 values {
172 weekdays: ptr(string); [[Array of seven strings to be used as weekday names. 172 weekdays: legacy(ptr(string)); [[Array of seven strings to be used as weekday names.
173 Warning: It must have 7 elements, or it will access invalid memory. 173 Warning: It must have 7 elements, or it will access invalid memory.
174 Warning: The strings must be $null terminated ('@\0').]] 174 Warning: The strings must be $null terminated ('@\0').]]
175 } 175 }
diff --git a/src/lib/elementary/elm_dayselector.eo b/src/lib/elementary/elm_dayselector.eo
index 0bc85ad001..c5135da6ea 100644
--- a/src/lib/elementary/elm_dayselector.eo
+++ b/src/lib/elementary/elm_dayselector.eo
@@ -107,7 +107,7 @@ class Elm.Dayselector (Efl.Ui.Layout)
107 */ 107 */
108 108
109 params { 109 params {
110 @in weekdays: ptr(string) @nullable; [[Array of seven strings to be used as weekday names. 110 @in weekdays: legacy(ptr(string)) @nullable; [[Array of seven strings to be used as weekday names.
111 Warning: It must have 7 elements, or it will access invalid memory. 111 Warning: It must have 7 elements, or it will access invalid memory.
112 Warning: The strings must be NULL terminated ('@\0').]] 112 Warning: The strings must be NULL terminated ('@\0').]]
113 } 113 }
diff --git a/src/lib/elementary/elm_map.eo b/src/lib/elementary/elm_map.eo
index 7f5376ad85..908444da84 100644
--- a/src/lib/elementary/elm_map.eo
+++ b/src/lib/elementary/elm_map.eo
@@ -431,7 +431,7 @@ class Elm.Map (Elm.Widget, Elm.Interface_Scrollable,
431 431
432 At least available sources of name type are "Nominatim". 432 At least available sources of name type are "Nominatim".
433 ]] 433 ]]
434 return: ptr(string); [[The char pointer array of source names.]] 434 return: legacy(ptr(string)); [[The char pointer array of source names.]]
435 params { 435 params {
436 @in type: Elm.Map.Source_Type; [[Source type.]] 436 @in type: Elm.Map.Source_Type; [[Source type.]]
437 } 437 }
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 1afbbac14a..c71a45452b 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -67,18 +67,6 @@ database_enum_add(Eolian_Typedecl *tp)
67 database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp); 67 database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
68} 68}
69 69
70static const Eina_Bool _ownable_types[] = {
71 EINA_FALSE, /* unknown */
72 EINA_FALSE, /* void */
73 EINA_FALSE, /* regular */
74 EINA_TRUE, /* complex */
75 EINA_TRUE, /* pointer */
76 EINA_TRUE, /* class */
77 EINA_TRUE, /* static array */
78 EINA_TRUE, /* terminated array */
79 EINA_FALSE /* undefined */
80};
81
82Eina_Bool 70Eina_Bool
83database_type_is_ownable(const Eolian_Type *tp) 71database_type_is_ownable(const Eolian_Type *tp)
84{ 72{
@@ -101,7 +89,7 @@ database_type_is_ownable(const Eolian_Type *tp)
101 } 89 }
102 return (ct[strlen(ct) - 1] == '*'); 90 return (ct[strlen(ct) - 1] == '*');
103 } 91 }
104 return _ownable_types[tp->type]; 92 return (tp->type == EOLIAN_TYPE_CLASS);
105} 93}
106 94
107static void 95static void
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index ecfb806b0b..3651d7ead2 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -172,6 +172,17 @@ _validate_type(Eolian_Type *tp)
172 return _obj_error(&tp->base, buf); 172 return _obj_error(&tp->base, buf);
173 } 173 }
174 174
175 if (tp->is_ptr && !tp->legacy)
176 {
177 tp->is_ptr = EINA_FALSE;
178 Eina_Bool still_ownable = database_type_is_ownable(tp);
179 tp->is_ptr = EINA_TRUE;
180 if (still_ownable)
181 {
182 return _obj_error(&tp->base, "cannot take a pointer to pointer type");
183 }
184 }
185
175 switch (tp->type) 186 switch (tp->type)
176 { 187 {
177 case EOLIAN_TYPE_VOID: 188 case EOLIAN_TYPE_VOID:
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 0ec492b9a3..da03709c38 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -456,14 +456,14 @@ parse_expr(Eo_Lexer *ls)
456 return parse_expr_bin(ls, 1); 456 return parse_expr_bin(ls, 1);
457} 457}
458 458
459static Eolian_Type *parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref); 459static Eolian_Type *parse_type_void(Eo_Lexer *ls);
460 460
461static Eolian_Type * 461static Eolian_Type *
462parse_type(Eo_Lexer *ls, Eina_Bool allow_ref) 462parse_type(Eo_Lexer *ls)
463{ 463{
464 Eolian_Type *ret; 464 Eolian_Type *ret;
465 eo_lexer_context_push(ls); 465 eo_lexer_context_push(ls);
466 ret = parse_type_void(ls, allow_ref); 466 ret = parse_type_void(ls);
467 if (ret->type == EOLIAN_TYPE_VOID) 467 if (ret->type == EOLIAN_TYPE_VOID)
468 { 468 {
469 eo_lexer_context_restore(ls); 469 eo_lexer_context_restore(ls);
@@ -512,7 +512,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
512 def->field_list = eina_list_append(def->field_list, fdef); 512 def->field_list = eina_list_append(def->field_list, fdef);
513 eo_lexer_get(ls); 513 eo_lexer_get(ls);
514 check_next(ls, ':'); 514 check_next(ls, ':');
515 tp = parse_type(ls, EINA_TRUE); 515 tp = parse_type(ls);
516 FILL_BASE(fdef->base, ls, fline, fcol); 516 FILL_BASE(fdef->base, ls, fline, fcol);
517 fdef->type = tp; 517 fdef->type = tp;
518 fdef->name = eina_stringshare_ref(fname); 518 fdef->name = eina_stringshare_ref(fname);
@@ -687,7 +687,7 @@ _parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
687} 687}
688 688
689static Eolian_Type * 689static Eolian_Type *
690parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref) 690parse_type_void(Eo_Lexer *ls)
691{ 691{
692 Eolian_Type *def; 692 Eolian_Type *def;
693 Eina_Strbuf *buf; 693 Eina_Strbuf *buf;
@@ -701,7 +701,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref)
701 pline = ls->line_number; 701 pline = ls->line_number;
702 pcol = ls->column; 702 pcol = ls->column;
703 check_next(ls, '('); 703 check_next(ls, '(');
704 def = parse_type_void(ls, allow_ref); 704 def = parse_type_void(ls);
705 FILL_BASE(def->base, ls, line, col); 705 FILL_BASE(def->base, ls, line, col);
706 def->is_const = EINA_TRUE; 706 def->is_const = EINA_TRUE;
707 check_match(ls, ')', '(', pline, pcol); 707 check_match(ls, ')', '(', pline, pcol);
@@ -714,12 +714,25 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref)
714 pline = ls->line_number; 714 pline = ls->line_number;
715 pcol = ls->column; 715 pcol = ls->column;
716 check_next(ls, '('); 716 check_next(ls, '(');
717 def = parse_type_void(ls, EINA_FALSE); 717 def = parse_type_void(ls);
718 FILL_BASE(def->base, ls, line, col); 718 FILL_BASE(def->base, ls, line, col);
719 def->is_ptr = EINA_TRUE; 719 def->is_ptr = EINA_TRUE;
720 check_match(ls, ')', '(', pline, pcol); 720 check_match(ls, ')', '(', pline, pcol);
721 return def; 721 return def;
722 } 722 }
723 case KW_legacy:
724 {
725 int pline, pcol;
726 eo_lexer_get(ls);
727 pline = ls->line_number;
728 pcol = ls->column;
729 check_next(ls, '(');
730 def = parse_type_void(ls);
731 FILL_BASE(def->base, ls, line, col);
732 def->legacy = EINA_TRUE;
733 check_match(ls, ')', '(', pline, pcol);
734 return def;
735 }
723 case KW_free: 736 case KW_free:
724 { 737 {
725 int pline, pcolumn; 738 int pline, pcolumn;
@@ -727,7 +740,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref)
727 pline = ls->line_number; 740 pline = ls->line_number;
728 pcolumn = ls->column; 741 pcolumn = ls->column;
729 check_next(ls, '('); 742 check_next(ls, '(');
730 def = parse_type_void(ls, allow_ref); 743 def = parse_type_void(ls);
731 check_next(ls, ','); 744 check_next(ls, ',');
732 check(ls, TOK_VALUE); 745 check(ls, TOK_VALUE);
733 def->freefunc = eina_stringshare_ref(ls->t.value.s); 746 def->freefunc = eina_stringshare_ref(ls->t.value.s);
@@ -768,23 +781,23 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref)
768 int bline = ls->line_number, bcol = ls->column; 781 int bline = ls->line_number, bcol = ls->column;
769 check_next(ls, '<'); 782 check_next(ls, '<');
770 if (tpid == KW_future) 783 if (tpid == KW_future)
771 def->base_type = parse_type_void(ls, EINA_FALSE); 784 def->base_type = parse_type_void(ls);
772 else 785 else
773 def->base_type = parse_type(ls, EINA_FALSE); 786 def->base_type = parse_type(ls);
774 pop_type(ls); 787 pop_type(ls);
775 if ((def->base_type->owned = (ls->t.kw == KW_at_owned))) 788 if ((def->base_type->owned = (ls->t.kw == KW_at_owned)))
776 eo_lexer_get(ls); 789 eo_lexer_get(ls);
777 if (tpid == KW_hash) 790 if (tpid == KW_hash)
778 { 791 {
779 check_next(ls, ','); 792 check_next(ls, ',');
780 def->base_type->next_type = parse_type(ls, EINA_FALSE); 793 def->base_type->next_type = parse_type(ls);
781 pop_type(ls); 794 pop_type(ls);
782 if ((def->base_type->next_type->owned = (ls->t.kw == KW_at_owned))) 795 if ((def->base_type->next_type->owned = (ls->t.kw == KW_at_owned)))
783 eo_lexer_get(ls); 796 eo_lexer_get(ls);
784 } 797 }
785 else if((tpid == KW_future) && test_next(ls, ',')) 798 else if((tpid == KW_future) && test_next(ls, ','))
786 { 799 {
787 def->base_type->next_type = parse_type_void(ls, EINA_FALSE); 800 def->base_type->next_type = parse_type_void(ls);
788 pop_type(ls); 801 pop_type(ls);
789 } 802 }
790 check_match(ls, '>', '<', bline, bcol); 803 check_match(ls, '>', '<', bline, bcol);
@@ -854,7 +867,7 @@ parse_typedef(Eo_Lexer *ls)
854 } 867 }
855 eo_lexer_context_pop(ls); 868 eo_lexer_context_pop(ls);
856 check_next(ls, ':'); 869 check_next(ls, ':');
857 def->base_type = parse_type(ls, EINA_FALSE); 870 def->base_type = parse_type(ls);
858 pop_type(ls); 871 pop_type(ls);
859 check_next(ls, ';'); 872 check_next(ls, ';');
860 FILL_DOC(ls, def, doc); 873 FILL_DOC(ls, def, doc);
@@ -890,7 +903,7 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global)
890 } 903 }
891 eo_lexer_context_pop(ls); 904 eo_lexer_context_pop(ls);
892 check_next(ls, ':'); 905 check_next(ls, ':');
893 def->base_type = parse_type(ls, EINA_FALSE); 906 def->base_type = parse_type(ls);
894 pop_type(ls); 907 pop_type(ls);
895 /* constants are required to have a value */ 908 /* constants are required to have a value */
896 if (!global) 909 if (!global)
@@ -926,9 +939,9 @@ parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void,
926 eo_lexer_get(ls); 939 eo_lexer_get(ls);
927 check_next(ls, ':'); 940 check_next(ls, ':');
928 if (allow_void) 941 if (allow_void)
929 ret->type = parse_type_void(ls, EINA_TRUE); 942 ret->type = parse_type_void(ls);
930 else 943 else
931 ret->type = parse_type(ls, EINA_TRUE); 944 ret->type = parse_type(ls);
932 ret->doc = NULL; 945 ret->doc = NULL;
933 ret->default_ret_val = NULL; 946 ret->default_ret_val = NULL;
934 ret->warn_unused = EINA_FALSE; 947 ret->warn_unused = EINA_FALSE;
@@ -995,9 +1008,9 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
995 eo_lexer_get(ls); 1008 eo_lexer_get(ls);
996 check_next(ls, ':'); 1009 check_next(ls, ':');
997 if (par->param_dir == EOLIAN_OUT_PARAM || par->param_dir == EOLIAN_INOUT_PARAM) 1010 if (par->param_dir == EOLIAN_OUT_PARAM || par->param_dir == EOLIAN_INOUT_PARAM)
998 par->type = parse_type_void(ls, EINA_TRUE); 1011 par->type = parse_type_void(ls);
999 else 1012 else
1000 par->type = parse_type(ls, EINA_TRUE); 1013 par->type = parse_type(ls);
1001 pop_type(ls); 1014 pop_type(ls);
1002 if ((is_vals || (par->param_dir == EOLIAN_OUT_PARAM)) && (ls->t.token == '(')) 1015 if ((is_vals || (par->param_dir == EOLIAN_OUT_PARAM)) && (ls->t.token == '('))
1003 { 1016 {
@@ -1801,7 +1814,7 @@ end:
1801 if (ls->t.token == ':') 1814 if (ls->t.token == ':')
1802 { 1815 {
1803 eo_lexer_get(ls); 1816 eo_lexer_get(ls);
1804 ev->type = parse_type(ls, EINA_TRUE); 1817 ev->type = parse_type(ls);
1805 ev->type->owned = has_owned; 1818 ev->type->owned = has_owned;
1806 pop_type(ls); 1819 pop_type(ls);
1807 } 1820 }
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 05c153b8f2..a8c1dbb637 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -177,6 +177,7 @@ struct _Eolian_Type
177 Eina_Bool is_const :1; 177 Eina_Bool is_const :1;
178 Eina_Bool is_ptr :1; 178 Eina_Bool is_ptr :1;
179 Eina_Bool owned :1; 179 Eina_Bool owned :1;
180 Eina_Bool legacy :1;
180}; 181};
181 182
182struct _Eolian_Typedecl 183struct _Eolian_Typedecl