*** empty log message ***
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@1018 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0b563336fd
commit
6ad55444c1
6 changed files with 93 additions and 76 deletions
51
Tools/WAD/Python/Makefile.in
Normal file
51
Tools/WAD/Python/Makefile.in
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#######################################################################
|
||||
# WAD Makefile
|
||||
#
|
||||
# David Beazley
|
||||
# January 1, 2001
|
||||
#######################################################################
|
||||
|
||||
# These are the files that make up the WAD core
|
||||
SRCS = python.c
|
||||
OBJS = python.o
|
||||
INCLUDE = -I../Include -I. $(SINCLUDE)
|
||||
WADOPT = @WADOPT@
|
||||
|
||||
# Location of your Python installation
|
||||
PYINCLUDE = @PYINCLUDE@
|
||||
PYSRCS = wadpyinit.cxx
|
||||
PYOBJS = wadpyinit.o
|
||||
|
||||
# C Compiler
|
||||
CC = @CC@
|
||||
CFLAGS = #@CCSHARED@
|
||||
|
||||
# C++ Compiler
|
||||
CXX = @CXX@
|
||||
CXXFLAGS = #@CXXSHARED@
|
||||
|
||||
# Linking options
|
||||
CLINK =
|
||||
CXXLINK = @CXXLINK@
|
||||
|
||||
# Rules for creation of a .o file from .cxx
|
||||
.SUFFIXES: .cxx
|
||||
.cxx.o:
|
||||
$(CXX) $(CXXFLAGS) $(WADOPT) $(INCLUDE) -c -o $*.o $<
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(PYINCLUDE) $(WADOPT) $(INCLUDE) -c -o $*.o $<
|
||||
|
||||
python: $(OBJS) $(PYOBJS)
|
||||
$(CXXLINK) $(OBJS) $(PYOBJS) -o libwadpy.so -L.. -lwadcore
|
||||
cp libwadpy.so ..
|
||||
|
||||
wc::
|
||||
wc $(SRCS)
|
||||
|
||||
clean::
|
||||
rm -f *.o *.so *~
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* wadpy.cxx
|
||||
* python.c
|
||||
*
|
||||
* Dynamically loadable python module for wad.
|
||||
*
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "Python.h"
|
||||
#include "wad.h"
|
||||
#include <signal.h>
|
||||
|
||||
/* These are the python exception objects we will add
|
||||
SegFault, BusError, AbortError */
|
||||
|
|
@ -220,7 +219,7 @@ static void handler(int signo, WadFrame *frame, char *ret) {
|
|||
PyErr_SetString(type, message);
|
||||
}
|
||||
|
||||
static void pywadinit() {
|
||||
void pywadinit() {
|
||||
PyObject *d, *m;
|
||||
m = PyImport_ImportModule((char *)"__builtin__");
|
||||
d = PyModule_GetDict(m);
|
||||
|
|
@ -243,23 +242,10 @@ static void pywadinit() {
|
|||
wad_set_returns(retpts);
|
||||
}
|
||||
|
||||
/* This hack is used to auto-initialize wad regardless of whether we are
|
||||
used as an imported module or as a link-library for another module */
|
||||
|
||||
class wadinitializer {
|
||||
public:
|
||||
wadinitializer() {
|
||||
pywadinit();
|
||||
}
|
||||
};
|
||||
|
||||
static wadinitializer wi;
|
||||
|
||||
static PyMethodDef wadmethods[] = {
|
||||
{0,0},
|
||||
};
|
||||
|
||||
extern "C"
|
||||
void initlibwadpy() {
|
||||
Py_InitModule((char *)"libwadpy",wadmethods);
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
%module wad
|
||||
%{
|
||||
#include "wad.h"
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
|
||||
extern jmp_buf Py_cerror;
|
||||
extern PyObject *Py_cerror_obj;
|
||||
|
||||
static PyObject *segfault_exc = 0;
|
||||
static PyObject *buserror_exc = 0;
|
||||
static PyObject *abort_exc = 0;
|
||||
|
||||
/* Handler function */
|
||||
static void handler(int signo, void *clientdata) {
|
||||
static char message[65536];
|
||||
int len = 0;
|
||||
PyObject *type;
|
||||
char *name;
|
||||
|
||||
strcpy(message,"[ C stack trace ]\n\n");
|
||||
switch(signo) {
|
||||
case SIGSEGV:
|
||||
type = segfault_exc;
|
||||
break;
|
||||
case SIGBUS:
|
||||
type = buserror_exc;
|
||||
break;
|
||||
case SIGABRT:
|
||||
type = abort_exc;
|
||||
break;
|
||||
default:
|
||||
type = PyExc_RuntimeError;
|
||||
break;
|
||||
}
|
||||
PyErr_SetString(type, message);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
%init %{
|
||||
wad_set_callback(handler);
|
||||
|
||||
wad_set_return("call_builtin", 0);
|
||||
|
||||
segfault_exc = PyErr_NewException("exceptions.SegFault", NULL, NULL);
|
||||
PyDict_SetItemString(d,"SegFault",segfault_exc);
|
||||
|
||||
buserror_exc = PyErr_NewException("exceptions.BusError", NULL, NULL);
|
||||
PyDict_SetItemString(d,"BusError",buserror_exc);
|
||||
|
||||
abort_exc = PyErr_NewException("exceptions.AbortError", NULL, NULL);
|
||||
PyDict_SetItemString(d,"AbortError",abort_exc);
|
||||
|
||||
%}
|
||||
|
||||
|
||||
28
Tools/WAD/Python/wadpyinit.cxx
Normal file
28
Tools/WAD/Python/wadpyinit.cxx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* wadpyinit.cxx
|
||||
*
|
||||
* C++ automatic initializer for Python module.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
||||
extern "C" void pywadinit();
|
||||
|
||||
/* This hack is used to auto-initialize wad regardless of whether we are
|
||||
used as an imported module or as a link-library for another module */
|
||||
|
||||
class wadinitializer {
|
||||
public:
|
||||
wadinitializer() {
|
||||
pywadinit();
|
||||
}
|
||||
};
|
||||
|
||||
static wadinitializer wi;
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ WADOPT = -DWAD_LINUX
|
|||
|
||||
# Location of your Python installation
|
||||
PYINCLUDE = -I/usr/local/include/python2.0
|
||||
PYSRCS = wadpy.cxx
|
||||
PYCSRCS = wadpyinit.cxx
|
||||
PYOBJS = wadpy.o
|
||||
|
||||
# Location of your Tcl installation
|
||||
|
|
@ -39,6 +39,9 @@ CXXFLAGS = #-fpic
|
|||
CLINK =
|
||||
CXXLINK = g++ -shared
|
||||
|
||||
# AR
|
||||
CC = ar
|
||||
|
||||
# Rules for creation of a .o file from .cxx
|
||||
.SUFFIXES: .cxx
|
||||
.cxx.o:
|
||||
|
|
@ -49,7 +52,9 @@ CXXLINK = g++ -shared
|
|||
|
||||
wad: $(WADOBJS) main.o
|
||||
$(CXXLINK) $(WADOBJS) main.o -o libwad.so
|
||||
$(AR) cr libwadcore.a $(WADOBJS)
|
||||
cp libwad.so ..
|
||||
cp libwadcore.a ..
|
||||
|
||||
python: $(WADOBJS) $(PYOBJS)
|
||||
$(CXXLINK) $(WADOBJS) $(PYOBJS) -o libwadpy.so
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ WADOPT = @WADOPT@
|
|||
|
||||
# Location of your Python installation
|
||||
PYINCLUDE = @PYINCLUDE@
|
||||
PYSRCS = wadpy.cxx
|
||||
PYCSRCS = wadpyinit.cxx
|
||||
PYOBJS = wadpy.o
|
||||
|
||||
# Location of your Tcl installation
|
||||
|
|
@ -38,6 +38,9 @@ CXXFLAGS = #@CXXSHARED@
|
|||
CLINK =
|
||||
CXXLINK = @CXXLINK@
|
||||
|
||||
# AR
|
||||
CC = @AR@
|
||||
|
||||
# Rules for creation of a .o file from .cxx
|
||||
.SUFFIXES: .cxx
|
||||
.cxx.o:
|
||||
|
|
@ -48,7 +51,9 @@ CXXLINK = @CXXLINK@
|
|||
|
||||
wad: $(WADOBJS) main.o
|
||||
$(CXXLINK) $(WADOBJS) main.o -o libwad.so
|
||||
$(AR) cr libwadcore.a $(WADOBJS)
|
||||
cp libwad.so ..
|
||||
cp libwadcore.a ..
|
||||
|
||||
python: $(WADOBJS) $(PYOBJS)
|
||||
$(CXXLINK) $(WADOBJS) $(PYOBJS) -o libwadpy.so
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue