liblouis-rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +520 -0
- data/README.md +100 -0
- data/Rakefile +80 -0
- data/ext/liblouis/braille_character.c +200 -0
- data/ext/liblouis/braille_table.c +198 -0
- data/ext/liblouis/braille_text.c +223 -0
- data/ext/liblouis/extconf.rb +73 -0
- data/ext/liblouis/liblouis.c +168 -0
- data/ext/liblouis/liblouis_ext.h +49 -0
- data/ext/liblouis/table_source.c +161 -0
- data/ext/liblouis/translation.c +443 -0
- data/liblouis-rb.gemspec +49 -0
- data/spec/liblouis_spec.rb +62 -0
- data/test/integration/packaging_test.rb +82 -0
- data/test/table_source_cases.rb +9 -0
- data/test/test_braille_character.rb +62 -0
- data/test/test_braille_table.rb +379 -0
- data/test/test_braille_text.rb +30 -0
- data/test/test_helper.rb +7 -0
- data/test/translation_cases.rb +33 -0
- data/vendor/liblouis/COPYING +674 -0
- data/vendor/liblouis/COPYING.LESSER +502 -0
- data/vendor/liblouis/configure.ac +290 -0
- data/vendor/liblouis/liblouis/commonTranslationFunctions.c +95 -0
- data/vendor/liblouis/liblouis/compileTranslationTable.c +5515 -0
- data/vendor/liblouis/liblouis/internal.h +781 -0
- data/vendor/liblouis/liblouis/liblouis.h.in +514 -0
- data/vendor/liblouis/liblouis/logging.c +233 -0
- data/vendor/liblouis/liblouis/lou_backTranslateString.c +1855 -0
- data/vendor/liblouis/liblouis/lou_translateString.c +4177 -0
- data/vendor/liblouis/liblouis/maketable.c +463 -0
- data/vendor/liblouis/liblouis/metadata.c +1258 -0
- data/vendor/liblouis/liblouis/pattern.c +1632 -0
- data/vendor/liblouis/liblouis/utils.c +448 -0
- data/vendor/liblouis/tables/Es-Es-G0.utb +248 -0
- data/vendor/liblouis/tables/IPA-unicode-range.uti +200 -0
- data/vendor/liblouis/tables/IPA.utb +164 -0
- data/vendor/liblouis/tables/Lv-Lv-g1.utb +509 -0
- data/vendor/liblouis/tables/Makefile.am +503 -0
- data/vendor/liblouis/tables/Pl-Pl-g1.utb +312 -0
- data/vendor/liblouis/tables/README +6 -0
- data/vendor/liblouis/tables/afr-za-g1.ctb +63 -0
- data/vendor/liblouis/tables/afr-za-g2.ctb +1050 -0
- data/vendor/liblouis/tables/akk-borger.utb +997 -0
- data/vendor/liblouis/tables/akk.utb +1002 -0
- data/vendor/liblouis/tables/ancient-languages-borger.utb +114 -0
- data/vendor/liblouis/tables/ancient-languages-us.utb +114 -0
- data/vendor/liblouis/tables/ar-ar-comp8.utb +293 -0
- data/vendor/liblouis/tables/ar-ar-g1-core.uti +291 -0
- data/vendor/liblouis/tables/ar-ar-g1.utb +26 -0
- data/vendor/liblouis/tables/ar-ar-g2.ctb +447 -0
- data/vendor/liblouis/tables/ar-ar-math.uti +501 -0
- data/vendor/liblouis/tables/ar.tbl +17 -0
- data/vendor/liblouis/tables/as-in-g1.utb +27 -0
- data/vendor/liblouis/tables/as.tbl +18 -0
- data/vendor/liblouis/tables/aw-in-g1.utb +27 -0
- data/vendor/liblouis/tables/awa.tbl +18 -0
- data/vendor/liblouis/tables/ba.utb +64 -0
- data/vendor/liblouis/tables/be-in-g1.utb +27 -0
- data/vendor/liblouis/tables/bel-comp.utb +42 -0
- data/vendor/liblouis/tables/bel-detailed.utb +32 -0
- data/vendor/liblouis/tables/bel.utb +61 -0
- data/vendor/liblouis/tables/bengali.cti +238 -0
- data/vendor/liblouis/tables/bg.ctb +215 -0
- data/vendor/liblouis/tables/bg.dis +84 -0
- data/vendor/liblouis/tables/bg.tbl +21 -0
- data/vendor/liblouis/tables/bg.utb +454 -0
- data/vendor/liblouis/tables/bh.ctb +24 -0
- data/vendor/liblouis/tables/bh.tbl +17 -0
- data/vendor/liblouis/tables/bn.tbl +18 -0
- data/vendor/liblouis/tables/bo.ctb +184 -0
- data/vendor/liblouis/tables/bo.tbl +21 -0
- data/vendor/liblouis/tables/boxes.ctb +162 -0
- data/vendor/liblouis/tables/br-in-g1.utb +27 -0
- data/vendor/liblouis/tables/bra.tbl +18 -0
- data/vendor/liblouis/tables/braille-patterns.cti +287 -0
- data/vendor/liblouis/tables/ca-chardefs.cti +225 -0
- data/vendor/liblouis/tables/ca-g1.ctb +46 -0
- data/vendor/liblouis/tables/ca.tbl +18 -0
- data/vendor/liblouis/tables/chr-us-g1.ctb +180 -0
- data/vendor/liblouis/tables/ckb-chardefs.cti +219 -0
- data/vendor/liblouis/tables/ckb-g1.ctb +31 -0
- data/vendor/liblouis/tables/ckb-translation.cti +131 -0
- data/vendor/liblouis/tables/ckb.tbl +18 -0
- data/vendor/liblouis/tables/compress.cti +44 -0
- data/vendor/liblouis/tables/controlchars.cti +27 -0
- data/vendor/liblouis/tables/cop-eg-comp8.utb +255 -0
- data/vendor/liblouis/tables/cop.utb +231 -0
- data/vendor/liblouis/tables/corrections.cti +47 -0
- data/vendor/liblouis/tables/countries.cti +263 -0
- data/vendor/liblouis/tables/critical-apparatus.uti +54 -0
- data/vendor/liblouis/tables/cs-chardefs.cti +385 -0
- data/vendor/liblouis/tables/cs-comp8.utb +405 -0
- data/vendor/liblouis/tables/cs-g1.ctb +37 -0
- data/vendor/liblouis/tables/cs-translation.cti +63 -0
- data/vendor/liblouis/tables/cs.tbl +20 -0
- data/vendor/liblouis/tables/cuneiform-transliterated-compact.utb +432 -0
- data/vendor/liblouis/tables/cuneiform-transliterated.utb +160 -0
- data/vendor/liblouis/tables/cy-cy-g1.utb +487 -0
- data/vendor/liblouis/tables/cy-cy-g2.ctb +199 -0
- data/vendor/liblouis/tables/cy.tbl +19 -0
- data/vendor/liblouis/tables/da-dk-6miscChars.cti +385 -0
- data/vendor/liblouis/tables/da-dk-6miscChars_1993.cti +412 -0
- data/vendor/liblouis/tables/da-dk-8miscChars.cti +90 -0
- data/vendor/liblouis/tables/da-dk-8miscChars_1993.cti +102 -0
- data/vendor/liblouis/tables/da-dk-g08.ctb +290 -0
- data/vendor/liblouis/tables/da-dk-g08_1993.ctb +331 -0
- data/vendor/liblouis/tables/da-dk-g16-lit_1993.ctb +294 -0
- data/vendor/liblouis/tables/da-dk-g16.ctb +289 -0
- data/vendor/liblouis/tables/da-dk-g16_1993.ctb +305 -0
- data/vendor/liblouis/tables/da-dk-g18.ctb +545 -0
- data/vendor/liblouis/tables/da-dk-g18_1993.ctb +563 -0
- data/vendor/liblouis/tables/da-dk-g2.dic +7439 -0
- data/vendor/liblouis/tables/da-dk-g26-lit_1993.ctb +898 -0
- data/vendor/liblouis/tables/da-dk-g26.ctb +1345 -0
- data/vendor/liblouis/tables/da-dk-g26_1993.ctb +1127 -0
- data/vendor/liblouis/tables/da-dk-g26l-lit_1993.ctb +588 -0
- data/vendor/liblouis/tables/da-dk-g26l_1993.ctb +604 -0
- data/vendor/liblouis/tables/da-dk-g28.ctb +2426 -0
- data/vendor/liblouis/tables/da-dk-g28_1993.ctb +2063 -0
- data/vendor/liblouis/tables/da-dk-g28l_1993.ctb +1594 -0
- data/vendor/liblouis/tables/da-dk-octobraille.dis +316 -0
- data/vendor/liblouis/tables/da-dk-octobraille_1993.dis +313 -0
- data/vendor/liblouis/tables/de-accents-detailed.cti +214 -0
- data/vendor/liblouis/tables/de-accents.cti +214 -0
- data/vendor/liblouis/tables/de-chardefs6.cti +289 -0
- data/vendor/liblouis/tables/de-chardefs8.cti +278 -0
- data/vendor/liblouis/tables/de-chess.ctb +37 -0
- data/vendor/liblouis/tables/de-comp6.utb +226 -0
- data/vendor/liblouis/tables/de-de-comp8.ctb +492 -0
- data/vendor/liblouis/tables/de-de.dis +331 -0
- data/vendor/liblouis/tables/de-eurobrl6.dis +101 -0
- data/vendor/liblouis/tables/de-eurobrl6u.dis +96 -0
- data/vendor/liblouis/tables/de-g0-core.uti +732 -0
- data/vendor/liblouis/tables/de-g0-detailed.utb +84 -0
- data/vendor/liblouis/tables/de-g0.utb +57 -0
- data/vendor/liblouis/tables/de-g1-core-patterns.dic +4863 -0
- data/vendor/liblouis/tables/de-g1-core.cti +67 -0
- data/vendor/liblouis/tables/de-g1-detailed.ctb +79 -0
- data/vendor/liblouis/tables/de-g1.ctb +54 -0
- data/vendor/liblouis/tables/de-g2-core-patterns.dic +26711 -0
- data/vendor/liblouis/tables/de-g2-core.cti +607 -0
- data/vendor/liblouis/tables/de-g2-detailed.ctb +60 -0
- data/vendor/liblouis/tables/de-g2.ctb +57 -0
- data/vendor/liblouis/tables/devanagari.cti +325 -0
- data/vendor/liblouis/tables/digits6Dots.uti +30 -0
- data/vendor/liblouis/tables/digits6DotsPlusDot6.uti +30 -0
- data/vendor/liblouis/tables/digits8Dots.uti +30 -0
- data/vendor/liblouis/tables/dra.ctb +23 -0
- data/vendor/liblouis/tables/dra.tbl +21 -0
- data/vendor/liblouis/tables/el.ctb +775 -0
- data/vendor/liblouis/tables/en-GB-g2.ctb +829 -0
- data/vendor/liblouis/tables/en-chardefs.cti +193 -0
- data/vendor/liblouis/tables/en-chess.ctb +37 -0
- data/vendor/liblouis/tables/en-g3-patterns.dic +11194 -0
- data/vendor/liblouis/tables/en-g3.ctb +2261 -0
- data/vendor/liblouis/tables/en-gb-comp8.ctb +282 -0
- data/vendor/liblouis/tables/en-gb-g1.utb +527 -0
- data/vendor/liblouis/tables/en-in-g1.ctb +162 -0
- data/vendor/liblouis/tables/en-nabcc.utb +166 -0
- data/vendor/liblouis/tables/en-nz-g1.utb +65 -0
- data/vendor/liblouis/tables/en-nz-g2.ctb +46 -0
- data/vendor/liblouis/tables/en-ueb-chardefs.uti +938 -0
- data/vendor/liblouis/tables/en-ueb-g1.ctb +167 -0
- data/vendor/liblouis/tables/en-ueb-g2.ctb +3925 -0
- data/vendor/liblouis/tables/en-ueb-math.ctb +71 -0
- data/vendor/liblouis/tables/en-us-brf.dis +102 -0
- data/vendor/liblouis/tables/en-us-comp6.ctb +149 -0
- data/vendor/liblouis/tables/en-us-comp8-ext.utb +626 -0
- data/vendor/liblouis/tables/en-us-comp8.ctb +62 -0
- data/vendor/liblouis/tables/en-us-compbrl.uti +69 -0
- data/vendor/liblouis/tables/en-us-emphasis.uti +45 -0
- data/vendor/liblouis/tables/en-us-g1.ctb +199 -0
- data/vendor/liblouis/tables/en-us-g2.ctb +1081 -0
- data/vendor/liblouis/tables/en-us-interline.ctb +1126 -0
- data/vendor/liblouis/tables/en-us-mathtext.ctb +880 -0
- data/vendor/liblouis/tables/en_CA.ctb +195 -0
- data/vendor/liblouis/tables/en_CA.tbl +21 -0
- data/vendor/liblouis/tables/en_GB.tbl +26 -0
- data/vendor/liblouis/tables/en_US-comp8-ext.tbl +15 -0
- data/vendor/liblouis/tables/en_US.tbl +26 -0
- data/vendor/liblouis/tables/eo-g1-x-system.ctb +85 -0
- data/vendor/liblouis/tables/eo-g1.ctb +165 -0
- data/vendor/liblouis/tables/eo.tbl +14 -0
- data/vendor/liblouis/tables/es-chardefs.cti +206 -0
- data/vendor/liblouis/tables/es-g1.ctb +36 -0
- data/vendor/liblouis/tables/es-g2.ctb +955 -0
- data/vendor/liblouis/tables/es-new.dis +284 -0
- data/vendor/liblouis/tables/es-no.utb +79 -0
- data/vendor/liblouis/tables/es-old.dis +284 -0
- data/vendor/liblouis/tables/es.tbl +19 -0
- data/vendor/liblouis/tables/et-6dot.utb +269 -0
- data/vendor/liblouis/tables/et-g0.utb +139 -0
- data/vendor/liblouis/tables/ethio-g1.ctb +335 -0
- data/vendor/liblouis/tables/eurodefs.cti +107 -0
- data/vendor/liblouis/tables/fa-ir-comp8.ctb +250 -0
- data/vendor/liblouis/tables/fa-ir-g1.utb +311 -0
- data/vendor/liblouis/tables/fi-fi-8dot.ctb +278 -0
- data/vendor/liblouis/tables/fi.utb +354 -0
- data/vendor/liblouis/tables/fil-g2.ctb +491 -0
- data/vendor/liblouis/tables/fr-bfu-comp6-puncs-math.uti +351 -0
- data/vendor/liblouis/tables/fr-bfu-comp6.utb +238 -0
- data/vendor/liblouis/tables/fr-bfu-comp68.cti +251 -0
- data/vendor/liblouis/tables/fr-bfu-comp8.utb +323 -0
- data/vendor/liblouis/tables/fr-bfu-g2.ctb +4644 -0
- data/vendor/liblouis/tables/ga-g1.utb +95 -0
- data/vendor/liblouis/tables/ga-g2.ctb +231 -0
- data/vendor/liblouis/tables/gd.ctb +123 -0
- data/vendor/liblouis/tables/gd.tbl +21 -0
- data/vendor/liblouis/tables/gez.tbl +21 -0
- data/vendor/liblouis/tables/gon.ctb +25 -0
- data/vendor/liblouis/tables/gon.tbl +17 -0
- data/vendor/liblouis/tables/gr-pl-comp8.uti +256 -0
- data/vendor/liblouis/tables/grc-international-common.uti +104 -0
- data/vendor/liblouis/tables/grc-international-composed.uti +268 -0
- data/vendor/liblouis/tables/grc-international-decomposed.uti +268 -0
- data/vendor/liblouis/tables/grc-international-en-composed.utb +54 -0
- data/vendor/liblouis/tables/grc-international-en.utb +206 -0
- data/vendor/liblouis/tables/grc-international-es.utb +228 -0
- data/vendor/liblouis/tables/gu-in-g1.utb +27 -0
- data/vendor/liblouis/tables/gu.tbl +18 -0
- data/vendor/liblouis/tables/gujarati.cti +221 -0
- data/vendor/liblouis/tables/gurumuki.cti +393 -0
- data/vendor/liblouis/tables/haw-us-g1.ctb +54 -0
- data/vendor/liblouis/tables/hbo-cantillated-rules.uti +71 -0
- data/vendor/liblouis/tables/hbo-cantillated.utb +109 -0
- data/vendor/liblouis/tables/hbo-common-rules.uti +152 -0
- data/vendor/liblouis/tables/hbo-ihbc-rules.uti +58 -0
- data/vendor/liblouis/tables/hbo-slim-rules.uti +68 -0
- data/vendor/liblouis/tables/hbo-slim.utb +100 -0
- data/vendor/liblouis/tables/hbo.utb +107 -0
- data/vendor/liblouis/tables/he-IL-comp8.utb +464 -0
- data/vendor/liblouis/tables/he-IL.utb +406 -0
- data/vendor/liblouis/tables/he-common-consonants.uti +102 -0
- data/vendor/liblouis/tables/he-common-vowels-ihbc.uti +161 -0
- data/vendor/liblouis/tables/hi-in-g1.utb +27 -0
- data/vendor/liblouis/tables/hi.tbl +18 -0
- data/vendor/liblouis/tables/hr-chardefs.cti +278 -0
- data/vendor/liblouis/tables/hr-comp8.tbl +21 -0
- data/vendor/liblouis/tables/hr-comp8.utb +239 -0
- data/vendor/liblouis/tables/hr-digits.uti +40 -0
- data/vendor/liblouis/tables/hr-g1.ctb +36 -0
- data/vendor/liblouis/tables/hr-g1.tbl +9 -0
- data/vendor/liblouis/tables/hr-translation.cti +364 -0
- data/vendor/liblouis/tables/ht-frenchcompatibility.uti +61 -0
- data/vendor/liblouis/tables/ht-g1.utb +114 -0
- data/vendor/liblouis/tables/hu-backtranslate-correction.dis +38 -0
- data/vendor/liblouis/tables/hu-backtranslate-word-corrections.cti +4293 -0
- data/vendor/liblouis/tables/hu-chardefs.cti +298 -0
- data/vendor/liblouis/tables/hu-exceptionwords.cti +3204 -0
- data/vendor/liblouis/tables/hu-hu-comp8.ctb +183 -0
- data/vendor/liblouis/tables/hu-hu-g1.ctb +129 -0
- data/vendor/liblouis/tables/hu-hu-g1_braille_input.cti +486 -0
- data/vendor/liblouis/tables/hu-hu-g2.ctb +270 -0
- data/vendor/liblouis/tables/hu-hu-g2_exceptions.cti +1164 -0
- data/vendor/liblouis/tables/hy.ctb +121 -0
- data/vendor/liblouis/tables/hy.tbl +21 -0
- data/vendor/liblouis/tables/hyph_cs_CZ.dic +3637 -0
- data/vendor/liblouis/tables/hyph_da_DK.dic +8896 -0
- data/vendor/liblouis/tables/hyph_de_DE.dic +5799 -0
- data/vendor/liblouis/tables/hyph_en_US.dic +5537 -0
- data/vendor/liblouis/tables/hyph_eo.dic +1024 -0
- data/vendor/liblouis/tables/hyph_es_ES.dic +877 -0
- data/vendor/liblouis/tables/hyph_fr_FR.dic +1067 -0
- data/vendor/liblouis/tables/hyph_hu_HU.dic +98519 -0
- data/vendor/liblouis/tables/hyph_it_IT.dic +410 -0
- data/vendor/liblouis/tables/hyph_nb_NO.dic +27142 -0
- data/vendor/liblouis/tables/hyph_nl_NL.dic +12725 -0
- data/vendor/liblouis/tables/hyph_nn_NO.dic +27142 -0
- data/vendor/liblouis/tables/hyph_pl_PL.dic +4074 -0
- data/vendor/liblouis/tables/hyph_pt_PT.dic +308 -0
- data/vendor/liblouis/tables/hyph_ru.dic +6480 -0
- data/vendor/liblouis/tables/hyph_sv_SE.dic +4697 -0
- data/vendor/liblouis/tables/is-chardefs6.cti +170 -0
- data/vendor/liblouis/tables/is-chardefs8.cti +293 -0
- data/vendor/liblouis/tables/is.ctb +157 -0
- data/vendor/liblouis/tables/is.tbl +18 -0
- data/vendor/liblouis/tables/it-it-comp6.utb +404 -0
- data/vendor/liblouis/tables/it-it-comp8.utb +663 -0
- data/vendor/liblouis/tables/iu-ca-g1.ctb +236 -0
- data/vendor/liblouis/tables/ja-kantenji-ucs2.utb +11448 -0
- data/vendor/liblouis/tables/ja-kantenji.utb +53 -0
- data/vendor/liblouis/tables/ja-rokutenkanji.utb +8710 -0
- data/vendor/liblouis/tables/ka-in-g1.utb +27 -0
- data/vendor/liblouis/tables/ka.utb +128 -0
- data/vendor/liblouis/tables/kannada.cti +282 -0
- data/vendor/liblouis/tables/kh-in-g1.utb +26 -0
- data/vendor/liblouis/tables/kha.tbl +18 -0
- data/vendor/liblouis/tables/kk.utb +77 -0
- data/vendor/liblouis/tables/km-g1.utb +412 -0
- data/vendor/liblouis/tables/kmr.tbl +108 -0
- data/vendor/liblouis/tables/kn.tbl +18 -0
- data/vendor/liblouis/tables/ko-2006-g1.ctb +49 -0
- data/vendor/liblouis/tables/ko-2006-g2.ctb +53 -0
- data/vendor/liblouis/tables/ko-2006.cti +190 -0
- data/vendor/liblouis/tables/ko-chars.cti +15140 -0
- data/vendor/liblouis/tables/ko-g1-rules.cti +634 -0
- data/vendor/liblouis/tables/ko-g1.ctb +48 -0
- data/vendor/liblouis/tables/ko-g2-rules.cti +9263 -0
- data/vendor/liblouis/tables/ko-g2.ctb +52 -0
- data/vendor/liblouis/tables/ko.cti +223 -0
- data/vendor/liblouis/tables/kok.ctb +24 -0
- data/vendor/liblouis/tables/kok.tbl +17 -0
- data/vendor/liblouis/tables/kru.ctb +24 -0
- data/vendor/liblouis/tables/kru.tbl +17 -0
- data/vendor/liblouis/tables/ks-in-g1.utb +27 -0
- data/vendor/liblouis/tables/latinLetterDef6Dots.uti +78 -0
- data/vendor/liblouis/tables/latinLetterDef8Dots.uti +75 -0
- data/vendor/liblouis/tables/latinLowercase.uti +389 -0
- data/vendor/liblouis/tables/latinUppercaseComp6.uti +78 -0
- data/vendor/liblouis/tables/lg-ug-g1.utb +60 -0
- data/vendor/liblouis/tables/litdigits6Dots.uti +30 -0
- data/vendor/liblouis/tables/litdigits6DotsPlusDot6.uti +30 -0
- data/vendor/liblouis/tables/lo-g1.utb +3127 -0
- data/vendor/liblouis/tables/loweredDigits6Dots.uti +30 -0
- data/vendor/liblouis/tables/loweredDigits8Dots.uti +30 -0
- data/vendor/liblouis/tables/lt-6dot.utb +308 -0
- data/vendor/liblouis/tables/lt-8dot.utb +281 -0
- data/vendor/liblouis/tables/lt.ctb +313 -0
- data/vendor/liblouis/tables/lv.tbl +22 -0
- data/vendor/liblouis/tables/maketablelist.sh +52 -0
- data/vendor/liblouis/tables/malayalam.cti +674 -0
- data/vendor/liblouis/tables/mao-nz-g1.ctb +65 -0
- data/vendor/liblouis/tables/marburg_single_cell_defs.cti +66 -0
- data/vendor/liblouis/tables/marburg_unicode_defs.cti +297 -0
- data/vendor/liblouis/tables/mk-g1.utb +240 -0
- data/vendor/liblouis/tables/ml-in-g1.utb +27 -0
- data/vendor/liblouis/tables/ml.tbl +21 -0
- data/vendor/liblouis/tables/mn-MN-common.cti +110 -0
- data/vendor/liblouis/tables/mn-MN-g1.utb +52 -0
- data/vendor/liblouis/tables/mn-MN-g2.ctb +50 -0
- data/vendor/liblouis/tables/mn-in-g1.utb +27 -0
- data/vendor/liblouis/tables/mni.tbl +18 -0
- data/vendor/liblouis/tables/mr-in-g1.utb +27 -0
- data/vendor/liblouis/tables/mr.tbl +18 -0
- data/vendor/liblouis/tables/ms-my-g2.ctb +4897 -0
- data/vendor/liblouis/tables/mt.ctb +114 -0
- data/vendor/liblouis/tables/mt.tbl +21 -0
- data/vendor/liblouis/tables/mun.ctb +24 -0
- data/vendor/liblouis/tables/mun.tbl +17 -0
- data/vendor/liblouis/tables/mwr.ctb +24 -0
- data/vendor/liblouis/tables/mwr.tbl +17 -0
- data/vendor/liblouis/tables/my-g1.utb +771 -0
- data/vendor/liblouis/tables/my-g2.ctb +3805 -0
- data/vendor/liblouis/tables/ne.ctb +22 -0
- data/vendor/liblouis/tables/ne.tbl +18 -0
- data/vendor/liblouis/tables/nemethdefs.cti +382 -0
- data/vendor/liblouis/tables/nl-BE.dis +532 -0
- data/vendor/liblouis/tables/nl-NL-g0.utb.in +646 -0
- data/vendor/liblouis/tables/nl-chardefs.uti.in +455 -0
- data/vendor/liblouis/tables/nl-comp8.utb +411 -0
- data/vendor/liblouis/tables/nl-print.dis +551 -0
- data/vendor/liblouis/tables/nl-unicode.dis +540 -0
- data/vendor/liblouis/tables/no-no-8dot-fallback-6dot-g0.utb +59 -0
- data/vendor/liblouis/tables/no-no-8dot.utb +629 -0
- data/vendor/liblouis/tables/no-no-braillo-047-01.dis +247 -0
- data/vendor/liblouis/tables/no-no-chardefs6.uti +305 -0
- data/vendor/liblouis/tables/no-no-comp8.ctb +323 -0
- data/vendor/liblouis/tables/no-no-cyrillic6dot.uti +95 -0
- data/vendor/liblouis/tables/no-no-g0.utb +320 -0
- data/vendor/liblouis/tables/no-no-g1.ctb +272 -0
- data/vendor/liblouis/tables/no-no-g2.ctb +737 -0
- data/vendor/liblouis/tables/no-no-g3.ctb +3597 -0
- data/vendor/liblouis/tables/no-no-generic.ctb +295 -0
- data/vendor/liblouis/tables/no-no-generic.dis +295 -0
- data/vendor/liblouis/tables/no-no-latinLetterDef6Dots_diacritics.uti +852 -0
- data/vendor/liblouis/tables/no-no.dis +291 -0
- data/vendor/liblouis/tables/np-in-g1.utb +27 -0
- data/vendor/liblouis/tables/nso-za-g1.utb +38 -0
- data/vendor/liblouis/tables/nso-za-g2.ctb +38 -0
- data/vendor/liblouis/tables/ny-mw.utb +70 -0
- data/vendor/liblouis/tables/or-in-g1.utb +27 -0
- data/vendor/liblouis/tables/or.tbl +18 -0
- data/vendor/liblouis/tables/oriya.cti +238 -0
- data/vendor/liblouis/tables/ovd-6g0.utb +64 -0
- data/vendor/liblouis/tables/ovd-8g0.utb +81 -0
- data/vendor/liblouis/tables/pa.tbl +18 -0
- data/vendor/liblouis/tables/pi.ctb +24 -0
- data/vendor/liblouis/tables/pi.tbl +17 -0
- data/vendor/liblouis/tables/pl-pl-comp8.ctb +658 -0
- data/vendor/liblouis/tables/pl.tbl +12 -0
- data/vendor/liblouis/tables/printables.cti +70 -0
- data/vendor/liblouis/tables/pt-comp6.utb +299 -0
- data/vendor/liblouis/tables/pt-pt-comp8.ctb +395 -0
- data/vendor/liblouis/tables/pt-pt-g1.utb +1312 -0
- data/vendor/liblouis/tables/pt-pt-g2.ctb +874 -0
- data/vendor/liblouis/tables/pt.tbl +20 -0
- data/vendor/liblouis/tables/pu-in-g1.utb +42 -0
- data/vendor/liblouis/tables/quotation-marks.uti +30 -0
- data/vendor/liblouis/tables/ro-g0.utb +85 -0
- data/vendor/liblouis/tables/ro.ctb +126 -0
- data/vendor/liblouis/tables/ro.tbl +21 -0
- data/vendor/liblouis/tables/ru-brf.dis +116 -0
- data/vendor/liblouis/tables/ru-comp6.utb +258 -0
- data/vendor/liblouis/tables/ru-comp8.utb +740 -0
- data/vendor/liblouis/tables/ru-letters.dis +145 -0
- data/vendor/liblouis/tables/ru-litbrl-detailed.utb +77 -0
- data/vendor/liblouis/tables/ru-litbrl.ctb +857 -0
- data/vendor/liblouis/tables/ru-math.uti +395 -0
- data/vendor/liblouis/tables/ru-ru-g1.ctb +804 -0
- data/vendor/liblouis/tables/ru-unicode.dis +121 -0
- data/vendor/liblouis/tables/rw-rw-g1.utb +133 -0
- data/vendor/liblouis/tables/sa-in-g1.utb +27 -0
- data/vendor/liblouis/tables/sa.tbl +18 -0
- data/vendor/liblouis/tables/sah.utb +72 -0
- data/vendor/liblouis/tables/sd.tbl +18 -0
- data/vendor/liblouis/tables/se-se.ctb +246 -0
- data/vendor/liblouis/tables/se-se.dis +334 -0
- data/vendor/liblouis/tables/si-in-g1.utb +27 -0
- data/vendor/liblouis/tables/sin.cti +213 -0
- data/vendor/liblouis/tables/sin.utb +35 -0
- data/vendor/liblouis/tables/sk-g1.ctb +1019 -0
- data/vendor/liblouis/tables/sk-sk-g1.utb +206 -0
- data/vendor/liblouis/tables/sk-sk.utb +112 -0
- data/vendor/liblouis/tables/sl-si-comp8.ctb +204 -0
- data/vendor/liblouis/tables/sl-si-g1.utb +471 -0
- data/vendor/liblouis/tables/sl.tbl +20 -0
- data/vendor/liblouis/tables/smi-6g0.utb +64 -0
- data/vendor/liblouis/tables/smi-8g0.utb +61 -0
- data/vendor/liblouis/tables/sot-za-g1.ctb +72 -0
- data/vendor/liblouis/tables/sot-za-g2.ctb +244 -0
- data/vendor/liblouis/tables/spaces.uti +62 -0
- data/vendor/liblouis/tables/sr-Cyrl.ctb +59 -0
- data/vendor/liblouis/tables/sr-common.cti +161 -0
- data/vendor/liblouis/tables/sr-cyrletters.cti +92 -0
- data/vendor/liblouis/tables/sr-g1.ctb +57 -0
- data/vendor/liblouis/tables/sr-latletters.cti +45 -0
- data/vendor/liblouis/tables/sv-1989.ctb +241 -0
- data/vendor/liblouis/tables/sv-1996.ctb +180 -0
- data/vendor/liblouis/tables/sv-6common.uti +1199 -0
- data/vendor/liblouis/tables/sv-6g0d.utb +508 -0
- data/vendor/liblouis/tables/sv-6g0p.utb +61 -0
- data/vendor/liblouis/tables/sv-6g1.uti +106 -0
- data/vendor/liblouis/tables/sv-6g1d.ctb +57 -0
- data/vendor/liblouis/tables/sv-6g2.uti +254 -0
- data/vendor/liblouis/tables/sv-6g2d.ctb +57 -0
- data/vendor/liblouis/tables/sv-8g0d.utb +495 -0
- data/vendor/liblouis/tables/sv-8g0n.utb +1236 -0
- data/vendor/liblouis/tables/sv-8g1.uti +199 -0
- data/vendor/liblouis/tables/sv-8g1d.ctb +73 -0
- data/vendor/liblouis/tables/sv-8g1n.ctb +73 -0
- data/vendor/liblouis/tables/sv-8g2.uti +486 -0
- data/vendor/liblouis/tables/sv-8g2d.ctb +73 -0
- data/vendor/liblouis/tables/sv-8g2n.ctb +73 -0
- data/vendor/liblouis/tables/sv-g0.utb +65 -0
- data/vendor/liblouis/tables/sv-g1.ctb +57 -0
- data/vendor/liblouis/tables/sv-g2.ctb +57 -0
- data/vendor/liblouis/tables/sv-phon.uti +241 -0
- data/vendor/liblouis/tables/sw-ke-g1-2.ctb +90 -0
- data/vendor/liblouis/tables/sw-ke-g1-3.ctb +109 -0
- data/vendor/liblouis/tables/sw-ke-g1-4.ctb +107 -0
- data/vendor/liblouis/tables/sw-ke-g1-5.ctb +73 -0
- data/vendor/liblouis/tables/sw-ke-g1.utb +278 -0
- data/vendor/liblouis/tables/sw-ke-g2.ctb +276 -0
- data/vendor/liblouis/tables/syc.utb +195 -0
- data/vendor/liblouis/tables/ta-ta-g1.ctb +167 -0
- data/vendor/liblouis/tables/ta.ctb +24 -0
- data/vendor/liblouis/tables/ta.tbl +21 -0
- data/vendor/liblouis/tables/tamil.cti +86 -0
- data/vendor/liblouis/tables/te-in-g1.utb +27 -0
- data/vendor/liblouis/tables/te.tbl +18 -0
- data/vendor/liblouis/tables/telugu.cti +239 -0
- data/vendor/liblouis/tables/text_nabcc.dis +426 -0
- data/vendor/liblouis/tables/th-comp8-backward.utb +226 -0
- data/vendor/liblouis/tables/th-g0.utb +177 -0
- data/vendor/liblouis/tables/th-g1.utb +89 -0
- data/vendor/liblouis/tables/th-g1.uti +315 -0
- data/vendor/liblouis/tables/th-g2.ctb +616 -0
- data/vendor/liblouis/tables/tr-g1.ctb +254 -0
- data/vendor/liblouis/tables/tr-g2.ctb +863 -0
- data/vendor/liblouis/tables/tr-g2.tbl +20 -0
- data/vendor/liblouis/tables/tr.ctb +324 -0
- data/vendor/liblouis/tables/tr.tbl +21 -0
- data/vendor/liblouis/tables/tsn-za-g1.ctb +33 -0
- data/vendor/liblouis/tables/tsn-za-g2.ctb +33 -0
- data/vendor/liblouis/tables/tt.utb +74 -0
- data/vendor/liblouis/tables/uga.utb +86 -0
- data/vendor/liblouis/tables/uk-comp.utb +53 -0
- data/vendor/liblouis/tables/uk-detailed.utb +32 -0
- data/vendor/liblouis/tables/uk.utb +101 -0
- data/vendor/liblouis/tables/ukchardefs.cti +106 -0
- data/vendor/liblouis/tables/ukmaths_single_cell_defs.cti +65 -0
- data/vendor/liblouis/tables/ukmaths_unicode_defs.cti +298 -0
- data/vendor/liblouis/tables/uni-text.dis +330 -0
- data/vendor/liblouis/tables/unicode-braille.utb +291 -0
- data/vendor/liblouis/tables/unicode-without-blank.dis +24 -0
- data/vendor/liblouis/tables/unicode.dis +278 -0
- data/vendor/liblouis/tables/ur-pk-g1.utb +248 -0
- data/vendor/liblouis/tables/ur-pk-g2.ctb +641 -0
- data/vendor/liblouis/tables/us-table.dis +67 -0
- data/vendor/liblouis/tables/uz-g1.utb +117 -0
- data/vendor/liblouis/tables/ve-za-g1.utb +69 -0
- data/vendor/liblouis/tables/ve-za-g2.ctb +208 -0
- data/vendor/liblouis/tables/vi-cb8.utb +49 -0
- data/vendor/liblouis/tables/vi-charsdef.uti +36 -0
- data/vendor/liblouis/tables/vi-lettersdef.uti +401 -0
- data/vendor/liblouis/tables/vi-puncsdef.uti +446 -0
- data/vendor/liblouis/tables/vi-saigon-g1.ctb +530 -0
- data/vendor/liblouis/tables/vi-vn-g0.utb +135 -0
- data/vendor/liblouis/tables/vi-vn-g1.ctb +574 -0
- data/vendor/liblouis/tables/vi-vn-g2.ctb +743 -0
- data/vendor/liblouis/tables/wiskunde-chardefs.cti +261 -0
- data/vendor/liblouis/tables/wordcx.dis +91 -0
- data/vendor/liblouis/tables/xh-za-g1.utb +61 -0
- data/vendor/liblouis/tables/xh-za-g2.ctb +386 -0
- data/vendor/liblouis/tables/yi.utb +236 -0
- data/vendor/liblouis/tables/zh-chn.ctb +45011 -0
- data/vendor/liblouis/tables/zh-hk.ctb +10461 -0
- data/vendor/liblouis/tables/zh-tw.ctb +53810 -0
- data/vendor/liblouis/tables/zh_CHN.tbl +23 -0
- data/vendor/liblouis/tables/zhcn-cbs.ctb +31523 -0
- data/vendor/liblouis/tables/zhcn-g1.ctb +26523 -0
- data/vendor/liblouis/tables/zhcn-g2.ctb +26519 -0
- data/vendor/liblouis/tables/zu-za-g1.utb +33 -0
- data/vendor/liblouis/tables/zu-za-g2.ctb +33 -0
- metadata +558 -0
data/Rakefile
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rake"
|
|
4
|
+
require "rake/clean"
|
|
5
|
+
require "rbconfig"
|
|
6
|
+
require "shellwords"
|
|
7
|
+
|
|
8
|
+
ROOT = __dir__
|
|
9
|
+
EXTENSION_DIR = File.join(ROOT, "ext", "liblouis")
|
|
10
|
+
EXTENSION = File.join(EXTENSION_DIR, "liblouis.#{RbConfig::CONFIG.fetch("DLEXT")}")
|
|
11
|
+
|
|
12
|
+
CLEAN.include(
|
|
13
|
+
File.join(EXTENSION_DIR, "*.o"),
|
|
14
|
+
File.join(EXTENSION_DIR, "*.def"),
|
|
15
|
+
File.join(EXTENSION_DIR, "mkmf.log")
|
|
16
|
+
)
|
|
17
|
+
CLOBBER.include(
|
|
18
|
+
File.join(EXTENSION_DIR, "Makefile"),
|
|
19
|
+
File.join(EXTENSION_DIR, "config.h"),
|
|
20
|
+
File.join(EXTENSION_DIR, "liblouis.h"),
|
|
21
|
+
EXTENSION
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def in_extension_directory
|
|
25
|
+
Dir.chdir(EXTENSION_DIR) { yield }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def msys_path(path)
|
|
29
|
+
path.tr("\\", "/").sub(/\A([A-Za-z]):/) { "/#{$1.downcase}" }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc "Compile the native extension"
|
|
33
|
+
task :compile do
|
|
34
|
+
ridk = File.join(RbConfig::CONFIG.fetch("bindir"), "ridk.cmd")
|
|
35
|
+
if Gem.win_platform? && File.file?(ridk)
|
|
36
|
+
command = [
|
|
37
|
+
"cd #{Shellwords.escape(msys_path(EXTENSION_DIR))}",
|
|
38
|
+
"#{Shellwords.escape(msys_path(RbConfig.ruby))} extconf.rb",
|
|
39
|
+
"make -j4"
|
|
40
|
+
].join(" && ")
|
|
41
|
+
sh ridk, "exec", "bash", "-lc", command
|
|
42
|
+
else
|
|
43
|
+
in_extension_directory do
|
|
44
|
+
ruby "extconf.rb"
|
|
45
|
+
sh RbConfig::CONFIG.fetch("MAKE", "make")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run_suite(pattern)
|
|
51
|
+
files = Dir[File.join(ROOT, pattern)].sort
|
|
52
|
+
ruby "-I#{EXTENSION_DIR}", "-e", files.map { |file| "require #{file.dump}" }.join("; ")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc "Run Minitest unit tests"
|
|
56
|
+
task test: :compile do
|
|
57
|
+
run_suite("test/**/test_*.rb")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "Run Minitest specs"
|
|
61
|
+
task spec: :compile do
|
|
62
|
+
run_suite("spec/**/*_spec.rb")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
desc "Build the gem in pkg"
|
|
66
|
+
task :gem do
|
|
67
|
+
spec = Gem::Specification.load(File.join(ROOT, "liblouis-rb.gemspec"))
|
|
68
|
+
abort "Could not load liblouis-rb.gemspec" unless spec
|
|
69
|
+
package_dir = File.join(ROOT, "pkg")
|
|
70
|
+
mkdir_p package_dir
|
|
71
|
+
ruby "-S", "gem", "build", spec.loaded_from,
|
|
72
|
+
"--output", File.join(package_dir, spec.file_name)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
desc "Test gem installation in paths with spaces and missing submodules"
|
|
76
|
+
task "test:package" do
|
|
77
|
+
ruby File.join(ROOT, "test/integration/packaging_test.rb")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
task default: %i[test spec]
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#include "liblouis_ext.h"
|
|
2
|
+
|
|
3
|
+
typedef struct {
|
|
4
|
+
uint8_t mask;
|
|
5
|
+
} ll_character_t;
|
|
6
|
+
|
|
7
|
+
static const rb_data_type_t ll_character_type = {
|
|
8
|
+
"LibLouis::BrailleCharacter",
|
|
9
|
+
{0, RUBY_TYPED_DEFAULT_FREE, 0,},
|
|
10
|
+
0, 0,
|
|
11
|
+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
static VALUE
|
|
15
|
+
ll_character_alloc(VALUE klass)
|
|
16
|
+
{
|
|
17
|
+
ll_character_t *character;
|
|
18
|
+
VALUE object = TypedData_Make_Struct(
|
|
19
|
+
klass, ll_character_t, &ll_character_type, character);
|
|
20
|
+
|
|
21
|
+
character->mask = 0;
|
|
22
|
+
return object;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static uint8_t
|
|
26
|
+
ll_mask_from_value(VALUE value)
|
|
27
|
+
{
|
|
28
|
+
if (RB_INTEGER_TYPE_P(value)) {
|
|
29
|
+
long mask = NUM2LONG(value);
|
|
30
|
+
if (mask < 0 || mask > 255)
|
|
31
|
+
rb_raise(rb_eRangeError, "braille mask must be between 0 and 255");
|
|
32
|
+
return (uint8_t)mask;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (RB_TYPE_P(value, T_ARRAY)) {
|
|
36
|
+
uint8_t mask = 0;
|
|
37
|
+
long index;
|
|
38
|
+
for (index = 0; index < RARRAY_LEN(value); index++) {
|
|
39
|
+
int dot = NUM2INT(rb_ary_entry(value, index));
|
|
40
|
+
if (dot < 1 || dot > 8)
|
|
41
|
+
rb_raise(rb_eRangeError, "braille dot must be between 1 and 8");
|
|
42
|
+
mask |= (uint8_t)(1u << (dot - 1));
|
|
43
|
+
}
|
|
44
|
+
return mask;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (RB_TYPE_P(value, T_STRING)) {
|
|
48
|
+
int length;
|
|
49
|
+
VALUE storage = ll_wide_storage_from_string(value, &length);
|
|
50
|
+
unsigned int codepoint;
|
|
51
|
+
|
|
52
|
+
if (length != 1)
|
|
53
|
+
rb_raise(rb_eArgError, "expected exactly one Unicode braille character");
|
|
54
|
+
codepoint = (unsigned int)LL_PTR(widechar, storage)[0];
|
|
55
|
+
if (codepoint < 0x2800 || codepoint > 0x28ff)
|
|
56
|
+
rb_raise(rb_eArgError, "expected a character in the Unicode braille block");
|
|
57
|
+
return (uint8_t)(codepoint - 0x2800);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
rb_raise(rb_eTypeError, "expected an Integer mask, an Array of dots, or a Unicode braille character");
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static VALUE
|
|
65
|
+
ll_character_initialize(int argc, VALUE *argv, VALUE self)
|
|
66
|
+
{
|
|
67
|
+
VALUE value = INT2FIX(0);
|
|
68
|
+
uint8_t mask;
|
|
69
|
+
ll_character_t *character;
|
|
70
|
+
|
|
71
|
+
rb_check_frozen(self);
|
|
72
|
+
rb_scan_args(argc, argv, "01", &value);
|
|
73
|
+
TypedData_Get_Struct(self, ll_character_t, &ll_character_type, character);
|
|
74
|
+
mask = ll_mask_from_value(value);
|
|
75
|
+
rb_check_frozen(self);
|
|
76
|
+
character->mask = mask;
|
|
77
|
+
rb_obj_freeze(self);
|
|
78
|
+
return self;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static VALUE
|
|
82
|
+
ll_character_initialize_copy(VALUE self, VALUE source)
|
|
83
|
+
{
|
|
84
|
+
ll_character_t *character;
|
|
85
|
+
|
|
86
|
+
if (self == source)
|
|
87
|
+
return self;
|
|
88
|
+
rb_obj_init_copy(self, source);
|
|
89
|
+
rb_check_frozen(self);
|
|
90
|
+
TypedData_Get_Struct(self, ll_character_t, &ll_character_type, character);
|
|
91
|
+
character->mask = ll_character_mask(source);
|
|
92
|
+
return self;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
VALUE
|
|
96
|
+
ll_character_new(uint8_t mask)
|
|
97
|
+
{
|
|
98
|
+
ll_character_t *character;
|
|
99
|
+
VALUE object = TypedData_Make_Struct(ll_cBrailleCharacter, ll_character_t,
|
|
100
|
+
&ll_character_type, character);
|
|
101
|
+
character->mask = mask;
|
|
102
|
+
rb_obj_freeze(object);
|
|
103
|
+
return object;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
uint8_t
|
|
107
|
+
ll_character_mask(VALUE object)
|
|
108
|
+
{
|
|
109
|
+
ll_character_t *character;
|
|
110
|
+
|
|
111
|
+
TypedData_Get_Struct(object, ll_character_t, &ll_character_type, character);
|
|
112
|
+
return character->mask;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static VALUE
|
|
116
|
+
ll_character_dots(VALUE self)
|
|
117
|
+
{
|
|
118
|
+
uint8_t mask = ll_character_mask(self);
|
|
119
|
+
VALUE dots = rb_ary_new_capa(8);
|
|
120
|
+
int dot;
|
|
121
|
+
|
|
122
|
+
for (dot = 1; dot <= 8; dot++)
|
|
123
|
+
if (mask & (1u << (dot - 1)))
|
|
124
|
+
rb_ary_push(dots, INT2FIX(dot));
|
|
125
|
+
return dots;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static VALUE
|
|
129
|
+
ll_character_mask_value(VALUE self)
|
|
130
|
+
{
|
|
131
|
+
return UINT2NUM(ll_character_mask(self));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static VALUE
|
|
135
|
+
ll_character_unicode(VALUE self)
|
|
136
|
+
{
|
|
137
|
+
return rb_enc_uint_chr(0x2800u + ll_character_mask(self), rb_utf8_encoding());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static VALUE
|
|
141
|
+
ll_character_equal(VALUE self, VALUE other)
|
|
142
|
+
{
|
|
143
|
+
if (!rb_typeddata_is_kind_of(other, &ll_character_type))
|
|
144
|
+
return Qfalse;
|
|
145
|
+
return ll_character_mask(self) == ll_character_mask(other) ? Qtrue : Qfalse;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static VALUE
|
|
149
|
+
ll_character_hash(VALUE self)
|
|
150
|
+
{
|
|
151
|
+
return rb_hash(UINT2NUM(ll_character_mask(self)));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static VALUE
|
|
155
|
+
ll_character_inspect(VALUE self)
|
|
156
|
+
{
|
|
157
|
+
return rb_sprintf("#<LibLouis::BrailleCharacter dots=%+"PRIsVALUE" mask=%u>",
|
|
158
|
+
ll_character_dots(self), (unsigned int)ll_character_mask(self));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
#define DEFINE_DOT_PREDICATE(number) \
|
|
162
|
+
static VALUE ll_character_dot##number##_p(VALUE self) \
|
|
163
|
+
{ \
|
|
164
|
+
return (ll_character_mask(self) & (1u << ((number) - 1))) ? Qtrue : Qfalse; \
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
DEFINE_DOT_PREDICATE(1)
|
|
168
|
+
DEFINE_DOT_PREDICATE(2)
|
|
169
|
+
DEFINE_DOT_PREDICATE(3)
|
|
170
|
+
DEFINE_DOT_PREDICATE(4)
|
|
171
|
+
DEFINE_DOT_PREDICATE(5)
|
|
172
|
+
DEFINE_DOT_PREDICATE(6)
|
|
173
|
+
DEFINE_DOT_PREDICATE(7)
|
|
174
|
+
DEFINE_DOT_PREDICATE(8)
|
|
175
|
+
|
|
176
|
+
void
|
|
177
|
+
ll_init_braille_character(void)
|
|
178
|
+
{
|
|
179
|
+
ll_cBrailleCharacter = rb_define_class_under(ll_mLibLouis, "BrailleCharacter", rb_cObject);
|
|
180
|
+
rb_define_alloc_func(ll_cBrailleCharacter, ll_character_alloc);
|
|
181
|
+
rb_define_method(ll_cBrailleCharacter, "initialize", ll_character_initialize, -1);
|
|
182
|
+
rb_define_method(ll_cBrailleCharacter, "initialize_copy", ll_character_initialize_copy, 1);
|
|
183
|
+
rb_define_method(ll_cBrailleCharacter, "dots", ll_character_dots, 0);
|
|
184
|
+
rb_define_method(ll_cBrailleCharacter, "mask", ll_character_mask_value, 0);
|
|
185
|
+
rb_define_alias(ll_cBrailleCharacter, "to_i", "mask");
|
|
186
|
+
rb_define_method(ll_cBrailleCharacter, "unicode_character", ll_character_unicode, 0);
|
|
187
|
+
rb_define_alias(ll_cBrailleCharacter, "to_s", "unicode_character");
|
|
188
|
+
rb_define_method(ll_cBrailleCharacter, "==", ll_character_equal, 1);
|
|
189
|
+
rb_define_method(ll_cBrailleCharacter, "eql?", ll_character_equal, 1);
|
|
190
|
+
rb_define_method(ll_cBrailleCharacter, "hash", ll_character_hash, 0);
|
|
191
|
+
rb_define_method(ll_cBrailleCharacter, "inspect", ll_character_inspect, 0);
|
|
192
|
+
rb_define_method(ll_cBrailleCharacter, "dot1?", ll_character_dot1_p, 0);
|
|
193
|
+
rb_define_method(ll_cBrailleCharacter, "dot2?", ll_character_dot2_p, 0);
|
|
194
|
+
rb_define_method(ll_cBrailleCharacter, "dot3?", ll_character_dot3_p, 0);
|
|
195
|
+
rb_define_method(ll_cBrailleCharacter, "dot4?", ll_character_dot4_p, 0);
|
|
196
|
+
rb_define_method(ll_cBrailleCharacter, "dot5?", ll_character_dot5_p, 0);
|
|
197
|
+
rb_define_method(ll_cBrailleCharacter, "dot6?", ll_character_dot6_p, 0);
|
|
198
|
+
rb_define_method(ll_cBrailleCharacter, "dot7?", ll_character_dot7_p, 0);
|
|
199
|
+
rb_define_method(ll_cBrailleCharacter, "dot8?", ll_character_dot8_p, 0);
|
|
200
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#include "liblouis_ext.h"
|
|
2
|
+
|
|
3
|
+
static ID id_file;
|
|
4
|
+
static ID id_display_name_ivar;
|
|
5
|
+
static ID id_display_name;
|
|
6
|
+
|
|
7
|
+
static VALUE
|
|
8
|
+
ll_table_file(VALUE table)
|
|
9
|
+
{
|
|
10
|
+
return rb_ivar_get(table, id_file);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const char *
|
|
14
|
+
ll_table_name(VALUE table)
|
|
15
|
+
{
|
|
16
|
+
VALUE file = ll_table_file(table);
|
|
17
|
+
|
|
18
|
+
return StringValueCStr(file);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static VALUE
|
|
22
|
+
ll_table_metadata_value(VALUE file, const char *key)
|
|
23
|
+
{
|
|
24
|
+
char *metadata = lou_getTableInfo(StringValueCStr(file), key);
|
|
25
|
+
VALUE result;
|
|
26
|
+
|
|
27
|
+
if (!metadata)
|
|
28
|
+
return Qnil;
|
|
29
|
+
result = rb_utf8_str_new_cstr(metadata);
|
|
30
|
+
lou_freeTableInfo(metadata);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static VALUE
|
|
35
|
+
ll_table_display_name(VALUE file, VALUE name)
|
|
36
|
+
{
|
|
37
|
+
if (NIL_P(name)) {
|
|
38
|
+
name = strchr(StringValueCStr(file), ',') ? Qnil :
|
|
39
|
+
ll_table_metadata_value(file, "display-name");
|
|
40
|
+
if (NIL_P(name))
|
|
41
|
+
name = rb_funcall(rb_cFile, rb_intern("basename"), 1, file);
|
|
42
|
+
} else {
|
|
43
|
+
name = rb_str_dup(StringValue(name));
|
|
44
|
+
rb_enc_associate(name, rb_utf8_encoding());
|
|
45
|
+
}
|
|
46
|
+
return rb_obj_freeze(name);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE
|
|
50
|
+
ll_table_finish(VALUE table, VALUE file, VALUE display_name)
|
|
51
|
+
{
|
|
52
|
+
file = ll_table_source_normalize(file);
|
|
53
|
+
rb_ivar_set(table, id_file, file);
|
|
54
|
+
rb_ivar_set(table, id_display_name_ivar,
|
|
55
|
+
ll_table_display_name(file, display_name));
|
|
56
|
+
return rb_obj_freeze(table);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static VALUE
|
|
60
|
+
ll_table_build(VALUE file)
|
|
61
|
+
{
|
|
62
|
+
return ll_table_finish(rb_obj_alloc(ll_cBrailleTable), file, Qnil);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static VALUE
|
|
66
|
+
ll_table_initialize(int argc, VALUE *argv, VALUE self)
|
|
67
|
+
{
|
|
68
|
+
const ID allowed[] = {id_display_name};
|
|
69
|
+
VALUE file;
|
|
70
|
+
VALUE keywords = Qnil;
|
|
71
|
+
VALUE display_name = Qundef;
|
|
72
|
+
|
|
73
|
+
rb_scan_args(argc, argv, "1:", &file, &keywords);
|
|
74
|
+
if (!NIL_P(keywords))
|
|
75
|
+
rb_get_kwargs(rb_hash_dup(keywords), allowed, 0, 1, &display_name);
|
|
76
|
+
return ll_table_finish(self, file,
|
|
77
|
+
display_name == Qundef ? Qnil : display_name);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static VALUE
|
|
81
|
+
ll_table_inspect(VALUE self)
|
|
82
|
+
{
|
|
83
|
+
return rb_sprintf(
|
|
84
|
+
"#<LibLouis::BrailleTable file=%+"PRIsVALUE" display_name=%+"PRIsVALUE">",
|
|
85
|
+
ll_table_file(self), rb_ivar_get(self, id_display_name_ivar));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static VALUE
|
|
89
|
+
ll_table_metadata(VALUE self, VALUE key)
|
|
90
|
+
{
|
|
91
|
+
VALUE string = StringValue(key);
|
|
92
|
+
|
|
93
|
+
return ll_table_metadata_value(ll_table_file(self), StringValueCStr(string));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static VALUE
|
|
97
|
+
ll_table_valid_p(VALUE self)
|
|
98
|
+
{
|
|
99
|
+
return lou_checkTable(ll_table_name(self)) ? Qtrue : Qfalse;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static VALUE
|
|
103
|
+
ll_table_compile(VALUE self, VALUE rule)
|
|
104
|
+
{
|
|
105
|
+
VALUE string = StringValue(rule);
|
|
106
|
+
|
|
107
|
+
if (!lou_compileString(ll_table_name(self), StringValueCStr(string)))
|
|
108
|
+
rb_raise(ll_eError, "could not compile Liblouis rule for table %s",
|
|
109
|
+
ll_table_name(self));
|
|
110
|
+
return self;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static VALUE
|
|
114
|
+
ll_table_emphasis_classes(VALUE self)
|
|
115
|
+
{
|
|
116
|
+
const char **classes = lou_getEmphClasses(ll_table_name(self));
|
|
117
|
+
VALUE result = rb_ary_new();
|
|
118
|
+
int index;
|
|
119
|
+
|
|
120
|
+
if (!classes)
|
|
121
|
+
return result;
|
|
122
|
+
for (index = 0; classes[index]; index++)
|
|
123
|
+
rb_ary_push(result, ID2SYM(rb_intern(classes[index])));
|
|
124
|
+
lou_freeEmphClasses(classes);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static VALUE
|
|
129
|
+
ll_table_list(char **files)
|
|
130
|
+
{
|
|
131
|
+
VALUE result = rb_ary_new();
|
|
132
|
+
int index;
|
|
133
|
+
|
|
134
|
+
if (!files)
|
|
135
|
+
return result;
|
|
136
|
+
for (index = 0; files[index]; index++)
|
|
137
|
+
rb_ary_push(result, ll_table_build(rb_utf8_str_new_cstr(files[index])));
|
|
138
|
+
lou_freeTableFiles(files);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static VALUE
|
|
143
|
+
ll_table_all(VALUE owner)
|
|
144
|
+
{
|
|
145
|
+
(void)owner;
|
|
146
|
+
return ll_table_list(lou_listTables());
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static VALUE
|
|
150
|
+
ll_table_find(VALUE owner, VALUE query)
|
|
151
|
+
{
|
|
152
|
+
VALUE string = StringValue(query);
|
|
153
|
+
char *file = lou_findTable(StringValueCStr(string));
|
|
154
|
+
VALUE result;
|
|
155
|
+
|
|
156
|
+
(void)owner;
|
|
157
|
+
if (!file)
|
|
158
|
+
return Qnil;
|
|
159
|
+
result = ll_table_build(rb_utf8_str_new_cstr(file));
|
|
160
|
+
lou_freeTableFile(file);
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static VALUE
|
|
165
|
+
ll_table_find_all(VALUE owner, VALUE query)
|
|
166
|
+
{
|
|
167
|
+
VALUE string = StringValue(query);
|
|
168
|
+
|
|
169
|
+
(void)owner;
|
|
170
|
+
return ll_table_list(lou_findTables(StringValueCStr(string)));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
void
|
|
174
|
+
ll_init_braille_table(void)
|
|
175
|
+
{
|
|
176
|
+
id_file = rb_intern("@file");
|
|
177
|
+
id_display_name_ivar = rb_intern("@display_name");
|
|
178
|
+
id_display_name = rb_intern("display_name");
|
|
179
|
+
|
|
180
|
+
ll_cBrailleTable = rb_define_class_under(ll_mLibLouis, "BrailleTable", rb_cObject);
|
|
181
|
+
rb_define_method(ll_cBrailleTable, "initialize", ll_table_initialize, -1);
|
|
182
|
+
rb_define_attr(ll_cBrailleTable, "file", 1, 0);
|
|
183
|
+
rb_define_attr(ll_cBrailleTable, "display_name", 1, 0);
|
|
184
|
+
rb_define_alias(ll_cBrailleTable, "to_s", "display_name");
|
|
185
|
+
rb_define_method(ll_cBrailleTable, "inspect", ll_table_inspect, 0);
|
|
186
|
+
rb_define_method(ll_cBrailleTable, "metadata", ll_table_metadata, 1);
|
|
187
|
+
rb_define_method(ll_cBrailleTable, "valid?", ll_table_valid_p, 0);
|
|
188
|
+
rb_define_method(ll_cBrailleTable, "compile", ll_table_compile, 1);
|
|
189
|
+
rb_define_method(ll_cBrailleTable, "emphasis_classes", ll_table_emphasis_classes, 0);
|
|
190
|
+
ll_init_translation();
|
|
191
|
+
|
|
192
|
+
rb_define_singleton_method(ll_cBrailleTable, "all", ll_table_all, 0);
|
|
193
|
+
rb_define_singleton_method(ll_cBrailleTable, "find", ll_table_find, 1);
|
|
194
|
+
rb_define_singleton_method(ll_cBrailleTable, "find_all", ll_table_find_all, 1);
|
|
195
|
+
rb_define_module_function(ll_mLibLouis, "tables", ll_table_all, 0);
|
|
196
|
+
rb_define_module_function(ll_mLibLouis, "find_table", ll_table_find, 1);
|
|
197
|
+
rb_define_module_function(ll_mLibLouis, "find_tables", ll_table_find_all, 1);
|
|
198
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
#include "liblouis_ext.h"
|
|
2
|
+
|
|
3
|
+
static ID id_characters;
|
|
4
|
+
static ID id_input_positions;
|
|
5
|
+
static ID id_output_positions;
|
|
6
|
+
static ID id_cursor_position;
|
|
7
|
+
|
|
8
|
+
static VALUE
|
|
9
|
+
ll_text_characters(VALUE text)
|
|
10
|
+
{
|
|
11
|
+
return rb_ivar_get(text, id_characters);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
int
|
|
15
|
+
ll_braille_text_p(VALUE value)
|
|
16
|
+
{
|
|
17
|
+
return rb_obj_is_kind_of(value, ll_cBrailleText);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static VALUE
|
|
21
|
+
ll_text_finish(VALUE text, VALUE characters, VALUE input_positions,
|
|
22
|
+
VALUE output_positions, VALUE cursor_position)
|
|
23
|
+
{
|
|
24
|
+
rb_obj_freeze(characters);
|
|
25
|
+
rb_ivar_set(text, id_characters, characters);
|
|
26
|
+
rb_ivar_set(text, id_input_positions, input_positions);
|
|
27
|
+
rb_ivar_set(text, id_output_positions, output_positions);
|
|
28
|
+
rb_ivar_set(text, id_cursor_position, cursor_position);
|
|
29
|
+
return rb_obj_freeze(text);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static VALUE
|
|
33
|
+
ll_character_from_input(VALUE input)
|
|
34
|
+
{
|
|
35
|
+
VALUE argv[] = {input};
|
|
36
|
+
|
|
37
|
+
return rb_obj_is_kind_of(input, ll_cBrailleCharacter) ? input :
|
|
38
|
+
rb_class_new_instance(1, argv, ll_cBrailleCharacter);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static VALUE
|
|
42
|
+
ll_text_initialize(int argc, VALUE *argv, VALUE self)
|
|
43
|
+
{
|
|
44
|
+
VALUE input = Qnil;
|
|
45
|
+
VALUE characters = rb_ary_new();
|
|
46
|
+
long index;
|
|
47
|
+
|
|
48
|
+
rb_scan_args(argc, argv, "01", &input);
|
|
49
|
+
if (RB_TYPE_P(input, T_STRING)) {
|
|
50
|
+
int length;
|
|
51
|
+
VALUE storage = ll_wide_storage_from_string(input, &length);
|
|
52
|
+
|
|
53
|
+
for (index = 0; index < length; index++) {
|
|
54
|
+
unsigned int codepoint = LL_PTR(widechar, storage)[index];
|
|
55
|
+
|
|
56
|
+
if (codepoint < 0x2800 || codepoint > 0x28ff)
|
|
57
|
+
rb_raise(rb_eArgError,
|
|
58
|
+
"BrailleText strings may contain only Unicode braille characters");
|
|
59
|
+
rb_ary_push(characters, ll_character_new((uint8_t)(codepoint - 0x2800)));
|
|
60
|
+
}
|
|
61
|
+
} else if (!NIL_P(input)) {
|
|
62
|
+
Check_Type(input, T_ARRAY);
|
|
63
|
+
for (index = 0; index < RARRAY_LEN(input); index++)
|
|
64
|
+
rb_ary_push(characters, ll_character_from_input(rb_ary_entry(input, index)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return ll_text_finish(self, characters, Qnil, Qnil, Qnil);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static VALUE
|
|
71
|
+
ll_text_from_dots(VALUE storage, int length, VALUE input_positions,
|
|
72
|
+
VALUE output_positions, VALUE cursor_position)
|
|
73
|
+
{
|
|
74
|
+
VALUE characters = rb_ary_new_capa(length);
|
|
75
|
+
VALUE text = rb_obj_alloc(ll_cBrailleText);
|
|
76
|
+
int index;
|
|
77
|
+
|
|
78
|
+
for (index = 0; index < length; index++)
|
|
79
|
+
rb_ary_push(characters,
|
|
80
|
+
ll_character_new((uint8_t)(LL_PTR(widechar, storage)[index] & 0xffu)));
|
|
81
|
+
return ll_text_finish(text, characters, input_positions,
|
|
82
|
+
output_positions, cursor_position);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
VALUE
|
|
86
|
+
ll_braille_text_from_dot_storage(VALUE storage, int length)
|
|
87
|
+
{
|
|
88
|
+
return ll_text_from_dots(storage, length, Qnil, Qnil, Qnil);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static VALUE
|
|
92
|
+
ll_position_array(VALUE storage, int length)
|
|
93
|
+
{
|
|
94
|
+
VALUE positions = rb_ary_new_capa(length);
|
|
95
|
+
int index;
|
|
96
|
+
|
|
97
|
+
for (index = 0; index < length; index++)
|
|
98
|
+
rb_ary_push(positions, INT2NUM(LL_PTR(int, storage)[index]));
|
|
99
|
+
return rb_obj_freeze(positions);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
VALUE
|
|
103
|
+
ll_braille_text_from_translation(VALUE storage, int length,
|
|
104
|
+
VALUE input_positions_storage,
|
|
105
|
+
VALUE output_positions_storage,
|
|
106
|
+
int input_length, int cursor_given,
|
|
107
|
+
int cursor_position)
|
|
108
|
+
{
|
|
109
|
+
return ll_text_from_dots(
|
|
110
|
+
storage, length,
|
|
111
|
+
ll_position_array(input_positions_storage, length),
|
|
112
|
+
ll_position_array(output_positions_storage, input_length),
|
|
113
|
+
cursor_given ? INT2NUM(cursor_position) : Qnil);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
VALUE
|
|
117
|
+
ll_braille_text_to_dot_storage(VALUE text, int *length)
|
|
118
|
+
{
|
|
119
|
+
VALUE characters = ll_text_characters(text);
|
|
120
|
+
VALUE storage;
|
|
121
|
+
long index;
|
|
122
|
+
|
|
123
|
+
if (RARRAY_LEN(characters) > INT_MAX)
|
|
124
|
+
rb_raise(rb_eArgError, "BrailleText is too long");
|
|
125
|
+
*length = (int)RARRAY_LEN(characters);
|
|
126
|
+
storage = ll_binary_storage((size_t)*length * sizeof(widechar));
|
|
127
|
+
for (index = 0; index < *length; index++)
|
|
128
|
+
LL_PTR(widechar, storage)[index] =
|
|
129
|
+
(widechar)(LOU_DOTS | ll_character_mask(rb_ary_entry(characters, index)));
|
|
130
|
+
return storage;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static VALUE
|
|
134
|
+
ll_text_unicode(VALUE self)
|
|
135
|
+
{
|
|
136
|
+
VALUE characters = ll_text_characters(self);
|
|
137
|
+
VALUE result = rb_enc_str_new(NULL, 0, rb_utf8_encoding());
|
|
138
|
+
long index;
|
|
139
|
+
|
|
140
|
+
for (index = 0; index < RARRAY_LEN(characters); index++)
|
|
141
|
+
rb_str_buf_append(result, rb_enc_uint_chr(
|
|
142
|
+
0x2800u + ll_character_mask(rb_ary_entry(characters, index)),
|
|
143
|
+
rb_utf8_encoding()));
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static VALUE
|
|
148
|
+
ll_text_length(VALUE self)
|
|
149
|
+
{
|
|
150
|
+
return LONG2NUM(RARRAY_LEN(ll_text_characters(self)));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static VALUE
|
|
154
|
+
ll_text_empty_p(VALUE self)
|
|
155
|
+
{
|
|
156
|
+
return RARRAY_LEN(ll_text_characters(self)) == 0 ? Qtrue : Qfalse;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static VALUE
|
|
160
|
+
ll_text_aref(int argc, VALUE *argv, VALUE self)
|
|
161
|
+
{
|
|
162
|
+
return rb_ary_aref(argc, argv, ll_text_characters(self));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static VALUE
|
|
166
|
+
ll_text_each(VALUE self)
|
|
167
|
+
{
|
|
168
|
+
VALUE characters;
|
|
169
|
+
long index;
|
|
170
|
+
|
|
171
|
+
RETURN_ENUMERATOR(self, 0, NULL);
|
|
172
|
+
characters = ll_text_characters(self);
|
|
173
|
+
for (index = 0; index < RARRAY_LEN(characters); index++)
|
|
174
|
+
rb_yield(rb_ary_entry(characters, index));
|
|
175
|
+
return self;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static VALUE
|
|
179
|
+
ll_text_equal(VALUE self, VALUE other)
|
|
180
|
+
{
|
|
181
|
+
return ll_braille_text_p(other) &&
|
|
182
|
+
rb_equal(ll_text_characters(self), ll_text_characters(other)) ? Qtrue : Qfalse;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static VALUE
|
|
186
|
+
ll_text_hash(VALUE self)
|
|
187
|
+
{
|
|
188
|
+
return rb_hash(ll_text_characters(self));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
static VALUE
|
|
192
|
+
ll_text_inspect(VALUE self)
|
|
193
|
+
{
|
|
194
|
+
return rb_sprintf("#<LibLouis::BrailleText %"PRIsVALUE">", ll_text_unicode(self));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
void
|
|
198
|
+
ll_init_braille_text(void)
|
|
199
|
+
{
|
|
200
|
+
id_characters = rb_intern("@characters");
|
|
201
|
+
id_input_positions = rb_intern("@input_positions");
|
|
202
|
+
id_output_positions = rb_intern("@output_positions");
|
|
203
|
+
id_cursor_position = rb_intern("@cursor_position");
|
|
204
|
+
|
|
205
|
+
ll_cBrailleText = rb_define_class_under(ll_mLibLouis, "BrailleText", rb_cObject);
|
|
206
|
+
rb_include_module(ll_cBrailleText, rb_mEnumerable);
|
|
207
|
+
rb_define_method(ll_cBrailleText, "initialize", ll_text_initialize, -1);
|
|
208
|
+
rb_define_attr(ll_cBrailleText, "characters", 1, 0);
|
|
209
|
+
rb_define_attr(ll_cBrailleText, "input_positions", 1, 0);
|
|
210
|
+
rb_define_attr(ll_cBrailleText, "output_positions", 1, 0);
|
|
211
|
+
rb_define_attr(ll_cBrailleText, "cursor_position", 1, 0);
|
|
212
|
+
rb_define_method(ll_cBrailleText, "unicode_text", ll_text_unicode, 0);
|
|
213
|
+
rb_define_alias(ll_cBrailleText, "to_s", "unicode_text");
|
|
214
|
+
rb_define_method(ll_cBrailleText, "length", ll_text_length, 0);
|
|
215
|
+
rb_define_alias(ll_cBrailleText, "size", "length");
|
|
216
|
+
rb_define_method(ll_cBrailleText, "empty?", ll_text_empty_p, 0);
|
|
217
|
+
rb_define_method(ll_cBrailleText, "[]", ll_text_aref, -1);
|
|
218
|
+
rb_define_method(ll_cBrailleText, "each", ll_text_each, 0);
|
|
219
|
+
rb_define_method(ll_cBrailleText, "==", ll_text_equal, 1);
|
|
220
|
+
rb_define_method(ll_cBrailleText, "eql?", ll_text_equal, 1);
|
|
221
|
+
rb_define_method(ll_cBrailleText, "hash", ll_text_hash, 0);
|
|
222
|
+
rb_define_method(ll_cBrailleText, "inspect", ll_text_inspect, 0);
|
|
223
|
+
}
|