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 a3c538fd80eb28f103161ce90aa03b05da303866 (commit) via 7a26d926dbd69b93075025f03f71fed563484f78 (commit) via 53d752f070bb250f906844ac8ad82f10ea33c5e7 (commit) from 75d8ed70740c7f15606f382a4bba5cd14a632b24 (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/a3c538fd80eb28f103161ce90aa03b05da303...
commit a3c538fd80eb28f103161ce90aa03b05da303866 Author: Tomas Gavenciak gavento@ucw.cz Date: Sat Dec 22 02:19:41 2012 +0100
Print stack trace on GP_ABORT inside active Python
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h index a1e8d14..95731b7 100644 --- a/include/core/GP_Common.h +++ b/include/core/GP_Common.h @@ -100,11 +100,12 @@ * GP_GENERAL_CHECK is a check with specified message prefix * (for assert and check) * - * SWIG_exception is a dummy no-op that is used to raise an exception when wrapped. - * NOTE: Currently totally useless. Hrmmppff. + * SWIG_print_trace() prints a trace of Python stack if a Python interpreter + * is set up. In case more wrappers are written, should print a trace + * for the currently active. */
-void SWIG_exception(const char *msg); +void SWIG_print_trace(void);
#define GP_INTERNAL_ABORT_BUFSIZE 1024 #define GP_INTERNAL_ABORT(str_abort_msg_, ...) do { @@ -117,7 +118,7 @@ void SWIG_exception(const char *msg); buf += snprintf(buf, bufend - buf, "abort()"); else buf += snprintf(buf, bufend - buf, " " __VA_ARGS__); - SWIG_exception(bufstart); + SWIG_print_trace(); fprintf(stderr, "%sn", bufstart); abort(); } while (0) diff --git a/libs/core/GP_Common.c b/libs/core/GP_Common.c index 92ec868..2cf6fc9 100644 --- a/libs/core/GP_Common.c +++ b/libs/core/GP_Common.c @@ -20,8 +20,27 @@ * * *****************************************************************************/
+#define _GNU_SOURCE + +#include "../config.h" + #include "core/GP_Common.h"
-void SWIG_exception(const char *msg) +#ifdef HAVE_DL +#include <dlfcn.h> +#endif /* HAVE_DL */ + + +void SWIG_print_trace(void) { +#ifdef HAVE_DL + /* Print python stack trace in case python lib is loaded and + * a python interpreter is initialized */ + int (*dl_Py_IsInitialized)(); + int (*dl_PyRun_SimpleString)(const char *); + dl_Py_IsInitialized = dlsym(RTLD_DEFAULT, "Py_IsInitialized"); + dl_PyRun_SimpleString = dlsym(RTLD_DEFAULT, "PyRun_SimpleString"); + if (dl_Py_IsInitialized && dl_PyRun_SimpleString && dl_Py_IsInitialized()) + dl_PyRun_SimpleString("import traceback; traceback.print_stack();"); +#endif /* HAVE_DL */ } diff --git a/pylib/gfxprim/common.i b/pylib/gfxprim/common.i index bc99ff3..2d17c0f 100644 --- a/pylib/gfxprim/common.i +++ b/pylib/gfxprim/common.i @@ -5,6 +5,7 @@ #define __attribute__(X)
%include <stdint.i> +%include <exception.i>
%feature("autodoc");
http://repo.or.cz/w/gfxprim.git/commit/7a26d926dbd69b93075025f03f71fed563484...
commit 7a26d926dbd69b93075025f03f71fed563484f78 Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Dec 21 21:09:08 2012 +0100
Finish Context methods and wrapping
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index bcc26f4..3bf8d08 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -22,7 +22,7 @@ def _init(module): """
import re - from ..utils import extend, add_swig_getmethod, add_swig_setmethod + from ..utils import extend, extend_direct, add_swig_getmethod, add_swig_setmethod from ..utils import import_members _context = module['Context']
@@ -55,9 +55,10 @@ def _init(module): c.parent = None return c
+ extend_direct @extend(_context) - def Subcontext(self, x, y, w, h): - "Create a subcontext (rectangular view)." + def SubContext(self, x, y, w, h): + "Create a subcontext (a rectangular view)." c = c_core.GP_SubContextAlloc(self, x, y, w, h) c.parent = self return c @@ -74,6 +75,22 @@ def _init(module): See GP_ContextConvert() for details.""" return c_core.GP_ContextConvert(self, pixeltype_no(target_type))
+ # Manipulation + extend_direct(_context, "PutPixel", c_core.GP_PutPixel, + "Set a pixel value encoded according to context PixelType. Clipped.") + + extend_direct(_context, "GetPixel", c_core.GP_GetPixel, + "Get a pixel value (encoded according to context PixelType). Clipped.") + + extend_direct(_context, "RotateCW", c_core.GP_ContextRotateCW, + "Rotate Context clockwise by changing the context orientation.") + + extend_direct(_context, "RotateCCW", c_core.GP_ContextRotateCCW, + "Rotate Context counter-clockwise by changing the context orientation.") + + extend_direct(_context, "Resize", c_core.GP_ContextResize, + "Resize the context bitmap (reallocate). Fails on subcontexts.") + # Color conversions
@extend(_context) @@ -136,23 +153,23 @@ TODO: on entering any func from Python, set up error reporting on GP_ABORT
! Pixeltype table and objects
-GP_PixelTypes +GP_PixelTypes - FIX
! IN Context class
-GP_ContextAlloc -GP_ContextResize -GP_ContextConvertAlloc -GP_ContextPrintInfo -GP_ContextRotateCCW -GP_SubContextAlloc -GP_ContextConvert -GP_ContextRotateCW -GP_ContextFree -GP_ContextInit -GP_SubContext -GP_ContextCopy -GP_PixelAddrOffset +GP_ContextAlloc C +GP_ContextResize C +GP_ContextConvertAlloc C +GP_ContextPrintInfo N +GP_ContextRotateCCW C +GP_SubContextAlloc C +GP_ContextConvert C +GP_ContextRotateCW C +GP_ContextFree Ci +GP_ContextInit N +GP_SubContext N +GP_ContextCopy C +GP_PixelAddrOffset N
! ?
@@ -168,8 +185,8 @@ GP_PixelAddrOffset
! Color conversion
-GP_RGBA8888ToPixel -GP_RGB888ToPixel +GP_RGBA8888ToPixel N +GP_RGB888ToPixel N GP_PixelToRGB888 GP_PixelToRGBA8888 GP_ColorNameToPixel @@ -212,12 +229,12 @@ Blit - reimplement with keyword args, no raw
! IN Context - basic drawing
-GP_PutPixel -GP_GetPixel +GP_PutPixel C +GP_GetPixel C
! ?
-# GP_NrThreads +# GP_NrThreads # GP_NrThreadsSet # GP_ProgressCallbackMP # SWIG_exception diff --git a/pylib/gfxprim/core/_extend_context.py b/pylib/gfxprim/core/_extend_context.py deleted file mode 100644 index 4b73ec9..0000000 --- a/pylib/gfxprim/core/_extend_context.py +++ /dev/null @@ -1,60 +0,0 @@ -from ..utils import extend, add_swig_getmethod, add_swig_setmethod -from . import core_c - -def extend_context(_context): - """ - Extends _context class with core module methods and properties - for object-oriented usage. - Called once on module inicialization. - """ - - # Add "parent" attribute - extend(_context, name='parent')(None) - - @extend(_context, name='__str__') - @extend(_context, name='__repr__') - def context_str(self): - return "<Context %dx%d, %dbpp, GP_Context %sowned, %s parent>" % ( - self.w, self.h, self.bpp, - "" if self.thisown else "not ", - "with" if self.parent else "no") - - @extend(_context) - 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) - 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) - 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 - return core_c.GP_ContextConvert(self, pixeltype_no) - - @extend(_context, name='Create') - @staticmethod - def Create(w, h, pixeltype): - "Allocate a new w*h bitmap of given type." - - pixeltype_no = pixeltype if isinstance(pixeltype, int) else 0 # !!! - # TODO: actually accept a PixelType - c = core_c.GP_ContextAlloc(w, h, pixeltype_no) - return c - - @extend(_context) - def RGBToPixel(self, r, g, b): - "Convert RGB888 (values 0-255) to context pixel type." - return core_c.GP_RGBToPixel(int(r), int(g), int(b), self.pixel_type) - - @extend(_context) - 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/utils.py b/pylib/gfxprim/utils.py index 32462f1..5dc6dab 100644 --- a/pylib/gfxprim/utils.py +++ b/pylib/gfxprim/utils.py @@ -13,6 +13,17 @@ 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 method(*args, **kwargs): + return call(*args, **kwargs) + method.__name__ = name + method.__doc__ = doc.strip() + 'n' + if swig_doc: + method.__doc__ = call.__doc__ + 'nn' + doc.strip() + 'n' + type.__setattr__(cls, 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/53d752f070bb250f906844ac8ad82f10ea33c...
commit 53d752f070bb250f906844ac8ad82f10ea33c5e7 Author: Tomas Gavenciak gavento@ucw.cz Date: Fri Dec 21 20:28:09 2012 +0100
First part of reworking pywrap for core
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index 7589d14..bcc26f4 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -1,30 +1,119 @@ -from . import core_c
-Context = core_c.GP_Context +# Import the SWIG wrapper + +from . import c_core + + +# Constants module
-# Constants from . import C
-def _init(module):
- # Extend Context with convenience methods - from ._extend_context import extend_context - extend_context(Context) +# Main Context proxy (extended below) + +Context = c_core.GP_Context + + +def _init(module): + """ + Extends _context class with core module methods and properties + for object-oriented usage. + Called once on module initialization. + """
- # Import some members from the SWIG module import re + from ..utils import extend, add_swig_getmethod, add_swig_setmethod from ..utils import import_members + _context = module['Context'] + + # String representation + + @extend(_context, name='__str__') + @extend(_context, name='__repr__') + def context_str(self): + return "<Context %dx%d, %dbpp, GP_Context %sowned, %s parent>" % ( + self.w, self.h, self.bpp, + "" if self.thisown else "not ", + "with" if self.parent else "no") + + # Creation + + def pixeltype_no(pixeltype): + "Return pixel type number from the number or a PixelType instance" + if isinstance(pixeltype, int): + return pixeltype + if isinstance(pixeltype, c_core.GP_PixelTypeDescription): + return pixeltype.type + raise TypeError("Not a PixelType instance or number: %r", pixeltype) + + @extend(_context, name='Create') + @staticmethod + def Create(w, h, pixeltype): + "Allocate a new w*h bitmap of given type." + # Add "parent" attribute, pointing to a wrapper of the actual parent or None + c = c_core.GP_ContextAlloc(w, h, pixeltype_no(pixeltype)) + c.parent = None + return c + + @extend(_context) + def Subcontext(self, x, y, w, h): + "Create a subcontext (rectangular view)." + c = c_core.GP_SubContextAlloc(self, x, y, w, h) + c.parent = self + return c + + @extend(_context) + def Copy(self, withdata): + "Copy the context to a new context. Pixel data are copie optionally." + flags = c_core.GP_COPY_WITH_PIXELS if withdata else 0 + return c_core.GP_ContextCopy(self, flags) + + @extend(_context) + def Convert(self, target_type): + """Converts context to a different pixel type, allocates new context. + See GP_ContextConvert() for details.""" + return c_core.GP_ContextConvert(self, pixeltype_no(target_type)) + + # Color conversions + + @extend(_context) + def RGBToPixel(self, r, g, b): + "Convert RGB888 (values 0-255) to context pixel type." + return c_core.GP_RGBToPixel(int(r), int(g), int(b), self.pixel_type) + + @extend(_context) + def RGBAToPixel(self, r, g, b, a): + "Convert RGBA8888 (values 0-255) to context pixel type." + return c_core.GP_RGBAToPixel(int(r), int(g), int(b), int(a), self.pixel_type) + + # Handle submodule methods such as context.gfx.Line(...) + _available_submodules = frozenset(['gfx', 'loaders', 'text', 'filters']) + + extend(_context, name='_submodules')({}) + + old__getattr__ = _context.__getattr__ + def Context__getattr__(self, name): + if name in _context._submodules: + assert name in _available_submodules + return _context._submodules[name](self) + if name in _available_submodules: + raise RuntimeError("GfxPrim submodule '%s' not loaded" % name) + return old__getattr__(self, name) + _context.__getattr__ = Context__getattr__ + + # Import constants into a separate module
- # Constants const_regexes = [ '^GP_[A-Z0-9_]*$', '^GP_PIXEL_x[A-Z0-9_]*$'] def strip_GP(s): return re.sub('^GP_', '', s) - import_members(core_c, C, include=const_regexes, sub=strip_GP) + import_members(c_core, C, include=const_regexes, sub=strip_GP) + # every Context also points to C for convenience + extend(_context, name='C')(C)
- # Functions - import_members(core_c, module, sub=strip_GP, + # Bulk import of functions - TODO: only import specified + import_members(c_core, module, sub=strip_GP, exclude=const_regexes + [ '^GP_Blitw+$', '^GP_Contextw+$', @@ -37,3 +126,100 @@ def _init(module):
_init(locals()) del _init + +""" +TODO: on entering any func from Python, set up error reporting on GP_ABORT +(raise an exception, restore stack and return, possibly longjmp? +(or just force python trace?) + +!! LIST of symbols to implement + +! Pixeltype table and objects + +GP_PixelTypes + +! IN Context class + +GP_ContextAlloc +GP_ContextResize +GP_ContextConvertAlloc +GP_ContextPrintInfo +GP_ContextRotateCCW +GP_SubContextAlloc +GP_ContextConvert +GP_ContextRotateCW +GP_ContextFree +GP_ContextInit +GP_SubContext +GP_ContextCopy +GP_PixelAddrOffset + +! ? + +# GP_GammaRelease +# GP_GammaCopy +# GP_GammaAcquire + +! ? + +# GP_DebugPrint +# GP_SetDebugLevel +# GP_GetDebugLevel + +! Color conversion + +GP_RGBA8888ToPixel +GP_RGB888ToPixel +GP_PixelToRGB888 +GP_PixelToRGBA8888 +GP_ColorNameToPixel + +GP_PixelTypeByName - reimplement + +# GP_ColorToPixel +# GP_PixelRGBMatch +# GP_ColorLoadPixels +# GP_PixelRGBLookup +# GP_ColorNameToColor +# GP_ColorToColorName + +! IN Context class + +Blit - reimplement with keyword args, no raw + +# GP_BlitXYXY +# GP_BlitXYXY_Fast +# GP_BlitXYWH +# GP_BlitXYWH_Clipped +# GP_BlitXYXY_Clipped +# GP_BlitXYXY_Raw_Fast +# GP_BlitXYWH_Raw +# GP_BlitXYXY_Raw + +! Do not want + +# GP_WritePixels_1BPP_LE +# GP_WritePixels_2BPP_LE +# GP_WritePixels_4BPP_LE +# GP_WritePixels1bpp +# GP_WritePixels2bpp +# GP_WritePixels4bpp +# GP_WritePixels8bpp +# GP_WritePixels16bpp +# GP_WritePixels18bpp +# GP_WritePixels32bpp +# GP_WritePixels24bpp + +! IN Context - basic drawing + +GP_PutPixel +GP_GetPixel + +! ? + +# GP_NrThreads +# GP_NrThreadsSet +# GP_ProgressCallbackMP +# SWIG_exception +""" + diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index c679c4b..6e1d017 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -1,5 +1,5 @@ %include "../common.i" -%module(package="gfxprim.core") core_c +%module(package="gfxprim.core") c_core
%{ #include "core/GP_Core.h" diff --git a/pylib/gfxprim/utils.py b/pylib/gfxprim/utils.py index 4d4bd05..32462f1 100644 --- a/pylib/gfxprim/utils.py +++ b/pylib/gfxprim/utils.py @@ -12,6 +12,7 @@ def extend(cls, name=None): return method return decf
+ def add_swig_getmethod(cls, name=None): "Decorator to add a property get method to a SWIG-defined class" def decf(method): @@ -21,6 +22,7 @@ def add_swig_getmethod(cls, name=None): cls.__swig_getmethods__[propname] = method return decf
+ def add_swig_setmethod(cls, name=None): "Decorator to add a property set method to a SWIG-defined class" def decf(method): @@ -30,6 +32,7 @@ def add_swig_setmethod(cls, name=None): cls.__swig_setmethods__[propname] = method return decf
+ 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. diff --git a/pywrap.mk b/pywrap.mk index 03d22cf..d8b18f6 100644 --- a/pywrap.mk +++ b/pywrap.mk @@ -3,9 +3,9 @@ $(error LIBNAME not defined, fix your library Makefile) endif
SWIG_SRC=$(LIBNAME).i -SWIG_PY=$(LIBNAME)_c.py SWIG_C=$(LIBNAME)_wrap.c -SWIG_LIB=_$(LIBNAME)_c.so +SWIG_PY=c_$(LIBNAME).py +SWIG_LIB=_c_$(LIBNAME).so
ifneq ($(SWIG),)
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Common.h | 9 +- libs/core/GP_Common.c | 21 +++- pylib/gfxprim/common.i | 1 + pylib/gfxprim/core/__init__.py | 227 +++++++++++++++++++++++++++++++-- pylib/gfxprim/core/_extend_context.py | 60 --------- pylib/gfxprim/core/core.i | 2 +- pylib/gfxprim/utils.py | 14 ++ pywrap.mk | 4 +- 8 files changed, 258 insertions(+), 80 deletions(-) delete mode 100644 pylib/gfxprim/core/_extend_context.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.