wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Make "usercode" in .tld-files work again. #98

Closed wc-duck closed 4 years ago

wc-duck commented 5 years ago

"usercode" was previously used to inject code in the generated headers as needed but was not re-implemented when the json-parser in the compiler was reworked.

It was used for such things as adding includes to the generated headers for use with external types.

wc-duck commented 4 years ago

I think I'll actually skip "usercode" as it stands now as it do not provide enough benefit to be able to include "any code". It feels too big as c++-code can do and be shaped in many ways that would need parsing and special casing. I don't think that complexity is worth the gain. However I'm thinking about adding a "user_includes"-section in the .tld instead as that would bring almost all the benefits without the downsides on the implementation side.

That section would be just an array of strings such as:

"user_includes" : [
    "apa/kossa.h",      // would generate #include "apa/kossa.h"
    "<whipp/whopp>" // if the include start with '<' it would generate #include <whipp/whopp>
]
lundmark commented 4 years ago

Oh just one user include would be enough, but if you have a list then that covers it more than enough!

wc-duck commented 4 years ago

Fixed by adding support for "c_includes" and removing support for "usercode"