This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 1a93c45d484a05a1e5e8ca1cf1a0046e10d3398d (commit) via da7cdf406b3451c27801c4ba68ac29aa1891a209 (commit) via 312c163a2316d0fa6c514fc0950d4bb788dee1b0 (commit) via 8ef914015870e89225900ea789da4f5741c444b4 (commit) via 90e74e126ba3bba072eea0456d5c3823a4617821 (commit) via a6c7bce8c64deb55ce270f8e40435de0ef08ca3f (commit) via 1606dfcb1db856a2e8f23bcb137c9a5b99310d06 (commit) via 0072fbd406ab3fca61423ffe37672ac9091912f3 (commit) from b1fbf0820773aebe6c2c0d79d5ea71417e3ec754 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/1a93c45d484a05a1e5e8ca1cf1a0046e10d33...
commit 1a93c45d484a05a1e5e8ca1cf1a0046e10d3398d Merge: da7cdf4 b1fbf08 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jan 28 09:05:18 2013 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/da7cdf406b3451c27801c4ba68ac29aa1891a...
commit da7cdf406b3451c27801c4ba68ac29aa1891a209 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 16:58:06 2013 +0100
pylib: tests: Clean up gfx tests
diff --git a/tests/pylib/test_gfx.py b/tests/pylib/test_gfx.py index 87289f9..e502e22 100644 --- a/tests/pylib/test_gfx.py +++ b/tests/pylib/test_gfx.py @@ -22,31 +22,31 @@ def test_gfx_submodule_has_C():
# These set the param types of the functions in GFX gfx_params = { - 'ArcSegment': 'CCCCCFFP', - 'Circle': 'CCCP', - 'Ellipse': 'CCCCP', + 'ArcSegment': 'IIIIIFFP', + 'Circle': 'IIIP', + 'Ellipse': 'IIIIP', 'Fill': 'P', - 'FillCircle': 'CCCP', - 'FillEllipse': 'CCCCP', + 'FillCircle': 'IIIP', + 'FillEllipse': 'IIIIP', 'FillPolygon': None, - 'FillRect': 'CCCCP', + 'FillRect': 'IIIIP', 'FillRect_AA': 'FFFFP', - 'FillRing': 'CCCCP', - 'FillSymbol': '0CCCCP', - 'FillTetragon': 'CCCCCCCCP', - 'FillTriangle': 'CCCCCCP', - 'HLine': 'CCCP', + 'FillRing': 'IIIIP', + 'FillSymbol': '0IIIIP', + 'FillTetragon': 'IIIIIIIIP', + 'FillTriangle': 'IIIIIIP', + 'HLine': 'IIIP', 'HLineAA': 'FFFP', - 'Line': 'CCCCP', + 'Line': 'IIIIP', 'LineAA': 'FFFFP', 'Polygon': None, 'PutPixelAA': 'FFP', - 'Rect': 'CCCCP', - 'Ring': 'CCCCP', - 'Symbol': '0CCCCP', - 'Tetragon': 'CCCCCCCCP', - 'Triangle': 'CCCCCCP', - 'VLine': 'CCCP', + 'Rect': 'IIIIP', + 'Ring': 'IIIIP', + 'Symbol': '0IIIIP', + 'Tetragon': 'IIIIIIIIP', + 'Triangle': 'IIIIIIP', + 'VLine': 'IIIP', 'VLineAA': 'FFFP', }
@@ -58,23 +58,35 @@ def test_all_methods_are_known(): if name[0] != '_' and name not in ['C', 'ctx']: assert name in gfx_params
+def gen_dummy_args(params): + """ + Generate dummy parameter tuple according to characters in the given string.
-@for_each_case(gfx_params, _filter=(lambda(n, params): params is not None)) -def test_method_callable(n, params): - "Call with dummy parameters" - c = Context(10, 10, 1) + 0 - 0 + S - String ("") + I - Int (1) + F - Float (0.5) + P - Pixel (0) + """ args = [] for t in params: if t == '0': args.append(0) - elif t == 'C': + elif t == 'I': args.append(1) elif t == 'P': args.append(0) elif t == 'F': args.append(0.5) + elif t == 'S': + args.append("") else: assert False - print args - c.gfx.__getattribute__(n)(*tuple(args)) + return tuple(args) + +@for_each_case(gfx_params, _filter=(lambda(n, params): params is not None)) +def test_method_callable(n, params): + "Call with dummy parameters" + c = Context(10, 10, 1) + c.gfx.__getattribute__(n)(*gen_dummy_args(params))
http://repo.or.cz/w/gfxprim.git/commit/312c163a2316d0fa6c514fc0950d4bb788dee...
commit 312c163a2316d0fa6c514fc0950d4bb788dee1b0 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 15:23:23 2013 +0100
pylib: tests: Unit tests for gfx submodule
diff --git a/tests/pylib/test_gfx.py b/tests/pylib/test_gfx.py new file mode 100644 index 0000000..87289f9 --- /dev/null +++ b/tests/pylib/test_gfx.py @@ -0,0 +1,80 @@ +"core.Context tests" + +from unittest import SkipTest +from testutils import * + +from gfxprim.core import Context +from gfxprim import gfx + + +def test_gfx_submodule_loads(): + "gfx is present in a Context" + c = Context(1, 1, 1) + assert c.gfx + + +def test_gfx_submodule_has_C(): + "gfx contains C" + c = Context(1, 1, 1) + assert c.gfx.C + assert gfx.C + + +# These set the param types of the functions in GFX +gfx_params = { + 'ArcSegment': 'CCCCCFFP', + 'Circle': 'CCCP', + 'Ellipse': 'CCCCP', + 'Fill': 'P', + 'FillCircle': 'CCCP', + 'FillEllipse': 'CCCCP', + 'FillPolygon': None, + 'FillRect': 'CCCCP', + 'FillRect_AA': 'FFFFP', + 'FillRing': 'CCCCP', + 'FillSymbol': '0CCCCP', + 'FillTetragon': 'CCCCCCCCP', + 'FillTriangle': 'CCCCCCP', + 'HLine': 'CCCP', + 'HLineAA': 'FFFP', + 'Line': 'CCCCP', + 'LineAA': 'FFFFP', + 'Polygon': None, + 'PutPixelAA': 'FFP', + 'Rect': 'CCCCP', + 'Ring': 'CCCCP', + 'Symbol': '0CCCCP', + 'Tetragon': 'CCCCCCCCP', + 'Triangle': 'CCCCCCP', + 'VLine': 'CCCP', + 'VLineAA': 'FFFP', + } + + +def test_all_methods_are_known(): + "All methods of gfx submodule have known param types in this test" + c = Context(1, 1, 1) + for name in dir(c.gfx): + if name[0] != '_' and name not in ['C', 'ctx']: + assert name in gfx_params + + +@for_each_case(gfx_params, _filter=(lambda(n, params): params is not None)) +def test_method_callable(n, params): + "Call with dummy parameters" + c = Context(10, 10, 1) + args = [] + for t in params: + if t == '0': + args.append(0) + elif t == 'C': + args.append(1) + elif t == 'P': + args.append(0) + elif t == 'F': + args.append(0.5) + else: + assert False + print args + c.gfx.__getattribute__(n)(*tuple(args)) +
http://repo.or.cz/w/gfxprim.git/commit/8ef914015870e89225900ea789da4f5741c44...
commit 8ef914015870e89225900ea789da4f5741c444b4 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 15:13:24 2013 +0100
pylib: test: Remove old @alltypes implementations
diff --git a/tests/pylib/testutils.py b/tests/pylib/testutils.py index e0ded8d..6c7ee5f 100644 --- a/tests/pylib/testutils.py +++ b/tests/pylib/testutils.py @@ -8,35 +8,6 @@ __all__ = ["alltypes", "for_each_case", "RandomizeContext", "ContextRand"]
-def alltypes_generator(_filter=None): - def decorate(f): - def gen(): - for t in core.PixelTypes[1:]: - if (_filter is None) or _filter(t): - yield f, t - gen.__name__ = f.__name__ - return gen - return decorate - - -def alltypes_new_functions(_filter=None): - def decorate(f): - for t in core.PixelTypes[1:]: - if (_filter is None) or _filter(t): - nf = (lambda tt: (lambda: f(tt)))(t) - nf.__name__ = f.__name__ + "_" + t.name - nf.__module__ = f.__module__ - nf.__doc__ = "%s<%s:%s>"% ( - f.__doc__ + " " if f.__doc__ else "", - nf.__module__, nf.__name__) - f.__globals__[nf.__name__] = nf - return None - return decorate - -# Switch to alltypes_new_functions by default -#alltypes = alltypes_new_functions - - def alltypes(_filter=None): """ Creates one test for each PixelType (except INVALID). @@ -87,6 +58,7 @@ def ContextRand(w, h, t, seed=None): RandomizeContext(c, seed) return c
+ def RandomizeContext(c, seed=None): """Fill Context with pseudorandom data.
http://repo.or.cz/w/gfxprim.git/commit/90e74e126ba3bba072eea0456d5c3823a4617...
commit 90e74e126ba3bba072eea0456d5c3823a4617821 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 15:12:02 2013 +0100
pylib: test: Add universal test generator, use for @alltypes
diff --git a/tests/pylib/testutils.py b/tests/pylib/testutils.py index 8c0b6fe..e0ded8d 100644 --- a/tests/pylib/testutils.py +++ b/tests/pylib/testutils.py @@ -4,7 +4,8 @@ from random import Random
from gfxprim import core
-__all__ = ["alltypes", "RandomizeContext", "ContextRand"] +__all__ = ["alltypes", "for_each_case", + "RandomizeContext", "ContextRand"]
def alltypes_generator(_filter=None): @@ -32,9 +33,51 @@ def alltypes_new_functions(_filter=None): return None return decorate
- # Switch to alltypes_new_functions by default -alltypes = alltypes_new_functions +#alltypes = alltypes_new_functions + + +def alltypes(_filter=None): + """ + Creates one test for each PixelType (except INVALID). + The pixeltype is given to the test function and the name + is appended to its name and docstring. + """ + flt = lambda n, t: _filter(t) + return for_each_case(dict([(t.name, t) for t in core.PixelTypes[1:]]), + givename=False, _filter=(flt if _filter else None)) + + +def for_each_case(cases, givename=True, _filter=None): + """ + Creates one test for each of `cases`. + + Cases is either list of strings or or string dict (with any values). + The test is then given (name) for list or (name, value) for dict, + or just (value) if givename=False. + + Optional _filter is called with (name) or (name, value) for dict to + determine which values to use (ret. True -> include). + """ + def decorate(f): + for n in cases: + assert isinstance(n, str) + if isinstance(cases, dict): + if givename: + nf = (lambda nn, nv: (lambda: f(nn, nv)))(n, cases[n]) + else: + nf = (lambda nv: (lambda: f(nv)))(cases[n]) + else: # assume a list or a tuple + nf = (lambda nn: (lambda: f(nn)))(n) + nf.__name__ = f.__name__ + "_" + n + nf.__module__ = f.__module__ + nf.__doc__ = "%s<%s:%s>"% ( + f.__doc__ + " " if f.__doc__ else "", + nf.__module__, nf.__name__) + f.__globals__[nf.__name__] = nf + return None + return decorate +
### core.Context helpers
http://repo.or.cz/w/gfxprim.git/commit/a6c7bce8c64deb55ce270f8e40435de0ef08c...
commit a6c7bce8c64deb55ce270f8e40435de0ef08ca3f Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 13:32:49 2013 +0100
pywrap: gfx: Submodule bindings for gfxprim.gfx
diff --git a/pylib/gfxprim/gfx/__init__.py b/pylib/gfxprim/gfx/__init__.py index c80ae6a..62ce4f0 100644 --- a/pylib/gfxprim/gfx/__init__.py +++ b/pylib/gfxprim/gfx/__init__.py @@ -1,27 +1,53 @@ -from . import gfx_c +""" +Module extending the Context class with .gfx submodule and its drawing functions. + +Use as in "import gfxprim.gfx; context_foo.gfx.Line(...)" +""" + +# Import the SWIG wrapper + +from . import c_gfx + + +# Constants module
from . import C
+ def _init(module): + "Extend Context with gfx submodule"
+ from ..utils import extend, add_swig_getmethod, add_swig_setmethod + from ..core import Context as _context + + # New Context submodule + + class GfxSubmodule(object): + def __init__(self, ctx): + self.ctx = ctx + self.C = C + + _context._submodules['gfx'] = GfxSubmodule
# Imports from the SWIG module + from ..utils import import_members, extend_submodule import re def strip_GP(s): return re.sub('^GP_', '', s)
- # Import constants from the SWIG module - from ..utils import import_members - const_regexes = ['^GP_[A-Z0-9_]*$'] - import_members(gfx_c, C, include=const_regexes, sub=strip_GP) - - # Import functions from the SWIG module - import_members(gfx_c, module, sub=strip_GP, - exclude=const_regexes + [ - '.*_Raw', - '^w+_swigregister$', - '^gfxprim$', - '^_w+$']) + const_regexes = [ + '^GP_[A-Z0-9_]*$', + ] + import_members(c_gfx, C, include=const_regexes, sub=strip_GP) + + for name in [ + 'ArcSegment', 'Circle', 'Ellipse', 'Fill', 'FillCircle', 'FillEllipse', + 'FillPolygon', 'FillRect', 'FillRect_AA', 'FillRing', 'FillSymbol', + 'FillTetragon', 'FillTriangle', 'HLine', 'HLineAA', 'Line', 'LineAA', + 'Polygon', 'PutPixelAA', 'Rect', 'Ring', 'Symbol', 'Tetragon', + 'Triangle', 'VLine', 'VLineAA']: + extend_submodule(GfxSubmodule, name, c_gfx.__getattribute__('GP_' + name)) +
_init(locals()) del _init diff --git a/pylib/gfxprim/gfx/gfx.i b/pylib/gfxprim/gfx/gfx.i index eb684da..881d2ca 100644 --- a/pylib/gfxprim/gfx/gfx.i +++ b/pylib/gfxprim/gfx/gfx.i @@ -1,5 +1,5 @@ %include "../common.i" -%module(package="gfxprim.gfx") gfx_c +%module(package="gfxprim.gfx") c_gfx
%{ #include "gfx/GP_Gfx.h"
http://repo.or.cz/w/gfxprim.git/commit/1606dfcb1db856a2e8f23bcb137c9a5b99310...
commit 1606dfcb1db856a2e8f23bcb137c9a5b99310d06 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 13:31:38 2013 +0100
pywrap: Add submodule extending method, improve existing
diff --git a/pylib/gfxprim/utils.py b/pylib/gfxprim/utils.py index 5dc6dab..4040a25 100644 --- a/pylib/gfxprim/utils.py +++ b/pylib/gfxprim/utils.py @@ -13,17 +13,34 @@ def extend(cls, name=None): return decf
-def extend_direct(cls, name, call, doc, swig_doc=True): - "Decorator extending a class with a function" +def extend_direct(cls, name, call, doc=None, swig_doc=True): + "Extend a class with a function. The first arg will be `self`." def method(*args, **kwargs): return call(*args, **kwargs) method.__name__ = name - method.__doc__ = doc.strip() + 'n' + if doc: + method.__doc__ = doc.strip() + 'n' + else: + method.__doc__ = "" if swig_doc: - method.__doc__ = call.__doc__ + 'nn' + doc.strip() + 'n' + method.__doc__ = call.__doc__ + 'nn' + method.__doc__ type.__setattr__(cls, name, method)
+def extend_submodule(module, name, call, doc=None, swig_doc=True): + "Extending a submodule with a function. The first arg will be `self.ctx`." + def method(self, *args, **kwargs): + return call(self.ctx, *args, **kwargs) + method.__name__ = name + if doc: + method.__doc__ = doc.strip() + 'n' + else: + method.__doc__ = "" + if swig_doc: + method.__doc__ = call.__doc__ + 'nn' + method.__doc__ + type.__setattr__(module, name, method) + + def add_swig_getmethod(cls, name=None): "Decorator to add a property get method to a SWIG-defined class" def decf(method):
http://repo.or.cz/w/gfxprim.git/commit/0072fbd406ab3fca61423ffe37672ac909191...
commit 0072fbd406ab3fca61423ffe37672ac9091912f3 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jan 27 13:31:07 2013 +0100
pywrap: Fix a typo
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index f9db954..9ad8eea 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -29,7 +29,7 @@ def _init(module):
_ptdescr = c_core.GP_PixelTypeDescription
- # String representation of + # String representation of a Context
@extend(_ptdescr, name='__str__') @extend(_ptdescr, name='__repr__')
-----------------------------------------------------------------------
Summary of changes: pylib/gfxprim/core/__init__.py | 2 +- pylib/gfxprim/gfx/__init__.py | 52 +++++++++++++++++------ pylib/gfxprim/gfx/gfx.i | 2 +- pylib/gfxprim/utils.py | 25 +++++++++-- tests/pylib/test_gfx.py | 92 ++++++++++++++++++++++++++++++++++++++++ tests/pylib/testutils.py | 61 ++++++++++++++++---------- 6 files changed, 192 insertions(+), 42 deletions(-) create mode 100644 tests/pylib/test_gfx.py
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.