bool f_interface_exists(CStrRef interface_name, bool autoload /* = true */) { const ClassInfo *info = ClassInfo::FindInterface(interface_name.data()); if (info) { if (autoload && (info->getAttribute() & ClassInfo::IsVolatile) != 0) { checkClassExists(interface_name, get_globals(), true); } return info->isDeclared(); } // look for interfaces redeclared by classes info = ClassInfo::FindClass(interface_name.data()); if (info && info->isClassInfoRedeclared()) { if (autoload && (info->getAttribute() & ClassInfo::IsVolatile) != 0) { checkClassExists(interface_name, get_globals(), true); } // XXX we currently do not update cso for interfaces, which means that // if the name is declared, and getCurrent() is still info itself, it must // be an interface. if (!info->isDeclared()) return false; return info->getCurrent()->isClassInfoRedeclared(); } return false; }
bool ClassInfo::isDeclared() const { if (m_attribute & IsVolatile) { if (m_attribute & IsInterface) { return get_globals()->interface_exists(m_name); } return get_globals()->class_exists(m_name); } return true; }
/* This guy calls the visitor from within the mutext lock, so the visitor cannot: - take too much time - try to acquire the mutext again - call a fontscaler (which might call into the cache) */ SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface, const SkDescriptor* desc, bool (*proc)(const SkGlyphCache*, void*), void* context) { if (!typeface) { typeface = SkTypeface::GetDefaultTypeface(); } SkASSERT(desc); SkGlyphCache_Globals& globals = get_globals(); SkGlyphCache* cache; { Exclusive ac(globals.fLock); globals.validate(); for (cache = globals.internalGetHead(); cache != nullptr; cache = cache->fNext) { if (cache->fDesc->equals(*desc)) { globals.internalDetachCache(cache); if (!proc(cache, context)) { globals.internalAttachCacheToHead(cache); cache = nullptr; } return cache; } } } // Check if we can create a scaler-context before creating the glyphcache. // If not, we may have exhausted OS/font resources, so try purging the // cache once and try again. { // pass true the first time, to notice if the scalercontext failed, // so we can try the purge. SkScalerContext* ctx = typeface->createScalerContext(desc, true); if (!ctx) { get_globals().purgeAll(); ctx = typeface->createScalerContext(desc, false); SkASSERT(ctx); } cache = new SkGlyphCache(typeface, desc, ctx); } AutoValidate av(cache); if (!proc(cache, context)) { // need to reattach globals.attachCacheToHead(cache); cache = nullptr; } return cache; }
JNIEXPORT float JNICALL JNI_FN(MuPDF_getPageWidth)(JNIEnv *env, jobject thiz) { globals *glo = get_globals(env, thiz); LOGE("PageWidth=%d", glo->pages[glo->current].width); return glo->pages[glo->current].width; }
static int check(CSOUND *csound, CNTRL *p) { CONTROL_GLOBALS *pp = get_globals(csound, &(p->p)); readvalues(pp); *p->kdest = pp->checks[(int) MYFLT2LONG(*p->kcntl)]; return OK; }
Array CmdVariable::GetGlobalVariables() { Array ret = hhvm ? g_vmContext->m_globalVarEnv->getDefinedVariables() : get_globals()->getDefinedVars(); ret.remove("GLOBALS"); return ret; }
EnvTest( long version, GlobalFunc *global, LWLayoutGeneric *local, void *serverData ) { LWItemID id; LWChanGroupID group; LWChannelID chan; if ( version != LWLAYOUTGENERIC_VERSION ) return AFUNC_BADVERSION; if ( !get_globals( global )) return AFUNC_BADGLOBAL; id = iteminfo->first( LWI_CAMERA, NULL ); group = iteminfo->chanGroup( id ); chan = chinfo->nextChannel( group, NULL ); while ( chan ) { if ( !strcmp( chinfo->channelName( chan ), "Position.X" )) break; chan = chinfo->nextChannel( group, chan ); } if ( !chan ) { msgf->info( "Couldn't find Position.X", NULL ); return AFUNC_OK; } test_eval( chan ); return AFUNC_OK; }
Variant &VariableStringPropertyExpression::lval(VariableEnvironment &env) const { Variant &proxy = get_globals()->__lvalProxy; Variant &lv = m_obj->getRef(env); SET_LINE; return lv.o_lval(m_name, proxy); }
Variant &ObjectPropertyExpression::lval(VariableEnvironment &env) const { // How annoying. Sometimes object is an lval and should be treated as such // and sometimes it isn't eg method call. const LvalExpression *lobj = m_obj->toLval(); if (lobj) { Variant &lv = lobj->lval(env); String name(m_name->get(env)); SET_LINE; return lv.o_lval(name, get_globals()->__lvalProxy); } else { Variant obj(m_obj->eval(env)); String name(m_name->get(env)); SET_LINE; return obj.o_lval(name, get_globals()->__lvalProxy); } }
JNIEXPORT float JNICALL JNI_FN(MuPDF_getPageHeight)(JNIEnv *env, jobject thiz) { globals *glo = get_globals(env, thiz); LOGE("PageHeight=%d", glo->pages[glo->current].height); return glo->pages[glo->current].height; }
JNIEXPORT int JNICALL JNI_FN(MuPDF_countPagesInternal)(JNIEnv *env, jobject thiz) { globals *glo = get_globals(env, thiz); return fz_count_pages(glo->doc); }
Array ClassInfo::GetConstants() { if (!s_loaded) Load(); Array res; Array dyn; { const ConstantMap &scm = s_systemFuncs->getConstants(); for (ConstantMap::const_iterator it = scm.begin(); it != scm.end(); ++it) { res.set(it->first, it->second->value); } } { const ConstantMap &ucm = s_userFuncs->getConstants(); for (ConstantMap::const_iterator it = ucm.begin(); it != ucm.end(); ++it) { res.set(it->first, it->second->value); } } if (s_hook) { dyn = s_hook->getConstants(); if (!dyn.isNull()) { res.merge(dyn); } } dyn = get_globals()->getDynamicConstants(); if (!dyn.isNull()) { res.merge(dyn); } return res; }
Variant &NestedVariableEnvironment::getVar(CStrRef s, SuperGlobal sg) { if (sg == SgGlobals) { return m_global = get_global_array_wrapper(); } if (sg == SgNormal) return m_ext->getVar(s, sg); return get_globals()->get(s); }
void value_set_analysis_fivrt::add_vars( const goto_functionst &goto_functions) { // get the globals std::list<value_set_fivrt::entryt> globals; get_globals(globals); value_set_fivrt &v=state.value_set; v.add_vars(globals); forall_goto_functions(f_it, goto_functions) { // get the locals std::set<irep_idt> locals; get_local_identifiers(f_it->second, locals); for(auto l : locals) { const symbolt &symbol=ns.lookup(l); std::list<value_set_fivrt::entryt> entries; get_entries(symbol, entries); v.add_vars(entries); } }
void VariableEnvironment::flagGlobal(CStrRef name, int idx) { if (isKindOf(KindOfFuncScopeVariableEnvironment)) { FuncScopeVariableEnvironment *fenv = static_cast<FuncScopeVariableEnvironment *>(this); Variant *var = fenv->getIdx(idx); if (!var) { AssocList &alist = fenv->getAssocList(); ASSERT(!alist.getPtr(name)); var = &alist.append(name); fenv->setIdx(idx, var); } var->assignRef(get_globals()->get(name)); return; } getVar(name, SgNormal).assignRef(get_globals()->get(name)); }
Array ClassInfo::GetClasses(bool declaredOnly) { if (!s_loaded) Load(); Array ret; for (ClassMap::const_iterator iter = s_classes.begin(); iter != s_classes.end(); ++iter) { if (!declaredOnly || !(iter->second->m_attribute & IsVolatile)) { ret.append(iter->first); } } // This way, the order of newly declared classes can be more consistent // with PHP. if (declaredOnly) { Array classes = get_globals()->getVolatileClasses(); for (ArrayIter iter(classes); iter; ++iter) { ret.append(iter.first()); } } if (s_hook) { Array dyn = s_hook->getClasses(); if (!dyn.isNull()) { ret = ret.merge(dyn); } } return ret; }
void invariant_propagationt::add_objects( const goto_functionst &goto_functions) { // get the globals object_listt globals; get_globals(globals); for(goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.begin(); f_it!=goto_functions.function_map.end(); f_it++) { // get the locals std::set<irep_idt> locals; get_local_identifiers(f_it->second, locals); const goto_programt &goto_program=f_it->second.body; // cache the list for the locals to speed things up typedef hash_map_cont<irep_idt, object_listt, irep_id_hash> object_cachet; object_cachet object_cache; for(goto_programt::instructionst::const_iterator i_it=goto_program.instructions.begin(); i_it!=goto_program.instructions.end(); i_it++) { #if 0 invariant_sett &is=(*this)[i_it].invariant_set; is.add_objects(globals); #endif for(std::set<irep_idt>::const_iterator l_it=locals.begin(); l_it!=locals.end(); l_it++) { // cache hit? object_cachet::const_iterator e_it=object_cache.find(*l_it); if(e_it==object_cache.end()) { const symbolt &symbol=ns.lookup(*l_it); object_listt &objects=object_cache[*l_it]; get_objects(symbol, objects); #if 0 is.add_objects(objects); #endif } #if 0 else is.add_objects(e_it->second); #endif } } } }
void SkGlyphCache_Globals::AttachCache(SkGlyphCache* cache) { if (cache == nullptr) { return; } SkASSERT(cache->fNext == nullptr); get_globals().attachCacheToHead(cache); }
const struct loadparm_s3_helpers *loadparm_s3_helpers(void) { struct loadparm_s3_helpers *helpers; helpers = &s3_fns; helpers->globals = get_globals(); helpers->lp_string = lp_string; return helpers; }
Variant &ThisStringPropertyExpression::lval(VariableEnvironment &env) const { Variant &proxy = get_globals()->__lvalProxy; if (!env.currentObject().is(KindOfObject)) { SET_LINE; raise_error("Using $this when not in an object context"); } SET_LINE; return env.currentObject().o_lval(m_name, proxy); }
static int button(CSOUND *csound, CNTRL *p) { CONTROL_GLOBALS *pp = get_globals(csound, &(p->p)); int t = (int)MYFLT2LONG(*p->kcntl); readvalues(pp); *p->kdest = pp->buttons[t]; pp->buttons[t] = 0; return OK; }
Variant &EvalObjectData::___offsetget_lval(Variant v_name) { const MethodStatement *ms = getMethodStatement("offsetget"); if (ms) { Variant &v = get_globals()->__lvalProxy; v = ms->invokeInstance(Object(root), CREATE_VECTOR1(v_name), false); return v; } else { return DynamicObjectData::___offsetget_lval(v_name); } }
bool f_interface_exists(CStrRef interface_name, bool autoload /* = true */) { const ClassInfo::ClassInfo *info = ClassInfo::FindInterface(interface_name.data()); if (info) { if (autoload && (info->getAttribute() & ClassInfo::IsVolatile) != 0) { checkClassExists(interface_name, get_globals(), true); } return info->isDeclared(); } return false; }
void SkGlyphCache::VisitAll(Visitor visitor, void* context) { SkGlyphCache_Globals& globals = get_globals(); Exclusive ac(globals.fLock); SkGlyphCache* cache; globals.validate(); for (cache = globals.internalGetHead(); cache != nullptr; cache = cache->fNext) { visitor(*cache, context); } }
void SkGlyphCache::ForEachStrike(std::function<void(const SkGlyphCache&)> visitor) { SkGlyphCache_Globals& globals = get_globals(); SkAutoExclusive ac(globals.fLock); SkGlyphCache* cache; globals.validate(); for (cache = globals.internalGetHead(); cache != nullptr; cache = cache->fNext) { visitor(*cache); } }
bool f_class_exists(CStrRef class_name, bool autoload /* = true */) { const ClassInfo *info = ClassInfo::FindClass(class_name.data()); if (info) { if (autoload && (info->getAttribute() & ClassInfo::IsVolatile) != 0) { checkClassExists(class_name, get_globals(), true); } if (!info->isDeclared()) return false; // XXX see the comment in f_interface_exists(). return !(info->getCurrent()->isClassInfoRedeclared()); } return false; }
/* ** Description ** Initialize application specific variables */ void init_global_appl (int apid, int physical_vdi_id, char * appl_name) { GLOBAL_APPL * globals; int work_in[] = {1,1,1,1,1,1,1,1,1,1,2}; int work_out[57]; int temp_vid; globals = get_globals(apid); globals->pid = getpid(); work_in[0] = 5; DEBUG3 ("lib_global.c: init_global_appl: physical_vdi_id = %d", physical_vdi_id); /* FIXME: change vid types to int and remove temp_vid */ temp_vid = physical_vdi_id; v_opnvwk (work_in, &temp_vid, work_out); globals->vid = temp_vid; DEBUG2("lib_global.c: apid = %d globals->vid = %d", apid, globals->vid); /* There is no default desktop background */ globals->desktop_background = NULL; /* There is no default menu */ globals->menu = NULL; /* Setup resource header */ globals->rshdr = NULL; /* Setup path mode: MiNT or Unix */ globals->path_mode = default_path_mode; /* Initialize application and accessory list as empty */ globals->appl_menu.count = 0; globals->appl_menu.size = 10; globals->appl_menu.entries = (APPL_ENTRY *)malloc (sizeof (APPL_ENTRY) * 10); globals->acc_menu.count = 0; globals->acc_menu.size = 10; globals->acc_menu.entries = (APPL_ENTRY *)malloc (sizeof (APPL_ENTRY) * 10); strcpy(globals->application_name, appl_name); globals->common = &global_common; DEBUG3 ("lib_global.c: Leaving global_init"); }
static int atexit_common (const struct one_atexit_routine *r, const void *dso) { struct keymgr_atexit_list *g = get_globals (); if (! g) return -1; if (g->running_routines || g->atexit_status == atexit_status_missing) return add_routine (g, r); if (g->atexit_status >= atexit_status_working) { int result; if (r->has_arg) { cxa_atexit_p cxa_atexit = g->cxa_atexit_f; result = _keymgr_set_and_unlock_processwide_ptr (KEYMGR_ATEXIT_LIST, g); if (CHECK_KEYMGR_ERROR (result)) return -1; return cxa_atexit (r->callback.cac, r->arg, dso); } else { atexit_p atexit_f = g->atexit_f; result = _keymgr_set_and_unlock_processwide_ptr (KEYMGR_ATEXIT_LIST, g); if (CHECK_KEYMGR_ERROR (result)) return -1; return atexit_f (r->callback.ac); } } else { cxa_atexit_p cxa_atexit = g->cxa_atexit_f; struct one_atexit_routine *alloced; int result; result = _keymgr_set_and_unlock_processwide_ptr (KEYMGR_ATEXIT_LIST, g); if (CHECK_KEYMGR_ERROR (result)) return -1; alloced = malloc (sizeof (struct one_atexit_routine)); if (! alloced) return -1; *alloced = *r; return cxa_atexit (cxa_atexit_wrapper, alloced, dso); } }
Variant &ObjectStringPropertyExpression::lval(VariableEnvironment &env) const { const LvalExpression *lobj = m_obj->toLval(); Variant &proxy = get_globals()->__lvalProxy; if (lobj) { Variant &lv = lobj->lval(env); SET_LINE; return lv.o_lval(m_name, proxy); } else { Variant obj(m_obj->eval(env)); SET_LINE; proxy = ref(obj.o_lval(m_name, proxy)); return proxy; } }
SkExclusiveStrikePtr SkGlyphCache::FindStrikeExclusive(const SkDescriptor& desc) { SkGlyphCache_Globals& globals = get_globals(); SkGlyphCache* cache; SkAutoExclusive ac(globals.fLock); for (cache = globals.internalGetHead(); cache != nullptr; cache = cache->fNext) { if (*cache->fDesc == desc) { globals.internalDetachCache(cache); return SkExclusiveStrikePtr(cache); } } return SkExclusiveStrikePtr(nullptr); }