×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    25

    Help with simple C++ wrapper

    Hello,
    I wanted to test the possibility of extending PyS60 with C++ so i tried to make a simple example (inspired from uikludges example). I have no problems with building the files, pyd, sis and signing themm but when i try to install on the phone i get this error:

    Unable to install. Mass memory not available.

    I also managed to build, sign and install the uikludges example and it works fine.
    Can anyone help please?

    here's the code i'm using:

    mySquare.cpp:
    Code:
    #include <e32std.h>
    #include <e32base.h>
    #include "Python.h"
    #include "symbian_python_ext_util.h"
    #include "logger.h"
    
    
    static PyObject* mySquare_getSquare(PyObject*, PyObject *args)
    {
        TInt number;
    	TInt square;
        
        if (!PyArg_ParseTuple(args, "i", &number))
            return NULL;
    	square = number * number;
        return Py_BuildValue("i", square);
    }
    
    static const PyMethodDef mySquare_methods[] = 
    {
        {"getSquare", (PyCFunction)mySquare_getSquare, METH_VARARGS},
        {0, 0}        /* Sentinel */
    };
    
    DL_EXPORT(void) init_mySquare()
    {
    	PyObject* module = Py_InitModule("_mySquare", (PyMethodDef*) mySquare_methods);
    }
    
    
    #ifndef EKA2
    GLDEF_C TInt E32Dll(TDllReason)
    {
      return KErrNone;
    }
    #endif

    mySquare.py

    Code:
    import _mySquare
    import e32
    
    def getSquare( number ):
    	_mySquare.getSquare(number)
    	
    #: Exported functions from this module
    __all__ = ["getSquare"]
    
    # Export all E*** pseudo constants automatically
    for x in locals().keys():
    	if x.startswith("E"):
    		__all__.append(x)
    mySquare.mmp

    Code:
    TARGETTYPE	dll
    UID 0x20033AE3 0xE7777777
    TARGET		_mySquare.pyd
    TARGETPATH	\sys\bin
    
    NOSTRICTDEF
    EXPORTUNFROZEN
    
    SYSTEMINCLUDE 	\epoc32\include
    SYSTEMINCLUDE 	\epoc32\include\libc
    
    USERINCLUDE		.
    USERINCLUDE   	\epoc32\include\python
    
    LIBRARY 	python222.lib
    LIBRARY 	euser.lib
    LIBRARY  	avkon.lib
    LIBRARY	    	flogger.lib
    LIBRARY		eikcore.lib 
    LIBRARY		cone.lib 
    LIBRARY     	ws32.lib 
    LIBRARY     	estlib.lib 
    library 	eikcoctl.lib
    library 	efsrv.lib
    
    MACRO __DO_LOGGING__
    
    SOURCE		mySquare.cpp
    
    #ifdef EKA2
    CAPABILITY LocalServices Location NetworkServices PowerMgmt ProtServ ReadDeviceData ReadUserData SurroundingsDD SwEvent TrustedUI UserEnvironment WriteDeviceData WriteUserData
    #endif

    mySquare.pkg

    Code:
    ;
    ; mySquare dll install
    ;
    ;Languages
    &EN
    
    ;Localised Vendor name
    %{"Sabin"}
    
    
    ;
    ;
    #{"mySquare"},(0x20033AE3),1,0,0
    ;
    ;Supports Series 60 v 2.0
    ;
    [0x101F7961], 0, 0, 0, {"Series60ProductID"}
    ;
    ; Files to install:
    
    "_mySquare.pyd"   		-"X:\mySquare\_mySquare.pyd"
    "mySquare.py"			-"X:\mySquare\mySquare.py"

  2. #2
    Registered User
    Join Date
    Mar 2008
    Posts
    25

    Re: Help with simple C++ wrapper

    any help? so basicaly my example is a stripped down example of uikludges... i can't figure out what's with that error. any help is apreciated !

  3. #3
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: Help with simple C++ wrapper

    Seems your phone has less memory? is it?

    On which device are you installing ?
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    25

    Re: Help with simple C++ wrapper

    oh, i forgot to mention that: the phone is a N95 8GB... and all memory is free...
    still didn't figure the problem out. can someone please try to see if the above example compiles and works on other phones?
    any help would be very much apreciated.

    thank you

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Help with simple C++ wrapper

    Hi,

    I don't have time to check this now but you could try replacing the X's with !'s in these lines in the pkg file:
    Code:
    "_mySquare.pyd"   	-"X:\mySquare\_mySquare.pyd"
    "mySquare.py"			-"X:\mySquare\mySquare.py"
    like this:
    Code:
    "_mySquare.pyd"   	-"!:\mySquare\_mySquare.pyd"
    "mySquare.py"			-"!:\mySquare\mySquare.py"
    That should ask you where you want to install the files and list available drives.

    Sorcery

  6. #6
    Registered User
    Join Date
    Mar 2008
    Posts
    25

    Re: Help with simple C++ wrapper

    I think that with the "X" I just specify the path from where to include the files in the .sis (I
    Code:
    subst x: c:\symbian
    to avoid any bldmake errors - all my examples, working and non-working, were compiled like this).

    Nevertheles i will give it a try.


    EDIT: It worked, the sis installed succesfully! But now i get the "ImportError: No moduled named mySquare" error. I will look into this, thanks a lot !

    EDIT2: It seems i was making a really stupid mistake. Replaced the last 2 lines in the .pkg with this:

    ; Files to install:

    "_mySquare.pyd" -"c:\sys\bin\_mySquare.pyd"
    "mySquare.py" -"c:\resource\mySquare.py"

    to install the module in the right place
    All works well now, I can import the module and call it's getSquare method but it returns the value of "None".
    Last edited by sstoica; 2008-04-04 at 15:24.

Similar Threads

  1. Simple tutorial needed
    By selimhanov in forum Tools and SDK Feedback (Closed)
    Replies: 6
    Last Post: 2008-01-08, 11:49
  2. [announce] s60 Simple libs wrapper 0.1
    By cyke64 in forum Symbian
    Replies: 0
    Last Post: 2007-05-24, 13:56
  3. Simple HTTPS Request Gone Wrong
    By roryfynn in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2006-01-30, 10:15
  4. Simple game do NOT imply simple solution...
    By etamburini in forum Mobile Java General
    Replies: 3
    Last Post: 2005-04-28, 14:32
  5. Simple game do NOT imply simple solution...
    By etamburini in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2005-04-04, 15:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×