diff options
| author | bptato <nincsnevem662@gmail.com> | 2025-03-20 18:04:13 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2025-03-20 18:10:53 +0100 |
| commit | e1139d40b2e914311085136dcc12b559d8e312b5 (patch) | |
| tree | 348c919981812dce625758f3cb91d6e8f7d71ef4 /lib/monoucha0/monoucha | |
| parent | 72dd71c1e608fcca7acfd067f73e4361da4336aa (diff) | |
| download | chawan-e1139d40b2e914311085136dcc12b559d8e312b5.tar.gz | |
Update libregexp/libunicode bindings
Lack of cbool is a pain. I'm sticking with JS_BOOL for now.
Diffstat (limited to 'lib/monoucha0/monoucha')
| -rw-r--r-- | lib/monoucha0/monoucha/libregexp.nim | 16 | ||||
| -rw-r--r-- | lib/monoucha0/monoucha/libunicode.nim | 12 | ||||
| -rw-r--r-- | lib/monoucha0/monoucha/quickjs.nim | 4 |
3 files changed, 18 insertions, 14 deletions
diff --git a/lib/monoucha0/monoucha/libregexp.nim b/lib/monoucha0/monoucha/libregexp.nim index 4a118afd..a3d0506f 100644 --- a/lib/monoucha0/monoucha/libregexp.nim +++ b/lib/monoucha0/monoucha/libregexp.nim @@ -7,6 +7,8 @@ from std/os import parentDir import libunicode +export libunicode.JS_BOOL + when not compileOption("threads"): const CFLAGS = "-O2 -fwrapv -DMNC_NO_THREADS" else: @@ -26,7 +28,7 @@ proc lre_realloc(opaque, p: pointer; size: csize_t): pointer {.exportc.} = # compilation pass" (i.e. in C). {.emit: """ #ifndef NOT_LRE_ONLY -int lre_check_stack_overflow(void *opaque, size_t alloca_size) +bool lre_check_stack_overflow(void *opaque, size_t alloca_size) { return 0; } @@ -65,17 +67,9 @@ proc lre_get_flags*(bc_buf: ptr uint8): cint const LRE_CC_RES_LEN_MAX* = 3 -# conv_type: -# 0 = to upper -# 1 = to lower -# 2 = case folding -# res must be an array of LRE_CC_RES_LEN_MAX -proc lre_case_conv*(res: ptr UncheckedArray[uint32]; c: uint32; - conv_type: cint): cint - -proc lre_is_space_non_ascii*(c: uint32): cint {.importc.} +proc lre_is_space_non_ascii*(c: uint32): JS_BOOL -proc lre_is_space*(c: uint32): cint {.importc.} +proc lre_is_space*(c: uint32): JS_BOOL {.pop.} # header, importc {.pop.} # raises diff --git a/lib/monoucha0/monoucha/libunicode.nim b/lib/monoucha0/monoucha/libunicode.nim index 4d4b29a8..b3f81e76 100644 --- a/lib/monoucha0/monoucha/libunicode.nim +++ b/lib/monoucha0/monoucha/libunicode.nim @@ -28,6 +28,8 @@ type UnicodeNormalizationEnum* {.size: sizeof(cint).} = enum UNICODE_NFC, UNICODE_NFD, UNICODE_NKFC, UNICODE_NKFD + JS_BOOL* {.importc: "bool".} = bool + {.passc: "-I" & currentSourcePath().parentDir().} {.push header: luheader, importc.} @@ -37,11 +39,19 @@ proc cr_init*(cr: ptr CharRange; mem_opaque: pointer; proc cr_free*(cr: ptr CharRange) +# conv_type: +# 0 = to upper +# 1 = to lower +# 2 = case folding +# res must be an array of LRE_CC_RES_LEN_MAX +proc lre_case_conv*(res: ptr UncheckedArray[uint32]; c: uint32; + conv_type: cint): cint + proc unicode_normalize*(pdst: ptr ptr uint32; src: ptr uint32; src_len: cint; n_type: UnicodeNormalizationEnum; opaque: pointer; realloc_func: DynBufReallocFunc): cint -proc unicode_script*(cr: ptr CharRange; script_name: cstring; is_ext: cint): +proc unicode_script*(cr: ptr CharRange; script_name: cstring; is_ext: JS_BOOL): cint proc unicode_prop*(cr: ptr CharRange; prop_name: cstring): cint proc unicode_general_category*(cr: ptr CharRange; gc_name: cstring): cint diff --git a/lib/monoucha0/monoucha/quickjs.nim b/lib/monoucha0/monoucha/quickjs.nim index 31924112..883806c9 100644 --- a/lib/monoucha0/monoucha/quickjs.nim +++ b/lib/monoucha0/monoucha/quickjs.nim @@ -7,6 +7,8 @@ import libregexp export constcharp +export libregexp.JS_BOOL + {.passc: "-DNOT_LRE_ONLY".} {.passl: "-lm".} @@ -253,8 +255,6 @@ type magic*: int16 u* {.importc.}: JSCFunctionListEntryU - JS_BOOL* {.importc: "bool".} = bool - JSPropertyEnum* {.importc.} = object is_enumerable*: JS_BOOL atom*: JSAtom |