Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Binary Parser frameworks

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.42
diff -u -r1.42 ChangeLog
--- ChangeLog	25 Nov 2002 05:55:43 -0000	1.42
+++ ChangeLog	27 Nov 2002 04:35:43 -0000
@@ -1,3 +1,42 @@
+2002-11-27 Alain Magloire
+
+	* model/.../cdt/core/model/CoreModel.java:
+	Remove the static qualifiers and force people to use getDefault().
+	(getBinaryParserFormat): New method to retrieve the format of a project.
+	(setBinaryParserFormat): New method to set the format of a project.
+	(getDefaultBinaryParserFormat): New method to retrieve the default format.
+	(setDefaultBinaryParserFormat): New method to set the default format.
+	* model/.../cdt/core/model/IBinaryParser.java: Move to be is the src directory.
+	* model/.../cdt/core/model/ICElementDelta.java: New Flag for the binary parser.
+	* model/.../internal/core/model/parser/BinaryContainerAdapter.java:
+	* model/.../internal/core/model/parser/BinaryFileAdapter.java:
+	* model/.../internal/core/model/parser/ElfBinaryArchive.java:
+	* model/.../internal/core/model/parser/ElfBinaryFile.java:
+	* model/.../internal/core/model/parser/PEBinaryArchive.java:
+	* model/.../internal/core/model/parser/PEBinaryFile.java:
+	* model/.../internal/core/model/parser/PEParser.java:
+	* model/.../internal/core/model/parser/ElfParser.java:
+	* model/.../internal/core/model/parser/Symbol.java:
+	* model/.../internal/core/model/ArchiveInfo.java:
+	* model/.../internal/core/model/BinaryInfo.java:
+	Organize imports.
+	* model/.../internal/core/model/CElementDelta.java (binaryParserChanged):
+	New method.
+	* model/.../internal/core/model/CModelManager.java (releaseCElement):
+	Remove the children of a container in the hashmap.
+	(getDefaultBinaryParserFormat): Return the default format.
+	(setDefaultBinaryParserFormat): set the default format.
+	(setBinaryParserFormat): remove the all the children and fire a binary parser change.
+
+	* src/../cdt/core/CCorePlugin.java (getBinaryParserConfigurations):
+	New method to search for the extension points.
+	* src/../cdt/core/IBinaryParser.java: New file
+	* src/../cdt/core/IBinaryParserConfiguration.java: New file
+	* src/../internal/cdt/core/BinaryParserConfiguration.java: New file
+
+	* plugin.xml: Binary parsers extension points.
+	
+
 2002-11-23 Alain Magloire
 
 	* model/.../cdt/core/model/CoreModel.java (getBinaryParser):
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/plugin.xml,v
retrieving revision 1.15
diff -u -r1.15 plugin.xml
--- plugin.xml	25 Nov 2002 05:55:56 -0000	1.15
+++ plugin.xml	27 Nov 2002 04:35:43 -0000
@@ -31,9 +31,9 @@
    <extension-point id="ProcessList" name="%ProcessList.name" schema="schema/ProcessList.exsd"/>
    <extension-point id="BinaryParser" name="BinaryParser"/>
 
-   <extension id="parser" name="C Parser" point="org.eclipse.cdt.core.BinaryParser">
-      <parser format="ELF" class="org.eclipse.cdt.internal.core.model.parser.ElfParser"/>
-      <parser format="PE"  class="org.eclipse.cdt.internal.core.model.parser.PEParser"/>
+   <extension point="org.eclipse.cdt.core.BinaryParser">
+      <parser name="Elf Parser" format="ELF" class="org.eclipse.cdt.internal.core.model.parser.ElfParser"/>
+      <parser name="PE Windows Parser" format="PE"  class="org.eclipse.cdt.internal.core.model.parser.PEParser"/>
    </extension>
    
    <extension
Index: model/org/eclipse/cdt/core/model/CoreModel.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java,v
retrieving revision 1.5
diff -u -r1.5 CoreModel.java
--- model/org/eclipse/cdt/core/model/CoreModel.java	25 Nov 2002 05:51:33 -0000	1.5
+++ model/org/eclipse/cdt/core/model/CoreModel.java	27 Nov 2002 04:35:52 -0000
@@ -12,8 +12,7 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IPath;
-
-// This should be done in the Plugin.
+import org.eclipse.core.runtime.IProgressMonitor;
 
 public class CoreModel {
 
@@ -72,91 +71,91 @@
 	/**
 	 * Return true if IFile is a shared library, i.e. libxx.so
 	 */
-	public static boolean isSharedLib(IFile file) {
+	public boolean isSharedLib(IFile file) {
 		return manager.isSharedLib(file);
 	}
 
 	/**
 	 * Return true if IFile is a an object(ELF), i.e. *.o
 	 */
-	public static boolean isObject(IFile file) {
+	public boolean isObject(IFile file) {
 		return manager.isObject(file);
 	}
 
 	/**
 	 * Return true if IFile is an ELF executable
 	 */
-	public static boolean isExecutable(IFile file) {
+	public boolean isExecutable(IFile file) {
 		return manager.isExecutable(file);
 	}
 
 	/**
 	 * Return true if IFile is an ELF.
 	 */
-	public static boolean isBinary(IFile file) {
+	public boolean isBinary(IFile file) {
 		return manager.isBinary(file);
 	}
 
 	/**
 	 * Return true if IFile is an Achive, *.a
 	 */
-	public static boolean isArchive(IFile file) {
+	public boolean isArchive(IFile file) {
 		return manager.isArchive(file);
 	}
 
 	/**
 	 * Return true if IFile is a TranslationUnit.
 	 */
-	public static boolean isTranslationUnit(IFile file) {
+	public boolean isTranslationUnit(IFile file) {
 		return manager.isTranslationUnit(file);
 	}
 
 	/**
 	 * Return true if name is a valid name for a translation unit.
 	 */
-	public static boolean isValidTranslationUnitName(String name){
+	public boolean isValidTranslationUnitName(String name){
 		return manager.isValidTranslationUnitName(name);
 	}
 
 	/**
 	 * Return true if project has C nature.
 	 */
-	public static boolean hasCNature(IProject project){
+	public boolean hasCNature(IProject project){
 		return manager.hasCNature(project);
 	}
 
-	public static boolean hasCCNature(IProject project){
+	public boolean hasCCNature(IProject project){
 		return manager.hasCCNature(project);
 	}
 
 	/**
-	 * Return the the binaryParser of the Project.
+	 * Return the binaryParser of the Project.
 	 */
-	public static IBinaryParser getBinaryParser(IProject project) {
-		return manager.getBinaryParser(project);
+	public String getBinaryParserFormat(IProject project) {
+		return manager.getBinaryParserFormat(project);
 	}
-	
+
 	/**
-	 * Return all the known binaryParsers formats.
+	 * Set the binaryParser of the Project.
 	 */
-	public static String[] getBinaryParserFormats() {
-		return CCorePlugin.getDefault().getBinaryParserFormats();
+	public void setBinaryParserFormat(IProject project, String format, IProgressMonitor monitor) {
+		manager.setBinaryParserFormat(project, format, monitor);
 	}
 
 	/**
-	 * Save the binary parser for the project.
+	 * Return the default BinaryParser format
 	 */
-	public static void setBinaryParser(IProject project, String format) {
-		manager.setBinaryParser(project, format);
+	public String getDefaultBinaryParserFormat() {
+		return manager.getDefaultBinaryParserFormat();
 	}
-	
+
 	/**
-	 * Return the BinaryParser corresponding to this format.
+	 * Set the default binaryParser.
 	 */
-	public static IBinaryParser getBinaryParser(String format) {
-		return CCorePlugin.getDefault().getBinaryParser(format);
+	public void setDefaultBinaryParserFormat(String format) {
+		manager.setDefaultBinaryParserFormat(format);
 	}
-	
+
 	/**
 	 * Return the singleton.
 	 */
Index: model/org/eclipse/cdt/core/model/IBinaryParser.java
===================================================================
RCS file: model/org/eclipse/cdt/core/model/IBinaryParser.java
diff -N model/org/eclipse/cdt/core/model/IBinaryParser.java
--- model/org/eclipse/cdt/core/model/IBinaryParser.java	25 Nov 2002 05:54:06 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,90 +0,0 @@
-package org.eclipse.cdt.core.model;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
- 
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- */
-public interface IBinaryParser {
-
-	/**
-	 * Represents a binary file for example an ELF executable.
-	 */
-	public interface IBinaryFile extends IAdaptable {
-		public int OBJECT = 0x1;
-		public int EXECUTABLE = 0x02;
-		public int SHARED = 0x04;
-		public int ARCHIVE = 0x08;
-		public int CORE = 0x10;
-
-		public IFile getFile();
-		public int getType();
-		public InputStream getContents();
-	}
-
-	/**
-	 * Represents an archive.
-	 */
-	public interface IBinaryArchive extends IBinaryFile {
-		public IBinaryObject[] getObjects();
-	}
-
-	/**
-	 * Represents a binary, for example an ELF excutable.
-	 */
-	public interface IBinaryObject extends IBinaryFile {
-
-		public boolean hasDebug();
-
-		public String getCPU();
-
-		public long getText();
-
-		public long getData();
-
-		public long getBSS();
-        
-		public boolean isLittleEndian();
-
-		public ISymbol[] getSymbols();
-		
-		public String getName();
-
-	}
-
-	/**
-	 * An executable.
-	 */
-	public interface IBinaryExecutable extends IBinaryObject {
-		public String[] getNeededSharedLibs();
-	}
-
-	/**
-	 * A DLL.
-	 */
-	public interface IBinaryShared extends IBinaryExecutable {
-		public String getSoName();
-	}
-
-	public interface ISymbol {
-		public int FUNCTION = 0x01;
-		public int VARIABLE = 0x02;
-	
-		public String getName();
-		public int getLineNumber();
-		public String getFilename();
-		public int getType();
-	}
-
-	public IBinaryFile getBinary(IFile file) throws IOException;
-	
-	public String getFormat();
-}
Index: model/org/eclipse/cdt/core/model/ICElementDelta.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElementDelta.java,v
retrieving revision 1.1
diff -u -r1.1 ICElementDelta.java
--- model/org/eclipse/cdt/core/model/ICElementDelta.java	26 Jun 2002 20:37:15 -0000	1.1
+++ model/org/eclipse/cdt/core/model/ICElementDelta.java	27 Nov 2002 04:35:52 -0000
@@ -95,6 +95,11 @@
 	 */
 	public int F_CLOSED = 0x0400;
 
+	/**
+	 * Change in the binary Parser.
+	 */
+	public int F_BINARY_PARSER_CHANGED = 0x0800;
+
 	//public int F_ADDED_TO_CLASSPATH = 0x0040;
 	//public int F_REMOVED_FROM_CLASSPATH = 0x0080;
 	//public int F_CLASSPATH_REORDER = 0x0100;
Index: model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java,v
retrieving revision 1.2
diff -u -r1.2 ArchiveInfo.java
--- model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java	18 Nov 2002 15:45:13 -0000	1.2
+++ model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java	27 Nov 2002 04:35:44 -0000
@@ -7,12 +7,12 @@
 
 import java.io.IOException;
 
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IBinaryParser;
 import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.internal.core.model.parser.BinaryFileAdapter;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
@@ -74,7 +74,7 @@
 	IBinaryArchive getBinaryArchive() {
 		if (archive == null) {
 			IProject project = getElement().getCProject().getProject();
-			IBinaryParser parser = CModelManager.getBinaryParser(project);
+			IBinaryParser parser = CModelManager.getDefault().getBinaryParser(project);
 			if (parser != null) {
 				try {
 					IFile file = (IFile) getElement().getUnderlyingResource();
Index: model/org/eclipse/cdt/internal/core/model/BinaryInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java,v
retrieving revision 1.4
diff -u -r1.4 BinaryInfo.java
--- model/org/eclipse/cdt/internal/core/model/BinaryInfo.java	22 Nov 2002 16:32:25 -0000	1.4
+++ model/org/eclipse/cdt/internal/core/model/BinaryInfo.java	27 Nov 2002 04:35:48 -0000
@@ -10,14 +10,14 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
+import org.eclipse.cdt.core.IBinaryParser.ISymbol;
 import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IBinaryParser;
 import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryExecutable;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryShared;
-import org.eclipse.cdt.core.model.IBinaryParser.ISymbol;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
@@ -160,7 +160,7 @@
 	IBinaryObject getBinaryObject() {
 		if (binary == null) {
 			IProject project = getElement().getCProject().getProject();
-			IBinaryParser parser = CModelManager.getBinaryParser(project);
+			IBinaryParser parser = CModelManager.getDefault().getBinaryParser(project);
 			if (parser != null) {
 				try {
 					IFile file = (IFile) getElement().getUnderlyingResource();
Index: model/org/eclipse/cdt/internal/core/model/CElementDelta.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java,v
retrieving revision 1.3
diff -u -r1.3 CElementDelta.java
--- model/org/eclipse/cdt/internal/core/model/CElementDelta.java	13 Oct 2002 21:30:28 -0000	1.3
+++ model/org/eclipse/cdt/internal/core/model/CElementDelta.java	27 Nov 2002 04:35:48 -0000
@@ -592,6 +592,19 @@
 	 * The constructor should be used to create the root delta 
 	 * and then a change operation should call this method.
 	 */
+	public void binaryParserChanged(ICElement element) {
+		CElementDelta attachedDelta = new CElementDelta(element);
+		attachedDelta.fKind = CHANGED;
+		attachedDelta.fChangeFlags |= F_BINARY_PARSER_CHANGED;
+		insertDeltaTree(element, attachedDelta);
+	}
+
+	/**
+	 * Creates the nested deltas resulting from a change operation.
+	 * Convenience method for creating change deltas.
+	 * The constructor should be used to create the root delta 
+	 * and then a change operation should call this method.
+	 */
 	public void sourceAttached(ICElement element) {
 		CElementDelta attachedDelta = new CElementDelta(element);
 		attachedDelta.fKind = CHANGED;
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.11
diff -u -r1.11 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java	25 Nov 2002 05:51:45 -0000	1.11
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java	27 Nov 2002 04:35:46 -0000
@@ -7,17 +7,23 @@
  
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.model.ElementChangedEvent;
 import org.eclipse.cdt.core.model.IArchive;
 import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryParser;
 import org.eclipse.cdt.core.model.ICElement;
 import org.eclipse.cdt.core.model.ICElementDelta;
 import org.eclipse.cdt.core.model.ICFile;
@@ -26,7 +32,6 @@
 import org.eclipse.cdt.core.model.ICResource;
 import org.eclipse.cdt.core.model.ICRoot;
 import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
 import org.eclipse.cdt.internal.core.model.parser.ElfParser;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
@@ -46,7 +51,7 @@
 
 public class CModelManager implements IResourceChangeListener {
 
-	private HashMap fParsedResources =  new HashMap();	
+	private Map fParsedResources =  Collections.synchronizedMap(new HashMap());
 
 	final static String BINARY_PARSER= "binaryparser";
 
@@ -327,8 +332,31 @@
 			parent.removeChild(celement);
 		}
 		try {
+			// Remove in the hashMap all the prefixOf the resource, this
+			// will catch things when it is a container to remove the entire hierarchy
 			IResource res = celement.getUnderlyingResource();
-			fParsedResources.remove(res);
+			if (res != null) {
+				IPath resPath = res.getFullPath();
+				if (resPath != null) {
+					ArrayList list = new ArrayList();
+					Set s = fParsedResources.keySet();
+					synchronized (s) {
+						Iterator keys = s.iterator();
+						while (keys.hasNext()) {
+							IResource r = (IResource)keys.next();
+							IPath p = r.getFullPath();
+							if (p != null && resPath.isPrefixOf(p)) {
+//System.out.println("Removing [" + resPath + "] " + p);
+								list.add(r);
+							}
+						}
+					}
+					for (int i = 0; i < list.size(); i++) {
+						fParsedResources.remove((IResource)list.get(i));
+					}
+				}
+				fParsedResources.remove(res);
+			}
 		} catch (CModelException e) {
 		}
 	}
@@ -348,21 +376,17 @@
 		return null;
 	}
 
-	public static IBinaryParser getBinaryParser(IProject project) {
+	public IBinaryParser getBinaryParser(IProject project) {
 		// It is in the property of the project of the cdtproject
 		// For now the default is Elf.
 		IBinaryParser parser = (IBinaryParser)fParsers.get(project);
 		if (parser == null) {
-			String format = null;
-			// FIXME: Ask the .cdtproject second.
-			try {
-				if (project != null) {
-					format = project.getPersistentProperty(binaryParserKey);
-				}
-			} catch (CoreException e) {
+			String format = getBinaryParserFormat(project);
+			if (format == null || format.length() == 0) {
+				format = getDefaultBinaryParserFormat();
 			}
 			if (format != null && format.length() > 0) {
-				parser = CoreModel.getDefault().getBinaryParser(format);
+				parser = CCorePlugin.getDefault().getBinaryParser(format);
 			}
 			if (parser == null) {
 				parser = defaultBinaryParser;
@@ -372,17 +396,67 @@
 		return parser;
 	}
 
-	public static void setBinaryParser(IProject project, String format) {
+	public String getDefaultBinaryParserFormat() {
+		String format = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(BINARY_PARSER);
+		if (format == null || format.length() == 0) {
+			return "ELF";
+		}
+		return format;
+	}
+
+	public String getBinaryParserFormat(IProject project) {
+		// It can be in the property of the project or in the .cdtproject
+		String format = null;
+		// FIXME: Ask the .cdtproject.
+		try {
+			if (project != null) {
+				format = project.getPersistentProperty(binaryParserKey);
+			}
+		} catch (CoreException e) {
+		}
+		return format;
+	}
+
+	public void setDefaultBinaryParserFormat(String format) {
+		CCorePlugin.getDefault().getPluginPreferences().setDefault(BINARY_PARSER, format);
+	}
+
+	public void setBinaryParserFormat(IProject project, String format, IProgressMonitor monitor) {
 		try {
 			if (project != null) {
 				project.setPersistentProperty(binaryParserKey, format);
 				fParsers.remove(project);
+				IPath projPath = project.getFullPath();
+				if (projPath != null) {
+					Collection c = fParsedResources.values();
+					ArrayList list = new ArrayList();
+					synchronized (c) {
+						Iterator values = c.iterator();
+						while (values.hasNext()) {
+							ICElement ce = (ICElement)values.next();
+							if (!(ce instanceof ICRoot || ce instanceof ICProject)) {
+							   	if (ce.getCProject().getProject().equals(project)) {
+									list.add(ce);
+								}
+							}
+						}
+					}
+					for (int i = 0; i < list.size(); i++) {
+						ICElement ce = (ICElement)list.get(i);
+						releaseCElement(ce);
+					}
+				}
+				// Fired and ICElementDelta.PARSER_CHANGED
+				CElementDelta delta = new CElementDelta(getCRoot());
+				delta.binaryParserChanged(create(project));
+				registerCModelDelta(delta);
+				fire();
 			}
 		} catch (CoreException e) {
 		}
 	}
 	
-	public static boolean isSharedLib(IFile file) {
+	public boolean isSharedLib(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
 			IBinaryFile bin = parser.getBinary(file);
@@ -393,7 +467,7 @@
 		return false;
 	}
 
-	public static boolean isObject(IFile file) {
+	public boolean isObject(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
 			IBinaryFile bin = parser.getBinary(file);
@@ -404,7 +478,7 @@
 		return false;
 	}
 
-	public static boolean isExecutable(IFile file) {
+	public boolean isExecutable(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
 			IBinaryFile bin = parser.getBinary(file);
@@ -415,7 +489,7 @@
 		return false;
 	}
 
-	public static boolean isBinary(IFile file) {
+	public boolean isBinary(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
 			IBinaryFile bin = parser.getBinary(file);
@@ -429,7 +503,7 @@
 		return false;
 	}
 
-	public static boolean isArchive(IFile file) {
+	public boolean isArchive(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
 			IBinaryFile bin = parser.getBinary(file);
@@ -440,11 +514,11 @@
 		return false;
 	}
 
-	public static boolean isTranslationUnit(IFile file) {
+	public boolean isTranslationUnit(IFile file) {
 		return isValidTranslationUnitName(file.getName());
 	}
 
-	public static boolean isValidTranslationUnitName(String name){
+	public boolean isValidTranslationUnitName(String name){
 		if (name == null) {
 			return false;
 		}
@@ -461,7 +535,7 @@
 	}
 
 	/* Only project with C nature and Open.  */
-	public static boolean hasCNature (IProject p) {
+	public boolean hasCNature (IProject p) {
 		boolean ok = false;
 		try {
 			ok = (p.isOpen() && p.hasNature(CProjectNature.C_NATURE_ID));
@@ -474,7 +548,7 @@
 	}
 
 	/* Only project with C++ nature and Open.  */
-	public static boolean hasCCNature (IProject p) {
+	public boolean hasCCNature (IProject p) {
 		boolean ok = false;
 		try {
 			ok = (p.isOpen() && p.hasNature(CCProjectNature.CC_NATURE_ID));
Index: model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java,v
retrieving revision 1.1
diff -u -r1.1 BinaryContainerAdapter.java
--- model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java	18 Nov 2002 15:43:53 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java	27 Nov 2002 04:35:50 -0000
@@ -7,8 +7,8 @@
  
 import java.util.ArrayList;
 
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.internal.core.model.Container;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
Index: model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java,v
retrieving revision 1.1
diff -u -r1.1 BinaryFileAdapter.java
--- model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java	18 Nov 2002 15:43:53 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java	27 Nov 2002 04:35:51 -0000
@@ -7,7 +7,7 @@
  
 import java.io.InputStream;
 
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.internal.core.model.Resource;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java,v
retrieving revision 1.2
diff -u -r1.2 ElfBinaryArchive.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java	25 Nov 2002 05:52:47 -0000	1.2
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java	27 Nov 2002 04:35:49 -0000
@@ -10,9 +10,9 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.utils.elf.AR;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java,v
retrieving revision 1.3
diff -u -r1.3 ElfBinaryFile.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java	25 Nov 2002 05:53:17 -0000	1.3
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java	27 Nov 2002 04:35:52 -0000
@@ -10,11 +10,11 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryExecutable;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryShared;
-import org.eclipse.cdt.core.model.IBinaryParser.ISymbol;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
+import org.eclipse.cdt.core.IBinaryParser.ISymbol;
 import org.eclipse.cdt.utils.elf.AR;
 import org.eclipse.cdt.utils.elf.Elf;
 import org.eclipse.cdt.utils.elf.ElfHelper;
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java,v
retrieving revision 1.2
diff -u -r1.2 ElfParser.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java	25 Nov 2002 05:53:32 -0000	1.2
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java	27 Nov 2002 04:35:51 -0000
@@ -7,7 +7,7 @@
  
 import java.io.IOException;
 
-import org.eclipse.cdt.core.model.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParser;
 import org.eclipse.cdt.utils.elf.AR;
 import org.eclipse.cdt.utils.elf.Elf;
 import org.eclipse.core.resources.IFile;
Index: model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java,v
retrieving revision 1.1
diff -u -r1.1 PEBinaryArchive.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java	25 Nov 2002 05:53:47 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java	27 Nov 2002 04:35:49 -0000
@@ -10,9 +10,9 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.utils.coff.PEArchive;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
Index: model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java,v
retrieving revision 1.1
diff -u -r1.1 PEBinaryFile.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java	25 Nov 2002 05:53:47 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java	27 Nov 2002 04:35:49 -0000
@@ -9,11 +9,11 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryExecutable;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.core.model.IBinaryParser.IBinaryShared;
-import org.eclipse.cdt.core.model.IBinaryParser.ISymbol;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
+import org.eclipse.cdt.core.IBinaryParser.ISymbol;
 import org.eclipse.cdt.utils.coff.Coff;
 import org.eclipse.cdt.utils.coff.PE;
 import org.eclipse.cdt.utils.coff.PEArchive;
Index: model/org/eclipse/cdt/internal/core/model/parser/PEParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java,v
retrieving revision 1.1
diff -u -r1.1 PEParser.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEParser.java	25 Nov 2002 05:53:47 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/parser/PEParser.java	27 Nov 2002 04:35:51 -0000
@@ -7,7 +7,7 @@
 
 import java.io.IOException;
 
-import org.eclipse.cdt.core.model.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParser;
 import org.eclipse.cdt.utils.coff.PE;
 import org.eclipse.cdt.utils.coff.PEArchive;
 import org.eclipse.core.resources.IFile;
Index: model/org/eclipse/cdt/internal/core/model/parser/Symbol.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/Symbol.java,v
retrieving revision 1.1
diff -u -r1.1 Symbol.java
--- model/org/eclipse/cdt/internal/core/model/parser/Symbol.java	25 Nov 2002 05:53:47 -0000	1.1
+++ model/org/eclipse/cdt/internal/core/model/parser/Symbol.java	27 Nov 2002 04:35:51 -0000
@@ -1,6 +1,6 @@
 package org.eclipse.cdt.internal.core.model.parser;
 
-import org.eclipse.cdt.core.model.IBinaryParser.ISymbol;
+import org.eclipse.cdt.core.IBinaryParser.ISymbol;
 
 /*
  * (c) Copyright IBM Corp. 2000, 2001.
Index: src/org/eclipse/cdt/core/CCorePlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java,v
retrieving revision 1.8
diff -u -r1.8 CCorePlugin.java
--- src/org/eclipse/cdt/core/CCorePlugin.java	25 Nov 2002 05:54:23 -0000	1.8
+++ src/org/eclipse/cdt/core/CCorePlugin.java	27 Nov 2002 04:35:54 -0000
@@ -13,8 +13,8 @@
 import org.eclipse.cdt.core.builder.ICBuilder;
 import org.eclipse.cdt.core.index.IndexModel;
 import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IBinaryParser;
 import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.internal.core.BinaryParserConfiguration;
 import org.eclipse.cdt.internal.core.CDescriptorManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
@@ -159,7 +159,7 @@
 		return getConsole(null);
 	}
 
-	public String[] getBinaryParserFormats() {
+	public IBinaryParserConfiguration[] getBinaryParserConfigurations() {
 		ArrayList list = new ArrayList();
 		IExtensionPoint extensionPoint = getDescriptor().getExtensionPoint("BinaryParser");
 		if (extensionPoint != null) {
@@ -167,14 +167,13 @@
 			for(int i = 0; i < extensions.length; i++){
 				IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
 				for( int j = 0; j < configElements.length; j++ ) {
-					String attr = configElements[j].getAttribute("format");
-					if (attr != null) {
-						list.add(attr);
-					}
+					String format = configElements[j].getAttribute("format");
+					String name = configElements[j].getAttribute("name");
+					list.add(new BinaryParserConfiguration(format, name));
 				}
 			}
 		}	
-		return (String[])list.toArray(new String[0]);
+		return (IBinaryParserConfiguration[])list.toArray(new IBinaryParserConfiguration[0]);
 	}
 	
 	public IBinaryParser getBinaryParser(String format) {
@@ -195,7 +194,7 @@
 		} catch (CoreException e) {
 		} 
 		return null;
-	}	
+	}
 
 	public CoreModel getCoreModel() {
 		return CoreModel.getDefault();
Index: src/org/eclipse/cdt/core/IBinaryParser.java
===================================================================
RCS file: src/org/eclipse/cdt/core/IBinaryParser.java
diff -N src/org/eclipse/cdt/core/IBinaryParser.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/core/IBinaryParser.java	27 Nov 2002 04:35:54 -0000
@@ -0,0 +1,90 @@
+package org.eclipse.cdt.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+ 
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ */
+public interface IBinaryParser {
+
+	/**
+	 * Represents a binary file for example an ELF executable.
+	 */
+	public interface IBinaryFile extends IAdaptable {
+		public int OBJECT = 0x1;
+		public int EXECUTABLE = 0x02;
+		public int SHARED = 0x04;
+		public int ARCHIVE = 0x08;
+		public int CORE = 0x10;
+
+		public IFile getFile();
+		public int getType();
+		public InputStream getContents();
+	}
+
+	/**
+	 * Represents an archive.
+	 */
+	public interface IBinaryArchive extends IBinaryFile {
+		public IBinaryObject[] getObjects();
+	}
+
+	/**
+	 * Represents a binary, for example an ELF excutable.
+	 */
+	public interface IBinaryObject extends IBinaryFile {
+
+		public boolean hasDebug();
+
+		public String getCPU();
+
+		public long getText();
+
+		public long getData();
+
+		public long getBSS();
+        
+		public boolean isLittleEndian();
+
+		public ISymbol[] getSymbols();
+		
+		public String getName();
+
+	}
+
+	/**
+	 * An executable.
+	 */
+	public interface IBinaryExecutable extends IBinaryObject {
+		public String[] getNeededSharedLibs();
+	}
+
+	/**
+	 * A DLL.
+	 */
+	public interface IBinaryShared extends IBinaryExecutable {
+		public String getSoName();
+	}
+
+	public interface ISymbol {
+		public int FUNCTION = 0x01;
+		public int VARIABLE = 0x02;
+	
+		public String getName();
+		public int getLineNumber();
+		public String getFilename();
+		public int getType();
+	}
+
+	public IBinaryFile getBinary(IFile file) throws IOException;
+	
+	public String getFormat();
+}
Index: src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
===================================================================
RCS file: src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
diff -N src/org/eclipse/cdt/core/IBinaryParserConfiguration.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/core/IBinaryParserConfiguration.java	27 Nov 2002 04:35:54 -0000
@@ -0,0 +1,12 @@
+package org.eclipse.cdt.core;
+
+
+
+/**
+ */
+public interface IBinaryParserConfiguration {
+
+	String getFormat();
+	String getName();
+	IBinaryParser getParser();
+}
Index: src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
diff -N src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/internal/core/BinaryParserConfiguration.java	27 Nov 2002 04:35:54 -0000
@@ -0,0 +1,40 @@
+package org.eclipse.cdt.internal.core;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.cdt.core.IBinaryParserConfiguration;
+
+/**
+ */
+public class BinaryParserConfiguration implements IBinaryParserConfiguration {
+
+	String format;
+	String name;
+
+	public BinaryParserConfiguration(String format, String name) {
+		this.format = format;
+		this.name = name;
+	}
+
+	/**
+	 * @see org.eclipse.cdt.core.IBinaryParserConfiguration#getFormat()
+	 */
+	public String getFormat() {
+		return format;
+	}
+
+	/**
+	 * @see org.eclipse.cdt.core.IBinaryParserConfiguration#getName()
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * @see org.eclipse.cdt.core.IBinaryParserConfiguration#getParser()
+	 */
+	public IBinaryParser getParser() {
+		return CCorePlugin.getDefault().getBinaryParser(format);
+	}
+
+}



Back to the top