Pre-python paper checkin

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@937 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-11-07 19:03:31 +00:00
commit 5803c0b61c
10 changed files with 225 additions and 21 deletions

View file

@ -19,6 +19,79 @@
static PyObject *segfault_exc = 0;
static PyObject *buserror_exc = 0;
static PyObject *abort_exc = 0;
static PyObject *illegal_exc = 0;
/* Function return points and values */
static WadReturnFunc retpts[] = {
{"call_builtin", 0},
{"_PyImport_LoadDynamicModule", 0},
{"PyEval_EvalCode", 0},
{"PyObject_GetAttrString", 0},
{"PyObject_SetAttrString", -1},
{"PyObject_Repr", 0},
{"PyObject_Print", -1},
{"PyObject_CallFunction", 0},
{"PyObject_CallMethod", 0},
{"PyObject_CallObject", 0},
{"PyObject_Cmp", -1},
{"PyObject_Compare", -1},
{"PyObject_DelAttrString",-1},
{"PyObject_DelItem",-1},
{"PyObject_GetItem",0},
{"PyObject_SetItem",-1},
{"PyObject_HasAttrString",-1},
{"PyObject_Hash",-1},
{"PyObject_Length",-1},
{"PyObject_Str",0},
{"PyObject_Type", 0},
{"PyNumber_Absolute", 0},
{"PyNumber_Add",0},
{"PyNumber_And",0},
{"PyNumber_Coerce",0},
{"PyNumber_Divide",0},
{"PyNumber_Divmod",0},
{"PyNumber_Float",0},
{"PyNumber_Int",0},
{"PyNumber_Invert",0},
{"PyNumber_Long",0},
{"PyNumber_Lshift",0},
{"PyNumber_Multiply", 0},
{"PyNumber_Negative", 0},
{"PyNumber_Or",0},
{"PyNumber_Positive", 0},
{"PyNumber_Power",0},
{"PyNumber_Remainder",0},
{"PyNumber_Rshift",0},
{"PyNumber_Subtract",0},
{"PyNumber_Xor",0},
{"PySequence_Concat",0},
{"PySequence_Count",-1},
{"PySequence_Delitem",-1},
{"PySequence_DelSlice",-1},
{"PySequence_Getitem",0},
{"PySequence_GetSlice",0},
{"PySequence_In",-1},
{"PySequence_Index",-1},
{"PySequence_Repeat",0},
{"PySequence_SetItem",-1},
{"PySequence_SetSlice",-1},
{"PySequence_Tuple",0},
{"PyMapping_Clear",-1},
{"PyMapping_DelItem",-1},
{"PyMapping_DelItemString",-1},
{"PyMapping_GetItemString",0},
{"PyMapping_HasKey",-1},
{"PyMapping_HasKeyString",-1},
{"PyMapping_Items",0},
{"PyMapping_Keys",0},
{"PyMapping_Length", -1},
{"PyMapping_SetItemString", -1},
{"PyMapping_Values", 0},
{0,0}};
/* Handler function */
static void handler(int signo, WadFrame *frame, char *ret) {
@ -47,6 +120,12 @@ static void handler(int signo, WadFrame *frame, char *ret) {
case SIGABRT:
type = abort_exc;
break;
case SIGFPE:
type = PyExc_FloatingPointError;
break;
case SIGILL:
type = illegal_exc;
break;
default:
type = PyExc_RuntimeError;
break;
@ -144,12 +223,12 @@ static void pywadinit() {
abort_exc = PyErr_NewException((char*)"exceptions.AbortError", NULL, NULL);
PyDict_SetItemString(d,(char *)"AbortError",abort_exc);
illegal_exc = PyErr_NewException((char *)"exceptions.IllegalInstruction", NULL, NULL);
PyDict_SetItemString(d,(char *)"IllegalInstruction",illegal_exc);
wad_init();
wad_set_callback(handler);
wad_set_return((char *)"call_builtin",0);
wad_set_return((char *)"_PyImport_LoadDynamicModule",0);
wad_set_return((char *)"PyEval_EvalCode",0);
wad_set_return((char *)"PyObject_GetAttr",0);
wad_set_returns(retpts);
}
/* This hack is used to auto-initialize wad regardless of whether we are
@ -169,6 +248,6 @@ static PyMethodDef wadmethods[] = {
};
extern "C"
void initwad() {
Py_InitModule((char *)"wad",wadmethods);
void initlibwadpy() {
Py_InitModule((char *)"libwadpy",wadmethods);
}