-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First working C Implementation #1
base: master
Are you sure you want to change the base?
Conversation
@DarkShadow44 Great to see! Also it might a good idea to For more details see: If you don't want to generate your 'export header' automatically (e.g., in CMake with (then just use Happy to contribute the patch just say the word |
Well, the entire runtime isn't designed to be used as a shared library in the first place. It's meant to be simply included as a single c file into the project. That's also why the header has special logic to handle dependencies and "configuring" the runtime. Not sure if the visibility really matters in such circumstances? Btw, I'm not 100% happy with how I currently handle KS_DEPEND_ON_INTERNALS, so I might rework that to have a proper interface, then only the runtime kaitaistruct.c would have access to internal structs and such. |
@DarkShadow44 Interesting. My interest is on the FFI side. Namely I'm thinking that once this is ported, then the number of supported languages grows from not 11 to 12, but from 11 to 50+. (I'm working on a new C compiler and associated tooling to take C libraries + headers and generate packages in dozens of different languages—using language-ecosystem recommended tooling—and release to their various app stores [e.g., Rust I don't want to translate things out of this C header that don't make sense when other languages are calling into it. |
Well, I separated the functions into functions that are needed by the program and functions needed by the generated code only. I could potentially separate this into two headers, if that makes sense? |
What is the timeline for this being merged and released so it can be used? |
@GreyCat @generalmimon what would you like to see before accepting the initial C implementation? Cheers. |
I would like to see you (or someone who has the time, which is not me at the moment) reviewing and testing the code. Not only in this PR, but also in related PRs. Check out kaitai-io/kaitai_struct_compiler#253 locally, rebase everything on top of |
Right off the bat, the indentation is wrong, for example here: kaitai_struct_c_runtime/kaitaistruct.c Lines 770 to 772 in e7a7971
kaitai_struct_c_runtime/kaitaistruct.c Lines 781 to 784 in e7a7971
... or here (3-space indent? 🤨): kaitai_struct_c_runtime/kaitaistruct.c Lines 800 to 804 in e7a7971
Also, this is a terrible idea: override def runParseExpectError(exception: KSError): Unit = {
runParseCommon1()
out.puts(s"BOOST_CHECK_EQUAL(error == 0, 0);")
} I explained why in kaitai-io/kaitai_struct_tests#96 (review):
Anyone could probably find this in 5 minutes if someone actually looked at the code instead of expecting someone else to do it. |
Tests: kaitai-io/kaitai_struct_tests#97
Compiler: kaitai-io/kaitai_struct_compiler#253