-
Notifications
You must be signed in to change notification settings - Fork 293
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
Adding ly_ctx_add_parsed_module API #2187
Conversation
This patch adds possiblity for user to add manually created parsed module into context.
What is the purpose of the new function? Why not simply use |
Background:
Coming back to your question: So And I need something in the middle. Do you agree or see some other option how to do that? |
Sorry, I have misunderstood the functionality and also did not expect the test actually demonstrates common usage. So, you have a really specific, perhaps unique, use-case and I am not sure it should be supported this way. Even manipulating parsed node structures is not expected, the modules are always returned as TLDR; This PR is the only way you can support your use-case? Even constructing the module in YANG first and then parsing it seems better to me, modifying an existing context by manually relinking parsed nodes is a dangerous thing to do. |
To support my use-case, I need 2 things in total:
So if you would prefer, I can shift this code into I fully understood and agree that playing with nodes, which are part of some existing modules, is very risky thing, so I am doing just minimal steps to achieve the needed results as:
Assumption is that none of the xpath nodes ( So effectively my fake module will after compilation reuse as much as possible from existing modules and "compiled" tree of my fake module, is kind of totally independent. Alternative would be to copy |
The cause of the requirement in 2. is intentional meaning those macros are not available on purpose. You are trying to perform operations that are supposed to be internal only. We have kept almost all the structures public so that even more invasive use-cases are supported but not encouraged or officially supported (meaning there are no dedicated API functions). That is why I am against adding So, I am sorry, but unless you can come up with some smaller changes that could be beneficial in general, not just for your use-case, you will have to implement all of this outside libyang. You can even use internal headers and it should not really take that much more effort but it will remain up to you to maintain it. |
Once you have a |
Ok, thanks both for the suggestion, I have adjust the code on my side based on your suggestions and it seems working. Cancelling this PR |
This patch adds possiblity for user to add manually created parsed module into context.