github.com/gotranspile/cxgo@v0.3.7/libs/wctype.go (about) 1 package libs 2 3 import ( 4 "unicode" 5 6 "github.com/gotranspile/cxgo/runtime/libc" 7 "github.com/gotranspile/cxgo/types" 8 ) 9 10 // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html 11 12 const ( 13 wctypeH = "wctype.h" 14 ) 15 16 func init() { 17 RegisterLibrary(wctypeH, func(c *Env) *Library { 18 runeT := c.Go().Rune() 19 isT := c.FuncTT(types.BoolT(), runeT) 20 toT := c.FuncTT(runeT, runeT) 21 return &Library{ 22 Imports: map[string]string{ 23 "libc": RuntimeLibc, 24 "unicode": "unicode", 25 }, 26 Idents: map[string]*types.Ident{ 27 "iswalpha": c.NewIdent("iswalpha", "libc.IsAlpha", libc.IsAlpha, isT), 28 "iswalnum": c.NewIdent("iswalnum", "libc.IsAlnum", libc.IsAlnum, isT), 29 //"iswblank": c.NewIdent("iswblank", "libc.IsBlank", libc.IsBlank, isT), 30 "iswcntrl": c.NewIdent("iswcntrl", "unicode.IsControl", unicode.IsControl, isT), 31 "iswdigit": c.NewIdent("iswdigit", "unicode.IsDigit", unicode.IsDigit, isT), 32 "iswgraph": c.NewIdent("iswgraph", "unicode.IsGraphic", unicode.IsGraphic, isT), 33 "iswlower": c.NewIdent("iswlower", "unicode.IsLower", unicode.IsLower, isT), 34 "iswprint": c.NewIdent("iswprint", "unicode.IsPrint", unicode.IsPrint, isT), 35 "iswpunct": c.NewIdent("iswpunct", "unicode.IsPunct", unicode.IsPunct, isT), 36 "iswspace": c.NewIdent("iswspace", "unicode.IsSpace", unicode.IsSpace, isT), 37 "iswupper": c.NewIdent("iswupper", "unicode.IsUpper", unicode.IsUpper, isT), 38 "towlower": c.NewIdent("towlower", "unicode.ToLower", unicode.ToLower, toT), 39 "towupper": c.NewIdent("towupper", "unicode.ToUpper", unicode.ToUpper, toT), 40 }, 41 Header: ` 42 #include <` + stdboolH + `> 43 #include <` + stddefH + `> 44 #include <` + StdioH + `> 45 46 #define wint_t _cxgo_go_rune 47 const wint_t WEOF = -1; 48 49 _Bool iswalnum(wint_t); 50 _Bool iswalpha(wint_t); 51 _Bool iswblank(wint_t); 52 _Bool iswcntrl(wint_t); 53 //_Bool iswctype(wint_t, wctype_t); 54 _Bool iswdigit(wint_t); 55 _Bool iswgraph(wint_t); 56 _Bool iswlower(wint_t); 57 _Bool iswprint(wint_t); 58 _Bool iswpunct(wint_t); 59 _Bool iswspace(wint_t); 60 _Bool iswupper(wint_t); 61 _Bool iswxdigit(wint_t); 62 //wint_t towctrans(wint_t, wctrans_t); 63 wint_t towlower(wint_t); 64 wint_t towupper(wint_t); 65 //wctrans_t wctrans(const char *); 66 //wctype_t wctype(const char *); 67 /* 68 _Bool iswalnum_l(wint_t, locale_t); 69 _Bool iswalpha_l(wint_t, locale_t); 70 _Bool iswblank_l(wint_t, locale_t); 71 _Bool iswcntrl_l(wint_t, locale_t); 72 _Bool iswctype_l(wint_t, wctype_t, locale_t); 73 _Bool iswdigit_l(wint_t, locale_t); 74 _Bool iswgraph_l(wint_t, locale_t); 75 _Bool iswlower_l(wint_t, locale_t); 76 _Bool iswprint_l(wint_t, locale_t); 77 _Bool iswpunct_l(wint_t, locale_t); 78 _Bool iswspace_l(wint_t, locale_t); 79 _Bool iswupper_l(wint_t, locale_t); 80 _Bool iswxdigit_l(wint_t, locale_t); 81 wint_t towctrans_l(wint_t, wctrans_t, locale_t); 82 wint_t towlower_l(wint_t, locale_t); 83 wint_t towupper_l(wint_t, locale_t); 84 wctrans_t wctrans_l(const char *, locale_t); 85 wctype_t wctype_l(const char *, locale_t); 86 */ 87 `, 88 } 89 }) 90 }