[Ficl-developers] poping values off the vm stack?
Brought to you by:
jsadler
From: Michel P. <mi...@zo...> - 2001-11-30 02:07:56
|
I never saw my last message come to the list, so for anyone who was thinking of answering it don't bother, I figured out my problem. If you didn't see it than don't worry about it. The current fun little thing I"m working on is embedding ficl in Python. I have it working pretty well at the moment, I can create vms and evalute python strings containing forth code, and I can also push integers onto the stack from python, but I can't figure out how to pop them. That's my question. I have these two C functions: static PyObject * FiclVM_pushint(FiclVMObject *self, PyObject *args) { int x; if (!PyArg_ParseTuple(args, "i:pushInt", &x)) return NULL; vmPush(self->ficl_vm, LVALUEtoCELL(x)); Py_INCREF(Py_None); return Py_None; } static PyObject * FiclVM_popint(FiclVMObject *self, PyObject *args) { CELL c; PyObject *i; if (!PyArg_ParseTuple(args, ":pushInt")) return NULL; c = vmPop(self->ficl_vm); i = PyInt_FromLong((long)&c); Py_INCREF(i); return i; } The first function works fine and pushes the right integer onto the Forth stack. The second function does return a valid python integer but when I push '5' I get '-1758473533' or whatever back. How can I turn 'c' into the right integer value? PyInt_FromLong expects a long value. Thanks, -Michel |