olofk / ipyxact

Python-based IP-XACT parser
MIT License
124 stars 48 forks source link

Issue adding AlternateRegister field to yaml des #2

Closed rinfranc closed 8 years ago

rinfranc commented 8 years ago

Hi, I am using your ipyxact lib to process an XML related to an IP. In this XML some r"egister" has the sub-field "alternateregisters", which has "alternateregister" and so on.. I have modified the yaml in this way: ....... alternateRegister: MEMBERS: name: str description: str access: str addressOffset: IpxactInt size: IpxactInt volatile: IpxactBool CHILDREN:

but now what happens is that inside "field" of "register", there are also the "field" coming from "alternateregister". Seems that due to the presence of "field" inside "register" and "alternateregister", the library append under "field" of "register" also the "field" of "alternateregister" What do you think about? Thanks in advance

olofk commented 8 years ago

Thanks for reporting. If I understand correctly, the field objects in register and alternateRegister are the same objects, but they should actually be two different copies. I'll take a look at the code and see if I can fix this somehow.

rinfranc commented 8 years ago

Hi, thanks for the quick reply. Yes, you are right, as you can read above, "field" is a sub-field of "register" and "alternateregister". What I have seen is that the "field" of alternateregister are copied also inside "field" of register. This is the yaml related to "field" that I haven't copied above:

field: MEMBERS: name: str description: str bitOffset: IpxactInt bitWidth: IpxactInt volatile: IpxactBool access: str testable: str modifiedWriteValue: str CHILDREN:

Thanks again

olofk commented 8 years ago

I think I've fixed the issue now. Also added the alternateRegister tags to the yaml file. Please close the issue if it works for you, or let me know if something is still broken.

Thanks

rinfranc commented 8 years ago

OK, thanks I was offline, give me the time to check it and then I will provide you a feedback Thank you

rinfranc commented 8 years ago

OK I have verified, the modification works fine.

Just another small issue, present also in the previous version that I forgot to mention: In the ipyxact.py file I have modified the row n.96 adding :"eval' in this way:

setattr(self, _name, _type(root.attrib[_tagname]))

                setattr(self, _name, (eval(_type)(root.attrib[_tagname])))

without this improvment, I have the following error:

_...egg/ipyxact/ipyxact.py", line 96, in parsetree TypeError: 'str' object is not callable

with this modification the script can be executed without problem. What do you think about? Is only an issue on my side?

Thank in advance Rinaldo

olofk commented 8 years ago

Hi Rinaldo,

You're absolutely right. My testcases had just missed this. I have updated the code and added a better testcase. Thanks for letting me know!