lib/ffi-icu/lib.rb in ffi-icu-0.0.2 vs lib/ffi-icu/lib.rb in ffi-icu-0.0.3

- old
+ new

@@ -18,11 +18,11 @@ suffix = '' # let the user tell us where the lib is if ENV['FFI_ICU_LIB'] libs = ENV['FFI_ICU_LIB'].split(",") - ffi_lib *libs + ffi_lib(*libs) if ENV['FFI_ICU_VERSION_SUFFIX'] return ENV['FFI_ICU_VERSION_SUFFIX'] elsif num = libs.first[/\d+$/] return num.split(//).join("_") @@ -143,11 +143,13 @@ layout :line, :int32_t, :offset, :int32_t, :pre_context, :pointer, :post_context, :pointer - + def to_s + "#<%s:%x line: %d offset: %d" % [self.class, hash*2, self[:line], self[:offset]] + end end class UTransPosition < FFI::Struct layout :context_start, :int32_t, :context_limit, :int32_t, @@ -177,7 +179,36 @@ :nfkc, 5, :fcd, 6 ] attach_function :unorm_normalize, "unorm_normalize#{suffix}", [:pointer, :int32_t, :normalization_mode, :int32_t, :pointer, :int32_t, :pointer], :int32_t + + # + # Text Boundary Analysis + # + + enum :iterator_type, [ :character, :word, :line, :sentence, :title] + enum :word_break, [ :none, 0, + :none_limit, 100, + :number, 100, + :number_limit, 200, + :letter, 200, + :letter_limit, 300, + :kana, 300, + :kana_limit, 400, + :ideo, 400, + :ideo_limit, 400 + ] + + attach_function :ubrk_countAvailable, "ubrk_countAvailable#{suffix}", [], :int32_t + attach_function :ubrk_getAvailable, "ubrk_getAvailable#{suffix}", [:int32_t], :string + + attach_function :ubrk_open, "ubrk_open#{suffix}", [:iterator_type, :string, :pointer, :int32_t, :pointer], :pointer + attach_function :ubrk_close, "ubrk_close#{suffix}", [:pointer], :void + attach_function :ubrk_setText, "ubrk_setText#{suffix}", [:pointer, :pointer, :int32_t, :pointer], :void + attach_function :ubrk_current, "ubrk_current#{suffix}", [:pointer], :int32_t + attach_function :ubrk_next, "ubrk_next#{suffix}", [:pointer], :int32_t + attach_function :ubrk_previous, "ubrk_previous#{suffix}", [:pointer], :int32_t + attach_function :ubrk_first, "ubrk_first#{suffix}", [:pointer], :int32_t + attach_function :ubrk_last, "ubrk_last#{suffix}", [:pointer], :int32_t end # Lib end # ICU