[pyxpcom] [native] pointers in *.idl files
by Marco Bosch other posts by this author
Sep 9 2001 12:27PM messages near this date
Re: [pyxpcom] New PyXPCom Project
|
RE: [pyxpcom] [native] pointers in *.idl files
Hello,
First of all I would like to thank Mark Hammond for the great work on
PyXPCOM.
I have been able to use PyXPCOM with an existing Mozilla 0.9.1 milestone
I already had on
my linux computer. This is an rpm package from Ximian (downloaded with
Red-Carpet)
which also included a mozilla-devel rpm package and nspr/ nspr-devel
packages.
Therefore I (and a lot of other Linux users) already have all the *.idl
and *.h files needed
on their computers. I only had to compiled a shared library of Python
2.0, which however
is not completely trivial, because there is no makefile target to do
that, see
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=400938&group_id=5470).
I did not have to download the complete mozilla source and compile the
whole beast, which
is basically impossible on my computer system. Instead, I only had to
`cvs checkout' the
mozilla/extensions/python/xpcom and change the makefile to find the
*.idl and *.h files.
So, now I have a working PyXPCOM and I can use a lot of services without
any problems.
However, I have a problem, that might be related to the PyXPCOM handling
of [native] pointers in
idl. I wanted to implement the nsICmdLineService in Python. For Mozilla
0.9.1 it's given by:
#include "nsISupports.idl"
#include "nsIFactory.idl"
[ptr] native charArray(char*);
[scriptable, uuid(e34783f4-ac08-11d2-8d19-00805fc2500c)]
interface nsICmdLineService : nsISupports{
string Initialize(in long argc);
string getCmdLineValue(in string argc);
readonly attribute string URLToLoad;
readonly attribute string programName;
readonly attribute long argc;
[noscript] readonly attribute charArray argv;};
My implementation looks like:
import xpcom
class nsIMyCmdLineService:
_com_interfaces_ = xpcom.components.interfaces.nsICmdLineService
_reg_clsid_ = "{e34783f5-ac08-11d2-8d19-00805fc2500c}"
_reg_contractid_ = "@mozilla.org/appshell/commandLineService;1"
def Initialize( self, param0 ):
print "commandLineService: Initialize"
print "param0: ",param0
def getCmdLineValue( self, param0 ):
print "commandLineService: getCmdLineValue"
return "noresult"
def get_URLToLoad( self ):
print "commandLineService: get_URLToLoad"
return ""
def get_programName( self ):
print "commandLineService: get_programName"
return "MyMozilla"
def get_argc( self ):
print "commandLineService: get_argc"
return 1
def get_argv( self ):
print "commandLineService: get_argv"
return ("MyMozilla")
My problem is with the get_argv routine. It's out value is defined as
readonly attribute charArray
and charArray is defined by
[ptr] native charArray(char*);
If I use this method, I get the warning:
PyXPCOM Warning: Converting Python object for an [out] param - The
object type (0xd) is unknown - leaving param alone!
I have the feeling that the void* type is not recognized/handled by
PyXPCOM. Does anybody have a solution to this?
greetings
Marco Bosch
_______________________________________________
pyxpcom mailing list
pyxpcom@[...].com
http://listserv.ActiveState.com/mailman/listinfo/pyxpcom
Thread:
Marco Bosch
Mark Hammond
|