/*! If a QAccessibleInterface implementation exists for the given \a object, this function returns a pointer to the implementation; otherwise it returns 0. The function calls all installed factory functions (from most recently installed to least recently installed) until one is found that provides an interface for the class of \a object. If no factory can provide an accessibility implementation for the class the function loads installed accessibility plugins, and tests if any of the plugins can provide the implementation. If no implementation for the object's class is available, the function tries to find an implementation for the object's parent class, using the above strategy. \warning The caller is responsible for deleting the returned interface after use. */ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) { accessibility_active = true; QAccessibleInterface *iface = 0; if (!object) return 0; QEvent e(QEvent::AccessibilityPrepare); QApplication::sendEvent(object, &e); const QMetaObject *mo = object->metaObject(); while (mo) { const QLatin1String cn(mo->className()); for (int i = qAccessibleFactories()->count(); i > 0; --i) { InterfaceFactory factory = qAccessibleFactories()->at(i - 1); iface = factory(cn, object); if (iface) return iface; } #ifndef QT_NO_LIBRARY QAccessibleFactoryInterface *factory = qobject_cast<QAccessibleFactoryInterface*>(loader()->instance(cn)); if (factory) { iface = factory->create(cn, object); if (iface) return iface; } #endif mo = mo->superClass(); } QWidget *widget = qobject_cast<QWidget*>(object); if (widget) return new QAccessibleWidget(widget); else if (object == qApp) return new QAccessibleApplication(); return 0; }
bool C4DefGraphics::Load(C4Group &hGroup, bool fColorByOwner) { char Filename[_MAX_PATH+1]; *Filename=0; C4DefGraphicsAdditionalResourcesLoader loader(hGroup); // load skeletons hGroup.ResetSearch(); while (hGroup.FindNextEntry("*", Filename, NULL, !!*Filename)) { if (!WildcardMatch(C4CFN_DefSkeleton, Filename) && !WildcardMatch(C4CFN_DefSkeletonXml, Filename)) continue; LoadSkeleton(hGroup, Filename, loader); } // Try from Mesh first if (!LoadMesh(hGroup, C4CFN_DefMesh, loader) && !LoadMesh(hGroup, C4CFN_DefMeshXml, loader) && !LoadBitmap(hGroup, C4CFN_DefGraphics, C4CFN_ClrByOwner, C4CFN_NormalMap, fColorByOwner)) return false; // load additional graphics C4DefGraphics *pLastGraphics = this; const int32_t iOverlayWildcardPos = SCharPos('*', C4CFN_ClrByOwnerEx); hGroup.ResetSearch(); *Filename=0; const char* const AdditionalGraphics[] = { C4CFN_DefGraphicsEx, C4CFN_DefGraphicsExMesh, C4CFN_DefGraphicsExMeshXml, NULL }; while (hGroup.FindNextEntry("*", Filename, NULL, !!*Filename)) { for(const char* const* szWildcard = AdditionalGraphics; *szWildcard != NULL; ++szWildcard) { if(!WildcardMatch(*szWildcard, Filename)) continue; // skip def graphics if (SEqualNoCase(Filename, C4CFN_DefGraphics) || SEqualNoCase(Filename, C4CFN_DefMesh) || SEqualNoCase(Filename, C4CFN_DefMeshXml)) continue; // skip scaled def graphics if (WildcardMatch(C4CFN_DefGraphicsScaled, Filename)) continue; // get name char GrpName[_MAX_PATH+1]; const int32_t iWildcardPos = SCharPos('*', *szWildcard); SCopy(Filename + iWildcardPos, GrpName, _MAX_PATH); RemoveExtension(GrpName); // remove trailing number for scaled graphics int32_t extpos; int scale; if ((extpos = SCharLastPos('.', GrpName)) > -1) if (sscanf(GrpName+extpos+1, "%d", &scale) == 1) GrpName[extpos] = '\0'; // clip to max length GrpName[C4MaxName]=0; // create new graphics pLastGraphics->pNext = new C4AdditionalDefGraphics(pDef, GrpName); pLastGraphics = pLastGraphics->pNext; if(*szWildcard == AdditionalGraphics[0]) { // create overlay-filename char OverlayFn[_MAX_PATH+1]; if(fColorByOwner) { // GraphicsX.png -> OverlayX.png SCopy(C4CFN_ClrByOwnerEx, OverlayFn, _MAX_PATH); OverlayFn[iOverlayWildcardPos]=0; SAppend(Filename + iWildcardPos, OverlayFn); EnforceExtension(OverlayFn, GetExtension(C4CFN_ClrByOwnerEx)); } // create normal filename char NormalFn[_MAX_PATH+1]; SCopy(C4CFN_NormalMapEx, NormalFn, _MAX_PATH); NormalFn[iOverlayWildcardPos]=0; SAppend(Filename + iWildcardPos, NormalFn); EnforceExtension(NormalFn, GetExtension(C4CFN_NormalMapEx)); // load them if (!pLastGraphics->LoadBitmap(hGroup, Filename, fColorByOwner ? OverlayFn : NULL, NormalFn, fColorByOwner)) return false; } else { if (!pLastGraphics->LoadMesh(hGroup, Filename, loader)) return false; } } } // done, success return true; }
void g1_model_list_class::add_model(const i4_str& model_name, r1_texture_manager_class * tmap) { //Ensure we're running. if (total_models==0 || array==NULL) { return; } total_models++; array=(model_info *)I4_REALLOC(array,total_models * sizeof(model_info), "model list extension"); int actual_total=total_models-1; g1_quad_object_loader_class loader(g1_object_heap); char nbuf[MAX_PATH]; //A string of the form "objects/%s.gmod" li_object * fmt=li_get_value("object_format", 0); char * n=li_string::get(fmt,0)->value(); sprintf(nbuf,n,model_name.c_str()); i4_file_class * in_file=i4_open(nbuf); if (in_file) { g1_loader_class * fp=g1_open_save_file(in_file); pf_model_load_open.stop(); if (fp) { array[actual_total].model=loader.load(fp, model_name, tmap); if (array[actual_total].model) { i4_filename_struct fn; i4_split_path(model_name, fn); array[actual_total].model->scale(model_scaling); // copy the name into the name buffer int len=strlen(fn.filename)+1; char * c=(char *)name_buffer->malloc(len, "name"); strcpy(c, fn.filename); array[actual_total].name_start=c; actual_total++; } delete fp; } else { i4_alert(i4gets("old_model_file"),200, model_name); } } else { pf_model_load_open.stop(); i4_alert(i4gets("file_missing"), 200, model_name); } total_models=actual_total; qsort(array, total_models, sizeof(model_info), g1_model_info_compare); // reset the model_reference values for (g1_model_ref * mi=model_references; mi; mi=mi->next) { mi->value=find_handle(mi->name); } }
int TailsAdvData::load(const Tbyte* data) { /* A VERY LONG SEQUENCE OF LOADS GOES HERE */ int dataAddr = 0; LoadHelper loader(data, dataAddr); // Throw if load data is invalid if ((loader.id() != DataChunkIDs::fileStart) || (loader.version() != 0)) { throw InvalidLoadDataException(TALES_SRCANDLINE, "TailsAdvData::load(const Tbyte*)"); } loader.readHeader(data + dataAddr); while (loader.id() != DataChunkIDs::fileEnd) { // Load appropriate data switch (loader.id()) { case DataChunkIDs::standardPalettes: dataAddr += standardPalettes_.load(data + dataAddr); break; case DataChunkIDs::paletteCycles: dataAddr += paletteCycles_.load(data + dataAddr); break; case DataChunkIDs::levelEffectsHeaders: dataAddr += levelEffectsHeaders_.load(data + dataAddr); break; case DataChunkIDs::levelPaletteHeaders: dataAddr += levelPaletteHeaders_.load(data + dataAddr); break; case DataChunkIDs::levelGraphicsData: dataAddr += levelGraphicsData_.load(data + dataAddr); break; case DataChunkIDs::tileMaps: dataAddr += tileMaps_.load(data + dataAddr); break; case DataChunkIDs::leafGraphicsTable: dataAddr += leafGraphicsTable_.load(data + dataAddr); break; case DataChunkIDs::waterSplashGraphicTable: dataAddr += waterSplashGraphicTable_.load(data + dataAddr); break; case DataChunkIDs::smokePuffGraphicTable: dataAddr += smokePuffGraphicTable_.load(data + dataAddr); break; case DataChunkIDs::spriteMappings: dataAddr += spriteMappings_.load(data + dataAddr); break; case DataChunkIDs::musicAssignments: dataAddr += musicAssignments_.load(data + dataAddr); break; case DataChunkIDs::radioMusic: dataAddr += radioMusic_.load(data + dataAddr); break; case DataChunkIDs::powerUpData: dataAddr += powerUpData_.load(data + dataAddr); break; case DataChunkIDs::emeraldHealthRefills: dataAddr += emeraldHealthRefills_.load(data + dataAddr); break; case DataChunkIDs::metatileWidthMaps: dataAddr += metatileWidthMaps_.load(data + dataAddr); break; case DataChunkIDs::metatileHeightMaps: dataAddr += metatileHeightMaps_.load(data + dataAddr); break; case DataChunkIDs::slopeSpeedValues: dataAddr += slopeSpeedValues_.load(data + dataAddr); break; case DataChunkIDs::metatileBehaviors: dataAddr += metatileBehaviors_.load(data + dataAddr); break; case DataChunkIDs::spawnPoints: dataAddr += spawnPoints_.load(data + dataAddr); break; case DataChunkIDs::warpDestinations: dataAddr += warpDestinations_.load(data + dataAddr); break; case DataChunkIDs::levelObjectEntryGroups: dataAddr += levelObjectEntryGroups_.load(data + dataAddr); break; case DataChunkIDs::mapData: dataAddr += mapData_.load(data + dataAddr); break; default: std::cerr << "ERROR: unrecognized chunk type " << loader.id() << ": skipping" << std::endl; loader.readHeader(data, dataAddr); dataAddr += loader.size(); break; } // std::cout << std::hex << dataAddr << std::endl; // Read header (but do not advance getpos; we want the chunk we load // to be able to reread it) loader.readHeader(data + dataAddr); } // Skip fileEnd marker loader.readHeader(data, dataAddr); // dataAddr += loader.size(); /* dataAddr += standardPalettes_.load(data + dataAddr); dataAddr += paletteCycles_.load(data + dataAddr); dataAddr += levelEffectsHeaders_.load(data + dataAddr); dataAddr += levelPaletteHeaders_.load(data + dataAddr); dataAddr += levelGraphicsData_.load(data + dataAddr); dataAddr += spriteMappings_.load(data + dataAddr); dataAddr += musicAssignments_.load(data + dataAddr); dataAddr += radioMusic_.load(data + dataAddr); dataAddr += powerUpData_.load(data + dataAddr); dataAddr += emeraldHealthRefills_.load(data + dataAddr); dataAddr += metatileWidthMaps_.load(data + dataAddr); dataAddr += metatileHeightMaps_.load(data + dataAddr); dataAddr += slopeSpeedValues_.load(data + dataAddr); dataAddr += metatileBehaviors_.load(data + dataAddr); dataAddr += spawnPoints_.load(data + dataAddr); dataAddr += warpDestinations_.load(data + dataAddr); dataAddr += levelObjectEntryGroups_.load(data + dataAddr); dataAddr += mapData_.load(data + dataAddr); */ return dataAddr; }
// ------------------------------------------------------------------ // ciEnv::get_klass_by_name_impl ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, constantPoolHandle cpool, ciSymbol* name, bool require_local) { ASSERT_IN_VM; EXCEPTION_CONTEXT; // Now we need to check the SystemDictionary Symbol* sym = name->get_symbol(); if (sym->byte_at(0) == 'L' && sym->byte_at(sym->utf8_length()-1) == ';') { // This is a name from a signature. Strip off the trimmings. // Call recursive to keep scope of strippedsym. TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, sym->utf8_length()-2, KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass)); ciSymbol* strippedname = get_symbol(strippedsym); return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local); } // Check for prior unloaded klass. The SystemDictionary's answers // can vary over time but the compiler needs consistency. ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name); if (unloaded_klass != NULL) { if (require_local) return NULL; return unloaded_klass; } Handle loader(THREAD, (oop)NULL); Handle domain(THREAD, (oop)NULL); if (accessing_klass != NULL) { loader = Handle(THREAD, accessing_klass->loader()); domain = Handle(THREAD, accessing_klass->protection_domain()); } // setup up the proper type to return on OOM ciKlass* fail_type; if (sym->byte_at(0) == '[') { fail_type = _unloaded_ciobjarrayklass; } else { fail_type = _unloaded_ciinstance_klass; } KlassHandle found_klass; { ttyUnlocker ttyul; // release tty lock to avoid ordering problems MutexLocker ml(Compile_lock); Klass* kls; if (!require_local) { kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, KILL_COMPILE_ON_FATAL_(fail_type)); } else { kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, KILL_COMPILE_ON_FATAL_(fail_type)); } found_klass = KlassHandle(THREAD, kls); } // If we fail to find an array klass, look again for its element type. // The element type may be available either locally or via constraints. // In either case, if we can find the element type in the system dictionary, // we must build an array type around it. The CI requires array klasses // to be loaded if their element klasses are loaded, except when memory // is exhausted. if (sym->byte_at(0) == '[' && (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { // We have an unloaded array. // Build it on the fly if the element class exists. TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, sym->utf8_length()-1, KILL_COMPILE_ON_FATAL_(fail_type)); // Get element ciKlass recursively. ciKlass* elem_klass = get_klass_by_name_impl(accessing_klass, cpool, get_symbol(elem_sym), require_local); if (elem_klass != NULL && elem_klass->is_loaded()) { // Now make an array for it return ciObjArrayKlass::make_impl(elem_klass); } } if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) { // Look inside the constant pool for pre-resolved class entries. for (int i = cpool->length() - 1; i >= 1; i--) { if (cpool->tag_at(i).is_klass()) { Klass* kls = cpool->resolved_klass_at(i); if (kls->name() == sym) { found_klass = KlassHandle(THREAD, kls); break; } } } } if (found_klass() != NULL) { // Found it. Build a CI handle. return get_klass(found_klass()); } if (require_local) return NULL; // Not yet loaded into the VM, or not governed by loader constraints. // Make a CI representative for it. return get_unloaded_klass(accessing_klass, name); }
QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key) { QGraphicsSystem *ret = 0; QString system = key.toLower(); #if defined (QT_GRAPHICSSYSTEM_OPENGL) if (system.isEmpty()) { system = QLatin1String("opengl"); } #elif defined (QT_GRAPHICSSYSTEM_OPENVG) && !defined(Q_CC_NOKIAX86) if (system.isEmpty()) { system = QLatin1String("openvg"); } #elif defined (QT_GRAPHICSSYSTEM_RUNTIME) if (system.isEmpty()) { system = QLatin1String("runtime"); } #elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) if (system.isEmpty()) { system = QLatin1String("raster"); } #endif if (system == QLatin1String("raster")) return new QRasterGraphicsSystem; #if !defined (QT_NO_GRAPHICSSYSTEM_HTML5CANVAS) && defined( EMSCRIPTEN ) if (system == QLatin1String("html5canvas")) return new QHtml5CanvasGraphicsSystem; #endif else if (system == QLatin1String("runtime")) return new QRuntimeGraphicsSystem; else if (system.isEmpty() || system == QLatin1String("native")) return 0; #ifndef QT_NO_LIBRARY if (!ret) { if (QGraphicsSystemFactoryInterface *factory = qobject_cast<QGraphicsSystemFactoryInterface*>(loader()->instance(system))) ret = factory->create(system); } #endif if (!ret) qWarning() << "Unable to load graphicssystem" << system; return ret; }
void PackArmPe::pack(OutputFile *fo) { // FIXME: we need to think about better support for --exact if (opt->exact) throwCantPackExact(); const unsigned objs = ih.objects; isection = new pe_section_t[objs]; fi->seek(pe_offset+sizeof(ih),SEEK_SET); fi->readx(isection,sizeof(pe_section_t)*objs); rvamin = isection[0].vaddr; infoHeader("[Processing %s, format %s, %d sections]", fn_basename(fi->getName()), getName(), objs); // check the PE header // FIXME: add more checks if (!opt->force && ( (ih.cpu != 0x1c0 && ih.cpu != 0x1c2) || (ih.opthdrsize != 0xe0) || ((ih.flags & EXECUTABLE) == 0) || (ih.subsystem != 9) || (ih.entry == 0 /*&& !isdll*/) || (ih.ddirsentries != 16) // || IDSIZE(PEDIR_EXCEPTION) // is this used on arm? // || IDSIZE(PEDIR_COPYRIGHT) )) throwCantPack("unexpected value in PE header (try --force)"); if (IDSIZE(PEDIR_SEC)) IDSIZE(PEDIR_SEC) = IDADDR(PEDIR_SEC) = 0; // throwCantPack("compressing certificate info is not supported"); if (IDSIZE(PEDIR_COMRT)) throwCantPack(".NET files (win32/net) are not yet supported"); if (isdll) opt->win32_pe.strip_relocs = false; else if (opt->win32_pe.strip_relocs < 0) opt->win32_pe.strip_relocs = (ih.imagebase >= 0x10000); if (opt->win32_pe.strip_relocs) { if (ih.imagebase < 0x10000) throwCantPack("--strip-relocs is not allowed when imagebase < 0x10000"); else ih.flags |= RELOCS_STRIPPED; } if (memcmp(isection[0].name,"UPX",3) == 0) throwAlreadyPackedByUPX(); if (!opt->force && IDSIZE(15)) throwCantPack("file is possibly packed/protected (try --force)"); if (ih.entry && ih.entry < rvamin) throwCantPack("run a virus scanner on this file!"); if (!opt->force && ih.subsystem == 1) throwCantPack("subsystem 'native' is not supported (try --force)"); if (ih.filealign < 0x200) throwCantPack("filealign < 0x200 is not yet supported"); handleStub(fi,fo,pe_offset); const unsigned usize = ih.imagesize; const unsigned xtrasize = UPX_MAX(ih.datasize, 65536u) + IDSIZE(PEDIR_IMPORT) + IDSIZE(PEDIR_BOUNDIM) + IDSIZE(PEDIR_IAT) + IDSIZE(PEDIR_DELAYIMP) + IDSIZE(PEDIR_RELOC); ibuf.alloc(usize + xtrasize); // BOUND IMPORT support. FIXME: is this ok? fi->seek(0,SEEK_SET); fi->readx(ibuf,isection[0].rawdataptr); Interval holes(ibuf); unsigned ic,jc,overlaystart = 0; ibuf.clear(0, usize); for (ic = jc = 0; ic < objs; ic++) { if (isection[ic].rawdataptr && overlaystart < isection[ic].rawdataptr + isection[ic].size) overlaystart = ALIGN_UP(isection[ic].rawdataptr + isection[ic].size,ih.filealign); if (isection[ic].vsize == 0) isection[ic].vsize = isection[ic].size; if ((isection[ic].flags & PEFL_BSS) || isection[ic].rawdataptr == 0 || (isection[ic].flags & PEFL_INFO)) { holes.add(isection[ic].vaddr,isection[ic].vsize); continue; } if (isection[ic].vaddr + isection[ic].size > usize) throwCantPack("section size problem"); if (((isection[ic].flags & (PEFL_WRITE|PEFL_SHARED)) == (PEFL_WRITE|PEFL_SHARED))) if (!opt->force) throwCantPack("writable shared sections not supported (try --force)"); if (jc && isection[ic].rawdataptr - jc > ih.filealign) throwCantPack("superfluous data between sections"); fi->seek(isection[ic].rawdataptr,SEEK_SET); jc = isection[ic].size; if (jc > isection[ic].vsize) jc = isection[ic].vsize; if (isection[ic].vsize == 0) // hack for some tricky programs - may this break other progs? jc = isection[ic].vsize = isection[ic].size; if (isection[ic].vaddr + jc > ibuf.getSize()) throwInternalError("buffer too small 1"); fi->readx(ibuf + isection[ic].vaddr,jc); jc += isection[ic].rawdataptr; } // check for NeoLite if (find(ibuf + ih.entry, 64+7, "NeoLite", 7) >= 0) throwCantPack("file is already compressed with another packer"); unsigned overlay = file_size - stripDebug(overlaystart); if (overlay >= (unsigned) file_size) { #if 0 if (overlay < file_size + ih.filealign) overlay = 0; else if (!opt->force) throwNotCompressible("overlay problem (try --force)"); #endif overlay = 0; } checkOverlay(overlay); Resource res; Interval tlsiv(ibuf); Export xport((char*)(unsigned char*)ibuf); const unsigned dllstrings = processImports(); processTls(&tlsiv); // call before processRelocs!! processResources(&res); processExports(&xport); processRelocs(); //OutputFile::dump("x1", ibuf, usize); // some checks for broken linkers - disable filter if necessary bool allow_filter = true; if (ih.codebase == ih.database || ih.codebase + ih.codesize > ih.imagesize || (isection[virta2objnum(ih.codebase,isection,objs)].flags & PEFL_CODE) == 0) allow_filter = false; const unsigned oam1 = ih.objectalign - 1; // FIXME: disabled: the uncompressor would not allocate enough memory //objs = tryremove(IDADDR(PEDIR_RELOC),objs); // FIXME: if the last object has a bss then this won't work // newvsize = (isection[objs-1].vaddr + isection[objs-1].size + oam1) &~ oam1; // temporary solution: unsigned newvsize = (isection[objs-1].vaddr + isection[objs-1].vsize + oam1) &~ oam1; //fprintf(stderr,"newvsize=%x objs=%d\n",newvsize,objs); if (newvsize + soimport + sorelocs > ibuf.getSize()) throwInternalError("buffer too small 2"); memcpy(ibuf+newvsize,oimport,soimport); memcpy(ibuf+newvsize+soimport,orelocs,sorelocs); cimports = newvsize - rvamin; // rva of preprocessed imports crelocs = cimports + soimport; // rva of preprocessed fixups ph.u_len = newvsize + soimport + sorelocs; // some extra data for uncompression support unsigned s = 0; upx_byte * const p1 = ibuf + ph.u_len; memcpy(p1 + s,&ih,sizeof (ih)); s += sizeof (ih); memcpy(p1 + s,isection,ih.objects * sizeof(*isection)); s += ih.objects * sizeof(*isection); if (soimport) { set_le32(p1 + s,cimports); set_le32(p1 + s + 4,dllstrings); s += 8; } if (sorelocs) { set_le32(p1 + s,crelocs); p1[s + 4] = (unsigned char) (big_relocs & 6); s += 5; } if (soresources) { set_le16(p1 + s,icondir_count); s += 2; } // end of extra data set_le32(p1 + s,ptr_diff(p1,ibuf) - rvamin); s += 4; ph.u_len += s; obuf.allocForCompression(ph.u_len); // prepare packheader ph.u_len -= rvamin; // prepare filter Filter ft(ph.level); ft.buf_len = ih.codesize; ft.addvalue = ih.codebase - rvamin; // compress int filter_strategy = allow_filter ? 0 : -3; // disable filters for files with broken headers if (ih.codebase + ih.codesize > ph.u_len) { ft.buf_len = 1; filter_strategy = -3; } // limit stack size needed for runtime decompression upx_compress_config_t cconf; cconf.reset(); cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack compressWithFilters(&ft, 2048, &cconf, filter_strategy, ih.codebase, rvamin, 0, NULL, 0); // info: see buildLoader() newvsize = (ph.u_len + rvamin + ph.overlap_overhead + oam1) &~ oam1; /* if (tlsindex && ((newvsize - ph.c_len - 1024 + oam1) &~ oam1) > tlsindex + 4) tlsindex = 0; */ const unsigned lsize = getLoaderSize(); int identsize = 0; const unsigned codesize = getLoaderSection("IDENTSTR",&identsize); assert(identsize > 0); getLoaderSection("UPX1HEAD",(int*)&ic); identsize += ic; pe_section_t osection[4]; // section 0 : bss // 1 : [ident + header] + packed_data + unpacker + tls // 2 : not compressed data // 3 : resource data -- wince 5 needs a new section for this // identsplit - number of ident + (upx header) bytes to put into the PE header int identsplit = pe_offset + sizeof(osection) + sizeof(oh); if ((identsplit & 0x1ff) == 0) identsplit = 0; else if (((identsplit + identsize) ^ identsplit) < 0x200) identsplit = identsize; else identsplit = ALIGN_GAP(identsplit, 0x200); ic = identsize - identsplit; const unsigned c_len = ((ph.c_len + ic) & 15) == 0 ? ph.c_len : ph.c_len + 16 - ((ph.c_len + ic) & 15); obuf.clear(ph.c_len, c_len - ph.c_len); const unsigned s1size = ALIGN_UP(ic + c_len + codesize,4u) + sotls; const unsigned s1addr = (newvsize - (ic + c_len) + oam1) &~ oam1; const unsigned ncsection = (s1addr + s1size + oam1) &~ oam1; const unsigned upxsection = s1addr + ic + c_len; Reloc rel(1024); // new relocations are put here static const char* symbols_to_relocate[] = { "ONAM", "BIMP", "BREL", "FIBE", "FIBS", "ENTR", "DST0", "SRC0" }; for (unsigned s2r = 0; s2r < TABLESIZE(symbols_to_relocate); s2r++) { unsigned off = linker->getSymbolOffset(symbols_to_relocate[s2r]); if (off != 0xdeaddead) rel.add(off + upxsection, 3); } // new PE header memcpy(&oh,&ih,sizeof(oh)); oh.filealign = 0x200; // identsplit depends on this memset(osection,0,sizeof(osection)); oh.entry = upxsection; oh.objects = 4; oh.chksum = 0; // fill the data directory ODADDR(PEDIR_DEBUG) = 0; ODSIZE(PEDIR_DEBUG) = 0; ODADDR(PEDIR_IAT) = 0; ODSIZE(PEDIR_IAT) = 0; ODADDR(PEDIR_BOUNDIM) = 0; ODSIZE(PEDIR_BOUNDIM) = 0; // tls is put into section 1 ic = s1addr + s1size - sotls; super::processTls(&rel,&tlsiv,ic); ODADDR(PEDIR_TLS) = sotls ? ic : 0; ODSIZE(PEDIR_TLS) = sotls ? 0x18 : 0; ic += sotls; // these are put into section 2 ic = ncsection; // wince wants relocation data at the beginning of a section processRelocs(&rel); ODADDR(PEDIR_RELOC) = soxrelocs ? ic : 0; ODSIZE(PEDIR_RELOC) = soxrelocs; ic += soxrelocs; processImports(ic, linker->getSymbolOffset("IATT") + upxsection); ODADDR(PEDIR_IMPORT) = ic; ODSIZE(PEDIR_IMPORT) = soimpdlls; ic += soimpdlls; processExports(&xport,ic); ODADDR(PEDIR_EXPORT) = soexport ? ic : 0; ODSIZE(PEDIR_EXPORT) = soexport; if (!isdll && opt->win32_pe.compress_exports) { ODADDR(PEDIR_EXPORT) = IDADDR(PEDIR_EXPORT); ODSIZE(PEDIR_EXPORT) = IDSIZE(PEDIR_EXPORT); } ic += soexport; ic = (ic + oam1) &~ oam1; const unsigned res_start = ic; if (soresources) processResources(&res,ic); ODADDR(PEDIR_RESOURCE) = soresources ? ic : 0; ODSIZE(PEDIR_RESOURCE) = soresources; ic += soresources; const unsigned onam = ncsection + soxrelocs + ih.imagebase; linker->defineSymbol("start_of_dll_names", onam); linker->defineSymbol("start_of_imports", ih.imagebase + rvamin + cimports); linker->defineSymbol("start_of_relocs", crelocs + rvamin + ih.imagebase); linker->defineSymbol("filter_buffer_end", ih.imagebase + ih.codebase + ih.codesize); linker->defineSymbol("filter_buffer_start", ih.imagebase + ih.codebase); linker->defineSymbol("original_entry", ih.entry + ih.imagebase); linker->defineSymbol("uncompressed_length", ph.u_len); linker->defineSymbol("start_of_uncompressed", ih.imagebase + rvamin); linker->defineSymbol("compressed_length", ph.c_len); linker->defineSymbol("start_of_compressed", ih.imagebase + s1addr + identsize - identsplit); defineDecompressorSymbols(); relocateLoader(); MemBuffer loader(lsize); memcpy(loader, getLoader(), lsize); patchPackHeader(loader, lsize); // this is computed here, because soxrelocs changes some lines above const unsigned ncsize = soxrelocs + soimpdlls + soexport; const unsigned fam1 = oh.filealign - 1; // fill the sections strcpy(osection[0].name,"UPX0"); strcpy(osection[1].name,"UPX1"); strcpy(osection[2].name, "UPX2"); strcpy(osection[3].name, ".rsrc"); osection[0].vaddr = rvamin; osection[1].vaddr = s1addr; osection[2].vaddr = ncsection; osection[3].vaddr = res_start; osection[0].size = 0; osection[1].size = (s1size + fam1) &~ fam1; osection[2].size = (ncsize + fam1) &~ fam1; osection[3].size = (soresources + fam1) &~ fam1; osection[0].vsize = osection[1].vaddr - osection[0].vaddr; //osection[1].vsize = (osection[1].size + oam1) &~ oam1; //osection[2].vsize = (osection[2].size + oam1) &~ oam1; osection[1].vsize = osection[1].size; osection[2].vsize = osection[2].size; osection[3].vsize = osection[3].size; osection[0].rawdataptr = 0; osection[1].rawdataptr = (pe_offset + sizeof(oh) + sizeof(osection) + fam1) &~ fam1; osection[2].rawdataptr = osection[1].rawdataptr + osection[1].size; osection[3].rawdataptr = osection[2].rawdataptr + osection[2].size; osection[0].flags = (unsigned) (PEFL_BSS|PEFL_EXEC|PEFL_WRITE|PEFL_READ); osection[1].flags = (unsigned) (PEFL_DATA|PEFL_EXEC|PEFL_WRITE|PEFL_READ); osection[2].flags = (unsigned) (PEFL_DATA|PEFL_READ); osection[3].flags = (unsigned) (PEFL_DATA|PEFL_READ); oh.imagesize = (osection[3].vaddr + osection[3].vsize + oam1) &~ oam1; oh.bsssize = osection[0].vsize; oh.datasize = osection[2].vsize + osection[3].vsize; oh.database = osection[2].vaddr; oh.codesize = osection[1].vsize; oh.codebase = osection[1].vaddr; oh.headersize = osection[1].rawdataptr; if (rvamin < osection[0].rawdataptr) throwCantPack("object alignment too small"); if (opt->win32_pe.strip_relocs && !isdll) oh.flags |= RELOCS_STRIPPED; //for (ic = 0; ic < oh.filealign; ic += 4) // set_le32(ibuf + ic,get_le32("UPX ")); ibuf.clear(0, oh.filealign); info("Image size change: %u -> %u KiB", ih.imagesize / 1024, oh.imagesize / 1024); infoHeader("[Writing compressed file]"); if (soresources == 0) { oh.objects = 3; memset(&osection[3], 0, sizeof(osection[3])); } // write loader + compressed file fo->write(&oh,sizeof(oh)); fo->write(osection,sizeof(osection)); // some alignment if (identsplit == identsize) { unsigned n = osection[1].rawdataptr - fo->getBytesWritten() - identsize; assert(n <= oh.filealign); fo->write(ibuf, n); } fo->write(loader + codesize,identsize); infoWriting("loader", fo->getBytesWritten()); fo->write(obuf,c_len); infoWriting("compressed data", c_len); fo->write(loader,codesize); if (opt->debug.dump_stub_loader) OutputFile::dump(opt->debug.dump_stub_loader, loader, codesize); if ((ic = fo->getBytesWritten() & 3) != 0) fo->write(ibuf,4 - ic); fo->write(otls,sotls); if ((ic = fo->getBytesWritten() & fam1) != 0) fo->write(ibuf,oh.filealign - ic); fo->write(oxrelocs,soxrelocs); fo->write(oimpdlls,soimpdlls); fo->write(oexport,soexport); if ((ic = fo->getBytesWritten() & fam1) != 0) fo->write(ibuf,oh.filealign - ic); fo->write(oresources,soresources); if ((ic = fo->getBytesWritten() & fam1) != 0) fo->write(ibuf,oh.filealign - ic); #if 0 printf("%-13s: program hdr : %8ld bytes\n", getName(), (long) sizeof(oh)); printf("%-13s: sections : %8ld bytes\n", getName(), (long) sizeof(osection)); printf("%-13s: ident : %8ld bytes\n", getName(), (long) identsize); printf("%-13s: compressed : %8ld bytes\n", getName(), (long) c_len); printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) codesize); printf("%-13s: tls : %8ld bytes\n", getName(), (long) sotls); printf("%-13s: resources : %8ld bytes\n", getName(), (long) soresources); printf("%-13s: imports : %8ld bytes\n", getName(), (long) soimpdlls); printf("%-13s: exports : %8ld bytes\n", getName(), (long) soexport); printf("%-13s: relocs : %8ld bytes\n", getName(), (long) soxrelocs); #endif // verify verifyOverlappingDecompression(); // copy the overlay copyOverlay(fo, overlay, &obuf); // finally check the compression ratio if (!checkFinalCompressionRatio(fo)) throwNotCompressible(); }
/*! Creates and returns a QStyle object that matches the given \a key, or returns 0 if no matching style is found. Both built-in styles and styles from style plugins are queried for a matching style. \note The keys used are case insensitive. \sa keys() */ QStyle *QStyleFactory::create(const QString& key) { QStyle *ret = 0; QString style = key.toLower(); #ifndef QT_NO_STYLE_WINDOWS if (style == QLatin1String("windows")) ret = new QWindowsStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSCE if (style == QLatin1String("windowsce")) ret = new QWindowsCEStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSMOBILE if (style == QLatin1String("windowsmobile")) ret = new QWindowsMobileStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSXP if (style == QLatin1String("windowsxp")) ret = new QWindowsXPStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSVISTA if (style == QLatin1String("windowsvista")) ret = new QWindowsVistaStyle; else #endif #ifndef QT_NO_STYLE_FUSION if (style == QLatin1String("fusion")) ret = new QFusionStyle; else #endif #ifndef QT_NO_STYLE_ANDROID if (style == QLatin1String("android")) ret = new QAndroidStyle; else #endif #ifndef QT_NO_STYLE_GTK if (style == QLatin1String("gtk") || style == QLatin1String("gtk+")) ret = new QGtkStyle; else #endif #ifndef QT_NO_STYLE_MAC if (style.startsWith(QLatin1String("macintosh"))) { ret = new QMacStyle; # ifdef Q_WS_MAC if (style == QLatin1String("macintosh")) style += QLatin1String(" (aqua)"); # endif } else #endif { } // Keep these here - they make the #ifdefery above work #ifndef QT_NO_LIBRARY if (!ret) ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style); #endif if(ret) ret->setObjectName(style); return ret; }
void CLMsgClassManager::loadAlltheFile(string *filelist,int strNum) { CLMsgClassLoader loader(this,filelist,strNum); }
EXPORT int bizswan_binstateload(System *s, const char *data, int length) { NewStateExternalBuffer loader(const_cast<char *>(data), length); s->SyncState<true>(&loader); return !loader.Overflow() && loader.GetLength() == length; }
EXPORT void bizswan_txtstateload(System *s, FPtrs *ff) { NewStateExternalFunctions loader(ff); s->SyncState<true>(&loader); }
Application::Application(int &argc, char **argv) : PsApplication(argc, argv), serverName(psServerPrefix() + cGUIDStr()), closing(false), updateRequestId(0), updateReply(0), updateThread(0), updateDownloader(0) { DEBUG_LOG(("Application Info: creation..")); QByteArray d(QDir((cPlatform() == dbipWindows ? cExeDir() : cWorkingDir()).toLower()).absolutePath().toUtf8()); char h[33] = { 0 }; hashMd5Hex(d.constData(), d.size(), h); serverName = psServerPrefix() + h + '-' + cGUIDStr(); if (mainApp) { DEBUG_LOG(("Application Error: another Application was created, terminating..")); exit(0); } mainApp = this; installEventFilter(new _DebugWaiter(this)); #if defined Q_OS_LINUX || defined Q_OS_LINUX64 QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/DejaVuSans.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/NanumMyeongjo-Regular.ttf")); #endif QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Regular.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Bold.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Semibold.ttf")); float64 dpi = primaryScreen()->logicalDotsPerInch(); if (dpi <= 108) { // 0-96-108 cSetScreenScale(dbisOne); } else if (dpi <= 132) { // 108-120-132 cSetScreenScale(dbisOneAndQuarter); } else if (dpi <= 168) { // 132-144-168 cSetScreenScale(dbisOneAndHalf); } else { // 168-192-inf cSetScreenScale(dbisTwo); } if (devicePixelRatio() > 1) { cSetRetina(true); cSetRetinaFactor(devicePixelRatio()); cSetIntRetinaFactor(int32(cRetinaFactor())); } if (!cLangFile().isEmpty() && QFileInfo(cLangFile()).exists()) { LangLoaderPlain loader(cLangFile()); cSetLangErrors(loader.errors()); if (!cLangErrors().isEmpty()) { LOG(("Lang load errors: %1").arg(cLangErrors())); } else if (!loader.warnings().isEmpty()) { LOG(("Lang load warnings: %1").arg(loader.warnings())); } } Local::start(); style::startManager(); anim::startManager(); historyInit(); DEBUG_LOG(("Application Info: inited..")); window = new Window(); psInstallEventFilter(); connect(&socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(socketError(QLocalSocket::LocalSocketError))); connect(&socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketWritten(qint64))); connect(&socket, SIGNAL(readyRead()), this, SLOT(socketReading())); connect(&server, SIGNAL(newConnection()), this, SLOT(newInstanceConnected())); connect(this, SIGNAL(aboutToQuit()), this, SLOT(closeApplication())); connect(&updateCheckTimer, SIGNAL(timeout()), this, SLOT(startUpdateCheck())); connect(this, SIGNAL(updateFailed()), this, SLOT(onUpdateFailed())); connect(this, SIGNAL(updateReady()), this, SLOT(onUpdateReady())); connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState))); connect(&writeUserConfigTimer, SIGNAL(timeout()), this, SLOT(onWriteUserConfig())); writeUserConfigTimer.setSingleShot(true); connect(&killDownloadSessionsTimer, SIGNAL(timeout()), this, SLOT(killDownloadSessions())); if (cManyInstance()) { startApp(); } else { DEBUG_LOG(("Application Info: connecting local socket to %1..").arg(serverName)); socket.connectToServer(serverName); } }
gep::ResourcePtr<gep::ISoundInstance> gep::FmodSound::createInstance() { FmodSoundInstanceLoader loader(makeResourcePtrFromThis<FmodSound>()); return g_globalManager.getResourceManager()->loadResource<FmodSoundInstance>(loader, gep::LoadAsync::No); }
/*! Creates the screen driver specified by the given \a key, using the display specified by the given \a displayId. Note that the keys are case-insensitive. \sa keys() */ QScreen *QScreenDriverFactory::create(const QString& key, int displayId) { QString driver = key.toLower(); #ifndef QT_NO_QWS_QVFB if (driver == QLatin1String("qvfb") || driver.isEmpty()) return new QVFbScreen(displayId); #endif #ifndef QT_NO_QWS_LINUXFB if (driver == QLatin1String("linuxfb") || driver.isEmpty()) return new QLinuxFbScreen(displayId); #endif #ifndef QT_NO_QWS_TRANSFORMED if (driver == QLatin1String("transformed")) return new QTransformedScreen(displayId); #endif #ifndef QT_NO_QWS_VNC if (driver == QLatin1String("vnc")) return new QVNCScreen(displayId); #endif #ifndef QT_NO_QWS_MULTISCREEN if (driver == QLatin1String("multi")) return new QMultiScreen(displayId); #endif #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) #ifndef QT_NO_LIBRARY if (QScreenDriverFactoryInterface *factory = qobject_cast<QScreenDriverFactoryInterface*>(loader()->instance(key))) return factory->create(driver, displayId); #endif #endif return 0; }
Controller::Controller(QString datadir, QString size, bool maximize, QObject *parent) : QObject(parent) { qRegisterMetaType<Image*>("Image"); qmlRegisterInterface<QAbstractItemModel >("QAbstractItemModel"); #if defined(Q_OS_ANDROID) QDir current=QDir::current(); current.cdUp(); Controller::cachePath=current.absolutePath()+"/cache"; Controller::dataPath=current.absolutePath()+"/files"; #else mViewer.setIcon(QIcon(":/images/icon512.png")); QString baseBase=datadir!="" ? datadir : QDir::homePath()+"/.TvSeriesOrganizer"; Controller::cachePath=baseBase+"/cache"; Controller::dataPath=baseBase+"/data"; QDir dir; dir.mkpath(Controller::cachePath); dir.mkpath(Controller::dataPath); #endif Series::dataPath=Controller::dataPath; QQmlNetworkAccessManagerFactoryWithCache * factory=new QQmlNetworkAccessManagerFactoryWithCache(cachePath); mViewer.engine()->setNetworkAccessManagerFactory(factory); QQmlContext *ctxt = mViewer.rootContext(); #if defined(Q_OS_ANDROID) mViewer.showExpanded(); ctxt->setContextProperty("awidth",mViewer.width()); ctxt->setContextProperty("aheight",mViewer.height()); #else QStringList cSize=size.split("x"); ctxt->setContextProperty("awidth",cSize[0].toInt()); ctxt->setContextProperty("aheight",cSize[1].toInt()); if(maximize) { QTimer * maximizeTimer=new QTimer(); maximizeTimer->setInterval(0); maximizeTimer->setSingleShot(true); connect(maximizeTimer,&QTimer::timeout,[this](){mViewer.showMaximized();}); maximizeTimer->start(); } #endif SignalList<Plugin*> * pluginList=new SignalList<Plugin*>(); QDir pluginDir(QCoreApplication::applicationDirPath()+"/plugin/"); for(QFileInfo fileInfo : pluginDir.entryInfoList(QDir::Files)) { QPluginLoader loader(fileInfo.absoluteFilePath()); QObject *plugin = loader.instance(); if(plugin) { AbstractPlugin * plug = qobject_cast<AbstractPlugin *>(plugin); Plugin * plug2=new Plugin(plug,this); pluginList->append(plug2); } } ctxt->setContextProperty("noPlugin",pluginList->size()==0); ctxt->setContextProperty("pluginModel",new SignalListAdapter<Plugin*>(pluginList,"plugin")); QNetworkAccessManager * networkAccessManager=new QNetworkAccessManager(this); DiskCache * diskCache=new DiskCache(networkAccessManager,this); TheTvDBAPI * theTvDBAPI=new TheTvDBAPI(Controller::cachePath,"http://thetvdb.com",TheTvDBAPIKey,networkAccessManager,diskCache,this); theTvDBAPI->updateCache([this,theTvDBAPI,ctxt,maximize,diskCache]() { mSeriesList=new SeriesList(theTvDBAPI,nullptr,this); mSeriesList->loadSeries(Controller::dataPath+"/myseries.txt"); ctxt->setContextProperty("seriesList", mSeriesList); TraktTvAPI* traktTvAPI = new TraktTvAPI(Controller::cachePath,mSeriesList,"http://api.trakt.tv",TraktTvAPIKey,theTvDBAPI,diskCache,this); SeriesListList * seriesListList=new SeriesListList(traktTvAPI,this); ctxt->setContextProperty("seriesListList", seriesListList); Settings::declareSettingsQml(); Settings * settings=new Settings(dataPath,this); ctxt->setContextProperty("settings", settings); mViewer.setSource(QUrl("qrc:/view/MainView.qml")); #if !defined(Q_OS_ANDROID) if(!maximize) mViewer.showExpanded(); #endif //qDebug()<<mViewer.size(); //mViewer.setMaximumSize(mViewer.size()); //mViewer.setMinimumSize(mViewer.size()-QSize(10,10)); }); }
int main(int argc, char* argv[]) { // parameters... char input_dir[400]; int num_iteration = 100000; int single_frame_flag = 0; int display_flag = 0; int test_flag = 0; int test_idx = 0; int target_idx = 0; int directory_id = atoi(argv[1]); int train_flag = atoi(argv[2]); int expanding_period = num_iteration / 2; int load_all_flag = 1; char dir[40]; sprintf(dir, "march_10_2014"); //Transform transform(initial_x, initial_y, initial_long_axis, initial_short_axis, initial_angle); //transform.CheckInvGradient(); if(argc == 4) { if(train_flag == 1) num_iteration = atoi(argv[3]); else if(train_flag == 0) single_frame_flag = atoi(argv[3]); else if(train_flag == 2) sprintf(dir, argv[3]); else if(train_flag == 3) { sprintf(dir, argv[3]); } else return 0; } if(argc == 5) { if(train_flag == 1) { sprintf(dir, argv[3]); num_iteration = atoi(argv[4]); // expanding_period = atof(argv[4]); } else if(train_flag == 0) { single_frame_flag = atoi(argv[3]); display_flag = atoi(argv[4]); } else if(train_flag == 3) { sprintf(dir, argv[3]); test_idx = atoi(argv[4]); } else return 0; } if(argc == 6){ if(train_flag == 1) { sprintf(dir, argv[3]); num_iteration = atoi(argv[4]); expanding_period = atof(argv[5]); } //else if(train_flag == 0) //{ // sprintf(dir, argv[3]); // single_frame_flag = atoi(argv[3]); // display_flag = atoi(argv[4]); // // test_idx = atoi(argv[5]); //} else return 0; } if(argc == 7){ if(train_flag == 0) { sprintf(dir, argv[3]); single_frame_flag = atoi(argv[4]); display_flag = atoi(argv[5]); // test_flag = atoi(argv[6]); test_idx = atoi(argv[6]); } else if(train_flag == 1) { sprintf(dir, argv[3]); num_iteration = atoi(argv[4]); expanding_period = atof(argv[5]); load_all_flag = atoi(argv[6]); } else return 0; } if(argc == 8){ if(train_flag == 0) { sprintf(dir, argv[3]); single_frame_flag = atoi(argv[4]); display_flag = atoi(argv[5]); test_flag = atoi(argv[6]); test_idx = atoi(argv[7]); } else return 0; } // initialization std::cout << "training iteration: " << num_iteration << std::endl; std::cout << "expanding period: " << expanding_period << std::endl; Explorer explorer(directory_id, num_iteration, expanding_period, load_all_flag, dir); if(train_flag == 1) explorer.Train(); else if(train_flag == 0) explorer.Test(display_flag, single_frame_flag, 1, 1798, test_idx, test_flag, 0); else if(train_flag == 2) { Loader loader(6, 15, directory_id, dir); loader.RecordSiftKeyPoints(); } else if(train_flag == 3) { // explorer.PlotDiagnosis(test_idx); // explorer.PlotTransformationGrid(); // explorer.ConvertRefCovToDistMetric(); // explorer.GetVideoImages(); // Transform transform; // transform.CheckInvGradient(); // explorer.RecursiveLeastSquareTest(); explorer.SaveSinusoidalFeature(); } else exit(0); }
void QSqlDatabasePrivate::init(const QString &type) { drvName = type; if (!driver) { #ifdef QT_SQL_PSQL if (type == QLatin1String("QPSQL") || type == QLatin1String("QPSQL7")) driver = new QPSQLDriver(); #endif #ifdef QT_SQL_MYSQL if (type == QLatin1String("QMYSQL") || type == QLatin1String("QMYSQL3")) driver = new QMYSQLDriver(); #endif #ifdef QT_SQL_ODBC if (type == QLatin1String("QODBC") || type == QLatin1String("QODBC3")) driver = new QODBCDriver(); #endif #ifdef QT_SQL_OCI if (type == QLatin1String("QOCI") || type == QLatin1String("QOCI8")) driver = new QOCIDriver(); #endif #ifdef QT_SQL_TDS if (type == QLatin1String("QTDS") || type == QLatin1String("QTDS7")) driver = new QTDSDriver(); #endif #ifdef QT_SQL_DB2 if (type == QLatin1String("QDB2")) driver = new QDB2Driver(); #endif #ifdef QT_SQL_SQLITE if (type == QLatin1String("QSQLITE")) driver = new QSQLiteDriver(); #endif #ifdef QT_SQL_SQLITE2 if (type == QLatin1String("QSQLITE2")) driver = new QSQLite2Driver(); #endif #ifdef QT_SQL_IBASE if (type == QLatin1String("QIBASE")) driver = new QIBaseDriver(); #endif } if (!driver) { DriverDict dict = QSqlDatabasePrivate::driverDict(); for (DriverDict::const_iterator it = dict.constBegin(); it != dict.constEnd() && !driver; ++it) { if (type == it.key()) { driver = ((QSqlDriverCreatorBase*)(*it))->createObject(); } } } #ifndef QT_NO_LIBRARY if (!driver && loader()) { if (QSqlDriverFactoryInterface *factory = qobject_cast<QSqlDriverFactoryInterface*>(loader()->instance(type))) driver = factory->create(type); } #endif // QT_NO_LIBRARY if (!driver) { qWarning("QSqlDatabase: %s driver not loaded", type.toLatin1().data()); qWarning("QSqlDatabase: available drivers: %s", QSqlDatabase::drivers().join(QLatin1String(" ")).toLatin1().data()); if (QCoreApplication::instance() == 0) qWarning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins"); driver = shared_null()->driver; } }
static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, const QByteArray &format) { QByteArray form = format.toLower(); QByteArray suffix; QImageIOHandler *handler = 0; #ifndef QT_NO_LIBRARY // check if any plugins can write the image QFactoryLoader *l = loader(); QStringList keys = l->keys(); int suffixPluginIndex = -1; #endif if (device && format.isEmpty()) { // if there's no format, see if \a device is a file, and if so, find // the file suffix and find support for that format among our plugins. // this allows plugins to override our built-in handlers. if (QFile *file = qobject_cast<QFile *>(device)) { if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()) { #ifndef QT_NO_LIBRARY int index = keys.indexOf(QString::fromLatin1(suffix)); if (index != -1) suffixPluginIndex = index; #endif } } } QByteArray testFormat = !form.isEmpty() ? form : suffix; #ifndef QT_NO_LIBRARY if (suffixPluginIndex != -1) { // when format is missing, check if we can find a plugin for the // suffix. QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QString::fromLatin1(suffix))); if (plugin && (plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite)) handler = plugin->create(device, suffix); } #endif // QT_NO_LIBRARY // check if any built-in handlers can write the image if (!handler && !testFormat.isEmpty()) { if (false) { #ifndef QT_NO_IMAGEFORMAT_PNG } else if (testFormat == "png") { handler = new QPngHandler; #endif #ifndef QT_NO_IMAGEFORMAT_JPEG } else if (testFormat == "jpg" || testFormat == "jpeg") { handler = new QJpegHandler; #endif #ifndef QT_NO_IMAGEFORMAT_MNG } else if (testFormat == "mng") { handler = new QMngHandler; #endif #ifndef QT_NO_IMAGEFORMAT_TIFF } else if (testFormat == "tif" || testFormat == "tiff") { handler = new QTiffHandler; #endif #ifdef QT_BUILTIN_GIF_READER } else if (testFormat == "gif") { handler = new QGifHandler; #endif #ifndef QT_NO_IMAGEFORMAT_BMP } else if (testFormat == "bmp") { handler = new QBmpHandler; #endif #ifndef QT_NO_IMAGEFORMAT_XPM } else if (testFormat == "xpm") { handler = new QXpmHandler; #endif #ifndef QT_NO_IMAGEFORMAT_XBM } else if (testFormat == "xbm") { handler = new QXbmHandler; handler->setOption(QImageIOHandler::SubType, testFormat); #endif #ifndef QT_NO_IMAGEFORMAT_PPM } else if (testFormat == "pbm" || testFormat == "pbmraw" || testFormat == "pgm" || testFormat == "pgmraw" || testFormat == "ppm" || testFormat == "ppmraw") { handler = new QPpmHandler; handler->setOption(QImageIOHandler::SubType, testFormat); #endif } } #ifndef QT_NO_LIBRARY if (!testFormat.isEmpty()) { for (int i = 0; i < keys.size(); ++i) { QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) { delete handler; handler = plugin->create(device, testFormat); break; } } } #endif // QT_NO_LIBRARY if (!handler) return 0; handler->setDevice(device); if (!testFormat.isEmpty()) handler->setFormat(testFormat); return handler; }
ServerBufferIntegration *ServerBufferIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) { #ifndef QT_NO_LIBRARY // Try loading the plugin from platformPluginPath first: if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); if (ServerBufferIntegration *ret = qLoadPlugin1<ServerBufferIntegration, ServerBufferIntegrationPlugin>(directLoader(), name, args)) return ret; } if (ServerBufferIntegration *ret = qLoadPlugin1<ServerBufferIntegration, ServerBufferIntegrationPlugin>(loader(), name, args)) return ret; #endif return 0; }
/* ------------------------------------------------------------------------- * main * ----------------------------------------------------------------------- */ int main(int argc, char** argv) { OptionsCont& oc = OptionsCont::getOptions(); // give some application descriptions oc.setApplicationDescription("Builds vehicle routes for SUMO using detector values."); oc.setApplicationName("dfrouter", "SUMO dfrouter Version " + (std::string)VERSION_STRING); int ret = 0; RODFNet* net = 0; RODFDetectorCon* detectors = 0; RODFDetectorFlows* flows = 0; try { // initialise the application system (messaging, xml, options) XMLSubSys::init(); RODFFrame::fillOptions(); OptionsIO::getOptions(true, argc, argv); if (oc.processMetaOptions(argc < 2)) { SystemFrame::close(); return 0; } XMLSubSys::setValidation(oc.getString("xml-validation"), oc.getString("xml-validation.net")); MsgHandler::initOutputOptions(); if (!RODFFrame::checkOptions()) { throw ProcessError(); } RandHelper::initRandGlobal(); // load data ROLoader loader(oc, false, !oc.getBool("no-step-log")); net = new RODFNet(oc.getBool("highway-mode")); RODFEdgeBuilder builder; loader.loadNet(*net, builder); net->buildApproachList(); // load detectors detectors = new RODFDetectorCon(); readDetectors(*detectors, oc, net); // load detector values flows = new RODFDetectorFlows(string2time(oc.getString("begin")), string2time(oc.getString("end")), string2time(oc.getString("time-step"))); readDetectorFlows(*flows, oc, *detectors); // build routes startComputation(net, *flows, *detectors, oc); } catch (const ProcessError& e) { if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) { WRITE_ERROR(e.what()); } MsgHandler::getErrorInstance()->inform("Quitting (on error).", false); ret = 1; #ifndef _DEBUG } catch (const std::exception& e) { if (std::string(e.what()) != std::string("")) { WRITE_ERROR(e.what()); } MsgHandler::getErrorInstance()->inform("Quitting (on error).", false); ret = 1; } catch (...) { MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false); ret = 1; #endif } delete net; delete flows; delete detectors; SystemFrame::close(); if (ret == 0) { std::cout << "Success." << std::endl; } return ret; }
int main(int argc, char** argv) { try { std::wstring modelURL (L"http://models.cellml.org/workspace/hodgkin_huxley_1952/@@rawfile/949cd4d3/hodgkin_huxley_1952.cellml"); // Create a CellML Bootstrap and a model loader. ObjRef<iface::cellml_api::CellMLBootstrap> bootstrap(CreateCellMLBootstrap()); ObjRef<iface::cellml_api::DOMModelLoader> loader(bootstrap->modelLoader()); // Load a CellML model. ObjRef<iface::cellml_api::Model> hhModel (loader->loadFromURL(modelURL)); // Request a RDF/API capable RDF representation... ObjRef<iface::cellml_api::RDFRepresentation> rr(hhModel->getRDFRepresentation(L"http://www.cellml.org/RDF/API")); ObjRef<iface::rdf_api::RDFAPIRepresentation> rrHH(QueryInterface(rr)); // Retrieve the DataSource. Note: Changes to the data source are not pushed back // to the model until the source attribute is set on the rrHH again. ObjRef<iface::rdf_api::DataSource> dsHH(rrHH->source()); // Get the resource corresponding to the cmeta:id on the model. Note that // cmetaId can return the empty string, which you should check for in // production code, if there is no cmeta:id ObjRef<iface::rdf_api::URIReference> hhModelRef (dsHH->getURIReference(bootstrap->makeURLAbsolute(modelURL, L"#" + hhModel->cmetaId()))); #ifdef DUMP_ALL_TRIPLES_FIRST { ObjRef<iface::rdf_api::TripleSet> ts(dsHH->getAllTriples()); ObjRef<iface::rdf_api::TripleEnumerator> te(ts->enumerateTriples()); while (true) { ObjRef<iface::rdf_api::Triple> t(te->getNextTriple()); if (t == NULL) break; displayTriple(t); } } #endif ObjRef<iface::rdf_api::URIReference> pmid(dsHH->getURIReference(L"http://www.cellml.org/bqs/1.0#Pubmed_id")); // Note: Calls like this could fail with an exception if there was no pubmed ID - production code should check. ObjRef<iface::rdf_api::Triple> t(hhModelRef->getTripleOutOfByPredicate(pmid)); ObjRef<iface::rdf_api::Node> n(t->object()); ObjRef<iface::rdf_api::Literal> lPMID(QueryInterface(n)); if (lPMID != NULL) // It will be null if for some reason it isn't a literal... std::wcout << L"Model pubmed ID: " << lPMID->lexicalForm() << std::endl; ObjRef<iface::rdf_api::URIReference> bqsReference(dsHH->getURIReference(L"http://www.cellml.org/bqs/1.0#reference")); ObjRef<iface::rdf_api::TripleSet> ts(hhModelRef->getTriplesOutOfByPredicate(bqsReference)); ObjRef<iface::rdf_api::TripleEnumerator> te(ts->enumerateTriples()); while (true) { t = te->getNextTriple(); if (t == NULL) break; ObjRef<iface::rdf_api::Resource> r(QueryInterface(t->object())); if (r == NULL) continue; std::wcout << L"Found a resource description:" << std::endl; try { t = r->getTripleOutOfByPredicate(pmid); n = t->object(); lPMID = QueryInterface(n); if (lPMID != NULL) std::wcout << L" Reference pubmed ID: " << lPMID->lexicalForm() << std::endl; } catch(...) {} // Look up the subject... ObjRef<iface::rdf_api::URIReference> subject(dsHH->getURIReference(L"http://purl.org/dc/elements/1.1/subject")); ts = r->getTriplesOutOfByPredicate(subject); ObjRef<iface::rdf_api::TripleEnumerator> te2 = ts->enumerateTriples(); while (true) { t = te2->getNextTriple(); if (t == NULL) break; n = t->object(); r = QueryInterface(n); if (r == NULL) continue; std::wcout << " Subject:" << std::endl; ObjRef<iface::rdf_api::URIReference> subjectType(dsHH->getURIReference(L"http://www.cellml.org/bqs/1.0#subject_type")); ts = r->getTriplesOutOfByPredicate(subjectType); ObjRef<iface::rdf_api::TripleEnumerator> te3 = ts->enumerateTriples(); t = te3->getNextTriple(); if (t) { n = t->object(); ObjRef<iface::rdf_api::Literal> l(QueryInterface(n)); std::wcout << " Subject Type=" << l->lexicalForm() << std::endl; } ObjRef<iface::rdf_api::URIReference> value(dsHH->getURIReference(L"http://www.w3.org/1999/02/22-rdf-syntax-ns#value")); ts = r->getTriplesOutOfByPredicate(value); te3 = ts->enumerateTriples(); t = te3->getNextTriple(); if (t == NULL) continue; n = t->object(); r = QueryInterface(n); if (r == NULL) continue; ObjRef<iface::rdf_api::Container> cont(r->correspondingContainer()); // Add a new entry to the container first... ObjRef<iface::rdf_api::PlainLiteral> newPL(dsHH->getPlainLiteral(L"Newly created label", L"en")); cont->appendChild(newPL); // Delete any labels that match 'giant axon'... ObjRef<iface::rdf_api::NodeIterator> ni(cont->iterateChildren()); while (true) { ObjRef<iface::rdf_api::Node> n(ni->getNextNode()); if (n == NULL) break; ObjRef<iface::rdf_api::Literal> l(QueryInterface(n)); if (l == NULL) continue; if (l->lexicalForm() == L"giant axon") // The false means don't renumber immediately. This leaves the // container with gaps... cont->removeChild(l, false); } cont->renumberContainer(); // Remove the gaps. displayContainer(cont, L" "); } } } catch (iface::cellml_api::CellMLException&) { std::wcout << L"A CellMLException was raised. In production code, you would normally have more " << L"exception handlers to work out exactly where the problem occurred. This program " << L"avoids that for simplicity, to make the normal control flow easier to understand. " << L"The most likely cause is a network problem retrieving the hardcoded model URL." << std::endl; return 1; } catch (iface::rdf_api::RDFProcessingError&) { std::wcout << L"An RDFProcessingError was raised. In production code, you would normally have more " << L"exception handlers to work out exactly where the problem occurred. This program " << L"avoids that for simplicity, to make the normal control flow easier to understand." << std::endl; return 2; } return 0; }
void App_LoadInstallSettings( wxConfigBase* ini ) { IniLoader loader( ini ); App_LoadSaveInstallSettings( loader ); }
/*! Creates the driver specified by \a key, using the given \a specification. Note that the keys are case-insensitive. \sa keys() */ QObject *QGenericPluginFactory::create(const QString& key, const QString &specification) { QString driver = key.toLower(); #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) #ifndef QT_NO_LIBRARY if (QGenericPluginFactoryInterface *factory = qobject_cast<QGenericPluginFactoryInterface*>(loader()->instance(driver))) return factory->create(driver, specification); #endif #endif return 0; }
/** * \brief Adds the loaders of this item class into a given loader map. * \param m The map in which the loaders are inserted. */ void bear::level_settings::populate_loader_map( engine::item_loader_map& m ) { super::populate_loader_map(m); m.insert( loader( get_level_globals() ) ); } // level_settings::populate_loader_map()
SDLImage::SDLImage(CDefFile *data, size_t frame, size_t group, bool compressed): surf(nullptr) { SDLImageLoader loader(this); data->loadFrame(frame, group, loader); }
// static void BlobResourceHandle::loadResourceSynchronously(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data) { BlobResourceSynchronousLoader loader(error, response, data); RefPtr<BlobResourceHandle> handle = BlobResourceHandle::create(blobData, request, &loader, false); handle->start(); }
void g1_model_list_class::reset(i4_array<i4_str *> &model_names, r1_texture_manager_class * tmap) { free_array(); if (g1_object_heap) { g1_object_heap->clear(); } if (name_buffer) { name_buffer->clear(); } if (array) { i4_free(array); array=0; } pf_load_models.start(); //"Loading models..." i4_status_class * stat=i4_create_status(i4gets("loading_models")); total_models=model_names.size(); array=(model_info *)I4_MALLOC(total_models * sizeof(model_info), "model list"); int actual_total=0; g1_quad_object_loader_class loader(g1_object_heap); char nbuf[MAX_PATH]; for (int i=0; i<model_names.size(); i++) { if (stat) { stat->update(i/(float)model_names.size()); } //The default scale. model_scaling=0.1f; pf_model_load_open.start(); //A string of the form "objects/%s.gmod" li_object * fmt=li_get_value("object_format", 0); char * n=li_string::get(fmt,0)->value(); sprintf(nbuf,n,model_names[i]->c_str()); i4_file_class * in_file=i4_open(nbuf); if (in_file) { g1_loader_class * fp=g1_open_save_file(in_file); pf_model_load_open.stop(); if (fp) { array[actual_total].model=loader.load(fp, *model_names[i], tmap); if (array[actual_total].model) { i4_filename_struct fn; i4_split_path(*model_names[i], fn); array[actual_total].model->scale(model_scaling); // copy the name into the name buffer int len=strlen(fn.filename)+1; char * c=(char *)name_buffer->malloc(len, "name"); strcpy(c, fn.filename); array[actual_total].name_start=c; actual_total++; } delete fp; } else { i4_alert(i4gets("old_model_file"),200, model_names[i]); } } else { pf_model_load_open.stop(); i4_alert(i4gets("file_missing"), 200, model_names[i]); } } delete stat; total_models=actual_total; qsort(array, total_models, sizeof(model_info), g1_model_info_compare); // reset the model_reference values for (g1_model_ref * mi=model_references; mi; mi=mi->next) { mi->value=find_handle(mi->name); } pf_load_models.stop(); }
void ExportBodymovin::Trigger(const std::string& src_file, const std::string& dst_dir) { Json::Value val; Json::Reader reader; std::locale::global(std::locale("")); std::ifstream fin(src_file.c_str()); std::locale::global(std::locale("C")); reader.parse(fin, val); fin.close(); auto dir = gum::FilepathHelper::Dir(src_file.c_str()); s2loader::BodymovinParser parser; parser.Parse(val, dir); auto sym_loader = std::make_shared<ee::SymbolLoader>(); auto spr_loader = std::make_shared<ee::SpriteLoader>(); CU_MAP<CU_STR, s2::SprPtr> map_assets; auto& assets = parser.GetAssets(); std::vector<bool> flags(assets.size(), false); while (true) { bool fail = false; for (int i = 0, n = assets.size(); i < n; ++i) { if (flags[i]) { continue; } const s2loader::BodymovinParser::Asset& a = assets[i]; if (a.layers.empty()) { auto filepath = gum::FilepathHelper::Absolute(".", a.filepath); auto spr = spr_loader->Create(filepath); map_assets.insert(std::make_pair(a.id, spr)); flags[i] = true; } else { bool skip = false; for (int j = 0, m = a.layers.size(); j < m; ++j) { const s2loader::BodymovinParser::Layer& layer = a.layers[j]; if (layer.layer_type == s2loader::BodymovinParser::LAYER_SOLID || layer.layer_type == s2loader::BodymovinParser::LAYER_NULL) { continue; } auto& id = a.layers[j].ref_id; auto itr = map_assets.find(id); if (itr == map_assets.end()) { skip = true; break; } } flags[i] = !skip; if (skip) { fail = true; continue; } auto sym = std::make_shared<libanim::Symbol>(); s2loader::BodymovinAnimLoader loader(*std::dynamic_pointer_cast<s2::AnimSymbol>(sym), sym_loader, spr_loader); loader.LoadLayers(map_assets, a.layers, parser.GetFrameRate(), parser.GetWidth(), parser.GetHeight(), parser.GetStartFrame(), parser.GetEndFrame()); std::string filepath = dst_dir + "\\" + std::string(a.id.c_str()) + "_" + ee::SymbolFile::Instance()->Tag(s2::SYM_ANIMATION) + ".json"; libanim::FileSaver::Store(filepath, *sym); sym->SetFilepath(filepath); libanim::Sprite* spr = new libanim::Sprite(sym); spr->UpdateBounding(); map_assets.insert(std::make_pair(a.id, spr)); } } if (!fail) { break; } } auto sym = std::make_shared<libanim::Symbol>(); s2loader::BodymovinAnimLoader loader(*sym, sym_loader, spr_loader); loader.LoadLayers(map_assets, parser.GetLayers(), parser.GetFrameRate(), parser.GetWidth(), parser.GetHeight(), parser.GetStartFrame(), parser.GetEndFrame()); std::string filepath = dst_dir + "\\data_" + ee::SymbolFile::Instance()->Tag(s2::SYM_ANIMATION) + ".json"; libanim::FileSaver::Store(filepath, *sym); FixFontLayers(dst_dir); }
QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default"))); if (plugin) { QList<QByteArray> list = plugin->deviceList(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); #endif return QAudioDeviceInfo(); }
QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default"))); if (plugin) { QList<QByteArray> list = plugin->availableDevices(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } #endif #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); #endif #endif return QAudioDeviceInfo(); }