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, pywrap has been updated via 0aed5090e5722d19b06bf91f6652923b1127a2c9 (commit) via 96cff89699672066b2a8f18043d8455a46add474 (commit) via 41a2719db7086efe7c888a3acc2807295bcef640 (commit) via d6538118cb90b513bbe82c90f7aa5c23b051050b (commit) via 85343b9e91ec90b29ea7cd3b568376154bd2b3df (commit) via 39401ddcc823b061542a35fd3020a5de5cf182be (commit) from ed8672e72135a52839ca300b6e1253ae9cecad1a (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/0aed5090e5722d19b06bf91f6652923b1127a...
commit 0aed5090e5722d19b06bf91f6652923b1127a2c9 Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Feb 24 18:51:24 2012 +0100
pywrap: CamelCase the method names, strip GP_ prefix
diff --git a/pylib/gfxprim/backends/__init__.py b/pylib/gfxprim/backends/__init__.py index e050008..f33aa9b 100644 --- a/pylib/gfxprim/backends/__init__.py +++ b/pylib/gfxprim/backends/__init__.py @@ -1,7 +1,7 @@ """ Module wrapping GfxPrim backends.
-BIG FAT WARNING +BIG FAT WARNING --------------- Accessing a context after its backend has ben freed will probably end your (program's) world @@ -20,19 +20,20 @@ backends_c = import_backends_c_helper() del import_backends_c_helper
# Extend Context with convenience methods -from . import extend_context -from ..core import Context -extend_context.extend_context_class(Context) -del Context -del extend_context +def extend(): + from . import extend_context + from ..core import Context + extend_context.extend_context_class(Context) +extend() +del extend
# Pull GP_Backend -GP_Backend = backends_c.GP_Backend +Backend = backends_c.GP_Backend
# Extend GP_Backend with convenience methods from . import extend_backend -extend_backend.extend_backend_class(GP_Backend) +extend_backend.extend_backend_class(Backend) del extend_backend
# Constants module @@ -41,14 +42,18 @@ from . import C # Import some members from the SWIG module def import_helper(module): from ..utils import import_members + import re + def strip_GP(s): + return re.sub('^GP_', '', s)
# Constants const_regexes = ['^GP_[A-Z0-9_]*$'] - import_members(backends_c, C, include=const_regexes) + import_members(backends_c, C, include=const_regexes, sub=strip_GP)
# Functions - import_members(backends_c, module, + import_members(backends_c, module, sub=strip_GP, exclude=const_regexes + [ + '^GP_Backend$', '^w+_swigregister$', '^_w+$']) import_helper(locals()) diff --git a/pylib/gfxprim/backends/extend_backend.py b/pylib/gfxprim/backends/extend_backend.py index 526302f..bbd52cd 100644 --- a/pylib/gfxprim/backends/extend_backend.py +++ b/pylib/gfxprim/backends/extend_backend.py @@ -14,17 +14,17 @@ def extend_backend_class(_backend_class): self.name, "" if self.thisown else "not ")
@extend(_backend_class) - def flip(self): + def Flip(self): "If display is buffered, this copies content of context onto display." return backends_c.GP_BackendFlip(self)
@extend(_backend_class) - def update_rect(self, rect): + def UpdateRect(self, rect): "Update a rectangle on a buffered backend." return backends_c.GP_BackendUpdateRect(self, rect[0], rect[1], rect[2], rect[3])
@extend(_backend_class) - def poll(self): + def Poll(self): "Poll the backend for events." return backends_c.GP_BackendPoll(self)
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index d1aba53..21699f7 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -11,21 +11,25 @@ from . import C
# Import some members from the SWIG module def import_helper(module): + import re from ..utils import import_members
# Constants const_regexes = [ '^GP_[A-Z0-9_]*$', '^GP_PIXEL_x[A-Z0-9_]*$'] - import_members(core_c, C, include=const_regexes) + def strip_GP(s): + return re.sub('^GP_', '', s) + import_members(core_c, C, include=const_regexes, sub=strip_GP)
# Functions - import_members(core_c, module, + import_members(core_c, module, sub=strip_GP, exclude=const_regexes + [ '^GP_Blitw+$', '^GP_Contextw+$', '^GP_PixelSNPrintw+$', '^GP_WritePixelsw+$', + '.*_Raw.*', '^w+_swigregister$', '^cvar$', '^_w+$']) diff --git a/pylib/gfxprim/core/extend_context.py b/pylib/gfxprim/core/extend_context.py index b72b5d2..f8f197d 100644 --- a/pylib/gfxprim/core/extend_context.py +++ b/pylib/gfxprim/core/extend_context.py @@ -27,21 +27,25 @@ def extend_context_class(_context_class): def h(self): return core_c.GP_ContextH(self)
+ @add_swig_getmethod(_context_class) + def pixel_type(self): + return self._pixel_type + @extend(_context_class) - def subcontext(self, x, y, w, h): + def Subcontext(self, x, y, w, h): "Create a subcontext (rectangular view)." c = core_c.GP_ContextSubContext(self, None, x, y, w, h) c.parent = self return c
@extend(_context_class) - def copy(self, withdata): + def Copy(self, withdata): "Copy the context to a new context. Pixel data are copie optionally." flags = core_c.GP_COPY_WITH_PIXELS if withdata else 0 return core_c.GP_ContextCopy(self, flags)
@extend(_context_class) - def convert(self, target_type): + def Convert(self, target_type): """Converts context to a different pixel type, allocates new context. See GP_ContextConvert() for details.""" pixeltype_no = target_type ## TODO also accept PixelType @@ -49,7 +53,7 @@ def extend_context_class(_context_class):
@extend(_context_class, name='create') @staticmethod - def create(w, h, pixeltype): + def Create(w, h, pixeltype): "Allocate a new w*h bitmap of given type."
pixeltype_no = pixeltype if isinstance(pixeltype, int) else 0 # !!! @@ -57,3 +61,12 @@ def extend_context_class(_context_class): c = core_c.GP_ContextAlloc(w, h, pixeltype_no) return c
+ @extend(_context_class) + def RGBToPixel(self, r, g, b): + "Convert RGB888 (values 0-255) to context pixel type." + return GP_RGBToPixel(r, g, b, self.pixel_type) + + @extend(_context_class) + def RGBAToPixel(self, r, g, b): + "Convert RGBA8888 (values 0-255) to context pixel type." + return GP_RGBToPixel(r, g, b, self.pixel_type) diff --git a/pylib/gfxprim/loaders/__init__.py b/pylib/gfxprim/loaders/__init__.py index 5f9de96..5c62e9d 100644 --- a/pylib/gfxprim/loaders/__init__.py +++ b/pylib/gfxprim/loaders/__init__.py @@ -12,18 +12,22 @@ loaders_c = import_loaders_c_helper() del import_loaders_c_helper
# Extend Context with convenience methods -from . import extend_context -from ..core import Context -extend_context.extend_context_class(Context) -del Context -del extend_context +def extend(): + from . import extend_context + from ..core import Context + extend_context.extend_context_class(Context) +extend() +del extend
# Import some members from the SWIG module def import_helper(module): from ..utils import import_members + import re + def strip_GP(s): + return re.sub('^GP_', '', s)
# Functions - import_members(loaders_c, module, + import_members(loaders_c, module, sub=strip_GP, exclude=[ '^w+_swigregister$', '^core_c$', diff --git a/pylib/gfxprim/loaders/extend_context.py b/pylib/gfxprim/loaders/extend_context.py index a7df590..c8334ae 100644 --- a/pylib/gfxprim/loaders/extend_context.py +++ b/pylib/gfxprim/loaders/extend_context.py @@ -9,13 +9,13 @@ def extend_context_class(_context_class):
@extend(_context_class, name='load') @staticmethod - def load(filename): + def Load(filename): "Load image from given file, guess type." c = loaders_c.GP_LoadImage_Wrap(filename) return c
@extend(_context_class) - def save(self, filename, format=None): + def Save(self, filename, format=None): """Save the image in given format (or guess it from the extension)
Currently, JPG, PNG and P[BGP]M are supported, but not for all diff --git a/pylib/gfxprim/utils.py b/pylib/gfxprim/utils.py index 467eed0..4060811 100644 --- a/pylib/gfxprim/utils.py +++ b/pylib/gfxprim/utils.py @@ -30,7 +30,7 @@ def add_swig_setmethod(cls, name=None): cls.__swig_setmethods__[propname] = method return decf
-def import_members(from_, to, include=[], exclude=[]): +def import_members(from_, to, include=[], exclude=[], sub=None): """Import members of `from_` to `to`. By default take all. If `exclude` is provided, use as a filter. If `include` is provided, ONLY include those. `include` and `exclude` are lists of regexes to match (include ^ and $).""" @@ -56,8 +56,9 @@ def import_members(from_, to, include=[], exclude=[]): ok = False
if ok: + newname = name if sub == None else sub(name) try: - to[name] = o + to[newname] = o except TypeError: - to.__setattr__(name, o) + to.__setattr__(newname, o)
http://repo.or.cz/w/gfxprim.git/commit/96cff89699672066b2a8f18043d8455a46add...
commit 96cff89699672066b2a8f18043d8455a46add474 Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Feb 24 14:48:52 2012 +0100
Potentially orphaned contexts, no fix
After deleting GP_Backend, the context pointer may still be held inside the application. This leads to EVIL.
No fix for now. Referencing the backend from the context would create an evil uncollectable loop.
diff --git a/pylib/gfxprim/backends/__init__.py b/pylib/gfxprim/backends/__init__.py index dce87e2..e050008 100644 --- a/pylib/gfxprim/backends/__init__.py +++ b/pylib/gfxprim/backends/__init__.py @@ -1,3 +1,12 @@ +""" +Module wrapping GfxPrim backends. + +BIG FAT WARNING +--------------- +Accessing a context after its backend has ben freed will probably +end your (program's) world +""" + # HACK to allow backends_c to find core_c def import_backends_c_helper(): from os.path import dirname @@ -10,6 +19,15 @@ def import_backends_c_helper(): backends_c = import_backends_c_helper() del import_backends_c_helper
+# Extend Context with convenience methods +from . import extend_context +from ..core import Context +extend_context.extend_context_class(Context) +del Context +del extend_context + + +# Pull GP_Backend GP_Backend = backends_c.GP_Backend
# Extend GP_Backend with convenience methods @@ -17,6 +35,7 @@ from . import extend_backend extend_backend.extend_backend_class(GP_Backend) del extend_backend
+# Constants module from . import C
# Import some members from the SWIG module diff --git a/pylib/gfxprim/backends/extend_context.py b/pylib/gfxprim/backends/extend_context.py new file mode 100644 index 0000000..f959547 --- /dev/null +++ b/pylib/gfxprim/backends/extend_context.py @@ -0,0 +1,8 @@ +from ..utils import extend, add_swig_getmethod, add_swig_setmethod +from . import backends_c + +def extend_context_class(_context_class): + """ + Extends _context_class class with backend support. + """ + extend(_context_class, name='backend')(None)
http://repo.or.cz/w/gfxprim.git/commit/41a2719db7086efe7c888a3acc2807295bcef...
commit 41a2719db7086efe7c888a3acc2807295bcef640 Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Feb 24 14:33:34 2012 +0100
Batch of support for backends in pywrap.
diff --git a/pylib/gfxprim/backends/C.py b/pylib/gfxprim/backends/C.py new file mode 100644 index 0000000..c8f987f --- /dev/null +++ b/pylib/gfxprim/backends/C.py @@ -0,0 +1,3 @@ +""" +Submodule for constants +""" diff --git a/pylib/gfxprim/backends/Makefile b/pylib/gfxprim/backends/Makefile new file mode 100644 index 0000000..11180f9 --- /dev/null +++ b/pylib/gfxprim/backends/Makefile @@ -0,0 +1,6 @@ +TOPDIR=../../.. +LIBNAME=backends +INCLUDE=core +LDLIBS+=-lGP_backends -lSDL +include $(TOPDIR)/pywrap.mk +include $(TOPDIR)/include.mk diff --git a/pylib/gfxprim/backends/__init__.py b/pylib/gfxprim/backends/__init__.py new file mode 100644 index 0000000..dce87e2 --- /dev/null +++ b/pylib/gfxprim/backends/__init__.py @@ -0,0 +1,36 @@ +# HACK to allow backends_c to find core_c +def import_backends_c_helper(): + from os.path import dirname + import sys + oldpath = sys.path[:] + sys.path.append(dirname(__file__) + '/../core') + from . import backends_c + sys.path = oldpath + return backends_c +backends_c = import_backends_c_helper() +del import_backends_c_helper + +GP_Backend = backends_c.GP_Backend + +# Extend GP_Backend with convenience methods +from . import extend_backend +extend_backend.extend_backend_class(GP_Backend) +del extend_backend + +from . import C + +# Import some members from the SWIG module +def import_helper(module): + from ..utils import import_members + + # Constants + const_regexes = ['^GP_[A-Z0-9_]*$'] + import_members(backends_c, C, include=const_regexes) + + # Functions + import_members(backends_c, module, + exclude=const_regexes + [ + '^w+_swigregister$', + '^_w+$']) +import_helper(locals()) +del import_helper diff --git a/pylib/gfxprim/backends/backends.swig b/pylib/gfxprim/backends/backends.swig new file mode 100644 index 0000000..792e789 --- /dev/null +++ b/pylib/gfxprim/backends/backends.swig @@ -0,0 +1,46 @@ +%module backends_c + +%{ +#include "GP_Backend.h" +#include "GP_Backends.h" +%} + +#define __attribute__(X) +%include <stdint.i> + +%feature("autodoc"); + +%import ../core/core.swig + + +/* + * General backend structure handling + */ + +%extend GP_Backend { + ~GP_Backend() { + GP_DEBUG(2, "[wrapper] GP_BackendExit (%s)", + $self->name); + GP_BackendExit($self); + } +}; + +%ignore GP_Backend::priv; +%ignore GP_Backend::fd_list; +%ignore GP_BackendFD; + +%include "GP_Backend.h" + + +/* + * Particular backends. We need to list every header separately. + */ + +%include "GP_Backends.h" + +%newobject GP_BackendLinuxFBInit; +%include "GP_LinuxFB.h" + +%newobject GP_BackendSDLInit; +%include "GP_SDL.h" + diff --git a/pylib/gfxprim/backends/extend_backend.py b/pylib/gfxprim/backends/extend_backend.py new file mode 100644 index 0000000..526302f --- /dev/null +++ b/pylib/gfxprim/backends/extend_backend.py @@ -0,0 +1,30 @@ +from ..utils import extend, add_swig_getmethod, add_swig_setmethod +from . import backends_c + +def extend_backend_class(_backend_class): + """ + Extends _backend_class class with convenience methods. + Called once on module inicialization. + """ + + @extend(_backend_class, name='__str__') + @extend(_backend_class, name='__repr__') + def backend_str(self): + return "<Backend "%s", GP_Backend %sowned>" % ( + self.name, "" if self.thisown else "not ") + + @extend(_backend_class) + def flip(self): + "If display is buffered, this copies content of context onto display." + return backends_c.GP_BackendFlip(self) + + @extend(_backend_class) + def update_rect(self, rect): + "Update a rectangle on a buffered backend." + return backends_c.GP_BackendUpdateRect(self, rect[0], rect[1], rect[2], rect[3]) + + @extend(_backend_class) + def poll(self): + "Poll the backend for events." + return backends_c.GP_BackendPoll(self) +
http://repo.or.cz/w/gfxprim.git/commit/d6538118cb90b513bbe82c90f7aa5c23b0510...
commit d6538118cb90b513bbe82c90f7aa5c23b051050b Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Feb 24 14:30:46 2012 +0100
Add separate sub-module for constants
(replace dict)
diff --git a/pylib/gfxprim/core/C.py b/pylib/gfxprim/core/C.py new file mode 100644 index 0000000..c8f987f --- /dev/null +++ b/pylib/gfxprim/core/C.py @@ -0,0 +1,3 @@ +""" +Submodule for constants +""" diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index cce62d2..d1aba53 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -7,16 +7,16 @@ from . import extend_context extend_context.extend_context_class(Context) del extend_context
+from . import C + # Import some members from the SWIG module def import_helper(module): from ..utils import import_members
- # Constants (TODO consider a separate module) + # Constants const_regexes = [ '^GP_[A-Z0-9_]*$', '^GP_PIXEL_x[A-Z0-9_]*$'] - C = {} - module['C'] = C import_members(core_c, C, include=const_regexes)
# Functions
http://repo.or.cz/w/gfxprim.git/commit/85343b9e91ec90b29ea7cd3b568376154bd2b...
commit 85343b9e91ec90b29ea7cd3b568376154bd2b3df Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Feb 24 14:28:28 2012 +0100
Enable additional library linking for pywrap.mk
diff --git a/pywrap.mk b/pywrap.mk index 3376c78..ab8dcf7 100644 --- a/pywrap.mk +++ b/pywrap.mk @@ -25,10 +25,10 @@ endif # VERBOSE
$(SWIG_LIB): $(SWIG_C) ifdef VERBOSE - $(CC) $< $(CFLAGS) $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP -L$(TOPDIR)/build/ -o $@ + $(CC) $< $(CFLAGS) $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@ else # VERBOSE @echo "LD $@" - @$(CC) $< $(CFLAGS) $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP -L$(TOPDIR)/build/ -o $@ + @$(CC) $< $(CFLAGS) $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@ endif # VERBOSE
endif # ifneq ($(SWIG),)
http://repo.or.cz/w/gfxprim.git/commit/39401ddcc823b061542a35fd3020a5de5cf18...
commit 39401ddcc823b061542a35fd3020a5de5cf182be Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Feb 24 14:28:01 2012 +0100
Fix attribute setting
diff --git a/pylib/gfxprim/utils.py b/pylib/gfxprim/utils.py index d48aa0e..467eed0 100644 --- a/pylib/gfxprim/utils.py +++ b/pylib/gfxprim/utils.py @@ -59,5 +59,5 @@ def import_members(from_, to, include=[], exclude=[]): try: to[name] = o except TypeError: - to.__setattribute__(name, o) + to.__setattr__(name, o)
-----------------------------------------------------------------------
Summary of changes: pylib/gfxprim/backends/C.py | 3 + pylib/gfxprim/{loaders => backends}/Makefile | 3 +- pylib/gfxprim/backends/__init__.py | 60 ++++++++++++++++++++++++++ pylib/gfxprim/backends/backends.swig | 46 ++++++++++++++++++++ pylib/gfxprim/backends/extend_backend.py | 30 +++++++++++++ pylib/gfxprim/backends/extend_context.py | 8 +++ pylib/gfxprim/core/C.py | 3 + pylib/gfxprim/core/__init__.py | 14 ++++-- pylib/gfxprim/core/extend_context.py | 21 +++++++-- pylib/gfxprim/loaders/__init__.py | 16 ++++--- pylib/gfxprim/loaders/extend_context.py | 4 +- pylib/gfxprim/utils.py | 7 ++- pywrap.mk | 4 +- 13 files changed, 196 insertions(+), 23 deletions(-) create mode 100644 pylib/gfxprim/backends/C.py copy pylib/gfxprim/{loaders => backends}/Makefile (65%) create mode 100644 pylib/gfxprim/backends/__init__.py create mode 100644 pylib/gfxprim/backends/backends.swig create mode 100644 pylib/gfxprim/backends/extend_backend.py create mode 100644 pylib/gfxprim/backends/extend_context.py create mode 100644 pylib/gfxprim/core/C.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.