Replies: 2 comments
|
hmm actually not sure about that, see that you can have multiple @(link_prefix = "avcodec_", default_calling_convention = "c")
foreign avcodec {
get_type :: proc(codec_id: CodecID) -> avutil.MediaType ---
get_name :: proc(id: CodecID) -> cstring ---
profile_name :: proc(codec_id: CodecID, profile: c.int) -> cstring ---
find_decoder :: proc(id: CodecID) -> ^Codec ---
find_decoder_by_name :: proc(name: cstring) -> ^Codec ---
find_encoder :: proc(id: CodecID) -> ^Codec ---
find_encoder_by_name :: proc(name: cstring) -> ^Codec ---
get_hw_config :: proc(codec: ^Codec, index: c.int) -> ^CodecHWConfig ---
// etc
}
@(link_prefix = "av_", default_calling_convention = "c")
foreign avcodec {
get_bits_per_sample :: proc(codec_id: CodecID) -> c.int ---
get_exact_bits_per_sample :: proc(codec_id: CodecID) -> c.int ---
get_pcm_codec :: proc(fmt: avutil.SampleFormat, be: c.int) -> CodecID ---
// etc
}would read really weird with the syntax you propose because now I would be "redefining" @(link_prefix = "avcodec_", default_calling_convention = "c")
avcodec :: foreign {
get_type :: proc(codec_id: CodecID) -> avutil.MediaType ---
get_name :: proc(id: CodecID) -> cstring ---
profile_name :: proc(codec_id: CodecID, profile: c.int) -> cstring ---
find_decoder :: proc(id: CodecID) -> ^Codec ---
find_decoder_by_name :: proc(name: cstring) -> ^Codec ---
find_encoder :: proc(id: CodecID) -> ^Codec ---
find_encoder_by_name :: proc(name: cstring) -> ^Codec ---
get_hw_config :: proc(codec: ^Codec, index: c.int) -> ^CodecHWConfig ---
// etc
}
@(link_prefix = "av_", default_calling_convention = "c")
avcodec :: foreign {
get_bits_per_sample :: proc(codec_id: CodecID) -> c.int ---
get_exact_bits_per_sample :: proc(codec_id: CodecID) -> c.int ---
get_pcm_codec :: proc(fmt: avutil.SampleFormat, be: c.int) -> CodecID ---
// etc
}In some sense if it were possible to put everything on a single block it would be fine, but just look at the SDL3 bindings for example. they are separated by subject and all symbols use the same lib. that wouldn't be really readable or coherent with I can also list other weirdnesses that arise from your understanding, but I think this already makes the point... |
|
Hm, you're right. My motivation wasn't really about changing the semantics of foreign blocks, but about consistency in the language. |
Uh oh!
There was an error while loading. Please reload this page.
Since the whole language uses the syntax name :: thing why foreign blocks uses a different syntax?
This is the actual foreign block syntax (used in the examples).
I think this could be much coherent with the syntax.
All reactions