nint NServiceClientFactoryConfig::compareTo(const INObject * other) const { if (this == other) return 0; try { const NServiceClientFactoryConfig * obj = dynamic_cast<const NServiceClientFactoryConfig*>(other); if (obj != NULL) { int result = 0; if ((result = getName().compare(obj->getName())) == 0) { if ((result = getFactory().compare(obj->getFactory())) == 0) { if ((result = getComponent().compare(obj->getComponent())) == 0) { result = getLibrary().compare(obj->getLibrary()); } } } return result; } else { return 1; } } catch (bad_cast &) { return 1; } }
/** * Resolve a package function. This goes explicitly to a loaded * package to resolve the name rather than relying on the global * cache. This will resolve to the same routine object as the * global cache, but this prevents us from picking one a * different one in case of a name conflict. * * @param packageName * The package name. * @param function The function name. * * @return A routine object for this function. */ RoutineClass *PackageManager::resolveRoutine(RexxString *packageName, RexxString *function) { // have we already loaded this package? // may need to bootstrap it up first. LibraryPackage *package = getLibrary(packageName); // now see if this can be resolved. return package->resolveRoutine(function); }
/** * Create a Native method from a registered package. * * @param packageName * The name of the package the library is loaded from. * * @param methodName The name of the procedure to resolve from the package. * * @return A Native method that represents this package entry. Returns * NULL if not found. */ RexxNativeMethod *PackageManager::resolveMethod(RexxString *packageName, RexxString *methodName) { // have we already loaded this package? // may need to bootstrap it up first. LibraryPackage *package = getLibrary(packageName); // now see if this can be resolved. return package->resolveMethod(methodName); }
void Text::onUpdate(Scalar dt) { if(localizationEntry.size()){ Library* lib = getLibrary(); if(lib) if(!lib->getLocalizedText(text, localizationEntry)) text.clear(); } Widget::onUpdate(dt); }
// This will find the library and UUID tags of the sub effect pointed by the // node, gets the effect descriptor and lib_entry_t and adds the subeffect - // sub_entry_t to the gSubEffectList int addSubEffect(cnode *root) { ALOGV("addSubEffect"); cnode *node; effect_uuid_t uuid; effect_descriptor_t *d; lib_entry_t *l; list_elem_t *e; node = config_find(root, LIBRARY_TAG); if (node == NULL) { return -EINVAL; } l = getLibrary(node->value); if (l == NULL) { ALOGW("addSubEffect() could not get library %s", node->value); return -EINVAL; } node = config_find(root, UUID_TAG); if (node == NULL) { return -EINVAL; } if (stringToUuid(node->value, &uuid) != 0) { ALOGW("addSubEffect() invalid uuid %s", node->value); return -EINVAL; } d = malloc(sizeof(effect_descriptor_t)); if (l->desc->get_descriptor(&uuid, d) != 0) { char s[40]; uuidToString(&uuid, s, 40); ALOGW("Error querying effect %s on lib %s", s, l->name); free(d); return -EINVAL; } #if (LOG_NDEBUG==0) char s[256]; dumpEffectDescriptor(d, s, 256); ALOGV("addSubEffect() read descriptor %p:%s",d, s); #endif if (EFFECT_API_VERSION_MAJOR(d->apiVersion) != EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) { ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name); free(d); return -EINVAL; } sub_effect_entry_t *sub_effect = malloc(sizeof(sub_effect_entry_t)); sub_effect->object = d; // lib_entry_t is stored since the sub effects are not linked to the library sub_effect->lib = l; e = malloc(sizeof(list_elem_t)); e->object = sub_effect; e->next = gSubEffectList->sub_elem; gSubEffectList->sub_elem = e; ALOGV("addSubEffect end"); return 0; }
Core::Core(std::string const &libname, size_t width, size_t height) : _libname(libname), _width(width), _height(height) { if (width < 5 || height < 5 || width > 160 || height > 60) Msg::Error("Errors with size. (not under 5 and not over 100)"); _win = NULL; _map.score = 0; getLibrary(_libname); }
//saves the path of the library specified by user to field library_path and constructs solver with that library. void Window::browse() { library_path->setText(QFileDialog::getOpenFileName(this,tr("Library"), path, "All files (*)")); std::ifstream sanat(getLibrary()); std::vector<QString> Qwords; std::string line; while (std::getline(sanat, line)) { Qwords.push_back(QString(line.data())); } // construct solver with words solver = SanajahtiSolver(Qwords); }
// checks if the class info has been loaded ClassInfoPtr ConfigObjectLoader::getClassInfo( str_cref name ) const { ClassInfoPtr cls; if( Utility::mapLookup( m_classes, name, cls ) ) { return cls; } else { expr_cref expr = lookup( name ); // you cannot realias a class so there is no need to recurse this. It must be of type Class // i.e. you can't do /* Foo = Class( SomeLib, SomeSymbol ); Bar = Foo; Obj = Bar( whatever ); */ if( expr.type() != EClass ) { std::ostringstream oss; oss << name << " is not a class"; throw std::invalid_argument( oss.str() ); } // A class will always have 2 parameters, a library and a symbol // The first must be the name of a library RecursiveExpressionPtr libExp = expr.param(0); if( libExp->type() != EVariable ) { std::ostringstream oss; oss << "First parameter of class " << name << " must be a library alias"; throw std::invalid_argument( oss.str() ); } // resolve the second one to a string std::string symbol; try { // rethrow with more context if it fails symbol = toString( *expr.param(1) ); } catch( std::invalid_argument const& err ) { std::ostringstream oss; oss << err.what() << "\n\t:in 2nd parameter of class definition " << name; throw oss.str(); } const DLObject * sym = NULL; std::string libName = libExp->value(); try { // try loading the symbol. If that fails, give error context. const Library & lib = getLibrary( libName ); sym = lib.getSymbol( symbol, true ); // we do want to throw if it can't load } catch( std::invalid_argument const& err ) { std::ostringstream oss; oss << err.what() << "\n\t whilst loading symbol " << symbol << " from library " << libName << " class " << name; throw std::invalid_argument( oss.str() ); } // if we are here, so far so good const BuilderFactory * fact = dynamic_cast< const BuilderFactory * >(sym); if( !fact ) { std::ostringstream oss; oss << "Symbol " << symbol << " in library " << libName << " is not a BuilderFactory, whilst loading class definition " << name; throw std::invalid_argument( oss.str() ); } cls.reset( new ClassInfo( name, fact ) ); m_classes[name] = cls; } return cls; }
void Text::onDraw(const ParentDrawInfo& pdi, IDrawer& render) { Library* lib = getLibrary(); if(!lib) return; Bound absChildBound; Bound b = childBound(); b.min = b.min * pdi.scale + pdi.offset; b.max = b.max * pdi.scale + pdi.offset; if(!pdi.bound.intersection(absChildBound, b)) return; Font* fnt = lib->getFont(font); if(!fnt) return; int settedTex = -1; UnicodeReader ur(text); Vector locsize = childBound().size(); Vector locpos(Scalar(0), locsize.y - (fnt->characterHeight() + Scalar(0.5)) * fontScale); while(!ur.empty()) { uint firstChar = ur.getFirst(); if(firstChar == '\n'){ locpos.y -= fnt->characterHeight() * fontScale; locpos.x = 0; ur.str = ur.str.afterLeftTrim(1); continue; } if(firstChar == '\r'){ locpos.x = 0; ur.str = ur.str.afterLeftTrim(1); continue; } if(isSpace(firstChar)){ const Font::CharInfo* ci = fnt->charInfo(firstChar); if(ci) locpos.x += fontScale * ci->width() * fnt->characterHeight() / ci->fontHeight; ur.str = ur.str.afterLeftTrim(1); continue; } const utf8* wordFirst = ur.str.first(); const utf8* wordEnd = ur.str.first(); while(!ur.empty()) { ConstString prev = ur.str; if(isSpace(ur.pop())){ ur.str = prev; break; } wordEnd = ur.str.first(); } if(wrapping) { uint wordLenght = fnt->stringLineLenght(ConstString(wordFirst, wordEnd)); if(locpos.x + (Scalar(wordLenght) - Scalar(0.5)) * fontScale > locsize.x && Scalar(wordLenght) * fontScale <= locsize.x){ locpos.y -= fnt->characterHeight() * fontScale; locpos.x = 0; } } UnicodeReader u(ConstString(wordFirst, wordEnd)); uint prevChar = 0; while(!u.empty()) { uint ch = u.pop(); const Font::CharInfo* ci = fnt->charInfo(ch); if(!ci) continue; Scalar scale = fontScale * fnt->characterHeight() / ci->fontHeight; const Font::ImageInfo& imgInfo = fnt->imageInfo(ci->image); locpos.x += Scalar(fnt->charactersKerning(prevChar, ch)) * scale; Vector p = position + locpos + Vector((Scalar)ci->dx - Scalar(0.5), (Scalar)ci->dy - Scalar(0.5)) * scale; Vector s((ci->du + 1) * scale, (ci->dv + 1) * scale); Bound v; v.min = p * pdi.scale + pdi.offset; v.max = (p + s) * pdi.scale + pdi.offset; Bound t(Scalar(ci->u) - Scalar(0.5), Scalar(ci->v) - Scalar(0.5), Scalar(ci->u + ci->du) + Scalar(0.5), Scalar(ci->v + ci->dv) + Scalar(0.5)); t.min *= imgInfo.invSize; t.max *= imgInfo.invSize; Bound clipedV, clipedT; if(clip(clipedV, clipedT, absChildBound, v, t)) { if(ci->image != settedTex){ render.setTexture(imgInfo.name); settedTex = ci->image; } Vector s = clipedV.size(); clipedV.min.x = floor(clipedV.min.x / scale) * scale + Scalar(0.5) * scale; clipedV.min.y = floor(clipedV.min.y / scale) * scale + Scalar(0.5) * scale; s.x = floor(Scalar(s.x / scale) + Scalar(0.5)) * scale; s.y = floor(Scalar(s.y / scale) + Scalar(0.5)) * scale; clipedV.max = clipedV.min + s; if((shadowShift.x || shadowShift.y) && shadowColor.w) { Scalar shiftX = fontScale * fnt->characterHeight(); Bound v_Sh; v_Sh.min = v.min + shadowShift * shiftX * pdi.scale; v_Sh.max = v.max + shadowShift * shiftX * pdi.scale; Bound clipedV_Sh, clipedT_Sh; if(clip(clipedV_Sh, clipedT_Sh, absChildBound, v_Sh, t)) { render.drawFontQuad(clipedV_Sh.min, clipedV_Sh.max, clipedT_Sh.min, clipedT_Sh.max, shadowColor, ci->channel, ci->bit, imgInfo.bitCompressedLenght); } } render.drawFontQuad(clipedV.min, clipedV.max, clipedT.min, clipedT.max, color, ci->channel, ci->bit, imgInfo.bitCompressedLenght); } locpos.x += Scalar(ci->width()) * scale; prevChar = ch; } } }
void Text::updateLayout_FromParent(const Bound& parentBound) { Widget::updateLayout_FromParent(parentBound); if((autoSizeX | autoSizeY | autoFontScaleByX | autoFontScaleByY) == 0 || wrapping) return; Library* lib = getLibrary(); if(!lib) return; Font* fnt = lib->getFont(font); if(!fnt) return; screen->lenghts.tmpSet(parentBound.size()); Vector maxSize(screen->lenghts.lenghts[maxSizeXType].x * maxSizeX, screen->lenghts.lenghts[maxSizeXType].y * maxSizeY); Vector marginLow, marginHi; margin.getLowAndHi(marginLow, marginHi, parentBound.size(), screen->lenghts); maxSize -= marginLow + marginHi; Vector2i stringSize = fnt->stringSize(text); stringSize.x += 2; stringSize.y += 2; Scalar maxFontScaleByX = -1; if(autoFontScaleByX) { if(autoSizeX && maxSizeXType) maxFontScaleByX = maxSize.x / Scalar(stringSize.x); else maxFontScaleByX = size.x / Scalar(stringSize.x); } Scalar maxFontScaleByY = -1; if(autoFontScaleByY) { uint h = autoFontScaleByYConsiderateNewLines ? stringSize.y : fnt->characterHeight(); if(autoSizeY && maxSizeYType) maxFontScaleByY = maxSize.y / Scalar(h); else maxFontScaleByY = size.y / Scalar(h); } if(maxFontScaleByX > 0) { if(maxFontScaleByY > 0) fontScale = min(maxFontScaleByX, maxFontScaleByY); else fontScale = maxFontScaleByX; } else if(maxFontScaleByY > 0) { fontScale = maxFontScaleByY; } if(autoSizeX) { if(maxSizeXType) size.x = min(stringSize.x * fontScale, maxSize.x); else size.x = stringSize.x * fontScale; } if(autoSizeY) { if(maxSizeYType) size.y = min(stringSize.y * fontScale, maxSize.y); else size.y = stringSize.y * fontScale; } Widget::updateLayout_FromParent(parentBound); }
int loadEffect(cnode *root) { cnode *node; effect_uuid_t uuid; lib_entry_t *l; effect_descriptor_t *d; list_elem_t *e; node = config_find(root, LIBRARY_TAG); if (node == NULL) { return -EINVAL; } l = getLibrary(node->value); if (l == NULL) { ALOGW("loadEffect() could not get library %s", node->value); return -EINVAL; } node = config_find(root, UUID_TAG); if (node == NULL) { return -EINVAL; } if (stringToUuid(node->value, &uuid) != 0) { ALOGW("loadEffect() invalid uuid %s", node->value); return -EINVAL; } d = malloc(sizeof(effect_descriptor_t)); if (!d) { ALOGE("failed to allocate effect descriptor"); return -EINVAL; } if (l->desc->get_descriptor(&uuid, d) != 0) { char s[40]; uuidToString(&uuid, s, 40); ALOGW("Error querying effect %s on lib %s", s, l->name); free(d); return -EINVAL; } #if (LOG_NDEBUG==0) char s[256]; dumpEffectDescriptor(d, s, 256); ALOGV("loadEffect() read descriptor %p:%s",d, s); #endif if (EFFECT_API_VERSION_MAJOR(d->apiVersion) != EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) { ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name); free(d); return -EINVAL; } e = malloc(sizeof(list_elem_t)); if (!e) { return -ENOMEM; } e->object = d; e->next = l->effects; l->effects = e; // After the UUID node in the config_tree, if node->next is valid, // that would be sub effect node. // Find the sub effects and add them to the gSubEffectList node = node->next; int count = 2; bool hwSubefx = false, swSubefx = false; list_sub_elem_t *sube = NULL; if (node != NULL) { ALOGV("Adding the effect to gEffectSubList as there are sub effects"); sube = malloc(sizeof(list_sub_elem_t)); if (!sube) { ALOGE("failed to allocate sub element list"); return -ENOMEM; } sube->object = d; sube->sub_elem = NULL; sube->next = gSubEffectList; gSubEffectList = sube; } while (node != NULL && count) { if (addSubEffect(node)) { ALOGW("loadEffect() could not add subEffect %s", node->value); // Change the gSubEffectList to point to older list; gSubEffectList = sube->next; free(sube->sub_elem);// Free an already added sub effect sube->sub_elem = NULL; free(sube); return -ENOENT; } sub_effect_entry_t *subEntry = (sub_effect_entry_t*)gSubEffectList->sub_elem->object; effect_descriptor_t *subEffectDesc = (effect_descriptor_t*)(subEntry->object); // Since we return a dummy descriptor for the proxy during // get_descriptor call,we replace it with the correspoding // sw effect descriptor, but with Proxy UUID // check for Sw desc if (!((subEffectDesc->flags & EFFECT_FLAG_HW_ACC_MASK) == EFFECT_FLAG_HW_ACC_TUNNEL)) { swSubefx = true; *d = *subEffectDesc; d->uuid = uuid; ALOGV("loadEffect() Changed the Proxy desc"); } else hwSubefx = true; count--; node = node->next; } // 1 HW and 1 SW sub effect found. Set the offload flag in the Proxy desc if (hwSubefx && swSubefx) { d->flags |= EFFECT_FLAG_OFFLOAD_SUPPORTED; } return 0; }