From b01b9197c789663be042484c52d361380513d836 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 9 May 2006 13:13:48 +0000 Subject: [PATCH] codegen/: Added code to ignore type and the function/methods/classes that use them. Original commit message from CVS: * codegen/codegen.py: * codegen/override.py: Added code to ignore type and the function/methods/classes that use them. * gst/gst.override: ignore methods/classes/types depending on how GStreamer core was built: _ GST_DISABLE_GST_DEBUG _ GST_DISABLE_LOADSAVE _ GST_DISABLE_PARSE --- ChangeLog | 12 ++++++++++++ codegen/codegen.py | 14 ++++++++++---- codegen/override.py | 11 +++++++++++ gst/gst.override | 19 ++++++++++++++++++- 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d97b46241e..2144696428 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-05-09 Edward Hervey + + * codegen/codegen.py: + * codegen/override.py: + Added code to ignore type and the function/methods/classes that use + them. + * gst/gst.override: + ignore methods/classes/types depending on how GStreamer core was built: + _ GST_DISABLE_GST_DEBUG + _ GST_DISABLE_LOADSAVE + _ GST_DISABLE_PARSE + 2006-05-09 Edward Hervey * testsuite/python.supp: diff --git a/codegen/codegen.py b/codegen/codegen.py index 3ffc547e49..7cc5bb43c7 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -220,6 +220,8 @@ class Wrapper: return { 'name': '%s.%s' % (self.objinfo.c_name, method.name) } def write_class(self): + if self.overrides.is_type_ignored(self.objinfo.c_name): + return self.fp.write('\n/* ----------- ' + self.objinfo.c_name + ' ----------- */\n\n') substdict = self.get_initial_class_substdict() if not substdict.has_key('tp_flags'): @@ -1081,12 +1083,14 @@ def write_classes(parser, overrides, fp): instance.write_class() fp.write('\n') -def write_enums(parser, prefix, fp=sys.stdout): +def write_enums(parser, overrides, prefix, fp=sys.stdout): if not parser.enums: return fp.write('\n/* ----------- enums and flags ----------- */\n\n') fp.write('void\n' + prefix + '_add_constants(PyObject *module, const gchar *strip_prefix)\n{\n') for enum in parser.enums: + if overrides.is_type_ignored(enum.c_name): + continue if enum.typecode is None: for nick, value in enum.values: fp.write(' PyModule_AddIntConstant(module, pyg_constant_strip_prefix("%s", strip_prefix), %s);\n' @@ -1131,7 +1135,7 @@ def write_extension_init(overrides, prefix, fp): fp.write(overrides.get_init() + '\n') fp.resetline() -def write_registers(parser, fp): +def write_registers(parser, overrides, fp): for boxed in parser.boxes: fp.write(' pyg_register_boxed(d, "' + boxed.name + '", ' + boxed.typecode + ', &Py' + boxed.c_name + '_Type);\n') @@ -1158,6 +1162,8 @@ def write_registers(parser, fp): else: pos = pos + 1 for obj in objects: + if overrides.is_type_ignored(obj.c_name): + continue bases = [] if obj.parent != None: bases.append(obj.parent) @@ -1204,9 +1210,9 @@ def write_source(parser, overrides, prefix, fp=FileOutput(sys.stdout)): wrapper = Wrapper(parser, None, overrides, fp) wrapper.write_functions(prefix) - write_enums(parser, prefix, fp) + write_enums(parser, overrides, prefix, fp) write_extension_init(overrides, prefix, fp) - write_registers(parser, fp) + write_registers(parser, overrides, fp) def register_types(parser): for boxed in parser.boxes: diff --git a/codegen/override.py b/codegen/override.py index f3712f6acf..5b5963261a 100644 --- a/codegen/override.py +++ b/codegen/override.py @@ -26,6 +26,7 @@ class Overrides: self.modulename = None self.ignores = {} self.glob_ignores = [] + self.type_ignores = {} self.overrides = {} self.overridden = {} self.kwargs = {} @@ -109,6 +110,13 @@ class Overrides: 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]" func = words[1] @@ -180,6 +188,9 @@ class Overrides: 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) diff --git a/gst/gst.override b/gst/gst.override index 41486d7d7f..a4a73a37df 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -204,6 +204,7 @@ static PyObject * pygst_debug_log (PyObject *pyobject, PyObject *string, GstDebugLevel level, gboolean isgstobject) { +#ifndef GST_DISABLE_GST_DEBUG gchar *str; gchar *function; gchar *filename; @@ -227,6 +228,7 @@ pygst_debug_log (PyObject *pyobject, PyObject *string, GstDebugLevel level, if (filename) g_free(filename); Py_INCREF (Py_None); +#endif return Py_None; } @@ -308,12 +310,27 @@ ignore gst_plugin_get_module gst_object_sink gst_version +#ifdef GST_DISABLE_LOADSAVE +%% +ignore-glob + gst_xml_* +%% +ignore-type + GstXML +#endif +#ifdef GST_DISABLE_PARSE +%% +ignore-glob + gst_parse_* +%% +ignore-type + GstParseError +#endif %% /* Magic to be able to use bugfixes of new releases without having to use newer core/base */ -#warn your mom ! ignore #if (GST_VERSION_MICRO < 5) # if (GST_VERSION_MICRO < 4)