diff options
author | Ali Alzyod <ali198724@gmail.com> | 2020-05-31 06:16:46 +0000 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2020-06-02 08:07:48 +0200 |
commit | ff3d3b19447c2eaa5378ea2e303f7a696d5370ef (patch) | |
tree | 13f35a9b11ce9e4d7f3642c4d84995d8fc2511db | |
parent | 5ca1a8c8a7fed96260b7d3faa5a12f55ac790855 (diff) | |
download | efl-ff3d3b19447c2eaa5378ea2e303f7a696d5370ef.tar.gz |
efl_access_text: remove ptr usage in eo files
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11907
-rw-r--r-- | src/lib/elementary/efl_access_text.eo | 18 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_textbox.c | 39 | ||||
-rw-r--r-- | src/lib/elementary/elm_atspi_bridge.c | 7 | ||||
-rw-r--r-- | src/lib/elementary/elm_entry.c | 41 | ||||
-rw-r--r-- | src/lib/elementary/elm_entry_eo.c | 4 | ||||
-rw-r--r-- | src/tests/elementary/elm_test_entry.c | 28 |
6 files changed, 71 insertions, 66 deletions
diff --git a/src/lib/elementary/efl_access_text.eo b/src/lib/elementary/efl_access_text.eo index 95cc367c3c..b40dc1a4eb 100644 --- a/src/lib/elementary/efl_access_text.eo +++ b/src/lib/elementary/efl_access_text.eo @@ -66,12 +66,12 @@ interface @beta Efl.Access.Text } keys { granularity: Efl.Access.Text_Granularity; [[Text granularity]] - start_offset: ptr(int); [[Offset indicating start of string according to given granularity. - -1 in case of error.]] - end_offset: ptr(int); [[Offset indicating end of string according to given granularity. - -1 in case of error.]] } values { + start_offset: int; [[Offset indicating start of string according to given granularity. + -1 in case of error.]] + end_offset: int; [[Offset indicating end of string according to given granularity. + -1 in case of error.]] string: mstring @move; [[Newly allocated UTF-8 encoded string. Must be free by a user.]] } } @@ -105,10 +105,10 @@ interface @beta Efl.Access.Text } keys { name: string; [[Text attribute name]] - start_offset: ptr(int); [[Position in text from which given attribute is set.]] - end_offset: ptr(int); [[Position in text to which given attribute is set.]] } values { + start_offset: int; [[Position in text from which given attribute is set.]] + end_offset: int; [[Position in text to which given attribute is set.]] value: mstring @move; [[Value of text attribute. Should be free()]] } } @@ -116,11 +116,9 @@ interface @beta Efl.Access.Text [[Gets list of all text attributes.]] get { } - keys { - start_offset: ptr(int); [[Start offset]] - end_offset: ptr(int); [[End offset]] - } values { + start_offset: int; [[Start offset]] + end_offset: int; [[End offset]] attributes: list<Efl.Access.Text_Attribute> @move; [[List of text attributes]] } } diff --git a/src/lib/elementary/efl_ui_textbox.c b/src/lib/elementary/efl_ui_textbox.c index 64f1034638..bd97b47db7 100644 --- a/src/lib/elementary/efl_ui_textbox.c +++ b/src/lib/elementary/efl_ui_textbox.c @@ -2099,11 +2099,13 @@ _efl_ui_textbox_efl_access_text_character_count_get(const Eo *obj, Efl_Ui_Textbo return eina_unicode_utf8_get_len(txt); } -EOLIAN static char* -_efl_ui_textbox_efl_access_text_string_get(const Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *pd, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset) +EOLIAN static void +_efl_ui_textbox_efl_access_text_string_get(const Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *pd, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset, char **ret EFL_TRANSFER_OWNERSHIP) { Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL; - char *ret = NULL; + + EINA_SAFETY_ON_NULL_RETURN(ret); + *ret = NULL; cur = evas_object_textblock_cursor_new(pd->text_obj); cur2 = evas_object_textblock_cursor_new(pd->text_obj); @@ -2158,26 +2160,26 @@ _efl_ui_textbox_efl_access_text_string_get(const Eo *obj EINA_UNUSED, Efl_Ui_Tex if (end_offset) *end_offset = evas_textblock_cursor_pos_get(cur2); - ret = evas_textblock_cursor_range_text_get(cur, cur2, EVAS_TEXTBLOCK_TEXT_PLAIN); + *ret = evas_textblock_cursor_range_text_get(cur, cur2, EVAS_TEXTBLOCK_TEXT_PLAIN); evas_textblock_cursor_free(cur); evas_textblock_cursor_free(cur2); - if (ret && efl_text_password_get(obj)) + if (*ret && efl_text_password_get(obj)) { int i = 0; - while (ret[i] != '\0') - ret[i++] = ENTRY_PASSWORD_MASK_CHARACTER; + while (*ret[i] != '\0') + *ret[i++] = ENTRY_PASSWORD_MASK_CHARACTER; } - return ret; + return; fail: if (start_offset) *start_offset = -1; if (end_offset) *end_offset = -1; if (cur) evas_textblock_cursor_free(cur); if (cur2) evas_textblock_cursor_free(cur2); - return NULL; + *ret = NULL; } EOLIAN static char* @@ -2453,23 +2455,26 @@ _efl_ui_textbox_efl_access_text_attribute_get(const Eo *obj, Efl_Ui_Textbox_Data return EINA_FALSE; } -EOLIAN static Eina_List* -_efl_ui_textbox_efl_access_text_text_attributes_get(const Eo *obj, Efl_Ui_Textbox_Data *pd EINA_UNUSED, int *start_offset, int *end_offset) +EOLIAN static void +_efl_ui_textbox_efl_access_text_text_attributes_get(const Eo *obj, Efl_Ui_Textbox_Data *pd EINA_UNUSED, int *start_offset, int *end_offset, Eina_List **ret EFL_TRANSFER_OWNERSHIP) { Efl_Text_Cursor_Object *cur1, *cur2; - Eina_List *ret = NULL; Efl_Access_Text_Attribute *attr; Eina_Iterator *annotations; Efl_Text_Attribute_Handle *an; Eo *mobj = (Eo *)obj; + + EINA_SAFETY_ON_NULL_RETURN(ret); + *ret = NULL; + cur1 = efl_ui_textbox_cursor_create(mobj); - if (!cur1) return NULL; + if (!cur1) return; cur2 = efl_ui_textbox_cursor_create(mobj); if (!cur2) { efl_del(cur1); - return NULL; + return; } efl_text_cursor_object_position_set(cur1, *start_offset); @@ -2480,17 +2485,15 @@ _efl_ui_textbox_efl_access_text_text_attributes_get(const Eo *obj, Efl_Ui_Textbo efl_del(cur1); efl_del(cur2); - if (!annotations) return NULL; + if (!annotations) return; EINA_ITERATOR_FOREACH(annotations, an) { attr = _textblock_node_format_to_atspi_text_attr(an); if (!attr) continue; - ret = eina_list_append(ret, attr); + *ret = eina_list_append(*ret, attr); } eina_iterator_free(annotations); - - return ret; } EOLIAN static Eina_List* diff --git a/src/lib/elementary/elm_atspi_bridge.c b/src/lib/elementary/elm_atspi_bridge.c index 43f97bf8bf..868a72ccf2 100644 --- a/src/lib/elementary/elm_atspi_bridge.c +++ b/src/lib/elementary/elm_atspi_bridge.c @@ -1357,7 +1357,7 @@ _text_string_at_offset_get(const Eldbus_Service_Interface *iface, const Eldbus_M } else if (efl_isa(obj, EFL_ACCESS_TEXT_INTERFACE)) { - str = efl_access_text_string_get(obj, gran, &start, &end); + efl_access_text_string_get(obj, gran, &start, &end, &str); } else { @@ -1635,7 +1635,8 @@ _text_attributes_get(const Eldbus_Service_Interface *iface, const Eldbus_Message } else if (efl_isa(obj, EFL_ACCESS_TEXT_INTERFACE)) { - Eina_List *attrs = efl_access_text_attributes_get(obj, &start, &end); + Eina_List *attrs = NULL; + efl_access_text_attributes_get(obj, &start, &end, &attrs); EINA_LIST_FREE(attrs, attr) { eldbus_message_iter_arguments_append(iter_array, "ss", attr->name, attr->value); @@ -2224,7 +2225,7 @@ _text_run_attributes_get(const Eldbus_Service_Interface *iface, const Eldbus_Mes iter_array = eldbus_message_iter_container_new(iter, 'a', "{ss}"); EINA_SAFETY_ON_NULL_GOTO(iter_array, fail); - attrs = efl_access_text_attributes_get(obj, &start, &end); + efl_access_text_attributes_get(obj, &start, &end, &attrs); if (incl_def) { diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index af8445b432..307976976c 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -5691,12 +5691,14 @@ _elm_entry_efl_access_text_character_count_get(const Eo *obj, Elm_Entry_Data *_p return ret; } -EOLIAN static char* -_elm_entry_efl_access_text_string_get(const Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset) +EOLIAN static void +_elm_entry_efl_access_text_string_get(const Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset, char **ret EFL_TRANSFER_OWNERSHIP) { Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL; Evas_Object *tblk; - char *ret = NULL; + + EINA_SAFETY_ON_NULL_RETURN(ret); + *ret = NULL; tblk = elm_entry_textblock_get(obj); if (!tblk) goto fail; @@ -5754,26 +5756,26 @@ _elm_entry_efl_access_text_string_get(const Eo *obj, Elm_Entry_Data *_pd EINA_UN if (end_offset) *end_offset = evas_textblock_cursor_pos_get(cur2); - ret = evas_textblock_cursor_range_text_get(cur, cur2, EVAS_TEXTBLOCK_TEXT_PLAIN); + *ret = evas_textblock_cursor_range_text_get(cur, cur2, EVAS_TEXTBLOCK_TEXT_PLAIN); evas_textblock_cursor_free(cur); evas_textblock_cursor_free(cur2); - if (ret && _pd->password) + if (*ret && _pd->password) { int i = 0; - while (ret[i] != '\0') - ret[i++] = ENTRY_PASSWORD_MASK_CHARACTER; + while (*ret[i] != '\0') + *ret[i++] = ENTRY_PASSWORD_MASK_CHARACTER; } - return ret; + return; fail: if (start_offset) *start_offset = -1; if (end_offset) *end_offset = -1; if (cur) evas_textblock_cursor_free(cur); if (cur2) evas_textblock_cursor_free(cur2); - return NULL; + *ret = NULL; } EOLIAN static char* @@ -6067,26 +6069,29 @@ _elm_entry_efl_access_text_attribute_get(const Eo *obj, Elm_Entry_Data *_pd EINA return EINA_FALSE; } -EOLIAN static Eina_List* -_elm_entry_efl_access_text_text_attributes_get(const Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, int *start_offset, int *end_offset) +EOLIAN static void +_elm_entry_efl_access_text_text_attributes_get(const Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, int *start_offset, int *end_offset, Eina_List **ret EFL_TRANSFER_OWNERSHIP) { Evas_Object *txtblk; Evas_Textblock_Cursor *cur1, *cur2; - Eina_List *formats, *ret = NULL, *l; + Eina_List *formats, *l; Evas_Object_Textblock_Node_Format *format; Efl_Access_Text_Attribute *attr; + EINA_SAFETY_ON_NULL_RETURN(ret); + *ret = NULL; + txtblk = elm_entry_textblock_get(obj); - if (!txtblk) return NULL; + if (!txtblk) return; cur1 = evas_object_textblock_cursor_new(txtblk); - if (!cur1) return NULL; + if (!cur1) return; cur2 = evas_object_textblock_cursor_new(txtblk); if (!cur2) { evas_textblock_cursor_free(cur1); - return NULL; + return; } evas_textblock_cursor_pos_set(cur1, *start_offset); @@ -6097,16 +6102,14 @@ _elm_entry_efl_access_text_text_attributes_get(const Eo *obj, Elm_Entry_Data *_p evas_textblock_cursor_free(cur1); evas_textblock_cursor_free(cur2); - if (!formats) return NULL; + if (!formats) return; EINA_LIST_FOREACH(formats, l , format) { attr = _textblock_node_format_to_atspi_text_attr(format); if (!attr) continue; - ret = eina_list_append(ret, attr); + *ret = eina_list_append(*ret, attr); } - - return ret; } EOLIAN static Eina_List* diff --git a/src/lib/elementary/elm_entry_eo.c b/src/lib/elementary/elm_entry_eo.c index 2cdebe49ba..b993fd5fd7 100644 --- a/src/lib/elementary/elm_entry_eo.c +++ b/src/lib/elementary/elm_entry_eo.c @@ -904,13 +904,13 @@ const char *_elm_entry_efl_access_object_i18n_name_get(const Eo *obj, Elm_Entry_ char *_elm_entry_efl_access_text_access_text_get(const Eo *obj, Elm_Entry_Data *pd, int start_offset, int end_offset); -char *_elm_entry_efl_access_text_string_get(const Eo *obj, Elm_Entry_Data *pd, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset); +void _elm_entry_efl_access_text_string_get(const Eo *obj, Elm_Entry_Data *pd, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset, char **ret EFL_TRANSFER_OWNERSHIP); Eina_Bool _elm_entry_efl_access_text_attribute_get(const Eo *obj, Elm_Entry_Data *pd, const char *name, int *start_offset, int *end_offset, char **value); -Eina_List *_elm_entry_efl_access_text_text_attributes_get(const Eo *obj, Elm_Entry_Data *pd, int *start_offset, int *end_offset); +void _elm_entry_efl_access_text_text_attributes_get(const Eo *obj, Elm_Entry_Data *pd, int *start_offset, int *end_offset, Eina_List **attributes); Eina_List *_elm_entry_efl_access_text_default_attributes_get(const Eo *obj, Elm_Entry_Data *pd); diff --git a/src/tests/elementary/elm_test_entry.c b/src/tests/elementary/elm_test_entry.c index cc68aed0dd..200ff1e744 100644 --- a/src/tests/elementary/elm_test_entry.c +++ b/src/tests/elementary/elm_test_entry.c @@ -155,28 +155,28 @@ EFL_START_TEST(elm_entry_atspi_text_string_get_char) elm_object_text_set(entry, txt); start = 1; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end, &val); ck_assert_str_eq(val, "o"); ck_assert(start == 1); ck_assert(end == 2); if (val) free(val); start = 8; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end, &val); ck_assert_str_eq(val, "ś"); ck_assert(start == 8); ck_assert(end == 9); if (val) free(val); start = 11; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end, &val); ck_assert_str_eq(val, " "); ck_assert(start == 11); ck_assert(end == 12); if (val) free(val); start = 111; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_CHAR, &start, &end, &val); ck_assert(start == -1); ck_assert(end == -1); ck_assert(val == NULL); @@ -198,28 +198,28 @@ EFL_START_TEST(elm_entry_atspi_text_string_get_word) elm_object_text_set(entry, txt); start = 1; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end, &val); ck_assert_str_eq(val, "Lorem"); ck_assert(start == 0); ck_assert(end == 5); if (val) free(val); start = 6; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end, &val); ck_assert_str_eq(val, "ipśum"); ck_assert(start == 6); ck_assert(end == 11); if (val) free(val); start = 19; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end, &val); ck_assert_str_eq(val, "dolor"); ck_assert(start == 14); ck_assert(end == 19); if (val) free(val); start = 111; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end, &val); ck_assert(start == -1); ck_assert(end == -1); ck_assert(val == NULL); @@ -242,28 +242,28 @@ EFL_START_TEST(elm_entry_atspi_text_string_get_paragraph) elm_object_text_set(entry, txt); start = 1; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH, &start, &end, &val); ck_assert_str_eq(val, "Lorem ipśum"); ck_assert(start == 0); ck_assert(end == 11); if (val) free(val); start = 20; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH, &start, &end, &val); ck_assert_str_eq(val, " dolor sit"); ck_assert(start == 12); ck_assert(end == 24); if (val) free(val); start = 25; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH, &start, &end, &val); ck_assert_str_eq(val, " amęt"); ck_assert(start == 25); ck_assert(end == 30); if (val) free(val); start = 111; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_WORD, &start, &end, &val); ck_assert(start == -1); ck_assert(end == -1); ck_assert(val == NULL); @@ -288,7 +288,7 @@ EFL_START_TEST(elm_entry_atspi_text_string_get_line) elm_object_text_set(entry, txt); start = 1; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_LINE, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_LINE, &start, &end, &val); ck_assert_str_eq(val, "Lorem ipśum"); ck_assert(start == 0); @@ -296,7 +296,7 @@ EFL_START_TEST(elm_entry_atspi_text_string_get_line) if (val) free(val); start = 13; - val = efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_LINE, &start, &end); + efl_access_text_string_get(entry, EFL_ACCESS_TEXT_GRANULARITY_LINE, &start, &end, &val); ck_assert_str_eq(val, " dolor sit amęt"); ck_assert(start == 12); ck_assert(end == 29); |