You Are Here:

Community: Developer Discussion Boards

#1 Old Help with simple C++ wrapper - 2008-04-02, 11:44

Join Date: Mar 2008
Posts: 25
sstoica
Offline
Registered User
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"
Reply With Quote

#2 Old Re: Help with simple C++ wrapper - 2008-04-03, 10:13

Join Date: Mar 2008
Posts: 25
sstoica
Offline
Registered User
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 !
Reply With Quote

#3 Old Re: Help with simple C++ wrapper - 2008-04-03, 12:51

Join Date: Dec 2007
Posts: 134
Location: India
kandyfloss's Avatar
kandyfloss
Offline
Regular Contributor
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
Reply With Quote

#4 Old Re: Help with simple C++ wrapper - 2008-04-03, 14:23

Join Date: Mar 2008
Posts: 25
sstoica
Offline
Registered User
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
Reply With Quote

#5 Old Re: Help with simple C++ wrapper - 2008-04-04, 13:33

Join Date: Dec 2006
Posts: 2,094
Sorcery-ltd's Avatar
Sorcery-ltd
Offline
Forum Nokia Champion
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
Reply With Quote

#6 Old Re: Help with simple C++ wrapper - 2008-04-04, 15:23

Join Date: Mar 2008
Posts: 25
sstoica
Offline
Registered User
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 16:24.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple tutorial needed selimhanov Tools and SDK Feedback 6 2008-01-08 12:49
[announce] s60 Simple libs wrapper 0.1 cyke64 Python 0 2007-05-24 14:56
Simple HTTPS Request Gone Wrong roryfynn Mobile Java Networking & Messaging & Security 3 2006-01-30 11:15
Simple game do NOT imply simple solution... etamburini Mobile Java General 3 2005-04-28 15:32
Simple game do NOT imply simple solution... etamburini Mobile Java Media (Graphics & Sounds) 3 2005-04-04 16:29

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia