[Ficl-developers] output function state?
Brought to you by:
jsadler
From: Michel P. <mi...@zo...> - 2001-11-30 19:28:41
|
The output function doesn't maintain any state, so I'm not sure how I can associate an output file (which is a pointer to a python object) with the output of a Ficl VM. Here's my code: typedef struct { PyObject_HEAD FICL_VM *ficl_vm; PyObject *out_file; } FiclVMObject; static FiclVMObject * newFiclVMObject(PyObject *arg) { FiclVMObject *self; PyObject *sys; PyObject *d; PyObject *outf; self = PyObject_New(FiclVMObject, &FiclVM_Type); if (self == NULL) return NULL; self->ficl_vm = ficlNewVM(my_system); /* Bind the output to sys.stdout */ sys = PyImport_ImportModule("sys"); d = PyModule_GetDict(sys); outf = PyDict_GetItemString(d, "stdout"); Py_INCREF(outf); self->out_file = outf; /* Still need to figure out how to write Ficl output to file */ return self; } This works fine, but I don't see how any output function that is passed to self->ficl_vm can be told about self->out_file. Is this what the FICL_VM->context is for? -Michel |