from c++ to python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luke14free
    New Member
    • Apr 2007
    • 79

    #1

    from c++ to python

    Hello to all,
    I am a python user and i would like to use a c++ extension in python (because i am forced to do that!) but i dont know where to start, on the where there are:

    1) swig that requires a mid passage and requires a knowledge of cpp(that i really dont have)
    2)pycxx that comes without docs and hasnt got any documentation on the web

    Thank you

    ps: if you want to see the script i am trying to use in python goto:

    http://forum.nokia.com/info/sw.nokia.com/id/8b3a6ed3-e833-4f7c-aee1-4c773196f894/S60_Platform_Fu ll-Duplex_Audio_Ex ample_v2_0_en.z ip.html

    PS: I am posting the same post on the c/c++ forum in order to see if anyone knows how to solve my problem there.

    Thank you,
    Best regards
    (feel free to correct my english)
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by luke14free
    Hello to all,
    I am a python user and i would like to use a c++ extension in python (because i am forced to do that!) but i dont know where to start, on the where there are:

    1) swig that requires a mid passage and requires a knowledge of cpp(that i really dont have)
    2)pycxx that comes without docs and hasnt got any documentation on the web

    Thank you

    ps: if you want to see the script i am trying to use in python goto:

    http://forum.nokia.com/info/sw.nokia.com/id/8b3a6ed3-e833-4f7c-aee1-4c773196f894/S60_Platform_Fu ll-Duplex_Audio_Ex ample_v2_0_en.z ip.html

    PS: I am posting the same post on the c/c++ forum in order to see if anyone knows how to solve my problem there.

    Thank you,
    Best regards
    (feel free to correct my english)
    A third option (which I have experience with - tried SWIG - too complicated) that might work for you is the ctypes module. It's included in version 2.5 and can be added to 2.4 (maybe even 2.3). It's basically a DLL loader with varailbe types that can be passed directly to C. I use it quite often for advance Window programming and it works very well.

    Hope that helps,
    Barton

    Comment

    • luke14free
      New Member
      • Apr 2007
      • 79

      #3
      very nice answer! Do you remember me? I am the man of the process handling, and you suggested me to use ctypes...And it worked...
      How could i didn't remember for a c library??

      Thank you

      Comment

      • luke14free
        New Member
        • Apr 2007
        • 79

        #4
        Sorry, i have just check the compatibility of dlls with python for nokia series 60 and it is uncompatible... what a pity, it would have been great!
        so, have you got other ideas?

        Thank you

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          Originally posted by luke14free
          Sorry, i have just check the compatibility of dlls with python for nokia series 60 and it is uncompatible... what a pity, it would have been great!
          so, have you got other ideas?

          Thank you
          The ctypes module is capable of handling libraries compiled with different call types:
          windll uses stdcall. There are others that I'm not familiar with and I dont't have 2.5 installed on this maching. But this online doc says:
          You load libraries by accessing them as attributes of these objects. cdll loads libraries which export functions using the standard cdecl calling convention, while windll libraries call functions using the stdcall calling convention.

          Comment

          • luke14free
            New Member
            • Apr 2007
            • 79

            #6
            So i should (using software a svisual studio...) create dlls with inside all the modules that i needed in c and then call them with python...it seems not so easy...
            and however please look ath this http://pymbian.sourcef orge.net/misc/statichack/INFO

            Best regards,
            Luke14free

            Comment

            Working...