-
Notifications
You must be signed in to change notification settings - Fork 199
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
Conditional compilation controlled on type level #339
Comments
I recall we had a proposal for an alternative approach somewhere — i.e. instead of huge lists like type:
switch-on: some_packet_id
cases:
1: some_external_type_1
2: some_external_type_2
3: some_external_type_3
# ... which also require every of these external types to be imported, instead this main file would declare some "extension point", and not list any of these files explicitly. And all these "some_external_type_*" would instead have some connection mechanism in their header, which would effectively find that "extension point" and inject their ID and type into it. I'm not sure about the exact implementation (and I can't seem to be able to find that discussion), but I wonder if that would be slightly more straightforward than doing these include/exclude rules file? |
Maybe you were referring to this issue? #71 |
@koczkatamas Yeah, exactly. Your original proposal was buried under the heap of direct import-related discussion topics. |
Do you mean inclusion of the whole directory and specifying the enum values as metadata for types? I don't see how this solves this problem, but I guess there should be a separate issue for this idea. Also I guess that scattering a single enum between multiple files opens a can of worms: we cannot just open a file and see what values are defined, we have the compiler to do that work itself. May be it's not bad if the compiler can resolve conflicts. Also in differrent formats differret subformats may have diferrent enum values. I guess an explicit mapping between enum and type is easier to observe. |
Let we have a container format using a bunch of other formats. And let's assumme thet we don't need most of them.
I mean, look at pcap.ksy. It refers lots of formats relevant only in network context. If I want analyse only USB captures with my program, I don't need them all.
Let's make some definitions. We can treat a set of all the types as a DAG (directed acyclic graph): a type is a vertex, if a type refers some type there is an edge from the referer to referee. For the purposes of this issue we call
B
a subDAG of a DAGA
if and only ifB≠A ^ (V(A-B) ∩ V(B) = ∅)
whereV(A)
gives the set of vertices of the graphA
.The idea is to provide an an additional argument to the compiler, which should refer a config file. In that file we should be able to write rules to select the types which are:
Then the compiler should act according to the rules. When a type is excluded the compiler should insert a code calling the callback in that branch instead of the code parsing the type and not to generate the imports and not to compile the type and its subDAGs. The callback should be programmer-defined. The default one should be to throw an exception or finish the program if there is no exceptions.
The text was updated successfully, but these errors were encountered: