Exemplo n.º 1
0
static bool isDevelopment()
    {
    static enum eDevel { Uninit, Devel, Deploy } devel;
    if(devel == Uninit)
        {
        OovString path = Project::getBinDirectory();
        size_t pos = path.find("bin");
        if(pos != std::string::npos)
            {
            path.replace(pos, 3, "lib");
            }
        OovStatus status(true, SC_File);
        if(FileIsDirOnDisk(path, status))
            {
            devel = Deploy;
            }
        else
            {
            devel = Devel;
            }
        if(status.needReport())
            {
            status.reported();
            }
        }
    return(devel == Devel);
    }
Exemplo n.º 2
0
OovString FilePathGetWithoutEndPathSep(
    OovStringRef const path)
{
    OovString str = path;
    FilePathRemovePathSep(str, str.length()-1);
    return str;
}
Exemplo n.º 3
0
int FilePath::discardLeadingRelSegments()
{
    int count = 0;
    bool didSeg = true;
    do
    {
        OovString seg = getPathSegment(0);
        if(seg.compare("..") == 0)
        {
            CHECKSIZE(__FILE__, __LINE__, size(), 3);
            pathStdStr().erase(0, 3);
            count++;
        }
        else if(seg.compare(".") == 0)
        {
            CHECKSIZE(__FILE__, __LINE__, size(), 2);
            pathStdStr().erase(0, 2);
        }
        else
        {
            didSeg = false;
        }
    } while(didSeg);
    return count;
}
Exemplo n.º 4
0
bool CppFileContents::write(OovStringRef const fn)
    {
    SimpleFile file;
    eOpenStatus openStat = file.open(fn, M_WriteExclusiveTrunc, OE_Binary);
    OovStatus status(openStat == OS_Opened, SC_File);
    if(status.ok())
        {
        OovString includeCov = "#include \"OovCoverage.h\"";
        appendLineEnding(includeCov);
        updateMemory();
        status = file.write(includeCov.c_str(), includeCov.length());
        }
    if(status.ok())
        {
        status = file.write(mFileContents.data(), mFileContents.size());
        }
    if(!status.ok())
        {
        OovString str = "Unable to write %s ";
        str += fn;
        str += "\n";
        status.report(ET_Error, str.getStr());
        }
    return status.ok();
    }
Exemplo n.º 5
0
static bool mapPath(ZonePathMap const &map, OovString const &origName,
        OovString &newName)
    {
    bool replaced = false;
    size_t starti = 0;
    newName = origName;
    do
        {
        size_t firstFoundi = OovString::npos;
        ZonePathReplaceItem const *repItem = nullptr;
        for(auto const &mapItem : map)
            {
            size_t foundi = newName.find(mapItem.mSearchPath, starti);
            if(foundi < firstFoundi)
                {
                repItem = &mapItem;
                firstFoundi = foundi;
                }
            }
        if(firstFoundi != OovString::npos)
            {
            newName.replace(firstFoundi, repItem->mSearchPath.length(),
                    repItem->mReplacePath);
            starti = firstFoundi + repItem->mReplacePath.length();
            replaced = true;
            }
        else
            starti = OovString::npos;
        } while(starti != OovString::npos);
    return replaced;
    }
Exemplo n.º 6
0
void Editor::idleDebugStatusChange(eDebuggerChangeStatus st)
    {
    if(st == DCS_RunState)
        {
        getEditFiles().updateDebugMenu();
        if(mDebugger.getChildState() == DCS_ChildPaused)
            {
            auto const &loc = mDebugger.getStoppedLocation();
            mEditFiles.viewModule(loc.getFilename(), loc.getLine());
            mDebugger.startGetStack();
            }
        }
    else if(st == DCS_Stack)
        {
        GtkTextView *view = GTK_TEXT_VIEW(ControlWindow::getTabView(
            ControlWindow::CT_Stack));
        Gui::setText(view, mDebugger.getStack());
        }
    else if(st == DCS_Value)
        {
//        mVarView.appendText(GuiTreeItem(), mDebugger.getVarValue().getAsString());
        GuiTreeItem item;
        appendTree(mVarView, item, mDebugger.getVarValue());

        GuiTreeItem root;
        int numChildren = mVarView.getNumChildren(root);
        OovString numPathStr;
        numPathStr.appendInt(numChildren-1);
        GuiTreePath path(numPathStr);
        mVarView.scrollToPath(path);
        }
    }
Exemplo n.º 7
0
void StringToLower(OovString &str)
    {
    for(size_t i=0; i<str.length(); ++i)
        {
        str.at(i) = static_cast<char>(tolower(str.at(i)));
        }
    }
Exemplo n.º 8
0
OovString Project::recoverFileName(OovStringRef const srcFileName)
    {
    OovString file = srcFileName;
    file.replaceStrs("_u", "_");
    file.replaceStrs("_s", "/");
    file.replaceStrs("_d", ".");
    return file;
    }
Exemplo n.º 9
0
/// For every includer file that is run across during parsing, this means that
/// the includer file was fully parsed, and that no old included information
/// needs to be kept, except to check if the old included information has not
/// changed.
///
///  This code assumes that no tricks are played with ifdef values, and
/// ifdef values must be the same every time a the same file is included.
void IncDirDependencyMap::write()
    {
    bool anyChanges = false;
    time_t curTime;
    time_t changedTime = 0;
    time(&curTime);

#if(SHARED_FILE)
    SharedFile file;
    if(!writeFileExclusiveReadUpdate(file))
        {
        fprintf(stderr, "\nOovCppParser - Write file sharing error %s\n", getFilename().c_str());
        }
#endif
    // Append new values from parsed includes into the original NameValueFile.
    // Update existing values times and make new dependencies.
    for(const auto &newMapItem : mParsedIncludeDependencies)
        {
        bool changed = includedPathsChanged(newMapItem.first, newMapItem.second);
        if(changed)
            {
            // Cheat and say updated time and checked time are the same.
            changedTime = curTime;

            CompoundValue newIncludedInfoCompVal;
            OovString changeStr;
            changeStr.appendInt(changedTime);
            newIncludedInfoCompVal.addArg(changeStr);

            OovString checkedStr;
            checkedStr.appendInt(curTime);
            newIncludedInfoCompVal.addArg(checkedStr);

            for(const auto &str : newMapItem.second)
                {
                size_t pos = newIncludedInfoCompVal.find(str);
                if(pos == CompoundValue::npos)
                    {
                    newIncludedInfoCompVal.addArg(str);
                    }
                }
            setNameValue(newMapItem.first, newIncludedInfoCompVal.getAsString());
            anyChanges = true;
            }
        }
    if(file.isOpen() && anyChanges)
        {
#if(SHARED_FILE)
        if(!writeFileExclusive(file))
            {
            OovString str = "Unable to write include map file";
            OovError::report(ET_Error, str);
            }
#else
        writeFile();
#endif
        }
    }
Exemplo n.º 10
0
OovString ModelStatement::getOverloadFuncName() const
    {
    OovString opName = getName();

    size_t pos = getRightSidePosFromMemberRefExpr(opName, true);
    if(pos != 0)
        opName.erase(0, pos);
    return opName;
    }
Exemplo n.º 11
0
// This is recursive.
// This adds items if they does not exist.  It preserves the tree
// so that the state of expanded items will not be destroyed.
// childIndex of -1 is special since the name is used to find the item.
static void appendTree(GuiTree &varView, GuiTreeItem &parentItem,
    DebugResult const &debResult, int childIndex = -1)
    {
    OovString varPrefix = debResult.getVarName();
    OovString str = varPrefix;
    if(debResult.getValue().length() > 0)
        {
        varPrefix += " : ";
        str = varPrefix;
        str += debResult.getValue();
        }

    GuiTreeItem item;
    bool foundItem = false;
    if(childIndex == -1)
        {
        if(varView.findImmediateChildPartialMatch(varPrefix, parentItem, item))
            {
            foundItem = true;
            }
        }
    else
        {
        foundItem = varView.getNthChild(parentItem, childIndex, item);
        }
    if(foundItem)
        {
        varView.setText(item, str);
        }
    else
        {
        item = varView.appendText(parentItem, str);
        }

    /// Remove items that no longer are available for the variable name.
        {
        int numDataChildren = debResult.getChildResults().size();
        int numTreeChildren = varView.getNumChildren(item);
        for(int childI=numDataChildren; childI<numTreeChildren; childI++)
            {
            varView.removeNthChild(item, childI);
            }
        }

    int callerChildIndex = 0;
    for(auto const &childRes : debResult.getChildResults())
        {
        appendTree(varView, item, *childRes.get(), callerChildIndex++);
        }
    /// @TODO - should only expand added item at parent level?
    GuiTreeItem root;
    int lastChild = varView.getNumChildren(root) - 1;
    OovString numPathStr;
    numPathStr.appendInt(lastChild);
    GuiTreePath path(numPathStr);
    varView.expandRow(path);
    }
Exemplo n.º 12
0
bool ModelStatement::hasBaseClassRef() const
    {
    OovString attrName = getName();
    bool present = attrName.find(getBaseClassMemberRefSep()) != std::string::npos;
    if(!present)
        {
        present = attrName.find(getBaseClassMemberCallSep()) != std::string::npos;
        }
    return(present);
    }
Exemplo n.º 13
0
std::string ComponentTypesFile::getComponentParentName(std::string const &compName)
    {
    OovString parent = compName;
    size_t pos = parent.rfind('/');
    if(pos != OovString::npos)
        {
        parent.erase(pos);
        }
    return parent;
    }
Exemplo n.º 14
0
std::string ComponentTypesFile::getComponentChildName(std::string const &compName)
    {
    OovString child = compName;
    size_t pos = child.rfind('/');
    if(pos != OovString::npos)
        {
        child.erase(0, pos+1);
        }
    return child;
    }
Exemplo n.º 15
0
OovString const Project::getBinDirectory()
    {
    static OovString path;
    if(path.length() == 0)
        {
        OovStatus status(true, SC_File);
#ifdef __linux__
        char buf[300];
        ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
        if(len >= 0)
            {
            buf[len] = '\0';
            path = buf;
            size_t pos = path.rfind('/');
            if(pos == std::string::npos)
                {
                pos = path.rfind('\\');
                }
            if(pos != std::string::npos)
                {
                path.resize(pos+1);
                }
            }
/*
        if(FileIsFileOnDisk("./oovaide", status))
            {
            path = "./";
            }
        else if(FileIsFileOnDisk("/usr/local/bin/oovaide", status))
            {
            path = "/usr/local/bin/";
            }
*/
        else
            {
            path = "/usr/bin";
            }
#else
        if(FileIsFileOnDisk("./oovaide.exe", status))
            {
            path = "./";
            }
        else
            {
            path = FilePathGetDrivePath(sArgv0);
            }
#endif
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to get bin directory");
            }
        }
    return path;
    }
Exemplo n.º 16
0
std::string BuildConfig::getCrcAsStr(OovStringRef const buildType, CrcTypes crcType) const
    {
    OovString buildStr = mConfigFile.getValue(buildType);
    std::vector<OovString> crcStrs = buildStr.split(';');
    std::string crcStr;
    if(crcStrs.size() == CT_LastCrc+1)
        {
        crcStr = crcStrs[crcType];
        }
    return crcStr;
    }
Exemplo n.º 17
0
OovStringVec CMaker::getCompSources(OovStringRef const compName)
    {
    OovStringVec sources = mCompTypes.getComponentSources(compName);
    OovString compPath = mCompTypes.getComponentAbsolutePath(compName);
    for(auto &src : sources)
        {
        src.erase(0, compPath.length());
        }
    std::sort(sources.begin(), sources.end(), compareNoCase);
    return sources;
    }
Exemplo n.º 18
0
void NameValueRecord::insertLine(OovString lineBuf)
    {
    size_t colonPos = lineBuf.find(mapDelimiter);
    if(colonPos != std::string::npos)
        {
        std::string key = lineBuf.substr(0, colonPos);
        size_t termPos = lineBuf.find('\n');
        std::string value = lineBuf.substr(colonPos+1, termPos-(colonPos+1));
        setNameValue(key, value);
        }
    }
Exemplo n.º 19
0
static void setFileDefine(OovStringRef const fn, OovStringRef const srcRootDir)
    {
    OovString relFn = Project::getSrcRootDirRelativeSrcFileName(fn, srcRootDir);
    OovString fileDef = "COV_";
    fileDef += relFn;
    fileDef.replaceStrs("//", "_");
    fileDef.replaceStrs("/", "_");
    fileDef.replaceStrs(".", "_");
    fileDef.replaceStrs(":", "");
    sFileDefine = fileDef;
    }
Exemplo n.º 20
0
bool FileIsFileOnDisk(OovStringRef const path, bool &success)
{
    OovString tempPath = path;
    FilePathRemovePathSep(tempPath, tempPath.size()-1);
    struct OovStat32 statval;
    int statRet = OovStat32(tempPath.getStr(), &statval);
    // Indicate there is an error only if the error is not ENOENT.
    success = ((statRet == 0) || (errno == ENOENT));
    // Only indicate the file exists if there was no error, and it is a file.
    return((statRet == 0) && !S_ISDIR(statval.st_mode));
}
Exemplo n.º 21
0
OovString Project::getSrcRootDirRelativeSrcFileName(OovStringRef const srcFileName,
        OovStringRef const srcRootDir)
    {
    OovString relSrcFileName = srcFileName;
    size_t pos = relSrcFileName.find(srcRootDir.getStr());
    if(pos != std::string::npos)
        {
        relSrcFileName.erase(pos, srcRootDir.numBytes());
        FilePathRemovePathSep(relSrcFileName, 0);
        }
    return relSrcFileName;
    }
Exemplo n.º 22
0
OovString Project::makeTreeOutBaseFileName(OovStringRef const srcFileName,
        OovStringRef const srcRootDir, OovStringRef const outFilePath)
    {
    OovString file = getSrcRootDirRelativeSrcFileName(srcFileName, srcRootDir);
    if(file[0] == '/')
        file.erase(0, 1);

    FilePath tmpOutFileName(outFilePath, FP_Dir);
    tmpOutFileName.appendFile(file);
    tmpOutFileName.discardExtension();
    return tmpOutFileName;
    }
Exemplo n.º 23
0
 void deleteSelected()
     {
     OovString selStr = mPathMapList.getSelected();
     if(selStr.length() > 0)
         {
         OovStringVec vec = selStr.split(" > ");
         if(vec.size() == 2)
             {
             mPathMapList.removeSelected();
             mDiagramPathMap->remove(ZonePathReplaceItem(vec[0], vec[1]));
             }
         }
     }
Exemplo n.º 24
0
bool EditOptions::getScreenCoord(char const * const tag, int &val)
    {
    OovString str = getValue(tag);
    bool got = false;
    if(str.length() > 0)
        {
        if(str.getInt(0, 100000, val))
            {
            got = true;
            }
        }
    return got;
    }
Exemplo n.º 25
0
OovString Project::makeOutBaseFileName(OovStringRef const srcFileName,
        OovStringRef const srcRootDir, OovStringRef const outFilePath)
    {
    OovString file = getSrcRootDirRelativeSrcFileName(srcFileName, srcRootDir);
    if(file[0] == '/')
        file.erase(0, 1);
    file.replaceStrs("_", "_u");
    file.replaceStrs("/", "_s");
    file.replaceStrs(".", "_d");
    FilePath outFileName(outFilePath, FP_Dir);
    outFileName.appendFile(file);
    return outFileName;
    }
Exemplo n.º 26
0
OovString ModelStatement::getAttrName() const
    {
    OovString attrName = getName();
    if(mStatementType == ST_Call)
        {
        size_t pos = getRightSidePosFromMemberRefExpr(attrName, false);
        if(pos != 0)
            attrName.erase(pos);
        else
            attrName.clear();
        }
    return attrName;
    }
Exemplo n.º 27
0
void ProjectSettingsDialog::rootSourceDirButtonClicked()
    {
    PathChooser ch;
    OovString srcRootDir;
    if(ch.ChoosePath(sProjectSettingsDialog->getParentWindow(),
            "Open Root Source Directory",
            GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, srcRootDir))
        {
        GtkEntry *dirEntry = GTK_ENTRY(Builder::getBuilder()->getWidget(
                "RootSourceDirEntry"));
        gtk_entry_set_text(dirEntry, srcRootDir.c_str());
        }
    }
Exemplo n.º 28
0
void Editor::setStyle()
    {
    GtkCssProvider *provider = gtk_css_provider_get_default();
    GdkDisplay *display = gdk_display_get_default();
    GdkScreen *screen = gdk_display_get_default_screen(display);

    OovString path = Project::getBinDirectory();
    path += "OovEdit.css";
    GError *err = 0;
    gtk_css_provider_load_from_path(provider, path.getStr(), &err);
    gtk_style_context_add_provider_for_screen (screen,
        GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    g_object_unref(provider);
    }
Exemplo n.º 29
0
bool IncDirDependencyMap::includedPathsChanged(OovStringRef includerFn,
        std::set<std::string> const &includedInfoStr) const
    {
    bool changed = false;

    // First check if the includer filename exists in the dependency file.
    OovString origIncludedInfoStr = getValue(includerFn);
    if(origIncludedInfoStr.size() > 0)
        {
        CompoundValue origIncludedInfoCompVal;
        // get the changed time, which is the first value and discard
        // everything else.
        origIncludedInfoCompVal.parseString(origIncludedInfoStr);
        // Check that counts of the number of includes is the same in
        // the new and original map.  This will detect deleted includes.
        if(origIncludedInfoCompVal.size()-IncDirMapNumTimeVals !=
                (includedInfoStr.size() * IncDirMapNumIncPathParts))
            {
            changed = true;
            }
        else
            {
            // Every included file in the new map must exist in the
            // original map.
            for(const auto &included : includedInfoStr)
                {
                CompoundValue incPathParts;
                incPathParts.parseString(included);
                if(incPathParts.size() == 2)
                    {
                    if(std::find(origIncludedInfoCompVal.begin(),
                            origIncludedInfoCompVal.end(), incPathParts[1]) ==
                            origIncludedInfoCompVal.end())
                        {
                        changed = true;
                        }
                    }
                else
                    {
                    changed = true;
                    }
                }
            }
        }
    else
        {
        changed = true;
        }
    return changed;
    }
Exemplo n.º 30
0
void ProjectSettingsDialog::oovaideProjectDirButtonClicked()
    {
    PathChooser ch;
    OovString projectDir;
    if(ch.ChoosePath(sProjectSettingsDialog->getParentWindow(),
            "Create OOVAIDE Project Directory",
            GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
        projectDir))
        {
        GtkEntry *dirEntry = GTK_ENTRY(Builder::getBuilder()->getWidget(
                "OovaideProjectDirEntry"));
        gtk_entry_set_text(dirEntry, projectDir.c_str());
        }
    }