mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-07 20:20:26 -03:00
Started binding, ran into things I don't know how to bind
This commit is contained in:
parent
ce6f3d29b5
commit
d49d0969a9
88
src/onigmo.cr
Normal file
88
src/onigmo.cr
Normal file
@ -0,0 +1,88 @@
|
||||
@[Link("onigmo")]
|
||||
|
||||
lib Onigmo
|
||||
type OnigOptionType = UInt32
|
||||
type OnigCaseFoldType = UInt32
|
||||
type OnigDistance = LibC::SizeT
|
||||
|
||||
struct OnigRegex
|
||||
p : LibC::UChar*
|
||||
used : UInt32
|
||||
alloc : UInt32
|
||||
|
||||
num_mem : Int32
|
||||
num_repeat : Int32
|
||||
num_null_check : Int32
|
||||
num_comb_exp_check : Int32
|
||||
num_call : Int32
|
||||
capture_history : UInt32
|
||||
bt_mem_start : UInt32
|
||||
bt_mem_end : UInt32
|
||||
stack_pop_level : Int32
|
||||
repeat_range_alloc : Int32
|
||||
options : OnigOptionType
|
||||
syntax : OnigSyntaxType*
|
||||
name_table : Void*
|
||||
case_fold_flag : OnigCaseFoldType
|
||||
optimize : Int32
|
||||
threshold_len : Int32
|
||||
anchor : Int32
|
||||
anchor_dmin : OnigDistance
|
||||
anchor_dmax : OnigDistance
|
||||
sub_anchor : Int32
|
||||
exact : LibC::UChar*
|
||||
exact_end : LibC::UChar*
|
||||
map : LibC::UChar*
|
||||
int_map : Int32*
|
||||
int_map_backward : Int32*
|
||||
dmin : OnigDistance
|
||||
dmax : OnigDistance
|
||||
chain : OnigRegex*
|
||||
end
|
||||
|
||||
type OnigRegexType = OnigRegex*
|
||||
type OnigCodePoint = UInt32
|
||||
type OnigUChar = LibC::UChar
|
||||
type OnigEncoding = Void*
|
||||
|
||||
struct OnigMetaCharTableType
|
||||
esc : OnigCodePoint
|
||||
anychar : OnigCodePoint
|
||||
anytime : OnigCodePoint
|
||||
zero_or_one_time : OnigCodePoint
|
||||
one_or_one_time : OnigCodePoint
|
||||
anychar_anytime : OnigCodePoint
|
||||
end
|
||||
|
||||
struct OnigSyntaxType
|
||||
op : UInt32
|
||||
op2 : UInt32
|
||||
behavior : UInt32
|
||||
options : OnigOptionType
|
||||
meta_char_table : OnigMetaCharTableType
|
||||
end
|
||||
|
||||
struct OnigErrorInfo
|
||||
enc : OnigEncoding
|
||||
par : OnigUChar*
|
||||
par_end : OnigUChar*
|
||||
end
|
||||
|
||||
ONIG_OPTION_NONE = 0u32
|
||||
ONIG_OPTION_DEFAULT = ONIG_OPTION_NONE
|
||||
|
||||
|
||||
fun new = onig_new(OnigRegex*, OnigUChar*, OnigUChar*, OnigOptionType, OnigEncoding, OnigSyntaxType*, OnigErrorInfo*)
|
||||
end
|
||||
|
||||
pattern = "a(.*)b|[e-f]+"
|
||||
str = "zzzzaffffffffb"
|
||||
|
||||
einfo = Onigmo::OnigErrorInfo.new
|
||||
|
||||
Onigmo.new(out reg,
|
||||
pattern.to_unsafe,
|
||||
pattern.to_unsafe + pattern.size,
|
||||
Onigmo::ONIG_OPTION_DEFAULT,
|
||||
0,
|
||||
Onigmo::ONIG_SYNTAX_DEFAULT, pointerof(einfo))
|
Loading…
x
Reference in New Issue
Block a user