Exemple #1
0
import sys
sys.path.append('../..')

from wrapobjects.wrap import wrap
from wrapobjects.wraplib.codegen import transform
from wrapobjects.oo import regex_method, regex_classmethod, regex_match, succeed
from wrapobjects.properties import make_properties

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'),
            )
Exemple #2
0
import sys
sys.path.append('../..')

from wrapobjects.wrap import wrap
from wrapobjects.oo import regex_method, regex_classmethod, argument_tag
from wrapobjects.properties import make_properties

with wrap(
        ('/usr/include/cairo/cairo-xcb.h', '/usr/include/cairo/cairo.h'),
        output='cairo.py',
        link_modules=['ooxcb.libxcb'],
        library='cairo'
        ) as w:
    w.add_pointer_class_wrappers(
            ('cairo_t', 'Context'),
            ('cairo_path_t', 'Path'),
            ('cairo_pattern_t', 'Pattern'),
            ('cairo_font_face_t', 'FontFace'),
            ('cairo_scaled_font_t', 'ScaledFont'),
            ('cairo_font_options_t', 'FontOptions'),
            ('cairo_matrix_t', 'Matrix'),
            ('cairo_toy_font_face_t', 'ToyFontFace'),
            ('cairo_user_font_face_t', 'UserFontFace'),
            ('cairo_surface_t', 'Surface'),
            ('cairo_image_surface_t', 'ImageSurface'),
            ('cairo_xcb_surface_t', 'XcbSurface'),
            ('cairo_glyph_t', 'Glyph'),
            )

    w.objects['ToyFontFace'].base = 'FontFace'
    w.objects['UserFontFace'].base = 'FontFace'
Exemple #3
0
import sys
sys.path.append('../..')
sys.path.insert(0, '../cairo')

from wrapobjects.wrap import wrap
from wrapobjects.wraplib.codegen import transform, DummyCodegen
from wrapobjects.oo import regex_method, regex_classmethod, argument_tag, succeed, regex_match, function
from wrapobjects.properties import make_properties

with wrap(
        ['pango-new.h'],
        output='pango.py',
        link_modules=['cairo'],
        library='pangocairo-1.0') as w:

    w.add_pointer_class_wrappers(
            ('PangoContext', 'Context'),
            ('PangoLayout', 'Layout'),
            ('PangoFontDescription', 'FontDescription'),
            ('PangoFontMap', 'FontMap'),
            ('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'),