-
Notifications
You must be signed in to change notification settings - Fork 4
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
Script can't handle class inheritance or class Instantiation #8
Comments
Regarding Regarding inheritance: >>> import armaclass
>>> armaclass.parse("""
... class my_class : other_class_inherited
... {
... a = 5;
... };
... """)
{'my_class': {'a': 5}} Or do you mean that Anyway, this would require changing the parser and while I'm actually currently working on this module, I was focusing on adding fuzzing before releasing the cython version of it, so I can't say when I will be able to add it myself. Maybe consider submitting a PR? ;) |
If nothing else, being able to not error out when our classes don't always have beginning and ending curly brackets would be nice. For the second point, I should have clarified. Yes, it does parse but it doesn't bring in the inherited class which I think is an oversight. Foy my specific case, If I lose the inherited class then it will break my config when I try to spit out the modified data back into an Arma class structure. |
For the record: Commit 42a5d83 fixes empty classes. You can just use the master branch. Regarding the other part, I've started working on it yesterday, but hit a few issues with Cython and those custom classes inheriting from 1:1 parsing-generation matching was never really a goal (like ignoring comments) but these ones actually impact the functionality of the generated file, so it would be good to handle them correctly. |
Thanks for pointing that out. I didn't know master branch fixes that issue. I unfortunately don't have any suggestions due to being unfamiliar with Cython. However, I appreciate your help and look forward to your solution. |
The master branch fixes that issue because I've added it just before writing that last message so it's normal that you did not expect it to work on master (because it wasn't :) ). Regarding suggestions, I was talking about the python part (as i'm writing everything in Pure Python mode with cython decorators, so that the code will work just fine without cython, it will just be much slower). The downside of using a |
Would it not work to just change the key name in the dictionary from |
a dataclass might be helpful here? https://docs.python.org/3/library/dataclasses.html#dataclasses.asdict |
I'm afraid not. The classes' contents that have a dataclass decorator need to be known ahead of time. I think? Namely, we need to have a new type of item(s) that would allow us to store additional constructs. In case of this issue, we're talking about the class' parent in the interitance hierarchy, but I'd like to do it in a way that would allow us to parse and store |
Would really love to have this fixed as its pretty important to capture class inheritance and instantiation when trying to parse Arma 3 classes.
When I try to parse a config.cpp file it errors out when it comes across the following.
class SlotInfo;
and
The text was updated successfully, but these errors were encountered: