1. 3.2, Wrapping DLLs and Float types
- Posted by Jeremy Cowgar <jeremy at cow?ar.?om> May 01, 2008
- 618 views
I've wrapped PgSQL and used Sqlite, PCRE and Iup in 3.2 now w/no problems, once the stack offset was fixed for gcc 4.3.0, however, none of those use the Float type. Now, before going further, the C examples I have created work great, and the wrapper that I've created works identical to the C examples when executed with Euphoria 3.1.1. However, the results are different with the same wrapper, the same examples on the same computer when run with 3.2. I am now wrapping LibHaru, which will be released into the archives and will give Euphoria PDF capabilities. However, floats, I have identified what I think is a bug, but I do not have the knowledge to track it down. The bug is this:
constant fHPDF_Page_SetFontAndSize = define_c_func(lib, "HPDF_Page_SetFontAndSize", {P, P, F}, I), fHPDF_Page_TextOut = define_c_func(lib, "HPDF_Page_TextOut", {P, F, F, P}, I) -- P = C_POINTER, F = C_FLOAT, I = C_INT.
The parameters for TextOut are: Page, X, Y and Text. The problem is the resulting PDF outputs for X, Y: 761 0 Td when it should be 60 761. What that tells PDF readers is unimportant, the part that is important is that Y is being shifted to X's position, and Y is 0. The parameters for SetFontAndSize are: Page, Font, Size. The Font section is output correctly, but the size is in the PDF as: 0 Tf when it should be 12 Tf. So, once again the Float is being lost/corrupted somehow in 3.2. Again, this all works great in 3.1.1. Thanks for any input. -- Jeremy Cowgar http://jeremy.cowgar.com
2. Re: 3.2, Wrapping DLLs and Float types
- Posted by Jeremy Cowgar <jeremy at co?g?r.com> May 01, 2008
- 578 views
Oh, I should add, that is 3.2 is also compiled with gcc 4.3.0, so it may be another change in 4.3.0 ? -- Jeremy Cowgar http://jeremy.cowgar.com
3. Re: 3.2, Wrapping DLLs and Float types
- Posted by Jason Gade <jaygade at ya?oo.co?> May 01, 2008
- 578 views
Jeremy Cowgar wrote: > > I've wrapped PgSQL and used Sqlite, PCRE and Iup in 3.2 now w/no problems, > once > the stack offset was fixed for gcc 4.3.0, however, none of those use the Float > type. > > Now, before going further, the C examples I have created work great, and the > wrapper that I've created works identical to the C examples when executed with > Euphoria 3.1.1. However, the results are different with the same wrapper, the > same examples on the same computer when run with 3.2. > > I am now wrapping LibHaru, which will be released into the archives and will > give Euphoria PDF capabilities. However, floats, I have identified what I > think > is a bug, but I do not have the knowledge to track it down. The bug is this: > > }}} <eucode> > constant > fHPDF_Page_SetFontAndSize = define_c_func(lib, "HPDF_Page_SetFontAndSize", > {P, P, F}, I), > fHPDF_Page_TextOut = define_c_func(lib, "HPDF_Page_TextOut", > {P, F, F, P}, I) > > -- P = C_POINTER, F = C_FLOAT, I = C_INT. > </eucode> {{{ > > The parameters for TextOut are: Page, X, Y and Text. The problem is the > resulting > PDF outputs for X, Y: 761 0 Td when it should be 60 761. What that tells PDF > readers is unimportant, the part that is important is that Y is being shifted > to X's position, and Y is 0. > > The parameters for SetFontAndSize are: Page, Font, Size. The Font section is > output correctly, but the size is in the PDF as: 0 Tf when it should be 12 Tf. > > So, once again the Float is being lost/corrupted somehow in 3.2. Again, this > all works great in 3.1.1. > > Thanks for any input. > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> This is getting outside of my expertise, but where there any compiler flags different for 3.0 than from 3.2? Maybe the offset you changed was still a little wrong but close enough to work most of the time? I'm wondering if one of the float arguments is being passed in a register instead of on the stack, or if it is being consumed by another function, or whether it is being passed at all. Also, are you sure the arguments are supposed to be floats and not doubles? I know they're different sizes but I don't know if GCC allocates the same amount of space on the stack for them. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
4. Re: 3.2, Wrapping DLLs and Float types
- Posted by Jeremy Cowgar <jeremy at ?owgar?com> May 01, 2008
- 604 views
Jason Gade wrote: > > This is getting outside of my expertise, but where there any compiler flags > different for 3.0 than from 3.2? Maybe the offset you changed was still a > little > wrong but close enough to work most of the time? > I'm not sure either. Matt helped me find the right offsets. <snip> > Also, are you sure the arguments are supposed to be floats and not doubles? Yes, I just went back and tripple checked. HPDF_STATUS HPDF_Page_SetFontAndSize (HPDF_Page page, HPDF_Font font, HPDF_REAL size); HPDF_STATUS HPDF_Page_TextOut (HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, const char *text); In hpdf_types.h: /* float type (32bit IEEE754) */ typedef float HPDF_REAL; -- Jeremy Cowgar http://jeremy.cowgar.com
5. Re: 3.2, Wrapping DLLs and Float types
- Posted by Jeremy Cowgar <jeremy at c?wgar.co?> May 03, 2008
- 590 views
Ok. I installed gcc-3.3 on my computer and Euphoria 3.2/4.0 works fine, floats and all when compiled with gcc-3.3. It works fine when compiled with gcc-4.3.0, except when using floats. So, the problem is with something changing in gcc. I am just not sure what. I am going to start a new thread about Euphoria and gcc-4.3.0 compatibility. Please comment there (so we can have proper subject titles). -- Jeremy Cowgar http://jeremy.cowgar.com