-
Notifications
You must be signed in to change notification settings - Fork 166
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
code that uses the struct module for reading bytes in file headers is not converted #8
Comments
Correct. Pytocs needs to be made aware of the |
now that I think of it it could be extended to know about all parts of the python standard library that has an implementation already in the .NET framework. |
Indeed. It just a question of time to write mappings from python APIs to equivalents in the .NET framework |
By the way, @AraHaan, is your expectation that when translating tuple_of_integers = struct.unpack("<ii", buffer) the result should be: var tuple_of_integers = @struct.unpack<Tuple<int,int>>("<ii", buffer); or are you expecting that, since the unpacking format string is constant, it should be broken down into something like the following code? int _tmp0 = 0;
var _tmp1 = PyToCs.Runtime.ReadLeInt32(buffer, ref _tmp0);
var _tmp2 = PyToCs.Runtime.ReadLeInt32(buffer, ref _tmp0);
var tuple_of_integers = Tuple.Create(_tmp1, _tmp2); My gut tells me the first choice is better as it follows the original Python source more closely. In particular avoiding the introduction of all those variables helps the readability of the code. |
Now that I realized it, the struct module is not really needed, just take the size of the struct module input string and put it into the 1st param in Also it needs BitConverter as well on my code, that was another reason why my manual translation crashed as well. However now my manual translation only gets the first elelment in the XML data and makes only that entry when it should get multiple ones, my guess is an typo somewhere. |
Sadly, the |
ah, I see. Also the zlib stuff from python could be converted to zlib.net usage (however it is sadly unmaintined to provide implementation of the very latest zlib into it though). |
It seems like python code that uses the struct module is not converted to compileable standalone C#. (it would probably get syntax errors).
Code like this for example:
Is not converted properly, it still looks almost exactly alike in the output C# code.
Also, if I try to manually convert it to look like this:
The program would crash at the second read into the file to get the data it needs to extract.
The text was updated successfully, but these errors were encountered: