WinMD::LibCFuns
Discovers the C functions that the installed Crystal's standard library
declares in lib LibC for the target platform, so the generator can avoid
redeclaring them (a fun with the same C name in another lib is a
redefinition error unless the signatures are identical).
The list is read from the compiler found on PATH (or WINMD_CRYSTAL) at
generation time rather than baked into winmd, so it always matches the
Crystal that will compile the bindings. It covers every declaration under
src/lib_c/<target>/ plus the platform's src/crystal/system/<os>/ files,
not just what a minimal program's prelude happens to require: which stdlib
files a user's program pulls in cannot be known here, so any name Crystal
declares for the target is treated as taken.
Each declaration is parsed with Crystal's own parser so the generator also
knows the parameter and return types LibC uses. With those it can emit a
wrapper that forwards to the stdlib declaration instead of only commenting
the function out (see WinMD::Function#libc_call).
Constants
Crystal's own types, which a bare name inside a lib still refers to.
Anything else written without a namespace (DWORD, Int, SizeT,
ULONG_PTR) is a type the lib declares, possibly in another file or
inside a {% if flag?(...) %} block the parser does not expand.
Class methods
Target triple reported by crystal --version, e.g. x86_64-pc-windows-msvc.
C symbol names of all funs declared for target by the stdlib of crystal.
Signatures of all funs declared for target, keyed by C symbol name
(the name a generated fun would collide with).
src/lib_c/<dir> for a target triple. Crystal names these directories
without the vendor part: x86_64-pc-windows-msvc -> x86_64-windows-msvc,
aarch64-apple-darwin -> aarch64-darwin, x86_64-unknown-linux-gnu ->
x86_64-linux-gnu.
One name per line, # comments allowed; used instead of discovery when
the generator must run without a Crystal compiler available.
Parses Crystal sources ({source, require_path} pairs) and returns every
fun declared inside a lib.
Declarations the parser does not see, because the file uses syntax newer
than the parser built into winmd or because the fun sits inside a
{% if flag?(...) %} block (whose body is only expanded by the compiler),
are still found by a textual scan and reported with their name only, so
they are not redeclared even though no wrapper can be generated.
src directory of the stdlib: the CRYSTAL_PATH entry that holds lib_c.
Platform-specific stdlib sources that also declare LibC functions.
Spells a type restriction from a lib declaration so it resolves from
generated code: names the lib declares get an absolute lib prefix, and
Foo* / -> Bar become Pointer(Foo) / Proc(Bar), which are valid
where a type is used as a value.