Thread: [pygccxml-development] inline asm
Brought to you by:
mbaas,
roman_yakovenko
From: Thomas R. <tho...@gm...> - 2008-08-16 08:23:05
|
Now that I have my other problem solved.. does py++ support inline asm? If so, how exactly would I handle a function that uses inline asm? If not, I'm having problems excluding the function and most likely I'm doing it wrong :P This is the offending code: NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) { #ifdef WIN32 NxF32 localCos, localSin; NxF32 local = f; _asm fld local _asm fsincos _asm fstp localCos _asm fstp localSin c = localCos; s = localSin; #else c = cosf(f); s = sinf(f); #endif } It's from the PhysX sdk :P This function is in a different header than I'm trying to bind, so this may be my issue. How do I exclude a member function if it's in a different header than I'm binding? I tried doing it just the way I normally would: foo = mb.member_function("foo") foo.exclude() That didn't work. I also tried specifying the class: bar = mb.class_("bar") foo = bar.member_function("foo") foo.exclude() But that didn't work either. -Tom |
From: Roman Y. <rom...@gm...> - 2008-08-16 10:08:25
|
On Sat, Aug 16, 2008 at 11:23 AM, Thomas Rab <tho...@gm...> wrote: > Now that I have my other problem solved.. does py++ support inline asm? What do you mean? Any way the answer is "no". > If > so, how exactly would I handle a function that uses inline asm? If not, I'm > having problems excluding the function and most likely I'm doing it wrong :P > This is the offending code: > > NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) > { > #ifdef WIN32 > NxF32 localCos, localSin; > NxF32 local = f; > _asm fld local > _asm fsincos > _asm fstp localCos > _asm fstp localSin > c = localCos; > s = localSin; > #else > c = cosf(f); > s = sinf(f); > #endif > } > It's from the PhysX sdk :P > This function is in a different header than I'm trying to bind, so this may > be my issue. How do I exclude a member function if it's in a different > header than I'm binding? I tried doing it just the way I normally would: > foo = mb.member_function("foo") > foo.exclude() > That didn't work. I also tried specifying the class: > bar = mb.class_("bar") > foo = bar.member_function("foo") > foo.exclude() > But that didn't work either. -Tom Sorry, I don't understand your question. Please create small and complete example, that demonstrates the problem. Also can you be clear what the problem is? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Matthias B. <mat...@gm...> - 2008-08-16 17:13:56
|
Roman Yakovenko wrote: > On Sat, Aug 16, 2008 at 11:23 AM, Thomas Rab <tho...@gm...> wrote: >> Now that I have my other problem solved.. does py++ support inline asm? > > What do you mean? Any way the answer is "no". Maybe he rather means whether *gccxml* supports inline asm. I actually don't know the answer to that but I would imagine that it supports the same syntax that gcc supports. Seeing that the posted code has a #ifdef WIN32, it looks like those assembler statements might only be understood by the Microsoft compiler. If this is the problem then it's similar to a problem I once had on OSX where some system headers use code in some inline functions that is specific to Apple's version of gcc. Of course, gccxml didn't understand those things and issued an error. My workaround to this problem was to create local copies of those system headers and remove the function bodies. I could then use those copies when running gccxml and use the original headers when compiling the code. It's a bit awkward, but it works. >> NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) >> { >> #ifdef WIN32 >> NxF32 localCos, localSin; >> NxF32 local = f; >> _asm fld local >> _asm fsincos >> _asm fstp localCos >> _asm fstp localSin >> c = localCos; >> s = localSin; >> #else >> c = cosf(f); >> s = sinf(f); >> #endif >> } >> It's from the PhysX sdk :P >> This function is in a different header than I'm trying to bind, so this may >> be my issue. How do I exclude a member function if it's in a different >> header than I'm binding? It doesn't matter in which header a function is declared (unless you explicitly restrict a query to certain headers). >> I tried doing it just the way I normally would: >> foo = mb.member_function("foo") >> foo.exclude() >> That didn't work. I also tried specifying the class: >> bar = mb.class_("bar") >> foo = bar.member_function("foo") >> foo.exclude() Is the NxMath class inside a namespace? Then you would have to search that namespace instead of the root namespace (or use the recursive flag). >> But that didn't work either. -Tom What do you mean by "it didn't work"? Did it produce an error message? If so, what was that error? Or did everything run fine but your Python module just contained more stuff than you wanted? As Roman said, you should be more specific as to what the actual problem is (it might also help knowing if you are actually on Windows or not (or if you did define WIN32 yourself)). - Matthias - |
From: Thomas R. <tho...@gm...> - 2008-08-17 01:59:03
|
> Maybe he rather means whether *gccxml* supports inline asm. I actually > don't know the answer to that but I would imagine that it supports the > same syntax that gcc supports. Seeing that the posted code has a #ifdef > WIN32, it looks like those assembler statements might only be understood > by the Microsoft compiler. > > If this is the problem then it's similar to a problem I once had on OSX > where some system headers use code in some inline functions that is > specific to Apple's version of gcc. Of course, gccxml didn't understand > those things and issued an error. > My workaround to this problem was to create local copies of those system > headers and remove the function bodies. I could then use those copies > when running gccxml and use the original headers when compiling the > code. It's a bit awkward, but it works. > > > It doesn't matter in which header a function is declared (unless you > explicitly restrict a query to certain headers). > > Is the NxMath class inside a namespace? Then you would have to search > that namespace instead of the root namespace (or use the recursive flag). > > >> But that didn't work either. -Tom > > What do you mean by "it didn't work"? Did it produce an error message? > If so, what was that error? Or did everything run fine but your Python > module just contained more stuff than you wanted? > As Roman said, you should be more specific as to what the actual problem > is (it might also help knowing if you are actually on Windows or not (or > if you did define WIN32 yourself)). > > - Matthias - > > > > Sorry for not being more clear. Yes, I suppose I did mean if gccxml supports inline assembly. I thought the answer would be no though, as I has checked if GCC supported inline asm and it looks like it does, but you need to do some things before it's able to work. I didn't really read into detail though. Anyway, that is fine. I can exclude the function. I'll try to explain the header problem more throughly. You answered the first part for me Matthias, thanks. I hadn't actually checked if it was in another namespace (doh!), I was trying to find the correct syntax earlier though. Can I do this for instance: inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") inlineASM.exclude() Right now because of this function I can't generate any code at all. Here is the error I get: C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In static member function `static void NxMath::sinCos(float, NxF32&, NxF32&)': C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` _asm' undeclared (first use this function) C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each undeclared identifier is reported only once for each function it appears in.) C:/Program Files/NVIDIA Corporation/NVIDIA PhysX SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax error before `local' I get this error whether or not I exclude the function (the way I had shown in the previous post). So I'm guess the problem is probably with namespaces and gccxml can not find the function I'm giving it. Sorry if any of these are silly questions. I'm still learning how to use py++ and I've never used GCC before (I've always used Microsoft compilers). GCC surely has some global define like WIN32 and LINUX to determine OS, does it not? I don't think that's a problem though. At least I'm not getting any errors related to it. The errors I posted are the only errors I'm getting at this point. Hopefully I was a bit more clear this time :) - Tom |
From: Roman Y. <rom...@gm...> - 2008-08-17 04:14:12
|
On Sun, Aug 17, 2008 at 4:59 AM, Thomas Rab <tho...@gm...> wrote: > Sorry for not being more clear. Yes, I suppose I did mean if gccxml > supports inline assembly. I thought the answer would be no though, as I has > checked if GCC supported inline asm and it looks like it does, but you need > to do some things before it's able to work. I didn't really read into detail > though. Anyway, that is fine. I can exclude the function. > I'll try to explain the header problem more throughly. You answered the > first part for me Matthias, thanks. I hadn't actually checked if it was in > another namespace (doh!), I was trying to find the correct syntax earlier > though. Can I do this for instance: > inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") > inlineASM.exclude() > Right now because of this function I can't generate any code at all. Here is > the error I get: > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In > static member function `static void NxMath::sinCos(float, NxF32&, > NxF32&)': > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` > _asm' undeclared (first use this function) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each > undeclared identifier is reported only once for each function it appears > in.) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax > error before `local' > > I get this error whether or not I exclude the function (the way I had shown > in the previous post). So I'm guess the problem is probably with namespaces > and gccxml can not find the function I'm giving it. Sorry if any of these > are silly questions. I'm still learning how to use py++ and I've never used > GCC before (I've always used Microsoft compilers). GCC surely has some > global define like WIN32 and LINUX to determine OS, does it not? I don't > think that's a problem though. At least I'm not getting any errors related > to it. The errors I posted are the only errors I'm getting at this point. > Hopefully I was a bit more clear this time :) - Tom If I understand right, you are not able to compile your code with gccxml and the reason is "_asm" function usage. I think, that this is a bug in gccxml and it could be fixed by Brad King, gccxml author. I suggest you to create small example and send it to him ( http://www.gccxml.org/mailman/listinfo/gccxml ) The current work-around is to move\comment the function body. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Matthias B. <mat...@gm...> - 2008-08-17 08:40:56
|
Thomas Rab wrote: > earlier though. Can I do this for instance: > inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") > inlineASM.exclude() Well, assuming that gccxml could parse the files then yes, this should work. But the problem is that your script never gets to this line because of the errors you are seeing. > Right now because of this function I can't generate any code at all. > Here is the error I get: > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In > static member function `static void NxMath::sinCos(float, NxF32&, > NxF32&)': > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` > _asm' undeclared (first use this function) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each > undeclared identifier is reported only once for each function it appears > in.) > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax > error before `local' You didn't post the full error message (I'm sure there was something before or after that) but I'm assuming you got that error when *generating* the Python binding source code (and not when compiling them). Py++ runs gccxml to parse the header files when you create the module builder object. If gccxml cannot parse the files you will get an error and your script terminates. This is why the code where you try to exclude the function will never get executed. Excluding a function doesn't mean it will be excluded from the parsing step, it rather means that the function will be excluded from the Python bindings. So before you can actually start working with Py++ you have to make sure that gccxml is able to parse the header files properly. I think in your case you have to do the workaround I mentioned in my other mail (creating local copies of the header files that have the function bodies removed). You may still follow Roman's suggestion though and post a message about this in the gccxml mailing list (as it's really a gccxml problem, not a Py++ one). Personally, I don't consider this to be a bug in gccxml though as the offending code apparently is specific to the Microsoft compiler. As far as I know, the syntax for inline assembly code is not part of the C/C++ standard, so every compiler can just do whatever it wants, and I'm not sure if gccxml is meant to be able to emulate all compilers out there (after all, it's called _GCC_xml). But of course, it would be nice if gccxml could handle such a case. Personally, I would prefer an option that instructs gccxml to entirely ignore function bodies when parsing the code (they are not needed by Py++ anyway), then this would also fix my problem on OSX. :) - Matthias - |
From: Thomas R. <tho...@gm...> - 2008-08-17 12:55:55
|
On Sun, Aug 17, 2008 at 3:41 AM, Matthias Baas <mat...@gm...>wrote: > Thomas Rab wrote: > > earlier though. Can I do this for instance: > > inlineASM = mb.namespace("foo").class_("NxMath").member_function("bar") > > inlineASM.exclude() > > Well, assuming that gccxml could parse the files then yes, this should > work. But the problem is that your script never gets to this line > because of the errors you are seeing. > > > Right now because of this function I can't generate any code at all. > > Here is the error I get: > > > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h: In > > static member function `static void NxMath::sinCos(float, NxF32&, > > NxF32&)': > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: ` > > _asm' undeclared (first use this function) > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: (Each > > undeclared identifier is reported only once for each function it > appears > > in.) > > C:/Program Files/NVIDIA Corporation/NVIDIA PhysX > > SDK/v2.8.1/SDKs/Foundation/include/NxMath.h:744: error: syntax > > error before `local' > > You didn't post the full error message (I'm sure there was something > before or after that) but I'm assuming you got that error when > *generating* the Python binding source code (and not when compiling them). > Py++ runs gccxml to parse the header files when you create the module > builder object. If gccxml cannot parse the files you will get an error > and your script terminates. This is why the code where you try to > exclude the function will never get executed. Excluding a function > doesn't mean it will be excluded from the parsing step, it rather means > that the function will be excluded from the Python bindings. > So before you can actually start working with Py++ you have to make sure > that gccxml is able to parse the header files properly. > > - Matthias -<https://lists.sourceforge.net/lists/listinfo/pygccxml-development> > Ah, that's where I got confused. I misunderstood exclude's function. I thought it was supposed to exclude it from parsing. Thanks for clearing that up! -Tom |