swakDataEntry<Type>::swakDataEntry(
    const word& entryName,
    const dictionary& dict,
    bool readEntryType
)
:
    DataEntry<Type>(entryName)
{
    if(readEntryType) {
        Istream& is(dict.lookup(entryName));
        word entryType(is);

        dictionary d(is);
        data_.set(
            new dictionary(
                dict,
                d
            )
        );
    } else {
        data_.set(
            new dictionary(
                dict,
                dict.subDict(entryName)
            )
        );
    }
    expression_=exprString(
        data_->lookup("expression"),
        data_()
    );
    independentVariableName_=word(data_->lookup("independentVariableName"));
}
Example #2
0
CCalEntry::TType OrganizerItemTypeTransform::entryTypeL(const QOrganizerItem &item)
{
    QString itemType = item.type();
    CCalEntry::TType entryType(CCalEntry::EAppt);

    if (itemType == QOrganizerItemType::TypeTodo || itemType == QOrganizerItemType::TypeTodoOccurrence)
        entryType = CCalEntry::ETodo;
    else if (itemType == QOrganizerItemType::TypeEvent || itemType == QOrganizerItemType::TypeEventOccurrence)
        entryType = CCalEntry::EAppt;
#ifdef AGENDA_EXT_SUPPORT
    else if (QOrganizerItemType::TypeNote == itemType) {
        entryType = CCalEntry::ENote;
    }
#endif
    else
        User::Leave(KErrUnknown); // unknown type
        
        

    // TODO: CCalEntry::EEvent???
    // TODO: CCalEntry::EReminder
    // TODO: CCalEntry::EAnniv if itemType=event & category=anniversary

    return entryType;
}
Example #3
0
static int
getEntry(Source *r, Entry *e, int checkepoch)
{
	u32int epoch;
	Block *b;

	if(r == nil){
		memset(&e, 0, sizeof e);
		return 1;
	}

	b = cacheGlobal(r->fs->cache, r->score, BtDir, r->tag, OReadOnly);
	if(b == nil)
		return 0;
	if(!entryUnpack(e, b->data, r->offset % r->epb)){
		blockPut(b);
		return 0;
	}
	epoch = b->l.epoch;
	blockPut(b);

	if(checkepoch){
		b = cacheGlobal(r->fs->cache, e->score, entryType(e), e->tag, OReadOnly);
		if(b){
			if(b->l.epoch >= epoch)
				fprint(2, "warning: entry %p epoch not older %#.8ux/%d %V/%d in getEntry\n",
					r, b->addr, b->l.epoch, r->score, epoch);
			blockPut(b);
		}
	}

	return 1;
}
// -----------------------------------------------------------------------------
// CAknFileSelectionModel::MdcaPoint
//
//
// -----------------------------------------------------------------------------
//
TPtrC CAknFileSelectionModel::MdcaPoint( TInt aIndex ) const
    {
    TEntry entry = iEntryArray->At( aIndex ); // reference
    TParsePtrC parsedEntry( entry.iName );
    TPtrC fileName( parsedEntry.NameAndExt() );
    TInt entryType( iImageIndexArray[ aIndex ] );

    TPtr itemWithImageIndex = iItemWithImageIndex->Des();

    switch( entryType )
        {
        case EThisFolderIcon:
            {
            if ( iDirectoryLevel == 0 )
                {
                // Root folder
                fileName.Set( iRootFolderText->Des() );
                }
            else
                {
                // Not the root folder
                iLocalizer->SetFullPath( iCurrentPath.DriveAndPath() );
                if ( iLocalizer->IsLocalized() ) // Localized?
                    {
                    // Folder name is localized
                    fileName.Set( iLocalizer->LocalizedName() );
                    }
                }
            break;
            }
        case EFolderIcon: // fall through
        case ESubFolderIcon:
        case EFolderEmptyIcon:
            {
            itemWithImageIndex = iCurrentPath.DriveAndPath();
            itemWithImageIndex.Append( entry.iName );
            // ignore error:
            AknCFDUtility::AddTrailingBackslash( itemWithImageIndex );
            iLocalizer->SetFullPath( itemWithImageIndex );
            if( iLocalizer->IsLocalized() )
                {
                fileName.Set( iLocalizer->LocalizedName() );
                }
            break;
            }
        default: // EFileIcon
            {
            break;
            }
        }

    _LIT( KImageHeader, "%d\t" );
    itemWithImageIndex.Format( KImageHeader, entryType );
    itemWithImageIndex.Append( fileName );

    return itemWithImageIndex;
    }
Example #5
0
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
:
    DataEntry<Type>(entryName),
    value_(pTraits<Type>::zero)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);

    is  >> value_;
}
Example #6
0
File: source.c Project: npe9/harvey
static int
sourceKill(Source *r, int doremove)
{
    Entry e;
    Block *b;
    uint32_t addr;
    uint32_t tag;
    int type;

    assert(sourceIsLocked(r));
    b = sourceLoad(r, &e);
    if(b == nil)
        return 0;

    assert(b->l.epoch == r->fs->ehi);

    if(doremove==0 && e.size == 0) {
        /* already truncated */
        blockPut(b);
        return 1;
    }

    /* remember info on link we are removing */
    addr = globalToLocal(e.score);
    type = entryType(&e);
    tag = e.tag;

    if(doremove) {
        if(e.gen != ~0)
            e.gen++;
        e.dsize = 0;
        e.psize = 0;
        e.flags = 0;
    } else {
        e.flags &= ~VtEntryLocal;
    }
    e.depth = 0;
    e.size = 0;
    e.tag = 0;
    memmove(e.score, vtZeroScore, VtScoreSize);
    entryPack(&e, b->data, r->offset % r->epb);
    blockDirty(b);
    if(addr != NilBlock)
        blockRemoveLink(b, addr, type, tag, 1);
    blockPut(b);

    if(doremove) {
        sourceUnlock(r);
        sourceClose(r);
    }

    return 1;
}
Example #7
0
Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
:
    DataEntry<Type>(entryName),
    TableBase<Type>(entryName, dictionary::null)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);

    is  >> this->table_;

    TableBase<Type>::check();
}
Example #8
0
Foam::Function1Types::Constant<Type>::Constant
(
    const word& entryName,
    const dictionary& dict
)
:
    Function1<Type>(entryName),
    value_(Zero)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);
    is  >> value_;
}
Example #9
0
File: source.c Project: npe9/harvey
/*
 * Change the depth of the source r.
 * The entry e for r is contained in block p.
 */
static int
sourceGrowDepth(Source *r, Block *p, Entry *e, int depth)
{
    Block *b, *bb;
    uint32_t tag;
    int type;
    Entry oe;

    assert(sourceIsLocked(r));
    assert(depth <= VtPointerDepth);

    type = entryType(e);
    b = cacheGlobal(r->fs->cache, e->score, type, e->tag, OReadWrite);
    if(b == nil)
        return 0;

    tag = e->tag;
    if(tag == 0)
        tag = tagGen();

    oe = *e;

    /*
     * Keep adding layers until we get to the right depth
     * or an error occurs.
     */
    while(e->depth < depth) {
        bb = cacheAllocBlock(r->fs->cache, type+1, tag, r->fs->ehi, r->fs->elo);
        if(bb == nil)
            break;
//fprint(2, "alloc %lux grow %V\n", bb->addr, b->score);
        memmove(bb->data, b->score, VtScoreSize);
        memmove(e->score, bb->score, VtScoreSize);
        e->depth++;
        type++;
        e->tag = tag;
        e->flags |= VtEntryLocal;
        blockDependency(bb, b, 0, vtZeroScore, nil);
        blockPut(b);
        b = bb;
        blockDirty(b);
    }

    entryPack(e, p->data, r->offset % r->epb);
    blockDependency(p, b, r->offset % r->epb, nil, &oe);
    blockPut(b);
    blockDirty(p);

    return e->depth == depth;
}
Example #10
0
Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
:
    scalarDataEntry(entryName),
    coeffs_(),
    preCoeffs_(coeffs_.size()),
    expCoeffs_(coeffs_.size()),
    canIntegrate_(true),
    dimensions_(dimless)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);

    token firstToken(is);
    is.putBack(firstToken);
    if (firstToken == token::BEGIN_SQR)
    {
        is  >> this->dimensions_;
    }
Example #11
0
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
:
    DataEntry<Type>(entryName),
    value_(pTraits<Type>::zero),
    dimensions_(dimless)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);
    token firstToken(is);
    if (firstToken.isWord())
    {
        token nextToken(is);
        if (nextToken == token::BEGIN_SQR)
        {
            is.putBack(nextToken);
            is >> dimensions_;
            is >> value_;
        }
void
AddPrinterDialog::_FillMenu(BMenu* menu, const char* path, uint32 what)
{
	for (uint32 i = 0; i < sizeof(gAddonDirs) / sizeof(directory_which); i++) {
		BPath addonPath;
		if (find_directory(gAddonDirs[i], &addonPath) != B_OK)
			continue;

		if (addonPath.Append(path) != B_OK)
			continue;

		BDirectory dir(addonPath.Path());
		if (dir.InitCheck() != B_OK)
			continue;

		BEntry entry;
		while (dir.GetNextEntry(&entry, true) == B_OK) {
			if (!entry.IsFile())
				continue;

			BNode node(&entry);
			if (node.InitCheck() != B_OK)
				continue;

			BNodeInfo info(&node);
			if (info.InitCheck() != B_OK)
				continue;

			char type[B_MIME_TYPE_LENGTH + 1];
			info.GetType(type);
			BMimeType entryType(type);
			// filter non executable entries (like "transport" subfolder...)
			if (entryType == B_APP_MIME_TYPE) {
				BPath transportPath;
				if (entry.GetPath(&transportPath) != B_OK)
					continue;

				BMessage* msg = new BMessage(what);
				msg->AddString("name", transportPath.Leaf());
				menu->AddItem(new BMenuItem(transportPath.Leaf(), msg));
			}
		}
	}
}
Example #13
0
Foam::Function1Types::Polynomial<Type>::Polynomial
(
    const word& entryName,
    const dictionary& dict
)
:
    Function1<Type>(entryName),
    coeffs_(),
    canIntegrate_(true)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);

    is  >> coeffs_;

    if (!coeffs_.size())
    {
        FatalErrorInFunction
            << "Polynomial coefficients for entry " << this->name_
            << " are invalid (empty)" << nl << exit(FatalError);
    }

    forAll(coeffs_, i)
    {
        if (mag(coeffs_[i].second() + pTraits<Type>::one) < rootVSmall)
        {
            canIntegrate_ = false;
            break;
        }
    }

    if (debug)
    {
        if (!canIntegrate_)
        {
            WarningInFunction
                << "Polynomial " << this->name_ << " cannot be integrated"
                << endl;
        }
    }
}
Example #14
0
Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
:
    DataEntry<scalar>(entryName),
    coeffs_(),
    canIntegrate_(true)
{
    Istream& is(dict.lookup(entryName));
    word entryType(is);

    is  >> coeffs_;

    if (!coeffs_.size())
    {
        FatalErrorIn("Foam::polynomial::polynomial(const word&, Istream&)")
            << "polynomial coefficients for entry " << this->name_
            << " are invalid (empty)" << nl << exit(FatalError);
    }

    forAll(coeffs_, i)
    {
        if (mag(coeffs_[i].second() + 1) < ROOTVSMALL)
        {
            canIntegrate_ = false;
            break;
        }
    }

    if (debug)
    {
        if (!canIntegrate_)
        {
            WarningIn("Foam::polynomial::polynomial(const word&, Istream&)")
                << "Polynomial " << this->name_ << " cannot be integrated"
                << endl;
        }
    }
}
Example #15
0
/*
 * When b points at bb, need to check:
 *
 * (i) b.e in [bb.e, bb.eClose)
 * (ii) if b.e==bb.e,  then no other b' in e points at bb.
 * (iii) if !(b.state&Copied) and b.e==bb.e then no other b' points at bb.
 * (iv) if b is active then no other active b' points at bb.
 * (v) if b is a past life of b' then only one of b and b' is active
 *	(too hard to check)
 */
static int
walkEpoch(Fsck *chk, Block *b, uchar score[VtScoreSize], int type, u32int tag,
	u32int epoch)
{
	int i, ret;
	u32int addr, ep;
	Block *bb;
	Entry e;

	if(b && chk->walkdepth == 0 && chk->printblocks)
		chk->print("%V %d %#.8ux %#.8ux\n", b->score, b->l.type,
			b->l.tag, b->l.epoch);

	if(!chk->useventi && globalToLocal(score) == NilBlock)
		return 1;

	chk->walkdepth++;

	bb = cacheGlobal(chk->cache, score, type, tag, OReadOnly);
	if(bb == nil){
		error(chk, "could not load block %V type %d tag %ux: %R",
			score, type, tag);
		chk->walkdepth--;
		return 0;
	}
	if(chk->printblocks)
		chk->print("%*s%V %d %#.8ux %#.8ux\n", chk->walkdepth*2, "",
			score, type, tag, bb->l.epoch);

	ret = 0;
	addr = globalToLocal(score);
	if(addr == NilBlock){
		ret = 1;
		goto Exit;
	}

	if(b){
		/* (i) */
		if(b->l.epoch < bb->l.epoch || bb->l.epochClose <= b->l.epoch){
			error(chk, "walk: block %#ux [%ud, %ud) points at %#ux [%ud, %ud)",
				b->addr, b->l.epoch, b->l.epochClose,
				bb->addr, bb->l.epoch, bb->l.epochClose);
			goto Exit;
		}

		/* (ii) */
		if(b->l.epoch == epoch && bb->l.epoch == epoch){
			if(getBit(chk->emap, addr)){
				error(chk, "walk: epoch join detected: addr %#ux %L",
					bb->addr, &bb->l);
				goto Exit;
			}
			setBit(chk->emap, addr);
		}

		/* (iii) */
		if(!(b->l.state&BsCopied) && b->l.epoch == bb->l.epoch){
			if(getBit(chk->xmap, addr)){
				error(chk, "walk: copy join detected; addr %#ux %L",
					bb->addr, &bb->l);
				goto Exit;
			}
			setBit(chk->xmap, addr);
		}
	}

	/* (iv) */
	if(epoch == chk->fs->ehi){
		/*
		 * since epoch==fs->ehi is first, amap is same as
		 * ``have seen active''
		 */
		if(getBit(chk->amap, addr)){
			error(chk, "walk: active join detected: addr %#ux %L",
				bb->addr, &bb->l);
			goto Exit;
		}
		if(bb->l.state&BsClosed)
			error(chk, "walk: addr %#ux: block is in active tree but is closed",
				addr);
	}else
		if(!getBit(chk->amap, addr))
			if(!(bb->l.state&BsClosed)){
				// error(chk, "walk: addr %#ux: block is not in active tree, not closed (%d)",
				// addr, bb->l.epochClose);
				chk->close(chk, bb, epoch+1);
				chk->nclose++;
			}

	if(getBit(chk->amap, addr)){
		ret = 1;
		goto Exit;
	}
	setBit(chk->amap, addr);

	if(chk->nseen++%chk->quantum == 0)
		chk->print("check: visited %d/%d blocks (%.0f%%)\n",
			chk->nseen, chk->nblocks, chk->nseen*100./chk->nblocks);

	b = nil;		/* make sure no more refs to parent */
	USED(b);

	switch(type){
	default:
		/* pointer block */
		for(i = 0; i < chk->bsize/VtScoreSize; i++)
			if(!walkEpoch(chk, bb, bb->data + i*VtScoreSize,
			    type-1, tag, epoch)){
				setBit(chk->errmap, bb->addr);
				chk->clrp(chk, bb, i);
				chk->nclrp++;
			}
		break;
	case BtData:
		break;
	case BtDir:
		for(i = 0; i < chk->bsize/VtEntrySize; i++){
			if(!entryUnpack(&e, bb->data, i)){
				// error(chk, "walk: could not unpack entry: %ux[%d]: %R",
				//	addr, i);
				setBit(chk->errmap, bb->addr);
				chk->clre(chk, bb, i);
				chk->nclre++;
				continue;
			}
			if(!(e.flags & VtEntryActive))
				continue;
if(0)			fprint(2, "%x[%d] tag=%x snap=%d score=%V\n",
				addr, i, e.tag, e.snap, e.score);
			ep = epoch;
			if(e.snap != 0){
				if(e.snap >= epoch){
					// error(chk, "bad snap in entry: %ux[%d] snap = %ud: epoch = %ud",
					//	addr, i, e.snap, epoch);
					setBit(chk->errmap, bb->addr);
					chk->clre(chk, bb, i);
					chk->nclre++;
					continue;
				}
				continue;
			}
			if(e.flags & VtEntryLocal){
				if(e.tag < UserTag)
				if(e.tag != RootTag || tag != RootTag || i != 1){
					// error(chk, "bad tag in entry: %ux[%d] tag = %ux",
					//	addr, i, e.tag);
					setBit(chk->errmap, bb->addr);
					chk->clre(chk, bb, i);
					chk->nclre++;
					continue;
				}
			}else
				if(e.tag != 0){
					// error(chk, "bad tag in entry: %ux[%d] tag = %ux",
					//	addr, i, e.tag);
					setBit(chk->errmap, bb->addr);
					chk->clre(chk, bb, i);
					chk->nclre++;
					continue;
				}
			if(!walkEpoch(chk, bb, e.score, entryType(&e),
			    e.tag, ep)){
				setBit(chk->errmap, bb->addr);
				chk->clre(chk, bb, i);
				chk->nclre++;
			}
		}
		break;
	}

	ret = 1;

Exit:
	chk->walkdepth--;
	blockPut(bb);
	return ret;
}
Example #16
0
File: source.c Project: npe9/harvey
static int
sourceShrinkDepth(Source *r, Block *p, Entry *e, int depth)
{
    Block *b, *nb, *ob, *rb;
    uint32_t tag;
    int type, d;
    Entry oe;

    assert(sourceIsLocked(r));
    assert(depth <= VtPointerDepth);

    type = entryType(e);
    rb = cacheGlobal(r->fs->cache, e->score, type, e->tag, OReadWrite);
    if(rb == nil)
        return 0;

    tag = e->tag;
    if(tag == 0)
        tag = tagGen();

    /*
     * Walk down to the new root block.
     * We may stop early, but something is better than nothing.
     */
    oe = *e;

    ob = nil;
    b = rb;
    /* BUG: explain type++.  i think it is a real bug */
    for(d=e->depth; d > depth; d--, type++) {
        nb = cacheGlobal(r->fs->cache, b->data, type-1, tag, OReadWrite);
        if(nb == nil)
            break;
        if(ob!=nil && ob!=rb)
            blockPut(ob);
        ob = b;
        b = nb;
    }

    if(b == rb) {
        blockPut(rb);
        return 0;
    }

    /*
     * Right now, e points at the root block rb, b is the new root block,
     * and ob points at b.  To update:
     *
     *	(i) change e to point at b
     *	(ii) zero the pointer ob -> b
     *	(iii) free the root block
     *
     * p (the block containing e) must be written before
     * anything else.
     */

    /* (i) */
    e->depth = d;
    /* might have been local and now global; reverse cannot happen */
    if(globalToLocal(b->score) == NilBlock)
        e->flags &= ~VtEntryLocal;
    memmove(e->score, b->score, VtScoreSize);
    entryPack(e, p->data, r->offset % r->epb);
    blockDependency(p, b, r->offset % r->epb, nil, &oe);
    blockDirty(p);

    /* (ii) */
    memmove(ob->data, vtZeroScore, VtScoreSize);
    blockDependency(ob, p, 0, b->score, nil);
    blockDirty(ob);

    /* (iii) */
    if(rb->addr != NilBlock)
        blockRemoveLink(p, rb->addr, rb->l.type, rb->l.tag, 1);

    blockPut(rb);
    if(ob!=nil && ob!=rb)
        blockPut(ob);
    blockPut(b);

    return d == depth;
}
Example #17
0
File: source.c Project: npe9/harvey
static Block *
blockWalk(Block *p, int index, int mode, Fs *fs, Entry *e)
{
    Block *b;
    Cache *c;
    uint32_t addr;
    int type;
    uint8_t oscore[VtScoreSize], score[VtScoreSize];
    Entry oe;

    c = fs->cache;

    if((p->l.type & BtLevelMask) == 0) {
        assert(p->l.type == BtDir);
        type = entryType(e);
        b = cacheGlobal(c, e->score, type, e->tag, mode);
    } else {
        type = p->l.type - 1;
        b = cacheGlobal(c, p->data + index*VtScoreSize, type, e->tag, mode);
    }

    if(b)
        b->pc = getcallerpc(&p);

    if(b == nil || mode == OReadOnly)
        return b;

    if(p->l.epoch != fs->ehi) {
        fprint(2, "blockWalk: parent not writable\n");
        abort();
    }
    if(b->l.epoch == fs->ehi)
        return b;

    oe = *e;

    /*
     * Copy on write.
     */
    if(e->tag == 0) {
        assert(p->l.type == BtDir);
        e->tag = tagGen();
        e->flags |= VtEntryLocal;
    }

    addr = b->addr;
    b = blockCopy(b, e->tag, fs->ehi, fs->elo);
    if(b == nil)
        return nil;

    b->pc = getcallerpc(&p);
    assert(b->l.epoch == fs->ehi);

    blockDirty(b);
    memmove(score, b->score, VtScoreSize);
    if(p->l.type == BtDir) {
        memmove(e->score, b->score, VtScoreSize);
        entryPack(e, p->data, index);
        blockDependency(p, b, index, nil, &oe);
    } else {
        memmove(oscore, p->data+index*VtScoreSize, VtScoreSize);
        memmove(p->data+index*VtScoreSize, b->score, VtScoreSize);
        blockDependency(p, b, index, oscore, nil);
    }
    blockDirty(p);

    if(addr != NilBlock)
        blockRemoveLink(p, addr, type, e->tag, 0);

    return b;
}
Example #18
0
File: source.c Project: npe9/harvey
static int
sourceShrinkSize(Source *r, Entry *e, uint64_t size)
{
    int i, type, ppb;
    uint64_t ptrsz;
    uint32_t addr;
    uint8_t score[VtScoreSize];
    Block *b;

    type = entryType(e);
    b = cacheGlobal(r->fs->cache, e->score, type, e->tag, OReadWrite);
    if(b == nil)
        return 0;

    ptrsz = e->dsize;
    ppb = e->psize/VtScoreSize;
    for(i=0; i+1<e->depth; i++)
        ptrsz *= ppb;

    while(type&BtLevelMask) {
        if(b->addr == NilBlock || b->l.epoch != r->fs->ehi) {
            /* not worth copying the block just so we can zero some of it */
            blockPut(b);
            return 0;
        }

        /*
         * invariant: each pointer in the tree rooted at b accounts for ptrsz bytes
         */

        /* zero the pointers to unnecessary blocks */
        i = (size+ptrsz-1)/ptrsz;
        for(; i<ppb; i++) {
            addr = globalToLocal(b->data+i*VtScoreSize);
            memmove(b->data+i*VtScoreSize, vtZeroScore, VtScoreSize);
            blockDirty(b);
            if(addr != NilBlock)
                blockRemoveLink(b, addr, type-1, e->tag, 1);
        }

        /* recurse (go around again) on the partially necessary block */
        i = size/ptrsz;
        size = size%ptrsz;
        if(size == 0) {
            blockPut(b);
            return 1;
        }
        ptrsz /= ppb;
        type--;
        memmove(score, b->data+i*VtScoreSize, VtScoreSize);
        blockPut(b);
        b = cacheGlobal(r->fs->cache, score, type, e->tag, OReadWrite);
        if(b == nil)
            return 0;
    }

    if(b->addr == NilBlock || b->l.epoch != r->fs->ehi) {
        blockPut(b);
        return 0;
    }

    /*
     * No one ever truncates BtDir blocks.
     */
    if(type == BtData && e->dsize > size) {
        memset(b->data+size, 0, e->dsize-size);
        blockDirty(b);
    }
    blockPut(b);
    return 1;
}