1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-03-20 11:25:21 -07:00
parent 4d70fc3fd4
commit 7728d48724
5 changed files with 32 additions and 35 deletions

View file

@ -14,6 +14,14 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db; package org.eclipse.cdt.internal.core.pdom.db;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -24,14 +32,6 @@ import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import com.ibm.icu.text.MessageFormat;
/** /**
* Database encapsulates access to a flat binary format file with a memory-manager-like API for * Database encapsulates access to a flat binary format file with a memory-manager-like API for
* obtaining and releasing areas of storage (memory). * obtaining and releasing areas of storage (memory).
@ -308,7 +308,7 @@ public class Database {
long freeblock = 0; long freeblock = 0;
int useDeltas; int useDeltas;
for (useDeltas= needDeltas; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) { for (useDeltas= needDeltas; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) {
freeblock = getFirstBlock(useDeltas*BLOCK_SIZE_DELTA); freeblock = getFirstBlock(useDeltas * BLOCK_SIZE_DELTA);
if (freeblock != 0) if (freeblock != 0)
break; break;
} }
@ -322,24 +322,24 @@ public class Database {
chunk = getChunk(freeblock); chunk = getChunk(freeblock);
} else { } else {
chunk = getChunk(freeblock); chunk = getChunk(freeblock);
removeBlock(chunk, useDeltas*BLOCK_SIZE_DELTA, freeblock); removeBlock(chunk, useDeltas * BLOCK_SIZE_DELTA, freeblock);
} }
final int unusedDeltas = useDeltas-needDeltas; final int unusedDeltas = useDeltas - needDeltas;
if (unusedDeltas >= MIN_BLOCK_DELTAS) { if (unusedDeltas >= MIN_BLOCK_DELTAS) {
// Add in the unused part of our block. // Add in the unused part of our block.
addBlock(chunk, unusedDeltas*BLOCK_SIZE_DELTA, freeblock + needDeltas*BLOCK_SIZE_DELTA); addBlock(chunk, unusedDeltas * BLOCK_SIZE_DELTA, freeblock + needDeltas * BLOCK_SIZE_DELTA);
useDeltas= needDeltas; useDeltas= needDeltas;
} }
// Make our size negative to show in use. // Make our size negative to show in use.
final int usedSize= useDeltas*BLOCK_SIZE_DELTA; final int usedSize= useDeltas * BLOCK_SIZE_DELTA;
chunk.putShort(freeblock, (short) -usedSize); chunk.putShort(freeblock, (short) -usedSize);
// Clear out the block, lots of people are expecting this. // Clear out the block, lots of people are expecting this.
chunk.clear(freeblock + BLOCK_HEADER_SIZE, usedSize-BLOCK_HEADER_SIZE); chunk.clear(freeblock + BLOCK_HEADER_SIZE, usedSize - BLOCK_HEADER_SIZE);
malloced+= usedSize; malloced += usedSize;
return freeblock + BLOCK_HEADER_SIZE; return freeblock + BLOCK_HEADER_SIZE;
} }
@ -352,7 +352,7 @@ public class Database {
chunk.fDirty = true; chunk.fDirty = true;
if (newChunkIndex >= fChunksAllocated) { if (newChunkIndex >= fChunksAllocated) {
int increment = Math.max(1024, fChunksAllocated/20); int increment = Math.max(1024, fChunksAllocated / 20);
Chunk[] newchunks = new Chunk[fChunksAllocated + increment]; Chunk[] newchunks = new Chunk[fChunksAllocated + increment];
System.arraycopy(fChunks, 0, newchunks, 0, fChunksAllocated); System.arraycopy(fChunks, 0, newchunks, 0, fChunksAllocated);
@ -374,8 +374,8 @@ public class Database {
if (address >= MAX_DB_SIZE) { if (address >= MAX_DB_SIZE) {
Object bindings[] = { this.getLocation().getAbsolutePath(), MAX_DB_SIZE }; Object bindings[] = { this.getLocation().getAbsolutePath(), MAX_DB_SIZE };
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
CCorePlugin.STATUS_PDOM_TOO_LARGE, NLS.bind(CCorePlugin CCorePlugin.STATUS_PDOM_TOO_LARGE, NLS.bind(
.getResourceString("pdom.DatabaseTooLarge"), bindings), null)); //$NON-NLS-1$ CCorePlugin.getResourceString("pdom.DatabaseTooLarge"), bindings), null)); //$NON-NLS-1$
} }
return address; return address;
} }
@ -388,7 +388,7 @@ public class Database {
assert fExclusiveLock; assert fExclusiveLock;
synchronized (fCache) { synchronized (fCache) {
final int oldLen= fChunks.length; final int oldLen= fChunks.length;
Chunk[] newchunks = new Chunk[oldLen+numChunks]; Chunk[] newchunks = new Chunk[oldLen + numChunks];
System.arraycopy(fChunks, 0, newchunks, 0, oldLen); System.arraycopy(fChunks, 0, newchunks, 0, oldLen);
for (int i = oldLen; i < oldLen + numChunks; i++) { for (int i = oldLen; i < oldLen + numChunks; i++) {
newchunks[i]= null; newchunks[i]= null;
@ -398,8 +398,8 @@ public class Database {
newchunks[ oldLen + numChunks - 1 ] = chunk; newchunks[ oldLen + numChunks - 1 ] = chunk;
fChunks= newchunks; fChunks= newchunks;
fCache.add(chunk, true); fCache.add(chunk, true);
fChunksAllocated=oldLen+numChunks; fChunksAllocated=oldLen + numChunks;
fChunksUsed=oldLen+numChunks; fChunksUsed=oldLen + numChunks;
return (long) (oldLen + numChunks - 1) * CHUNK_SIZE; return (long) (oldLen + numChunks - 1) * CHUNK_SIZE;
} }
} }

View file

@ -53,7 +53,7 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
this.linkage = linkage; this.linkage = linkage;
this.record = db.malloc(RECORD_SIZE); this.record = db.malloc(RECORD_SIZE);
db.putRecPtr(record + CLASS_DEFINITION, classDefName.getRecord()); db.putRecPtr(record + CLASS_DEFINITION, classDefName.getRecord());
linkage.storeType(record+BASECLASS_TYPE, base.getBaseClassType()); linkage.storeType(record + BASECLASS_TYPE, base.getBaseClassType());
byte flags = (byte)(base.getVisibility() | (base.isVirtual() ? 4 : 0)); byte flags = (byte)(base.getVisibility() | (base.isVirtual() ? 4 : 0));
db.putByte(record + FLAGS, flags); db.putByte(record + FLAGS, flags);

View file

@ -15,10 +15,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
@ -46,6 +42,10 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
*/ */
@ -145,7 +145,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
} }
public void addBases(PDOMName classDefName, ICPPBase[] bases) throws CoreException { public void addBases(PDOMName classDefName, ICPPBase[] bases) throws CoreException {
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES); getPDOM().removeCachedResult(record + PDOMCPPLinkage.CACHE_BASES);
final PDOMLinkage linkage = getLinkage(); final PDOMLinkage linkage = getLinkage();
PDOMCPPBase firstBase = getFirstBase(); PDOMCPPBase firstBase = getFirstBase();
for (ICPPBase base : bases) { for (ICPPBase base : bases) {
@ -159,7 +159,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
public void removeBases(PDOMName classDefName) throws CoreException { public void removeBases(PDOMName classDefName) throws CoreException {
final PDOM pdom = getPDOM(); final PDOM pdom = getPDOM();
final Database db = getDB(); final Database db = getDB();
pdom.removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES); pdom.removeCachedResult(record + PDOMCPPLinkage.CACHE_BASES);
PDOMCPPBase base= getFirstBase(); PDOMCPPBase base= getFirstBase();
PDOMCPPBase prevBase= null; PDOMCPPBase prevBase= null;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (QNX) - Initial API and implementation * Doug Schaefer (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -41,7 +41,6 @@ import org.eclipse.core.runtime.CoreException;
* Enumerations in the index. * Enumerations in the index.
*/ */
class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPDOMMemberOwner { class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPDOMMemberOwner {
private static final int OFFSET_ENUMERATOR_LIST = PDOMBinding.RECORD_SIZE; private static final int OFFSET_ENUMERATOR_LIST = PDOMBinding.RECORD_SIZE;
private static final int OFFSET_MIN_VALUE= OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE; private static final int OFFSET_MIN_VALUE= OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE;
private static final int OFFSET_MAX_VALUE= OFFSET_MIN_VALUE + 8; private static final int OFFSET_MAX_VALUE= OFFSET_MIN_VALUE + 8;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
class PDOMCPPFriend extends PDOMNode { class PDOMCPPFriend extends PDOMNode {
private static final int FRIEND_SPECIFIER = PDOMNode.RECORD_SIZE + 0; private static final int FRIEND_SPECIFIER = PDOMNode.RECORD_SIZE + 0;
private static final int NEXT_FRIEND = PDOMNode.RECORD_SIZE + 4; private static final int NEXT_FRIEND = PDOMNode.RECORD_SIZE + 4;
@ -79,5 +78,4 @@ class PDOMCPPFriend extends PDOMNode {
public void delete() throws CoreException { public void delete() throws CoreException {
getDB().free(record); getDB().free(record);
} }
} }