From: Arno P. <ar...@pu...> - 2010-11-30 18:07:19
|
interesting point. Can you please verify that this works now? If so, I will commit the patch. Arno On 11/30/10 7:45 AM, Troy Gaines wrote: > I have a char array in Objective C with this: char[] {0, 37, 0, 0}. > This is later passed to the readInt__ method in java_io_DataInputStream. > > This results in 9472 through the Simulator. On the Java side, I wrote a > test and this results in 2424832. It appears the byte order is being > reversed since Java reads and writes everything in byte order. It > seems like the following code needs to be reversed to match Java. > > So instead of p being p[0] = 0, p[1] = 25, p[2] = 0, p[3] = 0 it would > be p[0] = 0, p[1] = 0, p[2] = 25, p[3] = 0. This would correctly > convert on the iPhone. I posted what the new method could look like > although I didn't test it. > > *original* > > - (int) readInt__ > { > int d; > unsigned char* p = (unsigned char*) &d; > for (int i = 0; i < 4; i++) { > int v = [target read__]; > *p++ = (unsigned char) v; > } > > return d; > } > > to > > *new* > > - (int) readInt__ > { > int d; > unsigned char* p = (unsigned char*) &d; > for (int i = 4; i > 0; i--) { > int v = [target read__]; > p[i-1] = (unsigned char) v; > } > > return d; > } > > * > * > * > * > > > > ------------------------------------------------------------------------------ > Increase Visibility of Your 3D Game App& Earn a Chance To Win $500! > Tap into the largest installed PC base& get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. > http://p.sf.net/sfu/intelisp-dev2dev > > > > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |