summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-16 18:47:33 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-16 18:47:33 +0100
commit1be8e16191de38a54d706ad5ff99f20576e6ee71 (patch)
treeba32393ca42281c0c3857653d123e1b12999a896
parentadd todo list (diff)
downloadblueshift-1be8e16191de38a54d706ad5ff99f20576e6ee71.tar.gz
blueshift-1be8e16191de38a54d706ad5ff99f20576e6ee71.tar.bz2
blueshift-1be8e16191de38a54d706ad5ff99f20576e6ee71.tar.xz
beginning c binding
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--Makefile16
-rw-r--r--src/_blueshift_randr.pyx23
-rw-r--r--src/blueshift_randr_c.c (renamed from src/blueshift_randr.c)20
3 files changed, 35 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 97133b3..6aacca1 100644
--- a/Makefile
+++ b/Makefile
@@ -2,23 +2,31 @@ PKGCONFIG = pkg-config
OPTIMISE = -Og -g
WARN = -Wall -Wextra -pedantic
LIBS = xcb-randr
-STD = c90
+STD = c99
-FLAGS = $$($(PKGCONFIG) --cflags --libs $(LIBS)) -std=$(STD) $(WARN) $(OPTIMISE)
+FLAGS = $$($(PKGCONFIG) --cflags --libs $(LIBS)) -std=$(STD) $(WARN) $(OPTIMISE) -fPIC
.PHONY: all
all: bin/blueshift_randr
-bin/blueshift_randr: obj/blueshift_randr.o
+bin/blueshift_randr.so: obj/_blueshift_randr.o obj/blueshift_randr_c.o
@mkdir -p bin
- $(CC) $(FLAGS) -o $@ $^
+ $(CC) $(FLAGS) -shared -o $@ $^
obj/%.o: src/%.c
@mkdir -p obj
$(CC) $(FLAGS) -c -o $@ $<
+obj/%.o: obj/%.c
+ @mkdir -p obj
+ $(CC) $(FLAGS) -c -o $@ $<
+
+obj/_blueshift_randr.c: src/_blueshift_randr.pyx
+ cd src ; cython -3 $<
+ mv src/_blueshift_randr.c $@
+
.PHONY: all
clean:
diff --git a/src/_blueshift_randr.pyx b/src/_blueshift_randr.pyx
new file mode 100644
index 0000000..44fd4b6
--- /dev/null
+++ b/src/_blueshift_randr.pyx
@@ -0,0 +1,23 @@
+# -*- python -*-
+cdef extern int blueshift_randr_open(int use_screen)
+cdef extern int blueshift_randr_apply(unsigned long long int use_crtcs,
+ unsigned short int r_curve[256],
+ unsigned short int g_curve[256],
+ unsigned short int b_curve[256])
+cdef extern void blueshift_randr_close()
+
+
+def randr_open(int use_screen):
+ return blueshift_randr_open(use_screen)
+
+
+def randr_apply(unsigned long long int use_crtcs,
+ unsigned short int r_curve[256],
+ unsigned short int g_curve[256],
+ unsigned short int b_curve[256]):
+ return blueshift_randr_apply(use_crtcs, r_curve, g_curve, b_curve)
+
+
+def randr_close():
+ blueshift_randr_close()
+
diff --git a/src/blueshift_randr.c b/src/blueshift_randr_c.c
index 98ba2a3..bf2656e 100644
--- a/src/blueshift_randr.c
+++ b/src/blueshift_randr_c.c
@@ -290,23 +290,3 @@ void blueshift_randr_close(void)
xcb_disconnect(connection);
}
-
-
-int main(int argc, char** argv)
-{
- long i;
-
- (void) argc;
- (void) argv;
-
- if (blueshift_randr_open(0))
- return 1;
-
- for (i = 0; i < 256; i++)
- r_curve[i] = g_curve[i] = b_curve[i] = (int)((float)i / 255.f * (float)((1 << 16) - 1) + 0.f);
-
- i = blueshift_randr_apply(~0, r_curve, g_curve, b_curve);
- blueshift_randr_close();
- return i;
-}
-