void printVariableMap(std::ostream & o, const VariableMap & vars) { for ( VariableMap::const_iterator it = vars.begin(); it != vars.end();++it) { it->second.print(o); o << " "; } }
bool SUIPictureList::SetProperties( VariableMap args ) { for(VariableMap::iterator iter = args.begin(); iter != args.end(); iter++) { properties[iter->first] = iter->second; } return true; }
bool SScriptManager::SetSystemVariables( VariableMap setVars ) { for(VariableMap::iterator iter = setVars.begin(); iter != setVars.end(); iter++) { systemVariables[iter->first] = iter->second; } return true; }
bool SScriptManager::InitializeSystemVariables( VariableMap setVars ) { for(VariableMap::iterator iter = setVars.begin(); iter != setVars.end(); iter++) { if (systemVariables.find(iter->first) == systemVariables.end()) { systemVariables[iter->first] = iter->second;; } } return true; }
void Unify::SpecialMapCompression(VariableMap& v_map, const VariableMap& e_map, const VariableMap& o_v_map) { VariableMap out; for(VariableMap::const_iterator it = e_map.begin();it != e_map.end();it++) { const Argument* temp = it->second; if(temp->IsVariable()) { temp = v_map.find(temp)->second; } out[it->first] = temp; } for(VariableMap::const_iterator it = o_v_map.begin();it != o_v_map.end();it++) { out[it->first] = it->second; } v_map = out; }
bool KeyboardLayout::_SubstituteVariables(BString& term, VariableMap& variables, BString& unknown) { while (true) { int32 index = term.FindFirst('$'); if (index < 0) break; // find variable name VariableMap::iterator iterator = variables.begin(); VariableMap::iterator best = variables.end(); int32 bestLength = 0; for (; iterator != variables.end(); iterator++) { const BString& name = iterator->first; if (!name.Compare(&term[index], name.Length()) && name.Length() > bestLength) { best = iterator; bestLength = name.Length(); } } if (best != variables.end()) { // got one, replace it term.Remove(index, bestLength); term.Insert(best->second.String(), index); } else { // variable has not been found unknown = &term[index]; int32 length = 1; while (isalpha(unknown[length])) { length++; } unknown.Truncate(length); return false; } } return true; }
void nsPluginInstance::threadMain(void) { DBG("nsPluginInstance::threadMain started\n"); DBG("URL: %s\n", _url.c_str()); PR_Lock(playerLock); // Initialize Gnash core library. DBG("Gnash core initialized.\n"); // Init logfile. gnash::RcInitFile& rcinit = gnash::RcInitFile::getDefaultInstance(); std::string logfilename = std::string("T:npgnash.log"); rcinit.setDebugLog(logfilename); gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance(); dbglogfile.setWriteDisk(true); dbglogfile.setVerbosity(GNASH_DEBUG_LEVEL); DBG("Gnash logging initialized: %s\n", logfilename.c_str()); // Init sound. //_sound_handler.reset(gnash::sound::create_sound_handler_sdl()); //gnash::set_sound_handler(_sound_handler.get()); DBG("Gnash sound initialized.\n"); // Init GUI. int old_mouse_x = 0, old_mouse_y = 0, old_mouse_buttons = 0; _render_handler = (gnash::render_handler *) gnash::create_render_handler_agg("BGR24"); // _memaddr = (unsigned char *) malloc(getMemSize()); static_cast<gnash::render_handler_agg_base *>(_render_handler)->init_buffer( getMemAddr(), getMemSize(), _width, _height, _rowstride); gnash::set_render_handler(_render_handler); DBG("Gnash GUI initialized: %ux%u\n", _width, _height); gnash::URL url(_url); VariableMap vars; gnash::URL::parse_querystring(url.querystring(), vars); for (VariableMap::iterator i = vars.begin(), ie = vars.end(); i != ie; i++) { _flashVars[i->first] = i->second; } gnash::set_base_url(url); gnash::movie_definition* md = NULL; try { md = gnash::createMovie(url, _url.c_str(), false); } catch (const gnash::GnashException& err) { md = NULL; } if (!md) { /* * N.B. Can't use the goto here, as C++ complains about "jump to * label 'done' from here crosses initialization of ..." a bunch * of things. Sigh. So, instead, I duplicate the cleanup code * here. TODO: Remove this duplication. */ // goto done; PR_Unlock(playerLock); DBG("Clean up Gnash.\n"); //gnash::clear(); DBG("nsPluginInstance::threadMain exiting\n"); return; } DBG("Movie created: %s\n", _url.c_str()); int movie_width = static_cast<int>(md->get_width_pixels()); int movie_height = static_cast<int>(md->get_height_pixels()); float movie_fps = md->get_frame_rate(); DBG("Movie dimensions: %ux%u (%.2f fps)\n", movie_width, movie_height, movie_fps); gnash::SystemClock clock; // use system clock here... gnash::movie_root& root = gnash::VM::init(*md, clock).getRoot(); DBG("Gnash VM initialized.\n"); // Register this plugin as listener for FsCommands from the core // (movie_root) #if 0 /* Commenting out for now as registerFSCommandCallback() has changed. */ root.registerFSCommandCallback(FSCommand_callback); #endif // Register a static function to handle ActionScript events such // as Mouse.hide, Stage.align etc. // root.registerEventCallback(&staticEventHandlingFunction); md->completeLoad(); DBG("Movie loaded.\n"); std::auto_ptr<gnash::Movie> mr(md->createMovie()); mr->setVariables(_flashVars); root.setRootMovie(mr.release()); //root.set_display_viewport(0, 0, _width, _height); root.set_background_alpha(1.0f); gnash::Movie* mi = root.getRootMovie(); DBG("Movie instance created.\n"); //ShowWindow(_window, SW_SHOW); IIntuition->ShowWindow(_window,NULL); for (;;) { // DBG("Inside main thread loop.\n"); if (_shutdown) { DBG("Main thread shutting down.\n"); break; } size_t cur_frame = mi->get_current_frame(); // DBG("Got current frame number: %d.\n", cur_frame); size_t tot_frames = mi->get_frame_count(); // DBG("Got total frame count: %d.\n", tot_frames); // DBG("Advancing one frame.\n"); root.advance(); // DBG("Going to next frame.\n"); root.goto_frame(cur_frame + 1); // DBG("Ensuring frame is loaded.\n"); //root.get_movie_definition()->ensure_frame_loaded(tot_frames); // DBG("Setting play state to PLAY.\n"); root.set_play_state(gnash::MovieClip::PLAYSTATE_PLAY); if (old_mouse_x != mouse_x || old_mouse_y != mouse_y) { old_mouse_x = mouse_x; old_mouse_y = mouse_y; //root.notify_mouse_moved(mouse_x, mouse_y); } if (old_mouse_buttons != mouse_buttons) { old_mouse_buttons = mouse_buttons; int mask = 1; //root.notify_mouse_clicked(mouse_buttons > 0, mask); } root.display(); #if 0 RECT rt; GetClientRect(_window, &rt); InvalidateRect(_window, &rt, FALSE); InvalidatedRanges ranges; ranges.setSnapFactor(1.3f); ranges.setSingleMode(false); root.add_invalidated_bounds(ranges, false); ranges.growBy(40.0f); ranges.combine_ranges(); if (!ranges.isNull()) { InvalidateRect(_window, &rt, FALSE); } root.display(); #endif // DBG("Unlocking playerLock mutex.\n"); PR_Unlock(playerLock); // DBG("Sleeping.\n"); PR_Sleep(PR_INTERVAL_MIN); // DBG("Acquiring playerLock mutex.\n"); PR_Lock(playerLock); } done: PR_Unlock(playerLock); DBG("Clean up Gnash.\n"); /* * N.B. As per server/impl.cpp:clear(), all of Gnash's threads aren't * guaranteed to be terminated by this, yet. Therefore, when Firefox * unloads npgnash.dll after calling NS_PluginShutdown(), and there are * still Gnash threads running, they will try and access memory that was * freed as part of the unloading of npgnash.dll, resulting in a process * abend. */ //gnash::clear(); DBG("nsPluginInstance::threadMain exiting\n"); }