/* -*-c-file-style: "bsd" -*- */ /* * chicken_plugin.cpp * * * * Version $Revision$ * */ #ifndef _CHICKEN_PLUGIN_H #include #endif extern "C" Plugin::Object *createRTXIPlugin(void *) { return new ChickenPlugin(); } /* * * Default constructor * */ ChickenPlugin::ChickenPlugin(void) { int status; wm = Workspace::Manager::getInstance(); if ((status = CHICKEN_initialize (0, 0, 0, (void*)C_toplevel)) == 0) return; menuID = MainWindow::getInstance()->createControlMenuItem("Scheme Controller",this,SLOT(run(void))); } /* * * Destroys the object * */ ChickenPlugin::~ChickenPlugin(void) { MainWindow::getInstance()->removeControlMenuItem(menuID); } void ChickenPlugin::run(void) { C_word result = C_SCHEME_UNDEFINED; int status; status = CHICKEN_eval_string("(repl)", &result); } struct cmp_t { char *name; Workspace::Instance *x; }; void find (Workspace::Instance *w, cmp_t *ax) { IO::Block *b; b = (IO::Block *)w; if (strcmp((b->getName()).c_str(), ax->name) == 0) ax->x = w; } ChickenWorkspace *ChickenPlugin::getWorkspace (char *name) { struct cmp_t ax; ax.name = name; ax.x = NULL; wm->foreachWorkspace ((void (*)(Workspace::Instance*, void*))find, &ax); return (new ChickenWorkspace(ax.x)); } static Mutex mutex; ChickenPlugin *ChickenPlugin::instance = 0; ChickenPlugin *ChickenPlugin::getInstance(void) { if(instance) return instance; Mutex::Locker lock(&::mutex); if(!instance) { static ChickenPlugin plugin; instance = &plugin; } return instance; } ChickenWorkspace::ChickenWorkspace (Workspace::Instance *w) { this->w = w; } size_t ChickenWorkspace::getCount(flags_t type) { return w->getCount(type); } const char *ChickenWorkspace::getName(flags_t type, size_t index) { return (w->getName(type,index)).c_str(); } double ChickenWorkspace::getValue(flags_t type,size_t index) { return w->getValue(type,index); } void ChickenWorkspace::setValue(size_t index,double value) { w->setValue(index,value); } ChickenWorkspace *getChickenWorkspace (char *name) { return (ChickenPlugin::getInstance())->getWorkspace(name); } int isWorkspaceNull (ChickenWorkspace *x) { if (x==NULL) return 1; else return 0; } /* * $Id$ * * * $Log$ * */