Re: [Ficl-developers] output function state?
Brought to you by:
jsadler
From: john s. <joh...@al...> - 2001-11-30 21:52:14
|
That's what the pExtend or context pointer is for. Please use pVM->pExtend - I'm getting rid of context because they are both for the same purpose. - John At 11/30/01 11:29 AM, Michel Pelletier wrote: >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 > >_______________________________________________ >Ficl-developers mailing list >Fic...@li... >https://lists.sourceforge.net/lists/listinfo/ficl-developers John Sadler - joh...@al... T 650-595-4954 F 603-687-2885 C 415-271-6795 |