r4879 - in trunk/src/host/pye17: . codegen ecore_evas examples/ecore_evas
marek at docs.openmoko.org
marek at docs.openmoko.org
Tue Dec 23 10:24:23 CET 2008
Author: marek
Date: 2008-12-23 10:24:23 +0100 (Tue, 23 Dec 2008)
New Revision: 4879
Modified:
trunk/src/host/pye17/Makefile
trunk/src/host/pye17/codegen/argtypes.py
trunk/src/host/pye17/codegen/codegen.py
trunk/src/host/pye17/codegen/definitions.py
trunk/src/host/pye17/codegen/h2def.py
trunk/src/host/pye17/ecore_evas/ecore_evas.override
trunk/src/host/pye17/examples/ecore_evas/simple_window.py
Log:
add primitive callback support
Modified: trunk/src/host/pye17/Makefile
===================================================================
--- trunk/src/host/pye17/Makefile 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/Makefile 2008-12-23 09:24:23 UTC (rev 4879)
@@ -2,7 +2,7 @@
# E_PATH not given (env variable)
ifeq ($(wildcard $(E_PATH)),)
-E_PATH_TMP=~/openmoko/e17
+E_PATH_TMP=~/openmoko/e
ifneq ($(wildcard $(E_PATH_TMP)),)
E_PATH = $(E_PATH_TMP)
endif
Modified: trunk/src/host/pye17/codegen/argtypes.py
===================================================================
--- trunk/src/host/pye17/codegen/argtypes.py 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/codegen/argtypes.py 2008-12-23 09:24:23 UTC (rev 4879)
@@ -76,7 +76,7 @@
self.kwlist.append('"%s"' % kw)
class ArgType:
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
"""Add code to the WrapperInfo instance to handle
parameter."""
raise RuntimeError, "write_param not implemented for %s" % \
@@ -94,7 +94,7 @@
' return Py_None;')
class StringArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt != None:
if pdflt != 'NULL': pdflt = '"' + pdflt + '"'
info.varlist.add('char', '*' + pname + ' = ' + pdflt)
@@ -124,7 +124,7 @@
' return Py_None;')
class StringPtrArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt != None:
if pdflt != 'NULL': pdflt = '"' + pdflt + '"'
info.varlist.add('char', '**' + pname + ' = ' + pdflt)
@@ -155,7 +155,7 @@
class UCharArg(ArgType):
# allows strings with embedded NULLs.
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('guchar', '*' + pname + ' = "' + pdflt + '"')
else:
@@ -173,7 +173,7 @@
[pname])
class CharArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('char', pname + " = '" + pdflt + "'")
else:
@@ -192,7 +192,7 @@
'#endif\n'
' py_ret = (Py_UNICODE)ret;\n'
' return PyUnicode_FromUnicode(&py_ret, 1);\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('gunichar', pname + " = '" + pdflt + "'")
else:
@@ -206,7 +206,7 @@
class IntArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('int', pname + ' = ' + pdflt)
else:
@@ -236,7 +236,7 @@
' PyErr_SetString(PyExc_TypeError, "Parameter \'%(name)s\' must be an int or a long");\n'
' if (PyErr_Occurred())\n'
' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if not pdflt:
pdflt = '0';
@@ -259,7 +259,7 @@
else:
llp64 = False
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add(ptype, pname + ' = ' + pdflt)
else:
@@ -283,7 +283,7 @@
else:
llp64 = False
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add(ptype, pname + ' = ' + pdflt)
else:
@@ -301,7 +301,7 @@
info.codeafter.append(' return PyLong_FromLong(ret);\n')
class LongArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add(ptype, pname + ' = ' + pdflt)
else:
@@ -318,7 +318,7 @@
info.codeafter.append(' return PyBool_FromLong(ret);\n')
class TimeTArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('time_t', pname + ' = ' + pdflt)
else:
@@ -330,7 +330,7 @@
info.codeafter.append(' return PyInt_FromLong(ret);')
class ULongArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('unsigned long', pname + ' = ' + pdflt)
else:
@@ -342,7 +342,7 @@
info.codeafter.append(' return PyLong_FromUnsignedLong(ret);\n')
class UInt32Arg(ULongArg):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
ULongArg.write_param(self, ptype, pname, pdflt, pnull, info)
## if sizeof(unsigned long) > sizeof(unsigned int), we need to
## check the value is within guint32 range
@@ -356,7 +356,7 @@
' }\n') % vars())
class Int64Arg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('gint64', pname + ' = ' + pdflt)
else:
@@ -371,7 +371,7 @@
dflt = ' if (py_%(name)s)\n' \
' %(name)s = PyLong_AsUnsignedLongLong(py_%(name)s);\n'
before = ' %(name)s = PyLong_AsUnsignedLongLong(py_%(name)s);\n'
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('guint64', pname + ' = ' + pdflt)
info.codebefore.append(self.dflt % {'name':pname})
@@ -387,7 +387,7 @@
class DoubleArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('double', pname + ' = ' + pdflt)
else:
@@ -415,7 +415,7 @@
' }\n')
dflt = (' if (py_%(name)s)\n'
' %(name)s = PyFile_AsFile(py_%(name)s);\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pnull:
if pdflt:
info.varlist.add('FILE', '*' + pname + ' = ' + pdflt)
@@ -450,7 +450,7 @@
def __init__(self, enumname, typecode):
self.enumname = enumname
self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add(self.enumname, pname + ' = ' + pdflt)
else:
@@ -470,7 +470,7 @@
def __init__(self, flagname, typecode):
self.flagname = flagname
self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add(self.flagname, pname + ' = ' + pdflt)
default = "py_%s && " % (pname,)
@@ -510,7 +510,7 @@
self.objname = objname
self.cast = string.replace(typecode, '_TYPE_', '_', 1)
self.parent = parent
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pnull:
if pdflt:
info.varlist.add(self.objname, '*' + pname + ' = ' + pdflt)
@@ -590,7 +590,7 @@
def __init__(self, ptype, typecode):
self.typename = ptype
self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pnull:
info.varlist.add(self.typename, '*' + pname + ' = NULL')
info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
@@ -645,7 +645,7 @@
self.getter = getter
self.checker = 'Py' + ptype + '_Check'
self.new = new
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pnull:
info.varlist.add(ptype[:-1], '*' + pname + ' = NULL')
info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
@@ -680,16 +680,30 @@
' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n'
' return NULL;\n'
' }\n')
+ cb = (' if (!PyCallable_Check(py_%(name)s)) {\n'
+ ' PyErr_SetString(PyExc_TypeError, "parameter must be callable");\n'
+ ' return NULL;\n'
+ ' }\n\n'
+ ' /* Py_XINCREF & Py_XDECREF are NULL safe */\n'
+ ' Py_XINCREF(py_%(name)s); /* Add a reference to new callback */\n'
+ ' Py_XDECREF(%(cb_name)s_obj); /* Dispose of previous callback */\n'
+ ' %(cb_name)s_obj = py_%(name)s; /* Remember new callback */\n')
def __init__(self, ptype, typecode):
self.typename = ptype
self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if self.typename == "unsigned-int":
local_typename = "unsigned int"
else:
local_typename = self.typename
- if pnull:
+ if piscb:
+ info.varlist.add(local_typename, '*' + pname + ' = NULL')
+ info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
+ info.codebefore.append(self.cb % {'name': pname,
+ 'cb_name': info.function_c_name})
+
+ elif pnull:
info.varlist.add(local_typename, '*' + pname + ' = NULL')
info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
info.codebefore.append(self.null % {'name': pname,
@@ -722,7 +736,7 @@
atom = (' %(name)s = pygdk_atom_from_pyobject(py_%(name)s);\n'
' if (PyErr_Occurred())\n'
' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pdflt:
info.varlist.add('GdkAtom', pname + ' = ' + pdflt)
info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
@@ -745,7 +759,7 @@
class GTypeArg(ArgType):
gtype = (' if ((%(name)s = pyg_type_from_object(py_%(name)s)) == 0)\n'
' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
info.varlist.add('GType', pname)
info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
info.codebefore.append(self.gtype % {'name': pname})
@@ -759,7 +773,7 @@
class GErrorArg(ArgType):
handleerror = (' if (pyg_error_check(&%(name)s))\n'
' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
info.varlist.add('GError', '*' + pname + ' = NULL')
info.arglist.append('&' + pname)
info.codeafter.append(self.handleerror % { 'name': pname })
@@ -782,7 +796,7 @@
' gtk_tree_path_free(%(name)s);\n')
def __init__(self):
pass
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pnull:
info.varlist.add('GtkTreePath', '*' + pname + ' = NULL')
info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
@@ -823,7 +837,7 @@
' %(name)s = &%(name)s_rect;\n'
' else\n'
' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
if pnull:
info.varlist.add('GdkRectangle', pname + '_rect = { 0, 0, 0, 0 }')
info.varlist.add('GdkRectangle', '*' + pname)
@@ -844,7 +858,7 @@
info.codeafter.append(' return pyg_boxed_new(GDK_TYPE_RECTANGLE, &ret, TRUE, TRUE);')
class PyObjectArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
info.varlist.add('PyObject', '*' + pname)
info.add_parselist('O', ['&' + pname], [pname])
info.arglist.append(pname)
@@ -862,7 +876,7 @@
' return ret;')
class CairoArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
+ def write_param(self, ptype, pname, pdflt, pnull, info, piscb):
info.varlist.add('PycairoContext', '*' + pname)
info.add_parselist('O!', ['&PycairoContext_Type', '&' + pname], [pname])
info.arglist.append('%s->ctx' % pname)
@@ -901,9 +915,8 @@
else:
self.register(ptype, FlagsArg(ptype, typecode))
def register_object(self, ptype, parent, typecode):
- #fd = open("/tmp/debug.log","a")
- #fd.write("ptype: " + str(ptype) + ", parent:" + str(parent) + ", typecode: " + str(typecode) + "\n")
- #fd.close()
+ #import sys
+ #sys.stderr.write("ptype: " + str(ptype) + ", parent:" + str(parent) + ", typecode: " + str(typecode) + "\n")
oa = ObjectArg(ptype, parent, typecode)
self.register(ptype, oa) # in case I forget the * in the .defs
self.register(ptype+'*', oa)
Modified: trunk/src/host/pye17/codegen/codegen.py
===================================================================
--- trunk/src/host/pye17/codegen/codegen.py 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/codegen/codegen.py 2008-12-23 09:24:23 UTC (rev 4879)
@@ -204,6 +204,16 @@
'}\n\n'
)
+ cb_function_tmpl = (
+ 'static PyObject *%(cb_name)s_obj = NULL;\n\n'
+ 'void %(c_name)s_cb(void)\n'
+ '{\n'
+ ' PyObject *arglist = NULL;\n\n'
+ ' if (%(cb_name)s_obj != NULL)\n'
+ ' PyEval_CallObject(%(cb_name)s_obj, arglist);\n'
+ '}\n\n'
+ )
+
virtual_accessor_tmpl = (
'static PyObject *\n'
'_wrap_%(cname)s(PyObject *cls%(extraparams)s)\n'
@@ -277,9 +287,10 @@
# Maybe this could be done in a nicer way, but I'll leave it as it is
# for now: -- Johan
- if not self.overrides.slot_is_overriden('%s.tp_init' %
- self.objinfo.c_name):
- substdict['tp_init'] = self.write_constructor()
+ if not self.overrides.slot_is_overriden('%s.tp_init' % self.objinfo.c_name):
+ #import sys
+ #sys.stderr.write("tp_init: " + str(self.objinfo.c_name) + "\n")
+ substdict['tp_init'] = self.write_constructor()
substdict['tp_methods'] = self.write_methods()
substdict['tp_getset'] = self.write_getsets()
@@ -302,7 +313,7 @@
self.write_virtuals()
- def write_function_wrapper(self, function_obj, template,
+ def write_function_wrapper(self, function_obj, template, cb_template,
handle_return=0, is_method=0, kwargs_needed=0,
substdict=None):
'''This function is the guts of all functions that generate
@@ -310,6 +321,8 @@
if not substdict: substdict = {}
info = argtypes.WrapperInfo()
+ info.function_c_name = function_obj.c_name
+ info.piscb = 0
substdict.setdefault('errorreturn', 'NULL')
@@ -328,9 +341,11 @@
if param.pdflt != None and '|' not in info.parsestr:
info.add_parselist('|', [], [])
handler = argtypes.matcher.get(param.ptype)
+ if param.piscb:
+ info.piscb += 1
#fd.write("pname: " + param.pname + "; ptype: " + str(param.ptype) + "; pdflt: " + str(param.pdflt) + "; pnull: " + str(param.pnull) + "; handler: " + str(handler) + "\n")
handler.write_param(param.ptype, param.pname, param.pdflt,
- param.pnull, info)
+ param.pnull, info, param.piscb)
#fd.write("arglist 2: " + str(info.get_arglist()) + "\n")
@@ -367,7 +382,19 @@
substdict['varlist'] = info.get_varlist()
substdict['typecodes'] = info.parsestr
substdict['parselist'] = info.get_parselist()
+
substdict['arglist'] = info.get_arglist()
+
+ substdict['cb_code'] = ""
+
+ # TODO: deal with more arguments
+ if info.piscb > 0:
+ substdict['arglist'] = ", &" + function_obj.c_name + "_cb"
+ substdict['cb_code'] = cb_template % {'c_name': function_obj.c_name,
+ 'cb_name': function_obj.c_name}
+ template = substdict['cb_code'] + template
+ sys.stderr.write("cb_code: %s\n" % substdict['cb_code'])
+
substdict['codebefore'] = deprecated + (
string.replace(info.get_codebefore(),
'return NULL', 'return ' + substdict['errorreturn'])
@@ -389,19 +416,26 @@
substdict['extraparams'] = ''
flags = 'METH_NOARGS'
- #fd.write("arglist: " + str(info.get_arglist()) + "\n")
#for key,item in substdict.iteritems():
- # fd.write("key: " + str(key) + ", item: " + str(item) + "\n")
- #fd.close()
+ #sys.stderr.write("key: " + str(key) + ", item: " + str(item) + "\n")
+ if info.piscb > 0:
+ sys.stderr.write("template: %s\n" % (template % substdict))
+ #sys.stderr.write("cb_code (again): %s\n" % substdict['cb_code'])
+ #substdict['callback_code'] = 'balbla'
+ #for key,item in substdict.iteritems():
+ #sys.stderr.write("key: " + str(key) + ", item: " + str(item) + "\n")
return template % substdict, flags
def write_constructor(self):
initfunc = '0'
+ #import sys
+ #sys.stderr.write("searching constructor ...\n")
constructor = self.parser.find_constructor(self.objinfo,self.overrides)
if not constructor:
return self.write_default_constructor()
+ #sys.stderr.write("constructor: " + str(constructor.c_name) + "\n")
funcname = constructor.c_name
try:
if self.overrides.is_overriden(funcname):
@@ -430,6 +464,7 @@
constructor.c_name + '\n')
# write constructor from template ...
+ #sys.stderr.write("constructor: " + str(funcname) + ", tmpl:" + str(self.constructor_tmpl) + "\n")
code = self.write_function_wrapper(constructor,
self.constructor_tmpl,
handle_return=0, is_method=0, kwargs_needed=1,
@@ -505,8 +540,8 @@
else:
# write constructor from template ...
code, methflags = self.write_function_wrapper(meth,
- self.method_tmpl, handle_return=1, is_method=1,
- substdict=self.get_initial_method_substdict(meth))
+ self.method_tmpl, self.cb_function_tmpl, handle_return=1,
+ is_method=1, substdict=self.get_initial_method_substdict(meth))
self.fp.write(code)
methods.append(self.methdef_tmpl %
{ 'name': fixname(meth.name),
@@ -856,7 +891,7 @@
else:
# write constructor from template ...
code, methflags = self.write_function_wrapper(func,
- self.function_tmpl, handle_return=1, is_method=0)
+ self.function_tmpl, self.cb_function_tmpl, handle_return=1, is_method=0)
self.fp.write(code)
functions.append((func.name, '_wrap_' + funcname,
methflags, func.docstring))
Modified: trunk/src/host/pye17/codegen/definitions.py
===================================================================
--- trunk/src/host/pye17/codegen/definitions.py 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/codegen/definitions.py 2008-12-23 09:24:23 UTC (rev 4879)
@@ -14,12 +14,13 @@
# New Parameter class, wich emulates a tuple for compatibility reasons
class Parameter(object):
- def __init__(self, ptype, pname, pdflt, pnull, pdir=None):
+ def __init__(self, ptype, pname, pdflt, pnull, pdir=None, piscb=0):
self.ptype = ptype
self.pname = pname
self.pdflt = pdflt
self.pnull = pnull
self.pdir = pdir
+ self.piscb = piscb
def __len__(self): return 4
def __getitem__(self, i):
@@ -309,15 +310,19 @@
pdflt = None
pnull = 0
pdir = None
+ piscb = 0
for farg in parg[2:]:
- assert isinstance(farg, tuple)
- if farg[0] == 'default':
- pdflt = farg[1]
- elif farg[0] == 'null-ok':
- pnull = 1
- elif farg[0] == 'direction':
- pdir = farg[1]
- self.params.append(Parameter(ptype, pname, pdflt, pnull, pdir))
+ if farg == 'is_callback':
+ piscb = 1
+ continue
+ assert isinstance(farg, tuple)
+ if farg[0] == 'default':
+ pdflt = farg[1]
+ elif farg[0] == 'null-ok':
+ pnull = 1
+ elif farg[0] == 'direction':
+ pdir = farg[1]
+ self.params.append(Parameter(ptype, pname, pdflt, pnull, pdir, piscb))
elif arg[0] == 'varargs':
self.varargs = arg[1] in ('t', '#t')
elif arg[0] == 'deprecated':
Modified: trunk/src/host/pye17/codegen/h2def.py
===================================================================
--- trunk/src/host/pye17/codegen/h2def.py 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/codegen/h2def.py 2008-12-23 09:24:23 UTC (rev 4879)
@@ -482,11 +482,14 @@
callback = argument.find('(')
if callback > -1:
func_name_end = argument.find(')')
- argument = 'void* callback_' + argument[callback+1:func_name_end].lstrip("* ")
- spaces = string.count(argument, ' ')
- if spaces > 1:
- argument = string.replace(argument, ' ', '-', spaces - 1)
- #print "argument: " + argument + "; num spaces: " + str(spaces)
+ argument = 'void* cb_' + argument[callback+1:func_name_end].lstrip("* ") + ' *is_callback*'
+ else:
+ spaces = string.count(argument, ' ')
+ if spaces > 1:
+ argument = string.replace(argument, ' ', '-', spaces - 1)
+ #print "argument: " + argument + "; num spaces: " + str(spaces)
+
+ #sys.stderr.write('append argument: ' + argument + '\n')
arguments.append(argument)
# look for callback parameters
@@ -552,6 +555,10 @@
l = len(self.prefix) + 1
if mname[:l] == self.prefix and mname[l+1] == '_':
mname = mname[l+1:]
+
+ if mname.find("callback") > -1:
+ mname = mname.replace("callback", "cb")
+
self.fp.write('(define-method ' + mname + '\n')
self.fp.write(' (of-object "' + obj + '")\n')
self.fp.write(' (c-name "' + name + '")\n')
@@ -576,14 +583,20 @@
self.fp.write(' (parameters\n')
for arg in args:
if arg != '...':
- tupleArg = tuple(string.split(arg))
- if len(tupleArg) == 2:
+ tupleArg = tuple(string.split(arg))
+ is_callback = 0
+ if len(tupleArg) == 3 and tupleArg[2] == "*is_callback*":
+ is_callback = 1
+ if len(tupleArg) == 2 or is_callback:
var_type = tupleArg[0]
# some variable types are not supported
#if var_type == "unsigned-int":
#var_type = "guint" # see gtypes.h
#print "var type: " + var_type
- self.fp.write(' \'("%s" "%s")\n' % (var_type, tupleArg[1]))
+ self.fp.write(' \'("%s" "%s"' % (var_type, tupleArg[1]))
+ if is_callback:
+ self.fp.write(' "is_callback"')
+ self.fp.write(')\n')
self.fp.write(' )\n')
if is_varargs:
self.fp.write(' (varargs #t)\n')
Modified: trunk/src/host/pye17/ecore_evas/ecore_evas.override
===================================================================
--- trunk/src/host/pye17/ecore_evas/ecore_evas.override 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/ecore_evas/ecore_evas.override 2008-12-23 09:24:23 UTC (rev 4879)
@@ -86,3 +86,4 @@
return (PyObject *)new_self;
}
+%%
Modified: trunk/src/host/pye17/examples/ecore_evas/simple_window.py
===================================================================
--- trunk/src/host/pye17/examples/ecore_evas/simple_window.py 2008-12-19 05:15:47 UTC (rev 4878)
+++ trunk/src/host/pye17/examples/ecore_evas/simple_window.py 2008-12-23 09:24:23 UTC (rev 4879)
@@ -3,12 +3,17 @@
import ecore
import ecore_evas
+
+def on_resize():
+ print "resizing window"
+
try:
window = ecore_evas.software_x11_16_new(500,500)
except:
window = ecore_evas.software_x11_new(500,500)
window.title_set("TestWindow")
+window.cb_resize_set(on_resize)
window.show()
ecore.ecore_main_loop_begin()
More information about the commitlog
mailing list