wc-duck / datalibrary

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

Empty dl-definition fails with bad warning #50

Closed lundmark closed 8 years ago

lundmark commented 8 years ago

Warning is: 50> expected '{' but got 'P' at 114 50> at line 0, col 0: 50> P��� 50> ^

Should either not allow definition and print a more appropriate error or produce an empty typelibrary.

wc-duck commented 8 years ago

Do you have some minimal testcase?

lundmark commented 8 years ago

try to run the tlc-compiler on an empty file, or a file only containing blank space.

wc-duck commented 8 years ago

I have done a slightly stupid thing and I'm not really sure how to solve it =/ dl_context_load_txt_type_library() take a string and length ( but is currently ignoring the length =/ ) and dl_txt_pack() is only taking a string and expect it to be zero terminated. What I can't decide right now is if I want to change dl_context_load_txt_type_library() to take a zero-terminated string ( but by that giving up some flexibillity ) or adding a length to dl_txt_pack() and by that making it slightly more complicated to use?

I am leaning towards changing dl_txt_pack() but I would like some input on that.

lundmark commented 8 years ago

I think that all functions should accept a string and a length, or assume that all strings are null terminated. To be honest I don't think that it matters which one they use as long as they're all the same. The string+length is the most flexible, but also the most demanding. The string-which-is-null-terminated is simplest but least flexible. Honestly in this case I prefer flexibility over simplicity since I think that's the way that the library is designed. If I'm mistaken and the case is that you actually would prefer simplicity over flexibility in the library then I think that you should go that way and adapt the entire API that way :)

wc-duck commented 8 years ago

Should be fixed, output should be:

./local/linux_x86_64/gcc/debug/dltlc empty expected '{' but got at end of buffer failed to load typelib from "empty"