from __future__ import with_statement
-import os
-from ctypes.util import find_library
-
from .ast import (Alias, Array, Bitfield, Callback, Class, Constant, Enum,
Function, Interface, List, Map, Member, Struct, Union,
Varargs)
self.write_tag('c:include', attrs)
def _write_namespace(self, namespace, shlibs, cprefix):
- libraries = []
- for l in shlibs:
- found_libname = find_library(l)
- if not found_libname:
- found_libname = l
- libraries.append(os.path.basename(found_libname))
-
attrs = [('name', namespace.name),
('version', namespace.version),
- ('shared-library', ','.join(libraries)),
+ ('shared-library', ','.join(shlibs)),
('c:prefix', cprefix)]
with self.tagcontext('namespace', attrs):
# We define a custom sorting function here because
else:
return cmp(a, b)
for node in sorted(namespace.nodes, cmp=nscmp):
- self._write_node(node)
+ if not node.skip:
+ self._write_node(node)
def _write_node(self, node):
if isinstance(node, Function):
self.write_tag('alias', attrs)
def _write_callable(self, callable, tag_name, extra_attrs):
+ if callable.skip:
+ return
attrs = [('name', callable.name)]
attrs.extend(extra_attrs)
if callable.doc:
attrs.extend([('glib:type-name', enum.type_name),
('glib:get-type', enum.get_type),
('c:type', enum.ctype)])
- if enum.error_quark:
- attrs.append(('glib:error-quark', enum.error_quark))
else:
attrs.append(('c:type', enum.symbol))
+ if hasattr(enum, 'error_quark') and enum.error_quark:
+ attrs.append(('glib:error-quark', enum.error_quark))
with self.tagcontext('enumeration', attrs):
self._write_attributes(enum)
self._write_member(member)
def _write_member(self, member):
+ if member.skip:
+ return
attrs = [('name', member.name),
('value', str(member.value)),
('c:identifier', member.symbol)]
self._write_method(method)
def _write_property(self, prop):
+ if prop.skip:
+ return
attrs = [('name', prop.name)]
self._append_version(prop, attrs)
self._append_deprecated(prop, attrs)
('glib:get-type', boxed.get_type)]
def _write_record(self, record, extra_attrs=[]):
+ is_gtype_struct = False
attrs = list(extra_attrs)
if record.name is not None:
attrs.append(('name', record.name))
attrs.append(('disguised', '1'))
if isinstance(record, GLibRecord):
if record.is_gtype_struct_for:
+ is_gtype_struct = True
attrs.append(('glib:is-gtype-struct-for',
record.is_gtype_struct_for))
if record.doc:
self._write_attributes(record)
if record.fields:
for field in record.fields:
- self._write_field(field)
+ self._write_field(field, is_gtype_struct)
for method in record.constructors:
self._write_constructor(method)
for method in record.methods:
for method in union.methods:
self._write_method(method)
- def _write_field(self, field):
+ def _write_field(self, field, is_gtype_struct=False):
if isinstance(field, Function):
self._write_method(field)
return
if isinstance(field, Callback):
- self._write_callback(field)
+ attrs = [('name', field.name)]
+ with self.tagcontext('field', attrs):
+ self._write_attributes(field)
+ if is_gtype_struct:
+ self._write_callback(field)
+ else:
+ attrs = [('name', 'any'), ('c:type', 'pointer')]
+ self.write_tag('type', attrs)
elif isinstance(field, Struct):
self._write_record(field)
elif isinstance(field, Union):
self._write_type(field.type)
def _write_signal(self, signal):
+ if signal.skip:
+ return
attrs = [('name', signal.name)]
if signal.doc:
attrs.append(('doc', signal.doc))