DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
-SUBDIRS = ges tests tools common m4 pkgconfig docs bindings
+SUBDIRS = ges tests tools common m4 pkgconfig docs
DIST_SUBDIRS = $(SUBDIRS)
printf "+ check for build tools"
if test ! -z "$NOCHECK"; then echo " skipped"; else echo; fi
-version_check "autoconf" "$AUTOCONF autoconf autoconf-2.54 autoconf-2.53 autoconf-2.52" \
- "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 52 || DIE=1
-version_check "automake" "$AUTOMAKE automake automake-1.11 automake-1.10 automake-1.9 automake-1.7 automake-1.6 automake-1.5" \
- "ftp://ftp.gnu.org/pub/gnu/automake/" 1 7 || DIE=1
+version_check "autoconf" "$AUTOCONF autoconf" \
+ "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 62 || DIE=1
+version_check "automake" "$AUTOMAKE automake automake-1.11" \
+ "ftp://ftp.gnu.org/pub/gnu/automake/" 1 11 || DIE=1
#version_check "autopoint" "autopoint" \
# "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 17 || DIE=1
version_check "libtoolize" "$LIBTOOLIZE libtoolize glibtoolize" \
- "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 5 0 || DIE=1
+ "ftp://ftp.gnu.org/pub/gnu/libtool/" 2 2 6 || DIE=1
version_check "pkg-config" "" \
"http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
die_check $DIE
-autoconf_2_52d_check || DIE=1
aclocal_check || DIE=1
autoheader_check || DIE=1
+++ /dev/null
-SUBDIRS =
-
-if WITH_PYTHON
- SUBDIRS += python
-endif
+++ /dev/null
-SUBDIRS = codegen examples testsuite
-pkgpyexecdir = $(pyexecdir)
-
-# we install everything in pyexecdir; otherwise you end up with a mess for
-# multilib
-pygesdir = $(pkgpyexecdir)
-pyges_PYTHON =
-
-pygesexecdir = $(pkgpyexecdir)
-pygesexec_LTLIBRARIES = ges.la
-
-DEFS = $(srcdir)/ges-types.defs $(srcdir)/ges.defs
-defs_DATA = $(DEFS)
-defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
-OVERRIDES = ges.override
-
-INCLUDES = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
-
-ges_la_CFLAGS = -I$(top_srcdir)\
- $(PYGST_CFLAGS) $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) -Wno-write-strings
-ges_la_LDFLAGS = -export-symbols-regex "^(initges|_PyGObject_API).*" \
- -module -avoid-version $(GST_PLUGIN_LDFLAGS) $(GIO_LDFLAGS)
-ges_la_LIBADD = $(top_builddir)/ges/libges-@GST_MAJORMINOR@.la \
- $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
- $(GST_LIBS) $(PYGST_LIBS) $(LIBM) $(GIO_LIBS)
-ges_la_SOURCES = gesmodule.c
-nodist_ges_la_SOURCES = ges.c
-
-EXTRA_DIST = $(defs_DATA) $(OVERRIDES) arg-types.py
-
-CLEANFILES = ges.c
-
-.defs.c:
- ($(PYTHON) $(srcdir)/codegen/codegen.py \
- --load-types $(srcdir)/arg-types.py \
- --register $(srcdir)/ges-types.defs \
- --override $(srcdir)/$*.override \
- --prefix pyges $<) > gen-$*.c \
- && cp gen-$*.c $*.c \
- && rm -f gen-$*.c
-
+++ /dev/null
-# -*- Mode: Python -*-
-# vi:si:et:sw=4:sts=4:ts=4
-#
-# gst-python
-# Copyright (C) 2002 David I. Lehn
-# 2004 Johan Dahlin
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# Author: David I. Lehn <dlehn@users.sourceforge.net>
-
-from argtypes import UInt64Arg, Int64Arg, PointerArg, ArgMatcher, ArgType, matcher
-from reversewrapper import Parameter, ReturnType, GBoxedParam, GBoxedReturn, IntParam, IntReturn
-
-class XmlNodeArg(ArgType):
- """libxml2 node generator"""
-
- names = {"xobj":"xmlNode",
- "xptr":"xmlNodePtr",
- "xwrap":"libxml_xmlNodePtrWrap"}
-
- parm = (' if(xml == NULL) return NULL;\n'
- ' xobj = PyObject_GetAttrString(xml, "%(xobj)s");\n'
- ' if(!PyObject_IsInstance(py%(name)s, xobj)) {\n'
- ' PyErr_Clear();\n'
- ' PyErr_SetString(PyExc_RuntimeError,"%(name)s is not a %(xobj)s instance");\n'
- ' Py_DECREF(xobj);Py_DECREF(xml);\n'
- ' return NULL;\n'
- ' }\n'
- ' o = PyObject_GetAttrString(py%(name)s, "_o");\n'
- ' %(name)s = PyCObject_AsVoidPtr(o);\n')
- parmp = (' Py_DECREF(o); Py_DECREF(xobj);Py_DECREF(xml);\n')
-
- ret = (' if(xml == NULL) return NULL;\n')
- retp = (' xargs = PyTuple_New(1);\n'
- ' xobj = PyObject_GetAttrString(xml, "%(xobj)s");\n'
- ' o = %(xwrap)s(ret);\n'
- ' PyTuple_SetItem(xargs, 0, o);\n'
- ' return PyInstance_New(xobj, xargs, PyDict_New());\n')
-
- def write_param(self, ptype, pname, pdflt, pnull, info):
- info.varlist.add('PyObject', '*xml = _gst_get_libxml2_module()')
- info.varlist.add('PyObject', '*o')
- info.varlist.add('PyObject', '*xobj')
- info.varlist.add('PyObject', '*py' + pname)
- info.varlist.add(self.names["xptr"], pname)
- #if pnull:
- info.add_parselist('O', ['&py'+pname], [pname])
- info.arglist.append(pname)
- self.names["name"] = pname
- info.codebefore.append(self.parm % self.names)
- info.codeafter.append(self.parmp % self.names);
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('PyObject', '*xml = _gst_get_libxml2_module()')
- info.varlist.add('PyObject', '*xargs')
- info.varlist.add('PyObject', '*xobj')
- info.varlist.add('PyObject', '*o')
- info.varlist.add(self.names["xptr"], 'ret')
- info.codebefore.append(self.ret % self.names)
- info.codeafter.append(self.retp % self.names)
-
-class XmlDocArg(XmlNodeArg):
- """libxml2 doc generator"""
- names = {"xobj":"xmlDoc",
- "xptr":"xmlDocPtr",
- "xwrap":"libxml_xmlDocPtrWrap"}
-
-class GstCapsArg(ArgType):
- """GstCaps node generator"""
-
- before = (' %(name)s = pygst_caps_from_pyobject (py_%(name)s, %(namecopy)s);\n'
- ' if (PyErr_Occurred())\n'
- ' return NULL;\n')
- beforenull = (' if (py_%(name)s == Py_None || py_%(name)s == NULL)\n'
- ' %(name)s = NULL;\n'
- ' else\n'
- ' ' + before)
- after = (' if (%(name)s && %(name)s_is_copy)\n'
- ' gst_caps_unref (%(name)s);\n')
-
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if ptype == 'const-GstCaps*':
- self.write_const_param(pname, pdflt, pnull, info)
- elif ptype == 'GstCaps*':
- self.write_normal_param(pname, pdflt, pnull, info)
- else:
- raise RuntimeError, "write_param not implemented for %s" % ptype
-
- def write_const_param(self, pname, pdflt, pnull, info):
- if pdflt:
- assert pdflt == 'NULL'
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- else:
- info.varlist.add('PyObject', '*py_' + pname)
- info.varlist.add('GstCaps', '*'+pname)
- info.varlist.add('gboolean', pname+'_is_copy')
- info.add_parselist('O', ['&py_'+pname], [pname])
- info.arglist.append(pname)
- if pnull:
- info.codebefore.append (self.beforenull % { 'name' : pname, 'namecopy' : '&'+pname+'_is_copy' })
- else:
- info.codebefore.append (self.before % { 'name' : pname, 'namecopy' : '&'+pname+'_is_copy' })
- info.codeafter.append (self.after % { 'name' : pname, 'namecopy' : '&'+pname+'_is_copy' })
-
- def write_normal_param(self, pname, pdflt, pnull, info):
- if pdflt:
- assert pdflt == 'NULL'
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- else:
- info.varlist.add('PyObject', '*py_' + pname)
- info.varlist.add('GstCaps', '*'+pname)
- info.add_parselist('O', ['&py_'+pname], [pname])
- info.arglist.append(pname)
- if pnull:
- info.codebefore.append (self.beforenull % { 'name' : pname, 'namecopy' : 'NULL' })
- else:
- info.codebefore.append (self.before % { 'name' : pname, 'namecopy' : 'NULL' })
-
- def write_return(self, ptype, ownsreturn, info):
- if ptype == 'GstCaps*':
- info.varlist.add('GstCaps', '*ret')
- copyval = 'FALSE'
- elif ptype == 'const-GstCaps*':
- info.varlist.add('const GstCaps', '*ret')
- copyval = 'TRUE'
- else:
- raise RuntimeError, "write_return not implemented for %s" % ptype
- info.codeafter.append(' return pyg_boxed_new (GST_TYPE_CAPS, (GstCaps*) ret, '+copyval+', TRUE);')
-
-class GstIteratorArg(ArgType):
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('GstIterator', '*ret')
- info.codeafter.append(' return pygst_iterator_new(ret);')
-
-class GstMiniObjectArg(ArgType):
-
- before = (' %(name)s = %(macro)s(pygstminiobject_get (py_%(name)s));\n'
- ' if (PyErr_Occurred())\n'
- ' return NULL;\n')
-
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- assert pdflt == 'NULL'
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- else:
- info.varlist.add('PyObject', '*py_' + pname)
-
- #Converts 'GstBuffer*' to 'GstBuffer'
- #and const-GstBuffer* to 'const GstBuffer'
- info.varlist.add(ptype.replace('-',' ').replace('*',''), '*'+pname)
-
- if ptype in ['GstBuffer*', 'const-GstBuffer*']:
- info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_BUFFER' })
-
- elif ptype in ['GstEncodingProfile*', 'const-GstEncodingProfile*']:
- info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_ENCODING_PROFILE' })
-
- elif ptype in ['GstMessage*', 'const-GstMessage*']:
- info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_MESSAGE' })
-
- elif ptype in ['GstEvent*', 'const-GstEvent*']:
- info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_EVENT' })
-
- elif ptype in ['GstQuery*', 'const-GstQuery*']:
- info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_QUERY' })
-
- else:
- raise RuntimeError, "write_param not implemented for %s" % ptype
-
- info.add_parselist('O', ['&py_'+pname], [pname])
- info.arglist.append(pname)
-
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype, 'ret')
- info.codeafter.append(' return pygstminiobject_new((GstMiniObject *) ret);')
-
-class GstMiniObjectParam(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'GstMiniObject *')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
- self.wrapper.write_code(code=("if (%s) {\n"
- " py_%s = pygstminiobject_new((GstMiniObject *) %s);\n"
- " gst_mini_object_unref ((GstMiniObject *) %s);\n"
- "} else {\n"
- " Py_INCREF(Py_None);\n"
- " py_%s = Py_None;\n"
- "}"
- % (self.name, self.name, self.name, self.name, self.name)),
- cleanup=("gst_mini_object_ref ((GstMiniObject *) %s); Py_DECREF(py_%s);" % (self.name, self.name)))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-matcher.register_reverse('GstMiniObject*', GstMiniObjectParam)
-
-class GstMiniObjectReturn(ReturnType):
-
- def get_c_type(self):
- return self.props.get('c_type', 'GstMiniObject *')
-
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
-
- def write_error_return(self):
- self.wrapper.write_code("return NULL;")
-
- def write_conversion(self):
- self.wrapper.write_code("retval = (%s) pygstminiobject_get(py_retval);"
- % self.get_c_type())
- self.wrapper.write_code("gst_mini_object_ref((GstMiniObject *) retval);")
-
-matcher.register_reverse_ret('GstMiniObject*', GstMiniObjectReturn)
-
-class GstCapsParam(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'GstCaps *')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
- self.wrapper.write_code(code=("if (%s)\n"
- " py_%s = pyg_boxed_new (GST_TYPE_CAPS, %s, FALSE, TRUE);\n"
- "else {\n"
- " Py_INCREF(Py_None);\n"
- " py_%s = Py_None;\n"
- "}"
- % (self.name, self.name, self.name, self.name)),
- cleanup=("gst_caps_ref(%s);\nPy_DECREF(py_%s);" % (self.name, self.name)))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-matcher.register_reverse('GstCaps*', GstCapsParam)
-
-class GstCapsReturn(ReturnType):
-
- def get_c_type(self):
- return self.props.get('c_type', 'GstCaps *')
-
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
-
- def write_error_return(self):
- self.wrapper.write_code("return NULL;")
-
- def write_conversion(self):
- self.wrapper.write_code("retval = (%s) pygst_caps_from_pyobject (py_retval, NULL);"
- % self.get_c_type())
-## self.wrapper.write_code("gst_mini_object_ref((GstMiniObject *) retval);")
-
-matcher.register_reverse_ret('GstCaps*', GstCapsReturn)
-
-
-class Int64Param(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'gint64')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = PyLong_FromLongLong(%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-class Int64Return(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type', 'gint64')
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- def write_error_return(self):
- self.wrapper.write_code("return -G_MAXINT;")
- def write_conversion(self):
- self.wrapper.write_code(
- code=None,
- failure_expression="!PyLong_Check(py_retval)",
- failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");')
- self.wrapper.write_code("retval = PyLong_AsLongLong(py_retval);")
-
-class UInt64Param(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'guint64')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = PyLong_FromUnsignedLongLong(%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-class UInt64Return(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type', 'guint64')
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- def write_error_return(self):
- self.wrapper.write_code("return -G_MAXINT;")
- def write_conversion(self):
- self.wrapper.write_code(
- code=None,
- failure_expression="!PyLong_Check(py_retval)",
- failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");')
- self.wrapper.write_code("retval = PyLong_AsUnsignedLongLongMask(py_retval);")
-
-class ULongParam(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'gulong')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = PyLong_FromUnsignedLong(%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-class ULongReturn(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type', 'gulong')
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- def write_error_return(self):
- self.wrapper.write_code("return -G_MAXINT;")
- def write_conversion(self):
- self.wrapper.write_code(
- code=None,
- failure_expression="!PyLong_Check(py_retval)",
- failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");')
- self.wrapper.write_code("retval = PyLong_AsUnsignedLongMask(py_retval);")
-
-class ConstStringReturn(ReturnType):
-
- def get_c_type(self):
- return "const gchar *"
-
- def write_decl(self):
- self.wrapper.add_declaration("const gchar *retval;")
-
- def write_error_return(self):
- self.wrapper.write_code("return NULL;")
-
- def write_conversion(self):
- self.wrapper.write_code(
- code=None,
- failure_expression="!PyString_Check(py_retval)",
- failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be a string");')
- self.wrapper.write_code("retval = g_strdup(PyString_AsString(py_retval));")
-
-class StringArrayArg(ArgType):
- """Arg type for NULL-terminated string pointer arrays (GStrv, aka gchar**)."""
- def write_return(self, ptype, ownsreturn, info):
- if ownsreturn:
- raise NotImplementedError ()
- else:
- info.varlist.add("gchar", "**ret")
- info.codeafter.append(" if (ret) {\n"
- " guint size = g_strv_length(ret);\n"
- " PyObject *py_ret = PyTuple_New(size);\n"
- " gint i;\n"
- " for (i = 0; i < size; i++)\n"
- " PyTuple_SetItem(py_ret, i,\n"
- " PyString_FromString(ret[i]));\n"
- " return py_ret;\n"
- " }\n"
- " return PyTuple_New (0);\n")
-
-
-matcher.register('GstClockTime', UInt64Arg())
-matcher.register('GstElementFactoryListType', UInt64Arg())
-matcher.register('GstClockTimeDiff', Int64Arg())
-matcher.register('xmlNodePtr', XmlNodeArg())
-matcher.register('xmlDocPtr', XmlDocArg())
-matcher.register('GstCaps', GstCapsArg()) #FIXME: does this work?
-matcher.register('GstCaps*', GstCapsArg()) #FIXME: does this work?
-matcher.register('const-GstCaps*', GstCapsArg())
-matcher.register('GstIterator*', GstIteratorArg())
-
-arg = PointerArg('gpointer', 'G_TYPE_POINTER')
-matcher.register('GstClockID', arg)
-
-for typename in ["GstPlugin", "GstStructure", "GstTagList", "GError", "GstDate", "GstSegment"]:
- matcher.register_reverse(typename, GBoxedParam)
- matcher.register_reverse_ret(typename, GBoxedReturn)
-
-for typename in ["GstEncodingProfile*", "cons-GstEncodingProfile", "GstBuffer*", "const-GstBuffer*", "GstEvent*", "const-GstEvent*", "GstMessage*", "const-GstMessage*", "GstQuery*", "const-GstQuery*"]:
- matcher.register(typename, GstMiniObjectArg())
- matcher.register_reverse(typename, GstMiniObjectParam)
- matcher.register_reverse_ret(typename, GstMiniObjectReturn)
-
-for typename in ["gint64", "GstClockTimeDiff"]:
- matcher.register_reverse(typename, Int64Param)
- matcher.register_reverse_ret(typename, Int64Return)
-
-for typename in ["guint64", "GstClockTime", "GstElementFactoryListType"]:
- matcher.register_reverse(typename, UInt64Param)
- matcher.register_reverse_ret(typename, UInt64Return)
-
-matcher.register_reverse_ret("const-gchar*", ConstStringReturn)
-
-matcher.register_reverse("GType", IntParam)
-matcher.register_reverse_ret("GType", IntReturn)
-
-matcher.register_reverse("gulong", ULongParam)
-matcher.register_reverse_ret("gulong", ULongReturn)
-
-matcher.register("GStrv", StringArrayArg())
-
-del arg
+++ /dev/null
-EXTRA_DIST = \
- argtypes.py \
- code-coverage.py \
- codegen.py \
- definitions.py \
- defsparser.py \
- docextract.py \
- docgen.py \
- h2def.py \
- __init__.py \
- mergedefs.py \
- mkskel.py \
- override.py \
- reversewrapper.py \
- scmexpr.py
+++ /dev/null
-# -*- Mode: Python; py-indent-offset: 4 -*-
-
-__all__ = [
- 'argtypes',
- 'codegen',
- 'definitions',
- 'defsparser',
- 'docextract',
- 'docgen',
- 'h2def',
- 'defsgen'
- 'mergedefs',
- 'mkskel',
- 'override',
- 'scmexpr'
-]
+++ /dev/null
-# -*- Mode: Python; py-indent-offset: 4 -*-
-import string
-import keyword
-import struct
-
-py_ssize_t_clean = False
-
-class ArgTypeError(Exception):
- pass
-
-class ArgTypeNotFoundError(ArgTypeError):
- pass
-
-class ArgTypeConfigurationError(ArgTypeError):
- pass
-
-
-class VarList:
- """Nicely format a C variable list"""
- def __init__(self):
- self.vars = {}
- def add(self, ctype, name):
- if self.vars.has_key(ctype):
- self.vars[ctype] = self.vars[ctype] + (name,)
- else:
- self.vars[ctype] = (name,)
- def __str__(self):
- ret = []
- for type in self.vars.keys():
- ret.append(' ')
- ret.append(type)
- ret.append(' ')
- ret.append(string.join(self.vars[type], ', '))
- ret.append(';\n')
- if ret:
- ret.append('\n')
- return string.join(ret, '')
- return ''
-
-class WrapperInfo:
- """A class that holds information about variable defs, code
- snippets, etcd for use in writing out the function/method
- wrapper."""
- def __init__(self):
- self.varlist = VarList()
- self.parsestr = ''
- self.parselist = ['', 'kwlist']
- self.codebefore = []
- self.codeafter = []
- self.arglist = []
- self.kwlist = []
- def get_parselist(self):
- return string.join(self.parselist, ', ')
- def get_codebefore(self):
- return string.join(self.codebefore, '')
- def get_codeafter(self):
- return string.join(self.codeafter, '')
- def get_arglist(self):
- return string.join(self.arglist, ', ')
- def get_varlist(self):
- return str(self.varlist)
- def get_kwlist(self):
- ret = ' static char *kwlist[] = { %s };\n' % \
- string.join(self.kwlist + [ 'NULL' ], ', ')
- if not self.get_varlist():
- ret = ret + '\n'
- return ret
-
- def add_parselist(self, codes, parseargs, keywords):
- self.parsestr = self.parsestr + codes
- for arg in parseargs:
- self.parselist.append(arg)
- for kw in keywords:
- if keyword.iskeyword(kw):
- kw = kw + '_'
- self.kwlist.append('"%s"' % kw)
-
-class ArgType:
- def write_param(self, ptype, pname, pdflt, pnull, info):
- """Add code to the WrapperInfo instance to handle
- parameter."""
- raise RuntimeError("write_param not implemented for %s"
- % self.__class__.__name__)
- def write_return(self, ptype, ownsreturn, info):
- """Adds a variable named ret of the return type to
- info.varlist, and add any required code to info.codeafter to
- convert the return value to a python object."""
- raise RuntimeError("write_return not implemented for %s"
- % self.__class__.__name__)
-
-class NoneArg(ArgType):
- def write_return(self, ptype, ownsreturn, info):
- info.codeafter.append(' Py_INCREF(Py_None);\n' +
- ' return Py_None;')
-
-class StringArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt != None:
- if pdflt != 'NULL': pdflt = '"' + pdflt + '"'
- info.varlist.add('char', '*' + pname + ' = ' + pdflt)
- else:
- info.varlist.add('char', '*' + pname)
- info.arglist.append(pname)
- if pnull:
- info.add_parselist('z', ['&' + pname], [pname])
- else:
- info.add_parselist('s', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- if ownsreturn:
- # have to free result ...
- info.varlist.add('gchar', '*ret')
- info.codeafter.append(' if (ret) {\n' +
- ' PyObject *py_ret = PyString_FromString(ret);\n' +
- ' g_free(ret);\n' +
- ' return py_ret;\n' +
- ' }\n' +
- ' Py_INCREF(Py_None);\n' +
- ' return Py_None;')
- else:
- info.varlist.add('const gchar', '*ret')
- info.codeafter.append(' if (ret)\n' +
- ' return PyString_FromString(ret);\n'+
- ' Py_INCREF(Py_None);\n' +
- ' return Py_None;')
-
-class UCharArg(ArgType):
- # allows strings with embedded NULLs.
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('guchar', '*' + pname + ' = "' + pdflt + '"')
- else:
- info.varlist.add('guchar', '*' + pname)
- if py_ssize_t_clean:
- info.varlist.add('Py_ssize_t', pname + '_len')
- else:
- info.varlist.add('int', pname + '_len')
- info.arglist.append(pname)
- if pnull:
- info.add_parselist('z#', ['&' + pname, '&' + pname + '_len'],
- [pname])
- else:
- info.add_parselist('s#', ['&' + pname, '&' + pname + '_len'],
- [pname])
-
-class CharArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('char', pname + " = '" + pdflt + "'")
- else:
- info.varlist.add('char', pname)
- info.arglist.append(pname)
- info.add_parselist('c', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('gchar', 'ret')
- info.codeafter.append(' return PyString_FromStringAndSize(&ret, 1);')
-class GUniCharArg(ArgType):
- ret_tmpl = ('#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2\n'
- ' if (ret > 0xffff) {\n'
- ' PyErr_SetString(PyExc_RuntimeError, "returned character can not be represented in 16-bit unicode");\n'
- ' return NULL;\n'
- ' }\n'
- '#endif\n'
- ' py_ret = (Py_UNICODE)ret;\n'
- ' return PyUnicode_FromUnicode(&py_ret, 1);\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('gunichar', pname + " = '" + pdflt + "'")
- else:
- info.varlist.add('gunichar', pname)
- info.arglist.append(pname)
- info.add_parselist('O&', ['pyg_pyobj_to_unichar_conv', '&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('gunichar', 'ret')
- info.varlist.add('Py_UNICODE', 'py_ret')
- info.codeafter.append(self.ret_tmpl)
-
-
-class IntArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('int', pname + ' = ' + pdflt)
- else:
- info.varlist.add('int', pname)
- info.arglist.append(pname)
- info.add_parselist('i', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('int', 'ret')
- info.codeafter.append(' return PyInt_FromLong(ret);')
-
-class UIntArg(ArgType):
- dflt = (' if (py_%(name)s) {\n'
- ' if (PyLong_Check(py_%(name)s))\n'
- ' %(name)s = PyLong_AsUnsignedLong(py_%(name)s);\n'
- ' else if (PyInt_Check(py_%(name)s))\n'
- ' %(name)s = PyInt_AsLong(py_%(name)s);\n'
- ' else\n'
- ' PyErr_SetString(PyExc_TypeError, "Parameter \'%(name)s\' must be an int or a long");\n'
- ' if (PyErr_Occurred())\n'
- ' return NULL;\n'
- ' }\n')
- before = (' if (PyLong_Check(py_%(name)s))\n'
- ' %(name)s = PyLong_AsUnsignedLong(py_%(name)s);\n'
- ' else if (PyInt_Check(py_%(name)s))\n'
- ' %(name)s = PyInt_AsLong(py_%(name)s);\n'
- ' else\n'
- ' 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):
- if not pdflt:
- pdflt = '0';
-
- info.varlist.add(ptype, pname + ' = ' + pdflt)
- info.codebefore.append(self.dflt % {'name':pname})
- info.varlist.add('PyObject', "*py_" + pname + ' = NULL')
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype, 'ret')
- info.codeafter.append(' return PyLong_FromUnsignedLong(ret);')
-
-class SizeArg(ArgType):
-
- if struct.calcsize('P') <= struct.calcsize('l'):
- llp64 = True
- else:
- llp64 = False
-
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add(ptype, pname + ' = ' + pdflt)
- else:
- info.varlist.add(ptype, pname)
- info.arglist.append(pname)
- if self.llp64:
- info.add_parselist('k', ['&' + pname], [pname])
- else:
- info.add_parselist('K', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype, 'ret')
- if self.llp64:
- info.codeafter.append(' return PyLong_FromUnsignedLongLong(ret);\n')
- else:
- info.codeafter.append(' return PyLong_FromUnsignedLong(ret);\n')
-
-class SSizeArg(ArgType):
-
- if struct.calcsize('P') <= struct.calcsize('l'):
- llp64 = True
- else:
- llp64 = False
-
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add(ptype, pname + ' = ' + pdflt)
- else:
- info.varlist.add(ptype, pname)
- info.arglist.append(pname)
- if self.llp64:
- info.add_parselist('l', ['&' + pname], [pname])
- else:
- info.add_parselist('L', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype, 'ret')
- if self.llp64:
- info.codeafter.append(' return PyLong_FromLongLong(ret);\n')
- else:
- info.codeafter.append(' return PyLong_FromLong(ret);\n')
-
-class LongArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add(ptype, pname + ' = ' + pdflt)
- else:
- info.varlist.add(ptype, pname)
- info.arglist.append(pname)
- info.add_parselist('l', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype, 'ret')
- info.codeafter.append(' return PyInt_FromLong(ret);\n')
-
-class BoolArg(IntArg):
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('int', 'ret')
- info.codeafter.append(' return PyBool_FromLong(ret);\n')
-
-class TimeTArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('time_t', pname + ' = ' + pdflt)
- else:
- info.varlist.add('time_t', pname)
- info.arglist.append(pname)
- info.add_parselist('i', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('time_t', 'ret')
- info.codeafter.append(' return PyInt_FromLong(ret);')
-
-class ULongArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('unsigned long', pname + ' = ' + pdflt)
- else:
- info.varlist.add('unsigned long', pname)
- info.arglist.append(pname)
- info.add_parselist('k', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype, 'ret')
- info.codeafter.append(' return PyLong_FromUnsignedLong(ret);\n')
-
-class UInt32Arg(ULongArg):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- 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
- if struct.calcsize('L') > struct.calcsize('I'):
- info.codebefore.append((
- ' if (%(pname)s > G_MAXUINT32) {\n'
- ' PyErr_SetString(PyExc_ValueError,\n'
- ' "Value out of range in conversion of"\n'
- ' " %(pname)s parameter to unsigned 32 bit integer");\n'
- ' return NULL;\n'
- ' }\n') % vars())
-
-class Int64Arg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('gint64', pname + ' = ' + pdflt)
- else:
- info.varlist.add('gint64', pname)
- info.arglist.append(pname)
- info.add_parselist('L', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('gint64', 'ret')
- info.codeafter.append(' return PyLong_FromLongLong(ret);')
-
-class UInt64Arg(ArgType):
- 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):
- if pdflt:
- info.varlist.add('guint64', pname + ' = ' + pdflt)
- info.codebefore.append(self.dflt % {'name':pname})
- else:
- info.varlist.add('guint64', pname)
- info.codebefore.append(self.before % {'name':pname})
- info.varlist.add('PyObject', "*py_" + pname + ' = NULL')
- info.arglist.append(pname)
- info.add_parselist('O!', ['&PyLong_Type', '&py_' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('guint64', 'ret')
- info.codeafter.append(' return PyLong_FromUnsignedLongLong(ret);')
-
-
-class DoubleArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add('double', pname + ' = ' + pdflt)
- else:
- info.varlist.add('double', pname)
- info.arglist.append(pname)
- info.add_parselist('d', ['&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('double', 'ret')
- info.codeafter.append(' return PyFloat_FromDouble(ret);')
-
-class FileArg(ArgType):
- nulldflt = (' if (py_%(name)s == Py_None)\n'
- ' %(name)s = NULL;\n'
- ' else if (py_%(name)s && PyFile_Check(py_%(name)s)\n'
- ' %s = PyFile_AsFile(py_%(name)s);\n'
- ' else if (py_%(name)s) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a file object or None");\n'
- ' return NULL;\n'
- ' }')
- null = (' if (py_%(name)s && PyFile_Check(py_%(name)s)\n'
- ' %(name)s = PyFile_AsFile(py_%(name)s);\n'
- ' else if (py_%(name)s != Py_None) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a file object or None");\n'
- ' return NULL;\n'
- ' }\n')
- dflt = (' if (py_%(name)s)\n'
- ' %(name)s = PyFile_AsFile(py_%(name)s);\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- if pdflt:
- info.varlist.add('FILE', '*' + pname + ' = ' + pdflt)
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.nulldflt % {'name':pname})
- else:
- info.varlist.add('FILE', '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname)
- info.codebefore.append(self.null & {'name':pname})
- info.arglist.appned(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- else:
- if pdflt:
- info.varlist.add('FILE', '*' + pname + ' = ' + pdflt)
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.dflt % {'name':pname})
- info.arglist.append(pname)
- else:
- info.varlist.add('PyObject', '*' + pname)
- info.arglist.append('PyFile_AsFile(' + pname + ')')
- info.add_parselist('O!', ['&PyFile_Type', '&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('FILE', '*ret')
- info.codeafter.append(' if (ret)\n' +
- ' return PyFile_FromFile(ret, "", "", fclose);\n' +
- ' Py_INCREF(Py_None);\n' +
- ' return Py_None;')
-
-class EnumArg(ArgType):
- enum = (' if (pyg_enum_get_value(%(typecode)s, py_%(name)s, (gpointer)&%(name)s))\n'
- ' return NULL;\n')
- def __init__(self, enumname, typecode):
- self.enumname = enumname
- self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add(self.enumname, pname + ' = ' + pdflt)
- else:
- info.varlist.add(self.enumname, pname)
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.enum % { 'typecode': self.typecode,
- 'name': pname})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname]);
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('gint', 'ret')
- info.codeafter.append(' return pyg_enum_from_gtype(%s, ret);' % self.typecode)
-
-class FlagsArg(ArgType):
- flag = (' if (%(default)spyg_flags_get_value(%(typecode)s, py_%(name)s, (gpointer)&%(name)s))\n'
- ' return NULL;\n')
- def __init__(self, flagname, typecode):
- self.flagname = flagname
- self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pdflt:
- info.varlist.add(self.flagname, pname + ' = ' + pdflt)
- default = "py_%s && " % (pname,)
- else:
- info.varlist.add(self.flagname, pname)
- default = ""
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.flag % {'default':default,
- 'typecode':self.typecode,
- 'name':pname})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('guint', 'ret')
- info.codeafter.append(' return pyg_flags_from_gtype(%s, ret);' % self.typecode)
-
-class ObjectArg(ArgType):
- # should change these checks to more typesafe versions that check
- # a little further down in the class heirachy.
- nulldflt = (' if ((PyObject *)py_%(name)s == Py_None)\n'
- ' %(name)s = NULL;\n'
- ' else if (py_%(name)s && pygobject_check(py_%(name)s, &Py%(type)s_Type))\n'
- ' %(name)s = %(cast)s(py_%(name)s->obj);\n'
- ' else if (py_%(name)s) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(type)s or None");\n'
- ' return NULL;\n'
- ' }\n')
- null = (' if (py_%(name)s && pygobject_check(py_%(name)s, &Py%(type)s_Type))\n'
- ' %(name)s = %(cast)s(py_%(name)s->obj);\n'
- ' else if ((PyObject *)py_%(name)s != Py_None) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(type)s or None");\n'
- ' return NULL;\n'
- ' }\n')
- dflt = ' if (py_%(name)s)\n' \
- ' %(name)s = %(cast)s(py_%(name)s->obj);\n'
- def __init__(self, objname, parent, typecode):
- self.objname = objname
- self.cast = string.replace(typecode, '_TYPE_', '_', 1)
- self.parent = parent
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- if pdflt:
- info.varlist.add(self.objname, '*' + pname + ' = ' + pdflt)
- info.varlist.add('PyGObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.nulldflt % {'name':pname,
- 'cast':self.cast,
- 'type':self.objname})
- else:
- info.varlist.add(self.objname, '*' + pname + ' = NULL')
- info.varlist.add('PyGObject', '*py_' + pname)
- info.codebefore.append(self.null % {'name':pname,
- 'cast':self.cast,
- 'type':self.objname})
- if ptype.endswith('*'):
- typename = ptype[:-1]
- try:
- const, typename = typename.split('const-')
- except ValueError:
- const = ''
- if typename != ptype:
- info.arglist.append('(%s *) %s' % (ptype[:-1], pname))
- else:
- info.arglist.append(pname)
-
- info.add_parselist('O', ['&py_' + pname], [pname])
- else:
- if pdflt:
- info.varlist.add(self.objname, '*' + pname + ' = ' + pdflt)
- info.varlist.add('PyGObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.dflt % {'name':pname,
- 'cast':self.cast})
- info.arglist.append(pname)
- info.add_parselist('O!', ['&Py%s_Type' % self.objname,
- '&py_' + pname], [pname])
- else:
- info.varlist.add('PyGObject', '*' + pname)
- info.arglist.append('%s(%s->obj)' % (self.cast, pname))
- info.add_parselist('O!', ['&Py%s_Type' % self.objname,
- '&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- if ptype.endswith('*'):
- typename = ptype[:-1]
- try:
- const, typename = typename.split('const-')
- except ValueError:
- const = ''
- info.varlist.add(typename, '*ret')
- if ownsreturn:
- info.varlist.add('PyObject', '*py_ret')
- info.codeafter.append(' py_ret = pygobject_new((GObject *)ret);\n'
- ' if (ret != NULL)\n'
- ' g_object_unref(ret);\n'
- ' return py_ret;')
- else:
- info.codeafter.append(' /* pygobject_new handles NULL checking */\n' +
- ' return pygobject_new((GObject *)ret);')
-
-class BoxedArg(ArgType):
- # haven't done support for default args. Is it needed?
- check = (' if (pyg_boxed_check(py_%(name)s, %(typecode)s))\n'
- ' %(name)s = pyg_boxed_get(py_%(name)s, %(typename)s);\n'
- ' else {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s");\n'
- ' return NULL;\n'
- ' }\n')
- null = (' if (pyg_boxed_check(py_%(name)s, %(typecode)s))\n'
- ' %(name)s = pyg_boxed_get(py_%(name)s, %(typename)s);\n'
- ' else if (py_%(name)s != Py_None) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n'
- ' return NULL;\n'
- ' }\n')
- def __init__(self, ptype, typecode):
- self.typename = ptype
- self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- info.varlist.add(self.typename, '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
- info.codebefore.append(self.null % {'name': pname,
- 'typename': self.typename,
- 'typecode': self.typecode})
- else:
- info.varlist.add(self.typename, '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname)
- info.codebefore.append(self.check % {'name': pname,
- 'typename': self.typename,
- 'typecode': self.typecode})
- if ptype[-1] == '*':
- typename = ptype[:-1]
- if typename[:6] == 'const-': typename = typename[6:]
- if typename != self.typename:
- info.arglist.append('(%s *)%s' % (ptype[:-1], pname))
- else:
- info.arglist.append(pname)
- else:
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- ret_tmpl = ' /* pyg_boxed_new handles NULL checking */\n' \
- ' return pyg_boxed_new(%(typecode)s, %(ret)s, %(copy)s, TRUE);'
- def write_return(self, ptype, ownsreturn, info):
- if ptype[-1] == '*':
- decl_type = self.typename
- ret = 'ret'
- if ptype[:6] == 'const-':
- decl_type = 'const ' + self.typename
- ret = '(%s*) ret' % (self.typename,)
- info.varlist.add(decl_type, '*ret')
- else:
- info.varlist.add(self.typename, 'ret')
- ret = '&ret'
- ownsreturn = 0 # of course it can't own a ref to a local var ...
- info.codeafter.append(self.ret_tmpl %
- { 'typecode': self.typecode,
- 'ret': ret,
- 'copy': ownsreturn and 'FALSE' or 'TRUE'})
-
-class CustomBoxedArg(ArgType):
- # haven't done support for default args. Is it needed?
- null = (' if (%(check)s(py_%(name)s))\n'
- ' %(name)s = %(get)s(py_%(name)s);\n'
- ' else if (py_%(name)s != Py_None) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(type)s or None");\n'
- ' return NULL;\n'
- ' }\n')
- def __init__(self, ptype, pytype, getter, new):
- self.pytype = pytype
- self.getter = getter
- self.checker = 'Py' + ptype + '_Check'
- self.new = new
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- info.varlist.add(ptype[:-1], '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
- info.codebefore.append(self.null % {'name': pname,
- 'get': self.getter,
- 'check': self.checker,
- 'type': ptype[:-1]})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- else:
- info.varlist.add('PyObject', '*' + pname)
- info.arglist.append(self.getter + '(' + pname + ')')
- info.add_parselist('O!', ['&' + self.pytype, '&' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add(ptype[:-1], '*ret')
- info.codeafter.append(' if (ret)\n' +
- ' return ' + self.new + '(ret);\n' +
- ' Py_INCREF(Py_None);\n' +
- ' return Py_None;')
-
-class PointerArg(ArgType):
- # haven't done support for default args. Is it needed?
- check = (' if (pyg_pointer_check(py_%(name)s, %(typecode)s))\n'
- ' %(name)s = pyg_pointer_get(py_%(name)s, %(typename)s);\n'
- ' else {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s");\n'
- ' return NULL;\n'
- ' }\n')
- null = (' if (pyg_pointer_check(py_%(name)s, %(typecode)s))\n'
- ' %(name)s = pyg_pointer_get(py_%(name)s, %(typename)s);\n'
- ' else if (py_%(name)s != Py_None) {\n'
- ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n'
- ' return NULL;\n'
- ' }\n')
- def __init__(self, ptype, typecode):
- self.typename = ptype
- self.typecode = typecode
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- info.varlist.add(self.typename, '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
- info.codebefore.append(self.null % {'name': pname,
- 'typename': self.typename,
- 'typecode': self.typecode})
- else:
- info.varlist.add(self.typename, '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname)
- info.codebefore.append(self.check % {'name': pname,
- 'typename': self.typename,
- 'typecode': self.typecode})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- if ptype[-1] == '*':
- info.varlist.add(self.typename, '*ret')
- info.codeafter.append(' /* pyg_pointer_new handles NULL checking */\n' +
- ' return pyg_pointer_new(' + self.typecode + ', ret);')
- else:
- info.varlist.add(self.typename, 'ret')
- info.codeafter.append(' /* pyg_pointer_new handles NULL checking */\n' +
- ' return pyg_pointer_new(' + self.typecode + ', &ret);')
-
-class AtomArg(IntArg):
- dflt = ' if (py_%(name)s) {\n' \
- ' %(name)s = pygdk_atom_from_pyobject(py_%(name)s);\n' \
- ' if (PyErr_Occurred())\n' \
- ' return NULL;\n' \
- ' }\n'
- 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):
- if pdflt:
- info.varlist.add('GdkAtom', pname + ' = ' + pdflt)
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.dflt % {'name': pname})
- else:
- info.varlist.add('GdkAtom', pname)
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.atom % {'name': pname})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('GdkAtom', 'ret')
- info.varlist.add('PyObject *', 'py_ret')
- info.varlist.add('gchar *', 'name')
- info.codeafter.append(' name = gdk_atom_name(ret);\n'
- ' py_ret = PyString_FromString(name);\n'
- ' g_free(name);\n'
- ' return py_ret;')
-
-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):
- info.varlist.add('GType', pname)
- info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
- info.codebefore.append(self.gtype % {'name': pname})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('GType', 'ret')
- info.codeafter.append(' return pyg_type_wrapper_new(ret);')
-
-# simple GError handler.
-class GErrorArg(ArgType):
- handleerror = (' if (pyg_error_check(&%(name)s))\n'
- ' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
- info.varlist.add('GError', '*' + pname + ' = NULL')
- info.arglist.append('&' + pname)
- info.codeafter.append(self.handleerror % { 'name': pname })
-
-class GtkTreePathArg(ArgType):
- # haven't done support for default args. Is it needed?
- normal = (' %(name)s = pygtk_tree_path_from_pyobject(py_%(name)s);\n'
- ' if (!%(name)s) {\n'
- ' PyErr_SetString(PyExc_TypeError, "could not convert %(name)s to a GtkTreePath");\n'
- ' return NULL;\n'
- ' }\n')
- null = (' if (py_%(name)s != Py_None) {\n'
- ' %(name)s = pygtk_tree_path_from_pyobject(py_%(name)s);\n'
- ' if (!%(name)s) {\n'
- ' PyErr_SetString(PyExc_TypeError, "could not convert %(name)s to a GtkTreePath");\n'
- ' return NULL;\n'
- ' }\n'
- ' }\n')
- freepath = (' if (%(name)s)\n'
- ' gtk_tree_path_free(%(name)s);\n')
- def __init__(self):
- pass
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- info.varlist.add('GtkTreePath', '*' + pname + ' = NULL')
- info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
- info.codebefore.append(self.null % {'name': pname})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- else:
- info.varlist.add('GtkTreePath', '*' + pname)
- info.varlist.add('PyObject', '*py_' + pname)
- info.codebefore.append(self.normal % {'name': pname})
- info.arglist.append(pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- info.codeafter.append(self.freepath % {'name': pname})
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('GtkTreePath', '*ret')
- if ownsreturn:
- info.codeafter.append(' if (ret) {\n'
- ' PyObject *py_ret = pygtk_tree_path_to_pyobject(ret);\n'
- ' gtk_tree_path_free(ret);\n'
- ' return py_ret;\n'
- ' }\n'
- ' Py_INCREF(Py_None);\n'
- ' return Py_None;')
- else:
- info.codeafter.append(' if (ret) {\n'
- ' PyObject *py_ret = pygtk_tree_path_to_pyobject(ret);\n'
- ' return py_ret;\n'
- ' }\n'
- ' Py_INCREF(Py_None);\n'
- ' return Py_None;')
-
-class GdkRectanglePtrArg(ArgType):
- normal = (' if (!pygdk_rectangle_from_pyobject(py_%(name)s, &%(name)s))\n'
- ' return NULL;\n')
- null = (' if (py_%(name)s == Py_None)\n'
- ' %(name)s = NULL;\n'
- ' else if (pygdk_rectangle_from_pyobject(py_%(name)s, &%(name)s_rect))\n'
- ' %(name)s = &%(name)s_rect;\n'
- ' else\n'
- ' return NULL;\n')
- def write_param(self, ptype, pname, pdflt, pnull, info):
- if pnull:
- info.varlist.add('GdkRectangle', pname + '_rect = { 0, 0, 0, 0 }')
- info.varlist.add('GdkRectangle', '*' + pname)
- info.varlist.add('PyObject', '*py_' + pname + ' = Py_None')
- info.add_parselist('O', ['&py_' + pname], [pname])
- info.arglist.append(pname)
- info.codebefore.append(self.null % {'name': pname})
- else:
- info.varlist.add('GdkRectangle', pname + ' = { 0, 0, 0, 0 }')
- info.varlist.add('PyObject', '*py_' + pname)
- info.add_parselist('O', ['&py_' + pname], [pname])
- info.arglist.append('&' + pname)
- info.codebefore.append(self.normal % {'name': pname})
-
-class GdkRectangleArg(ArgType):
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add('GdkRectangle', 'ret')
- 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):
- info.varlist.add('PyObject', '*' + pname)
- info.add_parselist('O', ['&' + pname], [pname])
- info.arglist.append(pname)
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add("PyObject", "*ret")
- if ownsreturn:
- info.codeafter.append(' if (ret) {\n'
- ' return ret;\n'
- ' }\n'
- ' Py_INCREF(Py_None);\n'
- ' return Py_None;')
- else:
- info.codeafter.append(' if (!ret) ret = Py_None;\n'
- ' Py_INCREF(ret);\n'
- ' return ret;')
-
-class CairoArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- info.varlist.add('PycairoContext', '*' + pname)
- info.add_parselist('O!', ['&PycairoContext_Type', '&' + pname], [pname])
- info.arglist.append('%s->ctx' % pname)
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add("cairo_t", "*ret")
- if ownsreturn:
- info.codeafter.append(' return PycairoContext_FromContext(ret, NULL, NULL);')
- else:
- info.codeafter.append(' cairo_reference(ret);\n'
- ' return PycairoContext_FromContext(ret, NULL, NULL);')
-
-class GstElementArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- info.varlist.add('GstElement', '*' + pname)
- info.add_parselist('O!', ['&PyGstElement_Type', '&' + pname], [pname])
- info.arglist.append('%s' % pname)
-
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add("GstElement", "*ret")
- if ownsreturn:
- info.varlist.add('PyObject', '*py_ret')
- info.codeafter.append(' py_ret = pygobject_new((GObject *)ret);\n'
- ' if (ret != NULL)\n'
- ' g_object_unref(ret);\n'
- ' return py_ret;')
- else:
- info.codeafter.append(' /* pygobject_new handles NULL checking */\n' +
- ' return pygobject_new((GObject *)ret);')
-
-class GstPadArg(ArgType):
- def write_param(self, ptype, pname, pdflt, pnull, info):
- info.varlist.add('GstPad', '*' + pname)
- info.add_parselist('O!', ['&PyGstPad_Type', '&' + pname], [pname])
- info.arglist.append('%s' % pname)
-
- def write_return(self, ptype, ownsreturn, info):
- info.varlist.add("GstPad", "*ret")
- if ownsreturn:
- info.varlist.add('PyObject', '*py_ret')
- info.codeafter.append(' py_ret = pygobject_new((GObject *)ret);\n'
- ' if (ret != NULL)\n'
- ' g_object_unref(ret);\n'
- ' return py_ret;')
- else:
- info.codeafter.append(' /* pygobject_new handles NULL checking */\n' +
- ' return pygobject_new((GObject *)ret);')
-
-class ArgMatcher:
- def __init__(self):
- self.argtypes = {}
- self.reverse_argtypes = {}
- self.reverse_rettypes = {}
-
- def register(self, ptype, handler, overwrite=False):
- if not overwrite and ptype in self.argtypes:
- return
- self.argtypes[ptype] = handler
- def register_reverse(self, ptype, handler):
- self.reverse_argtypes[ptype] = handler
- def register_reverse_ret(self, ptype, handler):
- self.reverse_rettypes[ptype] = handler
-
- def register_enum(self, ptype, typecode):
- if typecode is None:
- self.register(ptype, IntArg())
- else:
- self.register(ptype, EnumArg(ptype, typecode))
- def register_flag(self, ptype, typecode):
- if typecode is None:
- self.register(ptype, IntArg())
- else:
- self.register(ptype, FlagsArg(ptype, typecode))
- def register_object(self, ptype, parent, typecode):
- oa = ObjectArg(ptype, parent, typecode)
- self.register(ptype, oa) # in case I forget the * in the .defs
- self.register(ptype+'*', oa)
- self.register('const-'+ptype+'*', oa)
- if ptype == 'GdkPixmap':
- # hack to handle GdkBitmap synonym.
- self.register('GdkBitmap', oa)
- self.register('GdkBitmap*', oa)
- def register_boxed(self, ptype, typecode):
- if self.argtypes.has_key(ptype): return
- arg = BoxedArg(ptype, typecode)
- self.register(ptype, arg)
- self.register(ptype+'*', arg)
- self.register('const-'+ptype+'*', arg)
- def register_custom_boxed(self, ptype, pytype, getter, new):
- arg = CustomBoxedArg(ptype, pytype, getter, new)
- self.register(ptype+'*', arg)
- self.register('const-'+ptype+'*', arg)
- def register_pointer(self, ptype, typecode):
- arg = PointerArg(ptype, typecode)
- self.register(ptype, arg)
- self.register(ptype+'*', arg)
- self.register('const-'+ptype+'*', arg)
-
- def get(self, ptype):
- try:
- return self.argtypes[ptype]
- except KeyError:
- if ptype[:8] == 'GdkEvent' and ptype[-1] == '*':
- return self.argtypes['GdkEvent*']
- raise ArgTypeNotFoundError("No ArgType for %s" % (ptype,))
- def _get_reverse_common(self, ptype, registry):
- props = dict(c_type=ptype)
- try:
- return registry[ptype], props
- except KeyError:
- try:
- handler = self.argtypes[ptype]
- except KeyError:
- if ptype.startswith('GdkEvent') and ptype.endswith('*'):
- handler = self.argtypes['GdkEvent*']
- else:
- raise ArgTypeNotFoundError("No ArgType for %s" % (ptype,))
- if isinstance(handler, ObjectArg):
- return registry['GObject*'], props
- elif isinstance(handler, EnumArg):
- props['typecode'] = handler.typecode
- props['enumname'] = handler.enumname
- return registry['GEnum'], props
- elif isinstance(handler, FlagsArg):
- props['typecode'] = handler.typecode
- props['flagname'] = handler.flagname
- return registry['GFlags'], props
- elif isinstance(handler, BoxedArg):
- props['typecode'] = handler.typecode
- props['typename'] = handler.typename
- return registry['GBoxed'], props
- else:
- raise ArgTypeNotFoundError("No ArgType for %s" % (ptype,))
-
- def get_reverse(self, ptype):
- return self._get_reverse_common(ptype, self.reverse_argtypes)
-
- def get_reverse_ret(self, ptype):
- ret, props = self._get_reverse_common(ptype, self.reverse_rettypes)
- if hasattr(ptype, 'optional') and ptype.optional:
- if ret.supports_optional:
- props['optional'] = True
- else:
- raise ArgTypeNotFoundError("Unsupported 'optional' for %s"
- % (ptype,))
- return ret, props
-
- def object_is_a(self, otype, parent):
- if otype == None: return 0
- if otype == parent: return 1
- if not self.argtypes.has_key(otype): return 0
- return self.object_is_a(self.get(otype).parent, parent)
-
-matcher = ArgMatcher()
-
-arg = NoneArg()
-matcher.register(None, arg)
-matcher.register('none', arg)
-
-arg = StringArg()
-matcher.register('char*', arg)
-matcher.register('gchar*', arg)
-matcher.register('const-char*', arg)
-matcher.register('char-const*', arg)
-matcher.register('const-gchar*', arg)
-matcher.register('gchar-const*', arg)
-matcher.register('string', arg)
-matcher.register('static_string', arg)
-
-arg = UCharArg()
-matcher.register('unsigned-char*', arg)
-matcher.register('const-guchar*', arg)
-matcher.register('const-guint8*', arg)
-matcher.register('guchar*', arg)
-
-arg = CharArg()
-matcher.register('char', arg)
-matcher.register('gchar', arg)
-matcher.register('guchar', arg)
-
-arg = GUniCharArg()
-matcher.register('gunichar', arg)
-
-arg = IntArg()
-matcher.register('int', arg)
-matcher.register('gint', arg)
-matcher.register('short', arg)
-matcher.register('gshort', arg)
-matcher.register('gushort', arg)
-matcher.register('gsize', SizeArg())
-matcher.register('gssize', SSizeArg())
-matcher.register('guint8', arg)
-matcher.register('gint8', arg)
-matcher.register('guint16', arg)
-matcher.register('gint16', arg)
-matcher.register('gint32', arg)
-matcher.register('GTime', arg)
-matcher.register('GSeekType', arg) # Hack, but we have no python wrapper
-
-arg = LongArg()
-matcher.register('long', arg)
-matcher.register('glong', arg)
-
-arg = UIntArg()
-matcher.register('guint', arg)
-
-arg = BoolArg()
-matcher.register('gboolean', arg)
-
-arg = TimeTArg()
-matcher.register('time_t', arg)
-
-matcher.register('guint32', UInt32Arg())
-
-arg = ULongArg()
-matcher.register('gulong', arg)
-
-arg = Int64Arg()
-matcher.register('gint64', arg)
-matcher.register('long-long', arg)
-matcher.register('goffset', arg)
-
-arg = UInt64Arg()
-matcher.register('guint64', arg)
-matcher.register('unsigned-long-long', arg)
-
-arg = DoubleArg()
-matcher.register('double', arg)
-matcher.register('gdouble', arg)
-matcher.register('float', arg)
-matcher.register('gfloat', arg)
-
-arg = FileArg()
-matcher.register('FILE*', arg)
-
-# enums, flags, objects
-
-matcher.register('GdkAtom', AtomArg())
-
-matcher.register('GType', GTypeArg())
-matcher.register('GtkType', GTypeArg())
-
-matcher.register('GError**', GErrorArg())
-matcher.register('GtkTreePath*', GtkTreePathArg())
-matcher.register('GdkRectangle*', GdkRectanglePtrArg())
-matcher.register('GtkAllocation*', GdkRectanglePtrArg())
-matcher.register('GdkRectangle', GdkRectangleArg())
-matcher.register('PyObject*', PyObjectArg())
-matcher.register('GstElement*', GstElementArg())
-matcher.register('GstPad*', GstPadArg())
-
-matcher.register('GdkNativeWindow', ULongArg())
-
-matcher.register_object('GObject', None, 'G_TYPE_OBJECT')
-
-del arg
-
-matcher.register('cairo_t*', CairoArg())
-matcher.register_boxed("GClosure", "G_TYPE_CLOSURE")
+++ /dev/null
-#! /usr/bin/env python
-
-from __future__ import generators
-import sys, os
-
-def read_symbols(file, type=None, dynamic=0):
- if dynamic:
- cmd = 'nm -D %s' % file
- else:
- cmd = 'nm %s' % file
- for line in os.popen(cmd, 'r'):
- if line[0] != ' ': # has an address as first bit of line
- while line[0] != ' ':
- line = line[1:]
- while line[0] == ' ':
- line = line[1:]
- # we should be up to "type symbolname" now
- sym_type = line[0]
- symbol = line[1:].strip()
-
- if not type or type == sym_type:
- yield symbol
-
-def main():
- if len(sys.argv) != 3:
- sys.stderr.write('usage: coverage-check library.so wrapper.so\n')
- sys.exit(1)
- library = sys.argv[1]
- wrapper = sys.argv[2]
-
- # first create a dict with all referenced symbols in the wrapper
- # should really be a set, but a dict will do ...
- wrapper_symbols = {}
- for symbol in read_symbols(wrapper, type='U', dynamic=1):
- wrapper_symbols[symbol] = 1
-
- # now go through the library looking for matches on the defined symbols:
- for symbol in read_symbols(library, type='T', dynamic=1):
- if symbol[0] == '_': continue
- if symbol not in wrapper_symbols:
- print symbol
-
-if __name__ == '__main__':
- main()
+++ /dev/null
-#! /usr/bin/env python
-
-import getopt
-import keyword
-import os
-import string
-import sys
-
-import argtypes
-import definitions
-import defsparser
-import override
-import reversewrapper
-import warnings
-
-class Coverage(object):
- def __init__(self, name):
- self.name = name
- self.wrapped = 0
- self.not_wrapped = 0
-
- def declare_wrapped(self):
- self.wrapped += 1
-
- def declare_not_wrapped(self):
- self.not_wrapped += 1
-
- def printstats(self):
- total = self.wrapped + self.not_wrapped
- fd = sys.stderr
- if total:
- fd.write("***INFO*** The coverage of %s is %.2f%% (%i/%i)\n" %
- (self.name,
- float(self.wrapped*100)/total,
- self.wrapped,
- total))
- else:
- fd.write("***INFO*** There are no declared %s.\n" % self.name)
-
-functions_coverage = Coverage("global functions")
-methods_coverage = Coverage("methods")
-vproxies_coverage = Coverage("virtual proxies")
-vaccessors_coverage = Coverage("virtual accessors")
-iproxies_coverage = Coverage("interface proxies")
-
-def exc_info():
- warnings.warn("deprecated", DeprecationWarning, stacklevel=2)
- #traceback.print_exc()
- etype, value, tb = sys.exc_info()
- ret = ""
- try:
- sval = str(value)
- if etype == argtypes.ArgTypeError:
- ret = "No ArgType for %s" % (sval,)
- else:
- ret = sval
- finally:
- del etype, value, tb
- return ret
-
-def fixname(name):
- if keyword.iskeyword(name):
- return name + '_'
- return name
-
-class FileOutput:
- '''Simple wrapper for file object, that makes writing #line
- statements easier.''' # "
- def __init__(self, fp, filename=None):
- self.fp = fp
- self.lineno = 1
- if filename:
- self.filename = filename
- else:
- self.filename = self.fp.name
- # handle writing to the file, and keep track of the line number ...
- def write(self, str):
- self.fp.write(str)
- self.lineno = self.lineno + string.count(str, '\n')
- def writelines(self, sequence):
- for line in sequence:
- self.write(line)
- def close(self):
- self.fp.close()
- def flush(self):
- self.fp.flush()
-
- def setline(self, linenum, filename):
- '''writes out a #line statement, for use by the C
- preprocessor.''' # "
- self.write('#line %d "%s"\n' % (linenum, filename))
- def resetline(self):
- '''resets line numbering to the original file'''
- self.setline(self.lineno + 1, self.filename)
-
-class Wrapper:
- type_tmpl = (
- 'PyTypeObject G_GNUC_INTERNAL Py%(typename)s_Type = {\n'
- ' PyObject_HEAD_INIT(NULL)\n'
- ' 0, /* ob_size */\n'
- ' "%(classname)s", /* tp_name */\n'
- ' sizeof(%(tp_basicsize)s), /* tp_basicsize */\n'
- ' 0, /* tp_itemsize */\n'
- ' /* methods */\n'
- ' (destructor)%(tp_dealloc)s, /* tp_dealloc */\n'
- ' (printfunc)0, /* tp_print */\n'
- ' (getattrfunc)%(tp_getattr)s, /* tp_getattr */\n'
- ' (setattrfunc)%(tp_setattr)s, /* tp_setattr */\n'
- ' (cmpfunc)%(tp_compare)s, /* tp_compare */\n'
- ' (reprfunc)%(tp_repr)s, /* tp_repr */\n'
- ' (PyNumberMethods*)%(tp_as_number)s, /* tp_as_number */\n'
- ' (PySequenceMethods*)%(tp_as_sequence)s, /* tp_as_sequence */\n'
- ' (PyMappingMethods*)%(tp_as_mapping)s, /* tp_as_mapping */\n'
- ' (hashfunc)%(tp_hash)s, /* tp_hash */\n'
- ' (ternaryfunc)%(tp_call)s, /* tp_call */\n'
- ' (reprfunc)%(tp_str)s, /* tp_str */\n'
- ' (getattrofunc)%(tp_getattro)s, /* tp_getattro */\n'
- ' (setattrofunc)%(tp_setattro)s, /* tp_setattro */\n'
- ' (PyBufferProcs*)%(tp_as_buffer)s, /* tp_as_buffer */\n'
- ' %(tp_flags)s, /* tp_flags */\n'
- ' %(tp_doc)s, /* Documentation string */\n'
- ' (traverseproc)%(tp_traverse)s, /* tp_traverse */\n'
- ' (inquiry)%(tp_clear)s, /* tp_clear */\n'
- ' (richcmpfunc)%(tp_richcompare)s, /* tp_richcompare */\n'
- ' %(tp_weaklistoffset)s, /* tp_weaklistoffset */\n'
- ' (getiterfunc)%(tp_iter)s, /* tp_iter */\n'
- ' (iternextfunc)%(tp_iternext)s, /* tp_iternext */\n'
- ' (struct PyMethodDef*)%(tp_methods)s, /* tp_methods */\n'
- ' (struct PyMemberDef*)0, /* tp_members */\n'
- ' (struct PyGetSetDef*)%(tp_getset)s, /* tp_getset */\n'
- ' NULL, /* tp_base */\n'
- ' NULL, /* tp_dict */\n'
- ' (descrgetfunc)%(tp_descr_get)s, /* tp_descr_get */\n'
- ' (descrsetfunc)%(tp_descr_set)s, /* tp_descr_set */\n'
- ' %(tp_dictoffset)s, /* tp_dictoffset */\n'
- ' (initproc)%(tp_init)s, /* tp_init */\n'
- ' (allocfunc)%(tp_alloc)s, /* tp_alloc */\n'
- ' (newfunc)%(tp_new)s, /* tp_new */\n'
- ' (freefunc)%(tp_free)s, /* tp_free */\n'
- ' (inquiry)%(tp_is_gc)s /* tp_is_gc */\n'
- '};\n\n'
- )
-
- slots_list = [
- 'tp_getattr', 'tp_setattr', 'tp_getattro', 'tp_setattro',
- 'tp_compare', 'tp_repr',
- 'tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'tp_hash',
- 'tp_call', 'tp_str', 'tp_as_buffer', 'tp_richcompare', 'tp_iter',
- 'tp_iternext', 'tp_descr_get', 'tp_descr_set', 'tp_init',
- 'tp_alloc', 'tp_new', 'tp_free', 'tp_is_gc',
- 'tp_traverse', 'tp_clear', 'tp_dealloc', 'tp_flags', 'tp_doc'
- ]
-
- getter_tmpl = (
- 'static PyObject *\n'
- '%(funcname)s(PyObject *self, void *closure)\n'
- '{\n'
- '%(varlist)s'
- ' ret = %(field)s;\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
-
- parse_tmpl = (
- ' if (!PyArg_ParseTupleAndKeywords(args, kwargs,'
- '"%(typecodes)s:%(name)s"%(parselist)s))\n'
- ' return %(errorreturn)s;\n'
- )
-
- deprecated_tmpl = (
- ' if (PyErr_Warn(PyExc_DeprecationWarning, '
- '"%(deprecationmsg)s") < 0)\n'
- ' return %(errorreturn)s;\n'
- )
-
- methdef_tmpl = (
- ' { "%(name)s", (PyCFunction)%(cname)s, %(flags)s,\n'
- ' %(docstring)s },\n'
- )
-
- noconstructor = (
- 'static int\n'
- 'pygobject_no_constructor(PyObject *self, PyObject *args, '
- 'PyObject *kwargs)\n'
- '{\n'
- ' gchar buf[512];\n'
- '\n'
- ' g_snprintf(buf, sizeof(buf), "%s is an abstract widget", '
- 'self->ob_type->tp_name);\n'
- ' PyErr_SetString(PyExc_NotImplementedError, buf);\n'
- ' return -1;\n'
- '}\n\n'
- )
-
- function_tmpl = (
- 'static PyObject *\n'
- '_wrap_%(cname)s(PyObject *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' %(begin_allow_threads)s\n'
- ' %(setreturn)s%(cname)s(%(arglist)s);\n'
- ' %(end_allow_threads)s\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
-
- virtual_accessor_tmpl = (
- 'static PyObject *\n'
- '_wrap_%(cname)s(PyObject *cls%(extraparams)s)\n'
- '{\n'
- ' gpointer klass;\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' klass = g_type_class_ref(pyg_type_from_object(cls));\n'
- ' if (%(class_cast_macro)s(klass)->%(virtual)s)\n'
- ' %(setreturn)s%(class_cast_macro)s(klass)->'
- '%(virtual)s(%(arglist)s);\n'
- ' else {\n'
- ' PyErr_SetString(PyExc_NotImplementedError, '
- '"virtual method %(name)s not implemented");\n'
- ' g_type_class_unref(klass);\n'
- ' return NULL;\n'
- ' }\n'
- ' g_type_class_unref(klass);\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
-
- # template for method calls
- constructor_tmpl = None
- method_tmpl = None
-
- def __init__(self, parser, objinfo, overrides, fp=FileOutput(sys.stdout)):
- self.parser = parser
- self.objinfo = objinfo
- self.overrides = overrides
- self.fp = fp
-
- def get_lower_name(self):
- return string.lower(string.replace(self.objinfo.typecode,
- '_TYPE_', '_', 1))
-
- def get_field_accessor(self, fieldname):
- raise NotImplementedError
-
- def get_initial_class_substdict(self): return {}
-
- def get_initial_constructor_substdict(self, constructor):
- return { 'name': '%s.__init__' % self.objinfo.py_name,
- 'errorreturn': '-1' }
-
- def get_initial_method_substdict(self, method):
- substdict = { 'name': '%s.%s' % (self.objinfo.py_name, method.name) }
- if method.unblock_threads:
- substdict['begin_allow_threads'] = 'pyg_begin_allow_threads;'
- substdict['end_allow_threads'] = 'pyg_end_allow_threads;'
- else:
- substdict['begin_allow_threads'] = ''
- substdict['end_allow_threads'] = ''
- return substdict
-
- def write_class(self):
- if self.overrides.is_type_ignored(self.objinfo.c_name):
- return
- self.fp.write('\n/* ----------- %s ----------- */\n\n' %
- self.objinfo.c_name)
- substdict = self.get_initial_class_substdict()
- if not substdict.has_key('tp_flags'):
- substdict['tp_flags'] = 'Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE'
- substdict['typename'] = self.objinfo.c_name
- if self.overrides.modulename:
- substdict['classname'] = '%s.%s' % (self.overrides.modulename,
- self.objinfo.name)
- else:
- substdict['classname'] = self.objinfo.name
- substdict['tp_doc'] = self.objinfo.docstring
-
- # 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()
- substdict['tp_methods'] = self.write_methods()
- substdict['tp_getset'] = self.write_getsets()
-
- # handle slots ...
- for slot in self.slots_list:
-
- slotname = '%s.%s' % (self.objinfo.c_name, slot)
- slotfunc = '_wrap_%s_%s' % (self.get_lower_name(), slot)
- if slot[:6] == 'tp_as_':
- slotfunc = '&' + slotfunc
- if self.overrides.slot_is_overriden(slotname):
- data = self.overrides.slot_override(slotname)
- self.write_function(slotname, data)
- substdict[slot] = slotfunc
- else:
- if not substdict.has_key(slot):
- substdict[slot] = '0'
-
- self.fp.write(self.type_tmpl % substdict)
-
- self.write_virtuals()
-
- def write_function_wrapper(self, function_obj, template,
- handle_return=0, is_method=0, kwargs_needed=0,
- substdict=None):
- '''This function is the guts of all functions that generate
- wrappers for functions, methods and constructors.'''
- if not substdict: substdict = {}
-
- info = argtypes.WrapperInfo()
-
- substdict.setdefault('errorreturn', 'NULL')
-
- # for methods, we want the leading comma
- if is_method:
- info.arglist.append('')
-
- if function_obj.varargs:
- raise argtypes.ArgTypeNotFoundError("varargs functions not supported")
-
- for param in function_obj.params:
- if param.pdflt != None and '|' not in info.parsestr:
- info.add_parselist('|', [], [])
- handler = argtypes.matcher.get(param.ptype)
- handler.write_param(param.ptype, param.pname, param.pdflt,
- param.pnull, info)
-
- substdict['setreturn'] = ''
- if handle_return:
- if function_obj.ret not in ('none', None):
- substdict['setreturn'] = 'ret = '
- handler = argtypes.matcher.get(function_obj.ret)
- handler.write_return(function_obj.ret,
- function_obj.caller_owns_return, info)
-
- if function_obj.deprecated != None:
- deprecated = self.deprecated_tmpl % {
- 'deprecationmsg': function_obj.deprecated,
- 'errorreturn': substdict['errorreturn'] }
- else:
- deprecated = ''
-
- # if name isn't set, set it to function_obj.name
- substdict.setdefault('name', function_obj.name)
-
- if function_obj.unblock_threads:
- substdict['begin_allow_threads'] = 'pyg_begin_allow_threads;'
- substdict['end_allow_threads'] = 'pyg_end_allow_threads;'
- else:
- substdict['begin_allow_threads'] = ''
- substdict['end_allow_threads'] = ''
-
- if self.objinfo:
- substdict['typename'] = self.objinfo.c_name
- substdict.setdefault('cname', function_obj.c_name)
- substdict['varlist'] = info.get_varlist()
- substdict['typecodes'] = info.parsestr
- substdict['parselist'] = info.get_parselist()
- substdict['arglist'] = info.get_arglist()
- substdict['codebefore'] = deprecated + (
- string.replace(info.get_codebefore(),
- 'return NULL', 'return ' + substdict['errorreturn'])
- )
- substdict['codeafter'] = (
- string.replace(info.get_codeafter(),
- 'return NULL',
- 'return ' + substdict['errorreturn']))
-
- if info.parsestr or kwargs_needed:
- substdict['parseargs'] = self.parse_tmpl % substdict
- substdict['extraparams'] = ', PyObject *args, PyObject *kwargs'
- flags = 'METH_VARARGS|METH_KEYWORDS'
-
- # prepend the keyword list to the variable list
- substdict['varlist'] = info.get_kwlist() + substdict['varlist']
- else:
- substdict['parseargs'] = ''
- substdict['extraparams'] = ''
- flags = 'METH_NOARGS'
-
- return template % substdict, flags
-
- def write_constructor(self):
- initfunc = '0'
- constructor = self.parser.find_constructor(self.objinfo,self.overrides)
- if not constructor:
- return self.write_default_constructor()
-
- funcname = constructor.c_name
- try:
- if self.overrides.is_overriden(funcname):
- data = self.overrides.override(funcname)
- self.write_function(funcname, data)
- self.objinfo.has_new_constructor_api = (
- self.objinfo.typecode in
- self.overrides.newstyle_constructors)
- else:
- # ok, a hack to determine if we should use
- # new-style constructores :P
- property_based = getattr(self,
- 'write_property_based_constructor',
- None)
- if property_based:
- if (len(constructor.params) == 0 or
- isinstance(constructor.params[0],
- definitions.Property)):
- # write_property_based_constructor is only
- # implemented in GObjectWrapper
- return self.write_property_based_constructor(
- constructor)
- else:
- sys.stderr.write(
- "Warning: generating old-style constructor for:" +
- constructor.c_name + '\n')
-
- # write constructor from template ...
- code = self.write_function_wrapper(constructor,
- self.constructor_tmpl,
- handle_return=0, is_method=0, kwargs_needed=1,
- substdict=self.get_initial_constructor_substdict(
- constructor))[0]
- self.fp.write(code)
- initfunc = '_wrap_' + funcname
- except argtypes.ArgTypeError, ex:
- sys.stderr.write('Could not write constructor for %s: %s\n'
- % (self.objinfo.c_name, str(ex)))
-
- initfunc = self.write_noconstructor()
- return initfunc
-
- def write_noconstructor(self):
- # this is a hack ...
- if not hasattr(self.overrides, 'no_constructor_written'):
- self.fp.write(self.noconstructor)
- self.overrides.no_constructor_written = 1
- initfunc = 'pygobject_no_constructor'
- return initfunc
-
- def write_default_constructor(self):
- return self.write_noconstructor()
-
- def get_methflags(self, funcname):
- if self.overrides.wants_kwargs(funcname):
- flags = 'METH_VARARGS|METH_KEYWORDS'
- elif self.overrides.wants_noargs(funcname):
- flags = 'METH_NOARGS'
- elif self.overrides.wants_onearg(funcname):
- flags = 'METH_O'
- else:
- flags = 'METH_VARARGS'
- if self.overrides.is_staticmethod(funcname):
- flags += '|METH_STATIC'
- elif self.overrides.is_classmethod(funcname):
- flags += '|METH_CLASS'
- return flags
-
- def write_function(self, funcname, data):
- lineno, filename = self.overrides.getstartline(funcname)
- self.fp.setline(lineno, filename)
- self.fp.write(data)
- self.fp.resetline()
- self.fp.write('\n\n')
-
- def _get_class_virtual_substdict(self, meth, cname, parent):
- substdict = self.get_initial_method_substdict(meth)
- substdict['virtual'] = meth.name
- substdict['cname'] = cname
- substdict['class_cast_macro'] = parent.typecode.replace(
- '_TYPE_', '_', 1) + "_CLASS"
- substdict['typecode'] = self.objinfo.typecode
- substdict['cast'] = string.replace(parent.typecode, '_TYPE_', '_', 1)
- return substdict
-
- def write_methods(self):
- methods = []
- klass = self.objinfo.c_name
- # First, get methods from the defs files
- for meth in self.parser.find_methods(self.objinfo):
- method_name = meth.c_name
- if self.overrides.is_ignored(method_name):
- continue
- try:
- if self.overrides.is_overriden(method_name):
- if not self.overrides.is_already_included(method_name):
- data = self.overrides.override(method_name)
- self.write_function(method_name, data)
-
- methflags = self.get_methflags(method_name)
- 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.fp.write(code)
- methods.append(self.methdef_tmpl %
- { 'name': fixname(meth.name),
- 'cname': '_wrap_' + method_name,
- 'flags': methflags,
- 'docstring': meth.docstring })
- methods_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- methods_coverage.declare_not_wrapped()
- sys.stderr.write('Could not write method %s.%s: %s\n'
- % (klass, meth.name, str(ex)))
-
- # Now try to see if there are any defined in the override
- for method_name in self.overrides.get_defines_for(klass):
- c_name = override.class2cname(klass, method_name)
- if self.overrides.is_already_included(method_name):
- continue
-
- try:
- data = self.overrides.define(klass, method_name)
- self.write_function(method_name, data)
- methflags = self.get_methflags(method_name)
-
- methods.append(self.methdef_tmpl %
- { 'name': method_name,
- 'cname': '_wrap_' + c_name,
- 'flags': methflags,
- 'docstring': 'NULL' })
- methods_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- methods_coverage.declare_not_wrapped()
- sys.stderr.write('Could not write method %s.%s: %s\n'
- % (klass, method_name, str(ex)))
-
- # Add GObject virtual method accessors, for chaining to parent
- # virtuals from subclasses
- methods += self.write_virtual_accessors()
-
- if methods:
- methoddefs = '_Py%s_methods' % self.objinfo.c_name
- # write the PyMethodDef structure
- methods.append(' { NULL, NULL, 0, NULL }\n')
- self.fp.write('static const PyMethodDef %s[] = {\n' % methoddefs)
- self.fp.write(string.join(methods, ''))
- self.fp.write('};\n\n')
- else:
- methoddefs = 'NULL'
- return methoddefs
-
- def write_virtual_accessors(self):
- klass = self.objinfo.c_name
- methods = []
- for meth in self.parser.find_virtuals(self.objinfo):
- method_name = self.objinfo.c_name + "__do_" + meth.name
- if self.overrides.is_ignored(method_name):
- continue
- try:
- if self.overrides.is_overriden(method_name):
- if not self.overrides.is_already_included(method_name):
- data = self.overrides.override(method_name)
- self.write_function(method_name, data)
- methflags = self.get_methflags(method_name)
- else:
- # temporarily add a 'self' parameter as first argument
- meth.params.insert(0, definitions.Parameter(
- ptype=(self.objinfo.c_name + '*'),
- pname='self', pdflt=None, pnull=None))
- try:
- # write method from template ...
- code, methflags = self.write_function_wrapper(
- meth, self.virtual_accessor_tmpl,
- handle_return=True, is_method=False,
- substdict=self._get_class_virtual_substdict(
- meth, method_name, self.objinfo))
- self.fp.write(code)
- finally:
- del meth.params[0]
- methods.append(self.methdef_tmpl %
- { 'name': "do_" + fixname(meth.name),
- 'cname': '_wrap_' + method_name,
- 'flags': methflags + '|METH_CLASS',
- 'docstring': 'NULL'})
- vaccessors_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- vaccessors_coverage.declare_not_wrapped()
- sys.stderr.write(
- 'Could not write virtual accessor method %s.%s: %s\n'
- % (klass, meth.name, str(ex)))
- return methods
-
- def write_virtuals(self):
- '''
- Write _wrap_FooBar__proxy_do_zbr() reverse wrapers for
- GObject virtuals
- '''
- klass = self.objinfo.c_name
- virtuals = []
- for meth in self.parser.find_virtuals(self.objinfo):
- method_name = self.objinfo.c_name + "__proxy_do_" + meth.name
- if self.overrides.is_ignored(method_name):
- continue
- try:
- if self.overrides.is_overriden(method_name):
- if not self.overrides.is_already_included(method_name):
- data = self.overrides.override(method_name)
- self.write_function(method_name, data)
- else:
- # write virtual proxy ...
- ret, props = argtypes.matcher.get_reverse_ret(meth.ret)
- wrapper = reversewrapper.ReverseWrapper(
- '_wrap_' + method_name, is_static=True)
- wrapper.set_return_type(ret(wrapper, **props))
- wrapper.add_parameter(reversewrapper.PyGObjectMethodParam(
- wrapper, "self", method_name="do_" + meth.name,
- c_type=(klass + ' *')))
- for param in meth.params:
- handler, props = argtypes.matcher.get_reverse(
- param.ptype)
- props["direction"] = param.pdir
- props["nullok"] = param.pnull
- wrapper.add_parameter(handler(wrapper,
- param.pname, **props))
- buf = reversewrapper.MemoryCodeSink()
- wrapper.generate(buf)
- self.fp.write(buf.flush())
- virtuals.append((fixname(meth.name), '_wrap_' + method_name))
- vproxies_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- vproxies_coverage.declare_not_wrapped()
- virtuals.append((fixname(meth.name), None))
- sys.stderr.write('Could not write virtual proxy %s.%s: %s\n'
- % (klass, meth.name, str(ex)))
- if virtuals:
- # Write a 'pygtk class init' function for this object,
- # except when the object type is explicitly ignored (like
- # GtkPlug and GtkSocket on win32).
- if self.overrides.is_ignored(self.objinfo.typecode):
- return
- class_cast_macro = self.objinfo.typecode.replace(
- '_TYPE_', '_', 1) + "_CLASS"
- cast_macro = self.objinfo.typecode.replace('_TYPE_', '_', 1)
- funcname = "__%s_class_init" % klass
- self.objinfo.class_init_func = funcname
- have_implemented_virtuals = not not [True
- for name, cname in virtuals
- if cname is not None]
- self.fp.write(
- ('\nstatic int\n'
- '%(funcname)s(gpointer gclass, PyTypeObject *pyclass)\n'
- '{\n') % vars())
-
- if have_implemented_virtuals:
- self.fp.write(' PyObject *o;\n')
- self.fp.write(
- ' %(klass)sClass *klass = '
- '%(class_cast_macro)s(gclass);\n'
- ' PyObject *gsignals = '
- 'PyDict_GetItemString(pyclass->tp_dict, "__gsignals__");\n'
- % vars())
-
- for name, cname in virtuals:
- do_name = 'do_' + name
- if cname is None:
- self.fp.write('\n /* overriding %(do_name)s '
- 'is currently not supported */\n' % vars())
- else:
- self.fp.write('''
- o = PyObject_GetAttrString((PyObject *) pyclass, "%(do_name)s");
- if (o == NULL)
- PyErr_Clear();
- else {
- if (!PyObject_TypeCheck(o, &PyCFunction_Type)
- && !(gsignals && PyDict_GetItemString(gsignals, "%(name)s")))
- klass->%(name)s = %(cname)s;
- Py_DECREF(o);
- }
-''' % vars())
- self.fp.write(' return 0;\n}\n')
-
- def write_getsets(self):
- lower_name = self.get_lower_name()
- getsets_name = lower_name + '_getsets'
- getterprefix = '_wrap_' + lower_name + '__get_'
- setterprefix = '_wrap_' + lower_name + '__set_'
-
- # no overrides for the whole function. If no fields,
- # don't write a func
- if not self.objinfo.fields:
- return '0'
- getsets = []
- for ftype, cfname in self.objinfo.fields:
- fname = cfname.replace('.', '_')
- gettername = '0'
- settername = '0'
- attrname = self.objinfo.c_name + '.' + fname
- if self.overrides.attr_is_overriden(attrname):
- code = self.overrides.attr_override(attrname)
- self.write_function(attrname, code)
- if string.find(code, getterprefix + fname) >= 0:
- gettername = getterprefix + fname
- if string.find(code, setterprefix + fname) >= 0:
- settername = setterprefix + fname
- if gettername == '0':
- try:
- funcname = getterprefix + fname
- info = argtypes.WrapperInfo()
- handler = argtypes.matcher.get(ftype)
- # for attributes, we don't own the "return value"
- handler.write_return(ftype, 0, info)
- self.fp.write(self.getter_tmpl %
- { 'funcname': funcname,
- 'varlist': info.varlist,
- 'field': self.get_field_accessor(cfname),
- 'codeafter': info.get_codeafter() })
- gettername = funcname
- except argtypes.ArgTypeError, ex:
- sys.stderr.write(
- "Could not write getter for %s.%s: %s\n"
- % (self.objinfo.c_name, fname, str(ex)))
- if gettername != '0' or settername != '0':
- getsets.append(' { "%s", (getter)%s, (setter)%s },\n' %
- (fixname(fname), gettername, settername))
-
- if not getsets:
- return '0'
- self.fp.write('static const PyGetSetDef %s[] = {\n' % getsets_name)
- for getset in getsets:
- self.fp.write(getset)
- self.fp.write(' { NULL, (getter)0, (setter)0 },\n')
- self.fp.write('};\n\n')
-
- return getsets_name
-
- def _write_get_symbol_names(self, writer, functions):
- self.fp.write("""static PyObject *
-_wrap__get_symbol_names(PyObject *self)
-{
- PyObject *pylist = PyList_New(0);
-
-""")
- for obj, bases in writer.get_classes():
- self.fp.write(' PyList_Append(pylist, '
- 'PyString_FromString("%s"));\n' % (obj.name))
-
- for name, cname, flags, docstring in functions:
- self.fp.write(' PyList_Append(pylist, '
- 'PyString_FromString("%s"));\n' % (name))
-
- for enum in writer.get_enums():
- self.fp.write(' PyList_Append(pylist, '
- 'PyString_FromString("%s"));\n' % (enum.name))
- for nick, value in enum.values:
- name = value[len(self.overrides.modulename)+1:]
- self.fp.write(' PyList_Append(pylist, '
- 'PyString_FromString("%s"));\n' % (name))
-
- self.fp.write(" return pylist;\n}\n\n");
-
- def _write_get_symbol(self, writer, functions):
- self.fp.write("""static PyObject *
-_wrap__get_symbol(PyObject *self, PyObject *args)
-{
- PyObject *d;
- char *name;
- static PyObject *modulename = NULL;
- static PyObject *module = NULL;
- static char *strip_prefix = "%s";
-
- if (!PyArg_ParseTuple(args, "Os", &d, &name))
- return NULL;
-
- if (!modulename)
- modulename = PyString_FromString("%s");
-
- if (!module)
- module = PyDict_GetItemString(d, "__module__");
-
-""" % (self.overrides.modulename.upper() + '_',
- self.overrides.modulename))
-
- first = True
- # Classes / GObjects
- for obj, bases in writer.get_classes():
- if first:
- self.fp.write(' if (!strcmp(name, "%s")) {\n' % obj.name)
- first = False
- else:
- self.fp.write(' } else if (!strcmp(name, "%s")) {\n' % obj.name)
- self.fp.write(
- ' return (PyObject*)pygobject_lookup_class(%s);\n' %
- obj.typecode)
- self.fp.write(' }\n')
-
- # Functions
- for name, cname, flags, docstring in functions:
- self.fp.write(' else if (!strcmp(name, "%s")) {\n' % name)
- self.fp.write(' static PyMethodDef ml = { '
- '"%s", (PyCFunction)%s, %s, "%s"};\n' % (
- name, cname, flags, docstring))
- self.fp.write(' return PyCFunction_NewEx(&ml, NULL, modulename);\n')
- self.fp.write(' }\n')
-
- # Enums
- def write_enum(enum, returnobj=False):
- if returnobj:
- ret = 'return '
- else:
- ret = ''
- if enum.deftype == 'enum':
- self.fp.write(
- ' %spyg_enum_add(module, "%s", strip_prefix, %s);\n'
- % (ret, enum.name, enum.typecode))
- else:
- self.fp.write(
- ' %spyg_flags_add(module, "%s", strip_prefix, %s);\n'
- % (ret, enum.name, enum.typecode))
-
- strip_len = len(self.overrides.modulename)+1 # GTK_
- for enum in writer.get_enums():
- # XXX: Implement without typecodes
- self.fp.write(' else if (!strcmp(name, "%s")) {\n' % enum.name)
- write_enum(enum, returnobj=True)
- self.fp.write(' }\n')
-
- for nick, value in enum.values:
- value = value[strip_len:]
- self.fp.write(' else if (!strcmp(name, "%s")) {\n' % value)
- write_enum(enum)
- self.fp.write(' return PyObject_GetAttrString(module, "%s");\n' %
- value)
- self.fp.write(' }\n')
-
- self.fp.write(' return Py_None;\n}\n\n');
-
- def _write_function_bodies(self):
- functions = []
- # First, get methods from the defs files
- for func in self.parser.find_functions():
- funcname = func.c_name
- if self.overrides.is_ignored(funcname):
- continue
- try:
- if self.overrides.is_overriden(funcname):
- data = self.overrides.override(funcname)
- self.write_function(funcname, data)
-
- methflags = self.get_methflags(funcname)
- else:
- # write constructor from template ...
- code, methflags = self.write_function_wrapper(func,
- self.function_tmpl, handle_return=1, is_method=0)
- self.fp.write(code)
- functions.append((func.name, '_wrap_' + funcname,
- methflags, func.docstring))
- functions_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- functions_coverage.declare_not_wrapped()
- sys.stderr.write('Could not write function %s: %s\n'
- % (func.name, str(ex)))
-
- # Now try to see if there are any defined in the override
- for funcname in self.overrides.get_functions():
- try:
- data = self.overrides.function(funcname)
- self.write_function(funcname, data)
- methflags = self.get_methflags(funcname)
- functions.append((funcname, '_wrap_' + funcname,
- methflags, 'NULL'))
- functions_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- functions_coverage.declare_not_wrapped()
- sys.stderr.write('Could not write function %s: %s\n'
- % (funcname, str(ex)))
- return functions
-
- def write_functions(self, writer, prefix):
- self.fp.write('\n/* ----------- functions ----------- */\n\n')
- functions = []
- func_infos = self._write_function_bodies()
-
- # If we have a dynamic namespace, write symbol and attribute getter
- if self.overrides.dynamicnamespace:
- self._write_get_symbol_names(writer, func_infos)
- self._write_get_symbol(writer, func_infos)
- for obj, bases in writer.get_classes():
- self.fp.write("""static PyTypeObject *
-%s_register_type(const gchar *name, PyObject *unused)
-{
- PyObject *m = PyImport_ImportModule("gtk");
- PyObject *d = PyModule_GetDict(m);
-""" % obj.c_name)
- writer.write_class(obj, bases, indent=1)
- self.fp.write(
- ' return (%s)PyDict_GetItemString(d, "%s");\n' % (
- 'PyTypeObject*', obj.name))
- self.fp.write("}\n")
-
- functions.append(' { "_get_symbol_names", '
- '(PyCFunction)_wrap__get_symbol_names, '
- 'METH_NOARGS, NULL },\n')
- functions.append(' { "_get_symbol", '
- '(PyCFunction)_wrap__get_symbol, '
- 'METH_VARARGS, NULL },\n')
- else:
- for name, cname, flags, docstring in func_infos:
- functions.append(self.methdef_tmpl % dict(name=name,
- cname=cname,
- flags=flags,
- docstring=docstring))
-
- # write the PyMethodDef structure
- functions.append(' { NULL, NULL, 0, NULL }\n')
-
- self.fp.write('const PyMethodDef ' + prefix + '_functions[] = {\n')
- self.fp.write(string.join(functions, ''))
- self.fp.write('};\n\n')
-
-class GObjectWrapper(Wrapper):
- constructor_tmpl = (
- 'static int\n'
- '_wrap_%(cname)s(PyGObject *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' self->obj = (GObject *)%(cname)s(%(arglist)s);\n'
- '%(codeafter)s\n'
- ' if (!self->obj) {\n'
- ' PyErr_SetString(PyExc_RuntimeError, '
- '"could not create %(typename)s object");\n'
- ' return -1;\n'
- ' }\n'
- '%(aftercreate)s'
- ' pygobject_register_wrapper((PyObject *)self);\n'
- ' return 0;\n'
- '}\n\n'
- )
-
- method_tmpl = (
- 'static PyObject *\n'
- '_wrap_%(cname)s(PyGObject *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' %(begin_allow_threads)s\n'
- ' %(setreturn)s%(cname)s(%(cast)s(self->obj)%(arglist)s);\n'
- ' %(end_allow_threads)s\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
- def __init__(self, parser, objinfo, overrides, fp=FileOutput(sys.stdout)):
- Wrapper.__init__(self, parser, objinfo, overrides, fp)
- if self.objinfo:
- self.castmacro = string.replace(self.objinfo.typecode,
- '_TYPE_', '_', 1)
-
- def get_initial_class_substdict(self):
- return { 'tp_basicsize' : 'PyGObject',
- 'tp_weaklistoffset' : 'offsetof(PyGObject, weakreflist)',
- 'tp_dictoffset' : 'offsetof(PyGObject, inst_dict)' }
-
- def get_field_accessor(self, fieldname):
- castmacro = string.replace(self.objinfo.typecode, '_TYPE_', '_', 1)
- return '%s(pygobject_get(self))->%s' % (castmacro, fieldname)
-
- def get_initial_constructor_substdict(self, constructor):
- substdict = Wrapper.get_initial_constructor_substdict(self,
- constructor)
- if not constructor.caller_owns_return:
- substdict['aftercreate'] = " g_object_ref(self->obj);\n"
- else:
- substdict['aftercreate'] = ''
- return substdict
-
- def get_initial_method_substdict(self, method):
- substdict = Wrapper.get_initial_method_substdict(self, method)
- substdict['cast'] = string.replace(self.objinfo.typecode,
- '_TYPE_', '_', 1)
- return substdict
-
- def write_default_constructor(self):
- try:
- parent = self.parser.find_object(self.objinfo.parent)
- except ValueError:
- parent = None
- if parent is not None:
- ## just like the constructor is inheritted, we should
- # inherit the new API compatibility flag
- self.objinfo.has_new_constructor_api = (
- parent.has_new_constructor_api)
- elif self.objinfo.parent == 'GObject':
- self.objinfo.has_new_constructor_api = True
- return '0'
-
- def write_property_based_constructor(self, constructor):
- self.objinfo.has_new_constructor_api = True
- out = self.fp
- print >> out, "static int"
- print >> out, '_wrap_%s(PyGObject *self, PyObject *args,' \
- ' PyObject *kwargs)\n{' % constructor.c_name
- if constructor.params:
- s = " GType obj_type = pyg_type_from_object((PyObject *) self);"
- print >> out, s
-
- def py_str_list_to_c(arg):
- if arg:
- return "{" + ", ".join(
- map(lambda s: '"' + s + '"', arg)) + ", NULL }"
- else:
- return "{ NULL }"
-
- classname = '%s.%s' % (self.overrides.modulename,
- self.objinfo.name)
-
- if constructor.params:
- mandatory_arguments = [param for param in constructor.params
- if not param.optional]
- optional_arguments = [param for param in constructor.params
- if param.optional]
- arg_names = py_str_list_to_c(
- [param.argname
- for param in mandatory_arguments + optional_arguments])
-
- prop_names = py_str_list_to_c(
- [param.pname
- for param in mandatory_arguments + optional_arguments])
-
- print >> out, " GParameter params[%i];" % \
- len(constructor.params)
- print >> out, " PyObject *parsed_args[%i] = {NULL, };" % \
- len(constructor.params)
- print >> out, " char *arg_names[] = %s;" % arg_names
- print >> out, " char *prop_names[] = %s;" % prop_names
- print >> out, " guint nparams, i;"
- print >> out
- if constructor.deprecated is not None:
- out.write(
- ' if (PyErr_Warn(PyExc_DeprecationWarning, '
- '"%s") < 0)\n' %
- constructor.deprecated)
- print >> out, ' return -1;'
- print >> out
- out.write(" if (!PyArg_ParseTupleAndKeywords(args, kwargs, ")
- template = '"'
- if mandatory_arguments:
- template += "O"*len(mandatory_arguments)
- if optional_arguments:
- template += "|" + "O"*len(optional_arguments)
- template += ':%s.__init__"' % classname
- print >> out, template, ", arg_names",
- for i in range(len(constructor.params)):
- print >> out, ", &parsed_args[%i]" % i,
-
- out.write(
- "))\n"
- " return -1;\n"
- "\n"
- " memset(params, 0, sizeof(GParameter)*%i);\n"
- " if (!pyg_parse_constructor_args(obj_type, arg_names,\n"
- " prop_names, params, \n"
- " &nparams, parsed_args))\n"
- " return -1;\n"
- " pygobject_constructv(self, nparams, params);\n"
- " for (i = 0; i < nparams; ++i)\n"
- " g_value_unset(¶ms[i].value);\n"
- % len(constructor.params))
- else:
- out.write(
- " static char* kwlist[] = { NULL };\n"
- "\n")
-
- if constructor.deprecated is not None:
- out.write(
- ' if (PyErr_Warn(PyExc_DeprecationWarning, "%s") < 0)\n'
- ' return -1;\n'
- '\n' % constructor.deprecated)
-
- out.write(
- ' if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n'
- ' ":%s.__init__",\n'
- ' kwlist))\n'
- ' return -1;\n'
- '\n'
- ' pygobject_constructv(self, 0, NULL);\n' % classname)
- out.write(
- ' if (!self->obj) {\n'
- ' PyErr_SetString(\n'
- ' PyExc_RuntimeError, \n'
- ' "could not create %s object");\n'
- ' return -1;\n'
- ' }\n' % classname)
-
- if not constructor.caller_owns_return:
- print >> out, " g_object_ref(self->obj);\n"
-
- out.write(
- ' return 0;\n'
- '}\n\n')
-
- return "_wrap_%s" % constructor.c_name
-
-
-class GInterfaceWrapper(GObjectWrapper):
- virtual_accessor_tmpl = (
- 'static PyObject *\n'
- '_wrap_%(cname)s(PyObject *cls%(extraparams)s)\n'
- '{\n'
- ' %(vtable)s *iface;\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' iface = g_type_interface_peek('
- 'g_type_class_peek(pyg_type_from_object(cls)), %(typecode)s);\n'
- ' if (iface->%(virtual)s)\n'
- ' %(setreturn)siface->%(virtual)s(%(arglist)s);\n'
- ' else {\n'
- ' PyErr_SetString(PyExc_NotImplementedError, '
- '"interface method %(name)s not implemented");\n'
- ' return NULL;\n'
- ' }\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
-
- def get_initial_class_substdict(self):
- return { 'tp_basicsize' : 'PyObject',
- 'tp_weaklistoffset' : '0',
- 'tp_dictoffset' : '0'}
-
- def write_constructor(self):
- # interfaces have no constructors ...
- return '0'
- def write_getsets(self):
- # interfaces have no fields ...
- return '0'
-
- def _get_class_virtual_substdict(self, meth, cname, parent):
- substdict = self.get_initial_method_substdict(meth)
- substdict['virtual'] = meth.name
- substdict['cname'] = cname
- substdict['typecode'] = self.objinfo.typecode
- substdict['vtable'] = self.objinfo.vtable
- return substdict
-
- def write_virtuals(self):
- ## Now write reverse method wrappers, which let python code
- ## implement interface methods.
- # First, get methods from the defs files
- klass = self.objinfo.c_name
- proxies = []
- for meth in self.parser.find_virtuals(self.objinfo):
- method_name = self.objinfo.c_name + "__proxy_do_" + meth.name
- if self.overrides.is_ignored(method_name):
- continue
- try:
- if self.overrides.is_overriden(method_name):
- if not self.overrides.is_already_included(method_name):
- data = self.overrides.override(method_name)
- self.write_function(method_name, data)
- else:
- # write proxy ...
- ret, props = argtypes.matcher.get_reverse_ret(meth.ret)
- wrapper = reversewrapper.ReverseWrapper(
- '_wrap_' + method_name, is_static=True)
- wrapper.set_return_type(ret(wrapper, **props))
- wrapper.add_parameter(reversewrapper.PyGObjectMethodParam(
- wrapper, "self", method_name="do_" + meth.name,
- c_type=(klass + ' *')))
- for param in meth.params:
- handler, props = argtypes.matcher.get_reverse(
- param.ptype)
- props["direction"] = param.pdir
- props["nullok"] = param.pnull
- wrapper.add_parameter(
- handler(wrapper, param.pname, **props))
- buf = reversewrapper.MemoryCodeSink()
- wrapper.generate(buf)
- self.fp.write(buf.flush())
- proxies.append((fixname(meth.name), '_wrap_' + method_name))
- iproxies_coverage.declare_wrapped()
- except argtypes.ArgTypeError, ex:
- iproxies_coverage.declare_not_wrapped()
- proxies.append((fixname(meth.name), None))
- sys.stderr.write('Could not write interface proxy %s.%s: %s\n'
- % (klass, meth.name, str(ex)))
-
- if not proxies or not [cname for name, cname in proxies if cname]:
- return
-
- ## Write an interface init function for this object
- funcname = "__%s__interface_init" % klass
- vtable = self.objinfo.vtable
- self.fp.write(
- '\nstatic void\n'
- '%(funcname)s(%(vtable)s *iface, PyTypeObject *pytype)\n'
- '{\n'
- ' %(vtable)s *parent_iface = '
- 'g_type_interface_peek_parent(iface);\n'
- ' PyObject *py_method;\n'
- '\n'
- % vars())
-
- for name, cname in proxies:
- do_name = 'do_' + name
- if cname is None:
- continue
-
- self.fp.write((
- ' py_method = pytype? PyObject_GetAttrString('
- '(PyObject *) pytype, "%(do_name)s") : NULL;\n'
- ' if (py_method && !PyObject_TypeCheck(py_method, '
- '&PyCFunction_Type)) {\n'
- ' iface->%(name)s = %(cname)s;\n'
- ' } else {\n'
- ' PyErr_Clear();\n'
- ' if (parent_iface) {\n'
- ' iface->%(name)s = parent_iface->%(name)s;\n'
- ' }\n'
- ' Py_XDECREF(py_method);\n'
- ' }\n'
- ) % vars())
- self.fp.write('}\n\n')
- interface_info = "__%s__iinfo" % klass
- self.fp.write('''
-static const GInterfaceInfo %s = {
- (GInterfaceInitFunc) %s,
- NULL,
- NULL
-};
-''' % (interface_info, funcname))
- self.objinfo.interface_info = interface_info
-
-class GBoxedWrapper(Wrapper):
- constructor_tmpl = (
- 'static int\n'
- '_wrap_%(cname)s(PyGBoxed *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' self->gtype = %(typecode)s;\n'
- ' self->free_on_dealloc = FALSE;\n'
- ' self->boxed = %(cname)s(%(arglist)s);\n'
- '%(codeafter)s\n'
- ' if (!self->boxed) {\n'
- ' PyErr_SetString(PyExc_RuntimeError, '
- '"could not create %(typename)s object");\n'
- ' return -1;\n'
- ' }\n'
- ' self->free_on_dealloc = TRUE;\n'
- ' return 0;\n'
- '}\n\n'
- )
-
- method_tmpl = (
- 'static PyObject *\n'
- '_wrap_%(cname)s(PyObject *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' %(begin_allow_threads)s\n'
- ' %(setreturn)s%(cname)s(pyg_boxed_get(self, '
- '%(typename)s)%(arglist)s);\n'
- ' %(end_allow_threads)s\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
-
- def get_initial_class_substdict(self):
- return { 'tp_basicsize' : 'PyGBoxed',
- 'tp_weaklistoffset' : '0',
- 'tp_dictoffset' : '0' }
-
- def get_field_accessor(self, fieldname):
- return 'pyg_boxed_get(self, %s)->%s' % (self.objinfo.c_name, fieldname)
-
- def get_initial_constructor_substdict(self, constructor):
- substdict = Wrapper.get_initial_constructor_substdict(
- self, constructor)
- substdict['typecode'] = self.objinfo.typecode
- return substdict
-
-class GPointerWrapper(GBoxedWrapper):
- constructor_tmpl = (
- 'static int\n'
- '_wrap_%(cname)s(PyGPointer *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' self->gtype = %(typecode)s;\n'
- ' self->pointer = %(cname)s(%(arglist)s);\n'
- '%(codeafter)s\n'
- ' if (!self->pointer) {\n'
- ' PyErr_SetString(PyExc_RuntimeError, '
- '"could not create %(typename)s object");\n'
- ' return -1;\n'
- ' }\n'
- ' return 0;\n'
- '}\n\n'
- )
-
- method_tmpl = (
- 'static PyObject *\n'
- '_wrap_%(cname)s(PyObject *self%(extraparams)s)\n'
- '{\n'
- '%(varlist)s'
- '%(parseargs)s'
- '%(codebefore)s'
- ' %(setreturn)s%(cname)s(pyg_pointer_get(self, '
- '%(typename)s)%(arglist)s);\n'
- '%(codeafter)s\n'
- '}\n\n'
- )
-
- def get_initial_class_substdict(self):
- return { 'tp_basicsize' : 'PyGPointer',
- 'tp_weaklistoffset' : '0',
- 'tp_dictoffset' : '0' }
-
- def get_field_accessor(self, fieldname):
- return 'pyg_pointer_get(self, %s)->%s' % (self.objinfo.c_name,
- fieldname)
-
- def get_initial_constructor_substdict(self, constructor):
- substdict = Wrapper.get_initial_constructor_substdict(
- self, constructor)
- substdict['typecode'] = self.objinfo.typecode
- return substdict
-
-class SourceWriter:
- def __init__(self, parser, overrides, prefix, fp=FileOutput(sys.stdout)):
- self.parser = parser
- self.overrides = overrides
- self.prefix = prefix
- self.fp = fp
-
- def write(self, py_ssize_t_clean=False):
- argtypes.py_ssize_t_clean = py_ssize_t_clean
-
- self.write_headers(py_ssize_t_clean)
- self.write_imports()
- self.write_type_declarations()
- self.write_body()
- self.write_classes()
-
- wrapper = Wrapper(self.parser, None, self.overrides, self.fp)
- wrapper.write_functions(self, self.prefix)
-
- if not self.overrides.dynamicnamespace:
- self.write_enums()
- self.write_extension_init()
- self.write_registers()
-
- argtypes.py_ssize_t_clean = False
-
- def write_headers(self, py_ssize_t_clean):
- self.fp.write('/* -- THIS FILE IS GENERATED - DO NOT EDIT */')
- self.fp.write('/* -*- Mode: C; c-basic-offset: 4 -*- */\n\n')
- if py_ssize_t_clean:
- self.fp.write('#define PY_SSIZE_T_CLEAN\n')
- self.fp.write('#include <Python.h>\n\n\n')
- if py_ssize_t_clean:
- self.fp.write('''
-
-#if PY_VERSION_HEX < 0x02050000
-typedef int Py_ssize_t;
-#define PY_SSIZE_T_MAX INT_MAX
-#define PY_SSIZE_T_MIN INT_MIN
-typedef inquiry lenfunc;
-typedef intargfunc ssizeargfunc;
-typedef intobjargproc ssizeobjargproc;
-#endif
-
-''')
- self.fp.write(self.overrides.get_headers())
- self.fp.resetline()
- self.fp.write('\n\n')
-
- def write_imports(self):
- self.fp.write('/* ---------- types from other modules ---------- */\n')
- for module, pyname, cname, importing_for in self.overrides.get_imports():
- if importing_for is None or is_registered_object(importing_for):
- self.fp.write('static PyTypeObject *_%s;\n' % cname)
- self.fp.write('#define %s (*_%s)\n' % (cname, cname))
- self.fp.write('\n\n')
-
- def write_type_declarations(self):
- #todo use 'static' if used only in one file
- self.fp.write('/* ---------- forward type declarations ---------- */\n')
- for obj in self.parser.boxes:
- if not self.overrides.is_type_ignored(obj.c_name):
- self.fp.write('PyTypeObject G_GNUC_INTERNAL Py' + obj.c_name + '_Type;\n')
- for obj in self.parser.objects:
- if not self.overrides.is_type_ignored(obj.c_name):
- self.fp.write('PyTypeObject G_GNUC_INTERNAL Py' + obj.c_name + '_Type;\n')
- for interface in self.parser.interfaces:
- if not self.overrides.is_type_ignored(interface.c_name):
- self.fp.write('PyTypeObject G_GNUC_INTERNAL Py' + interface.c_name + '_Type;\n')
- self.fp.write('\n')
-
- def write_body(self):
- self.fp.write(self.overrides.get_body())
- self.fp.resetline()
- self.fp.write('\n\n')
-
- def _sort_parent_children(self, objects):
- objects = list(objects)
- modified = True
- while modified:
- modified = False
- parent_index = None
- child_index = None
- for i, obj in enumerate(objects):
- if obj.parent == 'GObject':
- continue
- if obj.parent not in [info.c_name for info in objects[:i]]:
- for j, info in enumerate(objects[i+1:]):
- if info.c_name == obj.parent:
- parent_index = i + 1 + j
- child_index = i
- break
- else:
- continue
- break
- if child_index is not None and parent_index is not None:
- if child_index != parent_index:
- objects.insert(child_index, objects.pop(parent_index))
- modified = True
- return objects
-
- def write_classes(self):
- ## Sort the objects, so that we generate code for the parent types
- ## before their children.
- objects = self._sort_parent_children(self.parser.objects)
-
- for klass, items in ((GBoxedWrapper, self.parser.boxes),
- (GPointerWrapper, self.parser.pointers),
- (GObjectWrapper, objects),
- (GInterfaceWrapper, self.parser.interfaces)):
- for item in items:
- instance = klass(self.parser, item, self.overrides, self.fp)
- instance.write_class()
- self.fp.write('\n')
-
- def get_enums(self):
- enums = []
- for enum in self.parser.enums:
- if self.overrides.is_type_ignored(enum.c_name):
- continue
- enums.append(enum)
- return enums
-
- def write_enums(self):
- if not self.parser.enums:
- return
-
- self.fp.write('\n/* ----------- enums and flags ----------- */\n\n')
- self.fp.write(
- 'void\n' + self.prefix +
- '_add_constants(PyObject *module, const gchar *strip_prefix)\n{\n')
-
- self.fp.write(
- '#ifdef VERSION\n'
- ' PyModule_AddStringConstant(module, "__version__", VERSION);\n'
- '#endif\n')
-
- for enum in self.get_enums():
- if enum.typecode is None:
- for nick, value in enum.values:
- self.fp.write(
- ' PyModule_AddIntConstant(module, '
- '(char *) pyg_constant_strip_prefix("%s", strip_prefix), %s);\n'
- % (value, value))
- else:
- if enum.deftype == 'enum':
- self.fp.write(' pyg_enum_add(module, "%s", strip_prefix, %s);\n'
- % (enum.name, enum.typecode))
- else:
- self.fp.write(' pyg_flags_add(module, "%s", strip_prefix, %s);\n'
- % (enum.name, enum.typecode))
-
- self.fp.write('\n')
- self.fp.write(' if (PyErr_Occurred())\n')
- self.fp.write(' PyErr_Print();\n')
- self.fp.write('}\n\n')
-
- def write_object_imports(self, retval=''):
- imports = self.overrides.get_imports()[:]
- if not imports:
- return
-
- bymod = {}
- for module, pyname, cname, importing_for in imports:
- if importing_for is None or is_registered_object(importing_for):
- bymod.setdefault(module, []).append((pyname, cname))
- self.fp.write(' PyObject *module;\n\n')
- for module in bymod:
- self.fp.write(
- ' if ((module = PyImport_ImportModule("%s")) != NULL) {\n'
- % module)
- #self.fp.write(
- # ' PyObject *moddict = PyModule_GetDict(module);\n\n')
- for pyname, cname in bymod[module]:
- #self.fp.write(
- # ' _%s = (PyTypeObject *)PyDict_GetItemString('
- # 'moddict, "%s");\n' % (cname, pyname))
- self.fp.write(
- ' _%s = (PyTypeObject *)PyObject_GetAttrString('
- 'module, "%s");\n' % (cname, pyname))
- self.fp.write(' if (_%s == NULL) {\n' % cname)
- self.fp.write(' PyErr_SetString(PyExc_ImportError,\n')
- self.fp.write(' "cannot import name %s from %s");\n'
- % (pyname, module))
- self.fp.write(' return %s;\n' % retval)
- self.fp.write(' }\n')
- self.fp.write(' } else {\n')
- self.fp.write(' PyErr_SetString(PyExc_ImportError,\n')
- self.fp.write(' "could not import %s");\n' % module)
- self.fp.write(' return %s;\n' % retval)
- self.fp.write(' }\n')
- self.fp.write('\n')
-
- def write_extension_init(self):
- self.fp.write('/* initialise stuff extension classes */\n')
- self.fp.write('void\n' + self.prefix + '_register_classes(PyObject *d)\n{\n')
- self.write_object_imports()
- self.fp.write(self.overrides.get_init() + '\n')
- self.fp.resetline()
-
- def get_classes(self):
- objects = self.parser.objects[:]
- pos = 0
- while pos < len(objects):
- parent = objects[pos].parent
- for i in range(pos+1, len(objects)):
- if objects[i].c_name == parent:
- objects.insert(i+1, objects[pos])
- del objects[pos]
- break
- else:
- pos = pos + 1
-
- retval = []
- for obj in objects:
- if self.overrides.is_type_ignored(obj.c_name):
- continue
- bases = []
- if obj.parent != None:
- bases.append(obj.parent)
- bases = bases + obj.implements
- retval.append((obj, bases))
-
- return retval
-
- def write_registers(self):
- for boxed in self.parser.boxes:
- if not self.overrides.is_type_ignored(boxed.c_name):
- self.fp.write(' pyg_register_boxed(d, "' + boxed.name +
- '", ' + boxed.typecode +
- ', &Py' + boxed.c_name +
- '_Type);\n')
- for pointer in self.parser.pointers:
- if not self.overrides.is_type_ignored(pointer.c_name):
- self.fp.write(' pyg_register_pointer(d, "' + pointer.name +
- '", ' + pointer.typecode +
- ', &Py' + pointer.c_name + '_Type);\n')
- for interface in self.parser.interfaces:
- if not self.overrides.is_type_ignored(interface.c_name):
- self.fp.write(' pyg_register_interface(d, "'
- + interface.name + '", '+ interface.typecode
- + ', &Py' + interface.c_name + '_Type);\n')
- if interface.interface_info is not None:
- self.fp.write(' pyg_register_interface_info(%s, &%s);\n' %
- (interface.typecode, interface.interface_info))
-
- if not self.overrides.dynamicnamespace:
- for obj, bases in self.get_classes():
- self.write_class(obj, bases)
- else:
- for obj, bases in self.get_classes():
- self.fp.write(
- ' pyg_type_register_custom_callback("%s", '
- '(PyGTypeRegistrationFunction)%s_register_type, d);\n' %
- (obj.c_name, obj.c_name))
-
- self.fp.write('}\n')
-
- def _can_direct_ref(self, base):
- if not self.overrides.dynamicnamespace:
- return True
- if base == 'GObject':
- return True
- obj = get_object_by_name(base)
- if obj.module.lower() != self.overrides.modulename:
- return True
- return False
-
- def write_class(self, obj, bases, indent=1):
- indent_str = ' ' * (indent * 4)
- if bases:
- bases_str = 'Py_BuildValue("(%s)"' % (len(bases) * 'O')
-
- for base in bases:
- if self._can_direct_ref(base):
- bases_str += ', &Py%s_Type' % base
- else:
- baseobj = get_object_by_name(base)
- bases_str += ', PyObject_GetAttrString(m, "%s")' % baseobj.name
- bases_str += ')'
- else:
- bases_str = 'NULL'
-
- self.fp.write(
- '%(indent)spygobject_register_class(d, "%(c_name)s", %(typecode)s, &Py%(c_name)s_Type, %(bases)s);\n'
- % dict(indent=indent_str, c_name=obj.c_name, typecode=obj.typecode, bases=bases_str))
-
- if obj.has_new_constructor_api:
- self.fp.write(
- indent_str + 'pyg_set_object_has_new_constructor(%s);\n' %
- obj.typecode)
- else:
- print >> sys.stderr, (
- "Warning: Constructor for %s needs to be updated to new API\n"
- " See http://live.gnome.org/PyGTK_2fWhatsNew28"
- "#update-constructors") % obj.c_name
-
- if obj.class_init_func is not None:
- self.fp.write(
- indent_str + 'pyg_register_class_init(%s, %s);\n' %
- (obj.typecode, obj.class_init_func))
-
-_objects = {}
-
-def is_registered_object(c_name):
- return c_name in _objects
-
-def get_object_by_name(c_name):
- global _objects
- return _objects[c_name]
-
-def register_types(parser):
- global _objects
- for boxed in parser.boxes:
- argtypes.matcher.register_boxed(boxed.c_name, boxed.typecode)
- _objects[boxed.c_name] = boxed
- for pointer in parser.pointers:
- argtypes.matcher.register_pointer(pointer.c_name, pointer.typecode)
- for obj in parser.objects:
- argtypes.matcher.register_object(obj.c_name, obj.parent, obj.typecode)
- _objects[obj.c_name] = obj
- for iface in parser.interfaces:
- argtypes.matcher.register_object(iface.c_name, None, iface.typecode)
- _objects[iface.c_name] = iface
- for enum in parser.enums:
- if enum.deftype == 'flags':
- argtypes.matcher.register_flag(enum.c_name, enum.typecode)
- else:
- argtypes.matcher.register_enum(enum.c_name, enum.typecode)
-
-usage = 'usage: codegen.py [-o overridesfile] [-p prefix] defsfile'
-def main(argv):
- o = override.Overrides()
- prefix = 'pygtk'
- outfilename = None
- errorfilename = None
- opts, args = getopt.getopt(argv[1:], "o:p:r:t:D:I:",
- ["override=", "prefix=", "register=", "outfilename=",
- "load-types=", "errorfilename=", "py_ssize_t-clean"])
- defines = {} # -Dkey[=val] options
- py_ssize_t_clean = False
- for opt, arg in opts:
- if opt in ('-o', '--override'):
- o = override.Overrides(arg)
- elif opt in ('-p', '--prefix'):
- prefix = arg
- elif opt in ('-r', '--register'):
- # Warning: user has to make sure all -D options appear before -r
- p = defsparser.DefsParser(arg, defines)
- p.startParsing()
- register_types(p)
- del p
- elif opt == '--outfilename':
- outfilename = arg
- elif opt == '--errorfilename':
- errorfilename = arg
- elif opt in ('-t', '--load-types'):
- globals = {}
- execfile(arg, globals)
- elif opt == '-D':
- nameval = arg.split('=')
- try:
- defines[nameval[0]] = nameval[1]
- except IndexError:
- defines[nameval[0]] = None
- elif opt == '-I':
- defsparser.include_path.insert(0, arg)
- elif opt == '--py_ssize_t-clean':
- py_ssize_t_clean = True
- if len(args) < 1:
- print >> sys.stderr, usage
- return 1
- if errorfilename:
- sys.stderr = open(errorfilename, "w")
- p = defsparser.DefsParser(args[0], defines)
- if not outfilename:
- outfilename = os.path.splitext(args[0])[0] + '.c'
-
- p.startParsing()
-
- register_types(p)
- sw = SourceWriter(p, o, prefix, FileOutput(sys.stdout, outfilename))
- sw.write(py_ssize_t_clean)
-
- functions_coverage.printstats()
- methods_coverage.printstats()
- vproxies_coverage.printstats()
- vaccessors_coverage.printstats()
- iproxies_coverage.printstats()
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
+++ /dev/null
-# -*- Mode: Python; py-indent-offset: 4 -*-
-import copy
-import sys
-
-def get_valid_scheme_definitions(defs):
- return [x for x in defs if isinstance(x, tuple) and len(x) >= 2]
-
-def unescape(s):
- s = s.replace('\r\n', '\\r\\n').replace('\t', '\\t')
- return s.replace('\r', '\\r').replace('\n', '\\n')
-
-def make_docstring(lines):
- return "(char *) " + '\n'.join(['"%s"' % unescape(s) for s in lines])
-
-# New Parameter class, wich emulates a tuple for compatibility reasons
-class Parameter(object):
- def __init__(self, ptype, pname, pdflt, pnull, pdir=None):
- self.ptype = ptype
- self.pname = pname
- self.pdflt = pdflt
- self.pnull = pnull
- self.pdir = pdir
-
- def __len__(self): return 4
- def __getitem__(self, i):
- return (self.ptype, self.pname, self.pdflt, self.pnull)[i]
-
- def merge(self, old):
- if old.pdflt is not None:
- self.pdflt = old.pdflt
- if old.pnull is not None:
- self.pnull = old.pnull
-
-# We currently subclass 'str' to make impact on the rest of codegen as
-# little as possible. Later we can subclass 'object' instead, but
-# then we must find and adapt all places which expect return types to
-# be strings.
-class ReturnType(str):
- def __new__(cls, *args, **kwds):
- return str.__new__(cls, *args[:1])
- def __init__(self, type_name, optional=False):
- str.__init__(self)
- self.optional = optional
-
-# Parameter for property based constructors
-class Property(object):
- def __init__(self, pname, optional, argname):
- self.pname = pname
- self.optional = optional
- self.argname = argname
-
- def __len__(self): return 4
- def __getitem__(self, i):
- return ('', self.pname, self.optional, self.argname)[i]
-
- def merge(self, old):
- if old.optional is not None:
- self.optional = old.optional
- if old.argname is not None:
- self.argname = old.argname
-
-
-class Definition(object):
- docstring = "NULL"
-
- def py_name(self):
- return '%s.%s' % (self.module, self.name)
-
- py_name = property(py_name)
-
- def __init__(self, *args):
- """Create a new defs object of this type. The arguments are the
- components of the definition"""
- raise RuntimeError("this is an abstract class")
-
- def merge(self, old):
- """Merge in customisations from older version of definition"""
- raise RuntimeError("this is an abstract class")
-
- def write_defs(self, fp=sys.stdout):
- """write out this definition in defs file format"""
- raise RuntimeError("this is an abstract class")
-
- def guess_return_value_ownership(self):
- "return 1 if caller owns return value"
- if getattr(self, 'is_constructor_of', False):
- self.caller_owns_return = True
- elif self.ret in ('char*', 'gchar*', 'string'):
- self.caller_owns_return = True
- else:
- self.caller_owns_return = False
-
-
-class ObjectDef(Definition):
- def __init__(self, name, *args):
- self.name = name
- self.module = None
- self.parent = None
- self.c_name = None
- self.typecode = None
- self.fields = []
- self.implements = []
- self.class_init_func = None
- self.has_new_constructor_api = False
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'in-module':
- self.module = arg[1]
- elif arg[0] == 'docstring':
- self.docstring = make_docstring(arg[1:])
- elif arg[0] == 'parent':
- self.parent = arg[1]
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'fields':
- for parg in arg[1:]:
- self.fields.append((parg[0], parg[1]))
- elif arg[0] == 'implements':
- self.implements.append(arg[1])
- def merge(self, old):
- # currently the .h parser doesn't try to work out what fields of
- # an object structure should be public, so we just copy the list
- # from the old version ...
- self.fields = old.fields
- self.implements = old.implements
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-object ' + self.name + '\n')
- if self.module:
- fp.write(' (in-module "' + self.module + '")\n')
- if self.parent != (None, None):
- fp.write(' (parent "' + self.parent + '")\n')
- for interface in self.implements:
- fp.write(' (implements "' + interface + '")\n')
- if self.c_name:
- fp.write(' (c-name "' + self.c_name + '")\n')
- if self.typecode:
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- if self.fields:
- fp.write(' (fields\n')
- for (ftype, fname) in self.fields:
- fp.write(' \'("' + ftype + '" "' + fname + '")\n')
- fp.write(' )\n')
- fp.write(')\n\n')
-
-class InterfaceDef(Definition):
- def __init__(self, name, *args):
- self.name = name
- self.module = None
- self.c_name = None
- self.typecode = None
- self.vtable = None
- self.fields = []
- self.interface_info = None
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'in-module':
- self.module = arg[1]
- elif arg[0] == 'docstring':
- self.docstring = make_docstring(arg[1:])
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'vtable':
- self.vtable = arg[1]
- if self.vtable is None:
- self.vtable = self.c_name + "Iface"
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-interface ' + self.name + '\n')
- if self.module:
- fp.write(' (in-module "' + self.module + '")\n')
- if self.c_name:
- fp.write(' (c-name "' + self.c_name + '")\n')
- if self.typecode:
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- fp.write(')\n\n')
-
-class EnumDef(Definition):
- def __init__(self, name, *args):
- self.deftype = 'enum'
- self.name = name
- self.in_module = None
- self.c_name = None
- self.typecode = None
- self.values = []
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'in-module':
- self.in_module = arg[1]
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'values':
- for varg in arg[1:]:
- self.values.append((varg[0], varg[1]))
- def merge(self, old):
- pass
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-' + self.deftype + ' ' + self.name + '\n')
- if self.in_module:
- fp.write(' (in-module "' + self.in_module + '")\n')
- fp.write(' (c-name "' + self.c_name + '")\n')
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- if self.values:
- fp.write(' (values\n')
- for name, val in self.values:
- fp.write(' \'("' + name + '" "' + val + '")\n')
- fp.write(' )\n')
- fp.write(')\n\n')
-
-class FlagsDef(EnumDef):
- def __init__(self, *args):
- apply(EnumDef.__init__, (self,) + args)
- self.deftype = 'flags'
-
-class BoxedDef(Definition):
- def __init__(self, name, *args):
- self.name = name
- self.module = None
- self.c_name = None
- self.typecode = None
- self.copy = None
- self.release = None
- self.fields = []
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'in-module':
- self.module = arg[1]
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'copy-func':
- self.copy = arg[1]
- elif arg[0] == 'release-func':
- self.release = arg[1]
- elif arg[0] == 'fields':
- for parg in arg[1:]:
- self.fields.append((parg[0], parg[1]))
- def merge(self, old):
- # currently the .h parser doesn't try to work out what fields of
- # an object structure should be public, so we just copy the list
- # from the old version ...
- self.fields = old.fields
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-boxed ' + self.name + '\n')
- if self.module:
- fp.write(' (in-module "' + self.module + '")\n')
- if self.c_name:
- fp.write(' (c-name "' + self.c_name + '")\n')
- if self.typecode:
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- if self.copy:
- fp.write(' (copy-func "' + self.copy + '")\n')
- if self.release:
- fp.write(' (release-func "' + self.release + '")\n')
- if self.fields:
- fp.write(' (fields\n')
- for (ftype, fname) in self.fields:
- fp.write(' \'("' + ftype + '" "' + fname + '")\n')
- fp.write(' )\n')
- fp.write(')\n\n')
-
-class PointerDef(Definition):
- def __init__(self, name, *args):
- self.name = name
- self.module = None
- self.c_name = None
- self.typecode = None
- self.fields = []
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'in-module':
- self.module = arg[1]
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'fields':
- for parg in arg[1:]:
- self.fields.append((parg[0], parg[1]))
- def merge(self, old):
- # currently the .h parser doesn't try to work out what fields of
- # an object structure should be public, so we just copy the list
- # from the old version ...
- self.fields = old.fields
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-pointer ' + self.name + '\n')
- if self.module:
- fp.write(' (in-module "' + self.module + '")\n')
- if self.c_name:
- fp.write(' (c-name "' + self.c_name + '")\n')
- if self.typecode:
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- if self.fields:
- fp.write(' (fields\n')
- for (ftype, fname) in self.fields:
- fp.write(' \'("' + ftype + '" "' + fname + '")\n')
- fp.write(' )\n')
- fp.write(')\n\n')
-
-class MethodDefBase(Definition):
- def __init__(self, name, *args):
- dump = 0
- self.name = name
- self.ret = None
- self.caller_owns_return = None
- self.unblock_threads = None
- self.c_name = None
- self.typecode = None
- self.of_object = None
- self.params = [] # of form (type, name, default, nullok)
- self.varargs = 0
- self.deprecated = None
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'of-object':
- self.of_object = arg[1]
- elif arg[0] == 'docstring':
- self.docstring = make_docstring(arg[1:])
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'return-type':
- type_name = arg[1]
- optional = False
- for prop in arg[2:]:
- if prop[0] == 'optional':
- optional = True
- self.ret = ReturnType(type_name, optional)
- elif arg[0] == 'caller-owns-return':
- self.caller_owns_return = arg[1] in ('t', '#t')
- elif arg[0] == 'unblock-threads':
- self.unblock_threads = arg[1] in ('t', '#t')
- elif arg[0] == 'parameters':
- for parg in arg[1:]:
- ptype = parg[0]
- pname = parg[1]
- pdflt = None
- pnull = 0
- pdir = None
- 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))
- elif arg[0] == 'varargs':
- self.varargs = arg[1] in ('t', '#t')
- elif arg[0] == 'deprecated':
- self.deprecated = arg[1]
- else:
- sys.stderr.write("Warning: %s argument unsupported.\n"
- % (arg[0]))
- dump = 1
- if dump:
- self.write_defs(sys.stderr)
-
- if self.caller_owns_return is None and self.ret is not None:
- self.guess_return_value_ownership()
-
- def merge(self, old, parmerge):
- self.caller_owns_return = old.caller_owns_return
- self.varargs = old.varargs
- # here we merge extra parameter flags accross to the new object.
- if not parmerge:
- self.params = copy.deepcopy(old.params)
- return
- for i in range(len(self.params)):
- ptype, pname, pdflt, pnull = self.params[i]
- for p2 in old.params:
- if p2[1] == pname:
- self.params[i] = (ptype, pname, p2[2], p2[3])
- break
- def _write_defs(self, fp=sys.stdout):
- if self.of_object != (None, None):
- fp.write(' (of-object "' + self.of_object + '")\n')
- if self.c_name:
- fp.write(' (c-name "' + self.c_name + '")\n')
- if self.typecode:
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- if self.caller_owns_return:
- fp.write(' (caller-owns-return #t)\n')
- if self.unblock_threads:
- fp.write(' (unblock_threads #t)\n')
- if self.ret:
- fp.write(' (return-type "' + self.ret + '")\n')
- if self.deprecated:
- fp.write(' (deprecated "' + self.deprecated + '")\n')
- if self.params:
- fp.write(' (parameters\n')
- for ptype, pname, pdflt, pnull in self.params:
- fp.write(' \'("' + ptype + '" "' + pname +'"')
- if pdflt: fp.write(' (default "' + pdflt + '")')
- if pnull: fp.write(' (null-ok)')
- fp.write(')\n')
- fp.write(' )\n')
- if self.varargs:
- fp.write(' (varargs #t)\n')
- fp.write(')\n\n')
-
-
-class MethodDef(MethodDefBase):
- def __init__(self, name, *args):
- MethodDefBase.__init__(self, name, *args)
- for item in ('c_name', 'of_object'):
- if self.__dict__[item] == None:
- self.write_defs(sys.stderr)
- raise RuntimeError("definition missing required %s" % (item,))
-
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-method ' + self.name + '\n')
- self._write_defs(fp)
-
-class VirtualDef(MethodDefBase):
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-virtual ' + self.name + '\n')
- self._write_defs(fp)
-
-class FunctionDef(Definition):
- def __init__(self, name, *args):
- dump = 0
- self.name = name
- self.in_module = None
- self.is_constructor_of = None
- self.ret = None
- self.caller_owns_return = None
- self.unblock_threads = None
- self.c_name = None
- self.typecode = None
- self.params = [] # of form (type, name, default, nullok)
- self.varargs = 0
- self.deprecated = None
- for arg in get_valid_scheme_definitions(args):
- if arg[0] == 'in-module':
- self.in_module = arg[1]
- elif arg[0] == 'docstring':
- self.docstring = make_docstring(arg[1:])
- elif arg[0] == 'is-constructor-of':
- self.is_constructor_of = arg[1]
- elif arg[0] == 'c-name':
- self.c_name = arg[1]
- elif arg[0] == 'gtype-id':
- self.typecode = arg[1]
- elif arg[0] == 'return-type':
- self.ret = arg[1]
- elif arg[0] == 'caller-owns-return':
- self.caller_owns_return = arg[1] in ('t', '#t')
- elif arg[0] == 'unblock-threads':
- self.unblock_threads = arg[1] in ('t', '#t')
- elif arg[0] == 'parameters':
- for parg in arg[1:]:
- ptype = parg[0]
- pname = parg[1]
- pdflt = None
- pnull = 0
- for farg in parg[2:]:
- if farg[0] == 'default':
- pdflt = farg[1]
- elif farg[0] == 'null-ok':
- pnull = 1
- self.params.append(Parameter(ptype, pname, pdflt, pnull))
- elif arg[0] == 'properties':
- if self.is_constructor_of is None:
- print >> sys.stderr, "Warning: (properties ...) "\
- "is only valid for constructors"
- for prop in arg[1:]:
- pname = prop[0]
- optional = False
- argname = pname
- for farg in prop[1:]:
- if farg[0] == 'optional':
- optional = True
- elif farg[0] == 'argname':
- argname = farg[1]
- self.params.append(Property(pname, optional, argname))
- elif arg[0] == 'varargs':
- self.varargs = arg[1] in ('t', '#t')
- elif arg[0] == 'deprecated':
- self.deprecated = arg[1]
- else:
- sys.stderr.write("Warning: %s argument unsupported\n"
- % (arg[0],))
- dump = 1
- if dump:
- self.write_defs(sys.stderr)
-
- if self.caller_owns_return is None and self.ret is not None:
- self.guess_return_value_ownership()
- for item in ('c_name',):
- if self.__dict__[item] == None:
- self.write_defs(sys.stderr)
- raise RuntimeError("definition missing required %s" % (item,))
-
- _method_write_defs = MethodDef.__dict__['write_defs']
-
- def merge(self, old, parmerge):
- self.caller_owns_return = old.caller_owns_return
- self.varargs = old.varargs
- if not parmerge:
- self.params = copy.deepcopy(old.params)
- return
- # here we merge extra parameter flags accross to the new object.
- def merge_param(param):
- for old_param in old.params:
- if old_param.pname == param.pname:
- if isinstance(old_param, Property):
- # h2def never scans Property's, therefore if
- # we have one it was manually written, so we
- # keep it.
- return copy.deepcopy(old_param)
- else:
- param.merge(old_param)
- return param
- raise RuntimeError("could not find %s in old_parameters %r" % (
- param.pname, [p.pname for p in old.params]))
- try:
- self.params = map(merge_param, self.params)
- except RuntimeError:
- # parameter names changed and we can't find a match; it's
- # safer to keep the old parameter list untouched.
- self.params = copy.deepcopy(old.params)
-
- if not self.is_constructor_of:
- try:
- self.is_constructor_of = old.is_constructor_of
- except AttributeError:
- pass
- if isinstance(old, MethodDef):
- self.name = old.name
- # transmogrify from function into method ...
- self.write_defs = self._method_write_defs
- self.of_object = old.of_object
- del self.params[0]
- def write_defs(self, fp=sys.stdout):
- fp.write('(define-function ' + self.name + '\n')
- if self.in_module:
- fp.write(' (in-module "' + self.in_module + '")\n')
- if self.is_constructor_of:
- fp.write(' (is-constructor-of "' + self.is_constructor_of +'")\n')
- if self.c_name:
- fp.write(' (c-name "' + self.c_name + '")\n')
- if self.typecode:
- fp.write(' (gtype-id "' + self.typecode + '")\n')
- if self.caller_owns_return:
- fp.write(' (caller-owns-return #t)\n')
- if self.unblock_threads:
- fp.write(' (unblock-threads #t)\n')
- if self.ret:
- fp.write(' (return-type "' + self.ret + '")\n')
- if self.deprecated:
- fp.write(' (deprecated "' + self.deprecated + '")\n')
- if self.params:
- if isinstance(self.params[0], Parameter):
- fp.write(' (parameters\n')
- for ptype, pname, pdflt, pnull in self.params:
- fp.write(' \'("' + ptype + '" "' + pname +'"')
- if pdflt: fp.write(' (default "' + pdflt + '")')
- if pnull: fp.write(' (null-ok)')
- fp.write(')\n')
- fp.write(' )\n')
- elif isinstance(self.params[0], Property):
- fp.write(' (properties\n')
- for prop in self.params:
- fp.write(' \'("' + prop.pname +'"')
- if prop.optional: fp.write(' (optional)')
- fp.write(')\n')
- fp.write(' )\n')
- else:
- assert False, "strange parameter list %r" % self.params[0]
- if self.varargs:
- fp.write(' (varargs #t)\n')
-
- fp.write(')\n\n')
+++ /dev/null
-# -*- Mode: Python; py-indent-offset: 4 -*-
-import os, sys
-import scmexpr
-from definitions import BoxedDef, EnumDef, FlagsDef, FunctionDef, \
- InterfaceDef, MethodDef, ObjectDef, PointerDef, VirtualDef
-
-include_path = ['.']
-
-class IncludeParser(scmexpr.Parser):
- """A simple parser that follows include statements automatically"""
- def include(self, input_filename):
- global include_path
- if os.path.isabs(input_filename):
- filename = input_filename
- # set self.filename to the include name, to handle recursive includes
- oldfile = self.filename
- self.filename = filename
- self.startParsing()
- self.filename = oldfile
- else:
- inc_path = [os.path.dirname(self.filename)] + include_path
- for filename in [os.path.join(path_entry, input_filename)
- for path_entry in inc_path]:
- if not os.path.exists(filename):
- continue
- # set self.filename to the include name, to handle recursive includes
- oldfile = self.filename
- self.filename = filename
- self.startParsing()
- self.filename = oldfile
- break
- else:
- raise IOError("%s not found in include path %s" % (input_filename, inc_path))
-
-class DefsParser(IncludeParser):
- def __init__(self, arg, defines={}):
- IncludeParser.__init__(self, arg)
- self.objects = []
- self.interfaces = []
- self.enums = [] # enums and flags
- self.boxes = [] # boxed types
- self.pointers = [] # pointer types
- self.functions = [] # functions and methods
- self.virtuals = [] # virtual methods
- self.c_name = {} # hash of c names of functions
- self.methods = {} # hash of methods of particular objects
- self.defines = defines # -Dfoo=bar options, as dictionary
-
- def define_object(self, *args):
- odef = apply(ObjectDef, args)
- self.objects.append(odef)
- self.c_name[odef.c_name] = odef
- def define_interface(self, *args):
- idef = apply(InterfaceDef, args)
- self.interfaces.append(idef)
- self.c_name[idef.c_name] = idef
- def define_enum(self, *args):
- edef = apply(EnumDef, args)
- self.enums.append(edef)
- self.c_name[edef.c_name] = edef
- def define_flags(self, *args):
- fdef = apply(FlagsDef, args)
- self.enums.append(fdef)
- self.c_name[fdef.c_name] = fdef
- def define_boxed(self, *args):
- bdef = apply(BoxedDef, args)
- self.boxes.append(bdef)
- self.c_name[bdef.c_name] = bdef
- def define_pointer(self, *args):
- pdef = apply(PointerDef, args)
- self.pointers.append(pdef)
- self.c_name[pdef.c_name] = pdef
- def define_function(self, *args):
- fdef = apply(FunctionDef, args)
- self.functions.append(fdef)
- self.c_name[fdef.c_name] = fdef
- def define_method(self, *args):
- mdef = apply(MethodDef, args)
- self.functions.append(mdef)
- self.c_name[mdef.c_name] = mdef
- def define_virtual(self, *args):
- vdef = apply(VirtualDef, args)
- self.virtuals.append(vdef)
- def merge(self, old, parmerge):
- for obj in self.objects:
- if old.c_name.has_key(obj.c_name):
- obj.merge(old.c_name[obj.c_name])
- for f in self.functions:
- if old.c_name.has_key(f.c_name):
- f.merge(old.c_name[f.c_name], parmerge)
-
- def printMissing(self, old):
- for obj in self.objects:
- if not old.c_name.has_key(obj.c_name):
- obj.write_defs()
- for f in self.functions:
- if not old.c_name.has_key(f.c_name):
- f.write_defs()
-
- def write_defs(self, fp=sys.stdout):
- for obj in self.objects:
- obj.write_defs(fp)
- for enum in self.enums:
- enum.write_defs(fp)
- for boxed in self.boxes:
- boxed.write_defs(fp)
- for pointer in self.pointers:
- pointer.write_defs(fp)
- for func in self.functions:
- func.write_defs(fp)
-
- def find_object(self, c_name):
- for obj in self.objects:
- if obj.c_name == c_name:
- return obj
- else:
- raise ValueError('object %r not found' % c_name)
-
- def find_constructor(self, obj, overrides):
- for func in self.functions:
- if isinstance(func, FunctionDef) and \
- func.is_constructor_of == obj.c_name and \
- not overrides.is_ignored(func.c_name):
- return func
-
- def find_methods(self, obj):
- objname = obj.c_name
- return filter(lambda func, on=objname: isinstance(func, MethodDef) and
- func.of_object == on, self.functions)
-
- def find_virtuals(self, obj):
- objname = obj.c_name
- retval = filter(lambda func, on=objname: isinstance(func, VirtualDef) and
- func.of_object == on, self.virtuals)
- return retval
-
- def find_functions(self):
- return filter(lambda func: isinstance(func, FunctionDef) and
- not func.is_constructor_of, self.functions)
-
- def ifdef(self, *args):
- if args[0] in self.defines:
- for arg in args[1:]:
- #print >> sys.stderr, "-----> Handling conditional definition (%s): %s" % (args[0], arg)
- self.handle(arg)
- else:
- pass
- #print >> sys.stderr, "-----> Conditional %s is not true" % (args[0],)
-
- def ifndef(self, *args):
- if args[0] not in self.defines:
- for arg in args[1:]:
- self.handle(arg)
+++ /dev/null
-# -*- Mode: Python; py-indent-offset: 4 -*-
-'''Simple module for extracting GNOME style doc comments from C
-sources, so I can use them for other purposes.'''
-
-import sys, os, string, re
-
-# Used to tell if the "Since: ..." portion of the gtkdoc function description
-# should be omitted. This is useful for some C++ modules such as gstreamermm
-# that wrap C API which is still unstable and including this information would
-# not be useful.
-# This variable is modified from docextract_to_xml based on the --no-since
-# option being specified.
-no_since = False
-
-__all__ = ['extract']
-
-class GtkDoc:
- def __init__(self):
- self.name = None
- self.block_type = '' # The block type ('function', 'signal', 'property')
- self.params = []
- self.annotations = []
- self.description = ''
- self.ret = ('', []) # (return, annotations)
- def set_name(self, name):
- self.name = name
- def set_type(self, block_type):
- self.block_type = block_type
- def get_type(self):
- return self.block_type
- def add_param(self, name, description, annotations=[]):
- if name == '...':
- name = 'Varargs'
- self.params.append((name, description, annotations))
- def append_to_last_param(self, extra):
- self.params[-1] = (self.params[-1][0], self.params[-1][1] + extra,
- self.params[-1][2])
- def append_to_named_param(self, name, extra):
- for i in range(len(self.params)):
- if self.params[i][0] == name:
- self.params[i] = (name, self.params[i][1] + extra,
- self.params[i][2])
- return
- # fall through to adding extra parameter ...
- self.add_param(name, extra)
- def add_annotation(self, annotation):
- self.annotations.append(annotation)
- def get_annotations(self):
- return self.annotations
- def append_to_description(self, extra):
- self.description = self.description + extra
- def get_description(self):
- return self.description
- def add_return(self, first_line, annotations=[]):
- self.ret = (first_line, annotations)
- def append_to_return(self, extra):
- self.ret = (self.ret[0] + extra, self.ret[1])
-
-comment_start_pattern = re.compile(r'^\s*/\*\*\s')
-comment_end_pattern = re.compile(r'^\s*\*+/')
-comment_line_lead_pattern = re.compile(r'^\s*\*\s*')
-comment_empty_line_pattern = re.compile(r'^\s*\**\s*$')
-function_name_pattern = re.compile(r'^([a-z]\w*)\s*:?(\s*\(.*\)\s*){0,2}\s*$')
-signal_name_pattern = re.compile(r'^([A-Z]\w+::[a-z0-9-]+)\s*:?(\s*\(.*\)\s*){0,2}\s*$')
-property_name_pattern = re.compile(r'^([A-Z]\w+:[a-z0-9-]+)\s*:?(\s*\(.*\)\s*){0,2}\s*$')
-return_pattern = re.compile(r'^@?(returns:|return\s+value:)(.*\n?)$', re.IGNORECASE)
-deprecated_pattern = re.compile(r'^(deprecated\s*:\s*.*\n?)$', re.IGNORECASE)
-rename_to_pattern = re.compile(r'^(rename\s+to)\s*:\s*(.*\n?)$', re.IGNORECASE)
-param_pattern = re.compile(r'^@(\S+)\s*:(.*\n?)$')
-# Used to extract the annotations in the parameter and return descriptions
-# extracted using above [param|return]_pattern patterns.
-annotations_pattern = re.compile(r'^(?:(\s*\(.*\)\s*)*:)')
-# Used to construct the annotation lists.
-annotation_lead_pattern = re.compile(r'^\s*\(\s*(.*?)\s*\)\s*')
-
-# These patterns determine the identifier of the current comment block. They
-# are grouped in a list for easy determination of block identifiers (in
-# skip_to_identifier). The function_name_pattern should be tested for last
-# because it always matches signal and property identifiers.
-identifier_patterns = [ signal_name_pattern, property_name_pattern, function_name_pattern ]
-
-# This pattern is to match return sections that forget to have a colon (':')
-# after the initial 'Return' phrase. It is not included by default in the list
-# of final sections below because a lot of function descriptions begin with
-# 'Returns ...' and the process_description() function would stop right at that
-# first line, thinking it is a return section.
-no_colon_return_pattern = re.compile(r'^@?(returns|return\s+value)\s*(.*\n?)$', re.IGNORECASE)
-since_pattern = re.compile(r'^(since\s*:\s*.*\n?)$', re.IGNORECASE)
-
-# These patterns normally will be encountered after the description. Knowing
-# the order of their appearance is difficult so this list is used to test when
-# one begins and the other ends when processing the rest of the sections after
-# the description.
-final_section_patterns = [ return_pattern, since_pattern, deprecated_pattern, rename_to_pattern ]
-
-def parse_file(fp, doc_dict):
- line = fp.readline()
- while line:
- cur_doc = GtkDoc()
- line = skip_to_comment_block(fp, line)
- line = skip_to_identifier(fp, line, cur_doc)
- # See if the identifier is found (stored in the current GtkDoc by
- # skip_to_identifier). If so, continue reading the rest of the comment
- # block.
- if cur_doc.name:
- line = process_params(fp, line, cur_doc)
- line = process_description(fp, line, cur_doc)
- line = process_final_sections(fp, line, cur_doc)
- # Add the current doc block to the dictionary of doc blocks.
- doc_dict[cur_doc.name] = cur_doc
-
-# Given a list of annotations as string of the form
-# '(annotation1) (annotation2) ...' return a list of annotations of the form
-# [ (name1, value1), (name2, value2) ... ]. Not all annotations have values so
-# the values in the list of tuples could be empty ('').
-def get_annotation_list(annotations):
- annotation_list = []
- while annotations:
- match = annotation_lead_pattern.match(annotations)
- if match:
- annotation_contents = match.group(1)
- name, split, value = annotation_contents.strip().partition(' ')
- annotation_list.append((name, value))
- # Remove first occurrence to continue processing.
- annotations = annotation_lead_pattern.sub('', annotations)
- else:
- break
- return annotation_list
-
-# Given a currently read line, test that line and continue reading until the
-# beginning of a comment block is found or eof is reached. Return the last
-# read line.
-def skip_to_comment_block(fp, line):
- while line:
- if comment_start_pattern.match(line):
- break
- line = fp.readline()
- return line
-
-# Given the current line in a comment block, continue skipping lines until a
-# non-blank line in the comment block is found or until the end of the block
-# (or eof) is reached. Returns the line where reading stopped.
-def skip_to_nonblank(fp, line):
- while line:
- if not comment_empty_line_pattern.match(line):
- break
- line = fp.readline()
- # Stop processing if eof or end of comment block is reached.
- if not line or comment_end_pattern.match(line):
- break
- return line
-
-# Given the first line of a comment block (the '/**'), see if the next
-# non-blank line is the identifier of the comment block. Stop processing if
-# the end of the block or eof is reached. Store the identifier (if there is
-# one) and its type ('function', 'signal' or 'property') in the given GtkDoc.
-# Return the line where the identifier is found or the line that stops the
-# processing (if eof or the end of the comment block is found first).
-def skip_to_identifier(fp, line, cur_doc):
- # Skip the initial comment block line ('/**') if not eof.
- if line: line = fp.readline()
-
- # Now skip empty lines.
- line = skip_to_nonblank(fp, line)
-
- # See if the first non-blank line is the identifier.
- if line and not comment_end_pattern.match(line):
- # Remove the initial ' * ' in comment block line and see if there is an
- # identifier.
- line = comment_line_lead_pattern.sub('', line)
- for pattern in identifier_patterns:
- match = pattern.match(line)
- if match:
- # Set the GtkDoc name.
- cur_doc.set_name(match.group(1))
- # Get annotations and add them to the GtkDoc.
- annotations = get_annotation_list(match.group(2))
- for annotation in annotations:
- cur_doc.add_annotation(annotation)
- # Set the GtkDoc type.
- if pattern == signal_name_pattern:
- cur_doc.set_type('signal')
- elif pattern == property_name_pattern:
- cur_doc.set_type('property')
- elif pattern == function_name_pattern:
- cur_doc.set_type('function')
- return line
- return line
-
-# Given a currently read line (presumably the identifier line), read the next
-# lines, testing to see if the lines are part of parameter descriptions. If
-# so, store the parameter descriptions in the given doc block. Stop on eof and
-# return the last line that stops the processing.
-def process_params(fp, line, cur_doc):
- # Skip the identifier line if not eof. Also skip any blank lines in the
- # comment block. Return if eof or the end of the comment block are
- # encountered.
- if line: line = fp.readline()
- line = skip_to_nonblank(fp, line)
- if not line or comment_end_pattern.match(line):
- return line
-
- # Remove initial ' * ' in first non-empty comment block line.
- line = comment_line_lead_pattern.sub('', line)
-
- # Now process possible parameters as long as no eof or the end of the
- # param section is not reached (which could be triggered by anything that
- # doesn't match a '@param:..." line, even the end of the comment block).
- match = param_pattern.match(line)
- while line and match:
- description = match.group(2)
-
- # First extract the annotations from the description and save them.
- annotations = []
- annotation_match = annotations_pattern.match(description)
- if annotation_match:
- annotations = get_annotation_list(annotation_match.group(1))
- # Remove the annotations from the description
- description = annotations_pattern.sub('', description)
-
- # Default to appending lines to current parameter.
- append_func = cur_doc.append_to_last_param
-
- # See if the return has been included as part of the parameter
- # section and make sure that lines are added to the GtkDoc return if
- # so.
- if match.group(1).lower() == "returns":
- cur_doc.add_return(description, annotations)
- append_func = cur_doc.append_to_return
- # If not, just add it as a regular parameter.
- else:
- cur_doc.add_param(match.group(1), description, annotations)
-
- # Now read lines and append them until next parameter, beginning of
- # description (an empty line), the end of the comment block or eof.
- line = fp.readline()
- while line:
- # Stop processing if end of comment block or a blank comment line
- # is encountered.
- if comment_empty_line_pattern.match(line) or \
- comment_end_pattern.match(line):
- break
-
- # Remove initial ' * ' in comment block line.
- line = comment_line_lead_pattern.sub('', line)
-
- # Break from current param processing if a new one is
- # encountered.
- if param_pattern.match(line): break;
-
- # Otherwise, just append the current line and get the next line.
- append_func(line)
- line = fp.readline()
-
- # Re-evaluate match for while condition
- match = param_pattern.match(line)
-
- # End by returning the current line.
- return line
-
-# Having processed parameters, read the following lines into the description of
-# the current doc block until the end of the comment block, the end of file or
-# a return section is encountered.
-def process_description(fp, line, cur_doc):
- # First skip empty lines returning on eof or end of comment block.
- line = skip_to_nonblank(fp, line)
- if not line or comment_end_pattern.match(line):
- return line
-
- # Remove initial ' * ' in non-empty comment block line.
- line = comment_line_lead_pattern.sub('', line)
-
- # Also remove possible 'Description:' prefix.
- if line[:12] == 'Description:': line = line[12:]
-
- # Used to tell if the previous line was blank and a return section
- # uncommonly marked with 'Returns ...' instead of 'Returns: ...' has
- # started (assume it is non-empty to begin with).
- prev_line = 'non-empty'
-
- # Now read lines until a new section (like a return or a since section) is
- # encountered.
- while line:
- # See if the description section has ended (if the line begins with
- # 'Returns ...' and the previous line was empty -- this loop replaces
- # empty lines with a newline).
- if no_colon_return_pattern.match(line) and prev_line == '\n':
- return line
- # Or if one of the patterns of the final sections match
- for pattern in final_section_patterns:
- if pattern.match(line):
- return line
-
- # If not, append lines to description in the doc comment block.
- cur_doc.append_to_description(line)
-
- prev_line = line
- line = fp.readline()
-
- # Stop processing on eof or at the end of comment block.
- if not line or comment_end_pattern.match(line):
- return line
-
- # Remove initial ' * ' in line so that the text can be appended to the
- # description of the comment block and make sure that if the line is
- # empty it be interpreted as a newline.
- line = comment_line_lead_pattern.sub('', line)
- if not line: line = '\n'
-
-# Given the line that ended the description (the first line of one of the final
-# sections) process the final sections ('Returns:', 'Since:', etc.) until the
-# end of the comment block or eof. Return the line that ends the processing.
-def process_final_sections(fp, line, cur_doc):
- while line and not comment_end_pattern.match(line):
- # Remove leading ' * ' from current non-empty comment line.
- line = comment_line_lead_pattern.sub('', line)
- # Temporarily append the no colon return pattern to the final section
- # patterns now that the description has been processed. It will be
- # removed after the for loop below executes so that future descriptions
- # that begin with 'Returns ...' are not interpreted as a return
- # section.
- final_section_patterns.append(no_colon_return_pattern)
- for pattern in final_section_patterns:
- match = pattern.match(line)
- if match:
- if pattern == return_pattern or \
- pattern == no_colon_return_pattern:
- # Dealing with a 'Returns:' so first extract the
- # annotations from the description and save them.
- description = match.group(2)
- annotations = []
- annotation_match = \
- annotations_pattern.match(description)
- if annotation_match:
- annotations = \
- get_annotation_list(annotation_match.group(1))
- # Remove the annotations from the description
- description = annotations_pattern.sub('', description)
-
- # Now add the return.
- cur_doc.add_return(description, annotations)
- # In case more lines need to be appended.
- append_func = cur_doc.append_to_return
- elif pattern == rename_to_pattern:
- # Dealing with a 'Rename to:' section (GObjectIntrospection
- # annotation) so no further lines will be appended but this
- # single one (and only to the annotations).
- append_func = None
- cur_doc.add_annotation((match.group(1),
- match.group(2)))
- else:
- # For all others ('Since:' and 'Deprecated:') just append
- # the line to the description for now.
- # But if --no-since is specified, don't append it.
- if no_since and pattern == since_pattern:
- pass
- else:
- cur_doc.append_to_description(line)
-
- # In case more lines need to be appended.
- append_func = cur_doc.append_to_description
-
- # Stop final section pattern matching for loop since a match
- # has already been found.
- break
-
- # Remove the no colon return pattern (which was temporarily added in
- # the just executed loop) from the list of final section patterns.
- final_section_patterns.pop()
-
- line = fp.readline()
-
- # Now continue appending lines to current section until a new one is
- # found or an eof or the end of the comment block is encountered.
- finished = False
- while not finished and line and \
- not comment_end_pattern.match(line):
- # Remove leading ' * ' from line and make sure that if it is empty,
- # it be interpreted as a newline.
- line = comment_line_lead_pattern.sub('', line)
- if not line: line = '\n'
-
- for pattern in final_section_patterns:
- if pattern.match(line):
- finished = True
- break
-
- # Break out of loop if a new section is found (determined in above
- # inner loop).
- if finished: break
-
- # Now it's safe to append line.
- if append_func: append_func(line)
-
- # Get the next line to continue processing.
- line = fp.readline()
-
- return line
-
-def parse_dir(dir, doc_dict):
- for file in os.listdir(dir):
- if file in ('.', '..'): continue
- path = os.path.join(dir, file)
- if os.path.isdir(path):
- parse_dir(path, doc_dict)
- if len(file) > 2 and file[-2:] == '.c':
- sys.stderr.write("Processing " + path + '\n')
- parse_file(open(path, 'r'), doc_dict)
-
-def extract(dirs, doc_dict=None):
- if not doc_dict: doc_dict = {}
- for dir in dirs:
- parse_dir(dir, doc_dict)
- return doc_dict
-
-tmpl_section_pattern = re.compile(r'^<!-- ##### (\w+) (\w+) ##### -->$')
-def parse_tmpl(fp, doc_dict):
- cur_doc = None
-
- line = fp.readline()
- while line:
- match = tmpl_section_pattern.match(line)
- if match:
- cur_doc = None # new input shouldn't affect the old doc dict
- sect_type = match.group(1)
- sect_name = match.group(2)
-
- if sect_type == 'FUNCTION':
- cur_doc = doc_dict.get(sect_name)
- if not cur_doc:
- cur_doc = GtkDoc()
- cur_doc.set_name(sect_name)
- doc_dict[sect_name] = cur_doc
- elif line == '<!-- # Unused Parameters # -->\n':
- cur_doc = None # don't worry about unused params.
- elif cur_doc:
- if line[:10] == '@Returns: ':
- if string.strip(line[10:]):
- cur_doc.append_to_return(line[10:])
- elif line[0] == '@':
- pos = string.find(line, ':')
- if pos >= 0:
- cur_doc.append_to_named_param(line[1:pos], line[pos+1:])
- else:
- cur_doc.append_to_description(line)
- else:
- cur_doc.append_to_description(line)
-
- line = fp.readline()
-
-def extract_tmpl(dirs, doc_dict=None):
- if not doc_dict: doc_dict = {}
- for dir in dirs:
- for file in os.listdir(dir):
- if file in ('.', '..'): continue
- path = os.path.join(dir, file)
- if os.path.isdir(path):
- continue
- if len(file) > 2 and file[-2:] == '.sgml':
- parse_tmpl(open(path, 'r'), doc_dict)
- return doc_dict
+++ /dev/null
-#!/usr/bin/env python
-import getopt
-import os
-import re
-import sys
-
-import definitions
-import defsparser
-import docextract
-import override
-
-
-class Node:
-
- def __init__(self, name, interfaces=[]):
- self.name = name
- self.interfaces = interfaces
- self.subclasses = []
-
- def add_child(self, node):
- self.subclasses.append(node)
-
-
-def build_object_tree(parser):
- # reorder objects so that parent classes come first ...
- objects = parser.objects[:]
- pos = 0
- while pos < len(objects):
- parent = objects[pos].parent
- for i in range(pos+1, len(objects)):
- if objects[i].c_name == parent:
- objects.insert(i+1, objects[pos])
- del objects[pos]
- break
- else:
- pos = pos + 1
-
- root = Node(None)
- nodes = {None: root}
- for obj_def in objects:
- parent_name = obj_def.parent
- if parent_name == 'GObject':
- parent_name = None
- parent_node = nodes[parent_name]
- node = Node(obj_def.c_name, obj_def.implements)
- parent_node.add_child(node)
- nodes[node.name] = node
-
- if parser.interfaces:
- interfaces = Node('gobject.GInterface')
- root.add_child(interfaces)
- nodes[interfaces.name] = interfaces
- for obj_def in parser.interfaces:
- node = Node(obj_def.c_name)
- interfaces.add_child(node)
- nodes[node.name] = node
-
- if parser.boxes:
- boxed = Node('gobject.GBoxed')
- root.add_child(boxed)
- nodes[boxed.name] = boxed
- for obj_def in parser.boxes:
- node = Node(obj_def.c_name)
- boxed.add_child(node)
- nodes[node.name] = node
-
- if parser.pointers:
- pointers = Node('gobject.GPointer')
- root.add_child(pointers)
- nodes[pointers.name] = pointers
- for obj_def in parser.pointers:
- node = Node(obj_def.c_name)
- pointers.add_child(node)
- nodes[node.name] = node
-
- return root
-
-
-class DocWriter:
-
- def __init__(self):
- self._fp = None
- # parse the defs file
- self.parser = defsparser.DefsParser(())
- self.overrides = override.Overrides()
- self.classmap = {}
- self.docs = {}
-
- def add_sourcedirs(self, source_dirs):
- self.docs = docextract.extract(source_dirs, self.docs)
-
- def add_tmpldirs(self, tmpl_dirs):
- self.docs = docextract.extract_tmpl(tmpl_dirs, self.docs)
-
- def add_docs(self, defs_file, overrides_file, module_name):
- '''parse information about a given defs file'''
- self.parser.filename = defs_file
- self.parser.startParsing(defs_file)
- if overrides_file:
- self.overrides.handle_file(overrides_file)
-
- for obj in (self.parser.objects + self.parser.interfaces +
- self.parser.boxes + self.parser.pointers):
- if not obj.c_name in self.classmap:
- self.classmap[obj.c_name] = '%s.%s' % (
- module_name, obj.name)
-
- def pyname(self, name):
- return self.classmap.get(name, name)
-
- def _compare(self, obja, objb):
- return cmp(self.pyname(obja.c_name), self.pyname(objb.c_name))
-
- def output_docs(self, output_prefix):
- files = {}
-
- # class hierarchy
- hierarchy = build_object_tree(self.parser)
- filename = self.create_filename('hierarchy', output_prefix)
- self._fp = open(filename, 'w')
- self.write_full_hierarchy(hierarchy)
- self._fp.close()
-
- obj_defs = (self.parser.objects + self.parser.interfaces +
- self.parser.boxes + self.parser.pointers)
- obj_defs.sort(self._compare)
-
- for obj_def in obj_defs:
- filename = self.create_filename(obj_def.c_name, output_prefix)
- self._fp = open(filename, 'w')
- if isinstance(obj_def, definitions.ObjectDef):
- self.output_object_docs(obj_def)
- elif isinstance(obj_def, definitions.InterfaceDef):
- self.output_interface_docs(obj_def)
- elif isinstance(obj_def, definitions.BoxedDef):
- self.output_boxed_docs(obj_def)
- elif isinstance(obj_def, definitions.PointerDef):
- self.output_boxed_docs(obj_def)
- self._fp.close()
- files[os.path.basename(filename)] = obj_def
-
- if not files:
- return
-
- output_filename = self.create_toc_filename(output_prefix)
- self._fp = open(output_filename, 'w')
- self.output_toc(files)
- self._fp.close()
-
- def output_object_docs(self, obj_def):
- self.write_class_header(obj_def.c_name)
-
- self.write_heading('Synopsis')
- self.write_synopsis(obj_def)
- self.close_section()
-
- # construct the inheritence hierarchy ...
- ancestry = [(obj_def.c_name, obj_def.implements)]
- try:
- parent = obj_def.parent
- while parent != None:
- if parent == 'GObject':
- ancestry.append(('GObject', []))
- parent = None
- else:
- parent_def = self.parser.find_object(parent)
- ancestry.append((parent_def.c_name, parent_def.implements))
- parent = parent_def.parent
- except ValueError:
- pass
- ancestry.reverse()
- self.write_heading('Ancestry')
- self.write_hierarchy(obj_def.c_name, ancestry)
- self.close_section()
-
- constructor = self.parser.find_constructor(obj_def, self.overrides)
- if constructor:
- self.write_heading('Constructor')
- self.write_constructor(constructor,
- self.docs.get(constructor.c_name, None))
- self.close_section()
-
- methods = self.parser.find_methods(obj_def)
- methods = filter(lambda meth, self=self:
- not self.overrides.is_ignored(meth.c_name), methods)
- if methods:
- self.write_heading('Methods')
- for method in methods:
- self.write_method(method, self.docs.get(method.c_name, None))
- self.close_section()
-
- self.write_class_footer(obj_def.c_name)
-
- def get_methods_for_object(self, obj_def):
- methods = []
- for method in self.parser.find_methods(obj_def):
- if not self.overrides.is_ignored(method.c_name):
- methods.append(method)
- return methods
-
- def output_interface_docs(self, int_def):
- self.write_class_header(int_def.c_name)
-
- self.write_heading('Synopsis')
- self.write_synopsis(int_def)
- self.close_section()
-
- methods = self.get_methods_for_object(int_def)
- if methods:
- self.write_heading('Methods')
- for method in methods:
- self.write_method(method, self.docs.get(method.c_name, None))
- self.close_section()
- self.write_class_footer(int_def.c_name)
-
- def output_boxed_docs(self, box_def):
- self.write_class_header(box_def.c_name)
-
- self.write_heading('Synopsis')
- self.write_synopsis(box_def)
- self.close_section()
-
- constructor = self.parser.find_constructor(box_def, self.overrides)
- if constructor:
- self.write_heading('Constructor')
- self.write_constructor(constructor,
- self.docs.get(constructor.c_name, None))
- self.close_section()
-
- methods = self.get_methods_for_object(box_def)
- if methods:
- self.write_heading('Methods')
- for method in methods:
- self.write_method(method, self.docs.get(method.c_name, None))
- self.close_section()
-
- self.write_class_footer(box_def.c_name)
-
- def output_toc(self, files):
- self._fp.write('TOC\n\n')
- for filename in sorted(files):
- obj_def = files[filename]
- self._fp.write(obj_def.c_name + ' - ' + filename + '\n')
-
- # override the following to create a more complex output format
-
- def create_filename(self, obj_name, output_prefix):
- '''Create output filename for this particular object'''
- return output_prefix + '-' + obj_name.lower() + '.txt'
-
- def create_toc_filename(self, output_prefix):
- return self.create_filename(self, 'docs', output_prefix)
-
- def write_full_hierarchy(self, hierarchy):
-
- def handle_node(node, indent=''):
- for child in node.subclasses:
- self._fp.write(indent + node.name)
- if node.interfaces:
- self._fp.write(' (implements ')
- self._fp.write(', '.join(node.interfaces))
- self._fp.write(')\n')
- else:
- self._fp.write('\n')
- handle_node(child, indent + ' ')
- handle_node(hierarchy)
-
- def serialize_params(self, func_def):
- params = []
- for param in func_def.params:
- params.append(param[1])
- return ', '.join(params)
-
- # these need to handle default args ...
-
- def create_constructor_prototype(self, func_def):
- return '%s(%s)' % (func_def.is_constructor_of,
- self.serialize_params(func_def))
-
- def create_function_prototype(self, func_def):
- return '%s(%s)' % (func_def.name,
- self.serialize_params(func_def))
-
- def create_method_prototype(self, meth_def):
- return '%s.%s(%s)' % (meth_def.of_object,
- meth_def.name,
- self.serialize_params(meth_def))
-
- def write_class_header(self, obj_name):
- self._fp.write('Class %s\n' % obj_name)
- self._fp.write('======%s\n\n' % ('=' * len(obj_name)))
-
- def write_class_footer(self, obj_name):
- pass
-
- def write_heading(self, text):
- self._fp.write('\n' + text + '\n' + ('-' * len(text)) + '\n')
-
- def close_section(self):
- pass
-
- def write_synopsis(self, obj_def):
- self._fp.write('class %s' % obj_def.c_name)
- if isinstance(obj_def, definitions.ObjectDef):
- bases = []
- if obj_def.parent:
- bases.append(obj_def.parent)
- bases = bases = obj_def.implements
- if bases:
- self._fp.write('(%s)' % ', '.join(bases, ))
- self._fp.write(':\n')
-
- constructor = self.parser.find_constructor(obj_def, self.overrides)
- if constructor:
- prototype = self.create_constructor_prototype(constructor)
- self._fp.write(' def %s\n' % prototype)
-
- for method in self.get_methods_for_object(obj_def):
- prototype = self.create_method_prototype(method)
- self._fp.write(' def %s\n' % prototype)
-
- def write_hierarchy(self, obj_name, ancestry):
- indent = ''
- for name, interfaces in ancestry:
- self._fp.write(indent + '+-- ' + name)
- if interfaces:
- self._fp.write(' (implements ')
- self._fp.write(', '.join(interfaces))
- self._fp.write(')\n')
- else:
- self._fp.write('\n')
- indent = indent + ' '
- self._fp.write('\n')
-
- def write_constructor(self, func_def, func_doc):
- prototype = self.create_constructor_prototype(func_def)
- self._fp.write(prototype + '\n\n')
- for type, name, dflt, null in func_def.params:
- self.write_parameter(name, func_doc)
- self.write_return_value(func_def, func_doc)
- if func_doc and func_doc.description:
- self._fp.write(func_doc.description)
- self._fp.write('\n\n\n')
-
- def write_method(self, meth_def, func_doc):
- prototype = self.create_method_prototype(meth_def)
- self._fp.write(prototype + '\n\n')
- for type, name, dflt, null in meth_def.params:
- self.write_parameter(name, func_doc)
- self.write_return_value(meth_def, func_doc)
- if func_doc and func_doc.description:
- self._fp.write('\n')
- self._fp.write(func_doc.description)
- self._fp.write('\n\n')
-
- def write_parameter(self, param_name, func_doc):
- if func_doc:
- descr = func_doc.get_param_description(param_name)
- else:
- descr = 'a ' + type
- self._fp.write(' ' + param_name + ': ' + descr + '\n')
-
- def write_return_value(self, meth_def, func_doc):
- if meth_def.ret and meth_def.ret != 'none':
- if func_doc and func_doc.ret:
- descr = func_doc.ret
- else:
- descr = 'a ' + meth_def.ret
- self._fp.write(' Returns: ' + descr + '\n')
-
-CLASS_HEADER_TEMPLATE = """<refentry id="%(entryid)s">
- <refmeta>
- <refentrytitle>%(name)s</refentrytitle>
- <manvolnum>3</manvolnum>
- <refmiscinfo>%(miscinfo)s</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>%(name)s</refname><refpurpose></refpurpose>
- </refnamediv>
-
-"""
-VARIABLE_TEMPLATE = """<varlistentry>
- <term><parameter>%(parameter)s</parameter> :</term>
- <listitem><simpara>%(description)s</simpara></listitem>
- </varlistentry>
-"""
-
-DOCBOOK_HEADER = """<?xml version="1.0" standalone="no"?>
-<!DOCTYPE synopsis PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
-"""
-
-
-class DocbookDocWriter(DocWriter):
-
- def __init__(self):
- DocWriter.__init__(self)
-
- self._function_pat = re.compile(r'(\w+)\s*\(\)')
- self._parameter_pat = re.compile(r'\@(\w+)')
- self._constant_pat = re.compile(r'\%(-?\w+)')
- self._symbol_pat = re.compile(r'#([\w-]+)')
-
- self._transtable = ['-'] * 256
- # make string -> reference translation func
- for digit in '0123456789':
- self._transtable[ord(digit)] = digit
-
- for letter in 'abcdefghijklmnopqrstuvwxyz':
- self._transtable[ord(letter)] = letter
- self._transtable[ord(letter.upper())] = letter
- self._transtable = ''.join(self._transtable)
-
- def create_filename(self, obj_name, output_prefix):
- '''Create output filename for this particular object'''
- stem = output_prefix + '-' + obj_name.lower()
- return stem + '.xml'
-
- def create_toc_filename(self, output_prefix):
- return self.create_filename('classes', output_prefix)
-
- def make_class_ref(self, obj_name):
- return 'class-' + obj_name.translate(self._transtable)
-
- def make_method_ref(self, meth_def):
- return 'method-%s--%s' % (
- meth_def.of_object.translate(self._transtable),
- meth_def.name.translate(self._transtable))
-
- def _format_function(self, match):
- info = self.parser.c_name.get(match.group(1), None)
- if info:
- if isinstance(info, defsparser.FunctionDef):
- return self._format_funcdef(info)
- if isinstance(info, defsparser.MethodDef):
- return self._format_method(info)
-
- # fall through through
- return '<function>%s()</function>' % (match.group(1), )
-
- def _format_funcdef(self, info):
- if info.is_constructor_of is not None:
- # should have a link here
- return '<methodname>%s()</methodname>' % (
- self.pyname(info.is_constructor_of), )
- else:
- return '<function>%s()</function>' % (info.name, )
-
- def _format_param(self, match):
- return '<parameter>%s</parameterdliteral>' % (match.group(1), )
-
- def _format_const(self, match):
- return '<literal>%s</literal>' % (match.group(1), )
-
- def _format_method(self, info):
- return ('<link linkend="%s">'
- '<methodname>%s.%s</methodname>'
- '</link>') % (self.make_method_ref(info),
- self.pyname(info.of_object),
- info.name)
-
- def _format_object(self, info):
- return ('<link linkend="%s">'
- '<classname>%s</classname>'
- '</link>') % (self.make_class_ref(info.c_name),
- self.pyname(info.c_name))
-
- def _format_symbol(self, match):
- info = self.parser.c_name.get(match.group(1), None)
- if info:
- if isinstance(info, defsparser.FunctionDef):
- return self._format_funcdef(info)
- elif isinstance(info, defsparser.MethodDef):
- return self._format_method(info)
- elif isinstance(info, (defsparser.ObjectDef,
- defsparser.InterfaceDef,
- defsparser.BoxedDef,
- defsparser.PointerDef)):
- return self._format_object(info)
-
- # fall through through
- return '<literal>%s</literal>' % (match.group(1), )
-
- def reformat_text(self, text, singleline=0):
- # replace special strings ...
- text = self._function_pat.sub(self._format_function, text)
- text = self._parameter_pat.sub(self._format_param, text)
- text = self._constant_pat.sub(self._format_const, text)
- text = self._symbol_pat.sub(self._format_symbol, text)
-
- # don't bother with <para> expansion for single line text.
- if singleline:
- return text
-
- lines = text.strip().split('\n')
- for index in range(len(lines)):
- if lines[index].strip() == '':
- lines[index] = '</para>\n<para>'
- continue
- return '<para>%s</para>' % ('\n'.join(lines), )
-
- # write out hierarchy
-
- def write_full_hierarchy(self, hierarchy):
-
- def handle_node(node, indent=''):
- if node.name:
- self._fp.write('%s<link linkend="%s">%s</link>' %
- (indent, self.make_class_ref(node.name),
- self.pyname(node.name)))
- if node.interfaces:
- self._fp.write(' (implements ')
- for i in range(len(node.interfaces)):
- self._fp.write('<link linkend="%s">%s</link>' %
- (self.make_class_ref(node.interfaces[i]),
- self.pyname(node.interfaces[i])))
- if i != len(node.interfaces) - 1:
- self._fp.write(', ')
- self._fp.write(')\n')
- else:
- self._fp.write('\n')
-
- indent = indent + ' '
- node.subclasses.sort(lambda a, b:
- cmp(self.pyname(a.name), self.pyname(b.name)))
- for child in node.subclasses:
- handle_node(child, indent)
-
- self._fp.write(DOCBOOK_HEADER)
- self._fp.write('<synopsis>')
- handle_node(hierarchy)
- self._fp.write('</synopsis>\n')
-
- # these need to handle default args ...
-
- def create_constructor_prototype(self, func_def):
- xml = ['<constructorsynopsis language="python">\n']
- xml.append(' <methodname>__init__</methodname>\n')
- for type, name, dflt, null in func_def.params:
- xml.append(' <methodparam><parameter>')
- xml.append(name)
- xml.append('</parameter>')
- if dflt:
- xml.append('<initializer>')
- xml.append(dflt)
- xml.append('</initializer>')
- xml.append('</methodparam>\n')
- if not func_def.params:
- xml.append(' <methodparam></methodparam>')
- xml.append(' </constructorsynopsis>')
- return ''.join(xml)
-
- def create_function_prototype(self, func_def):
- xml = ['<funcsynopsis language="python">\n <funcprototype>\n']
- xml.append(' <funcdef><function>')
- xml.append(func_def.name)
- xml.append('</function></funcdef>\n')
- for type, name, dflt, null in func_def.params:
- xml.append(' <paramdef><parameter>')
- xml.append(name)
- xml.append('</parameter>')
- if dflt:
- xml.append('<initializer>')
- xml.append(dflt)
- xml.append('</initializer>')
- xml.append('</paramdef>\n')
- if not func_def.params:
- xml.append(' <paramdef></paramdef')
- xml.append(' </funcprototype>\n </funcsynopsis>')
- return ''.join(xml)
-
- def create_method_prototype(self, meth_def, addlink=0):
- xml = ['<methodsynopsis language="python">\n']
- xml.append(' <methodname>')
- if addlink:
- xml.append('<link linkend="%s">' % self.make_method_ref(meth_def))
- xml.append(self.pyname(meth_def.name))
- if addlink:
- xml.append('</link>')
- xml.append('</methodname>\n')
- for type, name, dflt, null in meth_def.params:
- xml.append(' <methodparam><parameter>')
- xml.append(name)
- xml.append('</parameter>')
- if dflt:
- xml.append('<initializer>')
- xml.append(dflt)
- xml.append('</initializer>')
- xml.append('</methodparam>\n')
- if not meth_def.params:
- xml.append(' <methodparam></methodparam>')
- xml.append(' </methodsynopsis>')
- return ''.join(xml)
-
- def write_class_header(self, obj_name):
- self._fp.write(DOCBOOK_HEADER)
- self._fp.write(CLASS_HEADER_TEMPLATE % dict(
- entryid=self.make_class_ref(obj_name),
- name=self.pyname(obj_name),
- miscinfo="PyGTK Docs"))
-
- def write_class_footer(self, obj_name):
- self._fp.write('</refentry>\n')
-
- def write_heading(self, text):
- self._fp.write(' <refsect1>\n')
- self._fp.write(' <title>' + text + '</title>\n\n')
-
- def close_section(self):
- self._fp.write(' </refsect1>\n')
-
- def write_synopsis(self, obj_def):
- self._fp.write('<classsynopsis language="python">\n')
- self._fp.write(' <ooclass><classname>%s</classname></ooclass>\n'
- % self.pyname(obj_def.c_name))
- if isinstance(obj_def, definitions.ObjectDef):
- if obj_def.parent:
- self._fp.write(' <ooclass><classname><link linkend="%s">%s'
- '</link></classname></ooclass>\n'
- % (self.make_class_ref(obj_def.parent),
- self.pyname(obj_def.parent)))
- for base in obj_def.implements:
- self._fp.write(' <ooclass><classname><link linkend="%s">%s'
- '</link></classname></ooclass>\n'
- % (self.make_class_ref(base), self.pyname(base)))
- elif isinstance(obj_def, definitions.InterfaceDef):
- self._fp.write(' <ooclass><classname>gobject.GInterface'
- '</classname></ooclass>\n')
- elif isinstance(obj_def, definitions.BoxedDef):
- self._fp.write(' <ooclass><classname>gobject.GBoxed'
- '</classname></ooclass>\n')
- elif isinstance(obj_def, definitions.PointerDef):
- self._fp.write(' <ooclass><classname>gobject.GPointer'
- '</classname></ooclass>\n')
-
- constructor = self.parser.find_constructor(obj_def, self.overrides)
- if constructor:
- self._fp.write(
- '%s\n' % self.create_constructor_prototype(constructor))
- for method in self.get_methods_for_object(obj_def):
- self._fp.write(
- '%s\n' % self.create_method_prototype(method, addlink=1))
- self._fp.write('</classsynopsis>\n\n')
-
- def write_hierarchy(self, obj_name, ancestry):
- self._fp.write('<synopsis>')
- indent = ''
- for name, interfaces in ancestry:
- self._fp.write(
- '%s+-- <link linkend="%s">%s</link>' %
- (indent, self.make_class_ref(name), self.pyname(name)))
- if interfaces:
- self._fp.write(' (implements ')
- for i in range(len(interfaces)):
- self._fp.write('<link linkend="%s">%s</link>' %
- (self.make_class_ref(interfaces[i]),
- self.pyname(interfaces[i])))
- if i != len(interfaces) - 1:
- self._fp.write(', ')
- self._fp.write(')\n')
- else:
- self._fp.write('\n')
- indent = indent + ' '
- self._fp.write('</synopsis>\n\n')
-
- def write_params(self, params, ret, func_doc):
- if not params and (not ret or ret == 'none'):
- return
- self._fp.write(' <variablelist>\n')
- for type, name, dflt, null in params:
- if func_doc:
- descr = func_doc.get_param_description(name).strip()
- else:
- descr = 'a ' + type
- self._fp.write(VARIABLE_TEMPLATE % dict(
- parameter=name,
- description=self.reformat_text(descr, singleline=1)))
- if ret and ret != 'none':
- if func_doc and func_doc.ret:
- descr = func_doc.ret.strip()
- else:
- descr = 'a ' + ret
- self._fp.write(VARIABLE_TEMPLATE % dict(
- parameter='Returns',
- description=self.reformat_text(descr, singleline=1)))
- self._fp.write(' </variablelist>\n')
-
- def write_constructor(self, func_def, func_doc):
- prototype = self.create_constructor_prototype(func_def)
- self._fp.write('<programlisting>%s</programlisting>\n' % prototype)
- self.write_params(func_def.params, func_def.ret, func_doc)
-
- if func_doc and func_doc.description:
- self._fp.write(self.reformat_text(func_doc.description))
- self._fp.write('\n\n\n')
-
- def write_method(self, meth_def, func_doc):
- self._fp.write(' <refsect2 id="%s">\n' % (
- self.make_method_ref(meth_def), ))
- self._fp.write(' <title>%s.%s</title>\n\n' % (
- self.pyname(meth_def.of_object),
- meth_def.name))
- prototype = self.create_method_prototype(meth_def)
- self._fp.write('<programlisting>%s</programlisting>\n' % prototype)
- self.write_params(meth_def.params, meth_def.ret, func_doc)
- if func_doc and func_doc.description:
- self._fp.write(self.reformat_text(func_doc.description))
- self._fp.write(' </refsect2>\n\n\n')
-
- def output_toc(self, files, fp=sys.stdout):
- self._fp.write(DOCBOOK_HEADER)
-
- #self._fp.write('<reference id="class-reference">\n')
- #self._fp.write(' <title>Class Documentation</title>\n')
- #for filename, obj_def in files:
- # self._fp.write('&' +
- # obj_def.c_name.translate(self._transtable) + ';\n')
- #self._fp.write('</reference>\n')
-
- self._fp.write('<reference id="class-reference" '
- 'xmlns:xi="http://www.w3.org/2001/XInclude">\n')
- self._fp.write(' <title>Class Reference</title>\n')
- for filename in sorted(files):
- self._fp.write(' <xi:include href="%s"/>\n' % filename)
- self._fp.write('</reference>\n')
-
-
-def main(args):
- try:
- opts, args = getopt.getopt(args[1:], "d:s:o:",
- ["defs-file=", "override=", "source-dir=",
- "output-prefix="])
- except getopt.error, e:
- sys.stderr.write('docgen.py: %s\n' % e)
- sys.stderr.write(
- 'usage: docgen.py -d file.defs [-s /src/dir] [-o output-prefix]\n')
- return 1
-
- defs_file = None
- overrides_file = None
- source_dirs = []
- output_prefix = 'docs'
- for opt, arg in opts:
- if opt in ('-d', '--defs-file'):
- defs_file = arg
- if opt in ('--override', ):
- overrides_file = arg
- elif opt in ('-s', '--source-dir'):
- source_dirs.append(arg)
- elif opt in ('-o', '--output-prefix'):
- output_prefix = arg
- if len(args) != 0 or not defs_file:
- sys.stderr.write(
- 'usage: docgen.py -d file.defs [-s /src/dir] [-o output-prefix]\n')
- return 1
-
- d = DocbookDocWriter()
- d.add_sourcedirs(source_dirs)
- d.add_docs(defs_file, overrides_file, 'gio')
- d.output_docs(output_prefix)
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
+++ /dev/null
-#!/usr/bin/env python
-# -*- Mode: Python; py-indent-offset: 4 -*-
-# GPL'ed
-# Toby D. Reeves <toby@max.rl.plh.af.mil>
-#
-# Modified by James Henstridge <james@daa.com.au> to output stuff in
-# Havoc's new defs format. Info on this format can be seen at:
-# http://mail.gnome.org/archives/gtk-devel-list/2000-January/msg00070.html
-# Updated to be PEP-8 compatible and refactored to use OOP
-#
-# Scan the given public .h files of a GTK module (or module using
-# GTK object conventions) and generates a set of scheme defs.
-#
-# h2def searches through a header file looking for function prototypes and
-# generates a scheme style defenition for each prototype.
-# Basically the operation of h2def is:
-#
-# - read each .h file into a buffer which is scrubbed of extraneous data
-# - find all object defenitions:
-# - find all structures that may represent a GtkObject
-# - find all structures that might represent a class
-# - find all structures that may represent a GtkObject subclass
-# - find all structures that might represent a class/Iface inherited from
-# GTypeInterface
-# - find all enum defenitions
-# - write out the defs
-#
-# The command line options are:
-#
-# -s --separate Create separate files for objects and function/method defs
-# using the given name as the base name (optional). If this
-# is not specified the combined object and function defs
-# will be output to sys.stdout.
-# -f --defsfilter Extract defs from the given file to filter the output defs
-# that is don't output defs that are defined in the
-# defsfile. More than one deffile may be specified.
-# -m --modulename The prefix to be stripped from the front of function names
-# for the given module
-# -n --namespace The module or namespace name to be used, for example
-# WebKit where h2def is unable to detect the module name
-# automatically. it also sets the gtype-id prefix.
-# --onlyenums Only produce defs for enums and flags
-# --onlyobjdefs Only produce defs for objects
-# -v Verbose output
-#
-# Examples:
-#
-# python h2def.py /usr/local/include/pango-1.0/pango/*.h >/tmp/pango.defs
-#
-# - Outputs all defs for the pango module.
-#
-# python h2def.py -m gdk -s /tmp/gdk-2.10 \
-# -f /usr/tmp/pygtk/gtk/gdk-base.defs \
-# /usr/local/include/gtk-2.0/gdk/*.h \
-# /usr/local/include/gtk-2.0/gdk-pixbuf/*.h
-#
-# - Outputs the gdk module defs that are not contained in the defs file
-# /usr/tmp/pygtk/gtk/gdk-base.defs. Two output files are created:
-# /tmp/gdk-2.10-types.defs and /tmp/gdk-2.10.defs.
-#
-# python h2def.py -n WebKit /usr/incude/webkit-1.0/webkit/*.h \
-# >/tmp/webkit.defs
-#
-# - Outputs all the defs for webkit module, setting the module name to WebKit
-# and the gtype-id prefix to WEBKIT_ which can't be detected automatically.
-#
-
-import getopt
-import os
-import re
-import string
-import sys
-
-import defsparser
-
-# ------------------ Create typecodes from typenames ---------
-
-_upperstr_pat1 = re.compile(r'([^A-Z])([A-Z])')
-_upperstr_pat2 = re.compile(r'([A-Z][A-Z])([A-Z][0-9a-z])')
-_upperstr_pat3 = re.compile(r'^([A-Z])([A-Z])')
-
-def to_upper_str(name):
- """Converts a typename to the equivalent upercase and underscores
- name. This is used to form the type conversion macros and enum/flag
- name variables"""
- name = _upperstr_pat1.sub(r'\1_\2', name)
- name = _upperstr_pat2.sub(r'\1_\2', name)
- name = _upperstr_pat3.sub(r'\1_\2', name, count=1)
- return string.upper(name)
-
-def typecode(typename, namespace=None):
- """create a typecode (eg. GTK_TYPE_WIDGET) from a typename"""
- if namespace:
- return string.replace(string.upper(namespace) + "_" + to_upper_str(typename[len(namespace):]), '_', '_TYPE_', 1)
-
- return string.replace(to_upper_str(typename), '_', '_TYPE_', 1)
-
-
-# ------------------ Find object definitions -----------------
-# Strips the comments from buffer
-def strip_comments(buf):
- parts = []
- lastpos = 0
- while 1:
- pos = string.find(buf, '/*', lastpos)
- if pos >= 0:
- parts.append(buf[lastpos:pos])
- pos = string.find(buf, '*/', pos)
- if pos >= 0:
- lastpos = pos + 2
- else:
- break
- else:
- parts.append(buf[lastpos:])
- break
- return string.join(parts, '')
-
-# Strips the dll API from buffer, for example WEBKIT_API
-def strip_dll_api(buf):
- pat = re.compile("[A-Z]*_API ")
- buf = pat.sub("", buf)
- return buf
-
-obj_name_pat = "[A-Z][a-z]*[A-Z][A-Za-z0-9]*"
-
-split_prefix_pat = re.compile('([A-Z]+[a-z]*)([A-Za-z0-9]+)')
-
-def find_obj_defs(buf, objdefs=[]):
- """
- Try to find object definitions in header files.
- """
-
- # filter out comments from buffer.
- buf = strip_comments(buf)
-
- # filter out dll api
- buf = strip_dll_api(buf)
-
- maybeobjdefs = [] # contains all possible objects from file
-
- # first find all structures that look like they may represent a GtkObject
- pat = re.compile("struct\s+_(" + obj_name_pat + ")\s*{\s*" +
- "(" + obj_name_pat + ")\s+", re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = pat.search(buf, pos)
- if not m: break
- maybeobjdefs.append((m.group(1), m.group(2)))
- pos = m.end()
-
- # handle typedef struct { ... } style struct defs.
- pat = re.compile("typedef struct\s+[_\w]*\s*{\s*" +
- "(" + obj_name_pat + ")\s+[^}]*}\s*" +
- "(" + obj_name_pat + ")\s*;", re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = pat.search(buf, pos)
- if not m: break
- maybeobjdefs.append((m.group(2), m.group(1)))
- pos = m.end()
-
- # now find all structures that look like they might represent a class:
- pat = re.compile("struct\s+_(" + obj_name_pat + ")Class\s*{\s*" +
- "(" + obj_name_pat + ")Class\s+", re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = pat.search(buf, pos)
- if not m: break
- t = (m.group(1), m.group(2))
- # if we find an object structure together with a corresponding
- # class structure, then we have probably found a GtkObject subclass.
- if t in maybeobjdefs:
- objdefs.append(t)
- pos = m.end()
-
- pat = re.compile("typedef struct\s+[_\w]*\s*{\s*" +
- "(" + obj_name_pat + ")Class\s+[^}]*}\s*" +
- "(" + obj_name_pat + ")Class\s*;", re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = pat.search(buf, pos)
- if not m: break
- t = (m.group(2), m.group(1))
- # if we find an object structure together with a corresponding
- # class structure, then we have probably found a GtkObject subclass.
- if t in maybeobjdefs:
- objdefs.append(t)
- pos = m.end()
-
- # now find all structures that look like they might represent
- # a class inherited from GTypeInterface:
- pat = re.compile("struct\s+_(" + obj_name_pat + ")Class\s*{\s*" +
- "GTypeInterface\s+", re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = pat.search(buf, pos)
- if not m: break
- t = (m.group(1), '')
- t2 = (m.group(1)+'Class', 'GTypeInterface')
- # if we find an object structure together with a corresponding
- # class structure, then we have probably found a GtkObject subclass.
- if t2 in maybeobjdefs:
- objdefs.append(t)
- pos = m.end()
-
- # now find all structures that look like they might represent
- # an Iface inherited from GTypeInterface:
- pat = re.compile("struct\s+_(" + obj_name_pat + ")Iface\s*{\s*" +
- "GTypeInterface\s+", re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = pat.search(buf, pos)
- if not m: break
- t = (m.group(1), '')
- t2 = (m.group(1)+'Iface', 'GTypeInterface')
- # if we find an object structure together with a corresponding
- # class structure, then we have probably found a GtkObject subclass.
- if t2 in maybeobjdefs:
- objdefs.append(t)
- pos = m.end()
-
-def sort_obj_defs(objdefs):
- objdefs.sort() # not strictly needed, but looks nice
- pos = 0
- while pos < len(objdefs):
- klass,parent = objdefs[pos]
- for i in range(pos+1, len(objdefs)):
- # parent below subclass ... reorder
- if objdefs[i][0] == parent:
- objdefs.insert(i+1, objdefs[pos])
- del objdefs[pos]
- break
- else:
- pos = pos + 1
- return objdefs
-
-# ------------------ Find enum definitions -----------------
-
-def find_enum_defs(buf, enums=[]):
- # strip comments
- # bulk comments
- buf = strip_comments(buf)
-
- # strip dll api macros
- buf = strip_dll_api(buf)
-
- # strip # directives
- pat = re.compile(r"""^[#].*?$""", re.MULTILINE)
- buf = pat.sub('', buf)
-
- buf = re.sub('\n', ' ', buf)
-
- enum_pat = re.compile(r'enum\s*{([^}]*)}\s*([A-Z][A-Za-z]*)(\s|;)')
- splitter = re.compile(r'\s*,\s', re.MULTILINE)
- pos = 0
- while pos < len(buf):
- m = enum_pat.search(buf, pos)
- if not m: break
-
- name = m.group(2)
- vals = m.group(1)
- isflags = string.find(vals, '<<') >= 0
- entries = []
- for val in splitter.split(vals):
- if not string.strip(val): continue
- entries.append(string.split(val)[0])
- if name != 'GdkCursorType':
- enums.append((name, isflags, entries))
-
- pos = m.end()
-
-# ------------------ Find function definitions -----------------
-
-def clean_func(buf):
- """
- Ideally would make buf have a single prototype on each line.
- Actually just cuts out a good deal of junk, but leaves lines
- where a regex can figure prototypes out.
- """
- # bulk comments
- buf = strip_comments(buf)
-
- # dll api
- buf = strip_dll_api(buf)
-
- # compact continued lines
- pat = re.compile(r"""\\\n""", re.MULTILINE)
- buf = pat.sub('', buf)
-
- # Preprocess directives
- pat = re.compile(r"""^[#].*?$""", re.MULTILINE)
- buf = pat.sub('', buf)
-
- #typedefs, stucts, and enums
- pat = re.compile(r"""^(typedef|struct|enum)(\s|.|\n)*?;\s*""",
- re.MULTILINE)
- buf = pat.sub('', buf)
-
- #strip DECLS macros
- pat = re.compile(r"""G_BEGIN_DECLS|BEGIN_LIBGTOP_DECLS""", re.MULTILINE)
- buf = pat.sub('', buf)
-
- #extern "C"
- pat = re.compile(r"""^\s*(extern)\s+\"C\"\s+{""", re.MULTILINE)
- buf = pat.sub('', buf)
-
- #multiple whitespace
- pat = re.compile(r"""\s+""", re.MULTILINE)
- buf = pat.sub(' ', buf)
-
- #clean up line ends
- pat = re.compile(r""";\s*""", re.MULTILINE)
- buf = pat.sub('\n', buf)
- buf = buf.lstrip()
-
- #associate *, &, and [] with type instead of variable
- #pat = re.compile(r'\s+([*|&]+)\s*(\w+)')
- pat = re.compile(r' \s* ([*|&]+) \s* (\w+)', re.VERBOSE)
- buf = pat.sub(r'\1 \2', buf)
- pat = re.compile(r'\s+ (\w+) \[ \s* \]', re.VERBOSE)
- buf = pat.sub(r'[] \1', buf)
-
- # make return types that are const work.
- buf = re.sub(r'\s*\*\s*G_CONST_RETURN\s*\*\s*', '** ', buf)
- buf = string.replace(buf, 'G_CONST_RETURN ', 'const-')
- buf = string.replace(buf, 'const ', 'const-')
-
- #strip GSEAL macros from the middle of function declarations:
- pat = re.compile(r"""GSEAL""", re.VERBOSE)
- buf = pat.sub('', buf)
-
- return buf
-
-proto_pat=re.compile(r"""
-(?P<ret>(-|\w|\&|\*)+\s*) # return type
-\s+ # skip whitespace
-(?P<func>\w+)\s*[(] # match the function name until the opening (
-\s*(?P<args>.*?)\s*[)] # group the function arguments
-""", re.IGNORECASE|re.VERBOSE)
-#"""
-arg_split_pat = re.compile("\s*,\s*")
-
-get_type_pat = re.compile(r'(const-)?([A-Za-z0-9]+)\*?\s+')
-pointer_pat = re.compile('.*\*$')
-func_new_pat = re.compile('(\w+)_new$')
-
-class DefsWriter:
- def __init__(self, fp=None, prefix=None, ns=None, verbose=False,
- defsfilter=None):
- if not fp:
- fp = sys.stdout
-
- self.fp = fp
- self.prefix = prefix
- self.namespace = ns
- self.verbose = verbose
-
- self._enums = {}
- self._objects = {}
- self._functions = {}
- if defsfilter:
- filter = defsparser.DefsParser(defsfilter)
- filter.startParsing()
- for func in filter.functions + filter.methods.values():
- self._functions[func.c_name] = func
- for obj in filter.objects + filter.boxes + filter.interfaces:
- self._objects[obj.c_name] = obj
- for obj in filter.enums:
- self._enums[obj.c_name] = obj
-
- def write_def(self, deffile):
- buf = open(deffile).read()
-
- self.fp.write('\n;; From %s\n\n' % os.path.basename(deffile))
- self._define_func(buf)
- self.fp.write('\n')
-
- def write_enum_defs(self, enums, fp=None):
- if not fp:
- fp = self.fp
-
- fp.write(';; Enumerations and flags ...\n\n')
- trans = string.maketrans(string.uppercase + '_',
- string.lowercase + '-')
- filter = self._enums
- for cname, isflags, entries in enums:
- if filter:
- if cname in filter:
- continue
- name = cname
- module = None
- if self.namespace:
- module = self.namespace
- name = cname[len(self.namespace):]
- else:
- m = split_prefix_pat.match(cname)
- if m:
- module = m.group(1)
- name = m.group(2)
- if isflags:
- fp.write('(define-flags ' + name + '\n')
- else:
- fp.write('(define-enum ' + name + '\n')
- if module:
- fp.write(' (in-module "' + module + '")\n')
- fp.write(' (c-name "' + cname + '")\n')
- fp.write(' (gtype-id "' + typecode(cname, self.namespace) + '")\n')
- prefix = entries[0]
- for ent in entries:
- # shorten prefix til we get a match ...
- # and handle GDK_FONT_FONT, GDK_FONT_FONTSET case
- while ((len(prefix) and prefix[-1] != '_') or ent[:len(prefix)] != prefix
- or len(prefix) >= len(ent)):
- prefix = prefix[:-1]
- prefix_len = len(prefix)
- fp.write(' (values\n')
- for ent in entries:
- fp.write(' \'("%s" "%s")\n' %
- (string.translate(ent[prefix_len:], trans), ent))
- fp.write(' )\n')
- fp.write(')\n\n')
-
- def write_obj_defs(self, objdefs, fp=None):
- if not fp:
- fp = self.fp
-
- fp.write(';; -*- scheme -*-\n')
- fp.write('; object definitions ...\n')
-
- filter = self._objects
- for klass, parent in objdefs:
- if filter:
- if klass in filter:
- continue
- if self.namespace:
- cname = klass[len(self.namespace):]
- cmodule = self.namespace
- else:
- m = split_prefix_pat.match(klass)
- cname = klass
- cmodule = None
- if m:
- cmodule = m.group(1)
- cname = m.group(2)
- fp.write('(define-object ' + cname + '\n')
- if cmodule:
- fp.write(' (in-module "' + cmodule + '")\n')
- if parent:
- fp.write(' (parent "' + parent + '")\n')
- fp.write(' (c-name "' + klass + '")\n')
- fp.write(' (gtype-id "' + typecode(klass, self.namespace) + '")\n')
- # should do something about accessible fields
- fp.write(')\n\n')
-
- def _define_func(self, buf):
- buf = clean_func(buf)
- buf = string.split(buf,'\n')
- filter = self._functions
- for p in buf:
- if not p:
- continue
- m = proto_pat.match(p)
- if m == None:
- if self.verbose:
- sys.stderr.write('No match:|%s|\n' % p)
- continue
- func = m.group('func')
- if func[0] == '_':
- continue
- if filter:
- if func in filter:
- continue
- ret = m.group('ret')
- args = m.group('args')
- args = arg_split_pat.split(args)
- for i in range(len(args)):
- spaces = string.count(args[i], ' ')
- if spaces > 1:
- args[i] = string.replace(args[i], ' ', '-', spaces - 1)
-
- self._write_func(func, ret, args)
-
- def _write_func(self, name, ret, args):
- if len(args) >= 1:
- # methods must have at least one argument
- munged_name = name.replace('_', '')
- m = get_type_pat.match(args[0])
- if m:
- obj = m.group(2)
- if munged_name[:len(obj)] == obj.lower():
- self._write_method(obj, name, ret, args)
- return
-
- if self.prefix:
- l = len(self.prefix)
- if name[:l] == self.prefix and name[l] == '_':
- fname = name[l+1:]
- else:
- fname = name
- else:
- fname = name
-
- # it is either a constructor or normal function
- self.fp.write('(define-function ' + fname + '\n')
- self.fp.write(' (c-name "' + name + '")\n')
-
- # Hmmm... Let's asume that a constructor function name
- # ends with '_new' and it returns a pointer.
- m = func_new_pat.match(name)
- if pointer_pat.match(ret) and m:
- cname = ''
- names = m.group(1).split('_')
-
- if self.namespace:
- cname = self.namespace
- names = names[1:]
-
- for s in names:
- cname += s.title()
- if cname != '':
- self.fp.write(' (is-constructor-of "' + cname + '")\n')
-
- self._write_return(ret)
- self._write_arguments(args)
-
- def _write_method(self, obj, name, ret, args):
- regex = string.join(map(lambda x: x+'_?', string.lower(obj)),'')
- mname = re.sub(regex, '', name, 1)
- if self.prefix:
- l = len(self.prefix) + 1
- if mname[:l] == self.prefix and mname[l+1] == '_':
- mname = mname[l+1:]
- self.fp.write('(define-method ' + mname + '\n')
- self.fp.write(' (of-object "' + obj + '")\n')
- self.fp.write(' (c-name "' + name + '")\n')
- self._write_return(ret)
- self._write_arguments(args[1:])
-
- def _write_return(self, ret):
- if ret != 'void':
- self.fp.write(' (return-type "' + ret + '")\n')
- else:
- self.fp.write(' (return-type "none")\n')
-
- def _write_arguments(self, args):
- is_varargs = 0
- has_args = len(args) > 0
- for arg in args:
- if arg == '...':
- is_varargs = 1
- elif arg in ('void', 'void '):
- has_args = 0
- if has_args:
- self.fp.write(' (parameters\n')
- for arg in args:
- if arg != '...':
- tupleArg = tuple(string.split(arg))
- if len(tupleArg) == 2:
- self.fp.write(' \'("%s" "%s")\n' % tupleArg)
- self.fp.write(' )\n')
- if is_varargs:
- self.fp.write(' (varargs #t)\n')
- self.fp.write(')\n\n')
-
-# ------------------ Main function -----------------
-
-def main(args):
- verbose = False
- onlyenums = False
- onlyobjdefs = False
- separate = False
- modulename = None
- namespace = None
- defsfilter = None
- opts, args = getopt.getopt(args[1:], 'vs:m:n:f:',
- ['onlyenums', 'onlyobjdefs',
- 'modulename=', 'namespace=',
- 'separate=', 'defsfilter='])
- for o, v in opts:
- if o == '-v':
- verbose = True
- if o == '--onlyenums':
- onlyenums = True
- if o == '--onlyobjdefs':
- onlyobjdefs = True
- if o in ('-s', '--separate'):
- separate = v
- if o in ('-m', '--modulename'):
- modulename = v
- if o in ('-n', '--namespace'):
- namespace = v
- if o in ('-f', '--defsfilter'):
- defsfilter = v
-
- if not args[0:1]:
- print 'Must specify at least one input file name'
- return -1
-
- # read all the object definitions in
- objdefs = []
- enums = []
- for filename in args:
- buf = open(filename).read()
- find_obj_defs(buf, objdefs)
- find_enum_defs(buf, enums)
- objdefs = sort_obj_defs(objdefs)
-
- if separate:
- methods = file(separate + '.defs', 'w')
- types = file(separate + '-types.defs', 'w')
-
- dw = DefsWriter(methods, prefix=modulename, ns=namespace,
- verbose=verbose, defsfilter=defsfilter)
- dw.write_obj_defs(objdefs, types)
- dw.write_enum_defs(enums, types)
- print "Wrote %s-types.defs" % separate
-
- for filename in args:
- dw.write_def(filename)
- print "Wrote %s.defs" % separate
- else:
- dw = DefsWriter(prefix=modulename, ns=namespace,
- verbose=verbose, defsfilter=defsfilter)
-
- if onlyenums:
- dw.write_enum_defs(enums)
- elif onlyobjdefs:
- dw.write_obj_defs(objdefs)
- else:
- dw.write_obj_defs(objdefs)
- dw.write_enum_defs(enums)
-
- for filename in args:
- dw.write_def(filename)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
+++ /dev/null
-#!/usr/bin/env python
-# -*- Mode: Python; py-indent-offset: 4 -*-
-
-import optparse
-
-import defsparser
-
-parser = optparse.OptionParser(
- usage="usage: %prog [options] generated-defs old-defs")
-parser.add_option("-p", "--merge-parameters",
- help="Merge changes in function/methods parameter lists",
- action="store_true", dest="parmerge", default=False)
-(options, args) = parser.parse_args()
-
-if len(args) != 2:
- parser.error("wrong number of arguments")
-
-newp = defsparser.DefsParser(args[0])
-oldp = defsparser.DefsParser(args[1])
-
-newp.startParsing()
-oldp.startParsing()
-
-newp.merge(oldp, options.parmerge)
-
-newp.write_defs()
+++ /dev/null
-#!/usr/bin/env python
-# -*- Mode: Python; py-indent-offset: 4 -*-
-
-import sys, os, getopt
-
-module_init_template = \
-'/* -*- Mode: C; c-basic-offset: 4 -*- */\n' + \
-'#ifdef HAVE_CONFIG_H\n' + \
-'# include "config.h"\n' + \
-'#endif\n' + \
-'#include <Python.h>\n' + \
-'#include <pygtk.h>\n' + \
-'\n' + \
-'/* include any extra headers needed here */\n' + \
-'\n' + \
-'void %(prefix)s_register_classes(PyObject *d);\n' + \
-'extern PyMethodDef %(prefix)s_functions[];\n' + \
-'\n' + \
-'DL_EXPORT(void)\n' + \
-'init%(module)s(void)\n' + \
-'{\n' + \
-' PyObject *m, *d;\n' + \
-'\n' + \
-' /* perform any initialisation required by the library here */\n' + \
-'\n' + \
-' m = Py_InitModule("%(module)s", %(prefix)s_functions);\n' + \
-' d = PyModule_GetDict(m);\n' + \
-'\n' + \
-' init_pygtk();\n' + \
-'\n' + \
-' %(prefix)s_register_classes(d);\n' + \
-'\n' + \
-' /* add anything else to the module dictionary (such as constants) */\n' +\
-'\n' + \
-' if (PyErr_Occurred())\n' + \
-' Py_FatalError("could not initialise module %(module)s");\n' + \
-'}\n'
-
-override_template = \
-'/* -*- Mode: C; c-basic-offset: 4 -*- */\n' + \
-'%%%%\n' + \
-'headers\n' + \
-'/* include any required headers here */\n' + \
-'%%%%\n' + \
-'init\n' + \
-' /* include any code here that needs to be executed before the\n' + \
-' * extension classes get initialised */\n' + \
-'%%%%\n' + \
-'\n' + \
-'/* you should add appropriate ignore, ignore-glob and\n' + \
-' * override sections here */\n'
-
-def open_with_backup(file):
- if os.path.exists(file):
- try:
- os.rename(file, file+'~')
- except OSError:
- # fail silently if we can't make a backup
- pass
- return open(file, 'w')
-
-def write_skels(fileprefix, prefix, module):
- fp = open_with_backup(fileprefix+'module.c')
- fp.write(module_init_template % { 'prefix': prefix, 'module': module })
- fp.close()
- fp = open_with_backup(fileprefix+'.override')
- fp.write(override_template % { 'prefix': prefix, 'module': module })
- fp.close()
-
-if __name__ == '__main__':
- opts, args = getopt.getopt(sys.argv[1:], 'f:p:m:h',
- ['file-prefix=', 'prefix=', 'module=', 'help'])
- fileprefix = None
- prefix = None
- module = None
- for opt, arg in opts:
- if opt in ('-f', '--file-prefix'):
- fileprefix = arg
- elif opt in ('-p', '--prefix'):
- prefix = arg
- elif opt in ('-m', '--module'):
- module = arg
- elif opt in ('-h', '--help'):
- print 'usage: mkskel.py -f fileprefix -p prefix -m module'
- sys.exit(0)
- if not fileprefix or not prefix or not module:
- print 'usage: mkskel.py -f fileprefix -p prefix -m module'
- sys.exit(1)
- write_skels(fileprefix, prefix, module)
+++ /dev/null
-# -*- Mode: Python; py-indent-offset: 4 -*-
-
-# this file contains code for loading up an override file. The override file
-# provides implementations of functions where the code generator could not
-# do its job correctly.
-
-import fnmatch
-import os
-import re
-import string
-import sys
-
-def class2cname(klass, method):
- c_name = ''
- for c in klass:
- if c.isupper():
- c_name += '_' + c.lower()
- else:
- c_name += c
- return c_name[1:] + '_' + method
-
-# import python_type as c_name [for arg_type]
-# Last ('for') clause is optional. If present, the type will be
-# imported only if given 'arg_type' is registered.
-import_pat = re.compile(r'\s*import\s+(\S+)\.([^\s.]+)\s+as\s+(\S+)(\s+for\s+(\S+))?')
-
-class Overrides:
- def __init__(self, filename=None):
- self.modulename = None
- self.ignores = {}
- self.glob_ignores = []
- self.type_ignores = {}
- self.overrides = {}
- self.overridden = {}
- self.kwargs = {}
- self.noargs = {}
- self.onearg = {}
- self.staticmethod = {}
- self.classmethod = {}
- self.startlines = {}
- self.override_attrs = {}
- self.override_slots = {}
- self.headers = ''
- self.body = ''
- self.init = ''
- self.imports = []
- self.defines = {}
- self.functions = {}
- self.newstyle_constructors = {}
- self.dynamicnamespace = False
- if filename:
- self.handle_file(filename)
-
- def handle_file(self, filename):
- oldpath = os.getcwd()
-
- fp = open(filename, 'r')
- dirname = os.path.dirname(os.path.abspath(filename))
-
- if dirname != oldpath:
- os.chdir(dirname)
-
- # read all the components of the file ...
- bufs = []
- startline = 1
- lines = []
- line = fp.readline()
- linenum = 1
- while line:
- if line == '%%\n' or line == '%%':
- if lines:
- bufs.append((string.join(lines, ''), startline))
- startline = linenum + 1
- lines = []
- else:
- lines.append(line)
- line = fp.readline()
- linenum = linenum + 1
- if lines:
- bufs.append((string.join(lines, ''), startline))
- if not bufs: return
-
- for buf, startline in bufs:
- self.__parse_override(buf, startline, filename)
-
- os.chdir(oldpath)
-
- def __parse_override(self, buffer, startline, filename):
- pos = string.find(buffer, '\n')
- if pos >= 0:
- line = buffer[:pos]
- rest = buffer[pos+1:]
- else:
- line = buffer ; rest = ''
- words = string.split(line)
- command = words[0]
- if (command == 'ignore' or
- command == 'ignore-' + sys.platform):
- "ignore/ignore-platform [functions..]"
- for func in words[1:]:
- self.ignores[func] = 1
- for func in string.split(rest):
- self.ignores[func] = 1
- elif (command == 'ignore-glob' or
- command == 'ignore-glob-' + sys.platform):
- "ignore-glob/ignore-glob-platform [globs..]"
- for func in words[1:]:
- self.glob_ignores.append(func)
- for func in string.split(rest):
- self.glob_ignores.append(func)
- elif (command == 'ignore-type' or
- command == 'ignore-type-' + sys.platform):
- "ignore-type/ignore-type-platform [typenames..]"
- for typename in words[1:]:
- self.type_ignores[typename] = 1
- for typename in string.split(rest):
- self.type_ignores[typename] = 1
- elif command == 'override':
- "override function/method [kwargs|noargs|onearg] [staticmethod|classmethod]"
- func = words[1]
- if 'kwargs' in words[1:]:
- self.kwargs[func] = 1
- elif 'noargs' in words[1:]:
- self.noargs[func] = 1
- elif 'onearg' in words[1:]:
- self.onearg[func] = True
-
- if 'staticmethod' in words[1:]:
- self.staticmethod[func] = True
- elif 'classmethod' in words[1:]:
- self.classmethod[func] = True
- if func in self.overrides:
- raise RuntimeError("Function %s is being overridden more than once" % (func,))
- self.overrides[func] = rest
- self.startlines[func] = (startline + 1, filename)
- elif command == 'override-attr':
- "override-slot Class.attr"
- attr = words[1]
- self.override_attrs[attr] = rest
- self.startlines[attr] = (startline + 1, filename)
- elif command == 'override-slot':
- "override-slot Class.slot"
- slot = words[1]
- self.override_slots[slot] = rest
- self.startlines[slot] = (startline + 1, filename)
- elif command == 'headers':
- "headers"
- self.headers = '%s\n#line %d "%s"\n%s' % \
- (self.headers, startline + 1, filename, rest)
- elif command == 'body':
- "body"
- self.body = '%s\n#line %d "%s"\n%s' % \
- (self.body, startline + 1, filename, rest)
- elif command == 'init':
- "init"
- self.init = '%s\n#line %d "%s"\n%s' % \
- (self.init, startline + 1, filename, rest)
- elif command == 'modulename':
- "modulename name"
- self.modulename = words[1]
- elif command == 'include':
- "include filename"
- for filename in words[1:]:
- self.handle_file(filename)
- for filename in string.split(rest):
- self.handle_file(filename)
- elif command == 'import':
- "import module1 [\n module2, \n module3 ...]"
- for line in string.split(buffer, '\n'):
- match = import_pat.match(line)
- if match:
- module, pyname, cname, conditional, importing_for = match.groups()
- self.imports.append((module, pyname, cname, importing_for or None))
- elif command == 'define':
- "define funcname [kwargs|noargs|onearg] [classmethod|staticmethod]"
- "define Class.method [kwargs|noargs|onearg] [classmethod|staticmethod]"
- func = words[1]
- klass = None
- if func.find('.') != -1:
- klass, func = func.split('.', 1)
-
- if not self.defines.has_key(klass):
- self.defines[klass] = {}
- self.defines[klass][func] = rest
- else:
- self.functions[func] = rest
-
- if 'kwargs' in words[1:]:
- self.kwargs[func] = 1
- elif 'noargs' in words[1:]:
- self.noargs[func] = 1
- elif 'onearg' in words[1:]:
- self.onearg[func] = 1
-
- if 'staticmethod' in words[1:]:
- self.staticmethod[func] = True
- elif 'classmethod' in words[1:]:
- self.classmethod[func] = True
-
- self.startlines[func] = (startline + 1, filename)
-
- elif command == 'new-constructor':
- "new-constructor GType"
- gtype, = words[1:]
- self.newstyle_constructors[gtype] = True
- elif command == 'options':
- for option in words[1:]:
- if option == 'dynamicnamespace':
- self.dynamicnamespace = True
-
- def is_ignored(self, name):
- if self.ignores.has_key(name):
- return 1
- for glob in self.glob_ignores:
- if fnmatch.fnmatchcase(name, glob):
- return 1
- return 0
-
- def is_type_ignored(self, name):
- return name in self.type_ignores
-
- def is_overriden(self, name):
- return self.overrides.has_key(name)
-
- def is_already_included(self, name):
- return self.overridden.has_key(name)
-
- def override(self, name):
- self.overridden[name] = 1
- return self.overrides[name]
-
- def define(self, klass, name):
- self.overridden[class2cname(klass, name)] = 1
- return self.defines[klass][name]
-
- def function(self, name):
- return self.functions[name]
-
- def getstartline(self, name):
- return self.startlines[name]
-
- def wants_kwargs(self, name):
- return self.kwargs.has_key(name)
-
- def wants_noargs(self, name):
- return self.noargs.has_key(name)
-
- def wants_onearg(self, name):
- return self.onearg.has_key(name)
-
- def is_staticmethod(self, name):
- return self.staticmethod.has_key(name)
-
- def is_classmethod(self, name):
- return self.classmethod.has_key(name)
-
- def attr_is_overriden(self, attr):
- return self.override_attrs.has_key(attr)
-
- def attr_override(self, attr):
- return self.override_attrs[attr]
-
- def slot_is_overriden(self, slot):
- return self.override_slots.has_key(slot)
-
- def slot_override(self, slot):
- return self.override_slots[slot]
-
- def get_headers(self):
- return self.headers
-
- def get_body(self):
- return self.body
-
- def get_init(self):
- return self.init
-
- def get_imports(self):
- return self.imports
-
- def get_defines_for(self, klass):
- return self.defines.get(klass, {})
-
- def get_functions(self):
- return self.functions
+++ /dev/null
-### -*- python -*-
-### Code to generate "Reverse Wrappers", i.e. C->Python wrappers
-### (C) 2004 Gustavo Carneiro <gjc@gnome.org>
-import argtypes
-import os
-
-DEBUG_MODE = ('PYGTK_CODEGEN_DEBUG' in os.environ)
-
-def join_ctype_name(ctype, name):
- '''Joins a C type and a variable name into a single string'''
- if ctype[-1] != '*':
- return " ".join((ctype, name))
- else:
- return "".join((ctype, name))
-
-
-class CodeSink(object):
- def __init__(self):
- self.indent_level = 0 # current indent level
- self.indent_stack = [] # previous indent levels
-
- def _format_code(self, code):
- assert isinstance(code, str)
- l = []
- for line in code.split('\n'):
- l.append(' '*self.indent_level + line)
- if l[-1]:
- l.append('')
- return '\n'.join(l)
-
- def writeln(self, line=''):
- raise NotImplementedError
-
- def indent(self, level=4):
- '''Add a certain ammount of indentation to all lines written
- from now on and until unindent() is called'''
- self.indent_stack.append(self.indent_level)
- self.indent_level += level
-
- def unindent(self):
- '''Revert indentation level to the value before last indent() call'''
- self.indent_level = self.indent_stack.pop()
-
-
-class FileCodeSink(CodeSink):
- def __init__(self, fp):
- CodeSink.__init__(self)
- assert isinstance(fp, file)
- self.fp = fp
-
- def writeln(self, line=''):
- self.fp.write(self._format_code(line))
-
-class MemoryCodeSink(CodeSink):
- def __init__(self):
- CodeSink.__init__(self)
- self.lines = []
-
- def writeln(self, line=''):
- self.lines.append(self._format_code(line))
-
- def flush_to(self, sink):
- assert isinstance(sink, CodeSink)
- for line in self.lines:
- sink.writeln(line.rstrip())
- self.lines = []
-
- def flush(self):
- l = []
- for line in self.lines:
- l.append(self._format_code(line))
- self.lines = []
- return "".join(l)
-
-class ReverseWrapper(object):
- '''Object that generates a C->Python wrapper'''
- def __init__(self, cname, is_static=True):
- assert isinstance(cname, str)
-
- self.cname = cname
- ## function object we will call, or object whose method we will call
- self.called_pyobj = None
- ## name of method of self.called_pyobj we will call
- self.method_name = None
- self.is_static = is_static
-
- self.parameters = []
- self.declarations = MemoryCodeSink()
- self.post_return_code = MemoryCodeSink()
- self.body = MemoryCodeSink()
- self.check_exception_code = MemoryCodeSink()
- self.cleanup_actions = []
- self.pyargv_items = []
- self.pyargv_optional_items = []
- self.pyret_parse_items = [] # list of (format_spec, parameter)
- self.code_sinks_stack = [self.body]
-
- def set_call_target(self, called_pyobj, method_name=None):
- assert called_pyobj is not None
- assert self.called_pyobj is None
- self.called_pyobj = called_pyobj
- self.method_name = method_name
-
- def set_return_type(self, return_type):
- assert isinstance(return_type, ReturnType)
- self.return_type = return_type
-
- def add_parameter(self, param):
- assert isinstance(param, Parameter)
- self.parameters.append(param)
-
- def add_declaration(self, decl_code):
- self.declarations.writeln(decl_code)
-
- def add_pyargv_item(self, variable, optional=False):
- if optional:
- self.pyargv_optional_items.append(variable)
- else:
- self.pyargv_items.append(variable)
-
- def add_pyret_parse_item(self, format_specifier, parameter, prepend=False):
- if prepend:
- self.pyret_parse_items.insert(0, (format_specifier, parameter))
- else:
- self.pyret_parse_items.append((format_specifier, parameter))
-
-
- def push_code_sink(self, code_sink):
- self.code_sinks_stack.insert(0, code_sink)
-
- def pop_code_sink(self):
- return self.code_sinks_stack.pop(0)
-
-
- def write_code(self, code,
- cleanup=None,
- failure_expression=None,
- failure_cleanup=None,
- failure_exception=None,
- code_sink=None):
- '''Add a chunk of code with cleanup and error handling
-
- This method is to be used by TypeHandlers when generating code
-
- Keywork arguments:
- code -- code to add
- cleanup -- code to cleanup any dynamic resources created by @code
- (except in case of failure) (default None)
- failure_expression -- C boolean expression to indicate
- if anything failed (default None)
- failure_cleanup -- code to cleanup any dynamic resources
- created by @code in case of failure (default None)
- failure_exception -- code to raise an exception in case of
- failure (which will be immediately
- printed and cleared), (default None)
- code_sink -- "code sink" to use; by default,
- ReverseWrapper.body is used, which writes the
- main body of the wrapper, before calling the
- python method. Alternatively,
- ReverseWrapper.after_pyret_parse can be used, to
- write code after the PyArg_ParseTuple that
- parses the python method return value.
- '''
- if code_sink is None:
- code_sink = self.code_sinks_stack[0]
- if code is not None:
- code_sink.writeln(code)
- if failure_expression is not None:
- code_sink.writeln("if (%s) {" % (failure_expression,))
- code_sink.indent()
- if failure_exception is None:
- code_sink.writeln("if (PyErr_Occurred())")
- code_sink.indent()
- code_sink.writeln("PyErr_Print();")
- code_sink.unindent()
- else:
- code_sink.writeln(failure_exception)
- code_sink.writeln("PyErr_Print();")
- if failure_cleanup is not None:
- code_sink.writeln(failure_cleanup)
- for cleanup_action in self.cleanup_actions:
- code_sink.writeln(cleanup_action)
-
- self.push_code_sink(code_sink)
- try:
- self.return_type.write_error_return()
- finally:
- self.pop_code_sink()
-
- code_sink.unindent()
- code_sink.writeln("}")
- if cleanup is not None:
- self.cleanup_actions.insert(0, cleanup)
-
- def generate(self, sink):
- '''Generate the code into a CodeSink object'''
- assert isinstance(sink, CodeSink)
-
- if DEBUG_MODE:
- self.declarations.writeln("/* begin declarations */")
- self.body.writeln("/* begin main body */")
- self.post_return_code.writeln("/* begin post-return code */")
-
- self.add_declaration("PyGILState_STATE __py_state;")
- self.write_code(code="__py_state = pyg_gil_state_ensure();",
- cleanup="pyg_gil_state_release(__py_state);")
-
- for param in self.parameters:
- param.convert_c2py()
-
- assert self.called_pyobj is not None,\
- "Parameters failed to provide a target function or method."
-
- if self.is_static:
- sink.writeln('static %s' % self.return_type.get_c_type())
- else:
- sink.writeln(self.return_type.get_c_type())
- c_proto_params = map(Parameter.format_for_c_proto, self.parameters)
- sink.writeln("%s(%s)\n{" % (self.cname, ", ".join(c_proto_params)))
-
- self.return_type.write_decl()
- self.add_declaration("PyObject *py_retval;")
-
- ## Handle number of arguments
- if self.pyargv_items:
- self.add_declaration("PyObject *py_args;")
- py_args = "py_args"
- if self.pyargv_optional_items:
- self.add_declaration("int argc = %i;" % len(self.pyargv_items))
- argc = "argc"
- for arg in self.pyargv_optional_items:
- self.body.writeln("if (%s)" % arg)
- self.body.indent()
- self.body.writeln("++argc;")
- self.body.unindent()
- else:
- argc = str(len(self.pyargv_items))
- else:
- if self.pyargv_optional_items:
- self.add_declaration("PyObject *py_args;")
- py_args = "py_args"
- self.add_declaration("int argc = 0;")
- argc = "argc"
- for arg in self.pyargv_optional_items:
- self.body.writeln("if (%s)" % arg)
- self.body.indent()
- self.body.writeln("++argc;")
- self.body.unindent()
- else:
- py_args = "NULL"
- argc = None
-
- self.body.writeln()
-
- if py_args != "NULL":
- self.write_code("py_args = PyTuple_New(%s);" % argc,
- cleanup="Py_DECREF(py_args);")
- pos = 0
- for arg in self.pyargv_items:
- try: # try to remove the Py_DECREF cleanup action, if we can
- self.cleanup_actions.remove("Py_DECREF(%s);" % arg)
- except ValueError: # otherwise we have to Py_INCREF..
- self.body.writeln("Py_INCREF(%s);" % arg)
- self.body.writeln("PyTuple_SET_ITEM(%s, %i, %s);" % (py_args, pos, arg))
- pos += 1
- for arg in self.pyargv_optional_items:
- self.body.writeln("if (%s) {" % arg)
- self.body.indent()
- try: # try to remove the Py_DECREF cleanup action, if we can
- self.cleanup_actions.remove("Py_XDECREF(%s);" % arg)
- except ValueError: # otherwise we have to Py_INCREF..
- self.body.writeln("Py_INCREF(%s);" % arg)
- self.body.writeln("PyTuple_SET_ITEM(%s, %i, %s);" % (py_args, pos, arg))
- self.body.unindent()
- self.body.writeln("}")
- pos += 1
-
- self.body.writeln()
-
- ## Call the python method
- if self.method_name is None:
- self.write_code("py_retval = PyObject_Call(%s, %s);"
- % (self.called_pyobj, py_args),
- cleanup="Py_XDECREF(py_retval);")
- self.check_exception_code.flush_to(self.body)
- self.write_code(None, failure_expression="!py_retval")
-
- else:
- self.add_declaration("PyObject *py_method;")
- self.write_code("py_method = PyObject_GetAttrString(%s, \"%s\");"
- % (self.called_pyobj, self.method_name),
- cleanup="Py_DECREF(py_method);",
- failure_expression="!py_method")
- self.write_code("py_retval = PyObject_CallObject(py_method, %s);"
- % (py_args,),
- cleanup="Py_XDECREF(py_retval);")
- self.check_exception_code.flush_to(self.body)
- self.write_code(None, failure_expression="!py_retval")
-
- ## -- Handle the return value --
-
- ## we need to check if the return_type object is prepared to cooperate with multiple return values
- len_before = len(self.pyret_parse_items)
- self.return_type.write_conversion()
- len_after = len(self.pyret_parse_items)
- assert (self.return_type.get_c_type() == 'void'
- or not (len_before == len_after and len_after > 0)),\
- ("Bug in reverse wrappers: return type handler %s"
- " is not prepared to cooperate multiple return values") % (type(self.return_type),)
-
- sink.indent()
-
- if self.pyret_parse_items == [("", "")]:
- ## special case when there are no return parameters
- self.write_code(
- code=None,
- failure_expression='py_retval != Py_None',
- failure_exception=('PyErr_SetString(PyExc_TypeError, '
- '"virtual method should return None");'))
- else:
- if len(self.pyret_parse_items) == 1:
- ## if retval is one item only, pack it in a tuple so we
- ## can use PyArg_ParseTuple as usual..
- self.write_code('py_retval = Py_BuildValue("(N)", py_retval);')
- if len(self.pyret_parse_items) > 0:
- ## Parse return values using PyArg_ParseTuple
- params = ["py_retval",
- '"%s"' % "".join([format for format, param in self.pyret_parse_items])]
- params.extend([param for format, param in self.pyret_parse_items if param])
- self.write_code(code=None, failure_expression=(
- '!PyArg_ParseTuple(%s)' % (', '.join(params),)))
-
- if DEBUG_MODE:
- self.declarations.writeln("/* end declarations */")
- self.declarations.flush_to(sink)
- sink.writeln()
- if DEBUG_MODE:
- self.body.writeln("/* end main body */")
- self.body.flush_to(sink)
- sink.writeln()
- if DEBUG_MODE:
- self.post_return_code.writeln("/* end post-return code */")
- self.post_return_code.flush_to(sink)
- sink.writeln()
-
- for cleanup_action in self.cleanup_actions:
- sink.writeln(cleanup_action)
- if self.return_type.get_c_type() != 'void':
- sink.writeln()
- sink.writeln("return retval;")
- sink.unindent()
- sink.writeln("}")
-
-class TypeHandler(object):
- def __init__(self, wrapper, **props):
- assert isinstance(wrapper, ReverseWrapper)
- self.wrapper = wrapper
- self.props = props
-
-class ReturnType(TypeHandler):
-
- supports_optional = False
-
- def get_c_type(self):
- raise NotImplementedError
-
- def write_decl(self):
- raise NotImplementedError
-
- def write_error_return(self):
- '''Write "return <value>" code in case of error'''
- raise NotImplementedError
-
- def write_conversion(self):
- '''Writes code to convert Python return value in 'py_retval'
- into C 'retval'. Returns a string with C boolean expression
- that determines if anything went wrong. '''
- raise NotImplementedError
-
-class Parameter(TypeHandler):
-
- def __init__(self, wrapper, name, **props):
- TypeHandler.__init__(self, wrapper, **props)
- self.name = name
-
- def get_c_type(self):
- raise NotImplementedError
-
- def convert_c2py(self):
- '''Write some code before calling the Python method.'''
- pass
-
- def format_for_c_proto(self):
- return join_ctype_name(self.get_c_type(), self.name)
-
-
-###---
-class StringParam(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'char *').replace('const-', 'const ')
-
- def convert_c2py(self):
- if self.props.get('optional', False):
- self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
- self.wrapper.write_code(code=("if (%s)\n"
- " py_%s = PyString_FromString(%s);\n"
- % (self.name, self.name, self.name)),
- cleanup=("Py_XDECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name, optional=True)
- elif self.props.get('nullok', False):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("if (%s)\n"
- " py_%s = PyString_FromString(%s);\n"
- "else {\n"
- " Py_INCREF(Py_None);\n"
- " py_%s = Py_None;\n"
- "}\n"
- % (self.name, self.name, self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
- else:
- self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
- self.wrapper.write_code(code=("if (%s)\n"
- " py_%s = PyString_FromString(%s);\n" %
- (self.name, self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name),
- failure_expression=("!py_%s" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-for ctype in ('char*', 'gchar*', 'const-char*', 'char-const*', 'const-gchar*',
- 'gchar-const*', 'string', 'static_string'):
- argtypes.matcher.register_reverse(ctype, StringParam)
-del ctype
-
-class StringReturn(ReturnType):
-
- def get_c_type(self):
- return self.props.get('c_type', 'char *').replace('const-', 'const ')
- #return "char *"
-
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- #self.wrapper.add_declaration("char *retval;")
-
- def write_error_return(self):
- self.wrapper.write_code("return NULL;")
-
- def write_conversion(self):
- self.wrapper.add_pyret_parse_item("s", "&retval", prepend=True)
- self.wrapper.write_code("retval = g_strdup(retval);", code_sink=self.wrapper.post_return_code)
-
-for ctype in ('char*', 'gchar*', 'const-gchar*'):
- argtypes.matcher.register_reverse_ret(ctype, StringReturn)
-del ctype
-
-
-class VoidReturn(ReturnType):
-
- def get_c_type(self):
- return "void"
-
- def write_decl(self):
- pass
-
- def write_error_return(self):
- self.wrapper.write_code("return;")
-
- def write_conversion(self):
- self.wrapper.add_pyret_parse_item("", "", prepend=True)
-
-argtypes.matcher.register_reverse_ret('void', VoidReturn)
-argtypes.matcher.register_reverse_ret('none', VoidReturn)
-
-class GObjectParam(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'GObject *')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
- self.wrapper.write_code(code=("if (%s)\n"
- " py_%s = pygobject_new((GObject *) %s);\n"
- "else {\n"
- " Py_INCREF(Py_None);\n"
- " py_%s = Py_None;\n"
- "}"
- % (self.name, self.name, self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse('GObject*', GObjectParam)
-
-class GObjectReturn(ReturnType):
-
- supports_optional = True
-
- def get_c_type(self):
- return self.props.get('c_type', 'GObject *')
-
- def write_decl(self):
- if not self.props.get('optional'):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- else:
- self.wrapper.add_declaration("%s retval = NULL;" % self.get_c_type())
-
- def write_error_return(self):
- self.wrapper.write_code("return NULL;")
-
- def write_conversion(self):
- if not self.props.get('optional'):
- self.wrapper.write_code(
- code=None,
- failure_expression="!PyObject_TypeCheck(py_retval, &PyGObject_Type)",
- failure_exception='PyErr_SetString(PyExc_TypeError, "retval should be a GObject");')
- self.wrapper.write_code("retval = (%s) pygobject_get(py_retval);"
- % self.get_c_type())
- self.wrapper.write_code("g_object_ref((GObject *) retval);")
- else:
- self.wrapper.write_code(
- code=None,
- failure_expression="py_retval != Py_None && !PyObject_TypeCheck(py_retval, &PyGObject_Type)",
- failure_exception='PyErr_SetString(PyExc_TypeError, "retval should be None or a GObject");')
- self.wrapper.write_code("if (py_retval != Py_None) {\n"
- " retval = (%s) pygobject_get(py_retval);\n"
- " g_object_ref((GObject *) retval);\n"
- "}\n"
- % self.get_c_type())
-
-argtypes.matcher.register_reverse_ret('GObject*', GObjectReturn)
-
-
-
-class IntParam(Parameter):
-
- def get_c_type(self):
- return self.props.get('c_type', 'int')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = PyInt_FromLong(%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-class IntReturn(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type', 'int')
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- def write_error_return(self):
- self.wrapper.write_code("return -G_MAXINT;")
- def write_conversion(self):
- self.wrapper.add_pyret_parse_item("i", "&retval", prepend=True)
-
-for argtype in ('int', 'gint', 'guint', 'short', 'gshort', 'gushort', 'long',
- 'glong', 'gsize', 'gssize', 'guint8', 'gint8', 'guint16',
- 'gint16', 'gint32', 'GTime'):
- argtypes.matcher.register_reverse(argtype, IntParam)
- argtypes.matcher.register_reverse_ret(argtype, IntReturn)
-del argtype
-
-class IntPtrParam(Parameter):
- def __init__(self, wrapper, name, **props):
- if "direction" not in props:
- raise argtypes.ArgTypeConfigurationError(
- "cannot use int* parameter without direction")
- if props["direction"] not in ("out", "inout"):
- raise argtypes.ArgTypeConfigurationError(
- "cannot use int* parameter with direction '%s'"
- % (props["direction"],))
- Parameter.__init__(self, wrapper, name, **props)
- def get_c_type(self):
- return self.props.get('c_type', 'int*')
- def convert_c2py(self):
- if self.props["direction"] == "inout":
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = PyInt_FromLong(*%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
- self.wrapper.add_pyret_parse_item("i", self.name)
-for argtype in ('int*', 'gint*'):
- argtypes.matcher.register_reverse(argtype, IntPtrParam)
-del argtype
-
-
-class GEnumReturn(IntReturn):
- def write_conversion(self):
- self.wrapper.write_code(
- code=None,
- failure_expression=(
- "pyg_enum_get_value(%s, py_retval, (gint *)&retval)"
- % (self.props['typecode'],)))
-
-argtypes.matcher.register_reverse_ret("GEnum", GEnumReturn)
-
-class GEnumParam(IntParam):
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = pyg_enum_from_gtype(%s, %s);" %
- (self.name, self.props['typecode'], self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name),
- failure_expression=("!py_%s" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse("GEnum", GEnumParam)
-
-class GFlagsReturn(IntReturn):
- def write_conversion(self):
- self.wrapper.write_code(
- code=None,
- failure_expression=(
- "pyg_flags_get_value(%s, py_retval, (gint *)&retval)" %
- self.props['typecode']))
-
-argtypes.matcher.register_reverse_ret("GFlags", GFlagsReturn)
-
-class GFlagsParam(IntParam):
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=(
- "py_%s = pyg_flags_from_gtype(%s, %s);" %
- (self.name, self.props['typecode'], self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name),
- failure_expression=("!py_%s" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse("GFlags", GFlagsParam)
-
-
-class GtkTreePathParam(IntParam):
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=(
- "py_%s = pygtk_tree_path_to_pyobject(%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name),
- failure_expression=("!py_%s" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse("GtkTreePath*", GtkTreePathParam)
-
-
-class GtkTreePathReturn(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type', 'GtkTreePath *')
- def write_decl(self):
- self.wrapper.add_declaration("GtkTreePath * retval;")
- def write_error_return(self):
- self.wrapper.write_code("return NULL;")
- def write_conversion(self):
- self.wrapper.write_code(
- "retval = pygtk_tree_path_from_pyobject(py_retval);\n",
- failure_expression=('!retval'),
- failure_exception=(
- 'PyErr_SetString(PyExc_TypeError, "retval should be a GtkTreePath");'))
-
-argtypes.matcher.register_reverse_ret("GtkTreePath*", GtkTreePathReturn)
-
-
-class BooleanReturn(ReturnType):
- def get_c_type(self):
- return "gboolean"
- def write_decl(self):
- self.wrapper.add_declaration("gboolean retval;")
- self.wrapper.add_declaration("PyObject *py_main_retval;")
- def write_error_return(self):
- self.wrapper.write_code("return FALSE;")
- def write_conversion(self):
- self.wrapper.add_pyret_parse_item("O", "&py_main_retval", prepend=True)
- self.wrapper.write_code(
- "retval = PyObject_IsTrue(py_main_retval)? TRUE : FALSE;",
- code_sink=self.wrapper.post_return_code)
-argtypes.matcher.register_reverse_ret("gboolean", BooleanReturn)
-
-class BooleanParam(Parameter):
- def get_c_type(self):
- return "gboolean"
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code("py_%s = %s? Py_True : Py_False;"
- % (self.name, self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse("gboolean", BooleanParam)
-
-
-class DoubleParam(Parameter):
- def get_c_type(self):
- return self.props.get('c_type', 'gdouble')
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = PyFloat_FromDouble(%s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-class DoublePtrParam(Parameter):
- def __init__(self, wrapper, name, **props):
- if "direction" not in props:
- raise argtypes.ArgTypeConfigurationError(
- "cannot use double* parameter without direction")
- if props["direction"] not in ("out", ): # inout not yet implemented
- raise argtypes.ArgTypeConfigurationError(
- "cannot use double* parameter with direction '%s'"
- % (props["direction"],))
- Parameter.__init__(self, wrapper, name, **props)
- def get_c_type(self):
- return self.props.get('c_type', 'double*')
- def convert_c2py(self):
- self.wrapper.add_pyret_parse_item("d", self.name)
-for argtype in ('double*', 'gdouble*'):
- argtypes.matcher.register_reverse(argtype, DoublePtrParam)
-del argtype
-
-class DoubleReturn(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type', 'gdouble')
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- def write_error_return(self):
- self.wrapper.write_code("return -G_MAXFLOAT;")
- def write_conversion(self):
- self.wrapper.add_pyret_parse_item("d", "&retval", prepend=True)
-
-for argtype in ('float', 'double', 'gfloat', 'gdouble'):
- argtypes.matcher.register_reverse(argtype, DoubleParam)
- argtypes.matcher.register_reverse_ret(argtype, DoubleReturn)
-
-
-class GBoxedParam(Parameter):
- def get_c_type(self):
- return self.props.get('c_type').replace('const-', 'const ')
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- ctype = self.get_c_type()
- if ctype.startswith('const '):
- ctype_no_const = ctype[len('const '):]
- self.wrapper.write_code(
- code=('py_%s = pyg_boxed_new(%s, (%s) %s, TRUE, TRUE);' %
- (self.name, self.props['typecode'],
- ctype_no_const, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- else:
- self.wrapper.write_code(
- code=('py_%s = pyg_boxed_new(%s, %s, FALSE, FALSE);' %
- (self.name, self.props['typecode'], self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse("GBoxed", GBoxedParam)
-
-
-class GBoxedReturn(ReturnType):
- def get_c_type(self):
- return self.props.get('c_type')
- def write_decl(self):
- self.wrapper.add_declaration("%s retval;" % self.get_c_type())
- def write_error_return(self):
- self.wrapper.write_code("return retval;")
- def write_conversion(self):
- self.wrapper.write_code(code = None,
- failure_expression=("!pyg_boxed_check(py_retval, %s)" %
- (self.props['typecode'],)),
- failure_exception=(
- 'PyErr_SetString(PyExc_TypeError, "retval should be a %s");'
- % (self.props['typename'],)))
- self.wrapper.write_code('retval = pyg_boxed_get(py_retval, %s);' %
- self.props['typename'])
-
-argtypes.matcher.register_reverse_ret("GBoxed", GBoxedReturn)
-
-
-class GdkRegionPtrReturn(GBoxedReturn):
- def write_error_return(self):
- self.wrapper.write_code("return gdk_region_new();")
- def write_conversion(self):
- self.props['typecode'] = 'PYGDK_TYPE_REGION'
- self.props['typename'] = 'GdkRegion'
- super(GdkRegionPtrReturn, self).write_conversion()
-
-argtypes.matcher.register_reverse_ret("GdkRegion*", GdkRegionPtrReturn)
-
-
-class PangoFontDescriptionReturn(GBoxedReturn):
- def write_error_return(self):
- self.wrapper.write_code("return pango_font_description_new();")
- def write_conversion(self):
- self.props['typecode'] = 'PANGO_TYPE_FONT_DESCRIPTION'
- self.props['typename'] = 'PangoFontDescription'
- super(PangoFontDescriptionReturn, self).write_conversion()
-
-argtypes.matcher.register_reverse_ret("PangoFontDescription*",
- PangoFontDescriptionReturn)
-
-
-class PangoFontMetricsReturn(GBoxedReturn):
- def write_error_return(self):
- self.wrapper.write_code("return pango_font_metrics_new();")
- def write_conversion(self):
- self.props['typecode'] = 'PANGO_TYPE_FONT_METRICS'
- self.props['typename'] = 'PangoFontMetrics'
- super(PangoFontMetricsReturn, self).write_conversion()
-
-argtypes.matcher.register_reverse_ret("PangoFontMetrics*",
- PangoFontMetricsReturn)
-
-
-class PangoLanguageReturn(GBoxedReturn):
- def write_error_return(self):
- self.wrapper.write_code("return pango_language_from_string(\"\");")
- def write_conversion(self):
- self.props['typecode'] = 'PANGO_TYPE_LANGUAGE'
- self.props['typename'] = 'PangoLanguage'
- super(PangoLanguageReturn, self).write_conversion()
-
-argtypes.matcher.register_reverse_ret("PangoLanguage*", PangoLanguageReturn)
-
-
-class GdkRectanglePtrParam(Parameter):
- def get_c_type(self):
- return self.props.get('c_type').replace('const-', 'const ')
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(
- code=('py_%s = pyg_boxed_new(GDK_TYPE_RECTANGLE, %s, TRUE, TRUE);' %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name))
- self.wrapper.add_pyargv_item("py_%s" % self.name)
-
-argtypes.matcher.register_reverse("GdkRectangle*", GdkRectanglePtrParam)
-argtypes.matcher.register_reverse('GtkAllocation*', GdkRectanglePtrParam)
-
-
-class GErrorParam(Parameter):
- def get_c_type(self):
- return self.props.get('c_type').replace('**', ' **')
- def convert_c2py(self):
- self.wrapper.write_code(code=None,
- failure_expression=("pyg_gerror_exception_check(%s)" % self.name),
- code_sink=self.wrapper.check_exception_code)
-
-argtypes.matcher.register_reverse('GError**', GErrorParam)
-
-
-class PyGObjectMethodParam(Parameter):
- def __init__(self, wrapper, name, method_name, **props):
- Parameter.__init__(self, wrapper, name, **props)
- self.method_name = method_name
-
- def get_c_type(self):
- return self.props.get('c_type', 'GObject *')
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
- self.wrapper.write_code(code=("py_%s = pygobject_new((GObject *) %s);" %
- (self.name, self.name)),
- cleanup=("Py_DECREF(py_%s);" % self.name),
- failure_expression=("!py_%s" % self.name))
- self.wrapper.set_call_target("py_%s" % self.name, self.method_name)
-
-
-class CallbackInUserDataParam(Parameter):
- def __init__(self, wrapper, name, free_it, **props):
- Parameter.__init__(self, wrapper, name, **props)
- self.free_it = free_it
-
- def get_c_type(self):
- return "gpointer"
-
- def convert_c2py(self):
- self.wrapper.add_declaration("PyObject **_user_data;")
- cleanup = self.free_it and ("g_free(%s);" % self.name) or None
- self.wrapper.write_code(code=("_real_user_data = (PyObject **) %s;"
- % self.name),
- cleanup=cleanup)
-
- self.wrapper.add_declaration("PyObject *py_func;")
- cleanup = self.free_it and "Py_DECREF(py_func);" or None
- self.wrapper.write_code(code="py_func = _user_data[0];",
- cleanup=cleanup)
- self.wrapper.set_call_target("py_func")
-
- self.wrapper.add_declaration("PyObject *py_user_data;")
- cleanup = self.free_it and "Py_XDECREF(py_user_data);" or None
- self.wrapper.write_code(code="py_user_data = _user_data[1];",
- cleanup=cleanup)
- self.wrapper.add_pyargv_item("py_user_data", optional=True)
-
-def _test():
- import sys
-
- if 1:
- wrapper = ReverseWrapper("this_is_the_c_function_name", is_static=True)
- wrapper.set_return_type(StringReturn(wrapper))
- wrapper.add_parameter(PyGObjectMethodParam(wrapper, "self", method_name="do_xxx"))
- wrapper.add_parameter(StringParam(wrapper, "param2", optional=True))
- wrapper.add_parameter(GObjectParam(wrapper, "param3"))
- #wrapper.add_parameter(InoutIntParam(wrapper, "param4"))
- wrapper.generate(FileCodeSink(sys.stderr))
-
- if 0:
- wrapper = ReverseWrapper("this_a_callback_wrapper")
- wrapper.set_return_type(VoidReturn(wrapper))
- wrapper.add_parameter(StringParam(wrapper, "param1", optional=False))
- wrapper.add_parameter(GObjectParam(wrapper, "param2"))
- wrapper.add_parameter(CallbackInUserDataParam(wrapper, "data", free_it=True))
- wrapper.generate(FileCodeSink(sys.stderr))
-
-if __name__ == '__main__':
- _test()
+++ /dev/null
-#!/usr/bin/env python
-# -*- Mode: Python; py-indent-offset: 4 -*-
-from __future__ import generators
-
-import string
-from cStringIO import StringIO
-
-class error(Exception):
- def __init__(self, filename, lineno, msg):
- Exception.__init__(self, msg)
- self.filename = filename
- self.lineno = lineno
- self.msg = msg
- def __str__(self):
- return '%s:%d: error: %s' % (self.filename, self.lineno, self.msg)
-
-trans = [' '] * 256
-for i in range(256):
- if chr(i) in string.letters + string.digits + '_':
- trans[i] = chr(i)
- else:
- trans[i] = '_'
-trans = string.join(trans, '')
-
-def parse(filename):
- if isinstance(filename, str):
- fp = open(filename, 'r')
- else: # if not string, assume it is some kind of iterator
- fp = filename
- filename = getattr(fp, 'name', '<unknown>')
- whitespace = ' \t\n\r\x0b\x0c'
- nonsymbol = whitespace + '();\'"'
- stack = []
- openlines = []
- lineno = 0
- for line in fp:
- pos = 0
- lineno += 1
- while pos < len(line):
- if line[pos] in whitespace: # ignore whitespace
- pass
- elif line[pos] == ';': # comment
- break
- elif line[pos:pos+2] == "'(":
- pass # the open parenthesis will be handled next iteration
- elif line[pos] == '(':
- stack.append(())
- openlines.append(lineno)
- elif line[pos] == ')':
- if len(stack) == 0:
- raise error(filename, lineno, 'close parenthesis found when none open')
- closed = stack[-1]
- del stack[-1]
- del openlines[-1]
- if stack:
- stack[-1] += (closed,)
- else:
- yield closed
- elif line[pos] == '"': # quoted string
- if not stack:
- raise error(filename, lineno,
- 'string found outside of s-expression')
- endpos = pos + 1
- chars = []
- while endpos < len(line):
- if endpos+1 < len(line) and line[endpos] == '\\':
- endpos += 1
- if line[endpos] == 'n':
- chars.append('\n')
- elif line[endpos] == 'r':
- chars.append('\r')
- elif line[endpos] == 't':
- chars.append('\t')
- else:
- chars.append('\\')
- chars.append(line[endpos])
- elif line[endpos] == '"':
- break
- else:
- chars.append(line[endpos])
- endpos += 1
- if endpos >= len(line):
- raise error(filename, lineno, "unclosed quoted string")
- pos = endpos
- stack[-1] += (''.join(chars),)
- else: # symbol/number
- if not stack:
- raise error(filename, lineno,
- 'identifier found outside of s-expression')
- endpos = pos
- while endpos < len(line) and line[endpos] not in nonsymbol:
- endpos += 1
- symbol = line[pos:endpos]
- pos = max(pos, endpos-1)
- try: symbol = int(symbol)
- except ValueError:
- try: symbol = float(symbol)
- except ValueError: pass
- stack[-1] += (symbol,)
- pos += 1
- if len(stack) != 0:
- msg = '%d unclosed parentheses found at end of ' \
- 'file (opened on line(s) %s)' % (len(stack),
- ', '.join(map(str, openlines)))
- raise error(filename, lineno, msg)
-
-class Parser:
- def __init__(self, filename):
- """Argument is either a string, a parse tree, or file object"""
- self.filename = filename
- def startParsing(self, filename=None):
- statements = parse(filename or self.filename)
- for statement in statements:
- self.handle(statement)
- def handle(self, tup):
- cmd = string.translate(tup[0], trans)
- if hasattr(self, cmd):
- getattr(self, cmd)(*tup[1:])
- else:
- self.unknown(tup)
- def unknown(self, tup):
- pass
-
-_testString = """; a scheme file
-(define-func gdk_font_load ; a comment at end of line
- GdkFont
- ((string name)))
-
-(define-boxed GdkEvent
- gdk_event_copy
- gdk_event_free
- "sizeof(GdkEvent)")
-"""
-
-if __name__ == '__main__':
- import sys
- if sys.argv[1:]:
- fp = open(sys.argv[1])
- else:
- fp = StringIO(_testString)
- statements = parse(fp)
- for s in statements:
- print `s`
+++ /dev/null
-examplesdir = $(pkgdatadir)/$(GST_MAJORMINOR)/examples
-
-examples_DATA = \
- simple.py
- effect.py
-
-EXTRA_DIST = $(examples_DATA)
+++ /dev/null
-#!/usr/bin/env python
-#
-# effect.py
-#
-# Copyright (C) 2011 Mathieu Duponchelle <seeed@laposte.net>
-# Copyright (C) 2011 Luis de Bethencourt <luis.debethencourt@collabora.co.uk>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-
-import sys
-import optparse
-
-import glib
-import gobject
-gobject.threads_init()
-
-import gst
-import ges
-
-class Effect:
- def __init__(self, effects):
- ges.init()
- self.mainloop = glib.MainLoop()
-
- self.timeline = ges.timeline_new_audio_video()
- layer = ges.TimelineLayer()
- self.src = ges.TimelineTestSource()
- self.src.set_start(long(0))
-
- self.src.set_duration(long(3000000000))
- self.src.set_vpattern("smpte75")
- layer.add_object(self.src)
- self.timeline.add_layer(layer)
-
- self.add_effects(effects)
-
- self.pipeline = ges.TimelinePipeline()
- self.pipeline.add_timeline(self.timeline)
- bus = self.pipeline.get_bus()
- bus.set_sync_handler(self.bus_handler)
-
- def add_effects(self, effects):
- for e in effects:
- effect = ges.TrackParseLaunchEffect(e)
- self.src.add_track_object(effect)
- for track in self.timeline.get_tracks():
- if track.get_caps().to_string() == \
- "video/x-raw-yuv; video/x-raw-rgb":
- print "setting effect: " + e
- track.add_object(effect)
-
- def bus_handler(self, unused_bus, message):
- if message.type == gst.MESSAGE_ERROR:
- print "ERROR"
- self.mainloop.quit()
- elif message.type == gst.MESSAGE_EOS:
- print "Done"
- self.mainloop.quit()
-
- return gst.BUS_PASS
-
- def run(self):
- if (self.pipeline.set_state(gst.STATE_PLAYING) == \
- gst.STATE_CHANGE_FAILURE):
- print "Couldn't start pipeline"
-
- self.mainloop.run()
-
-def main(args):
- usage = "usage: %s effect_name-1 .. effect_name-n\n" % args[0]
-
- if len(args) < 2:
- print usage + "using aging tv as a default instead"
- args.append("agingtv")
-
- parser = optparse.OptionParser (usage=usage)
- (opts, args) = parser.parse_args ()
-
- effect = Effect(args)
- effect.run()
-
-if __name__ == "__main__":
- main(sys.argv)
+++ /dev/null
-#!/usr/bin/env python
-#
-# simple.py
-#
-# Copyright (C) 2011 Thibault Saunier <thibault.saunier@collabora.co.uk>
-# Copyright (C) 2011 Luis de Bethencourt <luis.debethencourt@collabora.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-
-import sys
-import optparse
-
-import glib
-import gobject
-gobject.threads_init()
-
-import gst
-import ges
-
-class Simple:
- def __init__(self, uris):
- # init ges to have debug logs
- ges.init()
- self.mainloop = glib.MainLoop()
-
- timeline = ges.timeline_new_audio_video()
- self.layer = ges.SimpleTimelineLayer()
- timeline.add_layer(self.layer)
-
- self.pipeline = ges.TimelinePipeline()
- self.pipeline.add_timeline(timeline)
- bus = self.pipeline.get_bus()
- bus.set_sync_handler(self.bus_handler)
-
- # all timeline objects except the last will have a transition at the end
- for n in uris[:-1]:
- self.add_timeline_object(n, True)
- self.add_timeline_object(uris[-1], False)
-
- def add_timeline_object(self, uri, do_transition):
- filesource = ges.TimelineFileSource (uri)
- filesource.set_duration(long (gst.SECOND * 5))
- self.layer.add_object(filesource, -1)
-
- if do_transition:
- transition = ges.TimelineStandardTransition("crossfade")
- transition.duration = gst.SECOND * 2
- self.layer.add_object(transition, -1)
-
- def bus_handler(self, unused_bus, message):
- if message.type == gst.MESSAGE_ERROR:
- print "ERROR"
- self.mainloop.quit()
- elif message.type == gst.MESSAGE_EOS:
- print "Done"
- self.mainloop.quit()
-
- return gst.BUS_PASS
-
- def run(self):
- if (self.pipeline.set_state(gst.STATE_PLAYING) == \
- gst.STATE_CHANGE_FAILURE):
- print "Couldn't start pipeline"
-
- self.mainloop.run()
-
-
-def main(args):
- usage = "usage: %s URI-OF-VIDEO-1 ... URI-OF-VIDEO-n\n" % args[0]
-
- if len(args) < 2:
- sys.stderr.write(usage)
- sys.exit(1)
-
- parser = optparse.OptionParser (usage=usage)
- (options, args) = parser.parse_args ()
-
- simple = Simple(args)
- simple.run()
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv))
+++ /dev/null
-;; -*- scheme -*-
-; object definitions ...
-(define-object Formatter
- (in-module "GES")
- (parent "GObject")
- (c-name "GESFormatter")
- (gtype-id "GES_TYPE_FORMATTER")
-)
-
-(define-object KeyfileFormatter
- (in-module "GES")
- (parent "GESFormatter")
- (c-name "GESKeyfileFormatter")
- (gtype-id "GES_TYPE_KEYFILE_FORMATTER")
-)
-
-(define-object PitiviFormatter
- (in-module "GES")
- (parent "GESFormatter")
- (c-name "GESPitiviFormatter")
- (gtype-id "GES_TYPE_PITIVI_FORMATTER")
-)
-
-(define-object Timeline
- (in-module "GES")
- (parent "GstBin")
- (c-name "GESTimeline")
- (gtype-id "GES_TYPE_TIMELINE")
-)
-
-(define-object TimelineLayer
- (in-module "GES")
- (parent "GInitiallyUnowned")
- (c-name "GESTimelineLayer")
- (gtype-id "GES_TYPE_TIMELINE_LAYER")
-)
-
-(define-object SimpleTimelineLayer
- (in-module "GES")
- (parent "GESTimelineLayer")
- (c-name "GESSimpleTimelineLayer")
- (gtype-id "GES_TYPE_SIMPLE_TIMELINE_LAYER")
-)
-
-(define-object TimelineObject
- (in-module "GES")
- (parent "GInitiallyUnowned")
- (c-name "GESTimelineObject")
- (gtype-id "GES_TYPE_TIMELINE_OBJECT")
-)
-
-(define-object TimelineOperation
- (in-module "GES")
- (parent "GESTimelineObject")
- (c-name "GESTimelineOperation")
- (gtype-id "GES_TYPE_TIMELINE_OPERATION")
-)
-
-(define-object TimelineEffect
- (in-module "GES")
- (parent "GESTimelineOperation")
- (c-name "GESTimelineEffect")
- (gtype-id "GES_TYPE_TIMELINE_EFFECT")
-)
-
-(define-object TimelineOverlay
- (in-module "GES")
- (parent "GESTimelineOperation")
- (c-name "GESTimelineOverlay")
- (gtype-id "GES_TYPE_TIMELINE_OVERLAY")
-)
-
-(define-object TimelineParseLaunchEffect
- (in-module "GES")
- (parent "GESTimelineEffect")
- (c-name "GESTimelineParseLaunchEffect")
- (gtype-id "GES_TYPE_TIMELINE_PARSE_LAUNCH_EFFECT")
-)
-
-(define-object TimelinePipeline
- (in-module "GES")
- (parent "GstPipeline")
- (c-name "GESTimelinePipeline")
- (gtype-id "GES_TYPE_TIMELINE_PIPELINE")
-)
-
-(define-object TimelineSource
- (in-module "GES")
- (parent "GESTimelineObject")
- (c-name "GESTimelineSource")
- (gtype-id "GES_TYPE_TIMELINE_SOURCE")
-)
-
-(define-object TimelineFileSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESTimelineFileSource")
- (gtype-id "GES_TYPE_TIMELINE_FILE_SOURCE")
-)
-
-(define-object CustomTimelineSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESCustomTimelineSource")
- (gtype-id "GES_TYPE_CUSTOM_TIMELINE_SOURCE")
-)
-
-(define-object TimelineTestSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESTimelineTestSource")
- (gtype-id "GES_TYPE_TIMELINE_TEST_SOURCE")
-)
-
-(define-object TimelineTextOverlay
- (in-module "GES")
- (parent "GESTimelineOverlay")
- (c-name "GESTimelineTextOverlay")
- (gtype-id "GES_TYPE_TIMELINE_TEXT_OVERLAY")
-)
-
-(define-object TimelineTitleSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESTimelineTitleSource")
- (gtype-id "GES_TYPE_TIMELINE_TITLE_SOURCE")
-)
-
-(define-object TimelineTransition
- (in-module "GES")
- (parent "GESTimelineOperation")
- (c-name "GESTimelineTransition")
- (gtype-id "GES_TYPE_TIMELINE_TRANSITION")
-)
-
-(define-object TimelineStandardTransition
- (in-module "GES")
- (parent "GESTimelineTransition")
- (c-name "GESTimelineStandardTransition")
- (gtype-id "GES_TYPE_TIMELINE_STANDARD_TRANSITION")
-)
-
-(define-object Track
- (in-module "GES")
- (parent "GstBin")
- (c-name "GESTrack")
- (gtype-id "GES_TYPE_TRACK")
-)
-
-(define-object TrackObject
- (in-module "GES")
- (parent "GInitiallyUnowned")
- (c-name "GESTrackObject")
- (gtype-id "GES_TYPE_TRACK_OBJECT")
-)
-
-(define-object TrackOperation
- (in-module "GES")
- (parent "GESTrackObject")
- (c-name "GESTrackOperation")
- (gtype-id "GES_TYPE_TRACK_OPERATION")
-)
-
-(define-object TrackEffect
- (in-module "GES")
- (parent "GESTrackOperation")
- (c-name "GESTrackEffect")
- (gtype-id "GES_TYPE_TRACK_EFFECT")
-)
-
-(define-object TrackParseLaunchEffect
- (in-module "GES")
- (parent "GESTrackEffect")
- (c-name "GESTrackParseLaunchEffect")
- (gtype-id "GES_TYPE_TRACK_PARSE_LAUNCH_EFFECT")
-)
-
-(define-object TrackSource
- (in-module "GES")
- (parent "GESTrackObject")
- (c-name "GESTrackSource")
- (gtype-id "GES_TYPE_TRACK_SOURCE")
-)
-
-(define-object TrackImageSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackImageSource")
- (gtype-id "GES_TYPE_TRACK_IMAGE_SOURCE")
-)
-
-(define-object TrackFileSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackFileSource")
- (gtype-id "GES_TYPE_TRACK_FILE_SOURCE")
-)
-
-(define-object TrackAudioTestSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackAudioTestSource")
- (gtype-id "GES_TYPE_TRACK_AUDIO_TEST_SOURCE")
-)
-
-(define-object TrackTextOverlay
- (in-module "GES")
- (parent "GESTrackOperation")
- (c-name "GESTrackTextOverlay")
- (gtype-id "GES_TYPE_TRACK_TEXT_OVERLAY")
-)
-
-(define-object TrackTitleSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackTitleSource")
- (gtype-id "GES_TYPE_TRACK_TITLE_SOURCE")
-)
-
-(define-object TrackTransition
- (in-module "GES")
- (parent "GESTrackOperation")
- (c-name "GESTrackTransition")
- (gtype-id "GES_TYPE_TRACK_TRANSITION")
-)
-
-(define-object TrackAudioTransition
- (in-module "GES")
- (parent "GESTrackTransition")
- (c-name "GESTrackAudioTransition")
- (gtype-id "GES_TYPE_TRACK_AUDIO_TRANSITION")
-)
-
-(define-object TrackVideoTestSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackVideoTestSource")
- (gtype-id "GES_TYPE_TRACK_VIDEO_TEST_SOURCE")
-)
-
-(define-object TrackVideoTransition
- (in-module "GES")
- (parent "GESTrackTransition")
- (c-name "GESTrackVideoTransition")
- (gtype-id "GES_TYPE_TRACK_VIDEO_TRANSITION")
-)
-
-;; Enumerations and flags ...
-
-(define-flags TrackType
- (in-module "GES")
- (c-name "GESTrackType")
- (gtype-id "GES_TYPE_TRACK_TYPE")
- (values
- '("unknown" "GES_TRACK_TYPE_UNKNOWN")
- '("audio" "GES_TRACK_TYPE_AUDIO")
- '("video" "GES_TRACK_TYPE_VIDEO")
- '("text" "GES_TRACK_TYPE_TEXT")
- '("custom" "GES_TRACK_TYPE_CUSTOM")
- )
-)
-
-(define-enum VideoStandardTransitionType
- (in-module "GES")
- (c-name "GESVideoStandardTransitionType")
- (gtype-id "GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE")
- (values
- '("none" "GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE")
- '("bar-wipe-lr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR")
- '("bar-wipe-tb" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_TB")
- '("box-wipe-tl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_TL")
- '("box-wipe-tr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_TR")
- '("box-wipe-br" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_BR")
- '("box-wipe-bl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_BL")
- '("four-box-wipe-ci" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FOUR_BOX_WIPE_CI")
- '("four-box-wipe-co" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FOUR_BOX_WIPE_CO")
- '("barndoor-v" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_V")
- '("barndoor-h" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_H")
- '("box-wipe-tc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_TC")
- '("box-wipe-rc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_RC")
- '("box-wipe-bc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_BC")
- '("box-wipe-lc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_LC")
- '("diagonal-tl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DIAGONAL_TL")
- '("diagonal-tr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DIAGONAL_TR")
- '("bowtie-v" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOWTIE_V")
- '("bowtie-h" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOWTIE_H")
- '("barndoor-dbl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_DBL")
- '("barndoor-dtl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_DTL")
- '("misc-diagonal-dbd" "GES_VIDEO_STANDARD_TRANSITION_TYPE_MISC_DIAGONAL_DBD")
- '("misc-diagonal-dd" "GES_VIDEO_STANDARD_TRANSITION_TYPE_MISC_DIAGONAL_DD")
- '("vee-d" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_D")
- '("vee-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_L")
- '("vee-u" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_U")
- '("vee-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_R")
- '("barnvee-d" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_D")
- '("barnvee-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_L")
- '("barnvee-u" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_U")
- '("barnvee-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_R")
- '("iris-rect" "GES_VIDEO_STANDARD_TRANSITION_TYPE_IRIS_RECT")
- '("clock-cw12" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW12")
- '("clock-cw3" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW3")
- '("clock-cw6" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW6")
- '("clock-cw9" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW9")
- '("pinwheel-tbv" "GES_VIDEO_STANDARD_TRANSITION_TYPE_PINWHEEL_TBV")
- '("pinwheel-tbh" "GES_VIDEO_STANDARD_TRANSITION_TYPE_PINWHEEL_TBH")
- '("pinwheel-fb" "GES_VIDEO_STANDARD_TRANSITION_TYPE_PINWHEEL_FB")
- '("fan-ct" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_CT")
- '("fan-cr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_CR")
- '("doublefan-fov" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FOV")
- '("doublefan-foh" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FOH")
- '("singlesweep-cwt" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWT")
- '("singlesweep-cwr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWR")
- '("singlesweep-cwb" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWB")
- '("singlesweep-cwl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWL")
- '("doublesweep-pv" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PV")
- '("doublesweep-pd" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PD")
- '("doublesweep-ov" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_OV")
- '("doublesweep-oh" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_OH")
- '("fan-t" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_T")
- '("fan-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_R")
- '("fan-b" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_B")
- '("fan-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_L")
- '("doublefan-fiv" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FIV")
- '("doublefan-fih" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FIH")
- '("singlesweep-cwtl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWTL")
- '("singlesweep-cwbl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWBL")
- '("singlesweep-cwbr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWBR")
- '("singlesweep-cwtr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWTR")
- '("doublesweep-pdtl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PDTL")
- '("doublesweep-pdbl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PDBL")
- '("saloondoor-t" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_T")
- '("saloondoor-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_L")
- '("saloondoor-b" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_B")
- '("saloondoor-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_R")
- '("windshield-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_R")
- '("windshield-u" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_U")
- '("windshield-v" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_V")
- '("windshield-h" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_H")
- '("crossfade" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE")
- )
-)
-
-(define-enum TextVAlign
- (in-module "GES")
- (c-name "GESTextVAlign")
- (gtype-id "GES_TEXT_VALIGN_TYPE")
- (values
- '("baseline" "GES_TEXT_VALIGN_BASELINE")
- '("bottom" "GES_TEXT_VALIGN_BOTTOM")
- '("top" "GES_TEXT_VALIGN_TOP")
- )
-)
-
-(define-enum TextHAlign
- (in-module "GES")
- (c-name "GESTextHAlign")
- (gtype-id "GES_TEXT_HALIGN_TYPE")
- (values
- '("left" "GES_TEXT_HALIGN_LEFT")
- '("center" "GES_TEXT_HALIGN_CENTER")
- '("right" "GES_TEXT_HALIGN_RIGHT")
- )
-)
-
-(define-enum VideoTestPattern
- (in-module "GES")
- (c-name "GESVideoTestPattern")
- (gtype-id "GES_VIDEO_TEST_PATTERN_TYPE")
- (values
- '("smpte" "GES_VIDEO_TEST_PATTERN_SMPTE")
- '("snow" "GES_VIDEO_TEST_PATTERN_SNOW")
- '("black" "GES_VIDEO_TEST_PATTERN_BLACK")
- '("white" "GES_VIDEO_TEST_PATTERN_WHITE")
- '("red" "GES_VIDEO_TEST_PATTERN_RED")
- '("green" "GES_VIDEO_TEST_PATTERN_GREEN")
- '("blue" "GES_VIDEO_TEST_PATTERN_BLUE")
- '("checkers1" "GES_VIDEO_TEST_PATTERN_CHECKERS1")
- '("checkers2" "GES_VIDEO_TEST_PATTERN_CHECKERS2")
- '("checkers4" "GES_VIDEO_TEST_PATTERN_CHECKERS4")
- '("checkers8" "GES_VIDEO_TEST_PATTERN_CHECKERS8")
- '("circular" "GES_VIDEO_TEST_PATTERN_CIRCULAR")
- '("blink" "GES_VIDEO_TEST_PATTERN_BLINK")
- '("smpte75" "GES_VIDEO_TEST_PATTERN_SMPTE75")
- )
-)
-
-(define-flags PipelineFlags
- (in-module "GES")
- (c-name "GESPipelineFlags")
- (gtype-id "GES_TYPE_PIPELINE_FLAGS")
- (values
- '("preview-audio" "TIMELINE_MODE_PREVIEW_AUDIO")
- '("preview-video" "TIMELINE_MODE_PREVIEW_VIDEO")
- '("preview" "TIMELINE_MODE_PREVIEW")
- '("render" "TIMELINE_MODE_RENDER")
- '("smart-render" "TIMELINE_MODE_SMART_RENDER")
- )
-)
-
-(define-enum Edge
- (in-module "GES")
- (c-name "GESEdge")
- (gtype-id "GES_TYPE_EDGE")
- (values
- '("edge_start" "GES_EDGE_START")
- '("edge_end" "GES_EDGE_END")
- '("edge_none" "GES_EDGE_NONE")
- )
-)
-
-(define-enum EditMode
- (in-module "GES")
- (c-name "GESEditMode")
- (gtype-id "GES_TYPE_EDIT_MODE")
- (values
- '("edit_normal" "GES_EDIT_MODE_NORMAL")
- '("edit_ripple" "GES_EDIT_MODE_RIPPLE")
- '("edit_roll" "GES_EDIT_MODE_ROLL")
- '("edit_trim" "GES_EDIT_MODE_TRIM")
- '("edit_slide" "GES_EDIT_MODE_SLIDE")
- )
-)
+++ /dev/null
-;; -*- scheme -*-
-; object definitions ...
-(define-object Formatter
- (in-module "GES")
- (parent "GObject")
- (c-name "GESFormatter")
- (gtype-id "GES_TYPE_FORMATTER")
-)
-
-(define-object KeyfileFormatter
- (in-module "GES")
- (parent "GESFormatter")
- (c-name "GESKeyfileFormatter")
- (gtype-id "GES_TYPE_KEYFILE_FORMATTER")
-)
-
-(define-object PitiviFormatter
- (in-module "GES")
- (parent "GESFormatter")
- (c-name "GESPitiviFormatter")
- (gtype-id "GES_TYPE_PITIVI_FORMATTER")
-)
-
-(define-object Timeline
- (in-module "GES")
- (parent "GstBin")
- (c-name "GESTimeline")
- (gtype-id "GES_TYPE_TIMELINE")
-)
-
-(define-object TimelineLayer
- (in-module "GES")
- (parent "GInitiallyUnowned")
- (c-name "GESTimelineLayer")
- (gtype-id "GES_TYPE_TIMELINE_LAYER")
-)
-
-(define-object SimpleTimelineLayer
- (in-module "GES")
- (parent "GESTimelineLayer")
- (c-name "GESSimpleTimelineLayer")
- (gtype-id "GES_TYPE_SIMPLE_TIMELINE_LAYER")
-)
-
-(define-object TimelineObject
- (in-module "GES")
- (parent "GInitiallyUnowned")
- (c-name "GESTimelineObject")
- (gtype-id "GES_TYPE_TIMELINE_OBJECT")
-)
-
-(define-object TimelineOperation
- (in-module "GES")
- (parent "GESTimelineObject")
- (c-name "GESTimelineOperation")
- (gtype-id "GES_TYPE_TIMELINE_OPERATION")
-)
-
-(define-object TimelineEffect
- (in-module "GES")
- (parent "GESTimelineOperation")
- (c-name "GESTimelineEffect")
- (gtype-id "GES_TYPE_TIMELINE_EFFECT")
-)
-
-(define-object TimelineOverlay
- (in-module "GES")
- (parent "GESTimelineOperation")
- (c-name "GESTimelineOverlay")
- (gtype-id "GES_TYPE_TIMELINE_OVERLAY")
-)
-
-(define-object TimelineParseLaunchEffect
- (in-module "GES")
- (parent "GESTimelineEffect")
- (c-name "GESTimelineParseLaunchEffect")
- (gtype-id "GES_TYPE_TIMELINE_PARSE_LAUNCH_EFFECT")
-)
-
-(define-object TimelinePipeline
- (in-module "GES")
- (parent "GstPipeline")
- (c-name "GESTimelinePipeline")
- (gtype-id "GES_TYPE_TIMELINE_PIPELINE")
-)
-
-(define-object TimelineSource
- (in-module "GES")
- (parent "GESTimelineObject")
- (c-name "GESTimelineSource")
- (gtype-id "GES_TYPE_TIMELINE_SOURCE")
-)
-
-(define-object TimelineFileSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESTimelineFileSource")
- (gtype-id "GES_TYPE_TIMELINE_FILE_SOURCE")
-)
-
-(define-object CustomTimelineSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESCustomTimelineSource")
- (gtype-id "GES_TYPE_CUSTOM_TIMELINE_SOURCE")
-)
-
-(define-object TimelineTestSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESTimelineTestSource")
- (gtype-id "GES_TYPE_TIMELINE_TEST_SOURCE")
-)
-
-(define-object TimelineTextOverlay
- (in-module "GES")
- (parent "GESTimelineOverlay")
- (c-name "GESTimelineTextOverlay")
- (gtype-id "GES_TYPE_TIMELINE_TEXT_OVERLAY")
-)
-
-(define-object TimelineTitleSource
- (in-module "GES")
- (parent "GESTimelineSource")
- (c-name "GESTimelineTitleSource")
- (gtype-id "GES_TYPE_TIMELINE_TITLE_SOURCE")
-)
-
-(define-object TimelineTransition
- (in-module "GES")
- (parent "GESTimelineOperation")
- (c-name "GESTimelineTransition")
- (gtype-id "GES_TYPE_TIMELINE_TRANSITION")
-)
-
-(define-object TimelineStandardTransition
- (in-module "GES")
- (parent "GESTimelineTransition")
- (c-name "GESTimelineStandardTransition")
- (gtype-id "GES_TYPE_TIMELINE_STANDARD_TRANSITION")
-)
-
-(define-object Track
- (in-module "GES")
- (parent "GstBin")
- (c-name "GESTrack")
- (gtype-id "GES_TYPE_TRACK")
-)
-
-(define-object TrackObject
- (in-module "GES")
- (parent "GInitiallyUnowned")
- (c-name "GESTrackObject")
- (gtype-id "GES_TYPE_TRACK_OBJECT")
-)
-
-(define-object TrackOperation
- (in-module "GES")
- (parent "GESTrackObject")
- (c-name "GESTrackOperation")
- (gtype-id "GES_TYPE_TRACK_OPERATION")
-)
-
-(define-object TrackEffect
- (in-module "GES")
- (parent "GESTrackOperation")
- (c-name "GESTrackEffect")
- (gtype-id "GES_TYPE_TRACK_EFFECT")
-)
-
-(define-object TrackParseLaunchEffect
- (in-module "GES")
- (parent "GESTrackEffect")
- (c-name "GESTrackParseLaunchEffect")
- (gtype-id "GES_TYPE_TRACK_PARSE_LAUNCH_EFFECT")
-)
-
-(define-object TrackSource
- (in-module "GES")
- (parent "GESTrackObject")
- (c-name "GESTrackSource")
- (gtype-id "GES_TYPE_TRACK_SOURCE")
-)
-
-(define-object TrackImageSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackImageSource")
- (gtype-id "GES_TYPE_TRACK_IMAGE_SOURCE")
-)
-
-(define-object TrackFileSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackFileSource")
- (gtype-id "GES_TYPE_TRACK_FILESOURCE")
-)
-
-(define-object TrackAudioTestSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackAudioTestSource")
- (gtype-id "GES_TYPE_TRACK_AUDIO_TEST_SOURCE")
-)
-
-(define-object TrackTextOverlay
- (in-module "GES")
- (parent "GESTrackOperation")
- (c-name "GESTrackTextOverlay")
- (gtype-id "GES_TYPE_TRACK_TEXT_OVERLAY")
-)
-
-(define-object TrackTitleSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackTitleSource")
- (gtype-id "GES_TYPE_TRACK_TITLE_SOURCE")
-)
-
-(define-object TrackTransition
- (in-module "GES")
- (parent "GESTrackOperation")
- (c-name "GESTrackTransition")
- (gtype-id "GES_TYPE_TRACK_TRANSITION")
-)
-
-(define-object TrackAudioTransition
- (in-module "GES")
- (parent "GESTrackTransition")
- (c-name "GESTrackAudioTransition")
- (gtype-id "GES_TYPE_TRACK_AUDIO_TRANSITION")
-)
-
-(define-object TrackVideoTestSource
- (in-module "GES")
- (parent "GESTrackSource")
- (c-name "GESTrackVideoTestSource")
- (gtype-id "GES_TYPE_TRACK_VIDEO_TEST_SOURCE")
-)
-
-(define-object TrackVideoTransition
- (in-module "GES")
- (parent "GESTrackTransition")
- (c-name "GESTrackVideoTransition")
- (gtype-id "GES_TYPE_TRACK_VIDEO_TRANSITION")
-)
-
-;; Enumerations and flags ...
-
-(define-flags TrackType
- (in-module "GES")
- (c-name "GESTrackType")
- (gtype-id "GES_TYPE_TRACK_TYPE")
- (values
- '("unknown" "GES_TRACK_TYPE_UNKNOWN")
- '("audio" "GES_TRACK_TYPE_AUDIO")
- '("video" "GES_TRACK_TYPE_VIDEO")
- '("text" "GES_TRACK_TYPE_TEXT")
- '("custom" "GES_TRACK_TYPE_CUSTOM")
- )
-)
-
-(define-enum VideoStandardTransitionType
- (in-module "GES")
- (c-name "GESVideoStandardTransitionType")
- (gtype-id "GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE")
- (values
- '("none" "GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE")
- '("bar-wipe-lr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR")
- '("bar-wipe-tb" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_TB")
- '("box-wipe-tl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_TL")
- '("box-wipe-tr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_TR")
- '("box-wipe-br" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_BR")
- '("box-wipe-bl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_BL")
- '("four-box-wipe-ci" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FOUR_BOX_WIPE_CI")
- '("four-box-wipe-co" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FOUR_BOX_WIPE_CO")
- '("barndoor-v" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_V")
- '("barndoor-h" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_H")
- '("box-wipe-tc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_TC")
- '("box-wipe-rc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_RC")
- '("box-wipe-bc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_BC")
- '("box-wipe-lc" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOX_WIPE_LC")
- '("diagonal-tl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DIAGONAL_TL")
- '("diagonal-tr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DIAGONAL_TR")
- '("bowtie-v" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOWTIE_V")
- '("bowtie-h" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BOWTIE_H")
- '("barndoor-dbl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_DBL")
- '("barndoor-dtl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNDOOR_DTL")
- '("misc-diagonal-dbd" "GES_VIDEO_STANDARD_TRANSITION_TYPE_MISC_DIAGONAL_DBD")
- '("misc-diagonal-dd" "GES_VIDEO_STANDARD_TRANSITION_TYPE_MISC_DIAGONAL_DD")
- '("vee-d" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_D")
- '("vee-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_L")
- '("vee-u" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_U")
- '("vee-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_VEE_R")
- '("barnvee-d" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_D")
- '("barnvee-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_L")
- '("barnvee-u" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_U")
- '("barnvee-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_BARNVEE_R")
- '("iris-rect" "GES_VIDEO_STANDARD_TRANSITION_TYPE_IRIS_RECT")
- '("clock-cw12" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW12")
- '("clock-cw3" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW3")
- '("clock-cw6" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW6")
- '("clock-cw9" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CLOCK_CW9")
- '("pinwheel-tbv" "GES_VIDEO_STANDARD_TRANSITION_TYPE_PINWHEEL_TBV")
- '("pinwheel-tbh" "GES_VIDEO_STANDARD_TRANSITION_TYPE_PINWHEEL_TBH")
- '("pinwheel-fb" "GES_VIDEO_STANDARD_TRANSITION_TYPE_PINWHEEL_FB")
- '("fan-ct" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_CT")
- '("fan-cr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_CR")
- '("doublefan-fov" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FOV")
- '("doublefan-foh" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FOH")
- '("singlesweep-cwt" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWT")
- '("singlesweep-cwr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWR")
- '("singlesweep-cwb" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWB")
- '("singlesweep-cwl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWL")
- '("doublesweep-pv" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PV")
- '("doublesweep-pd" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PD")
- '("doublesweep-ov" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_OV")
- '("doublesweep-oh" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_OH")
- '("fan-t" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_T")
- '("fan-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_R")
- '("fan-b" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_B")
- '("fan-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_FAN_L")
- '("doublefan-fiv" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FIV")
- '("doublefan-fih" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLEFAN_FIH")
- '("singlesweep-cwtl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWTL")
- '("singlesweep-cwbl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWBL")
- '("singlesweep-cwbr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWBR")
- '("singlesweep-cwtr" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SINGLESWEEP_CWTR")
- '("doublesweep-pdtl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PDTL")
- '("doublesweep-pdbl" "GES_VIDEO_STANDARD_TRANSITION_TYPE_DOUBLESWEEP_PDBL")
- '("saloondoor-t" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_T")
- '("saloondoor-l" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_L")
- '("saloondoor-b" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_B")
- '("saloondoor-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_SALOONDOOR_R")
- '("windshield-r" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_R")
- '("windshield-u" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_U")
- '("windshield-v" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_V")
- '("windshield-h" "GES_VIDEO_STANDARD_TRANSITION_TYPE_WINDSHIELD_H")
- '("crossfade" "GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE")
- )
-)
-
-(define-enum TextVAlign
- (in-module "GES")
- (c-name "GESTextVAlign")
- (gtype-id "GES_TEXT_VALIGN_TYPE")
- (values
- '("baseline" "GES_TEXT_VALIGN_BASELINE")
- '("bottom" "GES_TEXT_VALIGN_BOTTOM")
- '("top" "GES_TEXT_VALIGN_TOP")
- )
-)
-
-(define-enum Edge
- (in-module "GES")
- (c-name "GESEdge")
- (gtype-id "GES_TYPE_EDGE")
- (values
- '("edge_start" "GES_EDGE_START")
- '("edge_end" "GES_EDGE_END")
- '("edge_none" "GES_EDGE_NONE")
- )
-)
-
-(define-enum EditMode
- (in-module "GES")
- (c-name "GESEditMode")
- (gtype-id "GES_TYPE_EDIT_MODE")
- (values
- '("edit_normal" "GES_EDIT_MODE_NORMAL")
- '("edit_ripple" "GES_EDIT_MODE_RIPPLE")
- '("edit_roll" "GES_EDIT_MODE_ROLL")
- '("edit_trim" "GES_EDIT_MODE_TRIM")
- '("edit_slide" "GES_EDIT_MODE_SLIDE")
- )
-)
-
-(define-enum TextHAlign
- (in-module "GES")
- (c-name "GESTextHAlign")
- (gtype-id "GES_TEXT_HALIGN_TYPE")
- (values
- '("left" "GES_TEXT_HALIGN_LEFT")
- '("center" "GES_TEXT_HALIGN_CENTER")
- '("right" "GES_TEXT_HALIGN_RIGHT")
- )
-)
-
-(define-enum VideoTestPattern
- (in-module "GES")
- (c-name "GESVideoTestPattern")
- (gtype-id "GES_VIDEO_TEST_PATTERN_TYPE")
- (values
- '("smpte" "GES_VIDEO_TEST_PATTERN_SMPTE")
- '("snow" "GES_VIDEO_TEST_PATTERN_SNOW")
- '("black" "GES_VIDEO_TEST_PATTERN_BLACK")
- '("white" "GES_VIDEO_TEST_PATTERN_WHITE")
- '("red" "GES_VIDEO_TEST_PATTERN_RED")
- '("green" "GES_VIDEO_TEST_PATTERN_GREEN")
- '("blue" "GES_VIDEO_TEST_PATTERN_BLUE")
- '("checkers1" "GES_VIDEO_TEST_PATTERN_CHECKERS1")
- '("checkers2" "GES_VIDEO_TEST_PATTERN_CHECKERS2")
- '("checkers4" "GES_VIDEO_TEST_PATTERN_CHECKERS4")
- '("checkers8" "GES_VIDEO_TEST_PATTERN_CHECKERS8")
- '("circular" "GES_VIDEO_TEST_PATTERN_CIRCULAR")
- '("blink" "GES_VIDEO_TEST_PATTERN_BLINK")
- '("smpte75" "GES_VIDEO_TEST_PATTERN_SMPTE75")
- )
-)
-
-(define-flags PipelineFlags
- (in-module "GES")
- (c-name "GESPipelineFlags")
- (gtype-id "GES_TYPE_PIPELINE_FLAGS")
- (values
- '("preview-audio" "TIMELINE_MODE_PREVIEW_AUDIO")
- '("preview-video" "TIMELINE_MODE_PREVIEW_VIDEO")
- '("preview" "TIMELINE_MODE_PREVIEW")
- '("render" "TIMELINE_MODE_RENDER")
- '("smart-render" "TIMELINE_MODE_SMART_RENDER")
- )
-)
-
-
-;; From ges-custom-timeline-source.h
-
-(define-function custom_timeline_source_get_type
- (c-name "ges_custom_timeline_source_get_type")
- (return-type "GType")
-)
-
-(define-function custom_timeline_source_new
- (c-name "ges_custom_timeline_source_new")
- (is-constructor-of "GESCustomTimelineSource")
- (return-type "GESCustomTimelineSource*")
- (parameters
- '("GESFillTrackObjectUserFunc" "func")
- '("gpointer" "user_data")
- )
-)
-
-
-
-;; From ges-enums.h
-
-(define-function track_type_get_type
- (c-name "ges_track_type_get_type")
- (return-type "GType")
-)
-
-(define-function video_standard_transition_type_get_type
- (c-name "ges_video_standard_transition_type_get_type")
- (return-type "GType")
-)
-
-(define-function text_valign_get_type
- (c-name "ges_text_valign_get_type")
- (return-type "GType")
-)
-
-(define-function text_halign_get_type
- (c-name "ges_text_halign_get_type")
- (return-type "GType")
-)
-
-(define-function video_test_pattern_get_type
- (c-name "ges_video_test_pattern_get_type")
- (return-type "GType")
-)
-
-(define-function pipeline_flags_get_type
- (c-name "ges_pipeline_flags_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-formatter.h
-
-(define-function formatter_get_type
- (c-name "ges_formatter_get_type")
- (return-type "GType")
-)
-
-(define-function formatter_new_for_uri
- (c-name "ges_formatter_new_for_uri")
- (return-type "GESFormatter*")
- (parameters
- '("const-gchar*" "uri")
- )
-)
-
-(define-function default_formatter_new
- (c-name "ges_default_formatter_new")
- (is-constructor-of "GESDefaultFormatter")
- (return-type "GESFormatter*")
-)
-
-(define-function formatter_can_load_uri
- (c-name "ges_formatter_can_load_uri")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "uri")
- )
-)
-
-(define-function formatter_can_save_uri
- (c-name "ges_formatter_can_save_uri")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "uri")
- )
-)
-
-(define-method load_from_uri
- (of-object "GESFormatter")
- (c-name "ges_formatter_load_from_uri")
- (return-type "gboolean")
- (parameters
- '("GESTimeline*" "timeline")
- '("const-gchar*" "uri")
- )
-)
-
-(define-method save_to_uri
- (of-object "GESFormatter")
- (c-name "ges_formatter_save_to_uri")
- (return-type "gboolean")
- (parameters
- '("GESTimeline*" "timeline")
- '("const-gchar*" "uri")
- )
-)
-
-(define-method load
- (of-object "GESFormatter")
- (c-name "ges_formatter_load")
- (return-type "gboolean")
- (parameters
- '("GESTimeline*" "timeline")
- )
-)
-
-(define-method save
- (of-object "GESFormatter")
- (c-name "ges_formatter_save")
- (return-type "gboolean")
- (parameters
- '("GESTimeline*" "timeline")
- )
-)
-
-(define-method clear_data
- (of-object "GESFormatter")
- (c-name "ges_formatter_clear_data")
- (return-type "none")
-)
-
-(define-method update_source_uri
- (of-object "GESFormatter")
- (c-name "ges_formatter_update_source_uri")
- (return-type "gboolean")
- (parameters
- '("GESTimelineFileSource*" "source")
- '("gchar*" "new_uri")
- )
-)
-
-
-;; From ges.h
-
-(define-function init
- (c-name "ges_init")
- (return-type "gboolean")
-)
-
-(define-function version
- (c-name "ges_version")
- (return-type "none")
- (parameters
- '("guint*" "major")
- '("guint*" "minor")
- '("guint*" "micro")
- '("guint*" "nano")
- )
-)
-
-
-;; From ges-internal.h
-
-
-
-;; From ges-keyfile-formatter.h
-
-(define-function keyfile_formatter_get_type
- (c-name "ges_keyfile_formatter_get_type")
- (return-type "GType")
-)
-
-(define-function keyfile_formatter_new
- (c-name "ges_keyfile_formatter_new")
- (is-constructor-of "GESKeyfileFormatter")
- (return-type "GESKeyfileFormatter*")
-)
-
-
-
-;; From gesmarshal.h
-
-
-
-;; From ges-screenshot.h
-
-(define-function play_sink_convert_frame
- (c-name "ges_play_sink_convert_frame")
- (return-type "GstBuffer*")
- (parameters
- '("GstElement*" "playsink")
- '("GstCaps*" "caps")
- )
-)
-
-
-
-;; From ges-simple-timeline-layer.h
-
-(define-function simple_timeline_layer_get_type
- (c-name "ges_simple_timeline_layer_get_type")
- (return-type "GType")
-)
-
-(define-function simple_timeline_layer_new
- (c-name "ges_simple_timeline_layer_new")
- (is-constructor-of "GESSimpleTimelineLayer")
- (return-type "GESSimpleTimelineLayer*")
-)
-
-(define-method add_object
- (of-object "GESSimpleTimelineLayer")
- (c-name "ges_simple_timeline_layer_add_object")
- (return-type "gboolean")
- (parameters
- '("GESTimelineObject*" "object")
- '("gint" "position")
- )
-)
-
-(define-method move_object
- (of-object "GESSimpleTimelineLayer")
- (c-name "ges_simple_timeline_layer_move_object")
- (return-type "gboolean")
- (parameters
- '("GESTimelineObject*" "object")
- '("gint" "newposition")
- )
-)
-
-(define-method is_valid
- (of-object "GESSimpleTimelineLayer")
- (c-name "ges_simple_timeline_layer_is_valid")
- (return-type "gboolean")
-)
-
-(define-method nth
- (of-object "GESSimpleTimelineLayer")
- (c-name "ges_simple_timeline_layer_nth")
- (return-type "GESTimelineObject*")
- (parameters
- '("gint" "position")
- )
-)
-
-(define-method index
- (of-object "GESSimpleTimelineLayer")
- (c-name "ges_simple_timeline_layer_index")
- (return-type "gint")
- (parameters
- '("GESTimelineObject*" "object")
- )
-)
-
-;; From ges-pitivi-formatter.h
-
-(define-function pitivi_formatter_get_type
- (c-name "ges_pitivi_formatter_get_type")
- (return-type "GType")
-)
-
-(define-function pitivi_formatter_new
- (c-name "ges_pitivi_formatter_new")
- (is-constructor-of "GESPitiviFormatter")
- (return-type "GESPitiviFormatter*")
-)
-
-(define-method set_sources
- (of-object "GESPitiviFormatter")
- (c-name "ges_pitivi_formatter_set_sources")
- (return-type "gboolean")
- (parameters
- '("GList*" "uris")
- )
-)
-
-(define-method get_sources
- (of-object "GESPitiviFormatter")
- (c-name "ges_pitivi_formatter_get_sources")
- (return-type "GList*")
-)
-
-;; From ges-timeline-effect.h
-
-(define-function timeline_effect_get_type
- (c-name "ges_timeline_effect_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-timeline-file-source.h
-
-(define-function timeline_filesource_get_type
- (c-name "ges_timeline_filesource_get_type")
- (return-type "GType")
-)
-
-(define-method set_mute
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_set_mute")
- (return-type "none")
- (parameters
- '("gboolean" "mute")
- )
-)
-
-(define-method set_max_duration
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_set_max_duration")
- (return-type "none")
- (parameters
- '("guint64" "maxduration")
- )
-)
-
-(define-method set_supported_formats
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_set_supported_formats")
- (return-type "none")
- (parameters
- '("GESTrackType" "supportedformats")
- )
-)
-
-(define-method set_is_image
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_set_is_image")
- (return-type "none")
- (parameters
- '("gboolean" "is_image")
- )
-)
-
-(define-method is_muted
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_is_muted")
- (return-type "gboolean")
-)
-
-(define-method get_max_duration
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_get_max_duration")
- (return-type "guint64")
-)
-
-(define-method is_image
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_is_image")
- (return-type "gboolean")
-)
-
-(define-method get_uri
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_get_uri")
- (return-type "const-gchar*")
-)
-
-(define-method get_supported_formats
- (of-object "GESTimelineFileSource")
- (c-name "ges_timeline_filesource_get_supported_formats")
- (return-type "GESTrackType")
-)
-
-(define-function timeline_filesource_new
- (c-name "ges_timeline_filesource_new")
- (is-constructor-of "GESTimelineFileSource")
- (return-type "GESTimelineFileSource*")
- (parameters
- '("gchar*" "uri")
- )
-)
-
-
-
-;; From ges-timeline.h
-
-(define-function timeline_get_type
- (c-name "ges_timeline_get_type")
- (return-type "GType")
-)
-
-(define-function timeline_new
- (c-name "ges_timeline_new")
- (is-constructor-of "GESTimeline")
- (return-type "GESTimeline*")
-)
-
-(define-function timeline_new_from_uri
- (c-name "ges_timeline_new_from_uri")
- (return-type "GESTimeline*")
- (parameters
- '("const-gchar*" "uri")
- )
-)
-
-(define-method load_from_uri
- (of-object "GESTimeline")
- (c-name "ges_timeline_load_from_uri")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "uri")
- )
-)
-
-(define-method save_to_uri
- (of-object "GESTimeline")
- (c-name "ges_timeline_save_to_uri")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "uri")
- )
-)
-
-(define-method add_layer
- (of-object "GESTimeline")
- (c-name "ges_timeline_add_layer")
- (return-type "gboolean")
- (parameters
- '("GESTimelineLayer*" "layer")
- )
-)
-
-(define-method remove_layer
- (of-object "GESTimeline")
- (c-name "ges_timeline_remove_layer")
- (return-type "gboolean")
- (parameters
- '("GESTimelineLayer*" "layer")
- )
-)
-
-(define-method get_layers
- (of-object "GESTimeline")
- (c-name "ges_timeline_get_layers")
- (return-type "GList*")
-)
-
-(define-method add_track
- (of-object "GESTimeline")
- (c-name "ges_timeline_add_track")
- (return-type "gboolean")
- (parameters
- '("GESTrack*" "track")
- )
-)
-
-(define-method remove_track
- (of-object "GESTimeline")
- (c-name "ges_timeline_remove_track")
- (return-type "gboolean")
- (parameters
- '("GESTrack*" "track")
- )
-)
-
-(define-method get_track_for_pad
- (of-object "GESTimeline")
- (c-name "ges_timeline_get_track_for_pad")
- (return-type "GESTrack*")
- (parameters
- '("GstPad*" "pad")
- )
-)
-
-(define-method get_tracks
- (of-object "GESTimeline")
- (c-name "ges_timeline_get_tracks")
- (return-type "GList*")
-)
-
-(define-method enable_update
- (of-object "GESTimeline")
- (c-name "ges_timeline_enable_update")
- (return-type "gboolean")
- (parameters
- '("gboolean" "enabled")
- )
-)
-
-(define-method is_updating
- (of-object "GESTimeline")
- (c-name "ges_timeline_is_updating")
- (return-type "gboolean")
-)
-
-
-
-;; From ges-timeline-layer.h
-
-(define-function timeline_layer_get_type
- (c-name "ges_timeline_layer_get_type")
- (return-type "GType")
-)
-
-(define-function timeline_layer_new
- (c-name "ges_timeline_layer_new")
- (is-constructor-of "GESTimelineLayer")
- (return-type "GESTimelineLayer*")
-)
-
-(define-method set_timeline
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_set_timeline")
- (return-type "none")
- (parameters
- '("GESTimeline*" "timeline")
- )
-)
-
-(define-method get_timeline
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_get_timeline")
- (return-type "GESTimeline*")
-)
-
-(define-method add_object
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_add_object")
- (return-type "gboolean")
- (parameters
- '("GESTimelineObject*" "object")
- )
-)
-
-(define-method remove_object
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_remove_object")
- (return-type "gboolean")
- (parameters
- '("GESTimelineObject*" "object")
- )
-)
-
-(define-method set_priority
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_set_priority")
- (return-type "none")
- (parameters
- '("guint" "priority")
- )
-)
-
-(define-method get_priority
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_get_priority")
- (return-type "guint")
-)
-
-(define-method get_objects
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_get_objects")
- (return-type "GList*")
-)
-
-(define-method is_empty
- (of-object "GESTimelineLayer")
- (c-name "ges_timeline_layer_is_empty")
- (return-type "gboolean")
-)
-
-
-
-;; From ges-timeline-object.h
-
-(define-function timeline_object_get_type
- (c-name "ges_timeline_object_get_type")
- (return-type "GType")
-)
-
-(define-method set_start
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_start")
- (return-type "none")
- (parameters
- '("guint64" "start")
- )
-)
-
-(define-method set_inpoint
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_inpoint")
- (return-type "none")
- (parameters
- '("guint64" "inpoint")
- )
-)
-
-(define-method set_duration
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_duration")
- (return-type "none")
- (parameters
- '("guint64" "duration")
- )
-)
-
-(define-method set_max_duration
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_max_duration")
- (return-type "none")
- (parameters
- '("guint64" "duration")
- )
-)
-
-(define-method get_max_duration
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_get_max_duration")
- (return-type "guint64")
-)
-
-(define-method set_priority
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_priority")
- (return-type "none")
- (parameters
- '("guint" "priority")
- )
-)
-
-(define-method set_layer
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_layer")
- (return-type "none")
- (parameters
- '("GESTimelineLayer*" "layer")
- )
-)
-
-(define-method create_track_object
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_create_track_object")
- (return-type "GESTrackObject*")
- (parameters
- '("GESTrack*" "track")
- )
-)
-
-(define-method create_track_objects
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_create_track_objects")
- (return-type "gboolean")
- (parameters
- '("GESTrack*" "track")
- )
-)
-
-(define-method release_track_object
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_release_track_object")
- (return-type "gboolean")
- (parameters
- '("GESTrackObject*" "trackobject")
- )
-)
-
-(define-method fill_track_object
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_fill_track_object")
- (return-type "gboolean")
- (parameters
- '("GESTrackObject*" "trackobj")
- '("GstElement*" "gnlobj")
- )
-)
-
-(define-method find_track_object
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_find_track_object")
- (return-type "GESTrackObject*")
- (parameters
- '("GESTrack*" "track")
- '("GType" "type")
- )
-)
-
-(define-method get_track_objects
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_get_track_objects")
- (return-type "GList*")
-)
-
-(define-method add_track_object
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_add_track_object")
- (return-type "gboolean")
- (parameters
- '("GESTrackObject*" "trobj")
- )
-)
-
-(define-method get_layer
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_get_layer")
- (return-type "GESTimelineLayer*")
-)
-
-(define-method get_top_effects
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_get_top_effects")
- (return-type "GList*")
-)
-
-(define-method get_top_effect_position
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_get_top_effect_position")
- (return-type "gint")
- (parameters
- '("GESTrackEffect*" "effect")
- )
-)
-
-(define-method set_top_effect_priority
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_top_effect_priority")
- (return-type "gboolean")
- (parameters
- '("GESTrackEffect*" "effect")
- '("guint" "newpriority")
- )
-)
-
-(define-method move_to_layer
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_move_to_layer")
- (return-type "gboolean")
- (parameters
- '("GESTimelineLayer*" "layer")
- )
-)
-
-(define-method is_moving_from_layer
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_is_moving_from_layer")
- (return-type "gboolean")
-)
-
-(define-method set_moving_from_layer
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_moving_from_layer")
- (return-type "none")
- (parameters
- '("gboolean" "is_moving")
- )
-)
-
-(define-method split
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_split")
- (return-type "GESTimelineObject*")
- (parameters
- '("guint64" "position")
- )
-)
-
-(define-method edit
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_edit")
- (return-type "gboolean")
- (parameters
- '("GList*" "layers")
- '("guint" "move_layer")
- '("GESEditMode" "mode")
- '("GESEdge" "edge")
- '("guint64" "position")
- '("guint64" "snap_distance")
- )
-)
-
-(define-method get_supported_formats
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_get_supported_formats")
- (return-type "GESTrackType")
-)
-
-(define-method set_supported_formats
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_set_supported_formats")
- (return-type "none")
- (parameters
- '("GESTrackType" "supportedformats")
- )
-)
-
-(define-method objects_set_locked
- (of-object "GESTimelineObject")
- (c-name "ges_timeline_object_objects_set_locked")
- (return-type "none")
- (parameters
- '("gboolean" "locked")
- )
-)
-
-;; From ges-timeline-operation.h
-
-(define-function timeline_operation_get_type
- (c-name "ges_timeline_operation_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-timeline-overlay.h
-
-(define-function timeline_overlay_get_type
- (c-name "ges_timeline_overlay_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-timeline-parse-launch-effect.h
-
-(define-function timeline_parse_launch_effect_get_type
- (c-name "ges_timeline_parse_launch_effect_get_type")
- (return-type "GType")
-)
-
-(define-function timeline_parse_launch_effect_new
- (c-name "ges_timeline_parse_launch_effect_new")
- (is-constructor-of "GESTimelineParseLaunchEffect")
- (return-type "GESTimelineParseLaunchEffect*")
- (parameters
- '("const-gchar*" "video_bin_description")
- '("const-gchar*" "audio_bin_description")
- )
-)
-
-
-
-;; From ges-timeline-pipeline.h
-
-(define-function timeline_pipeline_get_type
- (c-name "ges_timeline_pipeline_get_type")
- (return-type "GType")
-)
-
-(define-function timeline_pipeline_new
- (c-name "ges_timeline_pipeline_new")
- (is-constructor-of "GESTimelinePipeline")
- (return-type "GESTimelinePipeline*")
-)
-
-(define-method add_timeline
- (of-object "GESTimelinePipeline")
- (c-name "ges_timeline_pipeline_add_timeline")
- (return-type "gboolean")
- (parameters
- '("GESTimeline*" "timeline")
- )
-)
-
-(define-method set_render_settings
- (of-object "GESTimelinePipeline")
- (c-name "ges_timeline_pipeline_set_render_settings")
- (return-type "gboolean")
- (parameters
- '("gchar*" "output_uri")
- '("GstEncodingProfile*" "profile")
- )
-)
-
-(define-method set_mode
- (of-object "GESTimelinePipeline")
- (c-name "ges_timeline_pipeline_set_mode")
- (return-type "gboolean")
- (parameters
- '("GESPipelineFlags" "mode")
- )
-)
-
-(define-method get_thumbnail_buffer
- (of-object "GESTimelinePipeline")
- (c-name "ges_timeline_pipeline_get_thumbnail_buffer")
- (return-type "GstBuffer*")
- (parameters
- '("GstCaps*" "caps")
- )
-)
-
-(define-method get_thumbnail_rgb24
- (of-object "GESTimelinePipeline")
- (c-name "ges_timeline_pipeline_get_thumbnail_rgb24")
- (return-type "GstBuffer*")
- (parameters
- '("gint" "width")
- '("gint" "height")
- )
-)
-
-(define-method save_thumbnail
- (of-object "GESTimelinePipeline")
- (c-name "ges_timeline_pipeline_save_thumbnail")
- (return-type "gboolean")
- (parameters
- '("int" "width")
- '("int" "height")
- '("const-gchar*" "format")
- '("const-gchar*" "location")
- )
-)
-
-
-
-;; From ges-timeline-source.h
-
-(define-function timeline_source_get_type
- (c-name "ges_timeline_source_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-timeline-standard-transition.h
-
-(define-function timeline_standard_transition_get_type
- (c-name "ges_timeline_standard_transition_get_type")
- (return-type "GType")
-)
-
-(define-function timeline_standard_transition_new
- (c-name "ges_timeline_standard_transition_new")
- (is-constructor-of "GESTimelineStandardTransition")
- (return-type "GESTimelineStandardTransition*")
- (parameters
- '("GESVideoStandardTransitionType" "vtype")
- )
-)
-
-(define-function timeline_standard_transition_new_for_nick
- (c-name "ges_timeline_standard_transition_new_for_nick")
- (return-type "GESTimelineStandardTransition*")
- (parameters
- '("char*" "nick")
- )
-)
-
-
-
-;; From ges-timeline-test-source.h
-
-(define-function timeline_test_source_get_type
- (c-name "ges_timeline_test_source_get_type")
- (return-type "GType")
-)
-
-(define-method set_mute
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_set_mute")
- (return-type "none")
- (parameters
- '("gboolean" "mute")
- )
-)
-
-(define-method set_vpattern
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_set_vpattern")
- (return-type "none")
- (parameters
- '("GESVideoTestPattern" "vpattern")
- )
-)
-
-(define-method set_frequency
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_set_frequency")
- (return-type "none")
- (parameters
- '("gdouble" "freq")
- )
-)
-
-(define-method set_volume
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_set_volume")
- (return-type "none")
- (parameters
- '("gdouble" "volume")
- )
-)
-
-(define-method get_vpattern
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_get_vpattern")
- (return-type "GESVideoTestPattern")
-)
-
-(define-method is_muted
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_is_muted")
- (return-type "gboolean")
-)
-
-(define-method get_frequency
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_get_frequency")
- (return-type "gdouble")
-)
-
-(define-method get_volume
- (of-object "GESTimelineTestSource")
- (c-name "ges_timeline_test_source_get_volume")
- (return-type "gdouble")
-)
-
-(define-function timeline_test_source_new
- (c-name "ges_timeline_test_source_new")
- (is-constructor-of "GESTimelineTestSource")
- (return-type "GESTimelineTestSource*")
-)
-
-(define-function timeline_test_source_new_for_nick
- (c-name "ges_timeline_test_source_new_for_nick")
- (return-type "GESTimelineTestSource*")
- (parameters
- '("gchar*" "nick")
- )
-)
-
-
-
-;; From ges-timeline-text-overlay.h
-
-(define-function timeline_text_overlay_get_type
- (c-name "ges_timeline_text_overlay_get_type")
- (return-type "GType")
-)
-
-(define-method set_text
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_set_text")
- (return-type "none")
- (parameters
- '("const-gchar*" "text")
- )
-)
-
-(define-method set_font_desc
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_set_font_desc")
- (return-type "none")
- (parameters
- '("const-gchar*" "font_desc")
- )
-)
-
-(define-method set_valign
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_set_valign")
- (return-type "none")
- (parameters
- '("GESTextVAlign" "valign")
- )
-)
-
-(define-method set_halign
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_set_halign")
- (return-type "none")
- (parameters
- '("GESTextHAlign" "halign")
- )
-)
-
-(define-method get_text
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_get_text")
- (return-type "const-gchar*")
-)
-
-(define-method get_font_desc
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_get_font_desc")
- (return-type "const-gchar*")
-)
-
-(define-method get_valignment
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_get_valignment")
- (return-type "GESTextVAlign")
-)
-
-(define-method get_halignment
- (of-object "GESTimelineTextOverlay")
- (c-name "ges_timeline_text_overlay_get_halignment")
- (return-type "GESTextHAlign")
-)
-
-(define-function timeline_text_overlay_new
- (c-name "ges_timeline_text_overlay_new")
- (is-constructor-of "GESTimelineTextOverlay")
- (return-type "GESTimelineTextOverlay*")
-)
-
-
-
-;; From ges-timeline-title-source.h
-
-(define-function timeline_title_source_get_type
- (c-name "ges_timeline_title_source_get_type")
- (return-type "GType")
-)
-
-(define-method set_mute
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_set_mute")
- (return-type "none")
- (parameters
- '("gboolean" "mute")
- )
-)
-
-(define-method set_text
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_set_text")
- (return-type "none")
- (parameters
- '("const-gchar*" "text")
- )
-)
-
-(define-method set_font_desc
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_set_font_desc")
- (return-type "none")
- (parameters
- '("const-gchar*" "font_desc")
- )
-)
-
-(define-method set_valignment
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_set_valignment")
- (return-type "none")
- (parameters
- '("GESTextVAlign" "valign")
- )
-)
-
-(define-method set_halignment
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_set_halignment")
- (return-type "none")
- (parameters
- '("GESTextHAlign" "halign")
- )
-)
-
-(define-method get_font_desc
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_get_font_desc")
- (return-type "const-gchar*")
-)
-
-(define-method get_valignment
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_get_valignment")
- (return-type "GESTextVAlign")
-)
-
-(define-method get_halignment
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_get_halignment")
- (return-type "GESTextHAlign")
-)
-
-(define-method is_muted
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_is_muted")
- (return-type "gboolean")
-)
-
-(define-method get_text
- (of-object "GESTimelineTitleSource")
- (c-name "ges_timeline_title_source_get_text")
- (return-type "const-gchar*")
-)
-
-(define-function timeline_title_source_new
- (c-name "ges_timeline_title_source_new")
- (is-constructor-of "GESTimelineTitleSource")
- (return-type "GESTimelineTitleSource*")
-)
-
-
-
-;; From ges-timeline-transition.h
-
-(define-function timeline_transition_get_type
- (c-name "ges_timeline_transition_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-track-audio-test-source.h
-
-(define-function track_audio_test_source_get_type
- (c-name "ges_track_audio_test_source_get_type")
- (return-type "GType")
-)
-
-(define-method set_freq
- (of-object "GESTrackAudioTestSource")
- (c-name "ges_track_audio_test_source_set_freq")
- (return-type "none")
- (parameters
- '("gdouble" "freq")
- )
-)
-
-(define-method set_volume
- (of-object "GESTrackAudioTestSource")
- (c-name "ges_track_audio_test_source_set_volume")
- (return-type "none")
- (parameters
- '("gdouble" "volume")
- )
-)
-
-(define-method get_freq
- (of-object "GESTrackAudioTestSource")
- (c-name "ges_track_audio_test_source_get_freq")
- (return-type "double")
-)
-
-(define-method get_volume
- (of-object "GESTrackAudioTestSource")
- (c-name "ges_track_audio_test_source_get_volume")
- (return-type "double")
-)
-
-(define-function track_audio_test_source_new
- (c-name "ges_track_audio_test_source_new")
- (is-constructor-of "GESTrackAudioTestSource")
- (return-type "GESTrackAudioTestSource*")
-)
-
-
-
-;; From ges-track-audio-transition.h
-
-(define-function track_audio_transition_get_type
- (c-name "ges_track_audio_transition_get_type")
- (return-type "GType")
-)
-
-(define-function track_audio_transition_new
- (c-name "ges_track_audio_transition_new")
- (is-constructor-of "GESTrackAudioTransition")
- (return-type "GESTrackAudioTransition*")
-)
-
-
-
-;; From ges-track-effect.h
-
-(define-function track_effect_get_type
- (c-name "ges_track_effect_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-track-filesource.h
-
-(define-function track_filesource_get_type
- (c-name "ges_track_filesource_get_type")
- (return-type "GType")
-)
-
-(define-function track_filesource_new
- (c-name "ges_track_filesource_new")
- (is-constructor-of "GESTrackFilesource")
- (return-type "GESTrackFileSource*")
- (parameters
- '("gchar*" "uri")
- )
-)
-
-
-
-;; From ges-track.h
-
-(define-function track_get_type
- (c-name "ges_track_get_type")
- (return-type "GType")
-)
-
-(define-function track_new
- (c-name "ges_track_new")
- (is-constructor-of "GESTrack")
- (return-type "GESTrack*")
- (parameters
- '("GESTrackType" "type")
- '("GstCaps*" "caps")
- )
-)
-
-(define-method get_objects
- (of-object "GESTrack")
- (c-name "ges_track_get_objects")
- (return-type "GList*")
-)
-
-(define-method set_timeline
- (of-object "GESTrack")
- (c-name "ges_track_set_timeline")
- (return-type "none")
- (parameters
- '("GESTimeline*" "timeline")
- )
-)
-
-(define-method set_caps
- (of-object "GESTrack")
- (c-name "ges_track_set_caps")
- (return-type "none")
- (parameters
- '("const-GstCaps*" "caps")
- )
-)
-
-(define-method get_caps
- (of-object "GESTrack")
- (c-name "ges_track_get_caps")
- (return-type "const-GstCaps*")
-)
-
-(define-method get_timeline
- (of-object "GESTrack")
- (c-name "ges_track_get_timeline")
- (return-type "const-GESTimeline*")
-)
-
-(define-method add_object
- (of-object "GESTrack")
- (c-name "ges_track_add_object")
- (return-type "gboolean")
- (parameters
- '("GESTrackObject*" "object")
- )
-)
-
-(define-method remove_object
- (of-object "GESTrack")
- (c-name "ges_track_remove_object")
- (return-type "gboolean")
- (parameters
- '("GESTrackObject*" "object")
- )
-)
-
-(define-function track_video_raw_new
- (c-name "ges_track_video_raw_new")
- (return-type "GESTrack*")
-)
-
-(define-function track_audio_raw_new
- (c-name "ges_track_audio_raw_new")
- (return-type "GESTrack*")
-)
-
-(define-method enable_update
- (of-object "GESTrack")
- (c-name "ges_track_enable_update")
- (return-type "gboolean")
- (parameters
- '("gboolean" "enabled")
- )
-)
-
-
-
-;; From ges-track-image-source.h
-
-(define-function track_image_source_get_type
- (c-name "ges_track_image_source_get_type")
- (return-type "GType")
-)
-
-(define-function track_image_source_new
- (c-name "ges_track_image_source_new")
- (is-constructor-of "GESTrackImageSource")
- (return-type "GESTrackImageSource*")
- (parameters
- '("gchar*" "uri")
- )
-)
-
-(define-method is_updating
- (of-object "GESTrack")
- (c-name "ges_track_is_updating")
- (return-type "gboolean")
-)
-
-
-
-;; From ges-track-object.h
-
-(define-function track_object_get_type
- (c-name "ges_track_object_get_type")
- (return-type "GType")
-)
-
-(define-method set_track
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_track")
- (return-type "gboolean")
- (parameters
- '("GESTrack*" "track")
- )
-)
-
-(define-method get_track
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_track")
- (return-type "GESTrack*")
-)
-
-(define-method set_timeline_object
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_timeline_object")
- (return-type "none")
- (parameters
- '("GESTimelineObject*" "tlobject")
- )
-)
-
-(define-method get_timeline_object
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_timeline_object")
- (return-type "GESTimelineObject*")
-)
-
-(define-method get_gnlobject
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_gnlobject")
- (return-type "GstElement*")
-)
-
-(define-method get_element
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_element")
- (return-type "GstElement*")
-)
-
-(define-method set_locked
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_locked")
- (return-type "none")
- (parameters
- '("gboolean" "locked")
- )
-)
-
-(define-method is_locked
- (of-object "GESTrackObject")
- (c-name "ges_track_object_is_locked")
- (return-type "gboolean")
-)
-
-(define-method set_start
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_start")
- (return-type "none")
- (parameters
- '("guint64" "start")
- )
-)
-
-(define-method set_inpoint
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_inpoint")
- (return-type "none")
- (parameters
- '("guint64" "inpoint")
- )
-)
-
-(define-method set_duration
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_duration")
- (return-type "none")
- (parameters
- '("guint64" "duration")
- )
-)
-
-(define-method set_priority
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_priority")
- (return-type "none")
- (parameters
- '("guint32" "priority")
- )
-)
-
-(define-method set_active
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_active")
- (return-type "gboolean")
- (parameters
- '("gboolean" "active")
- )
-)
-
-(define-method get_start
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_start")
- (return-type "guint64")
-)
-
-(define-method get_inpoint
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_inpoint")
- (return-type "guint64")
-)
-
-(define-method get_max_duration
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_max_duration")
- (return-type "guint64")
-)
-
-(define-method set_max_duration
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_max_duration")
- (return-type "none")
- (parameters
- '("guint64" "duration")
- )
-)
-
-(define-method get_duration
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_duration")
- (return-type "guint64")
-)
-
-(define-method get_priority
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_priority")
- (return-type "guint32")
-)
-
-(define-method is_active
- (of-object "GESTrackObject")
- (c-name "ges_track_object_is_active")
- (return-type "gboolean")
-)
-
-(define-method list_children_properties
- (of-object "GESTrackObject")
- (c-name "ges_track_object_list_children_properties")
- (return-type "GParamSpec**")
- (parameters
- '("guint*" "n_properties")
- )
-)
-
-(define-method lookup_child
- (of-object "GESTrackObject")
- (c-name "ges_track_object_lookup_child")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "prop_name")
- '("GstElement**" "element")
- '("GParamSpec**" "pspec")
- )
-)
-
-(define-method get_child_property_by_pspec
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_child_property_by_pspec")
- (return-type "none")
- (parameters
- '("GParamSpec*" "pspec")
- '("GValue*" "value")
- )
-)
-
-(define-method get_child_property_valist
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_child_property_valist")
- (return-type "none")
- (parameters
- '("const-gchar*" "first_property_name")
- '("va_list" "var_args")
- )
-)
-
-(define-method get_child_property
- (of-object "GESTrackObject")
- (c-name "ges_track_object_get_child_property")
- (return-type "none")
- (parameters
- '("const-gchar*" "first_property_name")
- )
- (varargs #t)
-)
-
-(define-method set_child_property_valist
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_child_property_valist")
- (return-type "none")
- (parameters
- '("const-gchar*" "first_property_name")
- '("va_list" "var_args")
- )
-)
-
-(define-method set_child_property_by_pspec
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_child_property_by_pspec")
- (return-type "none")
- (parameters
- '("GParamSpec*" "pspec")
- '("GValue*" "value")
- )
-)
-
-(define-method set_child_property
- (of-object "GESTrackObject")
- (c-name "ges_track_object_set_child_property")
- (return-type "none")
- (parameters
- '("const-gchar*" "first_property_name")
- )
- (varargs #t)
-)
-
-(define-method edit
- (of-object "GESTrackObject")
- (c-name "ges_track_object_edit")
- (return-type "gboolean")
- (parameters
- '("GList*" "layers")
- '("GESEditMode" "mode")
- '("GESEdge" "edge")
- '("guint64" "position")
- '("guint64" "snap_distance")
- )
-)
-
-
-;; From ges-track-operation.h
-
-(define-function track_operation_get_type
- (c-name "ges_track_operation_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-track-parse-launch-effect.h
-
-(define-function track_parse_launch_effect_get_type
- (c-name "ges_track_parse_launch_effect_get_type")
- (return-type "GType")
-)
-
-(define-function track_parse_launch_effect_new
- (c-name "ges_track_parse_launch_effect_new")
- (is-constructor-of "GESTrackParseLaunchEffect")
- (return-type "GESTrackParseLaunchEffect*")
- (parameters
- '("const-gchar*" "bin_description")
- )
-)
-
-
-
-;; From ges-track-source.h
-
-(define-function track_source_get_type
- (c-name "ges_track_source_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-track-text-overlay.h
-
-(define-function track_text_overlay_get_type
- (c-name "ges_track_text_overlay_get_type")
- (return-type "GType")
-)
-
-(define-method set_text
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_set_text")
- (return-type "none")
- (parameters
- '("const-gchar*" "text")
- )
-)
-
-(define-method set_font_desc
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_set_font_desc")
- (return-type "none")
- (parameters
- '("const-gchar*" "font_desc")
- )
-)
-
-(define-method set_halignment
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_set_halignment")
- (return-type "none")
- (parameters
- '("GESTextHAlign" "halign")
- )
-)
-
-(define-method set_valignment
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_set_valignment")
- (return-type "none")
- (parameters
- '("GESTextVAlign" "valign")
- )
-)
-
-(define-method get_text
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_get_text")
- (return-type "const-gchar*")
-)
-
-(define-method get_font_desc
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_get_font_desc")
- (return-type "const-char*")
-)
-
-(define-method get_halignment
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_get_halignment")
- (return-type "GESTextHAlign")
-)
-
-(define-method get_valignment
- (of-object "GESTrackTextOverlay")
- (c-name "ges_track_text_overlay_get_valignment")
- (return-type "GESTextVAlign")
-)
-
-(define-function track_text_overlay_new
- (c-name "ges_track_text_overlay_new")
- (is-constructor-of "GESTrackTextOverlay")
- (return-type "GESTrackTextOverlay*")
-)
-
-
-
-;; From ges-track-title-source.h
-
-(define-function track_title_source_get_type
- (c-name "ges_track_title_source_get_type")
- (return-type "GType")
-)
-
-(define-method set_text
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_set_text")
- (return-type "none")
- (parameters
- '("const-gchar*" "text")
- )
-)
-
-(define-method set_font_desc
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_set_font_desc")
- (return-type "none")
- (parameters
- '("const-gchar*" "font_desc")
- )
-)
-
-(define-method set_halignment
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_set_halignment")
- (return-type "none")
- (parameters
- '("GESTextHAlign" "halign")
- )
-)
-
-(define-method set_valignment
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_set_valignment")
- (return-type "none")
- (parameters
- '("GESTextVAlign" "valign")
- )
-)
-
-(define-method get_text
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_get_text")
- (return-type "const-gchar*")
-)
-
-(define-method get_font_desc
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_get_font_desc")
- (return-type "const-gchar*")
-)
-
-(define-method get_halignment
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_get_halignment")
- (return-type "GESTextHAlign")
-)
-
-(define-method get_valignment
- (of-object "GESTrackTitleSource")
- (c-name "ges_track_title_source_get_valignment")
- (return-type "GESTextVAlign")
-)
-
-(define-function track_title_source_new
- (c-name "ges_track_title_source_new")
- (is-constructor-of "GESTrackTitleSource")
- (return-type "GESTrackTitleSource*")
-)
-
-
-
-;; From ges-track-transition.h
-
-(define-function track_transition_get_type
- (c-name "ges_track_transition_get_type")
- (return-type "GType")
-)
-
-
-
-;; From ges-track-video-test-source.h
-
-(define-function track_video_test_source_get_type
- (c-name "ges_track_video_test_source_get_type")
- (return-type "GType")
-)
-
-(define-function track_video_test_source_new
- (c-name "ges_track_video_test_source_new")
- (is-constructor-of "GESTrackVideoTestSource")
- (return-type "GESTrackVideoTestSource*")
-)
-
-(define-method set_pattern
- (of-object "GESTrackVideoTestSource")
- (c-name "ges_track_video_test_source_set_pattern")
- (return-type "none")
- (parameters
- '("GESVideoTestPattern" "pattern")
- )
-)
-
-(define-method get_pattern
- (of-object "GESTrackVideoTestSource")
- (c-name "ges_track_video_test_source_get_pattern")
- (return-type "GESVideoTestPattern")
-)
-
-
-
-;; From ges-track-video-transition.h
-
-(define-function track_video_transition_get_type
- (c-name "ges_track_video_transition_get_type")
- (return-type "GType")
-)
-
-(define-method set_transition_type
- (of-object "GESTrackVideoTransition")
- (c-name "ges_track_video_transition_set_transition_type")
- (return-type "gboolean")
- (parameters
- '("GESVideoStandardTransitionType" "type")
- )
-)
-
-(define-method get_transition_type
- (of-object "GESTrackVideoTransition")
- (c-name "ges_track_video_transition_get_transition_type")
- (return-type "GESVideoStandardTransitionType")
-)
-
-(define-function track_video_transition_new
- (c-name "ges_track_video_transition_new")
- (is-constructor-of "GESTrackVideoTransition")
- (return-type "GESTrackVideoTransition*")
-)
-
-
-
-;; From ges-types.h
-
-
-
-;; From ges-utils.h
-
-(define-function timeline_new_audio_video
- (c-name "ges_timeline_new_audio_video")
- (return-type "GESTimeline*")
-)
-
-
-
-;; From config.h
-
-
+++ /dev/null
-/* -*- Mode: C; c-basic-offset: 4 -*- */
-%%
-headers
-#define NO_IMPORT_PYGOBJECT
-#include <pygobject.h>
-#include <gst/pygst.h>
-
-#include <gst/gst.h>
-#include <ges/ges.h>
-#include <gst/pygst.h>
-
-#include <glib.h>
-#include <pyglib.h>
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Boonky define that allows for backwards compatibility with Python 2.4 */
-#if PY_VERSION_HEX < 0x02050000
-#define Py_ssize_t int
-#endif
-
-void pyges_register_classes(PyObject *d);
-void pyges_add_constants(PyObject *module, const gchar *strip_prefix);
-
-%%
-import gobject.GObject as PyGObject_Type
-import gobject.MainContext as PyGMainContext_Type
-import gobject.GObject as PyGInitiallyUnowned_Type
-import gst.Bin as PyGstBin_Type
-import gst.Pipeline as PyGstPipeline_Type
-import gst.Element as PyGstElement_Type
-import gst.Buffer as PyGstBuffer_Type
-import gst.Pad as PyGstPad_Type
-import gst.pbutils.EncodingProfile as PyGstEncodingProfile_Type
-
-%%
-override ges_track_get_timeline kwargs
-static PyObject *
-_wrap_ges_track_get_timeline(PyGObject *self)
-{
- const GESTimeline *ret;
-
- pyg_begin_allow_threads;
- ret = ges_track_get_timeline(GES_TRACK(self->obj));
- pyg_end_allow_threads;
- /* pygobject_new handles NULL checking */
- return pygobject_new((GObject *)ret);
-}
-
-%%
-override ges_track_get_caps noargs
-static PyObject *
-_wrap_ges_track_get_caps(PyGObject *self, void* closure)
-{
- const GstCaps *ret;
-
- ret = ges_track_get_caps(GES_TRACK(self->obj));
-
- return pyg_boxed_new (GST_TYPE_CAPS, (GstCaps*) ret, TRUE, TRUE);
-}
-
-%%
-override ges_track_set_caps kwargs
-static PyObject *
-_wrap_ges_track_set_caps(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = { "caps", NULL };
- PyObject *py_caps;
- GstCaps *caps;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer.set_caps", kwlist, &py_caps))
- return NULL;
-
- caps = pyg_boxed_get (py_caps, GstCaps);
- if (PyErr_Occurred())
- return NULL;
-
- pyg_begin_allow_threads;
- ges_track_set_caps (GES_TRACK(self->obj), caps);
- pyg_end_allow_threads;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-%%
-new-constructor GES_TYPE_TRACK
-%%
-override ges_track_new kwargs
-static int
-_wrap_ges_track_new(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = { "type", "caps", NULL };
- PyObject *py_type = NULL;
- GESTrackType type;
- GstCaps *caps;
- PyObject *py_caps;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:GES.Track.__init__", kwlist, &py_type, &py_caps))
- return -1;
- if (pyg_flags_get_value(GES_TYPE_TRACK_TYPE, py_type, (gpointer)&type))
- return -1;
- caps = pyg_boxed_get (py_caps, GstCaps);
- self->obj = (GObject *)ges_track_new(type, caps);
-
- if (!self->obj) {
- PyErr_SetString(PyExc_RuntimeError, "could not create GESTrack object");
- return -1;
- }
- pygobject_register_wrapper((PyObject *)self);
- return 0;
-}
-
-%%
-override ges_track_object_lookup_child kwargs
-static PyObject *
-_wrap_ges_track_object_lookup_child(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = {"name", NULL};
- char *name = NULL;
- GParamSpec *pspec;
- GstElement *element;
- gboolean ret;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "z:GES.TrackObject.lookup_child", kwlist, &name))
- return FALSE;
-
- pyg_begin_allow_threads;
- ret = ges_track_object_lookup_child (GES_TRACK_OBJECT (self->obj), name, &element, &pspec);
- pyg_end_allow_threads;
-
- if (!ret)
- return PyBool_FromLong(ret);
- return pygobject_new((GObject *)element);
-}
-
-%%
-override ges_timeline_parse_launch_effect_new kwargs
-static int
-_wrap_ges_timeline_parse_launch_effect_new(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = { "video_bin_description", "audio_bin_description", NULL };
- char *video_bin_description, *audio_bin_description = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,"zz:GES.TimelineParseLaunchEffect.__init__", kwlist, &video_bin_description, &audio_bin_description))
- return -1;
- self->obj = (GObject *)ges_timeline_parse_launch_effect_new(video_bin_description, audio_bin_description);
-
- if (!self->obj) {
- PyErr_SetString(PyExc_RuntimeError, "could not create GESTimelineParseLaunchEffect object");
- return -1;
- }
- pygobject_register_wrapper((PyObject *)self);
- return 0;
-}
-
-/* I did not override ges_formatter_get_data and set_data for these functions are deprecated */
-
-%%
-override ges_pitivi_formatter_set_sources kwargs
-static PyObject *
-_wrap_ges_pitivi_formatter_set_sources(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- GList *sources = NULL;
- guint i;
-
- PyObject *pylist = NULL;
- PyGObject *tmpobj = NULL;
- Py_ssize_t list_size;
-
- GESPitiviFormatter *formatter = GES_PITIVI_FORMATTER (self->obj);
-
- if (!PyArg_ParseTuple(args, "O:GESPitiviFormatter.set_sources",
- &pylist))
- return PyBool_FromLong(FALSE);
-
- list_size = PyList_GET_SIZE(pylist);
-
- for (i = 0; i < list_size; i++) {
- tmpobj = (PyGObject*)PyList_GetItem(pylist, i);
- sources = g_list_prepend (sources, tmpobj->obj);
- }
-
- return PyBool_FromLong (ges_pitivi_formatter_set_sources (formatter, sources));
-}
-
-%%
-override ges_pitivi_formatter_get_sources kwargs
-static PyObject *
-_wrap_ges_pitivi_formatter_get_sources(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_PITIVI_FORMATTER (self->obj),PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_pitivi_formatter_get_sources (GES_PITIVI_FORMATTER (self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- gchar * source = (gchar *)l->data;
- GST_ERROR ("Adding %s", source);
- PyList_Append(py_list, PyString_FromString(source));
- Py_DECREF(source);
- }
-
- return py_list;
-}
-
-%%
-override ges_timeline_object_get_top_effects noargs
-static PyObject *
-_wrap_ges_timeline_object_get_top_effects(PyGObject *self)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (self->obj),PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_timeline_object_get_top_effects(GES_TIMELINE_OBJECT(self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- GESTrackEffect *track_effect = (GESTrackEffect*)l->data;
- PyObject *py_track_effect = pygobject_new(G_OBJECT(track_effect));
- PyList_Append(py_list, py_track_effect);
- Py_DECREF(py_track_effect);
- }
-
- return py_list;
-}
-
-%%
-override ges_timeline_get_tracks noargs
-static PyObject *
-_wrap_ges_timeline_get_tracks(PyGObject *self)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_TIMELINE (self->obj),PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_timeline_get_tracks(GES_TIMELINE(self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- GESTrack *track = (GESTrack*)l->data;
- PyObject *py_track = pygobject_new(G_OBJECT(track));
- PyList_Append(py_list, py_track);
- Py_DECREF(py_track);
- }
-
- return py_list;
-}
-
-%%
-override ges_timeline_get_layers noargs
-static PyObject *
-_wrap_ges_timeline_get_layers(PyGObject *self)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_TIMELINE (self->obj), PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_timeline_get_layers(GES_TIMELINE(self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- GESTimelineLayer *layer = (GESTimelineLayer*)l->data;
- PyObject *py_layer = pygobject_new(G_OBJECT(layer));
- PyList_Append(py_list, py_layer);
- Py_DECREF(py_layer);
- }
-
- return py_list;
-}
-
-%%
-override ges_timeline_layer_get_objects noargs
-static PyObject *
-_wrap_ges_timeline_layer_get_objects(PyGObject *self)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_TIMELINE_LAYER (self->obj), PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_timeline_layer_get_objects(GES_TIMELINE_LAYER(self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- GESTimelineObject *object = (GESTimelineObject*)l->data;
- PyObject *py_object = pygobject_new(G_OBJECT(object));
- PyList_Append(py_list, py_object);
- Py_DECREF(py_object);
- }
-
- return py_list;
-}
-
-%%
-override ges_timeline_object_get_track_objects noargs
-static PyObject *
-_wrap_ges_timeline_object_get_track_objects(PyGObject *self)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (self->obj), PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_timeline_object_get_track_objects(GES_TIMELINE_OBJECT(self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- GESTrackObject *object = (GESTrackObject*)l->data;
- PyObject *py_object = pygobject_new(G_OBJECT(object));
- PyList_Append(py_list, py_object);
- Py_DECREF(py_object);
- }
-
- return py_list;
-}
-
-%%
-override ges_track_get_objects noargs
-static PyObject *
-_wrap_ges_track_get_objects(PyGObject *self)
-{
- const GList *l, *list;
- PyObject *py_list;
-
- g_return_val_if_fail (GES_IS_TRACK (self->obj), PyList_New(0));
-
- pyg_begin_allow_threads;
- list = ges_track_get_objects(GES_TRACK(self->obj));
- pyg_end_allow_threads;
-
- py_list = PyList_New(0);
- for (l = list; l; l = l->next) {
- GESTrackObject *object = (GESTrackObject*)l->data;
- PyObject *py_object = pygobject_new(G_OBJECT(object));
- PyList_Append(py_list, py_object);
- Py_DECREF(py_object);
- }
-
- return py_list;
-}
-
-%%
-override ges_track_object_get_child_property kwargs
-static PyObject *
-_wrap_ges_track_object_get_child_property (PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- gchar *property_name;
- GESTrackObject *obj = GES_TRACK_OBJECT (self->obj);
-
- GParamSpec *pspec = NULL;
- GValue value = { 0, } ;
- PyObject *ret;
-
- if (!PyArg_ParseTuple(args, "s:GESTrackObject.get_child_property",
- &property_name)) {
- return NULL;
- }
-
- ges_track_object_lookup_child(obj, property_name, NULL, &pspec);
- if (!pspec) {
- gchar buf[512];
- g_snprintf(buf, sizeof(buf),
- "container does not support property `%s'",
- property_name);
-
- PyErr_SetString(PyExc_TypeError, buf);
- return NULL;
- }
-
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
-
- ges_track_object_get_child_property_by_pspec(obj,
- pspec,
- &value);
-
- ret = pyg_value_as_pyobject(&value, TRUE);
- g_value_unset(&value);
-
- return ret;
-}
-
-%%
-override ges_track_object_set_child_property kwargs
-static PyObject *
-_wrap_ges_track_object_set_child_property (PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- gchar *property_name;
- GESTrackObject *obj = GES_TRACK_OBJECT (self->obj);
-
- GParamSpec *pspec = NULL;
- PyGObject *pyvalue;
- GValue value = { 0, } ;
-
- if (!PyArg_ParseTuple(args, "sO:GESTrackObject.set_child_property",
- &property_name, &pyvalue)) {
- return NULL;
- }
-
- ges_track_object_lookup_child(obj, property_name, NULL, &pspec);
- if (!pspec) {
- gchar buf[512];
- g_snprintf(buf, sizeof(buf),
- "container does not support property `%s'",
- property_name);
-
- PyErr_SetString(PyExc_TypeError, buf);
- return NULL;
- }
-
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
- pyg_value_from_pyobject(&value, (PyObject*)pyvalue);
-
- ges_track_object_set_child_property_by_pspec(obj,
- pspec,
- &value);
-
- g_value_unset(&value);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-%%
-override ges_track_object_list_children_properties noargs
-static PyObject *
-_wrap_ges_track_object_list_children_properties (PyGObject *self)
-{
- GParamSpec **specs;
- PyObject *list;
- guint nprops;
- guint i;
-
- specs = ges_track_object_list_children_properties(GES_TRACK_OBJECT (self->obj), &nprops);
- list = PyTuple_New(nprops);
- if (list == NULL) {
- g_free(specs);
- return NULL;
- }
-
- for (i = 0; i < nprops; i++) {
- PyTuple_SetItem(list, i, pyg_param_spec_new(specs[i]));
- }
-
- g_free(specs);
-
- return list;
-}
-
-%%
-override ges_version noargs
-static PyObject *
-_wrap_ges_version (PyObject *self)
-{
- guint major, minor, micro, nano;
- PyObject *py_tuple;
-
- ges_version (&major, &minor, µ, &nano);
- py_tuple = PyTuple_New(4);
- PyTuple_SetItem(py_tuple, 0, PyInt_FromLong(major));
- PyTuple_SetItem(py_tuple, 1, PyInt_FromLong(minor));
- PyTuple_SetItem(py_tuple, 2, PyInt_FromLong(micro));
- PyTuple_SetItem(py_tuple, 3, PyInt_FromLong(nano));
-
- return py_tuple;
-}
-
-
-%%
-override ges_track_object_edit kwargs
-static PyObject *
-_wrap_ges_track_object_edit (PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- GList *layers = NULL;
- GESEditMode mode;
- GESEdge edge;
- guint64 position;
- guint i;
- gboolean ret;
-
- PyObject *py_position = NULL;
- PyObject *list = NULL, *pymode = NULL, *pyedge = NULL;
- PyGObject *tmpobj = NULL;
- Py_ssize_t list_size;
-
- GESTrackObject *tckobj = GES_TRACK_OBJECT (self->obj);
-
- if (!PyArg_ParseTuple(args, "OOOl:GESTrackObject.edit",
- &list, &pymode, &pyedge, &py_position))
- return NULL;
-
- position = PyLong_AsUnsignedLongLong(py_position);
-
- list_size = PyList_GET_SIZE(list);
-
- for (i = 0; i < list_size; i++) {
- tmpobj = (PyGObject*)PyList_GetItem(list, i);
- layers = g_list_prepend (layers, GES_TIMELINE_LAYER (tmpobj->obj));
- }
-
- if (pyg_enum_get_value(GES_TYPE_EDIT_MODE, pymode, (gpointer)&mode))
- return FALSE;
-
- if (pyg_enum_get_value(GES_TYPE_EDGE, pyedge, (gpointer)&edge))
- return FALSE;
-
- ret = ges_track_object_edit (tckobj, layers, mode, edge, position);
-
- return PyBool_FromLong(ret);
-}
-
-%%
-override ges_timeline_object_edit kwargs
-static PyObject *
-_wrap_ges_timeline_object_edit (PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- GList *layers = NULL;
- GESEditMode mode;
- GESEdge edge;
- gint64 position;
- guint move_layer, i;
- gboolean ret;
-
- PyObject *py_position = NULL;
- PyObject *list = NULL, *pymode = NULL, *pyedge = NULL;
- PyGObject *tmpobj = NULL;
- Py_ssize_t list_size;
-
- GESTimelineObject *tlobj = GES_TIMELINE_OBJECT (self->obj);
-
- if (!PyArg_ParseTuple(args, "OiOOO:GESTimelineObject.edit",
- &list, &move_layer, &pymode, &pyedge, &py_position))
- return NULL;
-
- position = PyLong_AsUnsignedLongLong(py_position);
-
- list_size = PyList_GET_SIZE(list);
-
- for (i = 0; i < list_size; i++) {
- tmpobj = (PyGObject*)PyList_GetItem(list, i);
- layers = g_list_prepend (layers, GES_TIMELINE_LAYER (tmpobj->obj));
- }
-
- if (pyg_enum_get_value(GES_TYPE_EDIT_MODE, pymode, (gpointer)&mode))
- return FALSE;
-
- if (pyg_enum_get_value(GES_TYPE_EDGE, pyedge, (gpointer)&edge))
- return FALSE;
-
- ret = ges_timeline_object_edit (tlobj, layers, move_layer, mode, edge, position);
-
- return PyBool_FromLong(ret);
-}
-
-
-%%
-ignore-glob
-
- *_get_type
- ges_formatter_set_data
- ges_formatter_set_data
- *_valist
- *_by_pspec
+++ /dev/null
-/* -*- Mode: C; c-basic-offset: 4 -*- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include <Python.h>
-#include <pygobject.h>
-#include <pyglib.h>
-#include <gst/pygst.h>
-
-/* include any extra headers needed here */
-
-void pyges_register_classes (PyObject * d);
-extern PyMethodDef pyges_functions[];
-void pyges_add_constants (PyObject * module, const gchar * strip_prefix);
-DL_EXPORT (void)
-initges (void);
-
-DL_EXPORT (void)
-initges (void)
-{
- PyObject *m, *d;
-
- /* perform any initialisation required by the library here */
-
- m = Py_InitModule ("ges", pyges_functions);
- d = PyModule_GetDict (m);
-
- init_pygobject ();
- pygst_init ();
-
- pygst_init ();
- pyges_register_classes (d);
- pyges_add_constants (m, "GES_");
-
- /* add anything else to the module dictionary (such as constants) */
-
- if (PyErr_Occurred ())
- Py_FatalError ("could not initialise module ges");
-}
+++ /dev/null
-EXTRA_DIST = \
- common.py \
- test_timeline_pipeline.py \
- test_timeline.py \
- runtests.py \
- test_global_functions.py \
- test_timeline_test_source.py \
- test_layer.py \
- test_timeline_title_source.py \
- test_simple_layer.py \
- test_track.py \
- test_textoverlay.py \
- test_transition.py \
- test_timeline_file_source.py \
- test_timeline_parse_launch_effect.py
-
-check:
- @PYTHONPATH=$(top_builddir):$(top_builddir)/bindings/python/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
- @rm -fr *.pyc
+++ /dev/null
-# -*- Mode: Python -*-
-# vi:si:et:sw=4:sts=4:ts=4
-#
-# gst-python - Python bindings for GStreamer
-# Copyright (C) 2002 David I. Lehn
-# Copyright (C) 2004 Johan Dahlin
-# Copyright (C) 2005 Edward Hervey
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import os
-import sys
-import gc
-import unittest
-import gst
-
-import gobject
-try:
- gobject.threads_init()
-except:
- print "WARNING: gobject doesn't have threads_init, no threadsafety"
-
-def disable_stderr():
- global _stderr
- _stderr = file('/tmp/stderr', 'w+')
- sys.stderr = os.fdopen(os.dup(2), 'w')
- os.close(2)
- os.dup(_stderr.fileno())
-
-def enable_stderr():
- global _stderr
-
- os.close(2)
- os.dup(sys.stderr.fileno())
- _stderr.seek(0, 0)
- data = _stderr.read()
- _stderr.close()
- os.remove('/tmp/stderr')
- return data
-
-def run_silent(function, *args, **kwargs):
- disable_stderr()
-
- try:
- function(*args, **kwargs)
- except Exception, exc:
- enable_stderr()
- raise exc
-
- output = enable_stderr()
-
- return output
-
-class TestCase(unittest.TestCase):
-
- _types = [gst.Object, gst.MiniObject]
-
- def gccollect(self):
- # run the garbage collector
- ret = 0
- gst.debug('garbage collecting')
- while True:
- c = gc.collect()
- ret += c
- if c == 0: break
- gst.debug('done garbage collecting, %d objects' % ret)
- return ret
-
- def gctrack(self):
- # store all gst objects in the gc in a tracking dict
- # call before doing any allocation in your test, from setUp
- gst.debug('tracking gc GstObjects for types %r' % self._types)
- self.gccollect()
- self._tracked = {}
- for c in self._types:
- self._tracked[c] = [o for o in gc.get_objects() if isinstance(o, c)]
-
- def gcverify(self):
- # verify no new gst objects got added to the gc
- # call after doing all cleanup in your test, from tearDown
- gst.debug('verifying gc GstObjects for types %r' % self._types)
- new = []
- for c in self._types:
- objs = [o for o in gc.get_objects() if isinstance(o, c)]
- new.extend([o for o in objs if o not in self._tracked[c]])
-
- self.failIf(new, new)
- #self.failIf(new, ["%r:%d" % (type(o), id(o)) for o in new])
- del self._tracked
-
- def setUp(self):
- """
- Override me by chaining up to me at the start of your setUp.
- """
- # Using private variables is BAD ! this variable changed name in
- # python 2.5
- try:
- methodName = self.__testMethodName
- except:
- methodName = self._testMethodName
- gst.debug('%s.%s' % (self.__class__.__name__, methodName))
- self.gctrack()
-
- def tearDown(self):
- """
- Override me by chaining up to me at the end of your tearDown.
- """
- # Using private variables is BAD ! this variable changed name in
- # python 2.5
- try:
- methodName = self.__testMethodName
- except:
- methodName = self._testMethodName
- gst.debug('%s.%s' % (self.__class__.__name__, methodName))
- self.gccollect()
- self.gcverify()
+++ /dev/null
-import glob
-import os
-import sys
-import unittest
-
-SKIP_FILES = ['common', 'runtests']
-
-os.environ['LC_MESSAGES'] = 'C'
-
-def gettestnames(which):
- if not which:
- dir = os.path.split(os.path.abspath(__file__))[0]
- which = [os.path.basename(p) for p in glob.glob('%s/test_*.py' % dir)]
-
- names = map(lambda x: x[:-3], which)
- for f in SKIP_FILES:
- if f in names:
- names.remove(f)
- return names
-
-suite = unittest.TestSuite()
-loader = unittest.TestLoader()
-
-for name in gettestnames(sys.argv[1:]):
- suite.addTest(loader.loadTestsFromName(name))
-
-descriptions = 1
-verbosity = 1
-if os.environ.has_key('VERBOSE'):
- descriptions = 2
- verbosity = 2
-
-testRunner = unittest.TextTestRunner(descriptions=descriptions,
- verbosity=verbosity)
-result = testRunner.run(suite)
-if result.failures or result.errors:
- sys.exit(1)
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class GlobalFunctions(TestCase):
-
- def testGlobalFunctions(self):
- tl = ges.timeline_new_audio_video()
- tr = ges.timeline_standard_transition_new_for_nick("crossfade")
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class Layer(TestCase):
-
- def testLayer(self):
- lyr = ges.TimelineLayer()
- tl = ges.Timeline()
- src = ges.TimelineTestSource()
-
- lyr.set_timeline(tl)
-
- assert (lyr.add_object(src) == True)
- self.failIf(len (lyr.get_objects()) != 1)
- assert (lyr.remove_object(src) == True)
-
- lyr.set_priority(1)
- self.failIf(lyr.get_priority() != 1)
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class SimpleLayer(TestCase):
-
- def testSimpleLayer(self):
- lyr = ges.SimpleTimelineLayer()
- tl = ges.Timeline()
- src = ges.TimelineTestSource()
- src2 = ges.TimelineTestSource()
-
- lyr.set_timeline(tl)
-
- assert (lyr.add_object(src, 0) == True)
- assert (lyr.add_object(src2, 1) == True)
- assert (lyr.nth(0) == src)
- assert (lyr.move_object (src, 1) == True)
- self.failIf(lyr.index(src) != 1)
- assert (lyr.is_valid() == True)
+++ /dev/null
-import gst
-
-from common import TestCase
-import ges
-from time import sleep
-
-class TextOverlay(TestCase):
-
- def testTextOverlay(self):
-
- ovrl = ges.TimelineTextOverlay()
- lyr = ges.TimelineLayer()
- tl = ges.timeline_new_audio_video()
- tck = tl.get_tracks()[0]
-
- ovrl.set_text("Foo")
- self.failIf (ovrl.get_text() != "Foo")
- ovrl.set_font_desc ("Arial")
- self.failIf (ovrl.get_font_desc() != "Arial")
- ovrl.set_valign("top")
- self.failIf (ovrl.get_valignment().value_name != "top")
- ovrl.set_halign("left")
- self.failIf (ovrl.get_halignment().value_name != "left")
-
- #We will test Timeline Object class functions here
-
- ovrl.set_start(long(100))
- ovrl.set_inpoint(long(50))
- ovrl.set_duration(long(500))
- ovrl.set_priority(2)
- ovrl.set_layer(lyr)
- tck_obj = ovrl.create_track_object(tck)
- ovrl.add_track_object(tck_obj)
- self.failIf (ovrl.release_track_object(tck_obj) != True)
- self.failIf (ovrl.add_track_object(tck_obj) != True)
- self.failIf (len(ovrl.get_track_objects()) != 1)
- self.failIf (ovrl.get_layer() != lyr)
- ovrl.release_track_object(tck_obj)
-
- #We test TrackTextOverlay and TrackObject here
- tck_obj.set_text("Bar")
- self.failIf (tck_obj.get_text() != "Bar")
- tck_obj.set_font_desc ("Arial")
- self.failIf (tck_obj.get_font_desc() != "Arial")
- tck_obj.set_valignment("top")
- self.failIf (tck_obj.get_valignment().value_name != "top")
- tck_obj.set_halignment("left")
- self.failIf (tck_obj.get_halignment().value_name != "left")
-
- tck_obj.set_locked(False)
- self.failIf (tck_obj.is_locked() != False)
- tck_obj.set_start(long(100))
- tck_obj.set_inpoint(long(50))
- tck_obj.set_duration(long(500))
- tck_obj.set_priority(2)
- self.failIf (tck_obj.get_start() != 100)
- self.failIf (tck_obj.get_inpoint() != 50)
- self.failIf (tck_obj.get_duration() != 500)
- self.failIf (tck_obj.get_priority() != 2)
- tck_obj.set_timeline_object(ovrl)
- self.failIf(tck_obj.get_timeline_object() != ovrl)
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class Timeline(TestCase):
-
- def testTimeline(self):
-
- tl = ges.timeline_new_audio_video()
- lyr = ges.SimpleTimelineLayer()
- tck = ges.track_audio_raw_new()
-
- assert (tl.add_track(tck) == True)
- #We should have two tracks from the timeline_new_audio_video() function + 1
- self.failIf(len(tl.get_tracks()) != 3)
- assert (tl.remove_track(tck) == True)
-
- assert (tl.add_layer(lyr) == True)
- self.failIf(len(tl.get_layers()) != 1)
- assert (tl.remove_layer(lyr) == True)
+++ /dev/null
-import gst
-
-from common import TestCase
-import ges
-
-class TimelineFileSource(TestCase):
-
- def testTimelineFileSource(self):
- src = ges.TimelineFileSource("file://blahblahblah")
-
- src.set_mute(True)
- src.set_max_duration(long(100))
- src.set_supported_formats("video")
- assert (src.get_supported_formats().value_nicks[0] == "video")
- src.set_is_image(True)
- assert (src.get_max_duration() == 100)
- assert (src.is_image() == True)
- assert (src.get_uri() == "file://blahblahblah")
+++ /dev/null
-import gst
-
-from common import TestCase
-import ges
-from time import sleep
-
-class ParseLaunchEffect(TestCase):
-
- def testParseLaunchEffect(self):
- tl = ges.Timeline()
- tck = ges.track_video_raw_new()
- lyr = ges.TimelineLayer()
- efct = ges.TimelineParseLaunchEffect("agingtv", None)
- tck_efct = ges.TrackParseLaunchEffect("agingtv")
-
- tl.add_layer(lyr)
- efct.add_track_object(tck_efct)
- lyr.add_object(efct)
- tck.set_timeline(tl)
- tck.add_object(tck_efct)
- tck_efct.set_child_property("GstAgingTV::scratch-lines", 17)
- self.failIf(tck_efct.get_child_property("GstAgingTV::scratch-lines") != 17)
- self.failIf(len(tck_efct.list_children_properties()) != 6)
- self.failIf (tck_efct.lookup_child ("scratch-lines") == None)
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class TimelinePipeline(TestCase):
-
- def testTimelinePipeline(self):
- stgs = gst.pbutils.EncodingAudioProfile(gst.Caps("video/x-dirac"), "test", gst.caps_new_any(), 0)
- ppln = ges.TimelinePipeline()
- tl = ges.Timeline()
- assert (ppln.add_timeline (tl) == True)
- assert (ppln.set_mode("TIMELINE_MODE_PREVIEW_AUDIO") == True)
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class TimelineTestSource(TestCase):
-
- def testTimelineTestSource(self):
- src = ges.TimelineTestSource()
- tck_src = ges.TrackAudioTestSource()
- src.set_mute(True)
- src.set_vpattern("snow")
- src.set_frequency(880)
- src.set_volume (1)
- assert (src.get_vpattern() != None)
- assert (src.is_muted() == True)
- assert (src.get_frequency() == 880)
- assert (src.get_volume() == 1)
+++ /dev/null
-import gst
-
-from common import TestCase
-import ges
-
-class TimelineTitleSource(TestCase):
-
- def testTimelineTitleSource(self):
- src = ges.TimelineTitleSource()
- lyr = ges.TimelineLayer()
- tck = ges.track_video_raw_new()
-
- src.set_text("Foo")
- self.failIf (src.get_text() != "Foo")
- src.set_font_desc ("Arial")
- self.failIf (src.get_font_desc() != "Arial")
- src.set_valignment("top")
- assert (src.get_valignment().value_name == "top")
- src.set_halignment("left")
- assert (src.get_halignment().value_name == "left")
- src.set_mute(True)
- assert (src.is_muted() == True)
-
+++ /dev/null
-import gst
-
-from common import TestCase
-import ges
-
-class Track(TestCase):
-
- def testTrack(self):
- tck = ges.track_video_raw_new()
- tl = ges.Timeline()
- lyr = ges.TimelineLayer()
- src = ges.TimelineTestSource()
- caps = gst.caps_from_string("image/jpeg")
- obj = ges.TrackParseLaunchEffect ("agingtv")
-
- tl.add_layer(lyr)
- src.add_track_object(obj)
- lyr.add_object(src)
- tck.set_timeline(tl)
-
- assert (tck.add_object(obj) == True)
- assert (tck.get_timeline() == tl)
- tck.set_caps(caps)
- assert (tck.get_caps().to_string() == "image/jpeg")
+++ /dev/null
-import glib
-import gst
-
-from common import TestCase
-import ges
-
-class Timeline(TestCase):
-
- def testTimeline(self):
-
- tl = ges.timeline_new_audio_video()
- lyr = ges.SimpleTimelineLayer()
- src = ges.TimelineTestSource()
- src2 = ges.TimelineTestSource()
- tr = ges.TimelineStandardTransition("crossfade")
- pip = ges.TimelinePipeline()
- bus = pip.get_bus()
- self.mainloop = glib.MainLoop()
-
- # Let's add the layer to the timeline, and the sources
- # and transition to the layer.
-
- tl.add_layer(lyr)
- src.set_duration(long(gst.SECOND * 10))
- src2.set_duration(long(gst.SECOND * 10))
- src.set_vpattern("Random (television snow)")
- tr.set_duration(long(gst.SECOND * 10))
-
- lyr.add_object(src, -1)
- lyr.add_object(tr, -1)
- assert (lyr.add_object(src2, -1) == True)
-
- pip.add_timeline(tl)
- bus.set_sync_handler(self.bus_handler)
-
- self.pipeline = pip
- self.layer = lyr
-
- #Mainloop is finished, tear down.
- self.pipeline = None
-
-
- def bus_handler(self, unused_bus, message):
- if message.type == gst.MESSAGE_ERROR:
- print "ERROR"
- self.mainloop.quit()
- elif message.type == gst.MESSAGE_EOS:
- print "Done"
- self.mainloop.quit()
- return gst.BUS_PASS
-Subproject commit 11f0cd5a3fba36f85cf3e434150bfe66b1bf08d4
+Subproject commit dc702037b0490052dfc1fa5a3e5890bd55cf7b34
-AC_PREREQ(2.52)
+AC_PREREQ(2.62)
dnl initialize autoconf
dnl when going to/from release please set the nano (fourth number) right !
dnl releases only do Wall, cvs and prerelease does Werror too
-AC_INIT(GStreamer Editing Services, 0.10.1.1,
+AC_INIT(GStreamer Editing Services, 0.11.89.1,
http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
gstreamer-editing-services)
AG_GST_INIT
dnl initialize automake
-AM_INIT_AUTOMAKE([-Wno-portability])
+AM_INIT_AUTOMAKE([-Wno-portability 1.11 no-dist-gzip dist-xz tar-ustar])
dnl define PACKAGE_VERSION_* variables
AS_VERSION
AM_CONFIG_HEADER([config.h])
dnl AM_MAINTAINER_MODE only provides the option to configure to enable it
-AM_MAINTAINER_MODE
+AM_MAINTAINER_MODE([enable])
dnl sets host_* variables
AC_CANONICAL_HOST
AC_SUBST(AM_DEFAULT_VERBOSITY)])
dnl our libraries and install dirs use major.minor as a version
-GST_MAJORMINOR=$GST_EDITING_SERVICES_VERSION_MAJOR.$GST_EDITING_SERVICES_VERSION_MINOR
+GST_API_VERSION=$GST_EDITING_SERVICES_VERSION_MAJOR.$GST_EDITING_SERVICES_VERSION_MINOR
dnl we override it here if we need to for the release candidate of new series
-GST_MAJORMINOR=0.10
-AC_SUBST(GST_MAJORMINOR)
+GST_API_VERSION=1.0
+AC_SUBST(GST_API_VERSION)
-dnl FIXME: this macro doesn't actually work;
-dnl the generated libtool script has no support for the listed tags.
-dnl So this needs to be fixed first if we want to use this
-dnl AS_LIBTOOL_TAGS([CXX])
-
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
+AS_LIBTOOL(GST, 0, 0, 0)
dnl *** required versions of GStreamer stuff ***
-GST_REQ=0.10.34
-GSTPB_REQ=0.10.34
+GST_REQ=0.11.0
+GSTPB_REQ=0.11.0
dnl *** autotools stuff ****
dnl check for documentation tools
AG_GST_DOCBOOK_CHECK
GTK_DOC_CHECK([1.3])
-AS_PATH_PYTHON([2.1])
AG_GST_PLUGIN_DOCS([1.3],[2.1])
-dnl check for python
-AM_PATH_PYTHON
-AC_MSG_CHECKING(for python >= 2.3)
-prog="
-import sys, string
-minver = (2,3,0,'final',0)
-if sys.version_info < minver:
- sys.exit(1)
-sys.exit(0)"
-
-if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
-then
- HAVE_PYTHON=yes
- AC_MSG_RESULT(okay)
-else
- HAVE_PYTHON=no
- AC_MSG_RESULT(no python)
-fi
-
-AM_CHECK_PYTHON_HEADERS([HAVE_PYTHON_HEADERS=yes],[HAVE_PYTHON_HEADERS=no])
-
-dnl check for pygobject (optional, used in the bindings)
-PYGOBJECT_REQ=2.11.2
-PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0 >= $PYGOBJECT_REQ,
- [HAVE_PYGOBJECT="yes"], [HAVE_PYGOBJECT="no"])
-AC_SUBST(PYGOBJECT_CFLAGS)
-
-dnl check for gst-python
-PYGST_REQ=0.10.21.1
-PKG_CHECK_MODULES(PYGST, gst-python-0.10 >= $PYGST_REQ,
- [HAVE_PYGST="yes"], [HAVE_PYGST="no"])
-
-if test "x$HAVE_PYGST" = "xyes"; then
- PYGST_DEFSDIR=`pkg-config gst-python-0.10 --variable=defsdir`
-fi
-AC_SUBST(PYGST_DEFSDIR, $PYGST_DEFSDIR)
-
-if test \
- "x$HAVE_PYTHON" = "xyes" -a \
- "x$HAVE_PYTHON_HEADERS" = "xyes" -a \
- "x$HAVE_PYGOBJECT" = "xyes" -a \
- "x$HAVE_PYGST" = "xyes"; then
- HAVE_PYTHON_BINDINGS="yes"
-else
- HAVE_PYTHON_BINDINGS="no"
-fi
-
-AM_CONDITIONAL(WITH_PYTHON, [test "x$HAVE_PYTHON_BINDINGS" = "xyes"])
-
dnl *** checks for libraries ***
dnl check for libm, for sin() etc.
-# AC_CHECK_LIBM
+# LT_LIB_M
# AC_SUBST(LIBM)
dnl *** checks for header files ***
dnl *** checks for dependency libraries ***
dnl GLib is required
-AG_GST_GLIB_CHECK([2.28])
+AG_GST_GLIB_CHECK([2.31.14])
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.16, HAVE_GIO=yes, HAVE_GIO=no)
AC_SUBST(GIO_CFLAGS)
dnl checks for gstreamer
dnl uninstalled is selected preferentially -- see pkg-config(1)
-AG_GST_CHECK_GST($GST_MAJORMINOR, [$GST_REQ], yes)
-AG_GST_CHECK_GST_BASE($GST_MAJORMINOR, [$GST_REQ], yes)
-#AG_GST_CHECK_GST_GDP($GST_MAJORMINOR, [$GST_REQ], yes)
-AG_GST_CHECK_GST_CHECK($GST_MAJORMINOR, [$GST_REQ], no)
-AG_GST_CHECK_GST_CONTROLLER($GST_MAJORMINOR, [$GST_REQ], yes)
-AG_GST_CHECK_GST_PLUGINS_BASE($GST_MAJORMINOR, [$GSTPB_REQ], yes)
+AG_GST_CHECK_GST($GST_API_VERSION, [$GST_REQ], yes)
+AG_GST_CHECK_GST_BASE($GST_API_VERSION, [$GST_REQ], yes)
+#AG_GST_CHECK_GST_GDP($GST_API_VERSION, [$GST_REQ], yes)
+AG_GST_CHECK_GST_CHECK($GST_API_VERSION, [$GST_REQ], no)
+AG_GST_CHECK_GST_CONTROLLER($GST_API_VERSION, [$GST_REQ], yes)
+AG_GST_CHECK_GST_PLUGINS_BASE($GST_API_VERSION, [$GSTPB_REQ], yes)
AM_CONDITIONAL(HAVE_GST_CHECK, test "x$HAVE_GST_CHECK" = "xyes")
-GSTPB_PLUGINS_DIR=`$PKG_CONFIG gstreamer-plugins-base-$GST_MAJORMINOR --variable pluginsdir`
+GSTPB_PLUGINS_DIR=`$PKG_CONFIG gstreamer-plugins-base-$GST_API_VERSION --variable pluginsdir`
AC_SUBST(GSTPB_PLUGINS_DIR)
AC_MSG_NOTICE(Using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR)
dnl check for gstreamer-pbutils
-PKG_CHECK_MODULES(GST_PBUTILS, gstreamer-pbutils-$GST_MAJORMINOR, HAVE_GST_PBUTILS="yes", HAVE_GST_PBUTILS="no")
+PKG_CHECK_MODULES(GST_PBUTILS, gstreamer-pbutils-$GST_API_VERSION, HAVE_GST_PBUTILS="yes", HAVE_GST_PBUTILS="no")
if test "x$HAVE_GST_PBUTILS" != "xyes"; then
AC_ERROR([gst-pbutils is required for rendering support])
fi
AC_SUBST(GST_PBUTILS_CFLAGS)
dnl check for gst-controller
-PKG_CHECK_MODULES(GST_CONTROLLER, gstreamer-controller-$GST_MAJORMINOR, HAVE_GST_CONTROLLER="yes", HAVE_GST_CONROLLER="no")
+PKG_CHECK_MODULES(GST_CONTROLLER, gstreamer-controller-$GST_API_VERSION, HAVE_GST_CONTROLLER="yes", HAVE_GST_CONROLLER="no")
if test "x$HAVE_GST_CONTROLLER" != "xyes"; then
AC_ERROR([gst-controller is required for transition support])
fi
AC_SUBST(GST_CONTROLLER_CFLAGS)
dnl check for gstvideo
-PKG_CHECK_MODULES(GST_VIDEO, gstreamer-video-$GST_MAJORMINOR, HAVE_GST_VIDEO="yes", HAVE_GST_CONROLLER="no")
+PKG_CHECK_MODULES(GST_VIDEO, gstreamer-video-$GST_API_VERSION, HAVE_GST_VIDEO="yes", HAVE_GST_CONROLLER="no")
if test "x$HAVE_GST_VIDEO" != "xyes"; then
AC_ERROR([gst-video is required for transition support])
fi
dnl Check for documentation xrefs
GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
-GST_PREFIX="`$PKG_CONFIG --variable=prefix gstreamer-$GST_MAJORMINOR`"
-GSTPB_PREFIX="`$PKG_CONFIG --variable=prefix gstreamer-plugins-base-$GST_MAJORMINOR`"
+GST_PREFIX="`$PKG_CONFIG --variable=prefix gstreamer-$GST_API_VERSION`"
+GSTPB_PREFIX="`$PKG_CONFIG --variable=prefix gstreamer-plugins-base-$GST_API_VERSION`"
AC_SUBST(GLIB_PREFIX)
AC_SUBST(GST_PREFIX)
AC_SUBST(GSTPB_PREFIX)
GST_ALL_LDFLAGS="-no-undefined"
AC_SUBST(GST_ALL_LDFLAGS)
+dnl GST_LIB_LDFLAGS
+dnl linker flags shared by all libraries
+dnl LDFLAGS modifier defining exported symbols from built libraries
+GST_LIB_LDFLAGS=" -export-symbols-regex \^_*\(ges_\|GES_\).*"
+AC_SUBST(GST_LIB_LDFLAGS)
+
dnl *** output files ***
dnl po/Makefile.in
gst-editing-services.spec
m4/Makefile
ges/Makefile
-bindings/Makefile
-bindings/python/Makefile
-bindings/python/codegen/Makefile
-bindings/python/examples/Makefile
-bindings/python/testsuite/Makefile
tests/Makefile
tests/check/Makefile
tests/examples/Makefile
GTKDOC_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_BASE_CFLAGS) \
$(GST_CFLAGS) $(GIO_CFLAGS)
GTKDOC_LIBS = \
- $(top_builddir)/ges/libges-@GST_MAJORMINOR@.la \
+ $(top_builddir)/ges/libges-@GST_API_VERSION@.la \
$(GST_BASE_LIBS) $(GST_LIBS) $(GIO_LIBS)
GTKDOC_CC=$(LIBTOOL) --tag=CC --mode=compile $(CC)
<bookinfo>
<title>GStreamer Editing Services &GES_VERSION; Reference Manual</title>
<releaseinfo>
- for GStreamer Editing Services &GST_MAJORMINOR; (&GES_VERSION;)
+ for GStreamer Editing Services &GST_API_VERSION; (&GES_VERSION;)
</releaseinfo>
</bookinfo>
ges_timeline_pipeline_get_thumbnail_buffer
ges_timeline_pipeline_get_thumbnail_rgb24
ges_timeline_pipeline_save_thumbnail
+ges_timeline_pipeline_preview_get_video_sink
+ges_timeline_pipeline_preview_set_video_sink
<SUBSECTION Standard>
GESTimelinePipelineClass
GESTimelinePipelinePrivate
-<!ENTITY GST_MAJORMINOR "@GST_MAJORMINOR@">
+<!ENTITY GST_API_VERSION "@GST_API_VERSION@">
<!ENTITY GES_VERSION "@VERSION@">
-built_header_make = gesmarshal.h
-built_source_make = gesmarshal.c
+built_header_make =
+built_source_make =
-lib_LTLIBRARIES = libges-@GST_MAJORMINOR@.la
+lib_LTLIBRARIES = libges-@GST_API_VERSION@.la
-EXTRA_libges_@GST_MAJORMINOR@_la_SOURCES = gesmarshal.list
+EXTRA_libges_@GST_API_VERSION@_la_SOURCES = gesmarshal.list
CLEANFILES = $(BUILT_SOURCES) $(built_header_make) $(built_source_make)
-libges_@GST_MAJORMINOR@_la_SOURCES = \
+libges_@GST_API_VERSION@_la_SOURCES = \
$(built_source_make) \
ges.c \
ges-enums.c \
ges-pitivi-formatter.c \
ges-utils.c
-libges_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/ges/
-libges_@GST_MAJORMINOR@include_HEADERS = \
+libges_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/ges/
+libges_@GST_API_VERSION@include_HEADERS = \
$(built_header_make) \
ges-types.h \
ges.h \
noinst_HEADERS = \
ges-internal.h
-libges_@GST_MAJORMINOR@_la_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) \
+libges_@GST_API_VERSION@_la_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) \
$(GST_VIDEO_CFLAGS) $(GST_CONTROLLER_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CFLAGS) $(XML_CFLAGS) $(GIO_CFLAGS)
-libges_@GST_MAJORMINOR@_la_LIBADD = $(GST_PBUTILS_LIBS) \
+libges_@GST_API_VERSION@_la_LIBADD = $(GST_PBUTILS_LIBS) \
$(GST_VIDEO_LIBS) $(GST_CONTROLLER_LIBS) $(GST_PLUGINS_BASE_LIBS) \
$(GST_BASE_LIBS) $(GST_LIBS) $(XML_LIBS) $(GIO_LIBS)
-libges_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) \
- $(GST_LT_LDFLAGS) $(GIO_CFLAGS) -export-symbols-regex \^_*\(ges_\|GES_\).*
+libges_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) \
+ $(GST_LT_LDFLAGS) $(GIO_CFLAGS)
DISTCLEANFILE = $(CLEANFILES)
$(built_header_make) \
$(built_source_make)
-gesmarshal.h: gesmarshal.list
- glib-genmarshal --header --prefix=ges_marshal $^ > gesmarshal.h.tmp
- mv gesmarshal.h.tmp gesmarshal.h
-
-gesmarshal.c: gesmarshal.list
- echo "#include \"glib-object.h\"" >gesmarshal.c.tmp
- echo "#include \"gesmarshal.h\"" >> gesmarshal.c.tmp
- glib-genmarshal --body --prefix=ges_marshal $^ >> gesmarshal.c.tmp
- mv gesmarshal.c.tmp gesmarshal.c
include $(top_srcdir)/common/gst-glib-gen.mak
if HAVE_INTROSPECTION
-BUILT_GIRSOURCES = GES-@GST_MAJORMINOR@.gir
+BUILT_GIRSOURCES = GES-@GST_API_VERSION@.gir
-gir_headers=$(patsubst %,$(srcdir)/%, $(libges_@GST_MAJORMINOR@include_HEADERS))
-gir_headers+=$(patsubst %,$(builddir)/%, $(nodist_libges_@GST_MAJORMINOR@include_HEADERS))
-gir_sources=$(patsubst %,$(srcdir)/%, $(libges_@GST_MAJORMINOR@_la_SOURCES))
-gir_sources+=$(patsubst %,$(builddir)/%, $(nodist_libges_@GST_MAJORMINOR@_la_SOURCES))
-gir_cincludes=$(patsubst %,--c-include='ges/%',$(libges_@GST_MAJORMINOR@include_HEADERS))
-gir_cincludes+=$(patsubst %,--c-include='ges/%',$(nodist_libges_@GST_MAJORMINOR@include_HEADERS))
+gir_headers=$(patsubst %,$(srcdir)/%, $(libges_@GST_API_VERSION@include_HEADERS))
+gir_headers+=$(patsubst %,$(builddir)/%, $(nodist_libges_@GST_API_VERSION@include_HEADERS))
+gir_sources=$(patsubst %,$(srcdir)/%, $(libges_@GST_API_VERSION@_la_SOURCES))
+gir_sources+=$(patsubst %,$(builddir)/%, $(nodist_libges_@GST_API_VERSION@_la_SOURCES))
+gir_cincludes=$(patsubst %,--c-include='ges/%',$(libges_@GST_API_VERSION@include_HEADERS))
+gir_cincludes+=$(patsubst %,--c-include='ges/%',$(nodist_libges_@GST_API_VERSION@include_HEADERS))
-GES-@GST_MAJORMINOR@.gir: $(INTROSPECTION_SCANNER) libges-@GST_MAJORMINOR@.la
+GES-@GST_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libges-@GST_API_VERSION@.la
$(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
$(INTROSPECTION_SCANNER) -v --namespace GES \
- --nsversion=@GST_MAJORMINOR@ \
+ --nsversion=@GST_API_VERSION@ \
--identifier-prefix=GES \
--symbol-prefix=ges \
--warn-all \
$(gir_cincludes) \
-I$(top_srcdir) \
-I$(top_builddir) \
- --add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-0.10` \
- --add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-pbutils-0.10` \
+ --add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-@GST_API_VERSION@` \
+ --add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-pbutils-@GST_API_VERSION@` \
--add-include-path=`$(PKG_CONFIG) --variable=girdir gio-2.0` \
- --library=libges-@GST_MAJORMINOR@.la \
- --include=Gst-@GST_MAJORMINOR@ \
- --include=GstPbutils-@GST_MAJORMINOR@ \
+ --library=libges-@GST_API_VERSION@.la \
+ --include=Gst-@GST_API_VERSION@ \
+ --include=GstPbutils-@GST_API_VERSION@ \
--libtool="$(top_builddir)/libtool" \
- --pkg gstreamer-@GST_MAJORMINOR@ \
- --pkg gstreamer-pbutils-@GST_MAJORMINOR@ \
+ --pkg gstreamer-@GST_API_VERSION@ \
+ --pkg gstreamer-pbutils-@GST_API_VERSION@ \
--pkg gio-2.0 \
- --pkg-export ges-@GST_MAJORMINOR@ \
+ --pkg-export ges-@GST_API_VERSION@ \
+ --add-init-section="gst_init(NULL, NULL);" \
--add-init-section="ges_init(NULL, NULL);" \
--output $@ \
$(gir_headers) \
--includedir=$(srcdir) \
--includedir=$(srcdir)/../video \
--includedir=$(builddir) \
- --includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-0.10` \
- --includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-pbutils-0.10` \
+ --includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-@GST_API_VERSION@` \
+ --includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-pbutils-@GST_API_VERSION@` \
--includedir=`$(PKG_CONFIG) --variable=girdir gio-2.0` \
$(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
endif
Android.mk: Makefile.am $(BUILT_SOURCES)
- androgenizer -:PROJECT libges -:SHARED libges-@GST_MAJORMINOR@ \
+ androgenizer -:PROJECT libges -:SHARED libges-@GST_API_VERSION@ \
-:TAGS eng debug \
-:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
- -:SOURCES $(libges_@GST_MAJORMINOR@_la_SOURCES) \
- $(nodist_libges_@GST_MAJORMINOR@_la_SOURCES) \
- -:CFLAGS $(DEFS) $(libges_@GST_MAJORMINOR@_la_CFLAGS) \
- -:LDFLAGS $(libges_@GST_MAJORMINOR@_la_LDFLAGS) \
- $(libges_@GST_MAJORMINOR@_la_LIBADD) \
+ -:SOURCES $(libges_@GST_API_VERSION@_la_SOURCES) \
+ $(nodist_libges_@GST_API_VERSION@_la_SOURCES) \
+ -:CFLAGS $(DEFS) $(libges_@GST_API_VERSION@_la_CFLAGS) \
+ -:LDFLAGS $(libges_@GST_API_VERSION@_la_LDFLAGS) \
+ $(libges_@GST_API_VERSION@_la_LIBADD) \
-ldl \
- -:HEADER_TARGET gstreamer-@GST_MAJORMINOR@/gst/interfaces \
- -:HEADERS $(libges_@GST_MAJORMINOR@include_HEADERS) \
- $(nodist_libges_@GST_MAJORMINOR@include_HEADERS) \
+ -:HEADER_TARGET gstreamer-@GST_API_VERSION@/gst/interfaces \
+ -:HEADERS $(libges_@GST_API_VERSION@include_HEADERS) \
+ $(nodist_libges_@GST_API_VERSION@include_HEADERS) \
-:PASSTHROUGH LOCAL_ARM_MODE:=arm \
> $@
#include <gio/gio.h>
#include <stdlib.h>
-#include "gesmarshal.h"
#include "ges-formatter.h"
#include "ges-keyfile-formatter.h"
#include "ges-internal.h"
*/
ges_formatter_signals[SOURCE_MOVED_SIGNAL] =
g_signal_new ("source-moved", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
1, GES_TYPE_TIMELINE_FILE_SOURCE);
/**
*/
ges_formatter_signals[LOADED_SIGNAL] =
g_signal_new ("loaded", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
1, GES_TYPE_TIMELINE);
object_class->dispose = ges_formatter_dispose;
#include "ges-screenshot.h"
#include "ges-internal.h"
-GstBuffer *
+GstSample *
ges_play_sink_convert_frame (GstElement * playsink, GstCaps * caps)
{
- GstBuffer *result;
+ GstSample *sample = NULL;
- g_object_get (G_OBJECT (playsink), "frame", (GstMiniObject *) & result, NULL);
+ g_signal_emit_by_name (playsink, "convert-sample", caps, &sample);
- GST_DEBUG ("got buffer %p from playsink", result);
-
- if (result != NULL && caps != NULL) {
- GstBuffer *temp;
- GError *err = NULL;
-
- temp = gst_video_convert_frame (result, caps, 25 * GST_SECOND, &err);
- gst_buffer_unref (result);
- if (temp == NULL && err) {
- /* I'm really uncertain whether we should make playsink post an error
- * on the bus or not. It's not like it's a critical issue regarding
- * playsink behaviour. */
- GST_ERROR ("Error converting frame: %s", err->message);
- }
- result = temp;
- }
- return result;
+ return sample;
}
G_BEGIN_DECLS
-GstBuffer *
+GstSample *
ges_play_sink_convert_frame (GstElement * playsink, GstCaps * caps);
G_END_DECLS
#include <ges/ges.h>
#include "ges-internal.h"
-#include "gesmarshal.h"
static void
ges_simple_timeline_layer_object_removed (GESTimelineLayer * layer,
g_signal_new ("object-moved", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESSimpleTimelineLayerClass,
object_moved),
- NULL, NULL,
- ges_marshal_VOID__OBJECT_INT_INT, G_TYPE_NONE, 3,
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 3,
GES_TYPE_TIMELINE_OBJECT, G_TYPE_INT, G_TYPE_INT);
}
*/
#include "ges-internal.h"
-#include "gesmarshal.h"
#include "ges-timeline-layer.h"
#include "ges.h"
#include "ges-timeline-source.h"
ges_timeline_layer_signals[OBJECT_ADDED] =
g_signal_new ("object-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineLayerClass, object_added),
- NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
GES_TYPE_TIMELINE_OBJECT);
/**
ges_timeline_layer_signals[OBJECT_REMOVED] =
g_signal_new ("object-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineLayerClass,
- object_removed), NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GES_TYPE_TIMELINE_OBJECT);
+ object_removed), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
+ 1, GES_TYPE_TIMELINE_OBJECT);
}
static void
#include "ges-timeline-object.h"
#include "ges.h"
-#include "gesmarshal.h"
#include "ges-internal.h"
+#include <string.h>
+
gboolean
ges_timeline_object_fill_track_object_func (GESTimelineObject * object,
GESTrackObject * trackobj, GstElement * gnlobj);
*/
ges_timeline_object_signals[EFFECT_ADDED] =
g_signal_new ("effect-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, GES_TYPE_TRACK_EFFECT);
/**
*/
ges_timeline_object_signals[EFFECT_REMOVED] =
g_signal_new ("effect-removed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, GES_TYPE_TRACK_EFFECT);
/**
*/
ges_timeline_object_signals[TRACK_OBJECT_ADDED] =
g_signal_new ("track-object-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, GES_TYPE_TRACK_OBJECT);
/**
*/
ges_timeline_object_signals[TRACK_OBJECT_REMOVED] =
g_signal_new ("track-object-removed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, GES_TYPE_TRACK_OBJECT);
/**
GstPad *playsinkpad;
GstPad *encodebinpad;
GstPad *blocked_pad;
+ gulong probe_id;
} OutputChain;
G_DEFINE_TYPE (GESTimelinePipeline, ges_timeline_pipeline, GST_TYPE_PIPELINE);
GST_DEBUG ("Smart Render mode, setting input caps");
ocaps = gst_encoding_profile_get_input_caps (prof);
if (track->type == GES_TRACK_TYPE_AUDIO)
- rcaps = gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
+ rcaps = gst_caps_new_empty_simple ("audio/x-raw");
else
- rcaps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb");
+ rcaps = gst_caps_new_empty_simple ("video/x-raw");
gst_caps_append (ocaps, rcaps);
ges_track_set_caps (track, ocaps);
} else {
/* Raw preview or rendering mode */
if (track->type == GES_TRACK_TYPE_VIDEO)
- caps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb");
+ caps = gst_caps_new_empty_simple ("video/x-raw");
else if (track->type == GES_TRACK_TYPE_AUDIO)
- gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
+ caps = gst_caps_new_empty_simple ("audio/x-raw");
if (caps) {
ges_track_set_caps (track, caps);
ret = GST_STATE_CHANGE_FAILURE;
goto done;
}
- if (self->
- priv->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
+ if (self->priv->
+ mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
GST_DEBUG ("rendering => Updating pipeline caps");
if (!ges_timeline_pipeline_update_caps (self)) {
GST_ERROR_OBJECT (element, "Error setting the caps for rendering");
GstIterator *pads;
gboolean done = FALSE;
GstCaps *srccaps;
+ GValue paditem = { 0, };
if (G_UNLIKELY (pad == NULL))
goto no_pad;
pads = gst_element_iterate_sink_pads (element);
else
pads = gst_element_iterate_src_pads (element);
- srccaps = gst_pad_get_caps_reffed (pad);
+ srccaps = gst_pad_query_caps (pad, NULL);
GST_DEBUG ("srccaps %" GST_PTR_FORMAT, srccaps);
while (!done) {
- gpointer padptr;
-
- switch (gst_iterator_next (pads, &padptr)) {
+ switch (gst_iterator_next (pads, &paditem)) {
case GST_ITERATOR_OK:
{
- GstPad *testpad = (GstPad *) padptr;
+ GstPad *testpad = g_value_get_object (&paditem);
- if (gst_pad_is_linked (testpad)) {
- gst_object_unref (testpad);
- } else {
- GstCaps *sinkcaps = gst_pad_get_caps_reffed (testpad);
+ if (!gst_pad_is_linked (testpad)) {
+ GstCaps *sinkcaps = gst_pad_query_caps (testpad, NULL);
GST_DEBUG ("sinkccaps %" GST_PTR_FORMAT, sinkcaps);
if (gst_caps_can_intersect (srccaps, sinkcaps)) {
- res = testpad;
+ res = gst_object_ref (testpad);
done = TRUE;
- } else
- gst_object_unref (testpad);
+ }
gst_caps_unref (sinkcaps);
}
+ g_value_reset (&paditem);
}
break;
case GST_ITERATOR_DONE:
break;
}
}
+ g_value_reset (&paditem);
gst_iterator_free (pads);
gst_caps_unref (srccaps);
}
}
-static void
-pad_blocked (GstPad * pad, gboolean blocked, gpointer user_data)
+static GstPadProbeReturn
+pad_blocked (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
/* no nothing */
- GST_DEBUG_OBJECT (pad, "blocked callback, blocked: %d", blocked);
+ GST_DEBUG_OBJECT (pad, "blocked callback, blocked");
+ return GST_PAD_PROBE_OK;
}
static void
OutputChain *chain;
GESTrack *track;
GstPad *sinkpad;
+ GstCaps *caps;
gboolean reconfigured = FALSE;
+ caps = gst_pad_query_caps (pad, NULL);
+
GST_DEBUG_OBJECT (self, "new pad %s:%s , caps:%" GST_PTR_FORMAT,
- GST_DEBUG_PAD_NAME (pad), GST_PAD_CAPS (pad));
+ GST_DEBUG_PAD_NAME (pad), caps);
- if (G_UNLIKELY (!(track =
- ges_timeline_get_track_for_pad (self->priv->timeline, pad)))) {
+ gst_caps_unref (caps);
+
+ track = ges_timeline_get_track_for_pad (self->priv->timeline, pad);
+
+ if (G_UNLIKELY (!track)) {
GST_WARNING_OBJECT (self, "Couldn't find coresponding track !");
return;
}
goto error;
}
chain->blocked_pad = tmppad;
- GST_DEBUG ("blocking pad %" GST_PTR_FORMAT, tmppad);
- gst_pad_set_blocked_async (tmppad, TRUE, pad_blocked, NULL);
+ GST_DEBUG_OBJECT (tmppad, "blocking pad");
+ chain->probe_id = gst_pad_add_probe (tmppad, GST_PAD_PROBE_TYPE_BLOCK,
+ pad_blocked, NULL, NULL);
GST_DEBUG ("Reconfiguring playsink");
sinkpad = get_compatible_unlinked_pad (self->priv->encodebin, pad);
if (sinkpad == NULL) {
- GstCaps *caps = gst_pad_get_caps_reffed (pad);
+ GstCaps *caps = gst_pad_query_caps (pad, NULL);
+
/* If no compatible static pad is available, request a pad */
g_signal_emit_by_name (self->priv->encodebin, "request-pad", caps,
&sinkpad);
gst_caps_unref (caps);
+
if (G_UNLIKELY (sinkpad == NULL)) {
GST_ERROR_OBJECT (self, "Couldn't get a pad from encodebin !");
goto error;
}
if (chain->blocked_pad) {
- GST_DEBUG ("unblocking pad %" GST_PTR_FORMAT, chain->blocked_pad);
- gst_pad_set_blocked_async (chain->blocked_pad, FALSE, pad_blocked, NULL);
+ GST_DEBUG_OBJECT (chain->blocked_pad, "unblocking pad");
+ gst_pad_remove_probe (chain->blocked_pad, chain->probe_id);
gst_object_unref (chain->blocked_pad);
chain->blocked_pad = NULL;
+ chain->probe_id = 0;
}
/* Unlike/remove tee */
OutputChain *chain = (OutputChain *) tmp->data;
if (chain->blocked_pad) {
- GST_DEBUG ("unblocking pad %" GST_PTR_FORMAT, chain->blocked_pad);
- gst_pad_set_blocked_async (chain->blocked_pad, FALSE, pad_blocked, NULL);
+ GST_DEBUG_OBJECT (chain->blocked_pad, "unblocking pad");
+ gst_pad_remove_probe (chain->blocked_pad, chain->probe_id);
+ chain->probe_id = 0;
+ /* do we need to unref and NULL the pad here? */
}
}
}
}
/**
- * ges_timeline_pipeline_get_thumbnail_buffer:
+ * ges_timeline_pipeline_get_thumbnail:
* @self: a #GESTimelinePipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
* @caps: (transfer none): caps specifying current format. Use %GST_CAPS_ANY
* for native size.
*
- * Returns a #GstBuffer with the currently playing in the format specified by
- * caps. The caller should unref the #gst_buffer_unref when finished. If ANY
+ * Returns a #GstSample with the currently playing image in the format specified by
+ * caps. The caller should free the sample with #gst_sample_unref when finished. If ANY
* caps are specified, the information will be returned in the whatever format
* is currently used by the sink. This information can be retrieve from caps
* associated with the buffer.
*
- * Returns: (transfer full): a #GstBuffer or %NULL
+ * Returns: (transfer full): a #GstSample or %NULL
*/
-GstBuffer *
-ges_timeline_pipeline_get_thumbnail_buffer (GESTimelinePipeline * self,
- GstCaps * caps)
+GstSample *
+ges_timeline_pipeline_get_thumbnail (GESTimelinePipeline * self, GstCaps * caps)
{
GstElement *sink;
- GstBuffer *buf;
sink = self->priv->playsink;
+
if (!sink) {
GST_WARNING ("thumbnailing can only be done if we have a playsink");
return NULL;
}
- buf = ges_play_sink_convert_frame (sink, caps);
-
- return buf;
+ return ges_play_sink_convert_frame (sink, caps);
}
/**
*
* Returns: %TRUE if the thumbnail was properly save, else %FALSE.
*/
-
+/* FIXME 0.11: save_thumbnail should have a GError parameter */
gboolean
ges_timeline_pipeline_save_thumbnail (GESTimelinePipeline * self, int width, int
height, const gchar * format, const gchar * location)
{
+ GstMapInfo map_info;
GstBuffer *b;
- FILE *fp;
+ GstSample *sample;
GstCaps *caps;
gboolean res = TRUE;
if (height > 1)
gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
- if (!(b = ges_timeline_pipeline_get_thumbnail_buffer (self, caps))) {
+ if (!(sample = ges_timeline_pipeline_get_thumbnail (self, caps))) {
gst_caps_unref (caps);
return res;
}
- /* FIXME : Use standard glib methods */
- fp = fopen (location, "w+");
- if (!fwrite (GST_BUFFER_DATA (b), GST_BUFFER_SIZE (b), 1, fp) || ferror (fp)) {
- res = FALSE;
+ b = gst_sample_get_buffer (sample);
+ if (gst_buffer_map (b, &map_info, GST_MAP_READ)) {
+ GError *err = NULL;
+
+ if (!g_file_set_contents (location, (const char *) map_info.data,
+ map_info.size, &err)) {
+ GST_WARNING ("Could not save thumbnail: %s", err->message);
+ g_error_free (err);
+ res = FALSE;
+ }
}
- fclose (fp);
gst_caps_unref (caps);
+ gst_buffer_unmap (b, &map_info);
gst_buffer_unref (b);
+ gst_sample_unref (sample);
+
return res;
}
* @width: the requested width or -1 for native size
* @height: the requested height or -1 for native size
*
- * A convenience method for ges_timeline_pipeline_get_thumbnail_raw which
+ * A convenience method for @ges_timeline_pipeline_get_thumbnail which
* returns a buffer in 24-bit RGB, optionally scaled to the specified width
* and height. If -1 is specified for either dimension, it will be left at
* native size. You can retreive this information from the caps associated
* with the buffer.
*
- * The caller is responsible for unreffing the returned buffer with
- * #gst_buffer_unref.
+ * The caller is responsible for unreffing the returned sample with
+ * #gst_sample_unref.
*
- * Returns: (transfer full): a #GstBuffer or %NULL
+ * Returns: (transfer full): a #GstSample or %NULL
*/
-GstBuffer *
+GstSample *
ges_timeline_pipeline_get_thumbnail_rgb24 (GESTimelinePipeline * self,
gint width, gint height)
{
- GstBuffer *ret;
+ GstSample *ret;
GstCaps *caps;
- caps = gst_caps_from_string ("video/x-raw-rgb,bpp=(int)24," "depth=(int)24");
+ caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
+ "RGB", NULL);
if (width != -1)
gst_caps_set_simple (caps, "width", G_TYPE_INT, (gint) width, NULL);
if (height != -1)
gst_caps_set_simple (caps, "height", G_TYPE_INT, (gint) height, NULL);
- ret = ges_timeline_pipeline_get_thumbnail_buffer (self, caps);
+ ret = ges_timeline_pipeline_get_thumbnail (self, caps);
gst_caps_unref (caps);
return ret;
}
gboolean ges_timeline_pipeline_set_mode (GESTimelinePipeline *pipeline,
GESPipelineFlags mode);
-GstBuffer *
-ges_timeline_pipeline_get_thumbnail_buffer(GESTimelinePipeline *self, GstCaps *caps);
+GstSample *
+ges_timeline_pipeline_get_thumbnail(GESTimelinePipeline *self, GstCaps *caps);
-GstBuffer *
+GstSample *
ges_timeline_pipeline_get_thumbnail_rgb24(GESTimelinePipeline *self,
gint width, gint height);
* documentation about #GESFormatter.
*/
-#include "gesmarshal.h"
#include "ges-internal.h"
#include "ges-timeline.h"
#include "ges-track.h"
G_DEFINE_TYPE (GESTimeline, ges_timeline, GST_TYPE_BIN);
#define GES_TIMELINE_PENDINGOBJS_GET_LOCK(timeline) \
- (GES_TIMELINE(timeline)->priv->pendingobjects_lock)
+ (&GES_TIMELINE(timeline)->priv->pendingobjects_lock)
#define GES_TIMELINE_PENDINGOBJS_LOCK(timeline) \
(g_mutex_lock(GES_TIMELINE_PENDINGOBJS_GET_LOCK (timeline)))
#define GES_TIMELINE_PENDINGOBJS_UNLOCK(timeline) \
GstDiscoverer *discoverer;
GList *pendingobjects;
/* lock to avoid discovery of objects that will be removed */
- GMutex *pendingobjects_lock;
+ GMutex pendingobjects_lock;
/* Whether we are changing state asynchronously or not */
gboolean async_pending;
{
GESTimeline *timeline = GES_TIMELINE (object);
- g_mutex_free (timeline->priv->pendingobjects_lock);
+ g_mutex_clear (&timeline->priv->pendingobjects_lock);
G_OBJECT_CLASS (ges_timeline_parent_class)->finalize (object);
}
ges_timeline_signals[TRACK_ADDED] =
g_signal_new ("track-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_added), NULL,
- NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TRACK);
+ NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_TRACK);
/**
* GESTimeline::track-removed
ges_timeline_signals[TRACK_REMOVED] =
g_signal_new ("track-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_removed),
- NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TRACK);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_TRACK);
/**
* GESTimeline::layer-added
ges_timeline_signals[LAYER_ADDED] =
g_signal_new ("layer-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_added), NULL,
- NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TIMELINE_LAYER);
+ NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
+ GES_TYPE_TIMELINE_LAYER);
/**
* GESTimeline::layer-removed
ges_timeline_signals[LAYER_REMOVED] =
g_signal_new ("layer-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed),
- NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
GES_TYPE_TIMELINE_LAYER);
/**
*/
ges_timeline_signals[DISCOVERY_ERROR] =
g_signal_new ("discovery-error", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, gst_marshal_VOID__OBJECT_BOXED,
- G_TYPE_NONE, 2, GES_TYPE_TIMELINE_FILE_SOURCE, GST_TYPE_G_ERROR);
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
+ G_TYPE_NONE, 2, GES_TYPE_TIMELINE_FILE_SOURCE, G_TYPE_ERROR);
/**
* GESTimeline::track-objects-snapping:
priv->starts_ends = g_sequence_new (g_free);
priv->tracksources = g_sequence_new (g_object_unref);
- priv->pendingobjects_lock = g_mutex_new ();
+ g_mutex_init (&priv->pendingobjects_lock);
/* New discoverer with a 15s timeout */
priv->discoverer = gst_discoverer_new (15 * GST_SECOND, NULL);
g_signal_connect (priv->discoverer, "finished",
gst_element_set_locked_state ((GstElement *) tr_priv->track, TRUE);
}
- message = gst_message_new_async_start (GST_OBJECT_CAST (timeline), FALSE);
+ message = gst_message_new_async_start (GST_OBJECT_CAST (timeline));
parent_class->handle_message (GST_BIN_CAST (timeline), message);
}
}
GST_DEBUG_OBJECT (timeline, "Emitting async-done");
- message = gst_message_new_async_done (GST_OBJECT_CAST (timeline));
+ message = gst_message_new_async_done (GST_OBJECT_CAST (timeline), FALSE);
parent_class->handle_message (GST_BIN_CAST (timeline), message);
timeline->priv->async_pending = FALSE;
#include "ges-track-object.h"
#include "ges-track-audio-transition.h"
+#include <gst/controller/gstdirectcontrolbinding.h>
+
G_DEFINE_TYPE (GESTrackAudioTransition, ges_track_audio_transition,
GES_TYPE_TRACK_TRANSITION);
{
/* these enable volume interpolation. Unlike video, both inputs are adjusted
* simultaneously */
- GstController *a_controller;
- GstInterpolationControlSource *a_control_source;
+ GstControlSource *a_control_source;
- GstController *b_controller;
- GstInterpolationControlSource *b_control_source;
+ GstControlSource *b_control_source;
};
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_TRACK_AUDIO_TRANSITION, GESTrackAudioTransitionPrivate);
-
- self->priv->a_controller = NULL;
- self->priv->a_control_source = NULL;
-
- self->priv->b_controller = NULL;
- self->priv->b_control_source = NULL;
}
static void
self = GES_TRACK_AUDIO_TRANSITION (object);
- if (self->priv->a_controller) {
- g_object_unref (self->priv->a_controller);
- self->priv->a_controller = NULL;
+ if (self->priv->a_control_source) {
if (self->priv->a_control_source)
gst_object_unref (self->priv->a_control_source);
self->priv->a_control_source = NULL;
}
- if (self->priv->b_controller) {
- g_object_unref (self->priv->b_controller);
- self->priv->b_controller = NULL;
+ if (self->priv->b_control_source) {
if (self->priv->b_control_source)
gst_object_unref (self->priv->b_control_source);
self->priv->b_control_source = NULL;
GstElement * mixer)
{
GstElement *volume = gst_element_factory_make ("volume", NULL);
+
gst_bin_add (bin, volume);
if (!fast_element_link (element, volume) ||
const gchar *propname = "volume";
GstElement *mixer = NULL;
GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src;
- GstController *acontroller, *bcontroller;
- GstInterpolationControlSource *acontrol_source, *bcontrol_source;
+ GstControlSource *acontrol_source, *bcontrol_source;
self = GES_TRACK_AUDIO_TRANSITION (object);
gst_object_unref (sinkb_target);
gst_object_unref (src_target);
-
- //g_object_set(atarget, propname, (gdouble) 0, NULL);
- //g_object_set(btarget, propname, (gdouble) 0, NULL);
-
- acontroller = gst_object_control_properties (atarget, propname, NULL);
- bcontroller = gst_object_control_properties (btarget, propname, NULL);
-
- g_assert (acontroller && bcontroller);
-
acontrol_source = gst_interpolation_control_source_new ();
- gst_controller_set_control_source (acontroller,
- propname, GST_CONTROL_SOURCE (acontrol_source));
- gst_interpolation_control_source_set_interpolation_mode (acontrol_source,
- GST_INTERPOLATE_LINEAR);
+ gst_object_add_control_binding (GST_OBJECT (atarget),
+ gst_direct_control_binding_new (GST_OBJECT (atarget), propname,
+ acontrol_source));
+ g_object_set (acontrol_source, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
bcontrol_source = gst_interpolation_control_source_new ();
- gst_controller_set_control_source (bcontroller,
- propname, GST_CONTROL_SOURCE (bcontrol_source));
- gst_interpolation_control_source_set_interpolation_mode (bcontrol_source,
- GST_INTERPOLATE_LINEAR);
+ gst_object_add_control_binding (GST_OBJECT (btarget),
+ gst_direct_control_binding_new (GST_OBJECT (btarget), propname,
+ bcontrol_source));
+ g_object_set (acontrol_source, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
- self->priv->a_controller = acontroller;
- self->priv->b_controller = bcontroller;
self->priv->a_control_source = acontrol_source;
self->priv->b_control_source = bcontrol_source;
{
GESTrackAudioTransition *self;
GstElement *gnlobj = ges_track_object_get_gnlobject (object);
-
- GValue zero = { 0, };
- GValue one = { 0, };
+ GstTimedValueControlSource *ta, *tb;
self = GES_TRACK_AUDIO_TRANSITION (object);
- GST_LOG ("updating controller: gnlobj (%p) acontroller(%p) bcontroller(%p)",
- gnlobj, self->priv->a_controller, self->priv->b_controller);
+ GST_LOG ("updating controller: gnlobj (%p)", gnlobj);
if (G_UNLIKELY ((!gnlobj || !self->priv->a_control_source ||
!self->priv->b_control_source)))
return;
GST_INFO ("duration: %" G_GUINT64_FORMAT, duration);
- g_value_init (&zero, G_TYPE_DOUBLE);
- g_value_init (&one, G_TYPE_DOUBLE);
- g_value_set_double (&zero, 0.0);
- g_value_set_double (&one, 1.0);
GST_LOG ("setting values on controller");
+ ta = GST_TIMED_VALUE_CONTROL_SOURCE (self->priv->a_control_source);
+ tb = GST_TIMED_VALUE_CONTROL_SOURCE (self->priv->b_control_source);
- gst_interpolation_control_source_unset_all (self->priv->a_control_source);
- gst_interpolation_control_source_set (self->priv->a_control_source, 0, &one);
- gst_interpolation_control_source_set (self->priv->a_control_source,
- duration, &zero);
+ gst_timed_value_control_source_unset_all (ta);
+ gst_timed_value_control_source_set (ta, 0, 1.0);
+ gst_timed_value_control_source_set (ta, duration, 0.0);
- gst_interpolation_control_source_unset_all (self->priv->b_control_source);
- gst_interpolation_control_source_set (self->priv->b_control_source, 0, &zero);
- gst_interpolation_control_source_set (self->priv->b_control_source, duration,
- &one);
+ gst_timed_value_control_source_unset_all (tb);
+ gst_timed_value_control_source_set (tb, 0, 0.0);
+ gst_timed_value_control_source_set (tb, duration, 1.0);
GST_LOG ("done updating controller");
}
static GHashTable *
ges_track_effect_get_props_hashtable (GESTrackObject * self)
{
- gpointer data;
+ GValue item = { 0, };
GstIterator *it;
GParamSpec **parray;
GObjectClass *class;
it = gst_bin_iterate_recurse (GST_BIN (element));
while (!done) {
- switch (gst_iterator_next (it, &data)) {
+ switch (gst_iterator_next (it, &item)) {
case GST_ITERATOR_OK:
{
gchar **categories;
guint category;
- GstElement *child = GST_ELEMENT_CAST (data);
+ GstElement *child = g_value_get_object (&item);
factory = gst_element_get_factory (child);
klass = gst_element_factory_get_klass (factory);
}
g_strfreev (categories);
- gst_object_unref (child);
+ g_value_reset (&item);
break;
}
case GST_ITERATOR_RESYNC:
break;
}
}
+ g_value_unset (&item);
gst_iterator_free (it);
return ret;
source = gst_element_factory_make ("uridecodebin", NULL);
scale = gst_element_factory_make ("videoscale", NULL);
freeze = gst_element_factory_make ("imagefreeze", NULL);
- iconv = gst_element_factory_make ("ffmpegcolorspace", NULL);
+ iconv = gst_element_factory_make ("videoconvert", NULL);
g_object_set (scale, "add-borders", TRUE, NULL);
*/
#include "ges-internal.h"
-#include "gesmarshal.h"
#include "ges-track-object.h"
#include "ges-timeline-object.h"
#include <gobject/gvaluecollector.h>
ges_track_object_signals[DEEP_NOTIFY] =
g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED |
- G_SIGNAL_NO_HOOKS, 0, NULL, NULL, gst_marshal_VOID__OBJECT_PARAM,
+ G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 2, GST_TYPE_ELEMENT, G_TYPE_PARAM);
klass->create_gnl_object = ges_track_object_create_gnl_object_func;
}
if (track->type == GES_TRACK_TYPE_VIDEO) {
- bin_desc = g_strconcat ("ffmpegcolorspace name=beforecolorspace ! ",
- self->priv->bin_description, " ! ffmpegcolorspace name=aftercolorspace",
+ bin_desc = g_strconcat ("videoconvert name=pre_video_convert ! ",
+ self->priv->bin_description, " ! videoconvert name=post_video_convert",
NULL);
} else if (track->type == GES_TRACK_TYPE_AUDIO) {
bin_desc =
GESTrackTextOverlay *self = GES_TRACK_TEXT_OVERLAY (object);
text = gst_element_factory_make ("textoverlay", NULL);
- iconv = gst_element_factory_make ("ffmpegcolorspace", NULL);
- oconv = gst_element_factory_make ("ffmpegcolorspace", NULL);
+ iconv = gst_element_factory_make ("videoconvert", NULL);
+ oconv = gst_element_factory_make ("videoconvert", NULL);
self->priv->text_el = text;
g_object_ref (text);
#include <glib-object.h>
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include <gst/controller/gstinterpolationcontrolsource.h>
#include <ges/ges-types.h>
#include <ges/ges-track-operation.h>
#include <ges/ges.h>
#include "ges-internal.h"
+#include <gst/controller/gstdirectcontrolbinding.h>
+
G_DEFINE_TYPE (GESTrackVideoTransition, ges_track_video_transition,
GES_TYPE_TRACK_TRANSITION);
GESVideoStandardTransitionType type;
/* these enable video interpolation */
- GstController *controller;
- GstInterpolationControlSource *control_source;
+ GstControlSource *control_source;
/* so we can support changing between wipes */
GstElement *smpte;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_TRACK_VIDEO_TRANSITION, GESTrackVideoTransitionPrivate);
- self->priv->controller = NULL;
self->priv->control_source = NULL;
self->priv->smpte = NULL;
self->priv->mixer = NULL;
GST_LOG ("mixer: %p smpte: %p sinka: %p sinkb: %p",
priv->mixer, priv->smpte, priv->sinka, priv->sinkb);
- if (priv->controller) {
- g_object_unref (priv->controller);
- priv->controller = NULL;
+ if (priv->control_source) {
if (priv->control_source)
gst_object_unref (priv->control_source);
priv->control_source = NULL;
static void
on_caps_set (GstPad * srca_pad, GParamSpec * pspec, GstElement * capsfilt)
{
- gint width, height;
- const GstStructure *str;
- GstCaps *size_caps = NULL;
+ GstCaps *orig_caps;
+
+ orig_caps = gst_pad_query_caps (srca_pad, NULL);
+
+ if (orig_caps) {
+ gint width, height;
+ const GstStructure *str;
+ GstCaps *size_caps;
- if (GST_PAD_CAPS (srca_pad)) {
/* Get width and height of first video */
- str = gst_caps_get_structure (GST_PAD_CAPS (srca_pad), 0);
+ str = gst_caps_get_structure (orig_caps, 0);
gst_structure_get_int (str, "width", &width);
gst_structure_get_int (str, "height", &height);
/* Set capsfilter to the size of the first video */
size_caps =
- gst_caps_new_simple ("video/x-raw-yuv", "width", G_TYPE_INT, width,
+ gst_caps_new_simple ("video/x-raw", "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, NULL);
g_object_set (capsfilt, "caps", size_caps, NULL);
}
GstElement *mixer = NULL;
GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src,
*srca_pad;
- GstController *controller;
- GstInterpolationControlSource *control_source;
GESTrackVideoTransition *self;
GESTrackVideoTransitionPrivate *priv;
+ GstControlSource *control_source;
self = GES_TRACK_VIDEO_TRANSITION (object);
priv = self->priv;
GST_LOG ("creating a video bin");
topbin = gst_bin_new ("transition-bin");
- iconva = gst_element_factory_make ("ffmpegcolorspace", "tr-csp-a");
- iconvb = gst_element_factory_make ("ffmpegcolorspace", "tr-csp-b");
+ iconva = gst_element_factory_make ("videoconvert", "tr-csp-a");
+ iconvb = gst_element_factory_make ("videoconvert", "tr-csp-b");
scalea = gst_element_factory_make ("videoscale", "vs-a");
scaleb = gst_element_factory_make ("videoscale", "vs-b");
capsfilt = gst_element_factory_make ("capsfilter", "capsfilt");
- oconv = gst_element_factory_make ("ffmpegcolorspace", "tr-csp-output");
+ oconv = gst_element_factory_make ("videoconvert", "tr-csp-output");
gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, scalea, scaleb, capsfilt,
oconv, NULL);
mixer = gst_element_factory_make ("videomixer2", NULL);
if (mixer == NULL)
mixer = gst_element_factory_make ("videomixer", NULL);
+ g_assert (mixer);
g_object_set (G_OBJECT (mixer), "background", 1, NULL);
gst_bin_add (GST_BIN (topbin), mixer);
g_object_set (target, propname, (gfloat) 0.0, NULL);
- controller = gst_object_control_properties (target, propname, NULL);
-
control_source = gst_interpolation_control_source_new ();
- gst_controller_set_control_source (controller,
- propname, GST_CONTROL_SOURCE (control_source));
- gst_interpolation_control_source_set_interpolation_mode (control_source,
- GST_INTERPOLATE_LINEAR);
+ gst_object_add_control_binding (GST_OBJECT (target),
+ gst_direct_control_binding_new (GST_OBJECT (target), propname,
+ control_source));
+ g_object_set (control_source, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
- priv->controller = controller;
priv->control_source = control_source;
return topbin;
ges_track_video_transition_duration_changed (GESTrackObject * object,
guint64 duration)
{
- GValue start_value = { 0, };
- GValue end_value = { 0, };
GstElement *gnlobj = ges_track_object_get_gnlobject (object);
GESTrackVideoTransition *self = GES_TRACK_VIDEO_TRANSITION (object);
GESTrackVideoTransitionPrivate *priv = self->priv;
+ GstTimedValueControlSource *ts;
GST_LOG ("updating controller");
if (G_UNLIKELY (!gnlobj || !priv->control_source))
return;
- GST_INFO ("duration: %" G_GUINT64_FORMAT, duration);
- g_value_init (&start_value, G_TYPE_DOUBLE);
- g_value_init (&end_value, G_TYPE_DOUBLE);
- g_value_set_double (&start_value, priv->start_value);
- g_value_set_double (&end_value, priv->end_value);
+ ts = GST_TIMED_VALUE_CONTROL_SOURCE (priv->control_source);
+ GST_INFO ("duration: %" G_GUINT64_FORMAT, duration);
GST_LOG ("setting values on controller");
- gst_interpolation_control_source_unset_all (priv->control_source);
- gst_interpolation_control_source_set (priv->control_source, 0, &start_value);
- gst_interpolation_control_source_set (priv->control_source,
- duration, &end_value);
+ gst_timed_value_control_source_unset_all (ts);
+ gst_timed_value_control_source_set (ts, 0, priv->start_value);
+ gst_timed_value_control_source_set (ts, duration, priv->end_value);
GST_LOG ("done updating controller");
}
#include "ges-internal.h"
#include "ges-track.h"
#include "ges-track-object.h"
-#include "gesmarshal.h"
G_DEFINE_TYPE (GESTrack, ges_track, GST_TYPE_BIN);
* GESTrack:caps
*
* Caps used to filter/choose the output stream. This is generally set to
- * a generic set of caps like 'video/x-raw-rgb;video/x-raw-yuv' for raw video.
+ * a generic set of caps like 'video/x-raw' for raw video.
*
* Default value: #GST_CAPS_ANY.
*/
*/
ges_track_signals[TRACK_OBJECT_ADDED] =
g_signal_new ("track-object-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, GES_TYPE_TRACK_OBJECT);
/**
*/
ges_track_signals[TRACK_OBJECT_REMOVED] =
g_signal_new ("track-object-removed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 1, GES_TYPE_TRACK_OBJECT);
}
/**
* ges_track_new:
* @type: The type of track
- * @caps: The caps to restrict the output of the track to.
+ * @caps: (transfer full): The caps to restrict the output of the track to.
*
* Creates a new #GESTrack with the given @type and @caps.
*
* ges_track_video_raw_new:
*
* Creates a new #GESTrack of type #GES_TRACK_TYPE_VIDEO and with generic
- * raw video caps ("video/x-raw-yuv;video/x-raw-rgb");
+ * raw video caps ("video/x-raw");
*
* Returns: A new #GESTrack.
*/
ges_track_video_raw_new (void)
{
GESTrack *track;
- GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb");
+ GstCaps *caps = gst_caps_new_empty_simple ("video/x-raw");
track = ges_track_new (GES_TRACK_TYPE_VIDEO, caps);
* ges_track_audio_raw_new:
*
* Creates a new #GESTrack of type #GES_TRACK_TYPE_AUDIO and with generic
- * raw audio caps ("audio/x-raw-int;audio/x-raw-float");
+ * raw audio caps ("audio/x-raw");
*
* Returns: A new #GESTrack.
*/
ges_track_audio_raw_new (void)
{
GESTrack *track;
- GstCaps *caps = gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
+ GstCaps *caps = gst_caps_new_empty_simple ("audio/x-raw");
track = ges_track_new (GES_TRACK_TYPE_AUDIO, caps);
*
*/
-#include "gesmarshal.h"
#include "ges-internal.h"
#include "ges-timeline.h"
#include "ges-track.h"
*/
#include <ges/ges.h>
-#include <gst/controller/gstcontroller.h>
#include "ges-internal.h"
#define GES_GNONLIN_VERSION_NEEDED_MAJOR 0
ges_check_gnonlin_availability (void)
{
gboolean ret = TRUE;
- if (!gst_default_registry_check_feature_version ("gnlcomposition",
- GES_GNONLIN_VERSION_NEEDED_MAJOR, GES_GNONLIN_VERSION_NEEDED_MINOR,
- GES_GNONLIN_VERSION_NEEDED_MICRO)) {
- GST_ERROR
- ("GNonLin plugins not found, or not at least version %u.%u.%u",
- GES_GNONLIN_VERSION_NEEDED_MAJOR,
- GES_GNONLIN_VERSION_NEEDED_MINOR, GES_GNONLIN_VERSION_NEEDED_MICRO);
+ if (!gst_registry_check_feature_version (gst_registry_get (),
+ "gnlcomposition", GES_GNONLIN_VERSION_NEEDED_MAJOR,
+ GES_GNONLIN_VERSION_NEEDED_MINOR, GES_GNONLIN_VERSION_NEEDED_MICRO)) {
+ GST_ERROR ("GNonLin plugins not found, or not at least version %u.%u.%u",
+ GES_GNONLIN_VERSION_NEEDED_MAJOR, GES_GNONLIN_VERSION_NEEDED_MINOR,
+ GES_GNONLIN_VERSION_NEEDED_MICRO);
ret = FALSE;
}
return ret;
/* initialize debugging category */
GST_DEBUG_CATEGORY_INIT (_ges_debug, "ges", GST_DEBUG_FG_YELLOW,
"GStreamer Editing Services");
- gst_controller_init (NULL, NULL);
/* register timeline object classes with the system */
-%define majorminor @GST_MAJORMINOR@
+%define majorminor @GST_API_VERSION@
%define gstreamer gstreamer
-%define gst_minver 0.10.0
+%define gst_minver 0.11.0
Name: %{gstreamer}-editing-services
Version: @VERSION@
Release: @PACKAGE_VERSION_RELEASE@.gst
Summary: GStreamer helper library for editing applications
-%define majorminor @GST_MAJORMINOR@
+%define majorminor @GST_API_VERSION@
Group: Applications/Multimedia
License: LGPL
pcfiles = \
- gst-editing-services-@GST_MAJORMINOR@.pc
+ gst-editing-services-@GST_API_VERSION@.pc
pcfiles_uninstalled = \
- gst-editing-services-@GST_MAJORMINOR@-uninstalled.pc
+ gst-editing-services-@GST_API_VERSION@-uninstalled.pc
all-local: $(pcfiles) $(pcfiles_uninstalled)
### how to generate pc files
-%-@GST_MAJORMINOR@.pc: %.pc
+%-@GST_API_VERSION@.pc: %.pc
cp $< $@
-%-@GST_MAJORMINOR@-uninstalled.pc: %-uninstalled.pc
+%-@GST_API_VERSION@-uninstalled.pc: %-uninstalled.pc
cp $< $@
pkgconfigdir = $(libdir)/pkgconfig
Name: gst-editing-services
Description: GStreamer Editing Services
Version: @VERSION@
-Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@ gstreamer-controller-@GST_MAJORMINOR@ gstreamer-pbutils-@GST_MAJORMINOR@
-Libs: @abs_top_builddir@/ges/libges-@GST_MAJORMINOR@.la
+Requires: gstreamer-@GST_API_VERSION@ gstreamer-base-@GST_API_VERSION@ gstreamer-controller-@GST_API_VERSION@ gstreamer-pbutils-@GST_API_VERSION@
+Libs: @abs_top_builddir@/ges/libges-@GST_API_VERSION@.la
Cflags: -I@abs_top_srcdir@ -I@abs_top_builddir@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
-includedir=@includedir@/gstreamer-@GST_MAJORMINOR@
+includedir=@includedir@/gstreamer-@GST_API_VERSION@
Name: gst-editing-services
Description: GStreamer Editing Services
Version: @VERSION@
-Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@ gstreamer-controller-@GST_MAJORMINOR@ gstreamer-pbutils-@GST_MAJORMINOR@
-Libs: -L${libdir} -lges-@GST_MAJORMINOR@
+Requires: gstreamer-@GST_API_VERSION@ gstreamer-base-@GST_API_VERSION@ gstreamer-controller-@GST_API_VERSION@ gstreamer-pbutils-@GST_API_VERSION@
+Libs: -L${libdir} -lges-@GST_API_VERSION@
Cflags: -I${includedir}
TESTS_ENVIRONMENT =
-plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
+plugindir = $(libdir)/gstreamer-@GST_API_VERSION@
# override to _not_ install the test plugins
install-pluginLTLIBRARIES:
$(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) $(GST_CFLAGS) \
-UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
-LDADD = $(top_builddir)/ges/libges-@GST_MAJORMINOR@.la \
- $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_MAJORMINOR) \
+LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la \
+ $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_API_VERSION) \
$(GST_OBJ_LIBS) $(GST_CHECK_LIBS)
EXTRA_DIST = #gst-plugins-bad.supp
fail_unless (color_aging == FALSE);
pspecs = ges_track_object_list_children_properties (tck_effect, &n_props);
- fail_unless (n_props == 6);
+ fail_unless (n_props == 7);
spec = pspecs[0];
i = 1;
#include <unistd.h>
#define GetCurrentDir getcwd
+#include <gst/audio/audio.h>
+
#define KEY_FILE_START {\
if (cmp) g_key_file_free (cmp);\
cmp = g_key_file_new ();\
KEY_FILE_START;
KEY ("General", "version", "1");
KEY ("Track0", "type", "GES_TRACK_TYPE_AUDIO");
- KEY ("Track0", "caps", "audio/x-raw-int; audio/x-raw-float");
+ KEY ("Track0", "caps", "audio/x-raw");
KEY ("Layer0", "priority", "0");
KEY ("Layer0", "type", "simple");
COMPARE;
* information about the source line where the failing object was created.
*/
-#define CMP_FAIL(obj, ...) \
-{\
- gchar *file, *func;\
- guint line;\
- file = g_object_get_data (G_OBJECT(obj), "file");\
- func = g_object_get_data (G_OBJECT(obj), "function");\
- line = GPOINTER_TO_UINT(g_object_get_data (G_OBJECT(obj), "line"));\
- gst_debug_log (GST_CAT_DEFAULT, GST_LEVEL_ERROR, file, func,\
- line, G_OBJECT(obj), __VA_ARGS__);\
-}
+#define CMP_FAIL(a, ...) \
+ fail_unless (FALSE, __VA_ARGS__);
/* compare two GObjects for equality. pointer identity and GType short-circuit
* the comparison. If a and b are not identical pointers and of the same
/* ignore name and layer properties */
if (!g_strcmp0 ("name", (*iter)->name) ||
- !g_strcmp0 ("layer", (*iter)->name))
+ !g_strcmp0 ("layer", (*iter)->name) ||
+ !g_strcmp0 ("parent", (*iter)->name))
continue;
/* special case caps property */
g_object_get_property (b, (*iter)->name, &bv);
if (g_param_values_cmp (*iter, &av, &bv) != 0) {
- const gchar *a_str, *b_str;
+ gchar *a_str, *b_str;
a_str = gst_value_serialize (&av);
b_str = gst_value_serialize (&bv);
CMP_FAIL (b, "%s's %p and %p differ by property %s (%s != %s)",
typename, a, b, (*iter)->name, a_str, b_str);
+ g_free (a_str);
+ g_free (b_str);
+
goto fail;
}
static const gchar *data = "\n[General]\n"
"[Track0]\n"
"type=GES_TRACK_TYPE_AUDIO\n"
- "caps=audio/x-raw-int; audio/x-raw-float\n"
+ "caps=audio/x-raw\n"
"\n"
"[Layer0]\n"
"priority=0\n"
TIMELINE_BEGIN (expected) {
- TRACK (GES_TRACK_TYPE_AUDIO, "audio/x-raw-float; audio/x-raw-int");
+ TRACK (GES_TRACK_TYPE_AUDIO, "audio/x-raw");
SIMPLE_LAYER_BEGIN (0) {
TIMELINE_BEGIN (orig) {
- TRACK (GES_TRACK_TYPE_AUDIO, "audio/x-raw-int,width=32,rate=8000");
- TRACK (GES_TRACK_TYPE_VIDEO, "video/x-raw-rgb");
+ TRACK (GES_TRACK_TYPE_AUDIO, "audio/x-raw,"
+ "format=(string)" GST_AUDIO_NE (S32) ",rate=8000");
+ TRACK (GES_TRACK_TYPE_VIDEO, "video/x-raw,format=(string)RGB24");
LAYER_BEGIN (5) {
timeline = ges_timeline_new ();
layer = (GESTimelineLayer *) ges_simple_timeline_layer_new ();
fail_unless (ges_timeline_add_layer (timeline, layer));
- track = ges_track_new (GES_TRACK_TYPE_CUSTOM, GST_CAPS_ANY);
+ track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_new_any ());
fail_unless (ges_timeline_add_track (timeline, track));
g_signal_connect (G_OBJECT (layer), "object-moved", G_CALLBACK
(object_moved_cb), &info);
fail_unless (ges_timeline_add_layer (timeline, layer));
ges_timeline_layer_set_priority (layer, 0);
- track = ges_track_new (GES_TRACK_TYPE_VIDEO, GST_CAPS_ANY);
+ track = ges_track_new (GES_TRACK_TYPE_VIDEO, gst_caps_new_any ());
fail_unless (ges_timeline_add_track (timeline, track));
- track = ges_track_new (GES_TRACK_TYPE_AUDIO, GST_CAPS_ANY);
+ track = ges_track_new (GES_TRACK_TYPE_AUDIO, gst_caps_new_any ());
fail_unless (ges_timeline_add_track (timeline, track));
$(graphical)
AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS) -export-dynamic
-LDADD = $(top_builddir)/ges/libges-@GST_MAJORMINOR@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GTK_LIBS)
+LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GTK_LIBS)
App *app;
/* intialize GStreamer and GES */
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
gst_init (&argc, &argv);
ges_init ();
{NULL}
};
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
ctx = g_option_context_new ("- file segment playback with text overlay");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
{NULL}
};
- /* Initialization and option parsing */
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
ctx =
g_option_context_new
("- Plays an video file with sound (origin/muted/replaced)");
{NULL}
};
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
ctx = g_option_context_new ("- transition between two media files");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
static gboolean
thumbnail_cb (gpointer user)
{
- GstBuffer *b = NULL;
+ GstSample *b = NULL;
GstCaps *caps;
GESTimelinePipeline *p;
/* check raw rgb use-case with scaling */
b = ges_timeline_pipeline_get_thumbnail_rgb24 (p, 320, 240);
g_assert (b);
- gst_buffer_unref (b);
+ gst_sample_unref (b);
/* check encoding use-case from caps */
b = NULL;
- b = ges_timeline_pipeline_get_thumbnail_buffer (p, caps);
+ b = ges_timeline_pipeline_get_thumbnail (p, caps);
g_assert (b);
- gst_buffer_unref (b);
+ gst_sample_unref (b);
g_assert (ges_timeline_pipeline_save_thumbnail (p, -1, -1, (gchar *)
"image/jpeg", (gchar *) TEST_PATH));
GMainLoop *mainloop;
GstBus *bus;
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
ctx = g_option_context_new ("tests thumbnail supoprt (produces no output)");
g_option_context_set_summary (ctx, "");
g_option_context_add_main_entries (ctx, options, NULL);
{NULL}
};
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
ctx = g_option_context_new ("- transition between two media files");
g_option_context_set_summary (ctx,
"Select two files, and optionally a transition duration and type.\n"
ges-launch
-ges-launch-0.10
+ges-launch-0.11
-bin_PROGRAMS = ges-launch-@GST_MAJORMINOR@
+bin_PROGRAMS = ges-launch-@GST_API_VERSION@
AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS)
-LDADD = $(top_builddir)/ges/libges-@GST_MAJORMINOR@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GIO_LIBS)
+LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GIO_LIBS)
-ges_launch_@GST_MAJORMINOR@_SOURCES = ges-launch.c
+ges_launch_@GST_API_VERSION@_SOURCES = ges-launch.c
Android.mk: Makefile.am $(BUILT_SOURCES)
androgenizer \
-:PROJECT ges_launch -:EXECUTABLE ges-launch \
-:TAGS eng \
-:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
- -:SOURCES $(ges_launch_@GST_MAJORMINOR@_SOURCES) \
+ -:SOURCES $(ges_launch_@GST_API_VERSION@_SOURCES) \
-:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(AM_CFLAGS) \
- -:LDFLAGS -lges-@GST_MAJORMINOR@ $(GST_PBUTILS_LIBS) $(GST_LIBS) \
+ -:LDFLAGS -lges-@GST_API_VERSION@ $(GST_PBUTILS_LIBS) $(GST_LIBS) \
-:PASSTHROUGH LOCAL_ARM_MODE:=arm \
> $@
GMainLoop *mainloop;
GstBus *bus;
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
ctx = g_option_context_new ("- plays or renders a timeline.");
g_option_context_set_summary (ctx,
"ges-launch renders a timeline, which can be specified on the commandline,\n"