Skip to content

Commit

Permalink
suggest: add wide versions of suggestions_words
Browse files Browse the repository at this point in the history
  • Loading branch information
kevina committed Aug 24, 2019
1 parent f0cfadd commit 9f32997
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions auto/MkSrc/CcHelper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ sub make_wide_version ( $ \@ $ ; \% ) {
#ifdef __cplusplus
# define aspell_cast_(type, expr) (static_cast<type>(expr))
# define aspell_rcast_(type, expr) (reinterpret_cast<type>(expr))
# define aspell_cast_from_wide_(str) (static_cast<const void *>(str))
#else
# define aspell_cast_(type, expr) ((type)(expr))
# define aspell_rcast_(type, expr) ((type)(expr))
# define aspell_cast_from_wide_(str) ((const char *)(str))
#endif
---
Expand Down
11 changes: 10 additions & 1 deletion auto/mk-src.in
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class: speller
/
suggestions
encoded string: word
void pointer: unusued
void pointer: unused

method: store replacement

Expand Down Expand Up @@ -982,10 +982,19 @@ group: suggestions
class: suggestions
/
method: words
cc extra =>
\#define aspell_suggestions_words_w(type, ths, len) \\
aspell_rcast_(const type * *, aspell_suggestions_words(ths, len))
/
string array
array size pointer: len

# method: words wide
# c impl =>
# return reinterpret_cast<const void * *>(ths->words(len));
# const void pointer array
# array size pointer: len

method: normalized scores
desc => Returns the normalized scores. The values are between 0 and 1 inclusive
where higher numbers indicate a better match. The exact values may not
Expand Down
10 changes: 9 additions & 1 deletion test/wide_test_valid.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ int main() {
AspellStringEnumeration * elements = aspell_word_list_elements(suggestions);
const uint16_t * word = aspell_string_enumeration_next_w(uint16_t, elements);
if (memcmp(word, test_word, sizeof(test_incorrect)) != 0) {
fprintf(stderr, "%s", "fail: first suggesion is not what is expected\n");
fprintf(stderr, "%s", "fail: first suggesion is not what is expected (suggest)\n");
fail = 1;
}
delete_aspell_string_enumeration(elements);

AspellSuggestions * sugs = aspell_speller_suggestions_w(spell_checker, test_incorrect, -1, NULL);
unsigned len;
const uint16_t * * words = aspell_suggestions_words_w(uint16_t, sugs, &len);
if (len < 1 || memcmp(words[0], test_word, sizeof(test_incorrect)) != 0) {
fprintf(stderr, "%s", "fail: first suggesion is not what is expected (suggestions)\n");
fail = 1;
}

possible_err = new_aspell_document_checker(spell_checker);
if (aspell_error(possible_err) != 0) {
Expand Down

0 comments on commit 9f32997

Please sign in to comment.