Пример #1
0
RObject *RObjectList::findObjects (const QStringList &path, RObjectSearchMap *matches, const QString &op) {
	RK_TRACE (OBJECTS);
	RK_ASSERT (op == "$");

	if (path.value (1) == "::") {
		RObject *environment = findPackage (path[0]);
		if (!environment) return 0;
		
		return environment->findObjects (path.mid (2), matches, "$");
	} else if (path.value (1) == ":::") {
		RObject *environment = findPackage (path[0]);
		if (environment) environment = static_cast<REnvironmentObject*> (environment)->namespaceEnvironment ();
		if (!environment) environment = orphan_namespaces->findOrphanNamespace (path[0]);
		if (!environment) return 0;

		return environment->findObjects (path.mid (2), matches, "$");
	} else if (path.value (0) == ".GlobalEnv") {
		if (path.length () > 1) return getGlobalEnv ()->findObjects (path.mid (2), matches, "$");
		else if (matches) matches->insert (path.value (0), getGlobalEnv ());	// no return, here: At least one more match will be found in base
		else return getGlobalEnv ();
	}

	// no namespace given. Search all environments for matches
	RObject *found = getGlobalEnv ()->findObjects (path, matches, "$");
	if (found && !matches) return found;
	for (int i = 0; i < childmap.size (); ++i) {
		found = childmap[i]->findObjects (path, matches, "$");
		if (found && !matches) return found;
	}
	return 0;
}
Пример #2
0
int packagesPage::solveDepsCheckedGenerateList(const meskPackage package)
{
	// populate full list and loop and see if a package is required by other checked packages that are not in the list ?
	//cerr << "checking package : " << package.Name.toStdString() << endl << flush;
	checkDepPackage(package.Name);
	checkPackages.push_back(package.Name);
		
	// check all depends ons and all their depend ons ..
    for ( int i =0; i < package.Depends.size(); i++) 
    {
        meskPackage* dep = findPackage(package.Depends.at(i));

        if(dep)
        {
			if(dep->currentDependencies.indexOf(package.Name) == -1)
			{
				dep->currentDependencies.push_back(package.Name);
			}

			if (checkPackages.indexOf(dep->Name) == -1)
			{
				solveDepsCheckedGenerateList(*dep);
			}
		}
    }

    return 0;
}
Пример #3
0
//////////////////////////////////////////////////////////////////////////
// requestPackage
CsPackage* CsCore::requestPackage( const BcName& Package )
{
	CsPackage* pPackage = findPackage( Package );
	if( pPackage != NULL )
	{
		return pPackage;
	}

	// Check for a packed package.
	BcPath PackedPackage( getPackagePackedPath( Package ) );
	BcPath ImportPackage( getPackageImportPath( Package ) );
	BcBool PackageExists = FsCore::pImpl()->fileExists( (*PackedPackage).c_str() ) || FsCore::pImpl()->fileExists( (*ImportPackage).c_str() );

	// If it exists, create it. Internally it will trigger it's own load.
	if( PackageExists )
	{
		pPackage = new CsPackage( Package );
		PackageList_.push_back( pPackage );
	}	
	else
	{
		BcAssertMsg( BcFalse, "CsCore: Can't import package, missing \"%s\" or \"%s\"", (*PackedPackage).c_str(), (*ImportPackage).c_str() );
	}

	//
	return pPackage;	
}
Пример #4
0
Package *PackageModel::findPackage(QSharedPointer<PackageInfo> packagePtr)
{
    PackageKit::Package *p1 = packagePtr.data();
    QString name1 = p1? p1->name(): QString();

    return findPackage(name1);
}
Пример #5
0
void RObjectList::updateNamespaces (const QStringList namespace_names) {
	RK_TRACE (OBJECTS);

	QStringList orphan_namespace_names;
	for (int i = 0; i < namespace_names.size (); ++i) {
		if (!findPackage (namespace_names[i])) orphan_namespace_names.append (namespace_names[i]);
	}
	orphan_namespaces->updateFromR (update_chain, orphan_namespace_names);
}
Пример #6
0
std::vector<Pegasus::CIMInstance> InstallDialog::getPackages()
{
    QList<QListWidgetItem *> list = m_ui->list_widget->selectedItems();
    std::vector<Pegasus::CIMInstance> vector;
    for (int i = 0; i < list.size(); i++) {
        vector.push_back(findPackage(list[i]->text()));
    }

    return vector;
}
Пример #7
0
Ptr<ReadableStreamHandle>
PackageManager::readStream(const std::string & theRelativePath,
                         const std::string & thePackage)
{
    IPackagePtr myPackage = findPackage(theRelativePath, thePackage);
    if (myPackage) {
        return myPackage->getStream(theRelativePath);
    }
    return Ptr<ReadableStreamHandle>();
}
Пример #8
0
Package *PackageModel::findPackage(QSharedPointer<PackageInfo> packagePtr)
{
#ifdef PACKAGEMODEL_LOG   	
    qDebug() << Q_FUNC_INFO;	
#endif
    PackageInfo *p1 = packagePtr.data();
    QString id1 = p1? p1->id(): QString();

    return findPackage(id1);
}
Пример #9
0
Package* Application::loadPackage(const std::string &name, const SourcePosition &p, Package *requestor) {
    if (auto package = findPackage(name)) {
        if (!package->finishedLoading()) {
            throw CompilerError(p, "Circular dependency detected: ", requestor->name(), " and ", name,
                                " depend on each other.");
        }
        return package;
    }

    auto path = packageDirectory_ + "/" + name + "/header.emojic";
    auto package = std::make_unique<Package>(name, path, this);
    auto rawPtr = package.get();
    packages_.emplace(name, rawPtr);
    packagesLoadingOrder_.emplace_back(std::move(package));
    rawPtr->parse();
    rawPtr->analyse();
    return rawPtr;
}
Пример #10
0
Ptr<ReadableBlockHandle>
PackageManager::readFile(const std::string & theRelativePath,
                         const std::string & thePackage,
                         bool theThreadLockedFlag)
{
    if (theThreadLockedFlag) {
        _myReadLock.lock();
    }
    Ptr<ReadableBlockHandle> myResult = Ptr<ReadableBlockHandle>();
    IPackagePtr myPackage = findPackage(theRelativePath, thePackage);
    if (myPackage) {
        myResult = myPackage->getFile(theRelativePath);
    }
    if (theThreadLockedFlag) {
        _myReadLock.unlock();
    }
    return myResult;
}
Пример #11
0
//////////////////////////////////////////////////////////////////////////
// internalRequestResource
BcBool CsCore::internalRequestResource( const BcName& Package, const BcName& Name, const ReClass* Class, ReObjectRef< CsResource >& Handle )
{
	// Find package
	CsPackage* pPackage = findPackage( Package );
	if( pPackage || Package == BcName::NONE )
	{
		// If we can't find resource, throw an error.
		if( internalFindResource( Package, Name, Class, Handle ) == BcFalse )
		{
			BcPrintf( "CsCore::requestResource: Resource not availible \"%s.%s:%s\" requested.\n", (*Package).c_str(), (*Name).c_str(), (*Class->getName()).c_str() );
		}
	}
	else
	{
		BcPrintf( "CsCore::requestResource: Invalid package \"%s\" requested.\n", (*Package).c_str() );
	}
	
	return Handle.isValid();
}
Пример #12
0
FunctionPtr Findable::findConstructor( ScopePtr stable, const std::vector<std::string>& names )
{
	ScopePtr pkg_info = stable;	
	for( int idx = 0 ; idx < names.size() - 2 ; idx ++ )
	{	
		pkg_info = findPackage( pkg_info, names[idx] );
		if( pkg_info == NULL )
		{
			std::cerr << " findFunction can't find pkg "<<names[idx]<<std::endl;
			return FunctionPtr(); 
		}
	}

	ScopePtr class_type = findClassType_downward( pkg_info.get(), names[names.size()-1] );
	FunctionPtr found = findFunction_downward( class_type.get(), names[names.size()-1] );
	if( found ) return found;

	return FunctionPtr();
}
Пример #13
0
//////////////////////////////////////////////////////////////////////////
// processCallbacks
void CsCore::processCallbacks()
{
	TPackageReadyCallbackListIterator It = PackageReadyCallbackList_.begin();

	while( It != PackageReadyCallbackList_.end() )
	{
		TPackageReadyCallback& CallbackData( *It );
		CsPackage* pPackage = findPackage( CallbackData.Package_ );
		if( pPackage != NULL &&
			pPackage->isReady() )
		{
			CallbackData.Callback_( pPackage, CallbackData.ID_ );
			It = PackageReadyCallbackList_.erase( It );
		}
		else
		{
			++It;
		}
	}
}
Пример #14
0
ScopePtr Findable::findPackage( Scope* stable, const std::string& pkgs_name )
{

	for( std::vector<SymbolPtr>::iterator I = stable->m_childs.begin(), B = stable->m_childs.end()
			; I != B ; I ++ )
	{
//		std::cerr << " findPackage iterator to " <<(*I)->name() << std::endl;
		if( (*I)->name() == pkgs_name && (*I)->is( Symbol::T_SCOPE ) )
		{
			ScopePtr pkg_symbol = DYNA_CAST( Scope, *I );
			if( pkg_symbol->getScopeType() == Scope::T_PACKAGE )
			{
				return pkg_symbol;
			}
		}
	}
	if( stable->m_parent )
		return findPackage( stable->m_parent, pkgs_name );
	return ScopePtr();
}
Пример #15
0
IPackage::FileList
PackageManager::findFiles(const std::string & theRelativePath,
                          const std::string & thePackage,
                          bool doRecursiveSearch /*= false */)
{
    AC_TRACE << "findFiles pkg='" << thePackage << "' path='" << theRelativePath << "'";
    IPackage::FileList myFileList;
    if (!thePackage.empty()) {
        IPackagePtr myPackage = findPackage("", thePackage);
        myFileList = listPackageFiles(myPackage, theRelativePath, doRecursiveSearch);
    } else {
        for (PackageList::const_iterator iter = _myPackages.begin();
             iter != _myPackages.end(); ++iter) {
            IPackage::FileList myTmpFileList = listPackageFiles((*iter), theRelativePath, doRecursiveSearch);
            for (unsigned i = 0; i < myTmpFileList.size(); ++i) {
                myFileList.push_back(myTmpFileList[i]);
            }
        }
    }
    return myFileList;
}
Пример #16
0
Package* Package::loadPackage(const char *name, EmojicodeChar ns, const Token *errorToken) {
    Package *package = findPackage(name);
    
    if (package) {
        if (!package->finishedLoading()) {
            compilerError(errorToken, "Circular dependency detected: %s tried to load a package which intiatiated %s’s own loading.", name, name);
        }
    }
    else {
        char *path;
        asprintf(&path, packageDirectory "%s/header.emojic", name);
        
        package = new Package(name);
        
        if (strcmp("s", name) != 0) {
            package->loadPackage("s", globalNamespace, errorToken);
        }
        package->parse(path, errorToken);
    }
    
    package->loadInto(this, ns, errorToken);
    return package;
}
Пример #17
0
Package::Package(QString path, QObject* parent)
    : QObject(parent),
    m_metadata(new MetaData)
{
    /*
    A package roughly looks like this:

    examplepackage/
    |-- actions
    |   |-- silk-webapp-silk-commitlog.desktop
    |   |-- silk-webapp-silk-sidebar.desktop
    |   |-- silk-webapp-silk-sourcetree.desktop
    |   `-- silk-webapp-silk-urltrigger.desktop
    |-- plugin.desktop
    |-- scripts
    |   `-- togglesidebar.js
    `-- webapp.desktop


    */
    //m_metadata->pluginName = QString("silk");
    QString installedPath = findPackage(path);
    if (!installedPath.isEmpty()) {
        m_root = installedPath;
        m_metadataFile = m_root.path() + "/" + "metadata.desktop";
        readMetadata();
        readDir();
        //kDebug() << "installed, but valid?" << isValid();
        return;
    }

    QDir _d(path);
    if (_d.isRelative()) {
        path = QDir::currentPath() + "/" + path;
    }
    
    KUrl _dir(path);

    if (path.isEmpty()) {
        kDebug() << "Empty package structure";
    } else if (path.endsWith(".selkie")) {
        //kDebug() << "Package file:" << path;
        //QString unpackPath = "/tmp/unpacked/";

        KTempDir tmp;
        tmp.setAutoRemove(false);
        //kDebug() << "TempDir:" << tmp.name();
        QString unpackPath = tmp.name();
        importPackage(path, unpackPath);
        m_root = KUrl(unpackPath);
        m_metadataFile = unpackPath + "/" + "metadata.desktop";
        readMetadata();
        readDir();
    } else if (_dir.isValid()) {
        //kDebug() << "Reading dir" << _dir;
        m_root = _dir;
        m_metadataFile = m_root.path() + "/" + "metadata.desktop";
        readMetadata();
        readDir();
    }
    //show();
}
Пример #18
0
int packagesPage::solveDepsUnCheckedGenerateList(const meskPackage package)
{
 	unCheckPackages.push_back(package.Name);
 	uncheckDepPackage(package.Name);
	//cerr << "2" << endl << flush;
	// try to uncheck all the required by packages
	for ( int i =0; i < package.Depends.size(); i++) 
    {
        meskPackage* dep = findPackage(package.Depends.at(i));
        if(dep)
        {
			dep->currentDependencies.removeAll(package.Name);
						
			if (unCheckPackages.indexOf(dep->Name) == -1 &&
				dep->currentDependencies.size() == 0)
			{
				solveDepsUnCheckedGenerateList(*dep);
			}
		}
    }
    
    // remove all parent packages , useful if we enable to edit dependy package in the future
   	for ( int i =0; i < package.Dependencies.size(); i++) 
    {
        meskPackage* dep = findPackage(package.Dependencies.at(i));
        if(dep)
        {
			dep->currentDependencies.removeAll(package.Name);
						
			if (unCheckPackages.indexOf(dep->Name) == -1 &&
				dep->currentDependencies.size() == 0)
			{
				solveDepsUnCheckedGenerateList(*dep);
			}
		}
    }
    return 0;
    
    /*
	meskPackage* pkg = findPackage(package.Depends.at(i));
	if(!pkg)
	{
		return 1;
		//dep->currentDependencies.push_back(package.Name);
	}
		

	for ( int i =0; i < dep->currentDependencies.size(); i++)
	{
		meskPackage mpackage = getMeskPackage(package.Dependencies.at(i));
		if(mpackage.Critical || solveDepsUnChecked(mpackage))
		{
			setStatus(tr("Couldn't un-select ") + package.Name + tr(" which is required by ") + mpackage.Name, ERROR);
			continue;
		}
		uncheckDepPackage(package.Name);
	}
	
	return 0;
	
	for ( int i =0; i < package.Dependencies.size(); i++)
	{
		// if package is selected, then give an error and say that
		// this package is required by this dependency
		// otherwise continue and try to uncheck this pakcage and all it's packages...
		meskPackage mpackage = getMeskPackage(package.Dependencies.at(i));
		if(mpackage.Critical || solveDepsUnChecked(mpackage))
		{
			setStatus(tr("Couldn't un-select ") + package.Name + tr(" which is required by ") + mpackage.Name, ERROR);
			continue;
		}
		
	}
	
	uncheckDepPackage(package.Name);
	return 0;*/
	
	/*
    for ( int i =0; i < package.Depends.size(); i++)
    {
        solveDepsUnChecked(getMeskPackage(package.Depends.at(i)));
        for ( int k =0; k < pkgDeps[package.Depends.at(i)].size(); k++)
        {
            if (pkgDeps[package.Depends.at(i)].at(k) == package.Name)
            {
                pkgDeps[package.Depends.at(i)].erase(pkgDeps[package.Depends.at(i)].begin()+k);
                if (pkgDeps[package.Depends.at(i)].size() == 0)
                {
                    uncheckDepPackage(package.Depends.at(i));
                }
                break;
            }
        }
    }
    return 0;
    */
}