with wrap(['/usr/include/xosd.h'], output='xosd.py', library='xosd') as w: w.add_pointer_class_wrappers( ('xosd', 'XOSD'), ) w.add_init_redirect('XOSD', 'XOSD.create') meth = w.get_pyclass('XOSD').new_method('get_colour') meth.code.extend(transform(\ """r, g, b = c_int(), c_int(), c_int() xosd_get_colour(self._internal, byref(r), byref(g), byref(b)) return (r.value, g.value, b.value) """)) w.add_rules( regex_method('xosd_(.*)', 'XOSD'), regex_match('xosd_init', succeed), regex_match('xosd_get_colour', succeed), regex_classmethod('xosd_(create)', 'XOSD'), ) w.add_wrappers_visitor(make_properties) w.add_synonyms( ('XOSD_(.*)', r'\1') )
w.add_rules( regex_match(r'(pango_cairo_.*)', function), regex_method(r'pango_context_(.*)', 'Context'), regex_classmethod(r'pango_context_(new)', 'Context'), regex_method(r'pango_layout_(.*)', 'Layout'), regex_match(r'pango_layout_get_size', succeed), # separatedly wrapped regex_classmethod(r'pango_layout_(new)', 'Layout'), regex_method(r'pango_font_description_(.*)', 'FontDescription'), regex_classmethod(r'pango_font_description_(new|from_string)$', 'FontDescription'), regex_method(r'pango_font_map_(.*)', 'FontMap'), regex_method(r'pango_cairo_font_map_(.*)', 'CairoFontMap'), regex_classmethod(r'pango_cairo_font_map_(new|new_for_font_type)$', 'CairoFontMap'), ) w.add_wrappers_visitor(make_properties) w.add_synonyms( (r'PANGO_(.*)$', r'\1'), (r'pango_(.*)$', r'\1'), ) meth = w.get_pyclass('Layout').new_method('get_size') meth.code.extend(transform( """width, height = c_int(), c_int() pango_layout_get_size(self._internal, byref(width), byref(height)) return (width.value, height.value) """))