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 d028c5b88bfbe818f650dac41671b7dc74fab584 (commit)
via 133b310ce8ca4adc61f14648dee634a00d5cf077 (commit)
via 75272ddef49127d165aa2e041fcb49f5bdf437dd (commit)
via 3428c6433249fc771dc355438cd47d7d3abfd70d (commit)
via 116c09aa2a1efd689e4c2a66ad11d55988374983 (commit)
from 9fb8ec2881f24724d6fe71bbfecb7524e95053a7 (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/d028c5b88bfbe818f650dac41671b7dc74fa…
commit d028c5b88bfbe818f650dac41671b7dc74fab584
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 20:28:53 2011 +0100
Update and move GP_Context wrapper docstring
diff --git a/include/core/gfxprim_core.swig b/include/core/gfxprim_core.swig
index 366067c..4cdb160 100644
--- a/include/core/gfxprim_core.swig
+++ b/include/core/gfxprim_core.swig
@@ -44,12 +44,10 @@
/*
- * Context manipulation
+ * GP_Context wrapping
*/
-/* Rename accestors to GP_Context attributes to _attribute */
-/* would work in swig 2.0:
- * %rename("_%s", regexmatch$name="^GP_Context::") ""; */
+/* Rename accesors to GP_Context attributes to "_attribute" */
%rename("_%s") "GP_Context::pixels";
%rename("_%s") "GP_Context::bpp";
%rename("_%s") "GP_Context::bytes_per_row";
@@ -62,8 +60,26 @@
%rename("_%s") "GP_Context::y_swap";
%rename("_%s") "GP_Context::bit_endian";
%rename("_%s") "GP_Context::free_pixels";
+/* This nice batch would work in swig 2.0, sigh:
+ * %rename("_%s", regexmatch$name="^GP_Context::") ""; */
+
%rename("Context") "GP_Context";
+%feature("autodoc", "Proxy of C GP_Context struct
+
+You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
+All attributes of GP_Context are accessible directly as _attribute
+(self._w etc.), but it is reccomended to use redefined properties:
+
+self.w: Context width (transformed)
+self.h: Context width (transformed)
+
+Some context-related methods are provided as class members for convenience.
+
+GP_Context memory allocation is handled by gfxprim, deallocation by GP_ContextFree().
+The wrapper can be used without owning the GP_Context struct by setting self.this
+and self.thisown.") GP_Context;
+
%include "GP_Context.h"
%extend GP_Context {
@@ -74,6 +90,11 @@
}
};
+
+/*
+ * Context manipulation
+ */
+
%include "GP_GetPutPixel.h"
%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
diff --git a/pylib/context.py b/pylib/context.py
index 32ed123..1837b23 100644
--- a/pylib/context.py
+++ b/pylib/context.py
@@ -33,23 +33,7 @@ def extend_context_class(_context_class = core.Context):
Called on module inicialization.
"""
- type.__setattr__(_context_class, "__doc_2__",
- """Proxy of C GP_Context struct
-
- You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
- All attributes of GP_Context are accessible directly as "_attribute"
- (self._w etc.), but it is reccomended to use redefined properties:
-
- self.w: Context width (transformed)
- self.h: Context width (transformed)
-
- Some context methods are provided as class members for convenience.
-
- GP_Context memory allocation is handled completely by gfxprim.
- You shoud NEVER even think about self.this - this pointer will point to
- free memory after self.__del__ is called (in case of owned GP_Context).
- """)
-
+ # Add "parent" attribute
extend(_context_class, name='parent')(None)
@extend(_context_class, name='__str__')
http://repo.or.cz/w/gfxprim.git/commit/133b310ce8ca4adc61f14648dee634a00d5c…
commit 133b310ce8ca4adc61f14648dee634a00d5cf077
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 20:04:12 2011 +0100
Complete rewrite of the wrapper class
Now extending the SWIG wrapper instead of delegation
Decorating tools
TODO: set docstring correctly
diff --git a/pylib/context.py b/pylib/context.py
index 1551c5c..32ed123 100644
--- a/pylib/context.py
+++ b/pylib/context.py
@@ -1,58 +1,84 @@
import gfxprim_core_c as core
import gfxprim_loaders_c as loaders
-class Context(object):
- def __init__(self, context, owns_GP_Context, parent=None):
- """Create new GP_Context wrapper.
+def extend(cls, name=None):
+ def decf(method):
+ funname = name
+ if not funname:
+ funname = method.__name__
+ type.__setattr__(cls, funname, method)
+ return method
+ return decf
- The wrapper is just a (read-only) proxy with
- some conveniently mapped context methods.
- Direct access is possible through self.context.
- """
- # GP_Context struct (pre-wrapped by SWIG)
- self.context = context
- # call GP_ContextFree on del?
- self.owns_GP_Context = owns_GP_Context
- # Parent Context of a subcontext (if any)
- # It is important to hold a ref to parent because of GC
- self.parent = parent
-
- def __del__(self):
- print "Deleting %s (owns_GP_Context: %s)" % (self, self.owns_GP_Context)
- if self.owns_GP_Context:
- core.GP_ContextFree(self.context)
-
- @property
- def w(self):
- "Context width (transformed)"
- return core.GP_ContextW(self.context)
+def add_swig_getmethod(cls, name=None):
+ def decf(method):
+ propname = name
+ if not propname:
+ propname = method.__name__
+ cls.__swig_getmethods__[propname] = method
+ return decf
- @property
- def h(self):
- "Context height (transformed)"
- return core.GP_ContextH(self.context)
+def add_swig_setmethod(cls, name=None):
+ def decf(method):
+ propname = name
+ if not propname:
+ propname = method.__name__
+ cls.__swig_setmethods__[propname] = method
+ return decf
+
+
+def extend_context_class(_context_class = core.Context):
+ """
+ Extends _context_class class with convenience methods.
+ Called on module inicialization.
+ """
+
+ type.__setattr__(_context_class, "__doc_2__",
+ """Proxy of C GP_Context struct
+
+ You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
+ All attributes of GP_Context are accessible directly as "_attribute"
+ (self._w etc.), but it is reccomended to use redefined properties:
+
+ self.w: Context width (transformed)
+ self.h: Context width (transformed)
+
+ Some context methods are provided as class members for convenience.
- @property
- def bpp(self):
- "Context bpp"
- return self.context.bpp
+ GP_Context memory allocation is handled completely by gfxprim.
+ You shoud NEVER even think about self.this - this pointer will point to
+ free memory after self.__del__ is called (in case of owned GP_Context).
+ """)
- def __str__(self):
+ extend(_context_class, name='parent')(None)
+
+ @extend(_context_class, name='__str__')
+ @extend(_context_class, name='__repr__')
+ def context_str(self):
return "<Context %dx%d, %dbpp, GP_Context %sowned, %s parent>" % (
- self.w, self.h, self.bpp,
- "" if self.owns_GP_Context else "not ",
- "with" if self.parent else "no")
- __repr__ = __str__
+ self.w, self.h, self._bpp,
+ "" if self.thisown else "not ",
+ "with" if self.parent else "no")
+
+ @add_swig_getmethod(_context_class)
+ def w(self):
+ return core.GP_ContextW(self)
+
+ @add_swig_getmethod(_context_class)
+ def h(self):
+ return core.GP_ContextH(self)
+ @extend(_context_class)
def subcontext(self, x, y, w, h):
"Create a subcontext (rectangular view)."
- c = core.GP_ContextSubContext(self.context, None, x, y, w, h)
- if not c:
- raise Exception("Error creating subcontext")
- return type(self)(c, owns_GP_Context=True, parent=self)
+ c = core.GP_ContextSubContext(self, None, x, y, w, h)
+ c.thisown = True # GP_Context IS owned (but not the pixel data)
+ c.parent = self
+ return c
+ @extend(_context_class)
def save(self, filename, format=None):
- """Save the image in given format (or guess by the extension)
+ """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
context pixel types.
@@ -61,34 +87,40 @@ class Context(object):
format = filename.rsplit('.', 1)[-1]
format = format.lower()
if format == 'jpg':
- res = loaders.GP_SaveJPG(filename, self.context, None)
+ res = loaders.GP_SaveJPG(filename, self, None)
elif format == 'png':
- res = loaders.GP_SavePNG(filename, self.context, None)
+ res = loaders.GP_SavePNG(filename, self, None)
elif format == 'pbm':
- res = loaders.GP_SavePBM(filename, self.context, None)
+ res = loaders.GP_SavePBM(filename, self, None)
elif format == 'pgm':
- res = loaders.GP_SavePGM(filename, self.context, None)
+ res = loaders.GP_SavePGM(filename, self, None)
elif format == 'ppm':
- res = loaders.GP_SavePPM(filename, self.context, None)
+ res = loaders.GP_SavePPM(filename, self, None)
else:
raise Exception("Format %r not supported.", format)
if res != 0:
raise Exception("Error saving %r (code %d)", filename, res)
- @classmethod
- def create(cls, w, h, pixeltype):
+ @extend(_context_class, 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.GP_ContextAlloc(w, h, pixeltype_no)
- return cls(c, owns_GP_Context=True)
+ c.thisown = True
+ return c
- @classmethod
- def load(cls, filename):
+ @extend(_context_class, name='load')
+ @staticmethod
+ def load(filename):
"Load image from given file, guess type."
c = loaders.GP_LoadImage_SWIG(filename)
- if not c:
- raise Exception("Error loading %r", filename)
- return cls(c, owns_GP_Context=True)
+ c.thisown = True
+ return c
+
+
+
+extend_context_class()
http://repo.or.cz/w/gfxprim.git/commit/75272ddef49127d165aa2e041fcb49f5bdf4…
commit 75272ddef49127d165aa2e041fcb49f5bdf437dd
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 20:02:11 2011 +0100
Prepare for (more) direct wrapping of GP_Context
Add autodoc feature
Rename attributes to "_*"
Set GP_Context destructor
diff --git a/include/core/gfxprim_core.swig b/include/core/gfxprim_core.swig
index e9d68d1..366067c 100644
--- a/include/core/gfxprim_core.swig
+++ b/include/core/gfxprim_core.swig
@@ -8,6 +8,8 @@
%include <stdint.i>
+%feature("autodoc");
+
%nodefaultctor;
/*
@@ -45,8 +47,33 @@
* Context manipulation
*/
+/* Rename accestors to GP_Context attributes to _attribute */
+/* would work in swig 2.0:
+ * %rename("_%s", regexmatch$name="^GP_Context::") ""; */
+%rename("_%s") "GP_Context::pixels";
+%rename("_%s") "GP_Context::bpp";
+%rename("_%s") "GP_Context::bytes_per_row";
+%rename("_%s") "GP_Context::w";
+%rename("_%s") "GP_Context::h";
+%rename("_%s") "GP_Context::offset";
+%rename("_%s") "GP_Context::pixel_type";
+%rename("_%s") "GP_Context::axes_swap";
+%rename("_%s") "GP_Context::x_swap";
+%rename("_%s") "GP_Context::y_swap";
+%rename("_%s") "GP_Context::bit_endian";
+%rename("_%s") "GP_Context::free_pixels";
+%rename("Context") "GP_Context";
+
%include "GP_Context.h"
+%extend GP_Context {
+ ~GP_Context() {
+ GP_DEBUG(2, "[wrapper] GP_ContextFree (%dx%d raw, %dbpp, free_pixels:%d)",
+ $self->w, $self->h, $self->bpp, $self->free_pixels);
+ GP_ContextFree($self);
+ }
+};
+
%include "GP_GetPutPixel.h"
%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
http://repo.or.cz/w/gfxprim.git/commit/3428c6433249fc771dc355438cd47d7d3abf…
commit 3428c6433249fc771dc355438cd47d7d3abfd70d
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 10:39:00 2011 +0100
core SWIG cleanup, removed some internals
diff --git a/include/core/gfxprim_core.swig b/include/core/gfxprim_core.swig
index 2a96a71..e9d68d1 100644
--- a/include/core/gfxprim_core.swig
+++ b/include/core/gfxprim_core.swig
@@ -10,7 +10,9 @@
%nodefaultctor;
-/* Basic types and common methods */
+/*
+ * Basic types and common methods
+ */
%include "GP_Common.h"
%include "GP_Core.h"
@@ -23,23 +25,31 @@
%include "GP_ProgressCallback.h"
%include "GP_RetCode.h"
-/* Color and pixel types */
+
+/*
+ * Color and pixel types
+ */
%include "GP_Color.h"
-%include "GP_Context.h"
%include "GP_Pixel.h"
-%include "GP_Pixel.gen.h"
+%include "GP_Pixel.gen.h" /* Includes enum GP_PixelType definition */
%include "GP_Convert.h"
-%include "GP_Convert.gen.h"
-%include "GP_Convert_Scale.gen.h"
-%include "GP_Blit.gen.h"
+%import "GP_Convert.gen.h"
+%import "GP_Convert_Scale.gen.h"
+
+%import "GP_FnPerBpp.h"
+%import "GP_FnPerBpp.gen.h"
+
-/* Context manipulation */
+/*
+ * Context manipulation
+ */
%include "GP_Context.h"
-%include "GP_Blit.h"
-%include "GP_Blit.gen.h"
-%include "GP_FnPerBpp.h"
+
%include "GP_GetPutPixel.h"
+%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
+%include "GP_Blit.h"
+%import "GP_Blit.gen.h"
http://repo.or.cz/w/gfxprim.git/commit/116c09aa2a1efd689e4c2a66ad11d5598837…
commit 116c09aa2a1efd689e4c2a66ad11d55988374983
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 10:37:44 2011 +0100
Add GP_WritePixels.h to GP_Core.h
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index 70c2c3f..93ce52b 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -50,7 +50,10 @@
/* Individual pixel access */
#include "core/GP_GetPutPixel.h"
-/* blitting */
+/* Writing pixel blocks */
+#include "GP_WritePixel.h"
+
+/* Blitting */
#include "core/GP_Blit.h"
/* Debug and debug level */
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Core.h | 5 +-
include/core/gfxprim_core.swig | 80 ++++++++++++++++++++++----
pylib/context.py | 126 ++++++++++++++++++++++-----------------
3 files changed, 144 insertions(+), 67 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 3cca227bd9d97802da766c2feca0bb537c038b16 (commit)
from 2a44791a84f6aa540897532ea8a0e0d2e4e5ae10 (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/3cca227bd9d97802da766c2feca0bb537c03…
commit 3cca227bd9d97802da766c2feca0bb537c038b16
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 24 22:35:34 2011 +0100
Add -fPIC to fix the compilation on x86_64.
diff --git a/include/core/swigify.sh b/include/core/swigify.sh
index a82e16e..53a8ce4 100755
--- a/include/core/swigify.sh
+++ b/include/core/swigify.sh
@@ -2,7 +2,7 @@ set -e
swig -python -Wall -I/usr/include/ gfxprim_core.swig
gcc -shared gfxprim_core_wrap.c -L ../../build/ -I /usr/include/python2.6/ -I.. - -lGP -lpng -ljpeg -lm -ldl -o ../../build/_gfxprim_core.so
+ -fPIC -lGP -lpng -ljpeg -lm -ldl -o ../../build/_gfxprim_core.so
mv gfxprim_core.py ../../build/
rm gfxprim_core_wrap.c
diff --git a/include/loaders/swigify.sh b/include/loaders/swigify.sh
index 3308274..eb985f1 100755
--- a/include/loaders/swigify.sh
+++ b/include/loaders/swigify.sh
@@ -2,7 +2,7 @@ set -e
swig -python -Wall -I/usr/include/ gfxprim_loaders.swig
gcc -shared gfxprim_loaders_wrap.c -L ../../build/ -I /usr/include/python2.6/ -I.. - -lGP -lpng -ljpeg -lm -ldl -o ../../build/_gfxprim_loaders.so
+ -fPIC -lGP -lpng -ljpeg -lm -ldl -o ../../build/_gfxprim_loaders.so
mv gfxprim_loaders.py ../../build/
rm gfxprim_loaders_wrap.c
-----------------------------------------------------------------------
Summary of changes:
include/core/swigify.sh | 2 +-
include/loaders/swigify.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 31c18f79b0e5a2b49f3ad6315ab7605935b2fc56 (commit)
via 60a70cbf7bc06c6485f71f726ef1a5bb76469c05 (commit)
from 8b760eccced962d0cb0549dee86778454483671a (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/31c18f79b0e5a2b49f3ad6315ab7605935b2…
commit 31c18f79b0e5a2b49f3ad6315ab7605935b2fc56
Merge: 60a70cb 8b760ec
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Nov 22 23:02:10 2011 +0100
Merge branch 'master' of git://repo.or.cz/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/60a70cbf7bc06c6485f71f726ef1a5bb7646…
commit 60a70cbf7bc06c6485f71f726ef1a5bb76469c05
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Nov 22 23:01:41 2011 +0100
Add building core tests as a default dependency
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 7199ad2..1ee793a 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -5,6 +5,8 @@ TESTSUITE=core_suite
LDLIBS+=-lGP -L$(TOPDIR)/build/ -lcheck -lpng -ljpeg -lm -ldl
GENSOURCES+=GP_Convert.test.gen.c GP_WritePixel.test.gen.c
+all: $(TESTSUITE)
+
include $(TOPDIR)/tests.mk
include $(TOPDIR)/include.mk
-----------------------------------------------------------------------
Summary of changes:
tests/core/Makefile | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")