# HG changeset patch # User timkelly # Date 1242048275 18000 # Node ID 697b7727d088ba929968c70f7b2ef6b093b4aed3 # Parent e743b7cf572cc9505928708e35701d3ef23bd33f Add preliminary parser support for Symbian Binary Variation support (ported from BSF support). See bug 8796 diff -r e743b7cf572c -r 697b7727d088 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Thu May 07 12:10:50 2009 -0500 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Mon May 11 08:24:35 2009 -0500 @@ -67,7 +67,7 @@ public CarbideBuildConfiguration(IProject project, ISymbianBuildContext context) { - super(context.getSDK(), context.getPlatformString(), context.getTargetString(), context.getBuildVariationName()); + super(context.getSDK(), context.getPlatformString(), context.getTargetString()); projectTracker = new TrackedResource(project); sisBuilderInfoList = new ArrayList(0); envVarsInfo = new EnvironmentVarsInfo2(project, context); diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java Thu May 07 12:10:50 2009 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java Mon May 11 08:24:35 2009 -0500 @@ -41,7 +41,6 @@ private String platform; private String target; private String displayString = null; - private String symbianBuildVariationString; private static String EMULATOR_DISPLAY_TEXT = "Emulator"; //$NON-NLS-1$ private static String PHONE_DISPLAY_TEXT = "Phone"; //$NON-NLS-1$ @@ -63,26 +62,11 @@ public SymbianBuildContext(ISymbianSDK theSDK, String thePlatform, String theTarget) { sdkId = theSDK.getUniqueId(); - String[] platformString = thePlatform.split("\\."); - if (platformString != null && platformString.length == 2){ - platform = platformString[0]; - symbianBuildVariationString = platformString[1]; - } else { - platform = thePlatform; - symbianBuildVariationString = ""; - } - + platform = thePlatform; target = theTarget; getDisplayString(); } - - public SymbianBuildContext(ISymbianSDK theSDK, String thePlatform, String theTarget, String theBinaryVariationName) { - sdkId = theSDK.getUniqueId(); - platform = thePlatform; - target = theTarget; - symbianBuildVariationString = theBinaryVariationName; - getDisplayString(); - } + @Override public int hashCode() { @@ -157,13 +141,8 @@ } else { displayString = displayString + SPACE_DISPLAY_TEXT + RELEASE_DISPLAY_TEXT; } - - String platDisplay = platform; - if (symbianBuildVariationString.length() > 0){ - platDisplay = platform + "." + symbianBuildVariationString; - } - - displayString = displayString + " (" + platDisplay + ") [" + getSDK().getUniqueId() + "]"; //$NON-NLS-1$ + + displayString = displayString + " (" + platform + ") [" + getSDK().getUniqueId() + "]"; //$NON-NLS-1$ } return displayString; } @@ -529,6 +508,13 @@ public String getBuildVariationName() { - return symbianBuildVariationString; + String varName = ""; + + String[] tokens = getPlatformString().split("\\."); + if (tokens.length == 2){ + varName = tokens[1]; + } + + return varName; } } diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalog.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +*/ +package com.nokia.carbide.cpp.internal.sdk.core.model; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +import com.nokia.carbide.cpp.sdk.core.ISBVCatalog; +import com.nokia.carbide.cpp.sdk.core.ISBVPlatform; +import com.nokia.cpp.internal.api.utils.core.IMessage; + +/** + * This class defines the hierarchy of VAR files detected for a given SDK. + * + */ +public class SBVCatalog implements ISBVCatalog { + + private List messages; + private List platforms; + + public SBVCatalog(IPath sdkPath, IPath sdkIncludePath) { + this.messages = new ArrayList(1); + this.platforms = new ArrayList(10); + + File epoc32ToolsDir = sdkPath.append("epoc32").append("tools").append("variant").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ + File[] sbvFiles = epoc32ToolsDir.listFiles(new FilenameFilter() { + public boolean accept(File file, String str) { + return str.toLowerCase().endsWith(".var"); //$NON-NLS-1$ + } + }); + + // cannot read directory; return empty catalog + if (sbvFiles == null){ + return; + } + + // gather the individual SBV platforms + for (File sbvFile : sbvFiles) { + IPath sbvPath = new Path(sbvFile.getAbsolutePath()); + if (sbvPath.toFile().toString().endsWith("variants.var")){ + continue; + } + SBVPlatform platform = SBVPlatform.createPlatform(this, sbvPath, messages, sdkIncludePath); + if (platform != null) { + platforms.add(platform); + } + } + + // TODO: Do we need to bother with a hierarchy? + // now wire up the platforms + //establishPlatformHierarchy(); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVCatalog#getMessages() + */ + public IMessage[] getMessages() { + return (IMessage[]) messages.toArray(new IMessage[messages.size()]); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVCatalog#findPlatform(java.lang.String) + */ + public ISBVPlatform findPlatform(String platformName) { + for (ISBVPlatform platform : platforms) { + if (platform.getName().equalsIgnoreCase(platformName)) + return platform; + } + return null; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVCatalog#getPlatforms() + */ + public ISBVPlatform[] getPlatforms() { + return (ISBVPlatform[]) platforms.toArray(new ISBVPlatform[platforms.size()]); + } + +} diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalogFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalogFactory.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +*/ +package com.nokia.carbide.cpp.internal.sdk.core.model; + +import com.nokia.carbide.cpp.sdk.core.ISBVCatalog; +import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * This factory creates SBV catalogs. + * + */ +public class SBVCatalogFactory { + + /** + * Create a catalog of SBV information for the .var files detected + * in the given SDK's directory. The catalog is regenerated from scratch. + * @param sdk non-null SDK to scan + * @return a catalog, never null + */ + public static ISBVCatalog createCatalog(ISymbianSDK sdk) { + SBVCatalog catalog = new SBVCatalog(new Path(sdk.getEPOCROOT()), sdk.getIncludePath()); + return catalog; + } + + /** + * Create a catalog of BSV information for the VAR files detected + * in the given directory. The catalog is regenerated from scratch. + * @param sdkPath path to an SDK root + * @param sdkIncludePath path to the SDK's include directory + * @return a catalog, never null + */ + public static ISBVCatalog createCatalog(IPath sdkPath, IPath sdkIncludePath) { + SBVCatalog catalog = new SBVCatalog(sdkPath, sdkIncludePath); + return catalog; + } + +} diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +*/ +package com.nokia.carbide.cpp.internal.sdk.core.model; + +import java.text.MessageFormat; +import java.util.*; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; + +import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin; +import com.nokia.carbide.cpp.epoc.engine.ISBVViewRunnable; +import com.nokia.carbide.cpp.epoc.engine.model.ETristateFlag; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView; +import com.nokia.carbide.cpp.internal.api.sdk.Messages; +import com.nokia.carbide.cpp.sdk.core.ISBVCatalog; +import com.nokia.carbide.cpp.sdk.core.ISBVPlatform; +import com.nokia.cpp.internal.api.utils.core.*; + +/** + * This specifies a single SBV platform. + * + */ +public class SBVPlatform implements ISBVPlatform { + + /** The exact basename of the .var */ + private String name; + private IPath path; + private ISBVPlatform customizedPlatform; + private String customizes; + private IPath[] systemIncludePaths; + private IPath sdkIncludePath; + private IPath systemIncludePath; + private Map customizationOptions; + private ETristateFlag compileWithParent; + private ISBVCatalog catalog; + + /** + * @param sdk + * @param sbvPath + * @param enableAbiV2Mode used to remap ARMV5, ARMV6, or ARMV6_ABIV1 to an appropriate canonical name + + */ + // TODO: Add ISBVView for actual parsing + SBVPlatform(ISBVCatalog catalog, IPath sdkIncludePath, ISBVView view ) { + this.catalog = catalog; + this.sdkIncludePath = sdkIncludePath; + this.name = view.getName(); + this.customizes = view.getCustomizes().toUpperCase(); + this.path = view.getModel().getPath(); + this.compileWithParent = view.getCompileWithParent(); + this.customizationOptions = new HashMap(view.getCustomizationOptions()); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "SBV platform: " + name; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + return obj instanceof ISBVPlatform && ((ISBVPlatform) obj).getName().equalsIgnoreCase(name); + } + + + /** + * Set the customized platform. + * @param customized + */ + void setCustomizedPlatform(ISBVPlatform customized) { + Check.checkState(customized != this); + this.customizedPlatform = customized; + if (customized != null) { + this.customizes = customized.getName(); + } + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getCatalog() + */ + public ISBVCatalog getCatalog() { + return catalog; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getSBVPath() + */ + public IPath getSBVPath() { + return path; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getName() + */ + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getCustomizedPlatformName() + */ + public String getCustomizedPlatformName() { + return customizes; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getCustomizedPlatform() + */ + public ISBVPlatform getCustomizedPlatform() { + return customizedPlatform; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getSystemIncludePath() + */ + public IPath getSystemIncludePath() { + if (systemIncludePath == null) { + IPath customizedPlatformPath = null; + if (customizedPlatform != null) { + customizedPlatformPath = customizedPlatform.getSystemIncludePath(); + } + } + + return systemIncludePath; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISBVPlatform#getSystemIncludePaths() + */ + public IPath[] getSystemIncludePaths() { + if (systemIncludePaths == null) { + synchronized (this) { + // get unique set of paths in the proper order (most specific to least) + Set paths = new LinkedHashSet(); + ISBVPlatform platform = this; + while (platform != null) { + IPath path = platform.getSystemIncludePath(); + if (path != null) + paths.add(path); + } + systemIncludePaths = (IPath[]) paths.toArray(new IPath[paths.size()]); + } + } + return systemIncludePaths; + } + + /** + * Create one SBV platform, partially initialized in isolation from the + * content of one SBV file. + * @param catalog the owning catalog + * @param sbvPath full path to .sbv file + * @param messages array of messages to which to add any messages found while parsing + * @return new platform, or null on error + */ + public static SBVPlatform createPlatform( + final ISBVCatalog catalog, + final IPath sbvPath, + final List messages, + final IPath sdkIncludePath) { + + ISBVViewRunnable runnable = new ISBVViewRunnable() { + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.IViewRunnable#failedLoad(org.eclipse.core.runtime.CoreException) + */ + public Object failedLoad(CoreException exception) { + EpocEnginePlugin.log(exception); + messages.add(new Message(IMessage.ERROR, + new MessageLocation(sbvPath), + "SBVCatalog.SBVLoadError", //$NON-NLS-1$ + MessageFormat.format( + Messages.getString("SBVCatalog.SBVLoadError"), //$NON-NLS-1$ + new Object[] { exception.getLocalizedMessage() }) + )); + return null; + } + public Object run(ISBVView view) { + IMessage[] viewMessages = view.getMessages(); + for (IMessage message : viewMessages) { + messages.add(message); + } + return new SBVPlatform(catalog, sdkIncludePath, view); + } + }; + + return (SBVPlatform) EpocEnginePlugin.runWithSBVView(sbvPath, runnable); + } + + +} + diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java Thu May 07 12:10:50 2009 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java Mon May 11 08:24:35 2009 -0500 @@ -81,7 +81,9 @@ private List variantHRHMacros = null; private List bsfContextList = new ArrayList(0); - + + private List binaryVariantContextList = new ArrayList(0); + private Date createDate; private URL publisherURL; private String sdkDescription; @@ -92,6 +94,7 @@ List supportedTargetTypesList = new ArrayList(); private IBSFCatalog bsfCatalog; + private ISBVCatalog sbvCatalog; private Map> cachedPlatformMacros = new HashMap>(); @@ -260,6 +263,7 @@ ISDKManager sdkMgr = SDKCorePlugin.getSDKManager(); if (sdkMgr.getBSFScannerEnabled()){ buildTargets.addAll(getBSFPlatformContexts()); + //buildTargets.addAll(getBinaryVariationPlatformContexts()); // Symbian Binary Variation (.var) } return buildTargets; @@ -284,6 +288,24 @@ return bsfContextList; } + +public List getBinaryVariationPlatformContexts(){ + + synchronized (binaryVariantContextList) { + if (!binaryVariantContextList.isEmpty()){ + return binaryVariantContextList; + } + + ISBVCatalog catalog = getSBVCatalog(); + for (ISBVPlatform sbvPlatform : catalog.getPlatforms()) { + // Currently only variation of ARMV5 is supported... So just hard code the variated platform + binaryVariantContextList.add(new SymbianBuildContext(this, SymbianBuildContext.ARMV5_PLATFORM + "." + sbvPlatform.getName(), ISymbianBuildContext.DEBUG_TARGET)); + binaryVariantContextList.add(new SymbianBuildContext(this, SymbianBuildContext.ARMV5_PLATFORM + "." + sbvPlatform.getName(), ISymbianBuildContext.RELEASE_TARGET)); + } + } + + return binaryVariantContextList; + } public List getFilteredBuildConfigurations() { @@ -1187,5 +1209,16 @@ return bsfCatalog; } + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.sdk.core.ISymbianSDK#getBSFCatalog() + */ + public ISBVCatalog getSBVCatalog() { + synchronized (this) { + if (sbvCatalog == null) { + sbvCatalog = SBVCatalogFactory.createCatalog(this); + } + } + return sbvCatalog; + } } diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVCatalog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVCatalog.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +*/ +package com.nokia.carbide.cpp.sdk.core; + +import com.nokia.cpp.internal.api.utils.core.*; + +/** + * This is a catalog of all the .VAR (Symbian Binary Variation) files detected for a given SDK. + * + */ +public interface ISBVCatalog { + /** + * Get any problems detected while parsing the BSF files. + * @return array of messages, never null + */ + IMessage[] getMessages(); + + /** + * Get the array of SBV platforms detected. Each corresponds to + * a *.var file. This does not include the built-in platforms. + * @return array, never null + */ + ISBVPlatform[] getPlatforms(); + + + /** + * Find a platform with the given name. + * @param name platform name, case doesn't matter + * @return platform or null + */ + ISBVPlatform findPlatform(String platform); + +} diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +*/ +package com.nokia.carbide.cpp.sdk.core; + +import org.eclipse.core.runtime.IPath; + +import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin; + +/** + * This interface defines a single Symbian Binary Variation (SBV) platform. + *

+ * Once a platform is available + * from a catalog, it is contained in a hierarchy of platforms, terminating at + * built-in platforms (like ARMV5). + */ +public interface ISBVPlatform { + /** + * Get the catalog this platform is contained in. + * @return ISBVCatalog, never null + */ + ISBVCatalog getCatalog(); + + /** + * Get the platform's name, as seen in the .var filename. + * + * @return name, never null + */ + String getName(); + + /** + * Get the full file system path to the .var used. + *

+ * This may be used + * to retrieve the {@link ISBVView} via {@link EpocEnginePlugin#runWithSBVView(IPath, com.nokia.carbide.cpp.epoc.engine.model.IViewConfiguration, com.nokia.carbide.cpp.epoc.engine.ISBVViewRunnable)} + * to get more information about the SBV. + * + * @return path, never null + */ + IPath getSBVPath(); + + /** + * Get the system include path for this variant. + * @return full filesystem path to the include directory for the variant, + * which may be the parent/customized platform's directory for virtual + * variant, or null if no non-virtual parent exists. + */ + IPath getSystemIncludePath(); + + /** + * Get the system include file paths needed for this variant and all its parents. + * This does not include the epoc32\include\oem directory, which is presumed + * for all platforms. + * @return array of full filesystem paths, never null + */ + IPath[] getSystemIncludePaths(); +} diff -r e743b7cf572c -r 697b7727d088 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianBuildContext.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianBuildContext.java Thu May 07 12:10:50 2009 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianBuildContext.java Mon May 11 08:24:35 2009 -0500 @@ -113,6 +113,7 @@ /** * For platforms that are building with Symbian Binary Variation, this suffix will be included in the configuration name + * For example, if you are building variant armv5.product1, then this will return "product1" string. * @return The name of the Symbian Binary Variation, or an empy String if the configuration is not a variation. */ public String getBuildVariationName(); diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/META-INF/MANIFEST.MF --- a/project/com.nokia.carbide.cpp.epoc.engine/META-INF/MANIFEST.MF Thu May 07 12:10:50 2009 -0500 +++ b/project/com.nokia.carbide.cpp.epoc.engine/META-INF/MANIFEST.MF Mon May 11 08:24:35 2009 -0500 @@ -20,6 +20,7 @@ com.nokia.carbide.cpp.epoc.engine.model, com.nokia.carbide.cpp.epoc.engine.model.bldinf, com.nokia.carbide.cpp.epoc.engine.model.bsf, + com.nokia.carbide.cpp.epoc.engine.model.sbv, com.nokia.carbide.cpp.epoc.engine.model.makefile, com.nokia.carbide.cpp.epoc.engine.model.makefile.image, com.nokia.carbide.cpp.epoc.engine.model.mmp, diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/EpocEnginePlugin.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/EpocEnginePlugin.java Thu May 07 12:10:50 2009 -0500 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/EpocEnginePlugin.java Mon May 11 08:24:35 2009 -0500 @@ -16,6 +16,9 @@ */ package com.nokia.carbide.cpp.epoc.engine; +import org.eclipse.core.runtime.*; +import org.osgi.framework.BundleContext; + import com.nokia.carbide.cpp.epoc.engine.model.*; import com.nokia.carbide.cpp.epoc.engine.model.bldinf.*; import com.nokia.carbide.cpp.epoc.engine.model.bsf.*; @@ -23,14 +26,10 @@ import com.nokia.carbide.cpp.epoc.engine.model.makefile.IMakefileOwnedModel; import com.nokia.carbide.cpp.epoc.engine.model.makefile.image.*; import com.nokia.carbide.cpp.epoc.engine.model.mmp.*; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.*; import com.nokia.carbide.internal.cpp.epoc.engine.model.ViewDataCache; -import com.nokia.cpp.internal.api.utils.core.*; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; +import com.nokia.cpp.internal.api.utils.core.Logging; +import com.nokia.cpp.internal.api.utils.core.MultiResourceChangeListenerDispatcher; /** * The main plugin class to be used in the desktop. @@ -54,6 +53,7 @@ private static IModelProvider makefileModelProvider; private static IModelProvider imageMakefileModelProvider; private static IModelProvider bsfModelProvider; + private static IModelProvider sbvModelProvider; private static ViewDataCache mmpViewDataCache; @@ -145,7 +145,7 @@ } /** - * Get the provider that manages access to image (scalable icon) makefiles in the workspace. + * Get the provider that manages access to BSF files in an SDK. * @return provider, never null */ public static synchronized IModelProvider getBSFModelProvider() { @@ -155,6 +155,16 @@ return bsfModelProvider; } + /** + * Get the provider that manages access to the .var files in the SDK (for Symbian Binary Variation support). + * @return provider, never null + */ + public static synchronized IModelProvider getSBVModelProvider() { + if (sbvModelProvider == null) { + sbvModelProvider = ModelProviderFactory.createModelProvider(new SBVModelFactory()); + } + return sbvModelProvider; + } /** * Get the dispatcher for resource change events handling multiple paths. @@ -331,6 +341,46 @@ } /** + * Get a shared instance of the given SBV model, create a view + * with the given configuration, and run user code using the model. + *

+ * The model and view are automatically released. + *

+ * If the model cannot be loaded or an exception is thrown, the runnable's + * #failedLoad() is called. + * @param modelPath workspace-relative path + * @param runnable the code to run when the model is loaded (or fails) + * @return result from runnable#run + */ + public static Object runWithSBVView(IPath modelPath, + ISBVViewRunnable runnable) { + ISBVModel model; + if (runnable instanceof ViewRunnableAdapter) { + ((ViewRunnableAdapter) runnable).setModelPath(modelPath); + } + try { + model = getSBVModelProvider().getSharedModel(modelPath); + } catch (CoreException e) { + return runnable.failedLoad(e); + } catch (Throwable t) { + return runnable.failedLoad(new CoreException(Logging.newStatus(EpocEnginePlugin.getDefault(), t))); + } + ISBVView view = null; + if (model == null) { + return runnable.failedLoad(null); + } + try { + view = model.createView(null); + return runnable.run(view); + } finally { + if (view != null) + view.dispose(); + getSBVModelProvider().releaseSharedModel(model); + } + } + + + /** * Get a read-only copy of data for the given MMP view * with the given configuration, and run user code using the model. *

diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/ISBVViewRunnable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/ISBVViewRunnable.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.epoc.engine; + +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVModel; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView; + +/** + * Instantiate this interface and pass to EpocEnginePlugin#runWithSBVView() + * to encapsulate some of the bookkeeping of model/view handling. + * + */ +public interface ISBVViewRunnable extends IViewRunnable { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/SBVModelFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/SBVModelFactory.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.epoc.engine.model; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.text.IDocument; + +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVOwnedModel; +import com.nokia.carbide.internal.cpp.epoc.engine.model.sbv.SBVModel; + +public class SBVModelFactory implements IModelFactory { + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.IModelFactory#createModel(org.eclipse.core.runtime.IPath, org.eclipse.jface.text.IDocument) + */ + public ISBVOwnedModel createModel(IPath path, IDocument document) { + return new SBVModel(path, document); + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ESBVFlags.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ESBVFlags.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.epoc.engine.model.sbv; + +/** + * This enumeration defines all the flags which may appear in the SBV (.var) + * grammar. + * + */ +public enum ESBVFlags { + COMPILEWITHPARENT, + COMPILEALONE, + VIRTUALVARIANT, + VARIANT +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ISBVModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ISBVModel.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.epoc.engine.model.sbv; + +import com.nokia.carbide.cpp.epoc.engine.model.IModel; + +/** + * This is the user interface to a Symbian Binary Variation (VAR) model. + * + */ +public interface ISBVModel extends IModel { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ISBVOwnedModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ISBVOwnedModel.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.epoc.engine.model.sbv; + +import com.nokia.carbide.cpp.epoc.engine.model.*; + +/** + * This is the owner interface to the SBV (Symbian Binary Variant) model. + */ +public interface ISBVOwnedModel extends ISBVModel, IOwnedModel { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ISBVView.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/sbv/ISBVView.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.cpp.epoc.engine.model.sbv; + +import com.nokia.carbide.cpp.epoc.engine.model.ETristateFlag; +import com.nokia.carbide.cpp.epoc.engine.model.IView; + +import java.util.Map; + +/** + * A view onto .VAR (Symbian Binary Variation) contents. This is a parse over a single .VAR file. + *

+ * Note: this view cannot be rewritten. + * + * + */ +public interface ISBVView extends IView { + + /** Get the name of SBV as a platform. */ + String getName(); + + /** Set the CUSTOMIZES platform. + * @param platform may not be null, but may be "" */ + void setCustomizes(String platform); + + /** Get the CUSTOMIZES platform. + * @return platform this customizes; never null, but may be the empty string if .var is invalid. */ + String getCustomizes(); + + /** Tell whether the .var is compiled with its parent (COMPILEWITHPARENT, + * COMPILEALONE, or unspecified) */ + ETristateFlag getCompileWithParent(); + + /** Set the COMPILEWITHPARENT disposition. */ + void setCompileWithParent(ETristateFlag flag); + + /** Get the map of customization options, which is a map of + * the (capitalized) first token on the line to the remainder of the line. + * @return map never null */ + Map getCustomizationOptions(); + + /** Replace the map of customization options. + * @param map may not be null*/ + void setCustomizationOptions(Map map); + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/ASTSBVFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/ASTSBVFactory.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.*; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv.*; +import com.nokia.cpp.internal.api.utils.core.IMessage; + + +public abstract class ASTSBVFactory extends ASTFactory { + + public static IASTListNode createSBVStatementListNode() { + return createListNode(""); //$NON-NLS-1$ + } + + public static IASTSBVFlagStatement createSBVFlagStatement(String name) { + return new ASTSBVFlagStatement(createPreprocessorLiteralTextNode(name)); + } + + public static IASTSBVFlagStatement createSBVFlagStatement(IASTLiteralTextNode name) { + return new ASTSBVFlagStatement(name); + } + + public static IASTSBVTranslationUnit createSBVTranslationUnit( + IASTListNode nodes) { + if (nodes == null) + nodes = createTopLevelNodeListNode(); + return new ASTSBVTranslationUnit(nodes); + } + + public static IASTSBVTranslationUnit createSBVTranslationUnit() { + return createSBVTranslationUnit(null); + } + + public static IASTSBVProblemStatement createSBVProblemStatement(IASTPreprocessorTokenStream tokenStream, IMessage message) { + return new ASTSBVProblemStatement(tokenStream, message); + } + + public static IASTSBVProblemStatement createSBVProblemStatement(String string, IMessage message) { + return createSBVProblemStatement(createPreprocessorTokenStream(string), message); + } + + public static IASTSBVArgumentStatement createSBVArgumentStatement( + String keyword, String arguments) { + return createSBVArgumentStatement(createPreprocessorLiteralTextNode(keyword), + createPreprocessorLiteralTextNode(arguments)); + } + + public static IASTSBVArgumentStatement createSBVArgumentStatement( + IASTLiteralTextNode keyword, + IASTLiteralTextNode arguments) { + return new ASTSBVArgumentStatement(keyword, arguments); + } + + public static IASTSBVStatement createSBVCommentStatement(String line) { + if (line == null) + line = ""; //$NON-NLS-1$ + return new ASTSBVCommentStatement(createPreprocessorTokenStream(line)); + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVArgumentStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVArgumentStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTLiteralTextNode; + +public interface IASTSBVArgumentStatement extends IASTSBVStatement { + IASTLiteralTextNode getArgument(); + void setArgument(IASTLiteralTextNode argument); +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVCommentStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVCommentStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTPreprocessorTokenStreamStatement; + +public interface IASTSBVCommentStatement extends IASTSBVStatement, + IASTPreprocessorTokenStreamStatement { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVFlagStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVFlagStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTKeywordStatement; + +/** + * Statement representing a standalone flag. + * + */ +public interface IASTSBVFlagStatement extends IASTKeywordStatement, IASTSBVStatement { +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVProblemStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVProblemStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTProblemTopLevelNode; + +public interface IASTSBVProblemStatement extends IASTProblemTopLevelNode, + IASTSBVStatement { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTStatement; + +public interface IASTSBVStatement extends IASTStatement { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVTranslationUnit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/dom/sbv/IASTSBVTranslationUnit.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTTranslationUnit; + +public interface IASTSBVTranslationUnit extends IASTTranslationUnit { + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVArgumentStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVArgumentStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.*; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.IASTSBVArgumentStatement; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTKeywordStatement; + + +public class ASTSBVArgumentStatement extends ASTKeywordStatement implements + IASTSBVArgumentStatement { + + private IASTLiteralTextNode arguments; + + + /** + * @param keyword + * @param arguments + */ + public ASTSBVArgumentStatement(IASTLiteralTextNode keyword, IASTLiteralTextNode argument) { + super(keyword); + setArgument(argument); + dirty = false; + } + + /** + * @param statement + */ + public ASTSBVArgumentStatement(ASTSBVArgumentStatement statement) { + super(statement); + setArgument((IASTLiteralTextNode) statement.getArgument().copy()); + dirty = statement.dirty; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equalValue(IASTNode obj) { + if (!(obj instanceof ASTSBVArgumentStatement)) + return false; + if (!super.equalValue(obj)) + return false; + + ASTSBVArgumentStatement node = (ASTSBVArgumentStatement) obj; + return node.arguments.equalValue(arguments); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return super.hashCode() ^ arguments.hashCode() ^ -309982; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.mmp.dom.IASTMMPStatement#getArgumentText() + */ + public IASTLiteralTextNode getArgument() { + return arguments; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.mmp.dom.IASTMMPStatement#setArgumentText(com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTLiteralTextNode) + */ + public void setArgument(IASTLiteralTextNode argument) { + unparent(this.arguments); + if (argument != null) + parent(argument); + this.arguments = argument; + fireChanged(); + dirty = true; + } + + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.internal.ASTMMPStatement#copy() + */ + public IASTNode copy() { + return new ASTSBVArgumentStatement(this); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTNode#rewrite(com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IRewriteHandler) + */ + public void rewrite(IRewriteHandler handler) { + handler.emitNode(getKeyword()); + handler.emitSpace(); + handler.emitNode(arguments); + handler.emitNewline(); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.internal.ASTMMPKeywordStatement#getChildren() + */ + @Override + public IASTNode[] getChildren() { + return new IASTNode[] { getKeyword(), arguments }; + } +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVCommentStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVCommentStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTPreprocessorTokenStream; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.IASTSBVCommentStatement; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTPreprocessorTokenStreamStatement; + + +public class ASTSBVCommentStatement extends ASTPreprocessorTokenStreamStatement + implements IASTSBVCommentStatement { + + /** + * @param tokenStream + */ + public ASTSBVCommentStatement(IASTPreprocessorTokenStream tokenStream) { + super(tokenStream); + } + + /** + * @param node + */ + public ASTSBVCommentStatement(ASTSBVCommentStatement node) { + super(node); + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVFlagStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVFlagStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.*; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.IASTSBVFlagStatement; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTKeywordStatement; + + +public class ASTSBVFlagStatement extends ASTKeywordStatement implements + IASTSBVFlagStatement { + + /** + * @param keyword + * @param arguments + */ + public ASTSBVFlagStatement(IASTLiteralTextNode keyword) { + super(keyword); + } + + /** + * @param statement + */ + public ASTSBVFlagStatement(ASTSBVFlagStatement statement) { + super(statement); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equalValue(IASTNode obj) { + if (!(obj instanceof ASTSBVFlagStatement)) + return false; + return super.equalValue(obj); + } + + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.internal.ASTMMPStatement#copy() + */ + public IASTNode copy() { + return new ASTSBVFlagStatement(this); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTNode#rewrite(com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IRewriteHandler) + */ + public void rewrite(IRewriteHandler handler) { + handler.emitNode(getKeyword()); + handler.emitNewline(); + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVProblemStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVProblemStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTPreprocessorTokenStream; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.IASTSBVProblemStatement; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTProblemTopLevelNode; +import com.nokia.cpp.internal.api.utils.core.IMessage; + + +public class ASTSBVProblemStatement extends ASTProblemTopLevelNode implements + IASTSBVProblemStatement { + + /** + * @param tokenStream + * @param message + */ + public ASTSBVProblemStatement(IASTPreprocessorTokenStream tokenStream, IMessage message) { + super(tokenStream, message); + } + + /** + * @param statement + */ + public ASTSBVProblemStatement(ASTSBVProblemStatement statement) { + super(statement); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTStatement#getKeywordName() + */ + public String getKeywordName() { + return null; + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVStatement.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.IASTSBVStatement; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTStatement; + + +public abstract class ASTSBVStatement extends ASTStatement implements IASTSBVStatement { + + public ASTSBVStatement() { + super(); + } + + public ASTSBVStatement(ASTSBVStatement other) { + super(other); + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVTranslationUnit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/dom/sbv/ASTSBVTranslationUnit.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.dom.sbv; + +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.*; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.IASTSBVTranslationUnit; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTTranslationUnit; + + +public class ASTSBVTranslationUnit extends ASTTranslationUnit implements + IASTSBVTranslationUnit { + + public ASTSBVTranslationUnit( + IASTListNode nodes) { + super(nodes); + } + + public ASTSBVTranslationUnit(ASTSBVTranslationUnit unit) { + super(unit); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equalValue(IASTNode obj) { + if (!(obj instanceof ASTSBVTranslationUnit)) + return false; + return super.equalValue(obj); + } + + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ModelProviderBase.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ModelProviderBase.java Thu May 07 12:10:50 2009 -0500 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ModelProviderBase.java Mon May 11 08:24:35 2009 -0500 @@ -44,7 +44,7 @@ public abstract class ModelProviderBase implements IModelProvider { // not static or final so it can change during test - private boolean DUMP = false; + private boolean DUMP = true; private static int gProviderCounter; private int providerId; diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/sbv/SBVModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/sbv/SBVModel.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.model.sbv; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.text.IDocument; + +import com.nokia.carbide.cpp.epoc.engine.model.IViewConfiguration; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVOwnedModel; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView; +import com.nokia.carbide.internal.cpp.epoc.engine.model.ModelBase; + + +public class SBVModel extends ModelBase implements ISBVOwnedModel { + + public SBVModel(IPath path, IDocument document) { + super(path, document); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.model.ModelBase#createView(com.nokia.carbide.internal.cpp.epoc.engine.model.ModelBase, com.nokia.carbide.cpp.epoc.engine.model.IViewConfiguration) + */ + @Override + protected ISBVView createView(ModelBase model, IViewConfiguration configuration) { + return new SBVView(model, configuration); + } + +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/sbv/SBVView.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/sbv/SBVView.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,242 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.model.sbv; + +import java.util.*; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.text.IDocument; + +import com.nokia.carbide.cpp.epoc.engine.model.*; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVOwnedModel; +import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.ASTFactory; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTTopLevelNode; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.*; +import com.nokia.carbide.internal.cpp.epoc.engine.model.ModelBase; +import com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase; +import com.nokia.carbide.internal.cpp.epoc.engine.parser.IDocumentParser; +import com.nokia.carbide.internal.cpp.epoc.engine.parser.ParserFactory; +import com.nokia.cpp.internal.api.utils.core.*; + + +public class SBVView extends ViewBase implements ISBVView { + + private static final String HEADER = "##"; //$NON-NLS-1$ + private static final String COMPILEWITHPARENT = "COMPILEWITHPARENT"; //$NON-NLS-1$ + private static final String COMPILEALONE = "COMPILEALONE"; //$NON-NLS-1$ + private static final String CUSTOMIZES = "CUSTOMIZES"; //$NON-NLS-1$ + private static final String VARIANT = "VARIANT"; //$NON-NLS-1$ + private static final String VIRTUALVARIANT = "VIRTUALVARIANT"; //$NON-NLS-1$ + + private IASTSBVTranslationUnit tu; + private boolean sawHeaderComment; + private boolean sawCustomizes; + + private ETristateFlag compileWithParent; + private Map customizationOptions; + private String customizes; + + /** + * @param model + * @param parser + * @param viewConfiguration + */ + public SBVView(ModelBase model, IViewConfiguration viewConfiguration) { + super(model, null, viewConfiguration); + tu = null; + customizationOptions = new HashMap(); + } + + private void refresh() { + compileWithParent = ETristateFlag.UNSPECIFIED; + customizationOptions.clear(); + customizes = ""; //$NON-NLS-1$ + + IDocumentParser sbvParser = ParserFactory.createSBVParser(); + tu = (IASTSBVTranslationUnit) sbvParser.parse(getModel().getPath(), getModel().getDocument()); + + sawHeaderComment = false; + sawCustomizes = false; + + for (IASTTopLevelNode stmt : tu.getNodes()) { + if (stmt instanceof IASTSBVCommentStatement) { + if (((IASTSBVCommentStatement) stmt).getNewText().equals(HEADER)) { + sawHeaderComment = true; + } + } else if (stmt instanceof IASTSBVFlagStatement) { + String flag = ((IASTSBVFlagStatement) stmt).getKeywordName(); + handleStatement(flag); + } else if (stmt instanceof IASTSBVArgumentStatement) { + String option = ((IASTSBVArgumentStatement) stmt).getKeywordName(); + String value = ((IASTSBVArgumentStatement) stmt).getArgument().getValue(); + handleStatement(option, value); + } else { + Check.checkState(false); + } + } + } + + /** + * Handle a statement with an option and a value. + * @param option + * @param value + */ + private void handleStatement(String option, String value) { + if (!sawCustomizes && option.equals(CUSTOMIZES)) { + setCustomizes(value); + sawCustomizes = true; + } else { + getCustomizationOptions().put(option, value); + } + } + + /** + * Handle a flag statement + * @param flag + */ + private void handleStatement(String flag) { + if (flag.equals(COMPILEWITHPARENT)) { + setCompileWithParent(ETristateFlag.ENABLED); + } else if (flag.equals(COMPILEALONE)) { + setCompileWithParent(ETristateFlag.DISABLED); + } else { + getCustomizationOptions().put(flag, null); + } + } + + @Override + public IPath[] getReferencedFiles() { + return new IPath[] { model.getPath() }; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase#internalReparse() + */ + @Override + protected Map internalReparse(Map overrideDocumentMap) { + // empty: nothing new provided yet + Map documentMap = new HashMap(); + refresh(); + return documentMap; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase#internalRevertChanges() + */ + @Override + protected void internalRevertChanges() { + refresh(); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase#internalHasChanges() + */ + @Override + protected boolean internalHasChanges() { + return false; + } + + /** + */ + protected void internalCommit() { + // no changes supported + } + + @Override + public boolean merge() { + return true; + } + + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase#addViewSpecificMessages(java.util.List) + */ + @Override + protected void addViewSpecificMessages(List messageList) { + IPath fullPath = getModel().getPath(); + if (!sawHeaderComment) { + messageList.add(ASTFactory.createErrorMessage("SBVView.InvalidSBVHeader", + new Object[0], + new MessageLocation(fullPath))); + } + if (!sawCustomizes) { + messageList.add(ASTFactory.createErrorMessage("SBVView.NoCustomizesStatement", + new Object[0], + new MessageLocation(fullPath))); + } + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#getCompileWithParent() + */ + public ETristateFlag getCompileWithParent() { + return compileWithParent; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#getCustomizationOptions() + */ + public Map getCustomizationOptions() { + return customizationOptions; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#getCustomizes() + */ + public String getCustomizes() { + return customizes; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#getName() + */ + public String getName() { + return getModel().getPath().removeFileExtension().lastSegment(); + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#setCompileWithParent(com.nokia.carbide.cpp.epoc.engine.model.ETristateFlag) + */ + public void setCompileWithParent(ETristateFlag flag) { + Check.checkArg(flag); + this.compileWithParent = flag; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#setCustomizationOptions(java.util.Map) + */ + public void setCustomizationOptions(Map map) { + Check.checkArg(map); + this.customizationOptions = map; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView#setCustomizes(java.lang.String) + */ + public void setCustomizes(String platform) { + this.customizes = platform; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.cpp.epoc.engine.model.IView#getData() + */ + public IData getData() { + return null; + } +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/ParserFactory.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/ParserFactory.java Thu May 07 12:10:50 2009 -0500 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/ParserFactory.java Mon May 11 08:24:35 2009 -0500 @@ -23,6 +23,7 @@ import com.nokia.carbide.internal.cpp.epoc.engine.parser.mmp.MMPParser; import com.nokia.carbide.internal.cpp.epoc.engine.parser.pkg.IPKGParserConfiguration; import com.nokia.carbide.internal.cpp.epoc.engine.parser.pkg.PKGParser; +import com.nokia.carbide.internal.cpp.epoc.engine.parser.sbv.SBVParser; public abstract class ParserFactory { @@ -70,6 +71,15 @@ public static IDocumentParser createBSFParser() { return new BSFParser(); } + + /** + * Create a SBV (.var) parser, whose output contains only IASTSBVStatements. + * @return + */ + public static IDocumentParser createSBVParser() { + return new SBVParser(); + } + /** * Create a PKG parser, whose output contains only IASTBSFStatements. diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/sbv/ISBVParserConfiguration.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/sbv/ISBVParserConfiguration.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.parser.sbv; + + +/** + * Extend parser configuration to tell which statements and kinds are recognized, e.g., + * according to the current SDK. + *

+ * All the calls are passed a canonical upper-case keyword. + * + */ +public interface ISBVParserConfiguration { + /** Unknown or illegal for this SDK */ + int UNKNOWN_STATEMENT = 0; + /** A statement which appears alone on a line */ + int FLAG_STATEMENT = 1; + /** A statement taking a single argument */ + int SINGLE_ARGUMENT_STATEMENT = 2; + /** A statement with a list of arguments, all alike */ + int LIST_ARGUMENT_STATEMENT = 3; + + /** Not returned here, but in EMMPStatement */ + int AIF_STATEMENT = 4; + /** Not returned here, but in EMMPStatement */ + int OPTION_STATEMENT = 5; + /** Not returned here, but in EMMPStatement */ + int START_BLOCK_STATEMENT = 6; + /** Not returned here, but in EMMPStatement */ + int UID_STATEMENT = 7; + /** Not returned here, but in EMMPStatement */ + int BITMAP_SOURCE_STATEMENT = 8; + + /** Is AIF supported? */ + boolean isAifStatementRecognized(); + /** Is SOURCE (for START BITMAP) supported? */ + boolean isBitmapSourceStatementRecognized(); + /** Is OPTION supported? */ + boolean isOptionStatementRecognized(); + /** Is START ... END supported? */ + boolean isStartBlockStatementRecognized(); + /** Is UID supported? */ + boolean isUidStatementRecognized(); + + /** Classify this generic statement */ + int categorizeStatement(String keyword); +} diff -r e743b7cf572c -r 697b7727d088 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/sbv/SBVParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/parser/sbv/SBVParser.java Mon May 11 08:24:35 2009 -0500 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.carbide.internal.cpp.epoc.engine.parser.sbv; + +import java.io.IOException; +import java.io.StringReader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.Region; + +import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.*; +import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.sbv.*; +import com.nokia.carbide.internal.cpp.epoc.engine.dom.ASTUtils; +import com.nokia.carbide.internal.cpp.epoc.engine.parser.*; +import com.nokia.cpp.internal.api.utils.core.IMessage; +import com.nokia.cpp.internal.api.utils.core.MessageLocation; + +/** + * This is a parser for Symbian Binary Variation (.var). + * + */ +public class SBVParser implements IDocumentParser { + /** Pattern ignoring space, matching a keyword, and allowing for possible options following a space. */ + /* Avoids consuming trailing space */ + private static final Pattern KEYWORD_AND_OPTIONS = Pattern.compile( + "\\s*((?:\\w|_)+)\\s*(?:\\s+(.*?)(?>\\s+)?)?(\\s*)"); //$NON-NLS-1$ + + private IPath path; + + private boolean hadErrors; + + private PositionTrackingReader reader; + private int lineNumber; + private int lineOffset; + + private IDocument document; + + public SBVParser() { + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.parser.sbv.ISBVParser#parse(org.eclipse.core.runtime.IPath, java.io.Reader) + */ + public IASTSBVTranslationUnit parse(IPath path, IDocument document) { + this.document = document; + this.reader = new PositionTrackingReader(new StringReader(document.get())); + IASTListNode stmts = ASTSBVFactory.createSBVStatementListNode(); + IASTSBVTranslationUnit tu = ASTSBVFactory.createSBVTranslationUnit(stmts); + hadErrors = false; + try { + String line; + this.path = path; + this.lineOffset = reader.getOffset(); + this.lineNumber = reader.getLineNumber(); + while ((line = reader.readLine()) != null) { + IASTSBVStatement stmt = parseStatement(line); + if (stmt != null) { + stmts.add(stmt); + } + this.lineOffset = reader.getOffset(); + this.lineNumber = reader.getLineNumber(); + } + } catch (IOException e) { + EpocEnginePlugin.log(e); + } + + if (!stmts.isEmpty()) { + ParserUtils.setSourceRangeForListNode(null, stmts, null); + } else { + stmts.setSourceRegion(ASTUtils.createDocumentSourceRegion(document, path, + new Region(0, 0))); + } + tu.copySourceInfo(stmts); + + tu.setDirtyTree(false); + + return tu; + } + + /* (non-Javadoc) + * @see com.nokia.carbide.internal.cpp.epoc.engine.parser.IDocumentParser#hadErrors() + */ + public boolean hadErrors() { + return hadErrors; + } + + /** + * @param line + * @return + */ + private IASTSBVStatement parseStatement(String line) { + if (line.trim().length() == 0) { + return null; + } + + IDocumentSourceRegion region = ASTUtils.createDocumentSourceRegion( + document, + path, + new Region(lineOffset, reader.getOffset() - lineOffset)); + + IASTSBVStatement stmt = null; + + if (line.startsWith("#")) { //$NON-NLS-1$ + stmt = ASTSBVFactory.createSBVCommentStatement(line); + ((IASTSBVCommentStatement) stmt).getTokenStream().setSourceRegion(region.copy()); + } else { + Matcher matcher = KEYWORD_AND_OPTIONS.matcher(line); + if (!matcher.matches()) { + return ASTSBVFactory.createSBVProblemStatement(line, + ASTFactory.createMessage(IMessage.ERROR, + "SBVParser.UnknownStatement", //$NON-NLS-1$ + new Object[0], + getMessageLocation())); + } + + String keyword = matcher.group(1).toUpperCase(); + String arguments = matcher.group(2); + + IASTLiteralTextNode keywordNode = ASTSBVFactory.createPreprocessorLiteralTextNode(keyword); + ISourceRegion keywordRegion = ASTUtils.createDocumentSourceRegion( + document, + path, + new Region(lineOffset + matcher.start(1), keyword.length())); + keywordNode.setSourceRegion(keywordRegion); + + if (arguments != null) { + IASTLiteralTextNode argumentsNode = ASTSBVFactory.createPreprocessorLiteralTextNode(arguments); + ISourceRegion argumentsRegion = ASTUtils.createDocumentSourceRegion( + document, + path, + new Region(lineOffset + matcher.start(2), arguments.length())); + argumentsNode.setSourceRegion(argumentsRegion); + + stmt = ASTSBVFactory.createSBVArgumentStatement(keywordNode, argumentsNode); + } else { + stmt = ASTSBVFactory.createSBVFlagStatement(keywordNode); + } + } + stmt.setSourceRegion(region); + + return stmt; + } + + /** + * @return + */ + private MessageLocation getMessageLocation() { + return new MessageLocation(path, lineNumber, 0); + } + +}