Changeset 28a5ebd in mainline for uspace/srv/hid/output


Ignore:
Timestamp:
2020-06-18T15:39:50Z (6 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce52c333
Parents:
4f663f3e
Message:

Use char32_t instead of wchat_t to represent UTF-32 strings

The intention of the native HelenOS string API has been always to
support Unicode in the UTF-8 and UTF-32 encodings as the sole character
representations and ignore the obsolete mess of older single-byte and
multibyte character encodings. Before C11, the wchar_t type has been
slightly misused for the purpose of the UTF-32 strings. The newer
char32_t type is obviously a much more suitable option. The standard
defines char32_t as uint_least32_t, thus we can take the liberty to fix
it to uint32_t.

To maintain compatilibity with the C Standard, the putwchar(wchar_t)
functions has been replaced by our custom putuchar(char32_t) functions
where appropriate.

Location:
uspace/srv/hid/output
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/output/ctl/serial.c

    r4f663f3e r28a5ebd  
    5757        vt100_goto(state, col, row);
    5858        vt100_set_attr(state, field->attrs);
    59         vt100_putwchar(state, field->ch);
     59        vt100_putuchar(state, field->ch);
    6060}
    6161
     
    122122};
    123123
    124 errno_t serial_init(vt100_putwchar_t putwchar_fn,
     124errno_t serial_init(vt100_putuchar_t putuchar_fn,
    125125    vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn)
    126126{
    127127        vt100_state_t *state =
    128             vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putwchar_fn,
     128            vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putuchar_fn,
    129129            control_puts_fn, flush_fn);
    130130        if (state == NULL)
  • uspace/srv/hid/output/ctl/serial.h

    r4f663f3e r28a5ebd  
    3737#include "../proto/vt100.h"
    3838
    39 extern errno_t serial_init(vt100_putwchar_t, vt100_control_puts_t, vt100_flush_t);
     39extern errno_t serial_init(vt100_putuchar_t, vt100_control_puts_t, vt100_flush_t);
    4040
    4141#endif
  • uspace/srv/hid/output/gfx/font-8x16.c

    r4f663f3e r28a5ebd  
    4545 *
    4646 */
    47 uint16_t fb_font_glyph(const wchar_t ch)
     47uint16_t fb_font_glyph(const char32_t ch)
    4848{
    4949        if (ch == 0x0000)
  • uspace/srv/hid/output/gfx/font-8x16.h

    r4f663f3e r28a5ebd  
    4242#define FONT_SCANLINES  16
    4343
    44 extern uint16_t fb_font_glyph(const wchar_t);
     44extern uint16_t fb_font_glyph(const char32_t);
    4545extern uint8_t fb_font[FONT_GLYPHS][FONT_SCANLINES];
    4646
  • uspace/srv/hid/output/port/chardev.c

    r4f663f3e r28a5ebd  
    7878}
    7979
    80 static void chardev_putwchar(wchar_t ch)
     80static void chardev_putuchar(char32_t ch)
    8181{
    8282        if (chardev_bused == chardev_buf_size)
     
    9393        p = str;
    9494        while (*p != '\0')
    95                 chardev_putwchar(*p++);
     95                chardev_putuchar(*p++);
    9696}
    9797
     
    199199        }
    200200
    201         serial_init(chardev_putwchar, chardev_control_puts, chardev_flush);
     201        serial_init(chardev_putuchar, chardev_control_puts, chardev_flush);
    202202
    203203        discovery_finished = true;
  • uspace/srv/hid/output/port/kfb.c

    r4f663f3e r28a5ebd  
    7979
    8080/** Function to draw a character. */
    81 typedef void (*draw_char_t)(sysarg_t, sysarg_t, bool, wchar_t, pixel_t,
     81typedef void (*draw_char_t)(sysarg_t, sysarg_t, bool, char32_t, pixel_t,
    8282    pixel_t);
    8383
     
    287287 *
    288288 */
    289 static void draw_char_aligned(sysarg_t x, sysarg_t y, bool inverted, wchar_t ch,
     289static void draw_char_aligned(sysarg_t x, sysarg_t y, bool inverted, char32_t ch,
    290290    pixel_t bgcolor, pixel_t fgcolor)
    291291{
     
    350350 */
    351351static void draw_char_fallback(sysarg_t x, sysarg_t y, bool inverted,
    352     wchar_t ch, pixel_t bgcolor, pixel_t fgcolor)
     352    char32_t ch, pixel_t bgcolor, pixel_t fgcolor)
    353353{
    354354        /* Character glyph */
  • uspace/srv/hid/output/proto/vt100.c

    r4f663f3e r28a5ebd  
    140140
    141141vt100_state_t *vt100_state_create(sysarg_t cols, sysarg_t rows,
    142     vt100_putwchar_t putwchar_fn, vt100_control_puts_t control_puts_fn,
     142    vt100_putuchar_t putuchar_fn, vt100_control_puts_t control_puts_fn,
    143143    vt100_flush_t flush_fn)
    144144{
     
    147147                return NULL;
    148148
    149         state->putwchar = putwchar_fn;
     149        state->putuchar = putuchar_fn;
    150150        state->control_puts = control_puts_fn;
    151151        state->flush = flush_fn;
     
    220220}
    221221
    222 void vt100_putwchar(vt100_state_t *state, wchar_t ch)
    223 {
    224         state->putwchar(ch == 0 ? ' ' : ch);
     222void vt100_putuchar(vt100_state_t *state, char32_t ch)
     223{
     224        state->putuchar(ch == 0 ? ' ' : ch);
    225225        state->cur_col++;
    226226
  • uspace/srv/hid/output/proto/vt100.h

    r4f663f3e r28a5ebd  
    3636#include <io/charfield.h>
    3737
    38 typedef void (*vt100_putwchar_t)(wchar_t ch);
     38typedef void (*vt100_putuchar_t)(char32_t ch);
    3939typedef void (*vt100_control_puts_t)(const char *str);
    4040typedef void (*vt100_flush_t)(void);
     
    4848        char_attrs_t cur_attrs;
    4949
    50         vt100_putwchar_t putwchar;
     50        vt100_putuchar_t putuchar;
    5151        vt100_control_puts_t control_puts;
    5252        vt100_flush_t flush;
    5353} vt100_state_t;
    5454
    55 extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putwchar_t,
     55extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putuchar_t,
    5656    vt100_control_puts_t, vt100_flush_t);
    5757extern void vt100_state_destroy(vt100_state_t *);
     
    6464extern void vt100_set_attr(vt100_state_t *, char_attrs_t);
    6565extern void vt100_cursor_visibility(vt100_state_t *, bool);
    66 extern void vt100_putwchar(vt100_state_t *, wchar_t);
     66extern void vt100_putuchar(vt100_state_t *, char32_t);
    6767extern void vt100_flush(vt100_state_t *);
    6868
Note: See TracChangeset for help on using the changeset viewer.