1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

some swig code, needs more work

This commit is contained in:
tg(x) 2011-09-12 11:44:48 +02:00
parent 1c6225e057
commit 0990dbd863
5 changed files with 100 additions and 0 deletions

8
.gitignore vendored
View file

@ -18,6 +18,14 @@ test/testText
test/isRoutingVar test/isRoutingVar
test/getVarType test/getVarType
perl/*.c
perl/*.so
perl/*.pm
python/*.c
python/*.so
python/*.py
.config .config
~$* ~$*
.DS_Store .DS_Store

25
perl/Makefile Normal file
View file

@ -0,0 +1,25 @@
CFLAGS = -I../include -Wall -std=c99 -fPIC
SWIG = swig
PERL = perl
I = psyc.i
S = psyc_wrap.c
O = psyc_wrap.o
SO = PSYC.so
PM = PSYC.pm
PSYCO = ../src/packet.o ../src/parse.o ../src/match.o ../src/render.o ../src/memmem.o ../src/itoa.o ../src/variable.o ../src/text.o
all: swig lib
swig:
${SWIG} -I../include -perl5 $I
CFLAGS = ${CFLAGS_COMMON} $(shell ${PERL} -MConfig -e 'print join(" ", @Config{qw(ccflags optimize cccdlflags)}, "-I$$Config{archlib}/CORE")') -D_XOPEN_SOURCE
$O: $S
lib: $O
${MAKE} -C ../src ${PSYCO}
${CC} ${CFLAGS} $(shell ${PERL} -MConfig -e 'print $$Config{lddlflags}') ${PSYCO} $O -o ${SO}
clean:
rm -f $S $O ${SO} ${PM}

42
perl/psyc.i Normal file
View file

@ -0,0 +1,42 @@
%module PSYC
%{
/* Includes the headers in the wrapper code */
#include "psyc.h"
#include "psyc/packet.h"
#include "psyc/parse.h"
#include "psyc/render.h"
#include "psyc/syntax.h"
#include "psyc/text.h"
%}
/* Parse the headers to generate wrappers */
%include "cdata.i"
%rename("%(regex:/^PSYC_(.*)/\\1/)s") "";
%rename("%(regex:/^psyc_?(.*)/\\1/)s") "";
%rename("%(regex:/^psyc_(.*)2$/\\1/)s") "";
%apply (char *STRING, size_t LENGTH) { (const char *buffer, size_t length) };
%apply (char *STRING, size_t LENGTH) { (const char *name, size_t len) };
%apply (char *STRING, size_t LENGTH) { (const char *value, size_t len) };
// initTextState
%apply (char *STRING, size_t LENGTH) { (char *template, size_t tlen) };
%apply (char *STRING, size_t LENGTH) { (char *buffer, size_t blen) };
// setTextBrackets
%apply (char *STRING, size_t LENGTH) { (char *open, size_t openlen) };
%apply (char *STRING, size_t LENGTH) { (char *close, size_t closelen) };
//%apply (char *STRING, size_t LENGTH) { };
psycParseRC psyc_parse2 (psycParseState *state, char *oper,
char *name, size_t namelen,
char *value, size_t valuelen);
%include "psyc.h"
%include "psyc/packet.h"
%include "psyc/parse.h"
%include "psyc/render.h"
%include "psyc/syntax.h"
%include "psyc/text.h"

24
python/Makefile Normal file
View file

@ -0,0 +1,24 @@
CFLAGS = -Wall -std=c99 -fPIC -I../include $(shell ${PYTHON_CONFIG} --includes)
SWIG = swig
PYTHON_CONFIG = python-config
I = psyc.i
S = psyc_wrap.c
O = psyc_wrap.o
SO = _PSYC.so
PY = PSYC.py
PSYCO = ../src/packet.o ../src/parse.o ../src/match.o ../src/render.o ../src/memmem.o ../src/itoa.o ../src/variable.o ../src/text.o
all: swig lib
swig:
${SWIG} -I../include -python $I
$O: $S
lib: $O
${MAKE} -C ../src ${PSYCO}
${CC} -shared ${PSYCO} $O -o ${SO}
clean:
rm -f $S $O ${SO} ${PY} ${PY}c

1
python/psyc.i Symbolic link
View file

@ -0,0 +1 @@
../perl/psyc.i