예제 #1
0
void OptionsDialog::addConfig()
    {
    GtkEntry *newNameEntry = GTK_ENTRY(Builder::getBuilder()->getWidget("NewConfigNameEntry"));

    // Update the build config option
    std::string compStr = mProjectOptions.getValue(OptBuildConfigs);
    CompoundValue compVal;
    compVal.parseString(compStr);
    OovString newName = Gui::getText(newNameEntry);

    OovStringVec cfgs = compVal;
    cfgs.push_back(BuildConfigAnalysis);
    cfgs.push_back(BuildConfigDebug);
    cfgs.push_back(BuildConfigRelease);
    bool found = std::find(cfgs.begin(), cfgs.end(), newName) != cfgs.end();
    if(!found)
        {
        compVal.addArg(newName);
        mProjectOptions.setNameValue(OptBuildConfigs, compVal.getAsString());

        // Leave what is on the screen, and change the config name.Save the
        // screen data to the new config.
        mCurrentBuildConfig = newName;
    //    ScreenOptions options(mCurrentBuildConfig);
     //   options.screenToOptions();

        updateBuildConfig();
        }
    else
        Gui::messageBox("Configuration already exists", GTK_MESSAGE_INFO);
    }
예제 #2
0
const OovStringVec ProjectBuildArgs::getAllCrcLinkArgs() const
    {
    OovStringVec vec;
    for(auto item : mLinkArgs)
        vec.push_back(item.mString);
    std::copy(mPackageCrcLinkArgs.begin(), mPackageCrcLinkArgs.end(),
            std::back_inserter(vec));
    return vec;
    }
예제 #3
0
void ProjectBuildArgs::updateArgs()
    {
    OovStringVec args;
    CompoundValue baseArgs;
    baseArgs.parseString(mBuildEnv.getValue(OptCppArgs));
    for(auto const &arg : baseArgs)
        {
        args.push_back(arg);
        }
    parseArgs(args);
    }
예제 #4
0
OovStringVec NameValueRecord::getMatchingNames(OovStringRef const baseName) const
    {
    OovStringVec names;
    int len = baseName.numBytes();
    for(auto const &nv : mNameValues)
        {
        if(nv.first.compare(0, len, baseName, len) == 0)
            {
            names.push_back(nv.first);
            }
        }
    return names;
    }
예제 #5
0
OovStringVec ComponentTypesFile::getComponentNamesByType(eCompTypes cft) const
    {
    OovStringVec allCompNames = CompoundValueRef::parseString(
        mCompTypesFile.getValue("Components"));
    OovStringVec filteredNames;
    for(auto const &compName : allCompNames)
        {
        if(getComponentType(compName) == cft)
            {
            filteredNames.push_back(compName);
            }
        }
    return filteredNames;
    }
예제 #6
0
OovStringVec StringSplit(char const * const str, char const * const delimiterStr)
{
    OovString tempStr = str;
    OovStringVec tokens;
    size_t start = 0;
    size_t end = 0;
    const size_t delimLen = strlen(delimiterStr);
    while(end != std::string::npos)
        {
        end = tempStr.find(delimiterStr, start);
        size_t len = (end == std::string::npos) ? std::string::npos : end - start;
        OovString splitStr = tempStr.substr(start, len);
        tokens.push_back(splitStr);
        start = (( end > (std::string::npos - delimLen)) ?
                std::string::npos : end + delimLen);
        }
    return tokens;
    }
예제 #7
0
GraphSize OperationDrawer::drawClass(DiagramDrawer &drawer, const OperationClass &node,
        const OperationDrawOptions & /*options*/, bool draw)
    {
    GraphPoint startpos = node.getPosition();
    const ModelType *type = node.getType();
    OovStringRef const typeName = type->getName();
    int rectx = 0;
    int recty = 0;
    const ModelClassifier *classifier = type->getClass();
    if(classifier)
        {
        if(draw)
            {
            drawer.groupText(true, false);
            }
        OovStringVec strs;
        std::vector<GraphPoint> positions;
        strs.push_back(typeName);
        splitStrings(strs, 30, 40);

        for(auto const &str : strs)
            {
            recty += mCharHeight + (mPad * 2);
            positions.push_back(GraphPoint(startpos.x+mPad, startpos.y + recty - mPad));
            int curx = static_cast<int>(drawer.getTextExtentWidth(str)) + mPad*2;
            if(curx > rectx)
                rectx = curx;
            }

        if(draw)
            {
            drawer.groupShapes(true, Color(0,0,0), Color(245,245,255));
            drawer.drawRect(GraphRect(startpos.x, startpos.y, rectx, recty));
            drawer.groupShapes(false, Color(0,0,0), Color(245,245,255));

            for(size_t i=0; i<strs.size(); i++)
                {
                drawer.drawText(positions[i], strs[i]);
                }
            drawer.groupText(false, false);
            }
        }
    return GraphSize(rectx, recty);
    }
예제 #8
0
OovStringVec Tokenizer::codeComplete(size_t offset)
    {
    CLangAutoLock lock(mCLangLock, __LINE__, this);
    OovStringVec strs;
    unsigned options = 0;
// This gets more than we want.
//    unsigned options = clang_defaultCodeCompleteOptions();
    unsigned int line;
    unsigned int column;
    getLineColumn(offset, line, column);
    CXCodeCompleteResults *results = clang_codeCompleteAt(mTransUnit,
            mSourceFilename.getStr(), line, column,
            nullptr, 0, options);
    if(results)
        {
        clang_sortCodeCompletionResults(&results->Results[0], results->NumResults);
        for(size_t ri=0; ri<results->NumResults /*&& ri < 50*/; ri++)
            {
            OovString str;
            CXCompletionString compStr = results->Results[ri].CompletionString;
            size_t numChunks = clang_getNumCompletionChunks(compStr);
            for(size_t ci=0; ci<numChunks && ci < 30; ci++)
                {
                CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(compStr, ci);
                // We will discard return values from functions, so the first
                // chunk returned will be the identifier or function name.  Function
                // arguments will be returned after a space, so they can be
                // discarded easily.
                if(chunkKind == CXCompletionChunk_TypedText || str.length())
                    {
                    std::string chunkStr = getDisposedString(clang_getCompletionChunkText(compStr, ci));
                    if(str.length() != 0)
                    str += ' ';
                    str += chunkStr;
                    }
                }
            strs.push_back(str);
            }
        clang_disposeCodeCompleteResults(results);
        }
    return strs;
    }
예제 #9
0
OovStringVec Tokenizer::getDiagResults()
    {
    OovStringVec diagResults;
    if(mTransUnit)
        {
        int numDiags = clang_getNumDiagnostics(mTransUnit);
        for (int i = 0; i<numDiags && diagResults.size() < 10; i++)
            {
            CXDiagnostic diag = clang_getDiagnostic(mTransUnit, i);
//          CXDiagnosticSeverity sev = clang_getDiagnosticSeverity(diag);
//          if(sev >= CXDiagnostic_Error)
            OovString diagStr = getDisposedString(clang_formatDiagnostic(diag,
                clang_defaultDiagnosticDisplayOptions()));
            if(diagStr.find(mSourceFilename) != std::string::npos)
                {
                diagResults.push_back(diagStr);
                }
            }
        }
    return diagResults;
    }
예제 #10
0
void CompoundValueRef::parseStringRef(OovStringRef const strIn,
        OovStringVec &vec, char delimiter)
    {
    OovString str = strIn;
    size_t startArgPos = 0;
    while(startArgPos != std::string::npos)
        {
        size_t endColonPos = str.find(delimiter, startArgPos);
        std::string tempStr = str.substr(startArgPos, endColonPos-startArgPos);
        // For compatibility with previous files, allow a string that is
        // after the last colon. Previous versions that had the extra string
        // did not allow null strings.
        if(endColonPos != std::string::npos || tempStr.length() > 0)
            {
            vec.push_back(tempStr);
            }
        startArgPos = endColonPos;
        if(startArgPos != std::string::npos)
            startArgPos++;
        }
    }
예제 #11
0
OovStringVec StringSplit(char const * const str, OovStringVec const &delimiters,
    bool keepZeroLengthStrings)
    {
    OovString tempStr = str;
    OovStringVec tokens;
    size_t start = 0;
    size_t end = 0;
    size_t lowestEnd = 0;
    while(end != std::string::npos)
        {
        lowestEnd = std::string::npos;
        size_t delimLen = std::string::npos;
        for(auto const &delim : delimiters)
            {
            end = tempStr.find(delim, start);
            if(end < lowestEnd)
                {
                delimLen = strlen(delim.getStr());
                lowestEnd = end;
                }
            }
        end = lowestEnd;
        /// Don't add zero length strings when two delimiters are next to each other.
        size_t len = (end == std::string::npos) ? std::string::npos : end - start;
        if(keepZeroLengthStrings || len > 0)
            {
            OovString splitStr = tempStr.substr(start, len);
            if(splitStr.length() > 0)
                {
                tokens.push_back(splitStr);
                }
            }
        start = (( end > (std::string::npos - delimLen)) ?
                std::string::npos : end + delimLen);
        }
    return tokens;
    }
예제 #12
0
void ComponentGraph::updateConnections(const ComponentTypesFile &compFile,
        const ComponentDrawOptions &options)
    {
    BuildPackages buildPkgs(true);
    std::vector<Package> packages = buildPkgs.getPackages();
    mConnections.clear();

    OovStringVec compPaths;
    for(size_t i=0; i<mNodes.size(); i++)
        {
        if(mNodes[i].getComponentNodeType() == ComponentNode::CNT_Component)
            {
            std::string incPath;
            incPath = compFile.getComponentAbsolutePath(mNodes[i].getName());
            compPaths.push_back(incPath);
            }
        }

    // This is slow - look to improve?
    for(size_t consumerIndex=0; consumerIndex<mNodes.size(); consumerIndex++)
        {
        if(mNodes[consumerIndex].getComponentNodeType() == ComponentNode::CNT_Component)
            {
            OovStringVec srcFiles = compFile.getComponentFiles(
                ComponentTypesFile::CFT_CppSource, mNodes[consumerIndex].getName());
            for(auto const &srcFile : srcFiles)
                {
                FilePath fp;
                fp.getAbsolutePath(srcFile, FP_File);
                OovStringVec incDirs =
                        mIncludeMap->getNestedIncludeDirsUsedBySourceFile(fp);
                for(auto const &incDir : incDirs)
                    {
                    size_t supplierIndex = getComponentIndex(compPaths, incDir);
                    if(supplierIndex != NO_INDEX && consumerIndex != supplierIndex)
                        mConnections.insert(ComponentConnection(consumerIndex, supplierIndex));
                    }
                }
            }
        }
    for(size_t supplierIndex=0; supplierIndex<mNodes.size(); supplierIndex++)
        {
        if(mNodes[supplierIndex].getComponentNodeType() == ComponentNode::CNT_ExternalPackage)
            {
            OovString const &nodeName = mNodes[supplierIndex].getName();
            auto const &supplierIt = std::find_if(packages.begin(), packages.end(),
                    [nodeName](Package const &pkg) -> bool
                    { return(pkg.getPkgName().compare(nodeName) == 0); });
            if(supplierIt != packages.end())
                {
                for(size_t consumerIndex=0; consumerIndex<mNodes.size(); consumerIndex++)
                    {
                    if(mNodes[consumerIndex].getComponentNodeType() == ComponentNode::CNT_Component)
                        {
                        OovStringVec incRoots = (*supplierIt).getIncludeDirs();
                        if(mIncludeMap->anyRootDirsMatch(incRoots, compPaths[consumerIndex]))
                            {
                            mConnections.insert(ComponentConnection(consumerIndex, supplierIndex));
                            }
                        }
                    }
                }
            }
        }
    if(!options.drawImplicitRelations)
        pruneConnections();
    }
예제 #13
0
파일: oovCMaker.cpp 프로젝트: 8l/oovcde
OovStringVec CMaker::getCompLibrariesAndIncs(OovStringRef const compName,
        OovStringVec &extraIncDirs)
    {
    OovStringVec libs;
/*
    OovStringVec projectLibFileNames;
    mObjSymbols.appendOrderedLibFileNames("ProjLibs", getSymbolBasePath(),
            projectLibFileNames);
*/
    /// @todo - this does not order the libraries.
    OovStringVec srcFiles = mCompTypes.getComponentSources(compName);
    OovStringSet projLibs;
    OovStringSet extraIncDirsSet;
    OovStringVec compNames = mCompTypes.getComponentNames(true);
    for(auto const &srcFile : srcFiles)
        {
        FilePath fp;
        fp.getAbsolutePath(srcFile, FP_File);
        OovStringVec incDirs =
            mIncMap.getNestedIncludeDirsUsedBySourceFile(fp);
        for(auto const &supplierCompName : compNames)
            {
            ComponentTypesFile::eCompTypes compType =
                    mCompTypes.getComponentType(supplierCompName);
            if(compType == ComponentTypesFile::CT_StaticLib ||
                    compType == ComponentTypesFile::CT_Unknown)
                {
                std::string compDir = mCompTypes.getComponentAbsolutePath(
                    supplierCompName);
                for(auto const &incDir : incDirs)
                    {
                    if(compDir.compare(incDir) == 0)
                        {
                        if(supplierCompName.compare(compName) != 0)
                            {
                            if(compType == ComponentTypesFile::CT_StaticLib)
                                {
                                projLibs.insert(makeComponentNameFromDir(
                                    supplierCompName));
                                }
                            else
                                {
                                /// @todo - this could check for include files in the dir
                                extraIncDirsSet.insert(makeRelativeComponentNameFromDir(
                                    compName, supplierCompName));
                                }
                            break;
                            }
                        }
                    }
                }
            }
        }
    std::copy(projLibs.begin(), projLibs.end(), std::back_inserter(libs));
    std::copy(extraIncDirsSet.begin(), extraIncDirsSet.end(),
            std::back_inserter(extraIncDirs));

    for(auto const &pkg : mBuildPkgs.getPackages())
        {
        OovString compDir = mCompTypes.getComponentAbsolutePath(compName);
        OovStringVec incRoots = pkg.getIncludeDirs();
        if(mIncMap.anyRootDirsMatch(incRoots, compDir))
            {
            if(pkg.getPkgName().compare(compName) != 0)
                {
                OovString pkgRef = "${";
                OovString pkgDefName;
                makeDefineName(pkg.getPkgName(), pkgDefName);
                pkgRef += pkgDefName + "_LIBRARIES}";
                libs.push_back(pkgRef);
                }
            }
        }
    return libs;
    }