Replies: 9 comments
-
You can have a look at the Python and/or JavaScript crates I created too since they all use the Rust crate (although not by using a C API). The generator is written in C#: https://github.com/icedland/iced/tree/master/src/csharp/Intel/Generator (you need .NET SDK 6.0)
|
Beta Was this translation helpful? Give feedback.
-
So for step 1, would I copy the iced-x86 crate and then add |
Beta Was this translation helpful? Give feedback.
-
cc @wtfsck |
Beta Was this translation helpful? Give feedback.
-
That C API crate should reference iced-x86 (no need to copy the whole thing) and just add a C APIs for some funcs you need for your Ada code. Eg. a fn to create a decoder and other fns the Ada code needs (eg. decode()). |
Beta Was this translation helpful? Give feedback.
-
@wtfsck Oh, okay, so I'd create a C API for Iced-x86, and create functions for encoding/decoding/block decoding/encoding or whatever I need. And then on the Ada side of things I'd modify the generator to generate the instruction-based subprograms to emit instructions, or enumerations for decoders? Not really sure how decoding would work without that on the C side though... |
Beta Was this translation helpful? Give feedback.
-
There's no C side, it's all Rust with a C API. The C API crate (written in Rust) will be small and just convert the ptrs passed to it to rust references and call the original fns in the iced-x86 crate. Eg. a 'create decoder' fn would call #[no_mangle]//etc
fn decoder_new() -> some-ptr {
let d = Decoder::new(xxx);
// box it
// return ptr
}
// other fns here, eg. decode() -- the Ada code loads the dll or links to it and then calls the above methods (C API) The generator should be updated to generate all enums the Ada code needs (the other enums can be ignored). |
Beta Was this translation helpful? Give feedback.
-
I was thinking of wanting to use Iced in an ada kernel project/on embedded systems. That's why I asked about being able to possibly generate the crate as an Ada project perhaps. |
Beta Was this translation helpful? Give feedback.
-
If you mean generate 100% Ada code, the generator can't do that. You'd have to convert the non-generated code to Ada. It should be easier to just call into a C API, I think Ada supports that. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I'll look into it. Not really sure how using it in an embedded context would work in that case though. |
Beta Was this translation helpful? Give feedback.
-
What are the steps for adding other languages to the Iced crate? I'd like to add the Ada language if that would be alright.
Beta Was this translation helpful? Give feedback.
All reactions