Hi,
I'm trying to compile a Python package that uses pygtk and it's
codegen/argtypes facilities (the package is pygoocanvas).
I succeeded both on Linux and Windows (after having a hard time on
Windows) but I still have some virtual accessors and interfaces not being
created, on both platforms.
This happens because some of the types used in the .defs files are unknown
to argtypes:
Could not write virtual accessor method GooCanvasItem.get_child_property:
No ArgType for GValue*
Could not write virtual accessor method GooCanvasItem.get_items_at: No
ArgType for GList*
Could not write virtual accessor method GooCanvasItem.child_notify: No
ArgType for GParamSpec*
etc...
>From what I understand, the types need to be registered:
* a bunch of them are registered at the end of codegen/argtypes.py:
matcher.register('GType', GTypeArg())
matcher.register('GError**', GErrorArg())
* you can register your custom types in your package:
matcher.register('GooCanvasBounds*', BoundsPtrArg())
However I can't figure out where GValue and his friends should be
registered and why they're not. This seems weird to me because for
instance "gtk-2.16.defs" uses "GValue*", so I don't think this is
something that should be done by the package itself, even if I found some
code on the internet that manually does the following:
class GValueArg(argtypes.ArgType):
def write_param(self, ptype, pname, pdflt, pnull, info):
info.varlist.add('GValue', pname + ' = { 0 }')
info.varlist.add('PyObject', '*py_' + pname)
info.codebefore.append(' pygda_value_from_pyobject(&%s,
py_%s);\n' % (pname, pname))
info.codeafter.append(' if(G_IS_VALUE(&%s))
g_value_unset(&%s);\n' % (pname, pname))
info.arglist.append('&' + pname)
info.add_parselist('O', ['&py_' + pname], [pname])
def write_return(self, ptype, ownsreturn, info):
if(ptype == 'const-GValue*'):
info.varlist.add('const GValue', '*ret')
else:
info.varlist.add('GValue', '*ret')
info.varlist.add('PyObject', '*pyret')
info.codeafter.append(' pyret = pygda_value_as_pyobject(ret,
TRUE);\n')
if ownsreturn:
info.codeafter.append(' if(G_IS_VALUE(ret))
g_value_unset(ret);\n')
info.codeafter.append(' return pyret;')
arg = GValueArg()
argtypes.matcher.register('GValue*', arg)
argtypes.matcher.register('const-GValue*', arg)
Is there anyone that could help me on that subject?
Thanks in advance
-David
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/