8000 start adding enums · libvips/pyvips@37f284d · GitHub
[go: up one dir, main page]

Skip to content

Commit 37f284d

Browse files
committed
start adding enums
test_arithmetic.py runs now, but fails on every test heh need getattr on the Image class
1 parent 570108f commit 37f284d

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

pyvips/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# wrapper for libvips
22

33
# Our classes need to refer to each other ... make them go via this
4-
# package-level global which we update at the end with the real classes
4+
# package-level global which we update at the end with references to the real
5+
# classes
56
package_index = {
67
'Image': 'banana',
78
'Operation': 'apple',
89
'GValue': 'kumquat'
910
}
1011

1112
from base import *
13+
from enums import *
1214
from gvalue import GValue
1315
from gobject import GObject
1416
from vobject import VipsObject

pyvips/base.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
typedef struct _VipsImage VipsImage;
4343
typedef struct _GValue GValue;
4444
45-
void* g_malloc(size_t size);
46-
void g_free(void* data);
45+
void* g_malloc (size_t size);
46+
void g_free (void* data);
47+
48+
int vips_leak_set (int leak);
4749
4850
''')
4951

@@ -76,4 +78,8 @@ def __str__(self):
7678
def g_free_callback(ptr):
7779
gobject_lib.g_free(ptr)
7880

79-
__all__ = ['ffi', 'g_free_callback', 'vips_lib', 'gobject_lib', 'Error']
81+
def leak_set(leak):
82+
return vips_lib.vips_leak_set(leak)
83+
84+
__all__ = ['ffi', 'g_free_callback', 'vips_lib', 'gobject_lib', 'Error',
85+
'leak_set']

pyvips/enums.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# enums
2+
3+
from __future__ import division
4+
5+
import logging
6+
7+
logger = logging.getLogger(__name__)
8+
9+
# you can supply enum values as strings or ints ... these classes give the ints
10+
# for each string, so pyvips.BandFormat.SHORT is equivalent to "short"
11+
12+
class BandFormat(object):
13+
UCHAR = 0
14+
CHAR = 1
15+
USHORT = 2
16+
SHORT = 3
17+
UINT = 4
18+
INT = 5
19+
FLOAT = 6
20+
COMPLEX = 7
21+
DOUBLE = 8
22+
DPCOMPLEX = 9
23+
24+
def __eq__(self, other):
25+
print 'BANANA !!!'

0 commit comments

Comments
 (0)
0