56 lines
1.4 KiB
Crystal
56 lines
1.4 KiB
Crystal
@[Link(ldflags: "#{__DIR__}/../../external/liblex/build/external/libds/libds.a")]
|
|
lib LibDs
|
|
struct LlNode
|
|
next: LlNode*
|
|
prev: LlNode*
|
|
data: Void*
|
|
end
|
|
|
|
struct Ll
|
|
head: LlNode*
|
|
tail: LlNode*
|
|
end
|
|
|
|
enum Result
|
|
Success,
|
|
Malloc
|
|
end
|
|
|
|
fun compare_always(a: Void*, b: Void*): Int32
|
|
|
|
fun ll_init(list: Ll*)
|
|
fun ll_foreach(list: Ll*, compare_to: Void*,
|
|
compare: Void*, Void* -> Int32,
|
|
foreach: Void*, LibC::VaList-> Int32, ...): Int32
|
|
fun ll_free(list: Ll*)
|
|
end
|
|
|
|
@[Link(ldflags: "#{__DIR__}/../../external/liblex/build/liblex.a #{__DIR__}/../../external/liblex/build/external/libds/libds.a")]
|
|
lib LibLex
|
|
struct EvalConfig
|
|
stats: LibDs::Ll
|
|
end
|
|
|
|
struct Match
|
|
from: LibC::SizeT
|
|
to: LibC::SizeT
|
|
pattern: Int32
|
|
end
|
|
|
|
enum Result
|
|
Success,
|
|
Malloc,
|
|
Invalid,
|
|
Unrecognized
|
|
end
|
|
|
|
fun eval_config_init(config: EvalConfig*)
|
|
fun eval_config_add(config: EvalConfig*, string: UInt8*, id: Int32): Result
|
|
fun eval_all(string: UInt8*, index: LibC::SizeT, config: EvalConfig*,
|
|
matches: LibDs::Ll*): Result
|
|
fun eval_config_remove(config: EvalConfig*, string: UInt8*,
|
|
id: Int32): Result
|
|
fun eval_config_free(config: EvalConfig*): Result
|
|
fun eval_foreach_match_free(match: Void*, args: LibC::VaList): Int32
|
|
end
|