Beispiel #1
0
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')
            )

Beispiel #2
0
    w.objects['ToyFontFace'].base = 'FontFace'
    w.objects['UserFontFace'].base = 'FontFace'
    w.objects['ImageSurface'].base = 'Surface'
    w.objects['XcbSurface'].base = 'Surface'

    w.add_init_redirects(
            ('Context', 'Context.create'),
            ('ImageSurface', 'ImageSurface.create'),
            )

    w.add_rules(
            argument_tag(
                0,
                'POINTER(cairo_t)',
                regex_method(r'cairo_(.*)', 'Context'),
                ),
            regex_classmethod(r'cairo_(create)', 'Context'),

            regex_method(r'cairo_path_(.*)', 'Path'),

            regex_method(r'cairo_pattern_(.*)', 'Pattern'),
            regex_classmethod(r'cairo_pattern_(create_rgb|create_rgba|create_for_surface|create_linear|create_radial)', 'Pattern'),

            # all other glyph functions scare me.
            regex_classmethod(r'cairo_glyph_(allocate)', 'Glyph'),

            regex_method(r'cairo_font_face_(.*)', 'FontFace'),
            
            regex_method(r'cairo_toy_font_face_(.*)', 'ToyFontFace'),
            regex_classmethod(r'cairo_toy_font_face_(create)', 'ToyFontFace'),
Beispiel #3
0
            ('PangoCairoFontMap', 'CairoFontMap'),
            )
    w.wrappers['POINTER(cairo_t)'] = DummyCodegen(name='cairo.Context') # <- hacky, to get pango_cairo_* working

    w.get_pyclass('CairoFontMap').base = 'FontMap'

    w.add_init_redirects(
            ('Context', 'Context.new'),
            ('Layout', 'Layout.new'),
            ('FontDescription', 'FontDescription.new'),
            ('CairoFontMap', 'CairoFontMap.new'),
            )

    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'),
            )